Finish decompiling object49.c

This commit is contained in:
Marcus Huderle
2020-08-05 17:46:53 -05:00
parent 1912771187
commit 1cbdcf5a36
9 changed files with 165 additions and 409 deletions
+1 -7
View File
@@ -1,12 +1,12 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
#include "trig.h"
#include "random.h"
#include "link.h"
// Lakitu
extern void EnemyFunctionHandler(Entity *, void (*const funcs[])(Entity*));
extern void SetChildOffset(Entity *, u32, u32, u32);
// sub_0803C758
extern void sub_0803CAD0(Entity *);
@@ -41,7 +41,6 @@ extern void sub_0803CB64(Entity *);
extern void sub_0803CB34(Entity *);
// sub_0803CA0C
extern u32 sub_08003FC4(Entity *, u32);
extern void sub_0803CC08(Entity *this);
// sub_0803CA4C
@@ -51,12 +50,7 @@ extern u32 sub_080041A0(Entity *, Entity *, u32, u32);
// sub_0803CA84
extern u32 GetFacingDirection(Entity *, Entity *);
// sub_0803CAD0
extern u8 sub_080045D4(s16, s16, u16, u16);
extern void sub_080AEFE0(Entity *);
// sub_0803CB64
extern void PositionRelative(Entity *, Entity *, u32, u32);
extern void sub_08004488(u32);
typedef struct {
+3 -5
View File
@@ -1,13 +1,11 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
extern void EnemyFunctionHandler(Entity*, void (*const func[])(Entity*));
extern void sub_0804AA30(Entity*, void (*const func[][])(Entity*));
extern void sub_0804A7D4(Entity*);
extern void sub_0804A720(Entity*);
extern void sub_08045678(Entity*);
extern void sub_080AEFE0(void);
extern u32 sub_08003FC4(Entity*, u32);
extern void sub_08045678(Entity*);
extern void (*const gUnk_080D1868[])(Entity*);
@@ -25,7 +23,7 @@ void sub_080455BC(Entity *this)
void sub_080455D4(Entity *this)
{
sub_0804AA30(this, &gUnk_080D1868);
sub_0804AA30(this, gUnk_080D1868);
}
void sub_080455E4(Entity *this)
@@ -53,7 +51,7 @@ void sub_08045618(Entity *this)
void sub_08045654(Entity *this)
{
sub_080AEFE0();
sub_080AEFE0(this);
GetNextFrame(this);
if (sub_08003FC4(this, 0x1800) == 0) {
sub_08045678(this);
+1 -1
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
#include "npc.h"
#include "textbox.h"
#include "link.h"
@@ -28,7 +29,6 @@ extern void sub_080606D8(Entity*);
extern void sub_0807DD94(Entity*, u32);
extern void sub_080788E0(Entity*);
extern void sub_08004488(u32);
extern void sub_08003FC4(Entity*, u32);
extern void sub_080606C0(Entity*);
extern void sub_0800451C(Entity*);
extern void sub_08078784(Entity*, u32);
+1 -2
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
#include "room.h"
#include "flags.h"
@@ -16,10 +17,8 @@ void DeleteThisEntity(void);
extern Entity* GetEntityByType(u32, u32);
extern void sub_080686C4(Entity*, Entity*);
extern void sub_0806F62C(Entity*, u32, u32);
extern u32 sub_08003FC4(Entity*, u32);
extern void PlaySFX(u32);
extern void SetTileType(u32, u32, u32);
extern void sub_0807BA8C(u16, u32);
extern Entity gLinkEntity;
extern RoomControls gRoomControls;
+155 -12
View File
@@ -1,19 +1,22 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
#include "position.h"
#include "random.h"
#include "structures.h"
static void sub_0808F2B0(Entity*);
static void sub_0808F14C(Entity*);
static void sub_0808F244(Entity*);
extern u32 Random(void);
extern void sub_0808F2B0(Entity*);
extern u32 sub_08003FC4(Entity*, u32);
void sub_0808F14C(Entity*);
extern void PlaySFX(u32);
extern void sub_0806FCF4(Entity*, u32, u32, u32);
extern void sub_0808F244(Entity*);
extern void sub_0805EC9C(Entity*, u32, u32, u32);
extern void sub_0808F5EC(Entity*);
extern bool32 sub_0806F3E4(Entity *);
extern void (*const gUnk_08121E5C[])(Entity*);
extern void (*const gUnk_08121E88[])(Entity*);
extern void (*const gUnk_08121E98[])(Entity*);
extern const u16 gUnk_08121EA0[];
void Object49(Entity* this) {
gUnk_08121E5C[this->entityType.form](this);
@@ -52,7 +55,7 @@ void sub_0808F0D0(Entity* this) {
sub_0808F14C(this);
}
void sub_0808F14C(Entity* this) {
static void sub_0808F14C(Entity* this) {
sub_0808F2B0(this);
if (sub_08003FC4(this, 0x2000) == 0) {
this->action++;
@@ -103,7 +106,7 @@ void sub_0808F1F8(Entity *this)
sub_0808F244(this);
}
void sub_0808F244(Entity *this)
static void sub_0808F244(Entity *this)
{
this->spriteSettings.b.draw = this->parent->spriteSettings.b.draw;
@@ -119,7 +122,7 @@ void sub_0808F244(Entity *this)
}
}
void sub_0808F2B0(Entity *this)
static void sub_0808F2B0(Entity *this)
{
sub_0805EC9C(this, *(u32 *)&this->field_0x74, *(u32 *)&this->field_0x78, this->field_0x70.WORD);
}
@@ -152,4 +155,144 @@ void sub_0808F2C0(Entity *this)
if (this->action == 0xff) {
DeleteThisEntity();
}
}
}
void sub_0808F370(Entity* this) {
if (this->action == 0) {
if (this->parent->previousActionFlag == 1) {
this->action = 1;
this->field_0x70.WORD = 0;
sub_0808F5EC(this);
}
} else {
u8 flag = this->parent->previousActionFlag - 1;
if (flag < 5) {
if (this->field_0x70.WORD == 0) {
if (--(*(u32 *)&this->field_0x74) == -1) {
this->field_0x70.WORD = gUnk_08121EA0[Random() & 1];
}
} else {
if (--this->field_0x70.WORD == 0) {
sub_0808F5EC(this);
}
}
} else {
this->action = 0;
*(u32 *)&this->field_0x74 = 0;
}
}
}
void sub_0808F3DC(Entity* this) {
if (this->action == 0) {
this->spriteSettings.b.draw = 1;
this->action = 1;
this->actionDelay = 120;
InitializeAnimation(this, this->entityType.form + 1);
// TODO: This block of code might supposed to be a switch statement.
if (this->entityType.form != 8) {
if (this->entityType.form == 7) {
sub_0806FAD8(this->attachedEntity, this);
return;
}
} else {
this->damageType = this->attachedEntity->damageType;
this->attachedEntity->damageType = 0x7E;
}
ResolveEntityOnTop(this->attachedEntity, this);
} else {
if (*(u32 *)&this->parent->field_0x74 == 0) {
if (this->entityType.form == 8) {
this->attachedEntity->damageType = this->damageType;
}
DeleteThisEntity();
}
if (this->entityType.form == 5 && this->frames.b.f0) {
Entity* entity = CreateObjectWithParent(this->attachedEntity, 0x49, 8, 0);
if (entity) {
entity->parent = this->parent;
entity->attachedEntity = this->parent->parent;
}
}
GetNextFrame(this);
CopyPositionAndSpriteOffset(this->attachedEntity, this);
}
}
void sub_0808F498(Entity* this) {
u32 var0;
if (this->action != 0) {
if (sub_0806F3E4(this)) {
if (gScreenTransition.frameCount % 16 == 0) {
PlaySFX(0xEF);
}
DeleteThisEntity();
}
if (--this->actionDelay == 0xFF) {
DeleteThisEntity();
}
if (gLinkState.field_0x1c != 1) {
DeleteThisEntity();
}
} else {
this->action = 1;
this->actionDelay = 64;
var0 = this->entityType.parameter != 0 ? 44 : 43;
this->x.HALF.HI -= this->parent->boundingBox->field_0x6;
this->x.HALF.HI += (s32)Random() % (this->parent->boundingBox->field_0x6 * 2);
this->y.HALF.HI -= this->parent->boundingBox->field_0x7;
this->y.HALF.HI += (s32)Random() % (this->parent->boundingBox->field_0x7 * 2);
sub_0801D2B4(this, var0);
InitializeAnimation(this, 4);
}
}
void sub_0808F554(Entity* this) {
CopyPositionAndSpriteOffset(this->parent, this);
this->spriteOffsetY -= 24;
if ((s8)this->parent->spriteOffsetX != 0) {
this->spriteOffsetX += (s8)this->parent->spriteOffsetX / 2;
}
if (this->action != 0) {
if (*(u32 *)&this->cutsceneBeh) {
if (--(*(u32 *)&this->cutsceneBeh) == 0) {
DeleteThisEntity();
}
}
GetNextFrame(this);
} else {
this->action = 1;
this->spriteRendering.b3 = this->parent->spriteRendering.b3;
this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY;
this->spritePriority.b0 = 0;
InitializeAnimation(this, 3);
}
}
void sub_0808F5EC(Entity* this) {
Entity* entity = CreateObjectWithParent(this->attachedEntity, 0x49, 5, 0);
if (entity) {
entity->parent = this;
entity->attachedEntity = this->attachedEntity;
}
entity = CreateObjectWithParent(this->attachedEntity, 0x49, 6, 0);
if (entity) {
entity->parent = this;
entity->attachedEntity = this->attachedEntity;
}
entity = CreateObjectWithParent(this->attachedEntity, 0x49, 7, 0);
if (entity) {
entity->parent = this;
entity->attachedEntity = this->attachedEntity;
}
*(u32 *)&this->field_0x74 = 600;
}