npc5 document

This commit is contained in:
theo3 2024-01-01 12:12:05 -08:00
parent 983412cc77
commit 5324928f44
20 changed files with 539 additions and 500 deletions

View File

@ -348,8 +348,8 @@ sub_080041E8: @ 0x080041E8
subs r0, r0, r2 subs r0, r0, r2
subs r1, r1, r3 subs r1, r1, r3
thumb_func_start sub_080041EC thumb_func_start CalcDistance
sub_080041EC: @ 0x080041EC CalcDistance: @ 0x080041EC
adds r2, r0, #0 adds r2, r0, #0
muls r0, r2, r0 muls r0, r2, r0
adds r3, r1, #0 adds r3, r1, #0

View File

@ -301,8 +301,8 @@ CalculateDirectionTo: @ 0x080045D4
ldr r3, _08004694 @ =ram_CalcCollisionDirection ldr r3, _08004694 @ =ram_CalcCollisionDirection
bx r3 bx r3
non_word_aligned_thumb_func_start sub_080045DA non_word_aligned_thumb_func_start CalcOffsetAngle
sub_080045DA: @ 0x080045DA CalcOffsetAngle: @ 0x080045DA
push {r0, r1, r4, r5, r6, lr} push {r0, r1, r4, r5, r6, lr}
movs r6, #0x40 movs r6, #0x40
cmp r0, #0 cmp r0, #0

View File

@ -339,7 +339,7 @@ gUnk_0810B65C:: @ 0810B65C
gUnk_0810B65E:: @ 0810B65E gUnk_0810B65E:: @ 0810B65E
.incbin "npc5/gUnk_0810B65E.bin" .incbin "npc5/gUnk_0810B65E.bin"
gUnk_0810B660:: @ 0810B660 gZeldaFollowerText:: @ 0810B660
.4byte gUnk_0810B650 .4byte gUnk_0810B650
.4byte gUnk_0810B652 .4byte gUnk_0810B652
.4byte gUnk_0810B654 .4byte gUnk_0810B654

View File

@ -39,7 +39,7 @@ extern void ResetCollisionLayer(struct Entity_*);
extern void sub_08004596(struct Entity_*, u32); extern void sub_08004596(struct Entity_*, u32);
extern u32 sub_080045B4(struct Entity_*, u32, u32); extern u32 sub_080045B4(struct Entity_*, u32, u32);
extern u32 CalculateDirectionTo(u32, u32, u32, u32); extern u32 CalculateDirectionTo(u32, u32, u32, u32);
extern u32 sub_080045DA(s32, s32); extern u32 CalcOffsetAngle(s32, s32);
extern u32 sub_080086B4(u32, u32, const u8*); extern u32 sub_080086B4(u32, u32, const u8*);
extern u32 ResolveCollisionLayer(struct Entity_*); extern u32 ResolveCollisionLayer(struct Entity_*);
extern void sub_0800417E(struct Entity_*, u32); extern void sub_0800417E(struct Entity_*, u32);

View File

@ -189,7 +189,7 @@ void Enemy64_Action2_SubAction0(Enemy64Entity* this) {
} }
void Enemy64_Action2_SubAction1(Enemy64Entity* this) { void Enemy64_Action2_SubAction1(Enemy64Entity* this) {
u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
if (4 < (((super->direction - tmp) + 2) & 0xff)) { if (4 < (((super->direction - tmp) + 2) & 0xff)) {
if (((tmp - super->direction) & 0x80) != 0) { if (((tmp - super->direction) & 0x80) != 0) {
super->direction--; super->direction--;
@ -290,7 +290,7 @@ void Enemy64_Action3(Enemy64Entity* this) {
} }
void Enemy64_Action3_SubAction0(Enemy64Entity* this) { void Enemy64_Action3_SubAction0(Enemy64Entity* this) {
u32 tmp = sub_080045DA(gRoomControls.origin_x + 0xa8 - super->x.HALF.HI, u32 tmp = CalcOffsetAngle(gRoomControls.origin_x + 0xa8 - super->x.HALF.HI,
gRoomControls.origin_y + 0x80 - super->y.HALF.HI); gRoomControls.origin_y + 0x80 - super->y.HALF.HI);
if (tmp != super->direction) { if (tmp != super->direction) {
if (((tmp - super->direction) & 0x80) != 0) { if (((tmp - super->direction) & 0x80) != 0) {
@ -490,7 +490,7 @@ void sub_080499F0(Enemy64Entity* this) {
((this->unk_7c & 1) == 0)) { ((this->unk_7c & 1) == 0)) {
if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24) && if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24) &&
((this->unk_7c & 2) == 0)) { ((this->unk_7c & 2) == 0)) {
tmp = sub_080045DA((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, tmp = CalcOffsetAngle((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
(s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); (s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.x.WORD = super->x.WORD + gSineTable[tmp] * 0x2400; gPlayerEntity.base.x.WORD = super->x.WORD + gSineTable[tmp] * 0x2400;
gPlayerEntity.base.y.WORD = super->y.WORD + gSineTable[tmp + 0x40] * -0x2400; gPlayerEntity.base.y.WORD = super->y.WORD + gSineTable[tmp + 0x40] * -0x2400;

View File

@ -260,7 +260,7 @@ void sub_08046AE8(GyorgMaleEntity* this) {
} }
void sub_08046B18(GyorgMaleEntity* this) { void sub_08046B18(GyorgMaleEntity* this) {
u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
if (tmp != super->direction) { if (tmp != super->direction) {
if (((tmp - super->direction) & 0xFF) > 0x80) { if (((tmp - super->direction) & 0xFF) > 0x80) {
this->unk_76 -= 0x100; this->unk_76 -= 0x100;
@ -283,13 +283,13 @@ void sub_08046B8C(GyorgMaleEntity* this) {
this->unk_82 = gRoomControls.origin_y + 0x210; this->unk_82 = gRoomControls.origin_y + 0x210;
sub_08047D88(this); sub_08047D88(this);
} else { } else {
super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8); sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8);
} }
} }
void sub_08046C04(GyorgMaleEntity* this) { void sub_08046C04(GyorgMaleEntity* this) {
u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
if (tmp != super->direction) { if (tmp != super->direction) {
if (((tmp - super->direction) & 0xFF) > 0x80) { if (((tmp - super->direction) & 0xFF) > 0x80) {
this->unk_76 -= 0x100; this->unk_76 -= 0x100;
@ -311,7 +311,7 @@ void sub_08046C88(GyorgMaleEntity* this) {
sub_08048178(this, sub_08048158(this->unk_70)); sub_08048178(this, sub_08048158(this->unk_70));
sub_08047D88(this); sub_08047D88(this);
} else { } else {
super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8); sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8);
} }
} }
@ -348,7 +348,7 @@ void sub_08046D44(GyorgMaleEntity* this) {
} }
void sub_08046D98(GyorgMaleEntity* this) { void sub_08046D98(GyorgMaleEntity* this) {
u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
if (tmp != super->direction) { if (tmp != super->direction) {
if (((tmp - super->direction) & 0xFF) > 0x80) { if (((tmp - super->direction) & 0xFF) > 0x80) {
this->unk_76 -= 0x100; this->unk_76 -= 0x100;
@ -369,7 +369,7 @@ void sub_08046E0C(GyorgMaleEntity* this) {
this->unk_76 = super->direction << 8; this->unk_76 = super->direction << 8;
sub_08047D88(this); sub_08047D88(this);
} else { } else {
super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8); sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8);
} }
} }
@ -456,7 +456,7 @@ void sub_08046FE8(GyorgMaleEntity* this) {
} }
void sub_0804702C(GyorgMaleEntity* this) { void sub_0804702C(GyorgMaleEntity* this) {
u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
if (((super->direction - tmp + 2) & 0xFF) > 4) { if (((super->direction - tmp + 2) & 0xFF) > 4) {
if ((tmp - super->direction) & 0x80) { if ((tmp - super->direction) & 0x80) {
super->direction--; super->direction--;
@ -607,7 +607,7 @@ void sub_080473B8(GyorgMaleEntity* this) {
} }
void sub_080473F0(GyorgMaleEntity* this) { void sub_080473F0(GyorgMaleEntity* this) {
u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
if (((super->direction - tmp + 2) & 0xFF) > 4) { if (((super->direction - tmp + 2) & 0xFF) > 4) {
s32 tmp2 = tmp - super->direction; s32 tmp2 = tmp - super->direction;
if (tmp2 & 0x80) { if (tmp2 & 0x80) {
@ -791,7 +791,7 @@ void sub_080477F0(GyorgMaleEntity* this) {
if (super->speed < 0x300) { if (super->speed < 0x300) {
super->speed += 8; super->speed += 8;
} }
super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
sub_08047E48(this); sub_08047E48(this);
if (!EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x80)) { if (!EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x80)) {
super->action = 2; super->action = 2;
@ -896,7 +896,7 @@ void sub_08047978(GyorgMaleEntity* this) {
void sub_08047B08(GyorgMaleEntity* this) { void sub_08047B08(GyorgMaleEntity* this) {
sub_08047D88(this); sub_08047D88(this);
super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
super->speed = 0x200; super->speed = 0x200;
sub_08047E58(this); sub_08047E58(this);
if (!EntityWithinDistance(super, this->unk_80, this->unk_82, 4)) if (!EntityWithinDistance(super, this->unk_80, this->unk_82, 4))
@ -1066,7 +1066,7 @@ void sub_08047EA4(GyorgMaleEntity* this, u32 unk1) {
return; return;
if (this->unk_7c & 1) { if (this->unk_7c & 1) {
tmp2 = sub_08047F68(this) << 8; tmp2 = sub_08047F68(this) << 8;
dir = sub_080045DA(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, dir = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
tmp = dir - (tmp / 256); tmp = dir - (tmp / 256);
tmp &= 0xFF; tmp &= 0xFF;
@ -1149,7 +1149,7 @@ void sub_08048004(GyorgMaleEntity* this) {
if (b != 3) { if (b != 3) {
if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24)) { if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24)) {
if (!(this->unk_7c & 2)) { if (!(this->unk_7c & 2)) {
u32 tmp = sub_080045DA(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, u32 tmp = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.x.WORD = super->x.WORD + (gSineTable[tmp] * 9216); gPlayerEntity.base.x.WORD = super->x.WORD + (gSineTable[tmp] * 9216);
gPlayerEntity.base.y.WORD = super->y.WORD - (gSineTable[tmp + 0x40] * 9216); gPlayerEntity.base.y.WORD = super->y.WORD - (gSineTable[tmp + 0x40] * 9216);

View File

@ -167,11 +167,11 @@ void OctorokBoss_Hit_SubAction1(OctorokBossEntity* this) {
if (diffX > 8 || diffY > 8) { if (diffX > 8 || diffY > 8) {
this->heap->field_0x2 = 1; this->heap->field_0x2 = 1;
#if defined(JP) || defined(DEMO_JP) || defined(EU) #if defined(JP) || defined(DEMO_JP) || defined(EU)
super->direction = ((s32)sub_080045DA((((gRoomControls.origin_x + 0x108) << 0x10) - super->x.WORD), super->direction = ((s32)CalcOffsetAngle((((gRoomControls.origin_x + 0x108) << 0x10) - super->x.WORD),
(((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >> (((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >>
3; 3;
#else #else
super->direction = ((s32)sub_080045DA(gRoomControls.origin_x + 0x108 - super->x.HALF.HI, super->direction = ((s32)CalcOffsetAngle(gRoomControls.origin_x + 0x108 - super->x.HALF.HI,
gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >> gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >>
3; 3;
#endif #endif
@ -689,7 +689,7 @@ void OctorokBoss_Action1_AimTowardsPlayer(OctorokBossEntity* this) {
s32 tmp1; s32 tmp1;
s32 tmp2; s32 tmp2;
tmp1 = (u8)(sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) - tmp1 = (u8)(CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) -
(((u8)(-this->angle.HALF.HI) ^ 0x80))); (((u8)(-this->angle.HALF.HI) ^ 0x80)));
if (IS_FROZEN(this) == FALSE) { if (IS_FROZEN(this) == FALSE) {
tmp2 = 8; tmp2 = 8;
@ -898,7 +898,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
if (this->unk_80 == 0) { if (this->unk_80 == 0) {
super->direction = super->direction =
sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD); CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD);
tmp = ((u8) - (this->angle.HALF.HI + 0x80)) - super->direction; tmp = ((u8) - (this->angle.HALF.HI + 0x80)) - super->direction;
if (tmp < 0) { if (tmp < 0) {
tmp = -tmp; tmp = -tmp;
@ -912,7 +912,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
this->unk_80 = 1; this->unk_80 = 1;
this->timer = 2; this->timer = 2;
this->heap->targetAngle = this->heap->targetAngle =
sub_080045DA((gRoomControls.origin_x + 0x108) * 0x10000 - super->x.WORD, CalcOffsetAngle((gRoomControls.origin_x + 0x108) * 0x10000 - super->x.WORD,
(gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD); (gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD);
this->heap->targetAngle = (u8) - (this->heap->targetAngle + 0x80); this->heap->targetAngle = (u8) - (this->heap->targetAngle + 0x80);
SoundReq(SFX_ED); SoundReq(SFX_ED);
@ -956,7 +956,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
} else { } else {
this->timer--; this->timer--;
if ((gPlayerState.flags == PL_FROZEN) && (this->timer == 0x3c)) { if ((gPlayerState.flags == PL_FROZEN) && (this->timer == 0x3c)) {
tmp = sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD); tmp = CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD);
if ((u8)((tmp - ((u8) - this->angle.HALF.HI ^ 0x80))) > 0x80) { if ((u8)((tmp - ((u8) - this->angle.HALF.HI ^ 0x80))) > 0x80) {
this->heap->targetAngle = this->angle.HALF.HI + 0x30; this->heap->targetAngle = this->angle.HALF.HI + 0x30;
} else { } else {
@ -1178,7 +1178,7 @@ void sub_08036AF0(OctorokBossEntity* this, s32 radius, s32 angleSpeed) {
continue; continue;
} else { } else {
heap->tailObjects[index - 1]->angle.HALF.HI = heap->tailObjects[index - 1]->angle.HALF.HI =
sub_080045DA(heap->tailObjects[index - 1]->base.x.WORD - heap->tailObjects[index]->base.x.WORD, CalcOffsetAngle(heap->tailObjects[index - 1]->base.x.WORD - heap->tailObjects[index]->base.x.WORD,
heap->tailObjects[index - 1]->base.y.WORD - heap->tailObjects[index]->base.y.WORD); heap->tailObjects[index - 1]->base.y.WORD - heap->tailObjects[index]->base.y.WORD);
tmp = FixedMul(gSineTable[heap->tailObjects[index - 1]->angle.HALF.HI], radius << 4); tmp = FixedMul(gSineTable[heap->tailObjects[index - 1]->angle.HALF.HI], radius << 4);
tmp = FixedDiv(tmp, 0x100); tmp = FixedDiv(tmp, 0x100);

View File

@ -38,7 +38,7 @@ void sub_0806D8A0(Entity* this, ScriptExecutionContext* context) {
context->y.HALF.HI = yOffset; context->y.HALF.HI = yOffset;
xOffset -= this->x.HALF.HI; xOffset -= this->x.HALF.HI;
this->direction = sub_080045DA(xOffset, yOffset - this->y.HALF.HI); this->direction = CalcOffsetAngle(xOffset, yOffset - this->y.HALF.HI);
this->animationState = (this->animationState & 0x80) | gUnk_08114134[this->direction >> 4]; this->animationState = (this->animationState & 0x80) | gUnk_08114134[this->direction >> 4];
} }

View File

@ -154,7 +154,7 @@ void sub_0806991C(GormanEntity* this, ScriptExecutionContext* context) {
context->unk_19 = 8; context->unk_19 = 8;
context->postScriptActions |= 2; context->postScriptActions |= 2;
context->condition = 0; context->condition = 0;
tmp = sub_080045DA(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI); tmp = CalcOffsetAngle(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI);
super->direction = tmp; super->direction = tmp;
super->animationState = (super->animationState & 0x80) | gUnk_08111C74[(tmp << 0x18) >> 0x1c]; super->animationState = (super->animationState & 0x80) | gUnk_08111C74[(tmp << 0x18) >> 0x1c];
gActiveScriptInfo.flags |= 1; gActiveScriptInfo.flags |= 1;
@ -170,7 +170,7 @@ void sub_080699AC(GormanEntity* this, ScriptExecutionContext* context) {
context->unk_19 = 8; context->unk_19 = 8;
context->postScriptActions |= 2; context->postScriptActions |= 2;
context->condition = 0; context->condition = 0;
tmp = sub_080045DA(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI); tmp = CalcOffsetAngle(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI);
super->direction = tmp; super->direction = tmp;
super->animationState = (super->animationState & 0x80) | gUnk_08111C8C[(tmp << 0x18) >> 0x1c]; super->animationState = (super->animationState & 0x80) | gUnk_08111C8C[(tmp << 0x18) >> 0x1c];
gActiveScriptInfo.flags |= 1; gActiveScriptInfo.flags |= 1;

View File

@ -524,7 +524,7 @@ void sub_080626E0(Entity* this, ScriptExecutionContext* context) {
} }
if (--context->unk_19 == 0) { if (--context->unk_19 == 0) {
context->unk_19 = 10; context->unk_19 = 10;
uVar4 = sub_080045DA(context->x.HALF.HI - this->x.HALF.HI, context->y.HALF.HI - this->y.HALF.HI); uVar4 = CalcOffsetAngle(context->x.HALF.HI - this->x.HALF.HI, context->y.HALF.HI - this->y.HALF.HI);
this->direction = (u8)uVar4; this->direction = (u8)uVar4;
uVar4 = Random(); uVar4 = Random();
this->direction = (this->direction + uVar4 % 0xb) - 5; this->direction = (this->direction + uVar4 % 0xb) - 5;

File diff suppressed because it is too large Load Diff

View File

@ -710,7 +710,7 @@ void sub_0809567C(CutsceneMiscObjectEntity* this) {
super->action = 3; super->action = 3;
super->subAction = 1; super->subAction = 1;
super->speed = 0x400; super->speed = 0x400;
super->direction = sub_080045DA(super->x.WORD - ((s16)this->px << 16), super->y.WORD - ((s16)this->py << 16)); super->direction = CalcOffsetAngle(super->x.WORD - ((s16)this->px << 16), super->y.WORD - ((s16)this->py << 16));
} }
void CutsceneMiscObject_Type15(CutsceneMiscObjectEntity* this) { void CutsceneMiscObject_Type15(CutsceneMiscObjectEntity* this) {

View File

@ -83,10 +83,10 @@ void EvilSpirit_Action1(EvilSpiritEntity* this) {
this->unk7a = this->unk7c; this->unk7a = this->unk7c;
super->speed = 0x300; super->speed = 0x300;
super->direction = super->direction =
sub_080045DA(super->parent->x.WORD - super->x.WORD, super->parent->y.WORD - super->y.WORD) ^ 0x80; CalcOffsetAngle(super->parent->x.WORD - super->x.WORD, super->parent->y.WORD - super->y.WORD) ^ 0x80;
} else { } else {
super->speed = 0x600; super->speed = 0x600;
dir = sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^ dir = CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^
0x80; 0x80;
if (dir != super->direction) { if (dir != super->direction) {
if ((u8)(dir - super->direction) > 0x80) { if ((u8)(dir - super->direction) > 0x80) {
@ -178,7 +178,7 @@ void EvilSpirit_Action3(EvilSpiritEntity* this) {
short iVar4; short iVar4;
int iVar6; int iVar6;
super->direction = sub_080045DA(this->x - super->x.WORD, this->y - super->y.WORD); super->direction = CalcOffsetAngle(this->x - super->x.WORD, this->y - super->y.WORD);
if ((super->contactFlags & 0x7f) == 0x13) { if ((super->contactFlags & 0x7f) == 0x13) {
super->speed = 0x100; super->speed = 0x100;
super->gustJarTolerance--; super->gustJarTolerance--;

View File

@ -20,7 +20,7 @@ typedef struct {
/*0x70*/ u8 unk_70; /*0x70*/ u8 unk_70;
} FileScreenObjectsEntity; } FileScreenObjectsEntity;
extern u32 sub_080041EC(s32, s32); extern u32 CalcDistance(s32, s32);
static bool32 sub_0808E950(void); static bool32 sub_0808E950(void);
static void sub_0808EABC(FileScreenObjectsEntity*); static void sub_0808EABC(FileScreenObjectsEntity*);
@ -550,14 +550,14 @@ static u32 sub_0808EF6C(FileScreenObjectsEntity* this) {
return 0; return 0;
} }
var4 = var7 = sub_080041EC(var0, var2); var4 = var7 = CalcDistance(var0, var2);
var4 += 128; var4 += 128;
var7 = var4 + var7 * 16; var7 = var4 + var7 * 16;
if (this->unk_6c < var7) { if (this->unk_6c < var7) {
var7 = this->unk_6c; var7 = this->unk_6c;
} }
super->speed = var7; super->speed = var7;
super->direction = sub_080045DA(var0, var2) >> 3; super->direction = CalcOffsetAngle(var0, var2) >> 3;
LinearMoveUpdate(super); LinearMoveUpdate(super);
return 1; return 1;
} }

View File

@ -433,7 +433,7 @@ void sub_0809E0D4(KeyStealingTakkuriEntity* this, ScriptExecutionContext* contex
varY2 = varY; varY2 = varY;
if (--context->unk_19 == 0) { if (--context->unk_19 == 0) {
context->unk_19 = 8; context->unk_19 = 8;
super->direction = sub_080045DA(varX2 - super->x.HALF.HI, varY2 - super->y.HALF.HI); super->direction = CalcOffsetAngle(varX2 - super->x.HALF.HI, varY2 - super->y.HALF.HI);
} }
varX3 = super->x.HALF.HI - varX2; varX3 = super->x.HALF.HI - varX2;
varY3 = super->y.HALF.HI - varY2; varY3 = super->y.HALF.HI - varY2;

View File

@ -117,5 +117,5 @@ void sub_0809F448(Entity* this) {
break; break;
} }
this->speed = (tmp > 0 ? tmp : -tmp) / (tmp2->unk_1 << 8); this->speed = (tmp > 0 ? tmp : -tmp) / (tmp2->unk_1 << 8);
this->direction = sub_080045DA(tmp, 0) >> 3; this->direction = CalcOffsetAngle(tmp, 0) >> 3;
} }

View File

@ -181,7 +181,7 @@ void OctorokBossObject_Action1(OctorokBossObjectEntity* this) {
return; return;
} }
case 1: case 1:
super->direction = sub_080045DA(this->helper->tailObjects[super->timer]->x.WORD - super->x.WORD, super->direction = CalcOffsetAngle(this->helper->tailObjects[super->timer]->x.WORD - super->x.WORD,
this->helper->tailObjects[super->timer]->y.WORD - super->y.WORD); this->helper->tailObjects[super->timer]->y.WORD - super->y.WORD);
LinearMoveAngle(super, super->speed, super->direction); LinearMoveAngle(super, super->speed, super->direction);
if (EntityInRectRadius(super, this->helper->tailObjects[super->timer], 2, 2) == 0) { if (EntityInRectRadius(super, this->helper->tailObjects[super->timer], 2, 2) == 0) {
@ -207,7 +207,7 @@ void OctorokBossObject_Action1(OctorokBossObjectEntity* this) {
case 2: case 2:
if (super->parent->type2 == 3) { if (super->parent->type2 == 3) {
Entity* object = ((OctorokBossObjectEntity*)super->parent)->helper->mouthObject; Entity* object = ((OctorokBossObjectEntity*)super->parent)->helper->mouthObject;
super->direction = sub_080045DA(object->x.WORD - super->x.WORD, object->y.WORD - super->y.WORD); super->direction = CalcOffsetAngle(object->x.WORD - super->x.WORD, object->y.WORD - super->y.WORD);
LinearMoveAngle(super, 0x280, super->direction); LinearMoveAngle(super, 0x280, super->direction);
if (sub_0806FC80(super, super->parent, 0x48) == 0) { if (sub_0806FC80(super, super->parent, 0x48) == 0) {
return; return;

View File

@ -199,7 +199,7 @@ void sub_080845DC(SpecialFxObject* this) {
void sub_080845F8(SpecialFxObject* this) { void sub_080845F8(SpecialFxObject* this) {
if (((8 - (super->x.HALF.HI & 0xF)) | (8 - (super->y.HALF.HI & 0xF))) != 0) { if (((8 - (super->x.HALF.HI & 0xF)) | (8 - (super->y.HALF.HI & 0xF))) != 0) {
super->direction = sub_080045DA((8 - (super->x.HALF.HI & 0xF)), (8 - (super->y.HALF.HI & 0xF))) >> 3; super->direction = CalcOffsetAngle((8 - (super->x.HALF.HI & 0xF)), (8 - (super->y.HALF.HI & 0xF))) >> 3;
LinearMoveUpdate(super); LinearMoveUpdate(super);
} }
sub_08084630(this); sub_08084630(this);

View File

@ -25,28 +25,27 @@
#include "screenTransitions.h" #include "screenTransitions.h"
#include "sound.h" #include "sound.h"
#define GRAVITY_RATE Q_8_8(32) #define kGravityRate Q_8_8(32)
#define SLOPE_SPEED_MODIFIER 0x50 #define kWalkSpeedSlopeSubtractor Q_8_8(0.3125)
#define kWalkSpeed Q_8_8(1.25)
#define kWalkSpeedRolling Q_8_8(2.0)
#define kWalkSpeedGustJar Q_8_8(0.5)
#define kWalkSpeedShield Q_8_8(0.75)
#define kWalkSpeedSwordCharge Q_8_8(0.875)
#define kWalkSpeedBurning Q_8_8(3)
#define WALK_SPEED Q_8_8(1.25) #define kJumpSpeedForward Q_8_8(1)
#define ROLL_SPEED Q_8_8(2.0)
#define GUST_JAR_SPEED Q_8_8(0.5)
#define SHIELDING_SPEED Q_8_8(0.75)
#define SWORD_CHARGE_SPEED Q_8_8(0.875)
#define BURNING_SPEED Q_8_8(3)
#define JUMP_SPEED_FWD Q_8_8(1)
/* Jumping out of a hole */ /* Jumping out of a hole */
#define JUMP_SPEED_HOLE_FWD Q_8_8(0.46875) #define kJumpSpeedHoleForward Q_8_8(0.46875)
#define JUMP_SPEED_HOLE_Z Q_16_16(1.625) #define kJumpSpeedHoleZ Q_16_16(1.625)
/* Bouncing off a wall */ /* Bouncing off a wall */
#define BOUNCE_SPEED_FWD Q_8_8(1.0) #define kBounceSpeedForward Q_8_8(1.0)
#define BOUNCE_SPEED_Z Q_16_16(2.0) #define kBounceSpeedZ Q_16_16(2.0)
#define PULL_SPEED Q_8_8(0.5) #define kPullSpeed Q_8_8(0.5)
#define PUSH_SPEED Q_8_8(0.5) #define kPushSpeed Q_8_8(0.5)
#define FALL_DAMAGE 2 #define kFallDamage 2
typedef void(PlayerEntityAction)(PlayerEntity*); typedef void(PlayerEntityAction)(PlayerEntity*);
@ -392,7 +391,7 @@ static void PlayerNormal(PlayerEntity* this) {
if (gPlayerState.flags & PL_CAPTURED) { if (gPlayerState.flags & PL_CAPTURED) {
super->spritePriority.b1 = 0; super->spritePriority.b1 = 0;
super->knockbackDuration = 0; super->knockbackDuration = 0;
super->speed = WALK_SPEED; super->speed = kWalkSpeed;
gPlayerState.pushedObject = 0x80; gPlayerState.pushedObject = 0x80;
gPlayerState.framestate = PL_STATE_TRAPPED; gPlayerState.framestate = PL_STATE_TRAPPED;
if ((super->animationState >> 1) + 92 == super->animIndex && (u16)super->spriteIndex == 2) if ((super->animationState >> 1) + 92 == super->animIndex && (u16)super->spriteIndex == 2)
@ -421,14 +420,14 @@ static void PlayerNormal(PlayerEntity* this) {
} }
if (!gPlayerState.swim_state && (gPlayerState.jump_status & 0xC0) == 0) { if (!gPlayerState.swim_state && (gPlayerState.jump_status & 0xC0) == 0) {
if (gPlayerState.shield_status || gPlayerState.bow_state) { if (gPlayerState.shield_status || gPlayerState.bow_state) {
super->speed = SHIELDING_SPEED; super->speed = kWalkSpeedShield;
} else { } else {
if (gPlayerState.sword_state) { if (gPlayerState.sword_state) {
super->speed = SWORD_CHARGE_SPEED; super->speed = kWalkSpeedSwordCharge;
} else if (gPlayerState.field_0x1c) { } else if (gPlayerState.field_0x1c) {
super->speed = GUST_JAR_SPEED; super->speed = kWalkSpeedGustJar;
} else { } else {
super->speed = WALK_SPEED; super->speed = kWalkSpeed;
} }
} }
} }
@ -536,7 +535,7 @@ static void PlayerNormal(PlayerEntity* this) {
if ((gPlayerState.sword_state & 0x10) == 0) { if ((gPlayerState.sword_state & 0x10) == 0) {
super->direction = gPlayerState.direction; super->direction = gPlayerState.direction;
if (gPlayerState.flags & PL_BURNING) { if (gPlayerState.flags & PL_BURNING) {
super->speed = BURNING_SPEED; super->speed = kWalkSpeedBurning;
if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0)
super->direction = 4 * (super->animationState & 0xE); super->direction = 4 * (super->animationState & 0xE);
DeleteClones(); DeleteClones();
@ -624,7 +623,7 @@ static void PlayerFallUpdate(PlayerEntity* this) {
RespawnPlayer(); RespawnPlayer();
gPlayerState.field_0xa = 0; gPlayerState.field_0xa = 0;
super->iframes = 32; super->iframes = 32;
ModHealth(-FALL_DAMAGE); ModHealth(-kFallDamage);
} }
} }
} }
@ -641,19 +640,19 @@ static void PlayerBounce(PlayerEntity* this) {
static void PlayerBounceInit(PlayerEntity* this) { static void PlayerBounceInit(PlayerEntity* this) {
COLLISION_OFF(super); COLLISION_OFF(super);
super->direction = DirectionTurnAround(Direction8FromAnimationState(AnimationStateWalk(super->animationState))); super->direction = DirectionTurnAround(Direction8FromAnimationState(AnimationStateWalk(super->animationState)));
super->speed = BOUNCE_SPEED_FWD; super->speed = kBounceSpeedForward;
super->knockbackDuration = 0; super->knockbackDuration = 0;
super->subAction++; super->subAction++;
super->timer = gPlayerState.field_0x38; super->timer = gPlayerState.field_0x38;
super->spriteIndex = 1; super->spriteIndex = 1;
if (!(gPlayerState.flags & PL_MINISH)) { if (!(gPlayerState.flags & PL_MINISH)) {
super->zVelocity = BOUNCE_SPEED_Z; super->zVelocity = kBounceSpeedZ;
gPlayerState.animation = ANIM_BOUNCE; gPlayerState.animation = ANIM_BOUNCE;
InitScreenShake(16, 0); InitScreenShake(16, 0);
} else { } else {
gPlayerState.animation = ANIM_BOUNCE_MINISH; gPlayerState.animation = ANIM_BOUNCE_MINISH;
super->zVelocity = (BOUNCE_SPEED_Z * 3) / 4; super->zVelocity = (kBounceSpeedZ * 3) / 4;
} }
gPlayerState.jump_status = 0x80; gPlayerState.jump_status = 0x80;
@ -668,7 +667,7 @@ static void PlayerBounceUpdate(PlayerEntity* this) {
UpdatePlayerMovement(); UpdatePlayerMovement();
UpdateFloorType(); UpdateFloorType();
if (CheckQueuedAction() || GravityUpdate(super, GRAVITY_RATE)) if (CheckQueuedAction() || GravityUpdate(super, kGravityRate))
return; return;
gPlayerState.jump_status = 0; gPlayerState.jump_status = 0;
@ -866,7 +865,7 @@ static void PlayerJumpInit(PlayerEntity* this) {
temp <<= 12; temp <<= 12;
super->zVelocity = temp; super->zVelocity = temp;
super->speed = JUMP_SPEED_FWD; super->speed = kJumpSpeedForward;
DeleteClones(); DeleteClones();
SoundReq(SFX_PLY_JUMP); SoundReq(SFX_PLY_JUMP);
SoundReq(SFX_PLY_VO4); SoundReq(SFX_PLY_VO4);
@ -885,7 +884,7 @@ static void sub_08071130(PlayerEntity* this) {
LinearMoveUpdate(super); LinearMoveUpdate(super);
if (GravityUpdate(super, GRAVITY_RATE)) if (GravityUpdate(super, kGravityRate))
return; return;
gPlayerState.jump_status = 0; gPlayerState.jump_status = 0;
@ -1041,7 +1040,7 @@ static void PortalJumpOnUpdate(PlayerEntity* this) {
if ((super->x.HALF.HI != x) || (super->y.HALF.HI != y)) { if ((super->x.HALF.HI != x) || (super->y.HALF.HI != y)) {
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gArea.portal_x, gArea.portal_y); super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gArea.portal_x, gArea.portal_y);
super->speed = JUMP_SPEED_FWD; super->speed = kJumpSpeedForward;
UpdatePlayerMovement(); UpdatePlayerMovement();
} }
@ -1081,7 +1080,7 @@ static void PortalStandUpdate(PlayerEntity* this) {
super->direction = gPlayerState.direction; super->direction = gPlayerState.direction;
super->animationState = Direction8ToAnimationState(super->direction); super->animationState = Direction8ToAnimationState(super->direction);
super->zVelocity = Q_16_16(2.0); super->zVelocity = Q_16_16(2.0);
super->speed = JUMP_SPEED_FWD; super->speed = kJumpSpeedForward;
super->action = PLAYER_MINISH; super->action = PLAYER_MINISH;
super->subAction = 7; super->subAction = 7;
super->subtimer = 0; super->subtimer = 0;
@ -1216,7 +1215,7 @@ static void PortalShrinkUpdate(PlayerEntity* this) {
static void PortalEnterUpdate(PlayerEntity* this) { static void PortalEnterUpdate(PlayerEntity* this) {
if (super->timer == 0) { if (super->timer == 0) {
if (GravityUpdate(super, GRAVITY_RATE)) if (GravityUpdate(super, kGravityRate))
return; return;
super->spriteSettings.draw = FALSE; super->spriteSettings.draw = FALSE;
@ -1311,7 +1310,7 @@ static void PlayerTalkEzlo_Init(PlayerEntity* this) {
return; return;
} }
if (!GravityUpdate(super, GRAVITY_RATE)) { if (!GravityUpdate(super, kGravityRate)) {
gPlayerState.jump_status = 0; gPlayerState.jump_status = 0;
} }
} }
@ -1406,7 +1405,7 @@ static void PlayerPushInit(PlayerEntity* this) {
super->timer = 0; super->timer = 0;
super->subtimer = 1; super->subtimer = 1;
} else { } else {
super->speed = (gPlayerState.flags & PL_MINISH) ? PUSH_SPEED / 2 : PUSH_SPEED; super->speed = (gPlayerState.flags & PL_MINISH) ? kPushSpeed / 2 : kPushSpeed;
} }
PlayerPushUpdate(this); PlayerPushUpdate(this);
} }
@ -1419,19 +1418,19 @@ static void PlayerPushUpdate(PlayerEntity* this) {
static const PushFrame sPushFrames[] = { static const PushFrame sPushFrames[] = {
{ 5, 0 }, { 5, 0 },
{ 1, PUSH_SPEED * 2 }, { 1, kPushSpeed * 2 },
{ 5, 0 }, { 5, 0 },
{ 1, PUSH_SPEED * 2 }, { 1, kPushSpeed * 2 },
{ 2, 0 }, { 2, 0 },
{ 1, PUSH_SPEED * 2 }, { 1, kPushSpeed * 2 },
{ 2, 0 }, { 2, 0 },
{ 1, PUSH_SPEED * 2 }, { 1, kPushSpeed * 2 },
{ 3, 0 }, { 3, 0 },
{ 1, PUSH_SPEED * 2 }, { 1, kPushSpeed * 2 },
{ 8, PUSH_SPEED * 3 / 4 }, { 8, kPushSpeed * 3 / 4 },
{ 8, PUSH_SPEED * 3 / 4 }, { 8, kPushSpeed * 3 / 4 },
{ 8, PUSH_SPEED * 3 / 4 }, { 8, kPushSpeed * 3 / 4 },
{ 8, PUSH_SPEED / 2 }, { 8, kPushSpeed / 2 },
{ 0xFF, 0 }, { 0xFF, 0 },
}; };
@ -1491,7 +1490,7 @@ static void PlayerMinishDieInit(PlayerEntity* this) {
if (gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS)) if (gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS))
return; return;
if (GravityUpdate(super, GRAVITY_RATE)) { if (GravityUpdate(super, kGravityRate)) {
if (gPlayerState.flags & PL_NO_CAP) if (gPlayerState.flags & PL_NO_CAP)
gPlayerState.animation = ANIM_JUMP_NOCAP; gPlayerState.animation = ANIM_JUMP_NOCAP;
else else
@ -1637,7 +1636,7 @@ static void sub_08071E04(PlayerEntity* this) {
static void sub_08071E74(PlayerEntity* this) { static void sub_08071E74(PlayerEntity* this) {
u32 temp; u32 temp;
GravityUpdate(super, GRAVITY_RATE); GravityUpdate(super, kGravityRate);
UpdatePlayerMovement(); UpdatePlayerMovement();
temp = super->timer--; temp = super->timer--;
if (temp == 0) if (temp == 0)
@ -1703,7 +1702,7 @@ static void PlayerFrozenInit(PlayerEntity* this) {
} }
static void PlayerFrozenUpdate(PlayerEntity* this) { static void PlayerFrozenUpdate(PlayerEntity* this) {
if (GravityUpdate(super, GRAVITY_RATE) == 0) { if (GravityUpdate(super, kGravityRate) == 0) {
UpdateSpriteForCollisionLayer(super); UpdateSpriteForCollisionLayer(super);
gPlayerState.jump_status = 0; gPlayerState.jump_status = 0;
if (gPlayerState.field_0x14 == 0) { if (gPlayerState.field_0x14 == 0) {
@ -1807,7 +1806,7 @@ static void sub_08072168(PlayerEntity* this) {
u32 i; u32 i;
UpdateAnimationSingleFrame(super); UpdateAnimationSingleFrame(super);
i = (u16)sub_0806F854(super, 0, -12) ? GRAVITY_RATE * 2 : GRAVITY_RATE; i = (u16)sub_0806F854(super, 0, -12) ? kGravityRate * 2 : kGravityRate;
GravityUpdate(super, i); GravityUpdate(super, i);
if (gPlayerState.field_0x3a) { if (gPlayerState.field_0x3a) {
LinearMoveUpdate(super); LinearMoveUpdate(super);
@ -1837,7 +1836,7 @@ static void PlayerPull(PlayerEntity* this) {
static void sub_08072214(PlayerEntity* this) { static void sub_08072214(PlayerEntity* this) {
super->subAction = 1; super->subAction = 1;
super->speed = PULL_SPEED; super->speed = kPullSpeed;
super->timer = gPlayerState.field_0x38; super->timer = gPlayerState.field_0x38;
super->direction = Direction8FromAnimationState(AnimationStateFlip180(super->animationState)); super->direction = Direction8FromAnimationState(AnimationStateFlip180(super->animationState));
if ((gPlayerState.flags & PL_NO_CAP) == 0) { if ((gPlayerState.flags & PL_NO_CAP) == 0) {
@ -1904,7 +1903,7 @@ static void sub_08072354(PlayerEntity* this) {
sub_0806F854(super, 0, -12); sub_0806F854(super, 0, -12);
UpdateAnimationSingleFrame(super); UpdateAnimationSingleFrame(super);
sub_08079744(super); sub_08079744(super);
if (GravityUpdate(super, GRAVITY_RATE)) if (GravityUpdate(super, kGravityRate))
return; return;
super->spritePriority.b1 = 0; super->spritePriority.b1 = 0;
@ -2112,14 +2111,14 @@ static void PlayerRollUpdate(PlayerEntity* this) {
switch (super->frame & 0xf) { switch (super->frame & 0xf) {
case 0: case 0:
if ((super->frame & 0xf) == 0) { if ((super->frame & 0xf) == 0) {
super->speed = ROLL_SPEED; super->speed = kWalkSpeedRolling;
} }
break; break;
case 1: case 1:
super->speed += ROLL_SPEED / 16; super->speed += kWalkSpeedRolling / 16;
break; break;
case 2: case 2:
super->speed = (ROLL_SPEED * 3 / 2); super->speed = (kWalkSpeedRolling * 3 / 2);
break; break;
case 3: case 3:
super->speed = 0; super->speed = 0;
@ -2229,8 +2228,8 @@ static void sub_08072ACC(PlayerEntity* this) {
} else if (super->subtimer > 7) { } else if (super->subtimer > 7) {
COLLISION_ON(super); COLLISION_ON(super);
super->direction = gPlayerState.direction; super->direction = gPlayerState.direction;
super->zVelocity = JUMP_SPEED_HOLE_Z; super->zVelocity = kJumpSpeedHoleZ;
super->speed = JUMP_SPEED_HOLE_FWD; super->speed = kJumpSpeedHoleForward;
super->spritePriority.b0 = 4; super->spritePriority.b0 = 4;
super->spritePriority.b1 = 1; super->spritePriority.b1 = 1;
gPlayerState.jump_status = 0x41; gPlayerState.jump_status = 0x41;
@ -2277,7 +2276,7 @@ static void sub_08072B5C(PlayerEntity* this) {
temp <<= 12; temp <<= 12;
super->zVelocity = temp; super->zVelocity = temp;
super->speed = JUMP_SPEED_FWD; super->speed = kJumpSpeedForward;
gPlayerState.animation = ANIM_JUMP; gPlayerState.animation = ANIM_JUMP;
SoundReq(SFX_PLY_JUMP); SoundReq(SFX_PLY_JUMP);
} }
@ -2285,7 +2284,7 @@ static void sub_08072B5C(PlayerEntity* this) {
static void sub_08072C48(PlayerEntity* this) { static void sub_08072C48(PlayerEntity* this) {
UpdateAnimationSingleFrame(super); UpdateAnimationSingleFrame(super);
LinearMoveUpdate(super); LinearMoveUpdate(super);
if (GravityUpdate(super, GRAVITY_RATE)) if (GravityUpdate(super, kGravityRate))
return; return;
DoTileInteractionHere(super, 7); DoTileInteractionHere(super, 7);
@ -2403,7 +2402,7 @@ static void sub_08072D54(PlayerEntity* this) {
super->timer = 0; super->timer = 0;
} }
if (!GravityUpdate(super, GRAVITY_RATE)) { if (!GravityUpdate(super, kGravityRate)) {
COLLISION_ON(super); COLLISION_ON(super);
if (super->collisionLayer == 1) { if (super->collisionLayer == 1) {
ResetCollisionLayer(super); ResetCollisionLayer(super);
@ -2724,7 +2723,7 @@ static void sub_08073468(PlayerEntity* this) {
} }
static void sub_080734D4(PlayerEntity* this) { static void sub_080734D4(PlayerEntity* this) {
GravityUpdate(super, -(GRAVITY_RATE / 2)); GravityUpdate(super, -(kGravityRate / 2));
if (super->zVelocity > 0 || gPlayerState.field_0x38 == 1) { if (super->zVelocity > 0 || gPlayerState.field_0x38 == 1) {
super->zVelocity = Q_16_16(4.5625); super->zVelocity = Q_16_16(4.5625);
super->subAction++; super->subAction++;
@ -2732,7 +2731,7 @@ static void sub_080734D4(PlayerEntity* this) {
} }
static void sub_08073504(PlayerEntity* this) { static void sub_08073504(PlayerEntity* this) {
GravityUpdate(super, super->zVelocity < 0 ? GRAVITY_RATE / 4 : GRAVITY_RATE * 2); GravityUpdate(super, super->zVelocity < 0 ? kGravityRate / 4 : kGravityRate * 2);
if (super->zVelocity < 0 && super->z.HALF.HI > -32) { if (super->zVelocity < 0 && super->z.HALF.HI > -32) {
super->subAction++; super->subAction++;
this->unk_80.WORD = super->direction << 8; this->unk_80.WORD = super->direction << 8;
@ -2908,7 +2907,7 @@ static void sub_0807380C(PlayerEntity* this) {
} }
gPlayerState.animation = sAnims[super->animationState >> 1]; gPlayerState.animation = sAnims[super->animationState >> 1];
if (super->z.HALF.HI < -16) { if (super->z.HALF.HI < -16) {
GravityUpdate(super, GRAVITY_RATE / 16); GravityUpdate(super, kGravityRate / 16);
} else { } else {
if (--super->timer == 0) { if (--super->timer == 0) {
super->subAction = 7; super->subAction = 7;
@ -2939,7 +2938,7 @@ void sub_08073884(PlayerEntity* this) {
else else
InitParachuteRoom(); InitParachuteRoom();
} }
GravityUpdate(super, -((GRAVITY_RATE * 3) / 4)); GravityUpdate(super, -((kGravityRate * 3) / 4));
UpdateAnimationSingleFrame(super); UpdateAnimationSingleFrame(super);
} }
@ -2993,13 +2992,13 @@ static void sub_080739EC(PlayerEntity* this) {
gPlayerState.direction = super->direction; gPlayerState.direction = super->direction;
if (gPlayerState.jump_status & 0x80) if (gPlayerState.jump_status & 0x80)
super->collisions = COL_NONE; super->collisions = COL_NONE;
v = GRAVITY_RATE; v = kGravityRate;
} else { } else {
if ((u16)sub_0806F854(super, 0, -12)) { if ((u16)sub_0806F854(super, 0, -12)) {
gPlayerState.jump_status |= 8; gPlayerState.jump_status |= 8;
v = GRAVITY_RATE * 2; v = kGravityRate * 2;
} else { } else {
v = GRAVITY_RATE; v = kGravityRate;
if (gPlayerState.jump_status & 0x10) if (gPlayerState.jump_status & 0x10)
v /= 2; v /= 2;
} }
@ -3079,7 +3078,7 @@ void sub_08073B8C(PlayerEntity* this) {
--super->timer; --super->timer;
return; return;
} }
GravityUpdate(super, GRAVITY_RATE * 2); GravityUpdate(super, kGravityRate * 2);
if (super->z.HALF.HI >= -8) { if (super->z.HALF.HI >= -8) {
if (!gPlayerState.field_0x14 && (sub_0807A2B8() || !sub_08079D48())) { if (!gPlayerState.field_0x14 && (sub_0807A2B8() || !sub_08079D48())) {
COLLISION_ON(super); COLLISION_ON(super);
@ -3173,7 +3172,7 @@ static void sub_08073D20(PlayerEntity* this) {
} }
if (!UpdatePlayerCollision()) { if (!UpdatePlayerCollision()) {
UpdateActiveItems(super); UpdateActiveItems(super);
if (!GravityUpdate(super, GRAVITY_RATE)) if (!GravityUpdate(super, kGravityRate))
gPlayerState.jump_status = 0; gPlayerState.jump_status = 0;
if ((gPlayerState.field_0x7 & 0x80) == 0 && !gPlayerState.field_0xa) { if ((gPlayerState.field_0x7 & 0x80) == 0 && !gPlayerState.field_0xa) {
if (super->iframes <= 8) { if (super->iframes <= 8) {
@ -3251,7 +3250,7 @@ static void sub_08073FD0(PlayerEntity* this) {
SoundReq(SFX_PLY_JUMP); SoundReq(SFX_PLY_JUMP);
} }
} }
GravityUpdate(super, GRAVITY_RATE); GravityUpdate(super, kGravityRate);
if (super->zVelocity == 0) { if (super->zVelocity == 0) {
super->subAction++; super->subAction++;
SoundReq(SFX_PLY_GROW); SoundReq(SFX_PLY_GROW);
@ -3270,7 +3269,7 @@ static void sub_08074018(PlayerEntity* this) {
} }
static void sub_08074060(PlayerEntity* this) { static void sub_08074060(PlayerEntity* this) {
if (!GravityUpdate(super, GRAVITY_RATE)) { if (!GravityUpdate(super, kGravityRate)) {
super->hitbox = (Hitbox*)&gPlayerHitbox; super->hitbox = (Hitbox*)&gPlayerHitbox;
super->direction = DirectionSouth; super->direction = DirectionSouth;
super->animationState = IdleSouth; super->animationState = IdleSouth;
@ -3320,7 +3319,7 @@ void sub_080740D8(PlayerEntity* this) {
LinearMoveUpdate(super); LinearMoveUpdate(super);
else else
super->subtimer = 1; super->subtimer = 1;
if (!GravityUpdate(super, GRAVITY_RATE)) if (!GravityUpdate(super, kGravityRate))
PlayerSetNormalAndCollide(); PlayerSetNormalAndCollide();
} }
@ -3367,7 +3366,7 @@ static void sub_08074244(PlayerEntity* this, u32 a1, u32 a2) {
tmp = 4 * super->animationState; tmp = 4 * super->animationState;
} }
if (a1 != tmp || a2 != tmp) { if (a1 != tmp || a2 != tmp) {
gPlayerState.speed_modifier -= SLOPE_SPEED_MODIFIER; gPlayerState.speed_modifier -= kWalkSpeedSlopeSubtractor;
} }
} }
} }
@ -3788,7 +3787,7 @@ void SurfaceAction_ConveyerEast(PlayerEntity* this) {
static void conveyer_push(PlayerEntity* this) { static void conveyer_push(PlayerEntity* this) {
ResetActiveItems(); ResetActiveItems();
super->spritePriority.b1 = 0; super->spritePriority.b1 = 0;
super->speed = WALK_SPEED; super->speed = kWalkSpeed;
gPlayerState.flags |= PL_CONVEYOR_PUSHED; gPlayerState.flags |= PL_CONVEYOR_PUSHED;
gPlayerState.field_0xa |= 0x80; gPlayerState.field_0xa |= 0x80;
gPlayerState.mobility |= 0x80; gPlayerState.mobility |= 0x80;
@ -3839,7 +3838,7 @@ static void sub_08074CF8(PlayerEntity* this) {
sub_08074D34(this, *(ScriptExecutionContext**)&this->unk_84.WORD); sub_08074D34(this, *(ScriptExecutionContext**)&this->unk_84.WORD);
if ((this->unk_80.HALF.HI & 1) != 0) if ((this->unk_80.HALF.HI & 1) != 0)
super->animationState = v3; super->animationState = v3;
GravityUpdate(super, GRAVITY_RATE); GravityUpdate(super, kGravityRate);
UpdateAnimationSingleFrame(super); UpdateAnimationSingleFrame(super);
} }
@ -3995,7 +3994,7 @@ void sub_0807501C(PlayerEntity* this) {
void sub_0807508C(PlayerEntity* this) { void sub_0807508C(PlayerEntity* this) {
UpdateAnimationSingleFrame(super); UpdateAnimationSingleFrame(super);
if (GravityUpdate(super, GRAVITY_RATE)) { if (GravityUpdate(super, kGravityRate)) {
LinearMoveUpdate(super); LinearMoveUpdate(super);
} else { } else {
if (!gPlayerState.field_0x39) { if (!gPlayerState.field_0x39) {

View File

@ -436,7 +436,7 @@ void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 x, u32 y)
context->y.HALF.HI = y; context->y.HALF.HI = y;
xOffset = context->x.HALF.HI - entity->x.HALF.HI; xOffset = context->x.HALF.HI - entity->x.HALF.HI;
yOffset = context->y.HALF.HI - entity->y.HALF.HI; yOffset = context->y.HALF.HI - entity->y.HALF.HI;
direction = sub_080045DA(xOffset, yOffset); direction = CalcOffsetAngle(xOffset, yOffset);
entity->direction = direction; entity->direction = direction;
entity->animationState = (entity->animationState & 0x80) | sDirectionTable[(u8)direction >> 4]; entity->animationState = (entity->animationState & 0x80) | sDirectionTable[(u8)direction >> 4];
} }
@ -1394,7 +1394,7 @@ void ScriptCommand_0807EE30(Entity* entity, ScriptExecutionContext* context) {
if (!--context->unk_19) { if (!--context->unk_19) {
context->unk_19 = 8; context->unk_19 = 8;
entity->direction = entity->direction =
sub_080045DA(context->x.HALF.HI - entity->x.HALF.HI, context->y.HALF.HI - entity->y.HALF.HI); CalcOffsetAngle(context->x.HALF.HI - entity->x.HALF.HI, context->y.HALF.HI - entity->y.HALF.HI);
} }
tmp = entity->x.HALF.HI - context->x.HALF.HI; tmp = entity->x.HALF.HI - context->x.HALF.HI;
tmp2 = entity->y.HALF.HI - context->y.HALF.HI; tmp2 = entity->y.HALF.HI - context->y.HALF.HI;