summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortheo3 <arisstephenson2@gmail.com>2020-07-11 22:13:00 -0700
committertheo3 <arisstephenson2@gmail.com>2020-07-11 22:13:00 -0700
commitcdeae36d0979cb025262d6d85e45f7bf7b9bbae5 (patch)
tree0e5e5a6a3c70f5396cc654a55417c9fc052dec5a /src
parent9753a51b924dc60697d74dd116da5e169dbc05a7 (diff)
smith.c OK
Diffstat (limited to 'src')
-rw-r--r--src/fan.c77
-rw-r--r--src/manager1.c64
-rw-r--r--src/manager2.c18
-rw-r--r--src/smith.c225
-rw-r--r--src/zelda.c4
5 files changed, 386 insertions, 2 deletions
diff --git a/src/fan.c b/src/fan.c
index 93910dc7..481e3887 100644
--- a/src/fan.c
+++ b/src/fan.c
@@ -1,9 +1,86 @@
#include "global.h"
#include "entity.h"
+#include "flags.h"
+
+extern void sub_0809EE34(Entity*);
+extern void sub_0809EFB0(Entity*);
+extern void sub_0809EE08(Entity*);
+extern void sub_0809F08C(void);
+extern void sub_0809EE44(Entity*);
+extern void sub_0809EE24(Entity*);
extern void (*const gUnk_081243D4[])(Entity*);
void Fan(Entity *this)
{
gUnk_081243D4[this->action](this);
+}
+
+void sub_0809ED30(Entity *this)
+{
+ this->direction = (this->entityType.form ^ 2) << 3;
+ sub_0809EE34(this);
+ sub_0809EFB0(this);
+ InitializeAnimation(this, this->entityType.form);
+}
+
+void sub_0809ED54(Entity *this)
+{
+ u16 uVar1;
+ u32 iVar2;
+
+ if (((this->cutsceneBeh.HWORD == 0) || CheckFlags(this->cutsceneBeh.HWORD)) &&
+ ((this->entityType.parameter != 1 ||
+ (--this->field_0x74 == 0)))) {
+ sub_0809EE08(this);
+ }
+}
+
+void sub_0809ED88(Entity *this)
+{
+ sub_0809F08C();
+ sub_0809EE44(this);
+ if (this->field_0x86 != 0) {
+ if (this->cutsceneBeh.HWORD == this->field_0x86) {
+ if (CheckFlags(this->cutsceneBeh.HWORD)) {
+ return;
+ }
+ }
+ else if (!CheckFlags(this->cutsceneBeh.HWORD)) {
+ return;
+ }
+ sub_0809EE24(this);
+ }
+ else if (((this->entityType).parameter == 1) &&
+ (--this->field_0x74 == 0)) {
+ sub_0809EE24(this);
+ }
+}
+
+void sub_0809EDE4(Entity *this)
+{
+ sub_0809F08C();
+ sub_0809EE44(this);
+ if (this->frames.b.f3) {
+ sub_0809EE34(this);
+ }
+}
+
+void sub_0809EE08(Entity *this)
+{
+ this->action = 2;
+ this->field_0x74 = *((u8 *)&this->field_0x7c + 3) << 2;
+ InitializeAnimation(this, this->entityType.form);
+}
+
+void sub_0809EE24(Entity *this)
+{
+ this->action = 3;
+ InitializeAnimation(this, this->entityType.form + 4);
+}
+
+void sub_0809EE34(Entity *this)
+{
+ this->action = 1;
+ this->field_0x74 = this->actionDelay << 2;
} \ No newline at end of file
diff --git a/src/manager1.c b/src/manager1.c
new file mode 100644
index 00000000..ba556db0
--- /dev/null
+++ b/src/manager1.c
@@ -0,0 +1,64 @@
+#include "global.h"
+#include "entity.h"
+#include "screen.h"
+
+extern void sub_0801D7EC(u32);
+extern void sub_08056250(void);
+extern void sub_080570B8(Entity*);
+void sub_080570F8(void);
+extern void sub_08052D74(void*, void*, void*);
+
+extern void (*const gUnk_08107C5C[])(Entity*);
+extern void (*const gUnk_08107C48[])(Entity*);
+
+extern u8 gUnk_08107C40[];
+
+void Manager1(Entity *this)
+{
+ u8 bVar1;
+ u8 *pbVar2;
+
+ gUnk_08107C5C[this->action](this);
+ gUnk_08107C48[((u8*)&this->field_0x20)[1]](this);
+ bVar1 = gUnk_08107C40[((u8*)&this->field_0x20)[1]];
+ if ((bVar1 != 0) && (*(u8 *)&this->field_0x20 != bVar1)) {
+ ((u8*)&this->field_0x20)[0] = bVar1;
+ sub_0801D7EC(bVar1);
+ }
+}
+
+void sub_080570B8(Entity *this)
+{
+ u8 *pbVar1;
+
+ sub_0801D7EC(((u8 *)&this->field_0x20)[0]);
+ this->height.WORD = 0;
+ pbVar1 = ((u8 *)&this->field_0x20 + 1);
+ if (*pbVar1 == 3) {
+ gScreen.affine.bg3xOffset = 1;
+ }
+ else {
+ gUnk_08107C48[*pbVar1](this);
+ }
+}
+
+void sub_080570F8(void)
+{
+ gScreen.lcd.lcdControl2 &= 0xf7ff;
+ gScreen.controls.windowOutsideControl = 0;
+ sub_08056250();
+}
+
+void sub_08057118(Entity *this)
+{
+ this->actionDelay = 0;
+ *(u8 *)&this->field_0x20 = 0;
+ ((u8 *)&this->field_0x20)[1] = 0;
+ ((u8 *)&this->field_0x20)[2] = 0;
+ this->action = 1;
+ gScreen.affine.unk2 = 0x1e04;
+ *(u16 *)&gScreen.lcd.lcdControl2 |= 0x800;
+ gScreen.controls.windowOutsideControl = 0x3648;
+ gScreen.controls.mosaicSize = 0x1000;
+ sub_08052D74(this, sub_080570B8, sub_080570F8);
+} \ No newline at end of file
diff --git a/src/manager2.c b/src/manager2.c
new file mode 100644
index 00000000..707c13d1
--- /dev/null
+++ b/src/manager2.c
@@ -0,0 +1,18 @@
+#include "global.h"
+#include "entity.h"
+#include "screen.h"
+
+extern void sub_080576A0();
+extern void sub_08052D74();
+extern void sub_0805754C(Entity*);
+
+void Manager2(Entity *this)
+{
+ if (this->action == 0) {
+ this->action = 1;
+ gScreen.affine.bg3xOffset = 0;
+ gScreen.bg2.bg0xOffset = 0;
+ sub_08052D74(this, sub_080576A0, 0);
+ }
+ sub_0805754C(this);
+} \ No newline at end of file
diff --git a/src/smith.c b/src/smith.c
new file mode 100644
index 00000000..061d3c40
--- /dev/null
+++ b/src/smith.c
@@ -0,0 +1,225 @@
+#include "global.h"
+#include "entity.h"
+#include "textbox.h"
+
+typedef struct {
+ u8 filler[8];
+ u8 unk;
+} struct_02002A40;
+
+extern u32 GetFacingDirection(Entity*, Entity*);
+extern u32 sub_0806F5A4(u32);
+extern void sub_0806F118(Entity*);
+extern void sub_0806ED78(Entity*);
+extern Entity* CreateFx(Entity*, u32, u32);
+extern void PlaySFX(u32);
+extern u32 Random(void);
+extern void sub_0807000C(Entity*);
+extern u32 sub_0801E99C(Entity*);
+extern u32 sub_0806ED9C(Entity*, u32, u32);
+extern u32 sub_0806F078(Entity*, u32);
+extern void sub_0807DD50(Entity*);
+extern void sub_0807DD94(Entity*, u32);
+extern void sub_0807DDAC(Entity*, u32);
+extern void sub_0807DDE4(Entity*);
+extern u32 UpdateFuseInteraction(Entity*);
+extern u32 GetAnimationState(Entity*);
+extern void ShowNPCDialogue(Entity*, u32*);
+extern void sub_08078850(u32, u32, u32, u32*);
+extern void sub_08078784(Entity*, u32);
+
+extern void (*const gUnk_08110360[])(Entity*);
+extern void (*const gUnk_0811036C[])(Entity*);
+
+extern u16 gUnk_08110380[];
+extern SpriteLoadData gUnk_08110354;
+extern struct_02002A40 gUnk_02002A40;
+extern u32 gUnk_08110390[];
+extern u16 gUnk_081103D0[];
+extern u32 gUnk_081103E0;
+
+#if NON_MATCHING //reg-alloc
+void Smith(Entity *this)
+{
+ u32 iVar2;
+ u32 iVar4;
+
+ if ((this->flags & 2) != 0) {
+ if (this->interactType == 2) {
+ this->action = 4;
+ this->interactType = 0;
+ iVar4 = (this->animIndex == 0xc) ? 8 : 0;
+ iVar2 = sub_0806F5A4(GetFacingDirection(this, &gLinkEntity));
+ InitAnimationForceUpdate(this, iVar2 + iVar4);
+ sub_0806F118(this);
+ }
+ gUnk_0811036C[this->action](this);
+ }
+ else {
+ gUnk_08110360[this->action](this);
+ sub_0806ED78(this);
+ }
+ if (this->animIndex == 0xc) {
+ this->spritePriority.b1 = 0;
+ }
+ else {
+ this->spritePriority.b1 = 1;
+ }
+ if ((this->frames.all & 1) != 0) {
+ this->frames.all &= 0xfe;
+ CreateFx(this, 0x3d, 0x20);
+ PlaySFX(gUnk_08110380[(Random() & 7)]);
+ }
+}
+#else
+NAKED
+void Smith(Entity *this) {
+ asm(".include \"asm/non_matching/smith/smith.inc\"");
+}
+#endif
+
+void Smith_Head(Entity *this)
+{
+ u8 bVar1;
+
+ bVar1 = this->frames.all;
+ SetExtraSpriteFrame(this, 0, this->frameIndex);
+ if ((bVar1 & 0x40) != 0) {
+ SetExtraSpriteFrame(this, 1, 0x16);
+ }
+ else {
+ SetExtraSpriteFrame(this, 1, 0xff);
+ }
+ SetSpriteSubEntryOffsetData1(this,0,1);
+ sub_0807000C(this);
+}
+
+void sub_080660EC(Entity *this)
+{
+ if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) {
+ this->action = 1;
+ this->field_0x68 = sub_0801E99C(this);
+ InitAnimationForceUpdate(this, 2);
+ }
+}
+
+void sub_08066118(Entity *this)
+{
+ s32 uVar1;
+ u32 iVar2;
+
+ uVar1 = sub_0806ED9C(this, 0x28, 0x28);
+ if (uVar1 < 0) {
+ uVar1 = 2;
+ }
+ else {
+ if (this->field_0xf == 0) {
+ this->field_0xf = 0x10;
+ }
+ else {
+ --this->field_0xf;
+ uVar1 = this->animIndex;
+ }
+ }
+ if (sub_0806F078(this, uVar1) == 0) {
+ UpdateAnimationSingleFrame(this);
+ }
+ if (this->interactType != 0) {
+ this->action = 2;
+ TextboxNoOverlapFollow(0);
+ }
+}
+
+void sub_08066170(Entity *this)
+{
+ this->action = 1;
+}
+
+void sub_08066178(Entity *this)
+{
+ if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) {
+ this->action = 1;
+ this->spriteSettings.b.draw = 1;
+ this->field_0x68 = sub_0801E99C(this);
+ sub_0807DD50(this);
+ }
+}
+
+void sub_080661B0(Entity *this)
+{
+ sub_0807DD94(this, 0);
+}
+
+void sub_080661BC(Entity *this)
+{
+ u32 sVar1;
+
+ if (this->animIndex == 0xc) {
+ UpdateAnimationSingleFrame(this);
+ if ((this->frames.b.f3) != 0) {
+ this->field_0x80 = GetAnimationState(this) + 8;
+ InitAnimationForceUpdate(this, this->field_0x80);
+ }
+ }
+ else {
+ sub_0807DD94(this,0);
+ }
+}
+
+void sub_08066200(Entity *this)
+{
+ sub_0807DDAC(this, 0);
+ sub_0807DDE4(this);
+ UpdateAnimationSingleFrame(this);
+}
+
+void sub_08066218(Entity *this)
+{
+ if (UpdateFuseInteraction(this) != 0) {
+ this->action = 1;
+ }
+}
+
+void sub_0806622C(Entity *this)
+{
+ u32 iVar1;
+
+ if (gUnk_02002A40.unk - 2 < 0) {
+ iVar1 = 0;
+ }
+ else {
+ iVar1 = gUnk_02002A40.unk - 2;
+ }
+ ShowNPCDialogue(this, &gUnk_08110390[iVar1 * 2]);
+}
+
+void nullsub_501(Entity* this) {}
+
+void sub_08066258(void)
+{
+ PlaySFX(gUnk_081103D0[Random() & 7]);
+}
+
+void sub_08066274(u32 arg0)
+{
+ sub_08078850(arg0, 1, 0, &gUnk_081103E0);
+}
+
+void sub_08066288(Entity *arg0)
+{
+ sub_08078784(arg0, arg0->field_0x68);
+}
+
+void Smith_Fusion(Entity *this)
+{
+ if (this->action == 0) {
+ if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) {
+ this->action++;
+ this->spriteSettings.b.draw = 1;
+ InitAnimationForceUpdate(this, 6);
+ }
+ }
+ else {
+ UpdateAnimationSingleFrame(this);
+ }
+} \ No newline at end of file
diff --git a/src/zelda.c b/src/zelda.c
index 8aa89a33..2ba8bf28 100644
--- a/src/zelda.c
+++ b/src/zelda.c
@@ -11,7 +11,7 @@ extern Entity* sub_0805EB9C(u32, u32);
void CopyPosition(Entity*, Entity*);
void sub_08068680(Entity*, Entity*);
void sub_08068694(Entity*, Entity*);
-u32 sub_0806EDC4(Entity* ent);
+u32 GetAnimationState(Entity* ent);
void DeleteThisEntity(void);
extern Entity* GetEntityByType(u32, u32);
extern void sub_080686C4(Entity*, Entity*);
@@ -89,7 +89,7 @@ void sub_08066D94(Entity* ent) {
if (npc != NULL) {
npc->animationState = gLinkEntity.animationState;
npc->flags |= 0x20;
- npc->animationState = sub_0806EDC4(ent);
+ npc->animationState = GetAnimationState(ent);
roomID = gRoomControls.roomID;
npc->field_0x74 = roomID;
CopyPosition(ent, npc);