summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornotyouraveragehooman <65437533+notyouraveragehooman@users.noreply.github.com>2020-06-19 22:43:20 -0700
committerGitHub <noreply@github.com>2020-06-19 22:43:20 -0700
commit969241a1d0fdbd549c16e2aee22b4ece7c031793 (patch)
tree17df040c0a6cb997a0458bf8ac38fd40c610bd3a
parent373fb602b6b8d34624dd3a26223ed0d8e664b7d5 (diff)
Revert "Revert "mask.c OK""
-rw-r--r--asm/mask.s255
-rw-r--r--data/data_902.s2
-rw-r--r--include/entity.h2
-rw-r--r--linker.ld2
-rw-r--r--src/bladeBrothers.c2
-rw-r--r--src/bombPeahat.c2
-rw-r--r--src/flags.c2
-rw-r--r--src/greatFairy.c2
-rw-r--r--src/item.c2
-rw-r--r--src/keese.c2
-rw-r--r--src/mask.c142
-rw-r--r--src/npc.c2
-rw-r--r--src/object.c2
-rw-r--r--src/position.c2
-rw-r--r--src/rem.c2
-rw-r--r--src/simon.c2
-rw-r--r--src/syrup.c2
-rw-r--r--src/trig.c2
-rw-r--r--src/windTribeFlag.c2
-rw-r--r--src/windcrest.c2
20 files changed, 160 insertions, 273 deletions
diff --git a/asm/mask.s b/asm/mask.s
deleted file mode 100644
index 2b2977dc..00000000
--- a/asm/mask.s
+++ /dev/null
@@ -1,255 +0,0 @@
- .include "asm/macros.inc"
-
- .include "constants/constants.inc"
-
- .syntax unified
-
- .text
-
-
- thumb_func_start Mask
-Mask: @ 0x0809298C
- push {lr}
- ldr r2, _080929A0 @ =gUnk_081227A4
- ldrb r1, [r0, #0xc]
- lsls r1, r1, #2
- adds r1, r1, r2
- ldr r1, [r1]
- bl _call_via_r1
- pop {pc}
- .align 2, 0
-_080929A0: .4byte gUnk_081227A4
-
- thumb_func_start sub_080929A4
-sub_080929A4: @ 0x080929A4
- push {r4, r5, r6, lr}
- adds r5, r0, #0
- ldrb r1, [r5, #0xb]
- movs r6, #0xc0
- adds r0, r6, #0
- ands r0, r1
- cmp r0, #0
- beq _08092A08
- adds r4, r5, #0
- adds r4, #0x86
- ldrh r0, [r4]
- bl CheckFlags
- cmp r0, #0
- beq _08092A08
- ldrb r0, [r5, #0xb]
- adds r1, r6, #0
- ands r1, r0
- cmp r1, #0x40
- beq _080929D2
- cmp r1, #0x80
- beq _08092A04
- b _08092A08
-_080929D2:
- ldr r0, _080929F4 @ =gUnk_030010A0
- ldrh r1, [r0, #0xa]
- movs r0, #0xc1
- lsls r0, r0, #1
- cmp r1, r0
- beq _080929EE
- cmp r1, r0
- blt _080929FC
- ldr r0, _080929F8 @ =0x0000044F
- cmp r1, r0
- bgt _080929FC
- subs r0, #2
- cmp r1, r0
- blt _080929FC
-_080929EE:
- bl DeleteThisEntity
- b _08092A08
- .align 2, 0
-_080929F4: .4byte gUnk_030010A0
-_080929F8: .4byte 0x0000044F
-_080929FC:
- ldrh r0, [r4]
- bl ClearFlag
- b _08092A08
-_08092A04:
- bl DeleteThisEntity
-_08092A08:
- movs r0, #1
- strb r0, [r5, #0xc]
- movs r0, #0xc0
- lsls r0, r0, #9
- str r0, [r5, #0x20]
- bl Random
- movs r1, #7
- ands r0, r1
- lsls r0, r0, #0xa
- movs r2, #0x80
- lsls r2, r2, #6
- adds r1, r2, #0
- adds r2, r5, #0
- adds r2, #0x78
- movs r3, #0
- orrs r0, r1
- strh r0, [r2]
- ldrb r0, [r5, #0xe]
- lsrs r0, r0, #1
- strb r0, [r5, #0xf]
- strb r3, [r5, #0xe]
- ldrb r1, [r5, #0xb]
- movs r0, #0x3f
- ands r0, r1
- strb r0, [r5, #0x1e]
- movs r4, #0x2e
- ldrsh r1, [r5, r4]
- ldr r2, _08092A8C @ =gRoomControls
- ldrh r0, [r2, #6]
- subs r1, r1, r0
- asrs r1, r1, #4
- movs r3, #0x3f
- ands r1, r3
- movs r4, #0x32
- ldrsh r0, [r5, r4]
- ldrh r2, [r2, #8]
- subs r0, r0, r2
- asrs r0, r0, #4
- ands r0, r3
- lsls r0, r0, #6
- orrs r1, r0
- adds r4, r5, #0
- adds r4, #0x7e
- strh r1, [r4]
- ldrh r0, [r4]
- movs r1, #1
- bl sub_080001DA
- adds r1, r5, #0
- adds r1, #0x7c
- strh r0, [r1]
- ldrh r0, [r4]
- movs r1, #1
- bl sub_080002E0
- adds r1, r5, #0
- adds r1, #0x7a
- strh r0, [r1]
- ldr r0, _08092A90 @ =0x00004022
- ldrh r1, [r4]
- movs r2, #1
- bl SetTile
- pop {r4, r5, r6, pc}
- .align 2, 0
-_08092A8C: .4byte gRoomControls
-_08092A90: .4byte 0x00004022
-
- thumb_func_start sub_08092A94
-sub_08092A94: @ 0x08092A94
- push {r4, r5, lr}
- adds r4, r0, #0
- ldr r2, _08092B08 @ =gLinkEntity
- ldrb r0, [r2, #0xc]
- cmp r0, #6
- bne _08092B04
- ldrb r0, [r2, #0x14]
- cmp r0, #0
- bne _08092B04
- movs r1, #0x32
- ldrsh r0, [r4, r1]
- adds r0, #0x28
- movs r3, #0x32
- ldrsh r1, [r2, r3]
- cmp r0, r1
- blt _08092B04
- movs r0, #0x2e
- ldrsh r1, [r4, r0]
- movs r3, #0x2e
- ldrsh r0, [r2, r3]
- subs r1, r1, r0
- ldrb r0, [r4, #0xf]
- cmp r1, r0
- bge _08092B04
- cmn r1, r0
- ble _08092B04
- adds r0, r4, #0
- adds r0, #0x7c
- ldrh r0, [r0]
- adds r5, r4, #0
- adds r5, #0x7e
- ldrh r1, [r5]
- movs r2, #1
- bl SetTile
- adds r0, r4, #0
- adds r0, #0x7a
- ldrh r0, [r0]
- ldrh r1, [r5]
- movs r2, #1
- bl sub_08000148
- movs r0, #2
- strb r0, [r4, #0xc]
- ldrh r0, [r4, #0x36]
- subs r0, #0x20
- strh r0, [r4, #0x36]
- ldrh r0, [r4, #0x32]
- adds r0, #0x20
- strh r0, [r4, #0x32]
- ldrb r1, [r4, #0x19]
- movs r0, #0x3f
- ands r0, r1
- movs r1, #0x80
- orrs r0, r1
- strb r0, [r4, #0x19]
-_08092B04:
- pop {r4, r5, pc}
- .align 2, 0
-_08092B08: .4byte gLinkEntity
-
- thumb_func_start sub_08092B0C
-sub_08092B0C: @ 0x08092B0C
- push {r4, lr}
- adds r4, r0, #0
- ldrb r0, [r4, #0xe]
- cmp r0, #1
- bne _08092B50
- movs r0, #0
- movs r1, #3
- strb r1, [r4, #0xc]
- strb r0, [r4, #0xe]
- ldrb r0, [r4, #0xb]
- movs r1, #0xc0
- ands r1, r0
- cmp r1, #0x40
- beq _08092B32
- cmp r1, #0x80
- bne _08092B3C
- movs r0, #0x72
- bl sub_08004488
-_08092B32:
- adds r0, r4, #0
- adds r0, #0x86
- ldrh r0, [r0]
- bl SetFlag
-_08092B3C:
- adds r0, r4, #0
- movs r1, #5
- movs r2, #0
- bl CreateFx
- adds r0, r4, #0
- movs r1, #3
- bl sub_0805457C
- b _08092B6A
-_08092B50:
- adds r0, r4, #0
- adds r0, #0x78
- ldrh r1, [r0]
- adds r0, r4, #0
- bl sub_080044EC
- movs r1, #0x36
- ldrsh r0, [r4, r1]
- cmp r0, #0
- bne _08092B6A
- ldrb r0, [r4, #0xe]
- adds r0, #1
- strb r0, [r4, #0xe]
-_08092B6A:
- pop {r4, pc}
-
- thumb_func_start sub_08092B6C
-sub_08092B6C: @ 0x08092B6C
- push {lr}
- bl DeleteThisEntity
- pop {pc}
diff --git a/data/data_902.s b/data/data_902.s
index a1062359..f72f7efa 100644
--- a/data/data_902.s
+++ b/data/data_902.s
@@ -1360,7 +1360,7 @@ gUnk_08122794:: @ 08122794
gUnk_0812279C:: @ 0812279C
.incbin "baserom.gba", 0x12279C, 0x0000008
-gUnk_081227A4:: @ 081227A4
+MaskActionFuncs:: @ 081227A4
.incbin "baserom.gba", 0x1227A4, 0x0000010
gUnk_081227B4:: @ 081227B4
diff --git a/include/entity.h b/include/entity.h
index e3f86c82..897ca064 100644
--- a/include/entity.h
+++ b/include/entity.h
@@ -136,7 +136,7 @@ typedef struct Entity {
u32* heldObjectPtr;
u16 field_0x78;
u16 itemCooldown;
- u32 field_0x7c;
+ union SplitWord field_0x7c;
u16 field_0x80;
u16 field_0x82;
union SplitHWord cutsceneBeh;
diff --git a/linker.ld b/linker.ld
index bd32465c..2a2b0dd5 100644
--- a/linker.ld
+++ b/linker.ld
@@ -684,7 +684,7 @@ SECTIONS {
asm/lavaPlatform.o(.text);
asm/object5A.o(.text);
asm/object5B.o(.text);
- asm/mask.o(.text);
+ src/mask.o(.text);
asm/houseDoorInterior.o(.text);
asm/whirlwind.o(.text);
asm/objectBlockingStairs.o(.text);
diff --git a/src/bladeBrothers.c b/src/bladeBrothers.c
index fedaef0f..69a981f0 100644
--- a/src/bladeBrothers.c
+++ b/src/bladeBrothers.c
@@ -411,4 +411,4 @@ void BladeBrothers_Fusion(Entity* this) {
this->frames.all &= 0xfe;
sub_08068BEC(this, 0);
}
-} \ No newline at end of file
+}
diff --git a/src/bombPeahat.c b/src/bombPeahat.c
index efd14570..b5dda939 100644
--- a/src/bombPeahat.c
+++ b/src/bombPeahat.c
@@ -84,4 +84,4 @@ void nullsub_143(Entity* this){}
void sub_0802A91C(Entity *this)
{
this->currentHealth = 0;
-} \ No newline at end of file
+}
diff --git a/src/flags.c b/src/flags.c
index 64351e6e..5cce7c9e 100644
--- a/src/flags.c
+++ b/src/flags.c
@@ -130,4 +130,4 @@ void ClearGlobalFlag(u32 flag) {
void ClearRoomFlag(u32 flag) {
ClearBit(&gRoomFlags, flag);
-} \ No newline at end of file
+}
diff --git a/src/greatFairy.c b/src/greatFairy.c
index 28e9de33..02b5268b 100644
--- a/src/greatFairy.c
+++ b/src/greatFairy.c
@@ -579,4 +579,4 @@ void (*const GreatFairy_Form2Behaviors[])(Entity*) = {
sub_0808727C
};
-//clang-format on \ No newline at end of file
+//clang-format on
diff --git a/src/item.c b/src/item.c
index e89a3948..49afb9e6 100644
--- a/src/item.c
+++ b/src/item.c
@@ -35,4 +35,4 @@ void (*const gItemFunctions[])(ItemBehavior*, u32) = {
JarEmpty,
JarEmpty,
JarEmpty,
-}; \ No newline at end of file
+};
diff --git a/src/keese.c b/src/keese.c
index 22aee9d9..b9914c2f 100644
--- a/src/keese.c
+++ b/src/keese.c
@@ -131,4 +131,4 @@ void sub_08021EF0(Entity *this)
this->field_0x78 = gUnk_080CB6D6[Random() & 0xf];
this->itemCooldown = 0x3c;
InitializeAnimation(this, 0);
-} \ No newline at end of file
+}
diff --git a/src/mask.c b/src/mask.c
new file mode 100644
index 00000000..d33f3481
--- /dev/null
+++ b/src/mask.c
@@ -0,0 +1,142 @@
+#include "global.h"
+#include "entity.h"
+#include "room.h"
+#include "random.h"
+
+extern Entity gLinkEntity;
+extern u16 gUnk_030010A0[];
+
+extern void (*MaskActionFuncs[])(Entity *);
+
+extern void DeleteThisEntity();
+
+extern bool32 CheckFlags(u16);
+extern void SetFlag(u16);
+extern void ClearFlag(u16);
+
+extern void SetTile(u32, u16, u32);
+
+extern void CreateFx(Entity *, u16, u16);
+
+extern void sub_08000148(u16, u16, u32);
+extern s16 sub_080001DA(u16, u32);
+extern u16 sub_080002E0(u16, u32);
+
+extern void sub_08004488(u32);
+extern void sub_080044EC(Entity *, u16);
+extern void sub_0805457C(Entity *, s32);
+
+
+void Mask(Entity *this) {
+ MaskActionFuncs[this->action](this);
+}
+
+void sub_080929A4(Entity *this) {
+ if (this->entityType.parameter & 0xC0) {
+ if (CheckFlags(this->field_0x86)) {
+ s32 field_0x0a;
+
+ switch (this->entityType.parameter & 0xC0) {
+ case 0x40:
+ field_0x0a = gUnk_030010A0[0x5];
+
+ switch (field_0x0a) {
+ case 0x44D ... 0x44F:
+ case 0x182:
+ DeleteThisEntity();
+ goto switchEnd;
+ }
+
+ ClearFlag(this->field_0x86);
+ break;
+ case 0x80:
+ DeleteThisEntity();
+ break;
+ }
+ switchEnd:
+ }
+ }
+
+ this->action = 1;
+ this->field_0x20 = 0x18000;
+
+ this->field_0x78 = ((Random() & 7) << 10) | 0x2000;
+
+ this->field_0xf = this->actionDelay >> 1;
+ this->actionDelay = 0;
+
+ this->frameIndex = this->entityType.parameter & 0x3f;
+
+ this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
+ this->field_0x7c.HALF.LO = sub_080001DA(this->field_0x7c.HALF.HI, 1);
+
+ this->itemCooldown = sub_080002E0(this->field_0x7c.HALF.HI, 1);
+
+ SetTile(0x4022, this->field_0x7c.HALF.HI, 1);
+}
+
+// Probably related to knocking it down
+void sub_08092A94(Entity *this) {
+ // Check for the first frame of bonking animation
+ if (gLinkEntity.action != 6) {
+ return;
+ }
+
+ if (gLinkEntity.animationState != 0) {
+ return;
+ }
+
+ // Check if link is close enough to the mask
+ if (this->y.HALF.HI + 40 < gLinkEntity.y.HALF.HI) {
+ return;
+ }
+
+ if (this->x.HALF.HI - gLinkEntity.x.HALF.HI >= this->field_0xf || this->x.HALF.HI - gLinkEntity.x.HALF.HI <= -this->field_0xf) {
+ return;
+ }
+
+ // Presumably, make the mask fall
+ SetTile((u16)this->field_0x7c.HALF.LO, this->field_0x7c.HALF.HI, 1);
+
+ sub_08000148(this->itemCooldown, this->field_0x7c.HALF.HI, 1);
+
+ this->action = 2;
+
+ this->height.HALF.HI -= 0x20;
+ this->y.HALF.HI += 0x20;
+
+ this->spriteOrder.b3 = 2;
+}
+
+// Probably falling down
+void sub_08092B0C(Entity *this) {
+ if (this->actionDelay == 1) {
+ this->action = 3;
+
+ this->actionDelay = 0;
+ switch (this->entityType.parameter & 0xC0)
+ {
+ case 0x80:
+ sub_08004488(0x72);
+ case 0x40:
+ SetFlag(this->field_0x86);
+ break;
+
+ }
+
+ CreateFx(this, 5, 0);
+
+ sub_0805457C(this, 3);
+ }
+ else {
+ sub_080044EC(this, this->field_0x78);
+
+ if (this->height.HALF.HI == 0) {
+ this->actionDelay++;
+ }
+ }
+}
+
+void Mask_Delete(Entity *this) {
+ DeleteThisEntity();
+}
diff --git a/src/npc.c b/src/npc.c
index 49e6453f..dbd376e7 100644
--- a/src/npc.c
+++ b/src/npc.c
@@ -135,4 +135,4 @@ void (*const gNPCFunctions[][3])(Entity* ent) = {
{ DeleteEntity, NULL, NULL }
};
//clang-format on
-const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 }; \ No newline at end of file
+const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 };
diff --git a/src/object.c b/src/object.c
index d4062e0b..6e526824 100644
--- a/src/object.c
+++ b/src/object.c
@@ -198,4 +198,4 @@ void (*const gObjectFunctions[])(Entity*) = {
EnemyItem,
ObjectC1,
};
-//clang-format on \ No newline at end of file
+//clang-format on
diff --git a/src/position.c b/src/position.c
index f1711a4a..1c96046f 100644
--- a/src/position.c
+++ b/src/position.c
@@ -53,4 +53,4 @@ void ResolveEntityOnTop(Entity *param_1,Entity *param_2)
void sub_0806FAD8(Entity *param_1,Entity *param_2)
{
param_2->ticks.b0 = gUnk_08114F80[param_1->ticks.b0];
-} \ No newline at end of file
+}
diff --git a/src/rem.c b/src/rem.c
index 93180c5e..8e3fe38f 100644
--- a/src/rem.c
+++ b/src/rem.c
@@ -52,4 +52,4 @@ void sub_0806A3D8(Entity *this)
uVar1 = StartCutscene(this,&gUnk_08012F0C);
*(u32 *)&this->cutsceneBeh = (u32)uVar1;
sub_0807DD94(this, 0);
-} \ No newline at end of file
+}
diff --git a/src/simon.c b/src/simon.c
index 1e56d6bc..45046de5 100644
--- a/src/simon.c
+++ b/src/simon.c
@@ -65,4 +65,4 @@ void sub_0806C2A0(u32 *param_1,struct_0806C2A0 *param_2)
DoFade(0xc, 4);
break;
}
-} \ No newline at end of file
+}
diff --git a/src/syrup.c b/src/syrup.c
index 3e26793a..4f0badb4 100644
--- a/src/syrup.c
+++ b/src/syrup.c
@@ -74,4 +74,4 @@ void sub_0806A26C(Entity *this)
{
asm(".include \"asm/non_matching/syrup/sub_0806A26C.inc\"");
}
-#endif \ No newline at end of file
+#endif
diff --git a/src/trig.c b/src/trig.c
index 7f546eae..a406599f 100644
--- a/src/trig.c
+++ b/src/trig.c
@@ -327,4 +327,4 @@ const s16 gCosineTable[] = {
Q_8_8(0.99609375), // sin(317*(π/128))
Q_8_8(0.99609375), // sin(318*(π/128))
Q_8_8(0.99609375), // sin(319*(π/128))
-}; \ No newline at end of file
+};
diff --git a/src/windTribeFlag.c b/src/windTribeFlag.c
index b8257ff5..b17e9e9e 100644
--- a/src/windTribeFlag.c
+++ b/src/windTribeFlag.c
@@ -22,4 +22,4 @@ void WindTribeFlag(Entity *this)
if (this->frameDuration == 0xff) {
this->frameDuration = (Random() & 0xf) + 0x10;
}
-} \ No newline at end of file
+}
diff --git a/src/windcrest.c b/src/windcrest.c
index 0429a658..231eb425 100644
--- a/src/windcrest.c
+++ b/src/windcrest.c
@@ -38,4 +38,4 @@ void Windcrest_Unlock(Entity *this)
PlaySFX(0x72);
gUnk_02002A40.windcrests = gUnk_02002A40.windcrests | 1 << (this->entityType.parameter + 0x18);
CreateFx(this, 0x46, 0);
-} \ No newline at end of file
+}