mirror of
https://github.com/zeldaret/tmc
synced 2026-07-05 13:43:38 -04:00
Merge pull request #437 from hatal175/fan
Decompile fan and stoneTablet
This commit is contained in:
+211
-37
@@ -1,74 +1,248 @@
|
||||
#define NENT_DEPRECATED
|
||||
#include "global.h"
|
||||
#include "entity.h"
|
||||
#include "flags.h"
|
||||
#include "player.h"
|
||||
#include "functions.h"
|
||||
#include "sound.h"
|
||||
#include "object.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*);
|
||||
typedef struct {
|
||||
Entity base;
|
||||
u8 filler[0x4];
|
||||
u16 unk6c;
|
||||
u16 unk6e;
|
||||
u16 unk70;
|
||||
u16 unk72;
|
||||
u16 unk74;
|
||||
u8 filler2[0x8];
|
||||
u8 unk7e;
|
||||
u8 unk7f;
|
||||
u8 filler3[0x4];
|
||||
u16 fanFlags;
|
||||
u16 unk86;
|
||||
} FanEntity;
|
||||
|
||||
extern void (*const gUnk_081243D4[])(Entity*);
|
||||
void sub_0809EFB0(FanEntity*);
|
||||
void sub_0809EE44(FanEntity*);
|
||||
void sub_0809F08C(FanEntity*);
|
||||
void sub_0809EE24(FanEntity*);
|
||||
void sub_0809EE08(FanEntity*);
|
||||
void sub_0809EE34(FanEntity*);
|
||||
void sub_0809F0E4(FanEntity*);
|
||||
void Fan_Init(FanEntity* this);
|
||||
void Fan_Action1(FanEntity* this);
|
||||
void Fan_Action2(FanEntity* this);
|
||||
void Fan_Action3(FanEntity* this);
|
||||
bool32 sub_0809EF78(FanEntity*, Entity*);
|
||||
|
||||
extern const u8 gUnk_02027EB4[];
|
||||
|
||||
void Fan(Entity* this) {
|
||||
gUnk_081243D4[this->action](this);
|
||||
static void (*const actionFuncs[])(FanEntity*) = {
|
||||
Fan_Init,
|
||||
Fan_Action1,
|
||||
Fan_Action2,
|
||||
Fan_Action3,
|
||||
};
|
||||
actionFuncs[this->action]((FanEntity*)this);
|
||||
}
|
||||
|
||||
void sub_0809ED30(Entity* this) {
|
||||
this->direction = (this->type ^ 2) << 3;
|
||||
void Fan_Init(FanEntity* this) {
|
||||
super->direction = (super->type ^ 2) << 3;
|
||||
sub_0809EE34(this);
|
||||
sub_0809EFB0(this);
|
||||
InitializeAnimation(this, this->type);
|
||||
InitializeAnimation(super, super->type);
|
||||
}
|
||||
|
||||
void sub_0809ED54(Entity* this) {
|
||||
u16 uVar1;
|
||||
u32 iVar2;
|
||||
|
||||
if (((this->cutsceneBeh.HWORD == 0) || CheckFlags(this->cutsceneBeh.HWORD)) &&
|
||||
((this->type2 != 1 || (--this->field_0x74.HWORD == 0)))) {
|
||||
void Fan_Action1(FanEntity* this) {
|
||||
if (((this->fanFlags == 0) || CheckFlags(this->fanFlags)) && ((super->type2 != 1 || (--this->unk74 == 0)))) {
|
||||
sub_0809EE08(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0809ED88(Entity* this) {
|
||||
sub_0809F08C();
|
||||
void Fan_Action2(FanEntity* this) {
|
||||
sub_0809F08C(this);
|
||||
sub_0809EE44(this);
|
||||
if (this->field_0x86.HWORD != 0) {
|
||||
if (this->cutsceneBeh.HWORD == this->field_0x86.HWORD) {
|
||||
if (CheckFlags(this->cutsceneBeh.HWORD)) {
|
||||
if (this->unk86 != 0) {
|
||||
if (this->fanFlags == this->unk86) {
|
||||
if (CheckFlags(this->fanFlags)) {
|
||||
return;
|
||||
}
|
||||
} else if (!CheckFlags(this->cutsceneBeh.HWORD)) {
|
||||
} else if (!CheckFlags(this->fanFlags)) {
|
||||
return;
|
||||
}
|
||||
sub_0809EE24(this);
|
||||
} else if ((this->type2 == 1) && (--this->field_0x74.HWORD == 0)) {
|
||||
} else if ((super->type2 == 1) && (--this->unk74 == 0)) {
|
||||
sub_0809EE24(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0809EDE4(Entity* this) {
|
||||
sub_0809F08C();
|
||||
void Fan_Action3(FanEntity* this) {
|
||||
sub_0809F08C(this);
|
||||
sub_0809EE44(this);
|
||||
if (this->frame & 0x80) {
|
||||
if (super->frame & 0x80) {
|
||||
sub_0809EE34(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0809EE08(Entity* this) {
|
||||
this->action = 2;
|
||||
this->field_0x74.HWORD = *((u8*)&this->field_0x7c + 3) << 2;
|
||||
InitializeAnimation(this, this->type);
|
||||
void sub_0809EE08(FanEntity* this) {
|
||||
super->action = 2;
|
||||
this->unk74 = this->unk7f << 2;
|
||||
InitializeAnimation(super, super->type);
|
||||
}
|
||||
|
||||
void sub_0809EE24(Entity* this) {
|
||||
this->action = 3;
|
||||
InitializeAnimation(this, this->type + 4);
|
||||
void sub_0809EE24(FanEntity* this) {
|
||||
super->action = 3;
|
||||
InitializeAnimation(super, super->type + 4);
|
||||
}
|
||||
|
||||
void sub_0809EE34(Entity* this) {
|
||||
this->action = 1;
|
||||
this->field_0x74.HWORD = this->actionDelay << 2;
|
||||
void sub_0809EE34(FanEntity* this) {
|
||||
super->action = 1;
|
||||
this->unk74 = super->actionDelay << 2;
|
||||
}
|
||||
|
||||
void sub_0809EE44(FanEntity* this) {
|
||||
Entity* pEVar1;
|
||||
u32 bVar3;
|
||||
u32 uVar4;
|
||||
LinkedList* pList;
|
||||
|
||||
uVar4 = (super->frame & 7);
|
||||
super->speed = this->unk7e << uVar4;
|
||||
if (uVar4 != 0) {
|
||||
pEVar1 = &gPlayerEntity;
|
||||
if (sub_0809EF78(this, pEVar1)) {
|
||||
if (sub_08079F8C()) {
|
||||
sub_08079E58(super->speed, super->direction);
|
||||
}
|
||||
}
|
||||
pList = &gEntityLists[2];
|
||||
for (pEVar1 = pList->first; (Entity*)pList != pEVar1; pEVar1 = pEVar1->next) {
|
||||
if (pEVar1->kind == PLAYER_ITEM) {
|
||||
bVar3 = 0;
|
||||
switch (pEVar1->id) {
|
||||
case 0x13:
|
||||
if ((pEVar1->action != 2) || (1 < pEVar1->subAction))
|
||||
bVar3 = 1;
|
||||
break;
|
||||
case 0x2:
|
||||
if (pEVar1->action == 2)
|
||||
break;
|
||||
bVar3 = 1;
|
||||
break;
|
||||
case 0x3:
|
||||
if (pEVar1->x.HALF.HI != gPlayerEntity.x.HALF.HI ||
|
||||
pEVar1->y.HALF.HI != gPlayerEntity.y.HALF.HI)
|
||||
bVar3 = 1;
|
||||
break;
|
||||
break;
|
||||
case 0x4:
|
||||
if (super->field_0xf != 0)
|
||||
bVar3 = 1;
|
||||
break;
|
||||
case 0x11:
|
||||
case 0x19:
|
||||
bVar3 = 1;
|
||||
break;
|
||||
}
|
||||
if (bVar3) {
|
||||
if (sub_0809EF78(this, pEVar1) != 0) {
|
||||
sub_080044AE(pEVar1, super->speed, super->direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool32 sub_0809EF78(FanEntity* this, Entity* ent) {
|
||||
bool32 rv = 0;
|
||||
|
||||
if (((u32)this->unk70 >= ent->x.HALF.HI - this->unk6c) && ((u32)this->unk72 >= ent->y.HALF.HI - this->unk6e)) {
|
||||
rv = 1;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void sub_0809EFB0(FanEntity* this) {
|
||||
static const s8 tileTypeOffsets[] = { 0, 16, -16, 0, 0, -16, 16, 0 };
|
||||
u32 cVar1, cVar2;
|
||||
s32 sVar4;
|
||||
int iVar6;
|
||||
int iVar7;
|
||||
const u8* ptr;
|
||||
|
||||
cVar1 = tileTypeOffsets[super->type * 2];
|
||||
cVar2 = tileTypeOffsets[super->type * 2 + 1];
|
||||
iVar7 = super->x.HALF.HI;
|
||||
iVar6 = super->y.HALF.HI;
|
||||
ptr = gUnk_02027EB4;
|
||||
sVar4 = 0;
|
||||
do {
|
||||
sVar4++;
|
||||
iVar7 = iVar7 + cVar1;
|
||||
iVar6 = iVar6 + cVar2;
|
||||
} while (!IsTileCollision(ptr, iVar7, iVar6, 9));
|
||||
sVar4 = (sVar4 - 1) << 4;
|
||||
|
||||
switch (super->type) {
|
||||
case 0:
|
||||
this->unk6c = super->x.HALF.HI - 0x10;
|
||||
this->unk6e = super->y.HALF.HI + 8;
|
||||
this->unk70 = 0x20;
|
||||
this->unk72 = sVar4;
|
||||
break;
|
||||
case 1:
|
||||
this->unk6c = super->x.HALF.HI - (sVar4 + 8);
|
||||
this->unk6e = super->y.HALF.HI - 0x10;
|
||||
this->unk70 = sVar4;
|
||||
this->unk72 = 0x20;
|
||||
break;
|
||||
case 2:
|
||||
this->unk6c = super->x.HALF.HI - 0x10;
|
||||
this->unk6e = super->y.HALF.HI - (sVar4 + 8);
|
||||
this->unk70 = 0x20;
|
||||
this->unk72 = sVar4;
|
||||
break;
|
||||
case 3:
|
||||
this->unk6c = super->x.HALF.HI + 8;
|
||||
this->unk6e = super->y.HALF.HI - 0x10;
|
||||
this->unk70 = sVar4;
|
||||
this->unk72 = 0x20;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0809F08C(FanEntity* this) {
|
||||
if (super->field_0xf != 0) {
|
||||
super->field_0xf--;
|
||||
}
|
||||
|
||||
GetNextFrame(super);
|
||||
if (super->frame & 0x20) {
|
||||
super->frame &= ~0x20;
|
||||
super->field_0xf = 20;
|
||||
sub_0809F0E4(this);
|
||||
} else {
|
||||
if ((super->frame & 0x10) && super->field_0xf == 0) {
|
||||
super->field_0xf = 20;
|
||||
super->frame ^= 0x10;
|
||||
sub_0809F0E4(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0809F0E4(FanEntity* this) {
|
||||
static const s8 typeOffsets[] = { 0, 12, -12, 0, 0, -12, 12, 0 };
|
||||
Entity* pEVar1;
|
||||
const s8* ptr;
|
||||
|
||||
EnqueueSFX(SFX_183);
|
||||
pEVar1 = CreateObject(OBJECT_B2, super->type ^ 2, 0);
|
||||
if (pEVar1 != NULL) {
|
||||
pEVar1->parent = super;
|
||||
ptr = typeOffsets + super->type * 2;
|
||||
PositionRelative(super, pEVar1, ptr[0] << 0x10, ptr[1] << 0x10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "entity.h"
|
||||
#include "room.h"
|
||||
#include "functions.h"
|
||||
|
||||
void sub_080979CC(Entity*);
|
||||
void nullsub_529(Entity*);
|
||||
|
||||
void StoneTablet(Entity* this) {
|
||||
static void (*const actionFuncs[])(Entity*) = {
|
||||
sub_080979CC,
|
||||
nullsub_529,
|
||||
};
|
||||
|
||||
actionFuncs[this->action](this);
|
||||
}
|
||||
|
||||
void sub_080979CC(Entity* this) {
|
||||
static const u8 gUnk_081232EC[] = {
|
||||
0x22, 0x40, 0xFE, 0xFF, 0x22, 0x40, 0xFF, 0xFF, 0x22, 0x40, 0x0, 0x0, 0x22, 0x40, 0x1, 0x0, 0xFF, 0xFF,
|
||||
};
|
||||
|
||||
static const u8 gUnk_081232FE[] = {
|
||||
0x65, 0x40, 0xBF, 0xFF, 0x22, 0x40, 0xC0, 0xFF, 0x66, 0x40, 0xC1, 0xFF, 0x29,
|
||||
0x40, 0xFF, 0xFF, 0x26, 0x40, 0x0, 0x0, 0x2A, 0x40, 0x1, 0x0, 0xFF, 0xFF,
|
||||
};
|
||||
this->action = 1;
|
||||
this->spriteSettings.draw = 1;
|
||||
if (this->type == 3) {
|
||||
this->frameIndex = 0;
|
||||
sub_0801AF18(gUnk_081232FE, COORD_TO_TILE(this), this->collisionLayer);
|
||||
} else {
|
||||
this->frameIndex = this->type;
|
||||
sub_0801AF18(gUnk_081232EC, COORD_TO_TILE(this), this->collisionLayer);
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_529(Entity* this) {
|
||||
}
|
||||
Reference in New Issue
Block a user