Skip to content

Commit

Permalink
Merge pull request #686 from notyourav/followtest
Browse files Browse the repository at this point in the history
document unused zelda follower and gust jar states
  • Loading branch information
hytopoulos authored Jan 1, 2024
2 parents 983412c + f5c6178 commit 6fb8b41
Show file tree
Hide file tree
Showing 48 changed files with 685 additions and 628 deletions.
4 changes: 2 additions & 2 deletions asm/src/code_08003FC4.s
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ sub_080041E8: @ 0x080041E8
subs r0, r0, r2
subs r1, r1, r3

thumb_func_start sub_080041EC
sub_080041EC: @ 0x080041EC
thumb_func_start CalcDistance
CalcDistance: @ 0x080041EC
adds r2, r0, #0
muls r0, r2, r0
adds r3, r1, #0
Expand Down
4 changes: 2 additions & 2 deletions asm/src/code_080043E8.s
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ CalculateDirectionTo: @ 0x080045D4
ldr r3, _08004694 @ =ram_CalcCollisionDirection
bx r3

non_word_aligned_thumb_func_start sub_080045DA
sub_080045DA: @ 0x080045DA
non_word_aligned_thumb_func_start CalcOffsetAngle
CalcOffsetAngle: @ 0x080045DA
push {r0, r1, r4, r5, r6, lr}
movs r6, #0x40
cmp r0, #0
Expand Down
2 changes: 1 addition & 1 deletion asm/src/player.s
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ _080085E6:
ldr r3, _080088A8 @ =gPlayerState
ldrb r2, [r3, #0x1c]
orrs r2, r2
bne _0800861A // field_0x1c != 0
bne _0800861A // gustJarState != 0
ldrb r2, [r3, #5]
orrs r2, r2
bne _0800861A // heldObject != 0
Expand Down
2 changes: 1 addition & 1 deletion data/animations/npc/npc5.s
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ gUnk_0810B65C:: @ 0810B65C
gUnk_0810B65E:: @ 0810B65E
.incbin "npc5/gUnk_0810B65E.bin"

gUnk_0810B660:: @ 0810B660
gZeldaFollowerText:: @ 0810B660
.4byte gUnk_0810B650
.4byte gUnk_0810B652
.4byte gUnk_0810B654
Expand Down
2 changes: 1 addition & 1 deletion include/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern void ResetCollisionLayer(struct Entity_*);
extern void sub_08004596(struct Entity_*, u32);
extern u32 sub_080045B4(struct Entity_*, 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 ResolveCollisionLayer(struct Entity_*);
extern void sub_0800417E(struct Entity_*, u32);
Expand Down
26 changes: 22 additions & 4 deletions include/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ typedef struct {
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unk_6e;
/*0x6f*/ u8 unk_6f;
/*0x70*/ Entity* unk_70;
/*0x74*/ Entity* unk_74;
/*0x70*/ Entity* pulledJarEntity;
/*0x74*/ Entity* carriedEntity;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u16 unk_7a;
Expand Down Expand Up @@ -298,6 +298,24 @@ typedef enum {
SWORD_MOVE_LOW_BEAM,
} SwordMove;

typedef enum {
PL_JAR_NONE = 0x0,
PL_JAR_SUCK = 0x1,
PL_JAR_2 = 0x2,
PL_JAR_3 = 0x3,
PL_JAR_BLAST_INIT = 0x4,
PL_JAR_BLAST_UPDATE = 0x5,
PL_JAR_BLAST_DONE = 0x6,
PL_JAR_ENT_ATTACHED = 0x7,
} GustJarState;

typedef enum {
JAR_CHARGE_NONE = 0,
JAR_CHARGE_SMALL = 1,
JAR_CHARGE_MID = 2,
JAR_CHARGE_BIG = 3,
} GustJarCharge;

typedef enum {
ANIM_DEFAULT = 0x100,
ANIM_WALK = 0x104,
Expand Down Expand Up @@ -492,8 +510,8 @@ typedef struct {
/*0x18*/ u16 startPosY;
/*0x1a*/ u8 mobility;
/*0x1b*/ u8 sword_state;
/*0x1c*/ u8 field_0x1c;
/*0x1d*/ u8 gustJarSpeed;
/*0x1c*/ u8 gustJarState;
/*0x1d*/ u8 gustJarCharge;
/*0x1e*/ u8 dash_state;
/*0x1f*/ u8 field_0x1f[2];
/*0x21*/ u8 bow_state;
Expand Down
2 changes: 1 addition & 1 deletion src/beanstalkSubtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ u32 UpdatePlayerCollision(void) {
((gPlayerState.sword_state & 0x10) != 0)) ||
((sub_080806BC(gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x,
gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y, index, 5) == 0 &&
(((gPlayerState.heldObject != 0 || ((gPlayerState.field_0x1c & 0xf) != 0)) ||
(((gPlayerState.heldObject != 0 || ((gPlayerState.gustJarState & 0xf) != 0)) ||
(sub_0807BD14(&gPlayerEntity.base, index) == 0)))))) {
return 3;
}
Expand Down
2 changes: 1 addition & 1 deletion src/collision.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ CollisionResult sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSetting
CollisionResult sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((tgt->gustJarState & 4) != 0) {
if (tgt->gustJarTolerance) {
tgt->gustJarTolerance = tgt->gustJarTolerance - gPlayerState.gustJarSpeed;
tgt->gustJarTolerance = tgt->gustJarTolerance - gPlayerState.gustJarCharge;
if ((s8)tgt->gustJarTolerance <= 0) {
tgt->gustJarTolerance = 0;
tgt->subAction = 2;
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/bombPeahat.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void sub_0802A8F4(BombPeahatEntity* this) {
}

void sub_0802A8FC(BombPeahatEntity* this) {
if ((gPlayerState.field_0x1c & 0xf) == 0) {
super->health = gPlayerState.field_0x1c & 0xf;
if ((gPlayerState.gustJarState & 0xf) == 0) {
super->health = gPlayerState.gustJarState & 0xf;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/enemy/dust.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void sub_08044550(DustEntity* this) {
u8 uVar1;
const s8* ptr;

if ((gPlayerState.field_0x1c & 0xf) == 1) {
if ((gPlayerState.gustJarState & 0xf) == 1) {
if (super->speed < 0x100) {
super->speed += 0x10;
}
Expand Down
10 changes: 5 additions & 5 deletions src/enemy/enemy64.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void Enemy64_Action2_SubAction0(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 (((tmp - super->direction) & 0x80) != 0) {
super->direction--;
Expand Down Expand Up @@ -290,8 +290,8 @@ void Enemy64_Action3(Enemy64Entity* this) {
}

void Enemy64_Action3_SubAction0(Enemy64Entity* this) {
u32 tmp = sub_080045DA(gRoomControls.origin_x + 0xa8 - super->x.HALF.HI,
gRoomControls.origin_y + 0x80 - super->y.HALF.HI);
u32 tmp = CalcOffsetAngle(gRoomControls.origin_x + 0xa8 - super->x.HALF.HI,
gRoomControls.origin_y + 0x80 - super->y.HALF.HI);
if (tmp != super->direction) {
if (((tmp - super->direction) & 0x80) != 0) {
super->direction--;
Expand Down Expand Up @@ -490,8 +490,8 @@ void sub_080499F0(Enemy64Entity* this) {
((this->unk_7c & 1) == 0)) {
if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24) &&
((this->unk_7c & 2) == 0)) {
tmp = sub_080045DA((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
(s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
tmp = CalcOffsetAngle((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
(s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.x.WORD = super->x.WORD + gSineTable[tmp] * 0x2400;
gPlayerEntity.base.y.WORD = super->y.WORD + gSineTable[tmp + 0x40] * -0x2400;
}
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/flyingPot.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void FlyingPot_SubAction2(FlyingPotEntity* this) {
}

void FlyingPot_SubAction3(FlyingPotEntity* this) {
if (!(gPlayerState.field_0x1c & 0xF)) {
if (!(gPlayerState.gustJarState & 0xF)) {
sub_08037408(this);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/flyingSkull.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void sub_08039CE0(FlyingSkullEntity* this) {
}

void sub_08039D4C(FlyingSkullEntity* this) {
if ((gPlayerState.field_0x1c & 0xf) == 0) {
if ((gPlayerState.gustJarState & 0xf) == 0) {
sub_0803A0E0(this);
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/enemy/gyorgMale.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void sub_08046AE8(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) & 0xFF) > 0x80) {
this->unk_76 -= 0x100;
Expand All @@ -283,13 +283,13 @@ void sub_08046B8C(GyorgMaleEntity* this) {
this->unk_82 = gRoomControls.origin_y + 0x210;
sub_08047D88(this);
} 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);
}
}

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) & 0xFF) > 0x80) {
this->unk_76 -= 0x100;
Expand All @@ -311,7 +311,7 @@ void sub_08046C88(GyorgMaleEntity* this) {
sub_08048178(this, sub_08048158(this->unk_70));
sub_08047D88(this);
} 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);
}
}
Expand Down Expand Up @@ -348,7 +348,7 @@ void sub_08046D44(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) & 0xFF) > 0x80) {
this->unk_76 -= 0x100;
Expand All @@ -369,7 +369,7 @@ void sub_08046E0C(GyorgMaleEntity* this) {
this->unk_76 = super->direction << 8;
sub_08047D88(this);
} 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);
}
}
Expand Down Expand Up @@ -456,7 +456,7 @@ void sub_08046FE8(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 ((tmp - super->direction) & 0x80) {
super->direction--;
Expand Down Expand Up @@ -607,7 +607,7 @@ void sub_080473B8(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) {
s32 tmp2 = tmp - super->direction;
if (tmp2 & 0x80) {
Expand Down Expand Up @@ -791,7 +791,7 @@ void sub_080477F0(GyorgMaleEntity* this) {
if (super->speed < 0x300) {
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);
if (!EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x80)) {
super->action = 2;
Expand Down Expand Up @@ -896,7 +896,7 @@ void sub_08047978(GyorgMaleEntity* this) {

void sub_08047B08(GyorgMaleEntity* 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;
sub_08047E58(this);
if (!EntityWithinDistance(super, this->unk_80, this->unk_82, 4))
Expand Down Expand Up @@ -1066,8 +1066,8 @@ void sub_08047EA4(GyorgMaleEntity* this, u32 unk1) {
return;
if (this->unk_7c & 1) {
tmp2 = sub_08047F68(this) << 8;
dir = sub_080045DA(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
dir = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
tmp = dir - (tmp / 256);
tmp &= 0xFF;
gPlayerEntity.base.x.WORD += (gSineTable[tmp] - gSineTable[dir]) * tmp2;
Expand Down Expand Up @@ -1149,8 +1149,8 @@ void sub_08048004(GyorgMaleEntity* this) {
if (b != 3) {
if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24)) {
if (!(this->unk_7c & 2)) {
u32 tmp = sub_080045DA(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.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.x.WORD = super->x.WORD + (gSineTable[tmp] * 9216);
gPlayerEntity.base.y.WORD = super->y.WORD - (gSineTable[tmp + 0x40] * 9216);
}
Expand Down
22 changes: 11 additions & 11 deletions src/enemy/octorokBoss.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ void OctorokBoss_Hit_SubAction1(OctorokBossEntity* this) {
if (diffX > 8 || diffY > 8) {
this->heap->field_0x2 = 1;
#if defined(JP) || defined(DEMO_JP) || defined(EU)
super->direction = ((s32)sub_080045DA((((gRoomControls.origin_x + 0x108) << 0x10) - super->x.WORD),
(((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >>
super->direction = ((s32)CalcOffsetAngle((((gRoomControls.origin_x + 0x108) << 0x10) - super->x.WORD),
(((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >>
3;
#else
super->direction = ((s32)sub_080045DA(gRoomControls.origin_x + 0x108 - super->x.HALF.HI,
gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >>
super->direction = ((s32)CalcOffsetAngle(gRoomControls.origin_x + 0x108 - super->x.HALF.HI,
gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >>
3;
#endif
super->speed = 0x100;
Expand Down Expand Up @@ -689,7 +689,7 @@ void OctorokBoss_Action1_AimTowardsPlayer(OctorokBossEntity* this) {
s32 tmp1;
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)));
if (IS_FROZEN(this) == FALSE) {
tmp2 = 8;
Expand Down Expand Up @@ -898,7 +898,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {

if (this->unk_80 == 0) {
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;
if (tmp < 0) {
tmp = -tmp;
Expand All @@ -912,8 +912,8 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
this->unk_80 = 1;
this->timer = 2;
this->heap->targetAngle =
sub_080045DA((gRoomControls.origin_x + 0x108) * 0x10000 - super->x.WORD,
(gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD);
CalcOffsetAngle((gRoomControls.origin_x + 0x108) * 0x10000 - super->x.WORD,
(gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD);
this->heap->targetAngle = (u8) - (this->heap->targetAngle + 0x80);
SoundReq(SFX_ED);
}
Expand Down Expand Up @@ -956,7 +956,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
} else {
this->timer--;
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) {
this->heap->targetAngle = this->angle.HALF.HI + 0x30;
} else {
Expand Down Expand Up @@ -1178,8 +1178,8 @@ void sub_08036AF0(OctorokBossEntity* this, s32 radius, s32 angleSpeed) {
continue;
} else {
heap->tailObjects[index - 1]->angle.HALF.HI =
sub_080045DA(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);
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);
tmp = FixedMul(gSineTable[heap->tailObjects[index - 1]->angle.HALF.HI], radius << 4);
tmp = FixedDiv(tmp, 0x100);
heap->tailObjects[index - 1]->base.x.WORD = heap->tailObjects[index]->base.x.WORD + ((s32)tmp << 8);
Expand Down
Loading

0 comments on commit 6fb8b41

Please sign in to comment.