object86.c OK

This commit is contained in:
theo3
2020-07-08 19:45:04 -07:00
parent 6f08201b71
commit bde7b45adb
8 changed files with 365 additions and 630 deletions
+69
View File
@@ -0,0 +1,69 @@
#include "global.h"
#include "entity.h"
#include "room.h"
void sub_080A29BC(Entity *parent)
{
CreateFx(parent, 2, 0);
}
void sub_080A29C8(s32 xOff, s32 yOff, u32 layer)
{
Entity *pEVar1;
pEVar1 = CreateObject(0xf, 2, 0);
if (pEVar1 != NULL) {
pEVar1->x.HALF.HI = gRoomControls.roomOriginX + xOff;
pEVar1->y.HALF.HI = gRoomControls.roomOriginY + yOff;
pEVar1->collisionLayer = layer;
}
}
void sub_080A29FC(Entity *parent)
{
CreateFx(parent, 0x11, 0);
}
void sub_080A2A08(Entity *parent)
{
CreateFx(parent, 0x6, 0);
}
void sub_080A2A14(Entity *parent)
{
CreateFx(parent, 0xb, 0);
}
Entity * sub_080A2A20(Entity *parent, u32 form, u32 parameter)
{
Entity *pEVar1;
pEVar1 = CreateObjectWithParent(parent, 0, form, parameter);
if (pEVar1 != NULL) {
pEVar1->actionDelay = 5;
}
return pEVar1;
}
Entity * sub_080A2A3C(Entity *parent, u32 form, u32 subtype, u32 param_4)
{
Entity *ent;
ent = CreateObjectWithParent(parent, 0, form, subtype);
if (ent != NULL) {
ent->actionDelay = 5;
ent->field_0x86 = param_4;
}
return ent;
}
Entity * sub_080A2A64(Entity *parent)
{
Entity *pEVar1;
pEVar1 = CreateFx(parent, 0x20, 0);
if (pEVar1 != NULL) {
pEVar1->ticks.b0 = 7;
}
return pEVar1;
}
+102
View File
@@ -0,0 +1,102 @@
#include "global.h"
#include "entity.h"
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 (*const gUnk_08121E5C[])(Entity*);
extern void (*const gUnk_08121E88[])(Entity*);
extern void (*const gUnk_08121E98[])(Entity*);
void Object49(Entity* this) {
gUnk_08121E5C[this->entityType.form](this);
}
void sub_0808F0B8(Entity* this) {
gUnk_08121E88[this->action](this);
}
void sub_0808F0D0(Entity* this) {
u32 offsetX;
u32 offsetY;
Entity* ent;
u32 uVar3;
ent = CreateObjectWithParent(this, 0x49, 2, 0);
this->attachedEntity = ent;
if (ent == NULL) {
DeleteThisEntity();
}
this->action = 1;
this->height.HALF.HI = -0xc0;
offsetX = Random() % 64;
if ((Random() & 1) != 0) {
offsetX = -offsetX;
}
this->x.HALF.HI = this->parent->x.HALF.HI + offsetX;
offsetY = Random() % 32;
if ((Random() & 1) != 0) {
offsetY = -offsetY;
}
this->y.HALF.HI = this->parent->y.HALF.HI + offsetY;
*(u32*)&this->field_0x74 = 0x240;
*(u32*)&this->field_0x78 = 0x140;
InitializeAnimation(this, 3);
sub_0808F14C(this);
}
void sub_0808F14C(Entity* this) {
sub_0808F2B0(this);
if (sub_08003FC4(this, 0x2000) == 0) {
this->action++;
PlaySFX(0x84);
}
}
void sub_0808F170(Entity *this)
{
*(u32 *)&this->field_0x74 -= 0x20;
*(u32 *)&this->field_0x78 += 0x20;
sub_0806FCF4(this, *(u32 *)&this->field_0x78, 8, 2);
if (*(u32 *)&this->field_0x78 > 0x1ff) {
this->action++;
}
sub_0808F2B0(this);
}
void sub_0808F1A4(Entity *this)
{
*(u32 *)&this->field_0x78 += 0x10;
*(u32 *)&this->field_0x74 += 0x10;
sub_0806FCF4(this, *(u32 *)&this->field_0x78, 8, 2);
if (*(u32 *)&this->field_0x78 > 0x3ff) {
this->attachedEntity->action = 0xff;
DeleteThisEntity();
}
else {
sub_0808F2B0(this);
}
}
void sub_0808F1E0(Entity *this)
{
gUnk_08121E98[this->action](this);
}
void sub_0808F1F8(Entity *this)
{
u8 bVar1;
this->spriteOrder.b0 = 3;
this->action++;
this->spriteOrder.b3 = this->parent->spriteOrder.b3;
this->spriteOrientation.b2 = this->parent->spriteOrientation.b2;
this->ticks.b0 = 7;
InitializeAnimation(this, 1);
sub_0808F244(this);
}
+81
View File
@@ -0,0 +1,81 @@
#include "global.h"
#include "entity.h"
#include "link.h"
#include "flags.h"
extern u32 sub_080041A0(Entity*, Entity*, u32, u32);
void sub_08099ECC(Entity*);
extern void sub_0805E4E0(Entity*, u32);
extern void sub_0805B390(u32);
extern void CopyPosition(Entity*, Entity*);
extern void (*const gUnk_081237F8[])(Entity*);
void Object86(Entity* this) {
gUnk_081237F8[this->action](this);
}
void sub_08099DD0(Entity* this) {
this->collisionLayer = 1;
this->spriteOrder.b3 = 3;
this->ticks.b0 = 7;
this->previousActionFlag = 0;
if (GetInventoryValue(0x46)) {
this->action = 4;
this->frameIndex = 0;
} else {
this->action = 1;
InitializeAnimation(this, 0);
}
}
void sub_08099E10(Entity* this) {
if (CheckLocalFlag(0x74)) {
GetNextFrame(this);
if ((this->frames.all == 1) && (this->previousActionFlag == 0)) {
this->frames.all = 0;
sub_08099ECC(this);
}
if (this->frames.b.f3) {
this->action = 2;
InitializeAnimation(this, 1);
}
}
}
void sub_08099E58(Entity *this)
{
GetNextFrame(this);
if (this->frames.b.f3) {
this->frames.b.f3 = 0;
this->actionDelay++;
if (this->actionDelay == 3) {
this->action = 3;
this->frameIndex = 4;
}
}
}
void sub_08099E8C(Entity *this)
{
if (sub_080041A0(this, &gLinkEntity, 0xc, 0xc)) {
if (this->previousActionFlag == 0) {
sub_08099ECC(this);
sub_0805E4E0(this, 0x1e);
}
if (CheckLocalFlag(0x75)) {
sub_0805B390(0x7);
}
}
}
void nullsub_534(Entity* this) {}
void sub_08099ECC(Entity *this)
{
this->previousActionFlag = 1;
CopyPosition(this, &gLinkEntity);
gLinkState.linkAction = 3;
gLinkState.filler12[4] = 0;
gLinkState.flags.all |= 0x8000;
}