mirror of
https://github.com/zeldaret/tmc
synced 2026-07-28 07:09:19 -04:00
Merge pull request #410 from hatal175/objects
Decompile several Objects
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
#define NENT_DEPRECATED
|
||||
#include "entity.h"
|
||||
#include "room.h"
|
||||
#include "asm.h"
|
||||
#include "player.h"
|
||||
#include "functions.h"
|
||||
|
||||
typedef struct {
|
||||
Entity base;
|
||||
u8 filler[0x10];
|
||||
u16 unk78;
|
||||
u16 unk7a;
|
||||
u16 unk7c;
|
||||
u16 unk7e;
|
||||
u16 tile;
|
||||
u8 unk82;
|
||||
u8 unk83;
|
||||
} BoardEntity;
|
||||
|
||||
void Board_Init(BoardEntity*);
|
||||
void sub_08098BE0(BoardEntity*);
|
||||
void sub_08098BE8(BoardEntity*);
|
||||
bool32 sub_08098C30(BoardEntity*, Entity*);
|
||||
void sub_0807AAF8(Entity*, u32);
|
||||
|
||||
void Board(Entity* this) {
|
||||
static void (*const actionFuncs[])(BoardEntity*) = {
|
||||
Board_Init,
|
||||
sub_08098BE0,
|
||||
};
|
||||
|
||||
actionFuncs[this->action]((BoardEntity*)this);
|
||||
}
|
||||
|
||||
void Board_Init(BoardEntity* this) {
|
||||
static const u8 gUnk_0812366C[] = { 0x10, 0x1e, 0xc, 0x6, 0x10, 0x6, 0x0, 0x0 };
|
||||
const u8* pbVar2 = &gUnk_0812366C[super->type * 2];
|
||||
|
||||
super->action = 1;
|
||||
super->spriteSettings.draw = 1;
|
||||
super->frameIndex = super->type;
|
||||
this->unk82 = pbVar2[0];
|
||||
this->unk83 = pbVar2[1];
|
||||
this->unk78 = super->x.HALF.HI - (this->unk82 >> 1);
|
||||
this->unk7a = super->y.HALF.HI - (this->unk83 >> 1);
|
||||
this->tile = COORD_TO_TILE(super);
|
||||
super->collisionLayer = 1;
|
||||
UpdateSpriteForCollisionLayer(super);
|
||||
super->spritePriority.b0 = 6;
|
||||
if (super->type == 0) {
|
||||
SetTile(0x4074, this->tile - 0x40, super->collisionLayer);
|
||||
}
|
||||
sub_08098BE8(this);
|
||||
}
|
||||
|
||||
void sub_08098BE0(BoardEntity* this) {
|
||||
sub_08098BE8(this);
|
||||
}
|
||||
|
||||
void sub_08098BE8(BoardEntity* this) {
|
||||
if ((gPlayerState.flags & PL_MINISH) && sub_08098C30(this, &gPlayerEntity) && sub_08079F8C() &&
|
||||
gPlayerEntity.z.HALF.HI == 0) {
|
||||
gPlayerState.field_0x14 = 1;
|
||||
sub_0807AAF8(&gPlayerEntity, this->tile);
|
||||
}
|
||||
}
|
||||
|
||||
bool32 sub_08098C30(BoardEntity* this, Entity* ent) {
|
||||
u32 uVar1 = 0;
|
||||
u32 diffx = ent->x.HALF.HI - this->unk78;
|
||||
u32 diffy = ent->y.HALF.HI - this->unk7a;
|
||||
|
||||
if (diffx <= this->unk82 && diffy <= this->unk83) {
|
||||
uVar1 = 1;
|
||||
}
|
||||
return uVar1;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
#define NENT_DEPRECATED
|
||||
#include "entity.h"
|
||||
#include "flags.h"
|
||||
#include "asm.h"
|
||||
#include "sound.h"
|
||||
#include "room.h"
|
||||
#include "functions.h"
|
||||
|
||||
typedef struct {
|
||||
Entity base;
|
||||
u8 filler[0x8];
|
||||
u16 tile;
|
||||
u16 tileIndex;
|
||||
u8 unk74;
|
||||
u8 unk75;
|
||||
u8 filler2[0x10];
|
||||
u16 flags;
|
||||
} BollardEntity;
|
||||
|
||||
void sub_0808B2AC(BollardEntity*);
|
||||
void sub_0808B2CC(BollardEntity*);
|
||||
void sub_0808B324(BollardEntity*);
|
||||
void sub_0808B344(BollardEntity*);
|
||||
void sub_0808B38C(BollardEntity*);
|
||||
void sub_0808B41C(BollardEntity*);
|
||||
void sub_0808B3AC(BollardEntity*);
|
||||
void sub_0808B42C(BollardEntity*);
|
||||
|
||||
void Bollard(Entity* this) {
|
||||
static void (*const actionFuncs[])(BollardEntity*) = {
|
||||
sub_0808B2AC, sub_0808B2CC, sub_0808B324, sub_0808B344, sub_0808B38C,
|
||||
};
|
||||
|
||||
actionFuncs[this->action]((BollardEntity*)this);
|
||||
}
|
||||
|
||||
void sub_0808B2AC(BollardEntity* this) {
|
||||
if (super->type2 == 0) {
|
||||
sub_0808B41C(this);
|
||||
sub_0808B3AC(this);
|
||||
} else {
|
||||
sub_0808B42C(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0808B2CC(BollardEntity* this) {
|
||||
if (super->type2 == 0) {
|
||||
if (CheckFlags(this->flags) == 0) {
|
||||
return;
|
||||
}
|
||||
} else if (CheckFlags(this->flags) != 0) {
|
||||
return;
|
||||
}
|
||||
super->action = 2;
|
||||
InitializeAnimation(super, 3);
|
||||
SetTile(this->tileIndex, this->tile, super->collisionLayer);
|
||||
EnqueueSFX(SFX_1A5);
|
||||
}
|
||||
|
||||
void sub_0808B324(BollardEntity* this) {
|
||||
GetNextFrame(super);
|
||||
if (super->frame & 0x80) {
|
||||
sub_0808B42C(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0808B344(BollardEntity* this) {
|
||||
if (super->type2 == 0) {
|
||||
if (CheckFlags(this->flags) != 0) {
|
||||
return;
|
||||
}
|
||||
} else if (CheckFlags(this->flags) == 0) {
|
||||
return;
|
||||
}
|
||||
super->action = 4;
|
||||
InitializeAnimation(super, 2);
|
||||
sub_0808B3AC(this);
|
||||
EnqueueSFX(SFX_1A5);
|
||||
}
|
||||
|
||||
void sub_0808B38C(BollardEntity* this) {
|
||||
GetNextFrame(super);
|
||||
if (super->frame & 0x80) {
|
||||
sub_0808B41C(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0808B3AC(BollardEntity* this) {
|
||||
super->spritePriority.b0 = 4;
|
||||
this->tile = COORD_TO_TILE(super);
|
||||
this->tileIndex = GetTileIndex(this->tile, super->collisionLayer);
|
||||
this->unk74 = sub_080002E0(this->tile, super->collisionLayer);
|
||||
SetTile(0x400b, this->tile, super->collisionLayer);
|
||||
}
|
||||
|
||||
void sub_0808B41C(BollardEntity* this) {
|
||||
super->action = 1;
|
||||
InitializeAnimation(super, 0);
|
||||
}
|
||||
|
||||
void sub_0808B42C(BollardEntity* this) {
|
||||
super->action = 3;
|
||||
super->spritePriority.b0 = 7;
|
||||
InitializeAnimation(super, 1);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
#define NENT_DEPRECATED
|
||||
#include "entity.h"
|
||||
#include "room.h"
|
||||
#include "flags.h"
|
||||
#include "asm.h"
|
||||
|
||||
typedef struct {
|
||||
Entity base;
|
||||
u8 filler[0x18];
|
||||
u16 tile;
|
||||
} CabinFurnitureEntity;
|
||||
|
||||
void CabinFurniture_Init(CabinFurnitureEntity* this);
|
||||
void nullsub_535(CabinFurnitureEntity* this);
|
||||
void nullsub_2a(CabinFurnitureEntity* this);
|
||||
void nullsub_2(CabinFurnitureEntity* this);
|
||||
|
||||
void CabinFurniture(Entity* this) {
|
||||
static void (*const actionFuncs[])(CabinFurnitureEntity*) = {
|
||||
CabinFurniture_Init,
|
||||
nullsub_535,
|
||||
nullsub_2a,
|
||||
};
|
||||
actionFuncs[this->action]((CabinFurnitureEntity*)this);
|
||||
}
|
||||
|
||||
void CabinFurniture_Init(CabinFurnitureEntity* this) {
|
||||
u32 uVar1;
|
||||
u32 uVar6;
|
||||
u32 uVar7;
|
||||
|
||||
this->tile = COORD_TO_TILE(super);
|
||||
uVar1 = super->collisionLayer;
|
||||
UpdateSpriteForCollisionLayer(super);
|
||||
switch (super->type) {
|
||||
case 0:
|
||||
super->action = 2;
|
||||
super->spritePriority.b0 = 6;
|
||||
uVar7 = this->tile;
|
||||
uVar6 = uVar7 - 1;
|
||||
SetTile(0x4022, uVar6, uVar1);
|
||||
SetTile(0x4022, uVar7, uVar1);
|
||||
SetTile(0x4022, uVar7 + 1, uVar1);
|
||||
SetTile(0x4022, uVar7 + 0x3f, uVar1);
|
||||
SetTile(0x4022, uVar7 + 0x40, uVar1);
|
||||
SetTile(0x4022, uVar7 + 0x41, uVar1);
|
||||
SetTile(0x403d, uVar7 - 0x41, uVar1);
|
||||
SetTile(0x403d, uVar7 - 0x40, uVar1);
|
||||
SetTile(0x4026, uVar7 - 0x3f, uVar1);
|
||||
SetTile(0x4026, uVar7 - 0x81, uVar1);
|
||||
SetTile(0x4026, uVar7 - 0x80, uVar1);
|
||||
break;
|
||||
case 1:
|
||||
super->action = 1;
|
||||
uVar6 = this->tile;
|
||||
SetTile(0x4022, uVar6, uVar1);
|
||||
SetTile(0x4022, uVar6 + 0x40, uVar1);
|
||||
SetTile(0x4025, uVar6 + 0x41, uVar1);
|
||||
if (CheckLocalFlag(0x4f) == 0) {
|
||||
SetTile(0x402f, uVar6 + 1, uVar1);
|
||||
} else {
|
||||
SetTile(0x402d, uVar6 + 1, uVar1);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
super->action = 1;
|
||||
uVar7 = this->tile;
|
||||
uVar6 = uVar7 - 0x41;
|
||||
SetTile(0x4022, uVar6, uVar1);
|
||||
SetTile(0x4022, uVar7 - 0x40, uVar1);
|
||||
SetTile(0x4022, uVar7 - 1, uVar1);
|
||||
SetTile(0x4022, uVar7, uVar1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_535(CabinFurnitureEntity* this) {
|
||||
}
|
||||
|
||||
void nullsub_2a(CabinFurnitureEntity* this) {
|
||||
nullsub_2(this);
|
||||
}
|
||||
|
||||
void nullsub_2(CabinFurnitureEntity* this) {
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
#define NENT_DEPRECATED
|
||||
#include "entity.h"
|
||||
#include "room.h"
|
||||
#include "asm.h"
|
||||
#include "flags.h"
|
||||
#include "functions.h"
|
||||
#include "object.h"
|
||||
|
||||
typedef struct {
|
||||
Entity base;
|
||||
u8 filler[0x8];
|
||||
u16 tile;
|
||||
u16 tile2;
|
||||
u16 tileIndex;
|
||||
u16 tileIndex2;
|
||||
u8 filler2[0xe];
|
||||
u16 flags;
|
||||
} GentariCurtainEntity;
|
||||
|
||||
void sub_08092050(GentariCurtainEntity* this);
|
||||
void sub_0809214C(GentariCurtainEntity* this);
|
||||
void sub_08092164(GentariCurtainEntity* this);
|
||||
void nullsub_118(GentariCurtainEntity* this);
|
||||
void sub_0809223C(GentariCurtainEntity* this);
|
||||
void sub_080921BC(GentariCurtainEntity* this);
|
||||
void sub_080921F0(GentariCurtainEntity* this);
|
||||
void sub_08092214(GentariCurtainEntity* this);
|
||||
|
||||
extern Entity gUnk_030011E8[7];
|
||||
extern Entity gUnk_03003BE0;
|
||||
|
||||
void GentariCurtain(Entity* this) {
|
||||
static void (*const actionFuncs[])(GentariCurtainEntity*) = {
|
||||
sub_08092050,
|
||||
sub_0809214C,
|
||||
sub_08092164,
|
||||
nullsub_118,
|
||||
};
|
||||
|
||||
actionFuncs[this->action]((GentariCurtainEntity*)this);
|
||||
}
|
||||
|
||||
void sub_08092050(GentariCurtainEntity* this) {
|
||||
if (CheckFlags(this->flags)) {
|
||||
super->action = 3;
|
||||
super->x.HALF.HI += 2;
|
||||
sub_0809223C(this);
|
||||
InitAnimationForceUpdate(super, 1);
|
||||
} else {
|
||||
if (super->subAction == 0) {
|
||||
super->subAction = 1;
|
||||
super->collisionLayer = 1;
|
||||
super->spritePriority.b0 = 6;
|
||||
super->x.HALF.HI += 2;
|
||||
UpdateSpriteForCollisionLayer(super);
|
||||
this->tile = COORD_TO_TILE_OFFSET(super, 0, 8);
|
||||
this->tile2 = COORD_TO_TILE_OFFSET(super, 0, -8);
|
||||
this->tileIndex = GetTileIndex(this->tile, 1);
|
||||
this->tileIndex2 = GetTileIndex(this->tile2, 1);
|
||||
SetTile(0x4022, this->tile, 1);
|
||||
SetTile(0x4022, this->tile2, 1);
|
||||
InitAnimationForceUpdate(super, 0);
|
||||
} else {
|
||||
super->action = 1;
|
||||
sub_080921BC(this);
|
||||
sub_080921F0(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0809214C(GentariCurtainEntity* this) {
|
||||
if (CheckFlags(this->flags)) {
|
||||
super->action = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08092164(GentariCurtainEntity* this) {
|
||||
UpdateAnimationSingleFrame(super);
|
||||
if ((super->frame & 0x80) != 0) {
|
||||
super->action = 3;
|
||||
SetTile(this->tileIndex, this->tile, 1);
|
||||
SetTile(this->tileIndex2, this->tile2, 1);
|
||||
sub_08092214(this);
|
||||
sub_0809223C(this);
|
||||
InitAnimationForceUpdate(super, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_118(GentariCurtainEntity* this) {
|
||||
}
|
||||
|
||||
void sub_080921BC(GentariCurtainEntity* this) {
|
||||
GenericEntity* pEVar1;
|
||||
GenericEntity* end;
|
||||
|
||||
pEVar1 = (GenericEntity*)gUnk_030011E8;
|
||||
end = pEVar1 + 0x4f;
|
||||
|
||||
do {
|
||||
if (pEVar1->base.kind == OBJECT) {
|
||||
if (pEVar1->base.id == MINISH_SIZED_ARCHWAY) {
|
||||
if (pEVar1->base.type == 2) {
|
||||
super->child = (Entity*)pEVar1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
pEVar1++;
|
||||
} while (pEVar1 < end);
|
||||
super->child = NULL;
|
||||
}
|
||||
|
||||
void sub_080921F0(GentariCurtainEntity* this) {
|
||||
Entity* pEVar1 = super->child;
|
||||
if (pEVar1) {
|
||||
pEVar1->collisionLayer = 1;
|
||||
pEVar1->spritePriority.b0 = 7;
|
||||
UpdateSpriteForCollisionLayer(pEVar1);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08092214(GentariCurtainEntity* this) {
|
||||
Entity* pEVar1 = super->child;
|
||||
if (pEVar1) {
|
||||
pEVar1->collisionLayer = 2;
|
||||
pEVar1->spritePriority.b0 = 4;
|
||||
UpdateSpriteForCollisionLayer(pEVar1);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0809223C(GentariCurtainEntity* this) {
|
||||
super->collisionLayer = 2;
|
||||
super->spritePriority.b0 = 3;
|
||||
UpdateSpriteForCollisionLayer(super);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#include "entity.h"
|
||||
#include "room.h"
|
||||
#include "player.h"
|
||||
#include "asm.h"
|
||||
#include "sound.h"
|
||||
#include "functions.h"
|
||||
#include "effects.h"
|
||||
|
||||
void LadderUp(Entity* this) {
|
||||
Entity* fxEnt;
|
||||
u32 uVar4;
|
||||
|
||||
switch (this->action) {
|
||||
case 0:
|
||||
if (this->actionDelay) {
|
||||
uVar4 = 1;
|
||||
} else {
|
||||
#ifndef EU
|
||||
uVar4 = 3;
|
||||
#else
|
||||
uVar4 = 2;
|
||||
#endif
|
||||
}
|
||||
this->action = uVar4;
|
||||
this->spriteOffsetY += 8;
|
||||
InitializeAnimation(this, 10);
|
||||
if (this->action == 1) {
|
||||
this->z.HALF.HI = 0xff80;
|
||||
}
|
||||
if (this->type2) {
|
||||
return;
|
||||
}
|
||||
this->y.HALF.HI = (this->y.HALF.HI & 0xfff0) + 0xc;
|
||||
SetTile(0x4023, COORD_TO_TILE(this), this->collisionLayer);
|
||||
break;
|
||||
case 1:
|
||||
if (GravityUpdate(this, 0x1000) == 0) {
|
||||
fxEnt = CreateFx(this, FX_GIANT_EXPLOSION, 0x40);
|
||||
if (fxEnt) {
|
||||
fxEnt->y.HALF.HI += 8;
|
||||
}
|
||||
InitScreenShake(0x1e, 0);
|
||||
SoundReq(SFX_10B);
|
||||
this->action = 2;
|
||||
#ifndef EU
|
||||
this->actionDelay = 0x3c;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
#ifndef EU
|
||||
if (--this->actionDelay) {
|
||||
return;
|
||||
}
|
||||
this->action = 3;
|
||||
SoundReq(SFX_SECRET_BIG);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
if (this->type2 == 0) {
|
||||
if (gPlayerEntity.y.HALF.HI < this->y.HALF.HI) {
|
||||
if (gPlayerState.floor_type != 0x1e && (GetTileTypeByEntity(this) == 0x4017)) {
|
||||
SetTile(0x4023, COORD_TO_TILE(this), this->collisionLayer);
|
||||
sub_0807BA8C(COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer);
|
||||
}
|
||||
} else {
|
||||
if (GetTileTypeByEntity(this) != 0x4017) {
|
||||
SetTile(0x4017, COORD_TO_TILE(this), this->collisionLayer);
|
||||
if (this->type == 0) {
|
||||
SetTile(0x4017, COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer);
|
||||
} else {
|
||||
SetTile(0x4014, COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user