Improve mask.c, update to latest Entity struct

Also ran format.sh which changed various files
This commit is contained in:
21aslade 2020-06-19 22:33:45 -06:00
parent d13da4af82
commit 31f1937534
17 changed files with 58 additions and 43 deletions

View File

@ -1360,7 +1360,7 @@ gUnk_08122794:: @ 08122794
gUnk_0812279C:: @ 0812279C gUnk_0812279C:: @ 0812279C
.incbin "baserom.gba", 0x12279C, 0x0000008 .incbin "baserom.gba", 0x12279C, 0x0000008
gUnk_081227A4:: @ 081227A4 MaskActionFuncs:: @ 081227A4
.incbin "baserom.gba", 0x1227A4, 0x0000010 .incbin "baserom.gba", 0x1227A4, 0x0000010
gUnk_081227B4:: @ 081227B4 gUnk_081227B4:: @ 081227B4

View File

@ -3,39 +3,44 @@
#include "room.h" #include "room.h"
#include "random.h" #include "random.h"
#define COORD_TO_TILE(entity) ((((entity->x.HALF.HI - gRoomControls.roomOriginX) >> 4) & 0x3fU) | (((entity->y.HALF.HI - gRoomControls.roomOriginY) >> 4) & 0x3fU) << 6)
extern void (*gUnk_081227A4[])(Entity *);
extern void DeleteThisEntity();
extern u16 gUnk_030010A0[];
extern bool32 CheckFlags(u16);
extern void ClearFlag(u16);
extern s16 sub_080001DA(u16, u32);
extern void SetTile(u32, u16, u32);
extern u16 sub_080002E0(u16, u32);
extern void sub_08000148(u16, u16, u32);
extern Entity gLinkEntity; 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_08004488(u32);
extern void sub_080044EC(Entity *, u16); extern void sub_080044EC(Entity *, u16);
extern void CreateFx(Entity *, u16, u16);
extern void sub_0805457C(Entity *, s32); extern void sub_0805457C(Entity *, s32);
extern void SetFlag(u16);
void Mask(Entity *this) { void Mask(Entity *this) {
gUnk_081227A4[this->action](this); MaskActionFuncs[this->action](this);
} }
void sub_080929A4(Entity *this) { void sub_080929A4(Entity *this) {
if (this->entityType.parameter2 & 0xC0) { if (this->entityType.parameter & 0xC0) {
if (CheckFlags(this->field_0x86)) { if (CheckFlags(this->field_0x86)) {
s32 field_0x0a; s32 field_0x0a;
switch (this->entityType.parameter2 & 0xC0) {
switch (this->entityType.parameter & 0xC0) {
case 0x40: case 0x40:
field_0x0a = gUnk_030010A0[0x5]; field_0x0a = gUnk_030010A0[0x5];
switch (field_0x0a) { switch (field_0x0a) {
default:
break;
case 0x44D ... 0x44F: case 0x44D ... 0x44F:
case 0x182: case 0x182:
DeleteThisEntity(); DeleteThisEntity();
@ -57,10 +62,10 @@ void sub_080929A4(Entity *this) {
this->field_0x78 = ((Random() & 7) << 10) | 0x2000; this->field_0x78 = ((Random() & 7) << 10) | 0x2000;
this->field_0xf = this->parameter3 >> 1; this->field_0xf = this->actionDelay >> 1;
this->parameter3 = 0; this->actionDelay = 0;
this->animationList = this->entityType.parameter2 & 0x3f; this->frameIndex = this->entityType.parameter & 0x3f;
this->field_0x7c.HALF.HI = COORD_TO_TILE(this); this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
this->field_0x7c.HALF.LO = sub_080001DA(this->field_0x7c.HALF.HI, 1); this->field_0x7c.HALF.LO = sub_080001DA(this->field_0x7c.HALF.HI, 1);
@ -70,7 +75,9 @@ void sub_080929A4(Entity *this) {
SetTile(0x4022, 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) { void sub_08092A94(Entity *this) {
// Check for the first frame of bonking animation
if (gLinkEntity.action != 6) { if (gLinkEntity.action != 6) {
return; return;
} }
@ -79,6 +86,7 @@ void sub_08092A94(Entity *this) {
return; return;
} }
// Check if link is close enough to the mask
if (this->y.HALF.HI + 40 < gLinkEntity.y.HALF.HI) { if (this->y.HALF.HI + 40 < gLinkEntity.y.HALF.HI) {
return; return;
} }
@ -87,21 +95,26 @@ void sub_08092A94(Entity *this) {
return; return;
} }
// Presumably, make the mask fall
SetTile((u16)this->field_0x7c.HALF.LO, this->field_0x7c.HALF.HI, 1); SetTile((u16)this->field_0x7c.HALF.LO, this->field_0x7c.HALF.HI, 1);
sub_08000148(this->itemCooldown, this->field_0x7c.HALF.HI, 1); sub_08000148(this->itemCooldown, this->field_0x7c.HALF.HI, 1);
this->action = 2; this->action = 2;
this->height.HALF.HI -= 0x20; this->height.HALF.HI -= 0x20;
this->y.HALF.HI += 0x20; this->y.HALF.HI += 0x20;
this->spriteOrder.b3 = 2; this->spriteOrder.b3 = 2;
} }
// Probably falling down
void sub_08092B0C(Entity *this) { void sub_08092B0C(Entity *this) {
if (this->parameter3 == 1) { if (this->actionDelay == 1) {
this->action = 3; this->action = 3;
this->parameter3 = 0;
switch (this->entityType.parameter2 & 0xC0) this->actionDelay = 0;
switch (this->entityType.parameter & 0xC0)
{ {
case 0x80: case 0x80:
sub_08004488(0x72); sub_08004488(0x72);
@ -110,18 +123,20 @@ void sub_08092B0C(Entity *this) {
break; break;
} }
CreateFx(this, 5, 0); CreateFx(this, 5, 0);
sub_0805457C(this, 3); sub_0805457C(this, 3);
} }
else { else {
sub_080044EC(this, this->field_0x78); sub_080044EC(this, this->field_0x78);
if (this->height.HALF.HI == 0) { if (this->height.HALF.HI == 0) {
this->parameter3++; this->actionDelay++;
} }
} }
} }
void sub_08092B6C(Entity *this) { void Mask_Delete(Entity *this) {
DeleteThisEntity(); DeleteThisEntity();
} }