Decompile HittableLever

This commit is contained in:
octorock 2022-01-24 21:52:22 +01:00
parent b7abbfd927
commit a6657fbd33
7 changed files with 83 additions and 8 deletions

View File

@ -164,4 +164,5 @@ extern u32 GetTileIndex(u32, u32);
extern void sub_0806FBB4(Entity*);
extern u32 sub_080002D4(s32, s32, u32);
extern void sub_08078930(Entity*);
extern void sub_080044AE(Entity*, u32, u32);
#endif

View File

@ -273,7 +273,7 @@ void Object2B(Entity*);
void Beanstalk(Entity*);
void Smoke(Entity*);
void PushableRock(Entity*);
void HittableLever(Entity*);
void HittableLever();
void Object30(Entity*);
void FrozenFlower(Entity*);
void PullableMushroom(Entity*);

View File

@ -691,7 +691,7 @@ SECTIONS {
asm/object/beanstalk.o(.text);
src/object/smoke.o(.text);
asm/object/pushableRock.o(.text);
asm/object/hittableLever.o(.text);
src/object/hittableLever.o(.text);
asm/object/object30.o(.text);
src/object/frozenFlower.o(.text);
asm/object/pullableMushroom.o(.text);
@ -1416,7 +1416,7 @@ SECTIONS {
data/const/object/smoke.o(.rodata);
data/const/object/pushableRock.o(.rodata);
data/animations/object/pushableRock.o(.rodata);
data/const/object/hittableLever.o(.rodata);
src/object/hittableLever.o(.rodata);
data/const/object/object30.o(.rodata);
data/const/object/object31.o(.rodata);
data/const/object/pullableMushroom.o(.rodata);

View File

@ -46,7 +46,6 @@ u32 sub_08058B08(ManagerC*, u32, u32, const struct_08108228*);
void sub_08058B5C(ManagerC*, u32);
extern void sub_0805622C(struct BgAffineDstData*, u32, u32);
extern void sub_080044AE(Entity*, u32, u32);
extern u8 gUnk_03003DE4[0xC];

View File

@ -259,8 +259,6 @@ u32 sub_08081F7C(Entity* this, u32 r7) {
return 1;
}
extern void sub_080044AE(Entity*, u32, u32);
void sub_08081FF8(Entity* this) {
u32 direction;
u32 i;

View File

@ -0,0 +1,79 @@
/**
* @file hittableLever.c
* @ingroup Objects
*
* @brief Hittable Lever object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[8];
/*0x70*/ u16 wasHit; /**< Has this lever been hit before. */
/*0x72*/ u8 unk_72[0x14];
/*0x86*/ u16 hitFlag;
} HittableLeverEntity;
extern void (*const HittableLever_Actions[])(HittableLeverEntity*);
extern const Hitbox gUnk_08121180;
void HittableLever_UpdateTile(HittableLeverEntity*);
void HittableLever(HittableLeverEntity* this) {
if (super->iframes == 0) {
this->wasHit = 0;
}
HittableLever_Actions[super->action](this);
}
void HittableLever_Init(HittableLeverEntity* this) {
super->action = 1;
super->flags |= 0x80;
super->field_0x3c = 7;
super->hitType = 0x8f;
super->flags2 = 0xa;
super->hitbox = (Hitbox*)&gUnk_08121180;
if (super->type == 0) {
if (CheckFlags(this->hitFlag)) {
super->type = 1;
} else {
super->type = 0;
}
} else {
SetFlag(this->hitFlag);
}
HittableLever_UpdateTile(this);
}
void HittableLever_Idle(HittableLeverEntity* this) {
if (((super->bitfield & 0x80) != 0) && (this->wasHit == 0)) {
this->wasHit = 1;
super->type ^= 1;
super->iframes = -0x18;
HittableLever_UpdateTile(this);
if (CheckFlags(this->hitFlag)) {
ClearFlag(this->hitFlag);
} else {
SetFlag(this->hitFlag);
}
SoundReqClipped(super, SFX_117);
}
}
void HittableLever_UpdateTile(HittableLeverEntity* this) {
if (super->type != 0) {
sub_0807B7D8(0x378, COORD_TO_TILE(super), super->collisionLayer);
} else {
sub_0807B7D8(0x377, COORD_TO_TILE(super), super->collisionLayer);
}
}
void (*const HittableLever_Actions[])(HittableLeverEntity*) = {
HittableLever_Init,
HittableLever_Idle,
};
const Hitbox gUnk_08121180 = { 0, 1, { 0, 0, 0, 0 }, 4, 3 };

View File

@ -30,8 +30,6 @@ typedef struct {
enum PullableLeverPart { HANDLE, MIDDLE, SOCKET };
extern void sub_080044AE(Entity*, u32, u32);
extern u16 gUnk_02021F00[];
extern Hitbox gUnk_080FD270;
extern Hitbox gUnk_080FD278;