mirror of
https://github.com/zeldaret/tmc
synced 2026-06-16 14:50:22 -04:00
Match lilypadLarge functions and add const data
This commit is contained in:
+269
-18
@@ -27,12 +27,7 @@ typedef struct {
|
||||
u8 unk_85;
|
||||
} LilypadLargeEntity;
|
||||
|
||||
extern void (*const gUnk_08120608[])(LilypadLargeEntity*);
|
||||
extern Hitbox gUnk_08120640;
|
||||
extern void (*const gUnk_0812062C[])(LilypadLargeEntity*);
|
||||
extern u8 gUnk_08120638[];
|
||||
extern u8 gUnk_08126EE4[];
|
||||
extern u32 gUnk_08120620[];
|
||||
|
||||
void sub_080855E8(LilypadLargeEntity*);
|
||||
void sub_08085CDC(LilypadLargeEntity*);
|
||||
@@ -42,11 +37,25 @@ void sub_08085E74(LilypadLargeEntity*);
|
||||
void sub_08085F48(LilypadLargeEntity*);
|
||||
void sub_08085D28(LilypadLargeEntity*);
|
||||
void sub_08085D60(LilypadLargeEntity*);
|
||||
void sub_08085504(LilypadLargeEntity*);
|
||||
void sub_080855E8(LilypadLargeEntity*);
|
||||
void sub_08085A1C(LilypadLargeEntity*);
|
||||
void sub_08085C5C(LilypadLargeEntity*);
|
||||
void sub_08085CDC(LilypadLargeEntity*);
|
||||
void sub_08085D10(LilypadLargeEntity*);
|
||||
void sub_08085B40(LilypadLargeEntity*);
|
||||
void sub_08085A98(LilypadLargeEntity*);
|
||||
void sub_08085A44(LilypadLargeEntity*);
|
||||
|
||||
void LilypadLarge(LilypadLargeEntity* this) {
|
||||
gUnk_08120608[super->action](this);
|
||||
static void (*const actionFuncs[])(LilypadLargeEntity*) = {
|
||||
sub_08085504, sub_080855E8, sub_08085A1C, sub_08085C5C, sub_08085CDC, sub_08085D10,
|
||||
};
|
||||
actionFuncs[super->action](this);
|
||||
}
|
||||
|
||||
static const Hitbox gUnk_08120640;
|
||||
|
||||
void sub_08085504(LilypadLargeEntity* this) {
|
||||
if (super->type == 0xff) {
|
||||
if (GetInventoryValue(ITEM_FLIPPERS)) {
|
||||
@@ -79,7 +88,7 @@ void sub_08085504(LilypadLargeEntity* this) {
|
||||
super->action = 1;
|
||||
super->speed = 0x100;
|
||||
super->spritePriority.b0 = 6;
|
||||
super->hitbox = &gUnk_08120640;
|
||||
super->hitbox = (Hitbox*)&gUnk_08120640;
|
||||
super->flags |= ENT_COLLIDE;
|
||||
super->collisionFlags = 7;
|
||||
super->hitType = 1;
|
||||
@@ -92,10 +101,245 @@ void sub_08085504(LilypadLargeEntity* this) {
|
||||
sub_080855E8(this);
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/lilypadLarge/sub_080855E8.inc", void sub_080855E8(LilypadLargeEntity* this));
|
||||
void sub_080855E8(LilypadLargeEntity* this) {
|
||||
static const u32 gUnk_08120620[] = {
|
||||
0x5000,
|
||||
0x18000,
|
||||
0x28000,
|
||||
};
|
||||
s16 sVar3;
|
||||
u32 uVar1;
|
||||
u16 uVar8;
|
||||
s32 sVar10;
|
||||
u32 uVar5;
|
||||
u32 tmp;
|
||||
u32 uVar4;
|
||||
|
||||
super->flags |= 0x20;
|
||||
if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) {
|
||||
|
||||
gPlayerState.flags |= 2;
|
||||
if (gPlayerEntity.z.WORD == 0) {
|
||||
if (gPlayerState.swim_state != 0) {
|
||||
gPlayerEntity.collisionFlags &= 0xfb;
|
||||
gPlayerState.swim_state = 0;
|
||||
}
|
||||
*(u32*)&gPlayerState.field_0x82[2] = (u32)this; // TODO
|
||||
if (super->collisionLayer == 1) {
|
||||
ResetCollisionLayer(&gPlayerEntity);
|
||||
} else {
|
||||
sub_08004542(&gPlayerEntity);
|
||||
}
|
||||
if (super->subtimer == 0) {
|
||||
super->subtimer = 4;
|
||||
while (super->subtimer != 0) {
|
||||
sub_080A2AF4(super, 8, 10);
|
||||
super->subtimer--;
|
||||
}
|
||||
super->subtimer = 1;
|
||||
super->timer |= 0x80;
|
||||
this->unk_70 = 0;
|
||||
this->unk_6c = 0;
|
||||
}
|
||||
if (gPlayerState.field_0x1c == 3) {
|
||||
tmp = gUnk_08120620[gPlayerState.gustJarSpeed - 1];
|
||||
switch (gPlayerEntity.animationState & 6) {
|
||||
case 4:
|
||||
this->unk_70 -= tmp;
|
||||
break;
|
||||
case 0:
|
||||
this->unk_70 += tmp;
|
||||
break;
|
||||
case 2:
|
||||
this->unk_6c -= tmp;
|
||||
break;
|
||||
case 6:
|
||||
this->unk_6c += tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (super->subtimer != 0) {
|
||||
super->subtimer = 0;
|
||||
SoundReq(SFX_WATER_WALK);
|
||||
}
|
||||
if ((super->contactFlags & 0x7f) == 0x13) {
|
||||
sVar10 = gPlayerEntity.x.HALF.HI + (s8)gUnk_08126EE4[gPlayerEntity.animationState & 0xe];
|
||||
uVar4 = gPlayerEntity.y.HALF.HI + (s8)gUnk_08126EE4[gPlayerEntity.animationState | 1];
|
||||
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, sVar10, uVar4);
|
||||
|
||||
switch (gPlayerState.gustJarSpeed) {
|
||||
case 3:
|
||||
tmp = 0x400;
|
||||
break;
|
||||
case 2:
|
||||
tmp = 0x300;
|
||||
break;
|
||||
case 1:
|
||||
tmp = 0x200;
|
||||
break;
|
||||
}
|
||||
|
||||
//! @bug: tmp could be uninitialized here
|
||||
sVar3 = FixedMul(gSineTable[(u32)super->direction * 8], ((s16)tmp) >> 8);
|
||||
sVar3 = FixedDiv(sVar3, 0x100);
|
||||
this->unk_6c = this->unk_6c + (((s32)sVar3 << 0x10) >> 8);
|
||||
sVar3 = FixedMul(gSineTable[(u32)super->direction * 8 + 0x40], ((s16)tmp) >> 8);
|
||||
sVar3 = FixedDiv(sVar3, 0x100);
|
||||
this->unk_70 = this->unk_70 - (((s32)sVar3 << 0x10) >> 8);
|
||||
}
|
||||
super->contactFlags = 0;
|
||||
}
|
||||
super->child = (Entity*)super->x.WORD;
|
||||
super->parent = (Entity*)super->y.WORD;
|
||||
if (this->unk_6c != 0 || this->unk_70 != 0) {
|
||||
if ((this->unk_70 < -0x10000)) {
|
||||
this->unk_70 = -0x10000;
|
||||
} else if ((this->unk_70) > 0x10000) {
|
||||
this->unk_70 = 0x10000;
|
||||
}
|
||||
|
||||
if ((this->unk_6c < -0x10000)) {
|
||||
this->unk_6c = -0x10000;
|
||||
} else if ((this->unk_6c) > 0x10000) {
|
||||
this->unk_6c = 0x10000;
|
||||
}
|
||||
|
||||
if ((gRoomTransition.frameCount & 0xfU) == 0) {
|
||||
CreateLargeWaterTrace(super);
|
||||
}
|
||||
sVar10 = super->x.WORD + this->unk_6c;
|
||||
uVar4 = super->y.WORD + this->unk_70;
|
||||
super->direction = CalculateDirectionTo(super->x.WORD, super->y.WORD, sVar10, uVar4);
|
||||
sVar3 = FixedMul((s16)((this->unk_6c << 8) >> 0x10), 0x100);
|
||||
sVar3 = FixedDiv(sVar3, gSineTable[(u32)super->direction * 8]);
|
||||
super->speed = sVar3;
|
||||
sVar3 = FixedMul((s16)((this->unk_70 << 8) >> 0x10), 0x100);
|
||||
sVar3 = FixedDiv(sVar3, gSineTable[(u32)super->direction * 8 + 0x40]);
|
||||
tmp = -sVar3;
|
||||
if ((s32)tmp > super->speed) {
|
||||
super->speed = tmp;
|
||||
}
|
||||
|
||||
if (super->type2 != 0) {
|
||||
if (this->unk_7c.HALF.HI < 0x1000) {
|
||||
this->unk_7c.WORD += super->speed * 0x1000;
|
||||
} else {
|
||||
super->type2 = 0;
|
||||
}
|
||||
} else {
|
||||
if (this->unk_7c.HALF.HI > -0x1000) {
|
||||
this->unk_7c.WORD += super->speed * -0x1000;
|
||||
} else {
|
||||
super->type2 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub_08085EFC(this);
|
||||
ProcessMovement4(super);
|
||||
if (super->child == (Entity*)super->x.WORD) {
|
||||
if (this->unk_85 == 2) {
|
||||
this->unk_6c = 0;
|
||||
} else {
|
||||
this->unk_85++;
|
||||
}
|
||||
} else {
|
||||
this->unk_85 = 0;
|
||||
}
|
||||
|
||||
if (super->parent == (Entity*)super->y.WORD) {
|
||||
if (this->unk_85 == 2) {
|
||||
this->unk_70 = 0;
|
||||
} else {
|
||||
this->unk_85++;
|
||||
}
|
||||
} else {
|
||||
this->unk_85 = 0;
|
||||
}
|
||||
|
||||
if ((gPlayerState.flags & 2) != 0) {
|
||||
sub_08085F1C(this);
|
||||
}
|
||||
|
||||
if (this->unk_6c != 0) {
|
||||
if (this->unk_6c < 0) {
|
||||
if (this->unk_6c > -0x80) {
|
||||
this->unk_6c = 0;
|
||||
} else {
|
||||
this->unk_6c += 0x80;
|
||||
}
|
||||
if ((super->collisions & 0xe00) == 0xe00) {
|
||||
s32 tmp = this->unk_6c;
|
||||
if (this->unk_6c < 0) {
|
||||
tmp += 3;
|
||||
}
|
||||
this->unk_6c = -(tmp >> 2);
|
||||
}
|
||||
} else {
|
||||
if (this->unk_6c < 0x80u) {
|
||||
this->unk_6c = 0;
|
||||
} else {
|
||||
this->unk_6c -= 0x80;
|
||||
}
|
||||
if ((super->collisions & 0xe000) == 0xe000) {
|
||||
s32 tmp = this->unk_6c;
|
||||
if (this->unk_6c < 0) {
|
||||
tmp += 3;
|
||||
}
|
||||
this->unk_6c = -(tmp >> 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this->unk_70 != 0) {
|
||||
if ((s32)this->unk_70 < 0) {
|
||||
if ((s32)this->unk_70 > -0x80) {
|
||||
this->unk_70 = 0;
|
||||
} else {
|
||||
this->unk_70 += 0x80;
|
||||
}
|
||||
if ((super->collisions & 0xe) == 0xe) {
|
||||
u32 tmp2 = this->unk_70;
|
||||
if ((s32)this->unk_70 < 0) {
|
||||
tmp2 += 3;
|
||||
}
|
||||
this->unk_70 = -((s32)tmp2 >> 2);
|
||||
}
|
||||
} else {
|
||||
if (this->unk_70 < 0x80u) {
|
||||
this->unk_70 = 0;
|
||||
} else {
|
||||
this->unk_70 -= 0x80;
|
||||
}
|
||||
if ((super->collisions & 0xe0) == 0xe0) {
|
||||
// goto _080859D8;
|
||||
u32 tmp2 = this->unk_70;
|
||||
if ((s32)this->unk_70 < 0) {
|
||||
tmp2 += 3;
|
||||
}
|
||||
this->unk_70 = -((s32)tmp2 >> 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
sub_08085D28(this);
|
||||
sub_08085D60(this);
|
||||
} else {
|
||||
end:
|
||||
if ((gRoomTransition.frameCount & 0x1fU) == 0) {
|
||||
sub_080A2AF4(super, 8, 10);
|
||||
}
|
||||
}
|
||||
sub_08085F48(this);
|
||||
}
|
||||
|
||||
void sub_08085A1C(LilypadLargeEntity* this) {
|
||||
gUnk_0812062C[super->subAction](this);
|
||||
static void (*const subActionFuncs[])(LilypadLargeEntity*) = {
|
||||
sub_08085A44,
|
||||
sub_08085A98,
|
||||
sub_08085B40,
|
||||
};
|
||||
subActionFuncs[super->subAction](this);
|
||||
gPlayerState.flags |= PL_FLAGS2;
|
||||
sub_08078B48();
|
||||
}
|
||||
@@ -236,9 +480,15 @@ void sub_08085D28(LilypadLargeEntity* this) {
|
||||
}
|
||||
}
|
||||
|
||||
NONMATCH("asm/non_matching/lilypadLarge/sub_08085D60.inc", void sub_08085D60(LilypadLargeEntity* this)) {
|
||||
void sub_08085D60(LilypadLargeEntity* this) {
|
||||
static const s8 gUnk_08120638[] = {
|
||||
0, -24, 24, 0, 0, 24, -24, 0,
|
||||
};
|
||||
u32 r4; // horizontal direction?
|
||||
u32 r6; // vertical direction?
|
||||
u32 tmp;
|
||||
s32 tmpX, tmpX2;
|
||||
s32 tmpY, tmpY2;
|
||||
if ((gPlayerState.flags & PL_FLAGS2) != 0) {
|
||||
if (gPlayerState.framestate != PL_STATE_DIE) {
|
||||
if (gPlayerState.jump_status == 0) {
|
||||
@@ -258,9 +508,9 @@ NONMATCH("asm/non_matching/lilypadLarge/sub_08085D60.inc", void sub_08085D60(Lil
|
||||
}
|
||||
}
|
||||
if (r4 == DirectionWest || r4 == DirectionEast) { // Handle horizontal
|
||||
u32 tmp = r4 >> 2;
|
||||
s32 tmpX = gUnk_08120638[tmp];
|
||||
s32 tmpY = gUnk_08120638[tmp + 1];
|
||||
tmp = r4 >> 2;
|
||||
tmpX = gUnk_08120638[tmp];
|
||||
tmpY = gUnk_08120638[tmp + 1];
|
||||
if (sub_080B1AF0(super, tmpX, tmpY) == 0xff) {
|
||||
|
||||
if (sub_080806BC((super->x.HALF.HI - gRoomControls.origin_x) + tmpX,
|
||||
@@ -277,10 +527,10 @@ NONMATCH("asm/non_matching/lilypadLarge/sub_08085D60.inc", void sub_08085D60(Lil
|
||||
}
|
||||
}
|
||||
if (r6 == DirectionNorth || r6 == DirectionSouth) { // Handle vertical
|
||||
u32 tmp = r6 >> 2;
|
||||
s32 tmpX = (u8)gUnk_08120638[tmp];
|
||||
s32 tmpY = gUnk_08120638[tmp + 1];
|
||||
if (sub_080B1AF0(super, tmpX, tmpY) == 0xff) {
|
||||
tmp = r6 >> 2;
|
||||
tmpX2 = gUnk_08120638[tmp];
|
||||
tmpY2 = gUnk_08120638[tmp + 1];
|
||||
if (sub_080B1AF0(super, tmpX2, tmpY2) == 0xff) {
|
||||
if (sub_0807BD14(&gPlayerEntity, r6 >> 3) != 0) {
|
||||
super->direction = (u8)r6;
|
||||
sub_08085E74(this);
|
||||
@@ -293,7 +543,6 @@ NONMATCH("asm/non_matching/lilypadLarge/sub_08085D60.inc", void sub_08085D60(Lil
|
||||
}
|
||||
super->flags &= ~ENT_PERSIST;
|
||||
}
|
||||
END_NONMATCH
|
||||
|
||||
void sub_08085E74(LilypadLargeEntity* this) {
|
||||
super->flags |= ENT_PERSIST;
|
||||
@@ -383,3 +632,5 @@ void sub_08085F48(LilypadLargeEntity* this) {
|
||||
}
|
||||
SetAffineInfo(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI);
|
||||
}
|
||||
|
||||
static const Hitbox gUnk_08120640 = { 0, 0, { 16, 14, 14, 16 }, 16, 16 };
|
||||
|
||||
Reference in New Issue
Block a user