summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornotyourav <65437533+notyourav@users.noreply.github.com>2022-09-05 11:33:54 -0700
committerGitHub <noreply@github.com>2022-09-05 11:33:54 -0700
commit3ecaa31df011cc6e77fe1dd4e02fe90f14fae65e (patch)
tree8e8e21872e76a6bdf01669ead6af83cb0f7fe267 /src
parent11e57bc8e8ac9a9e73c3c3cf221670de3cdf8df7 (diff)
parentca6857fddb86871a324a4bc93b32d3e05a4d9d38 (diff)
Merge pull request #570 from hatal175/sub_080432A8
Diffstat (limited to 'src')
-rw-r--r--src/enemy/madderpillar.c39
-rw-r--r--src/enemy/mulldozer.c8
-rw-r--r--src/enemy/spearMoblin.c24
-rw-r--r--src/enemy/vaatiArm.c67
-rw-r--r--src/object/figurineDevice.c120
-rw-r--r--src/playerUtils.c83
-rw-r--r--src/ui.c56
7 files changed, 373 insertions, 24 deletions
diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c
index 46f0d2ef..ad81c2d4 100644
--- a/src/enemy/madderpillar.c
+++ b/src/enemy/madderpillar.c
@@ -19,6 +19,9 @@ void sub_0802A18C(Entity*);
bool32 sub_08029FE4(Entity*);
void sub_08029FB4(Entity*, u32, u32);
void sub_0802A0F8(Entity*);
+void sub_08029F0C(Entity*);
+
+extern s16 gUnk_080B4488[];
extern void (*const gUnk_080CCD44[])(Entity*);
extern void (*const Madderpillar_Functions[])(Entity*);
@@ -320,7 +323,41 @@ void sub_08029DE4(Entity* this) {
}
}
-ASM_FUNC("asm/non_matching/madderpillar/sub_08029E0C.inc", void sub_08029E0C(Entity* this))
+void sub_08029E0C(Entity* this) {
+ u32 tile;
+ s32 uVar4;
+ s32 iVar3;
+ u32 i;
+ u32 uVar2;
+ const u8* ptr;
+ u32 local_24;
+ u32 dir;
+
+ uVar2 = (this->direction >> 3) * 3;
+ ptr = &gUnk_080CCDC8[uVar2];
+ uVar4 = (Random() & 1) * 2 - 1;
+ iVar3 = ((s32)Random() & 0xf) % 3;
+ tile = COORD_TO_TILE(this);
+ for (i = 0; i < 3; i++) {
+ dir = ptr[iVar3];
+ if (sub_080B1B44(gUnk_080B4488[dir >> 3] + tile, this->collisionLayer) == 0) {
+ local_24 = dir;
+ if (this->direction - this->field_0x74.HALF.LO != dir - this->direction)
+ break;
+ }
+ iVar3 = (iVar3 + uVar4 + 3) % 3;
+ }
+
+ if (i == 3) {
+ dir = local_24;
+ }
+
+ if (this->field_0x74.HALF.LO != this->direction) {
+ this->field_0x74.HALF.LO = this->direction;
+ }
+ this->direction = dir;
+ sub_08029F0C(this);
+}
void sub_08029EEC(Entity* this) {
u32 uVar1 = (this->direction >> 3) + this->field_0x74.HALF.HI;
diff --git a/src/enemy/mulldozer.c b/src/enemy/mulldozer.c
index fbb376e0..854235de 100644
--- a/src/enemy/mulldozer.c
+++ b/src/enemy/mulldozer.c
@@ -436,7 +436,7 @@ void sub_08033320(MulldozerEntity* this) {
}
}
-NONMATCH("asm/non_matching/mulldozer/sub_08033364.inc", bool32 sub_08033364(MulldozerEntity* this)) {
+bool32 sub_08033364(MulldozerEntity* this) {
Entity* entity;
u32 radius;
u32 tmp;
@@ -452,14 +452,16 @@ NONMATCH("asm/non_matching/mulldozer/sub_08033364.inc", bool32 sub_08033364(Mull
if (super->type != 0) {
return TRUE;
}
- if (((GetFacingDirection(super, gUnk_020000B0) + 2) & 0x1c) >> 2 == super->animationState) {
+ tmp = GetFacingDirection(super, gUnk_020000B0);
+ tmp = Direction8RoundUp(tmp);
+ tmp = Direction8ToAnimationState(tmp);
+ if (super->animationState == tmp) {
return TRUE;
}
}
}
return FALSE;
}
-END_NONMATCH
void (*const Mulldozer_Functions[])(MulldozerEntity*) = {
Mulldozer_OnInit,
diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c
index 6a2874e9..29c2584f 100644
--- a/src/enemy/spearMoblin.c
+++ b/src/enemy/spearMoblin.c
@@ -24,7 +24,7 @@ extern void (*const SpearMoblin_Functions[])(Entity*);
extern void (*const gUnk_080CC7A8[])(Entity*);
extern const u8 gUnk_080CC7BC[];
extern const s8 gUnk_080CC7C0[];
-extern const u8 gUnk_080CC7D0[];
+extern const s8 gUnk_080CC7D0[];
extern const u16 gUnk_080CC7D8[];
extern const Hitbox* const gUnk_080CC944[];
@@ -242,7 +242,8 @@ void sub_08028528(Entity* this) {
}
}
-NONMATCH("asm/non_matching/spearMoblin/sub_08028604.inc", void sub_08028604(Entity* this)) {
+void sub_08028604(Entity* this) {
+ u32 iVar3;
this->subtimer = 0;
if (this->field_0x82.HALF.LO == 1) {
this->timer = gUnk_080CC7BC[Random() & 3];
@@ -251,12 +252,10 @@ NONMATCH("asm/non_matching/spearMoblin/sub_08028604.inc", void sub_08028604(Enti
u32 rand = Random();
u32 tmp;
tmp = gUnk_080CC7D0[rand & 7] + 0x18;
- tmp += this->direction;
- tmp &= 0x18;
- this->direction = tmp;
+ this->direction = DirectionRound(tmp + this->direction);
+ iVar3 = Direction8ToAnimationState(this->direction);
} else {
- u32 iVar3 = sub_08049EE4(this);
- s8 uVar1;
+ iVar3 = sub_08049EE4(this);
if (this->field_0x82.HALF.HI == 0) {
u32 rand = Random();
iVar3 += gUnk_080CC7C0[rand & 0xf];
@@ -267,18 +266,19 @@ NONMATCH("asm/non_matching/spearMoblin/sub_08028604.inc", void sub_08028604(Enti
this->field_0x82.HALF.HI--;
}
this->direction = (iVar3 + 4U) & 0x18;
+ iVar3 = Direction8ToAnimationState(this->direction);
}
} else {
- this->timer = 0xc;
+ this->timer = 12;
this->speed = 0;
+ iVar3 = Direction8ToAnimationState(this->direction);
}
- if (this->direction >> 2 != this->animationState) {
- this->animationState = this->direction >> 2;
+ if (iVar3 != this->animationState) {
+ this->animationState = iVar3;
sub_080287E0(this);
}
}
-END_NONMATCH
bool32 sub_080286CC(Entity* this) {
if (this->field_0x80.HALF.HI == 0) {
@@ -429,7 +429,7 @@ const s8 gUnk_080CC7C0[] = {
0x00, 0xFE,
};
-const u8 gUnk_080CC7D0[] = {
+const s8 gUnk_080CC7D0[] = {
0x08, 0x10,
0x08, 0x00,
0x10, 0x08,
diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c
index 1e78d133..a6f87b9d 100644
--- a/src/enemy/vaatiArm.c
+++ b/src/enemy/vaatiArm.c
@@ -858,9 +858,45 @@ static void sub_0804325C(Entity* this) {
}
}
-static ASM_FUNC("asm/non_matching/vaati/sub_080432A8.inc", void sub_080432A8(Entity* this))
+void sub_080432A8(Entity* this) {
+ s32 iVar3;
+ s32 i;
+ VaatiArm_HeapStruct1* hs;
+ Entity* ent;
+ i = 3;
+ iVar3 = 0;
+
+ for (; i >= 0; i--) {
+ hs = &((VaatiArm_HeapStruct*)this->myHeap)->s1[i];
+ if (hs->unk0c > 2) {
+ hs->unk0c--;
+ if (++iVar3 > 1) {
+ break;
+ }
+ }
+ }
+
+ hs = &((VaatiArm_HeapStruct*)this->myHeap)->s1[0];
+ hs->unk04.HALF.HI -= 2;
+
+ for (i = 0; i < 4; i++) {
+ ent = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
+ if (ent->z.HALF.HI < 4) {
+ COLLISION_ON(ent);
+ ent->spriteSettings.draw = 1;
+ }
+ }
- static NONMATCH("asm/non_matching/vaati/sub_0804334C.inc", void sub_0804334C(Entity* this)) {
+ if ((((VaatiArm_HeapStruct*)this->myHeap)->entities[0]->spriteSettings.draw == 1) &&
+ (((VaatiArm_HeapStruct*)this->myHeap)->s1[1].unk0c < 3)) {
+ this->subAction = 1;
+ this->timer = 0x1e;
+ ((VaatiArm_HeapStruct*)this->myHeap)->s1[0].unk04.HWORD = 0x4000;
+ sub_0804AA1C(((VaatiArm_HeapStruct*)this->myHeap)->entities[4]);
+ }
+}
+
+static NONMATCH("asm/non_matching/vaati/sub_0804334C.inc", void sub_0804334C(Entity* this)) {
int bVar1;
Entity* entity;
VaatiArm_HeapStruct1* s;
@@ -1162,9 +1198,32 @@ static u32 sub_080437DC(Entity* this) {
return 1;
}
-static ASM_FUNC("asm/non_matching/vaati/sub_0804393C.inc", void sub_0804393C(Entity* this))
+void sub_0804393C(Entity* this) {
+ s32 uVar1;
+ s32 uVar2;
+ s32 uVar6;
+ s32 iVar7;
+ VaatiArm_HeapStruct1* hs;
+ Entity* ent;
- static void sub_08043A10(Entity* this) {
+ ent = ((VaatiArm_HeapStruct*)this->myHeap)->entities[0];
+ if (ent->field_0x7c.BYTES.byte0 != 0 && ent->field_0x7c.BYTES.byte1 <= this->type) {
+ uVar2 = gUnk_080D1362[this->type * 16 + ((ent->field_0x7c.BYTES.byte0 >> 3) & 0xf)];
+ } else {
+ uVar2 = 0;
+ }
+ hs = &((VaatiArm_HeapStruct*)this->myHeap)->s1[this->type];
+ uVar2 = (uVar2 + hs->unk0c) << 8;
+ uVar1 = -gSineTable[hs->unk04.HALF.HI + 0x40] * uVar2;
+ uVar2 = (gSineTable[hs->unk04.HALF.HI & 0x7f] * uVar2) / 0x100;
+ uVar6 = gSineTable[hs->unk00.HALF.HI] * uVar2;
+ iVar7 = -gSineTable[hs->unk00.HALF.HI + 0x40] * uVar2;
+ PositionRelative(((VaatiArm_HeapStruct*)this->myHeap)->entities[this->type + 1], this, uVar6, iVar7);
+ this->z.WORD += uVar1;
+ this->spriteOffsetY = ((VaatiArm_HeapStruct*)this->myHeap)->entities[this->type + 1]->spriteOffsetY;
+}
+
+static void sub_08043A10(Entity* this) {
sub_08043B7C(this);
sub_0804393C(((VaatiArm_HeapStruct*)this->myHeap)->entities[4]);
((VaatiArm_HeapStruct*)this->myHeap)->entities[4]->y.HALF.HI -= 8;
diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c
index e01a1304..75d626f3 100644
--- a/src/object/figurineDevice.c
+++ b/src/object/figurineDevice.c
@@ -32,10 +32,11 @@ typedef struct {
/*0x80*/ u8 unk_80;
#endif
/*0x81*/ u8 unk_81;
- /*0x82*/ s8 unk_82;
#ifdef EU
+ /*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
#else
+ /*0x82*/ s8 unk_82;
/*0x83*/ s8 unk_83;
#endif
} FigurineDeviceEntity;
@@ -319,7 +320,122 @@ void sub_08087F58(FigurineDeviceEntity* this) {
}
}
-ASM_FUNC("asm/non_matching/figurineDevice/sub_08087F94.inc", void sub_08087F94(FigurineDeviceEntity* this, s32 param_2))
+void sub_08087F94(FigurineDeviceEntity* this, s32 param_2) {
+#ifdef EU
+ u32 uVar8;
+ u32 iVar9;
+
+ iVar9 = this->unk_83 + param_2;
+ if (CheckLocalFlag(SHOP07_COMPLETE)) {
+ sub_08088034(this);
+ return;
+ }
+
+ if (param_2 < 0) {
+ if (iVar9 < this->unk_82) {
+ if (this->unk_83 != this->unk_82) {
+ this->unk_83 = this->unk_82;
+ this->unk_81 = 1;
+ SoundReq(SFX_TEXTBOX_CHOICE);
+ } else {
+ sub_08088034(this);
+ }
+ } else {
+ this->unk_83 = iVar9;
+ this->unk_81 += param_2;
+ SoundReq(SFX_TEXTBOX_CHOICE);
+ }
+ return;
+ }
+ uVar8 = this->unk_81 + param_2;
+ if (uVar8 > (s32)gSave.stats.shells) {
+ if (gSave.stats.shells != this->unk_81) {
+ uVar8 = gSave.stats.shells;
+ param_2 = (gSave.stats.shells - this->unk_81);
+ iVar9 = this->unk_83 + param_2;
+ } else {
+ sub_08088034(this);
+ return;
+ }
+ } else if (iVar9 > 100) {
+ if (this->unk_83 == 100) {
+ sub_08088034(this);
+ return;
+ } else {
+ iVar9 = 100;
+ param_2 = (iVar9 - this->unk_83);
+ uVar8 = this->unk_81 + param_2;
+ }
+ }
+
+#else
+ s32 uVar8;
+ s32 iVar9;
+ s32 t1, t2;
+
+ if (CheckLocalFlag(SHOP07_COMPLETE)) {
+ sub_08088034(this);
+ return;
+ }
+
+ // This could probably be done without t1 and t2
+ t1 = this->unk_83;
+ iVar9 = t1 + param_2;
+ if (param_2 < 0) {
+ if (iVar9 < this->unk_82) {
+ if (this->unk_83 != this->unk_82) {
+ this->unk_83 = this->unk_82;
+ this->unk_81 = 1;
+ SoundReq(SFX_TEXTBOX_CHOICE);
+ } else {
+ sub_08088034(this);
+ }
+ } else {
+ this->unk_83 = iVar9;
+ this->unk_81 += param_2;
+ SoundReq(SFX_TEXTBOX_CHOICE);
+ }
+ return;
+ }
+ t2 = this->unk_81;
+ uVar8 = t2 + param_2;
+ if (uVar8 > gSave.stats.shells) {
+ if (gSave.stats.shells != this->unk_81) {
+ uVar8 = gSave.stats.shells;
+ param_2 = (gSave.stats.shells - this->unk_81);
+ iVar9 = t1 + param_2;
+#ifdef JP
+ if (iVar9 > 100) {
+ iVar9 = 100;
+ param_2 = (iVar9 - t1);
+ uVar8 = t2 + param_2;
+ }
+#endif
+ } else {
+ sub_08088034(this);
+ return;
+ }
+ }
+#ifdef JP
+ else if (iVar9 > 100) {
+#else
+ if (iVar9 > 100) {
+#endif
+ if (this->unk_83 == 100) {
+ sub_08088034(this);
+ return;
+ } else {
+ iVar9 = 100;
+ param_2 = (iVar9 - t1);
+ uVar8 = t2 + param_2;
+ }
+ }
+#endif
+
+ this->unk_83 = iVar9;
+ this->unk_81 = uVar8;
+ SoundReq(SFX_TEXTBOX_CHOICE);
+}
void sub_08088034(FigurineDeviceEntity* this) {
if (super->timer == 0) {
diff --git a/src/playerUtils.c b/src/playerUtils.c
index f8d2225c..3e23404a 100644
--- a/src/playerUtils.c
+++ b/src/playerUtils.c
@@ -1618,7 +1618,88 @@ u32 sub_080797C4(void) {
return tmp == (gPlayerEntity.collisions & tmp);
}
-ASM_FUNC("asm/non_matching/playerUtils/sub_080797EC.inc", void sub_080797EC())
+void sub_080797EC(void) {
+ u32 animation;
+
+ if ((gPlayerState.flags & PL_NO_CAP) != 0) {
+ if (gPlayerState.heldObject != 0) {
+ animation = 0x934;
+ } else if (gPlayerState.shield_status != 0) {
+ animation = 0x410;
+ } else if (gPlayerState.field_0x1f[2] == 0) {
+ if (gPlayerState.swim_state != 0) {
+ animation = 0x290;
+ } else {
+ animation = 0x16c;
+ if ((gPlayerState.sword_state & 0x48) != 0) {
+ gPlayerState.prevAnim = 0x6c;
+ return;
+ } else if (gPlayerState.sword_state == 0) {
+ if (gPlayerState.framestate == 0) {
+ gPlayerState.framestate = 1;
+ }
+ animation = 0x404;
+ } else {
+ animation = 0x16c;
+ if (sub_080793E4(0)) {
+ if (sub_080B1B44(GetPlayerTilePos(), gPlayerEntity.collisionLayer) != 0xff) {
+ gPlayerState.sword_state &= ~8;
+ animation = 0x170;
+ }
+ }
+ }
+ }
+ } else {
+ animation = 0x284;
+ }
+ } else {
+ if (gPlayerState.field_0x1c != 0) {
+ return;
+ } else if (gPlayerState.heldObject != 0) {
+ animation = 0x348;
+ } else if (gPlayerState.dash_state != 0) {
+ animation = 0x298;
+ } else if ((gPlayerState.flags & PL_IN_MINECART) != 0) {
+ animation = 0x710;
+ } else if (gPlayerState.shield_status != 0) {
+ animation = 0x160;
+ } else if (gPlayerState.field_0x1f[2] != 0) {
+ animation = 0x284;
+ } else {
+ if (gPlayerState.swim_state != 0) {
+ animation = 0x290;
+ } else {
+ animation = 0x16c;
+ if ((gPlayerState.sword_state & 0x48) != 0) {
+ gPlayerState.prevAnim = 0x6c;
+ return;
+ } else if (gPlayerState.sword_state != 0) {
+ animation = 0x16c;
+ if (sub_080793E4(0)) {
+ if (sub_080B1B44(GetPlayerTilePos(), (u32)gPlayerEntity.collisionLayer) != 0xff) {
+ gPlayerState.sword_state &= ~8;
+ animation = 0x170;
+ }
+ }
+ } else {
+ if (gPlayerState.framestate == 0) {
+ gPlayerState.framestate = 1;
+ }
+ if ((gPlayerState.flags & PL_USE_LANTERN) != 0) {
+ animation = 0x608;
+ } else {
+ animation = 0x104;
+ }
+ }
+ }
+ }
+ }
+ gPlayerState.animation = animation;
+
+ if (gPlayerState.shield_status == 0) {
+ UpdateAnimationSingleFrame(&gPlayerEntity);
+ }
+}
void ResolvePlayerAnimation(void) {
u32 index;
diff --git a/src/ui.c b/src/ui.c
index 47f3599b..613afa2e 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -63,6 +63,8 @@ extern struct_020350E2 gUnk_020350E2;
extern const u16 gUnk_080C8F2C[];
extern u32 gUnk_085C4620[];
extern Frame* gSpriteAnimations_322[];
+extern u16 gUnk_080C8F54[];
+extern u32 gUnk_080C8F7C[];
typedef struct {
u16 unk_0; // -> gOamCmd._4
@@ -491,7 +493,59 @@ void sub_0801C824(void) {
}
}
-ASM_FUNC("asm/non_matching/ui/DrawChargeBar.inc", void DrawChargeBar())
+void DrawChargeBar(void) {
+ bool32 tmp1;
+ u16* ptr1;
+ u32 tmp2;
+ u32 tmp3;
+ register u32 rem asm("r1");
+ u32 tmp5;
+
+ tmp1 = FALSE;
+ if ((gUnk_0200AF00.unk_1 & 0x20) == 0) {
+ tmp1 = gPlayerState.chargeState.action != 0;
+ }
+
+ if (!tmp1)
+ return sub_0801C824();
+
+ ptr1 = (gUnk_0200AF00.maxHealth > 0x28) ? (u16*)((u8*)(&gUnk_02034D30) + 0x40) : (u16*)&gUnk_02034D30.unk_0;
+
+ tmp2 = Div(gPlayerState.chargeState.chargeTimer + 19, 20);
+ if (tmp2 > 40) {
+ tmp2 = 40;
+ }
+ if (gUnk_0200AF00.unk_6 == 0 || gUnk_0200AF00.unk_7 != tmp2) {
+ gUnk_0200AF00.unk_6 = 1;
+ gUnk_0200AF00.unk_7 = tmp2;
+ tmp3 = Div(tmp2, 4);
+ tmp5 = rem;
+ ptr1[0] = 0xf016;
+ ptr1[11] = 0xf416;
+ DmaSet(3, gUnk_080C8F54 + (10 - tmp3), ptr1 + 1, 0x8000000a);
+ if (tmp5 != 0) {
+ ptr1[tmp3 + 1] = ((tmp5 + 0x17U) & 0x3ff) | 0xf000;
+ }
+ gScreen.bg0.updated = 1;
+ }
+
+ switch (gPlayerState.chargeState.action) {
+ case 4:
+ case 5:
+ gUnk_0200AF00.unk_9 += (gPlayerState.chargeState.action == 4) ? 2 : 1;
+ tmp3 = gUnk_0200AF00.unk_9 >> 4 & 3;
+ break;
+ default:
+ tmp3 = 0;
+ break;
+ }
+
+ if (tmp3 != gUnk_0200AF00.unk_8) {
+ gUnk_0200AF00.unk_8 = tmp3;
+ ptr1 = (u16*)0x600c2c0;
+ DmaSet(3, gUnk_080C8F7C[tmp3], ptr1, 0x84000030);
+ }
+}
void DrawKeys(void) {
s32 iVar1;