diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2022-01-24 21:52:22 +0100 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2022-01-24 21:52:22 +0100 |
| commit | a6657fbd330de38b99646e0513e7c74bc871fac9 (patch) | |
| tree | bdaeb892ce0ffcf061328150fc4bdbeeffd76746 /src/object | |
| parent | b7abbfd9272d001f1425cc84f7aaedaaf5d22414 (diff) | |
Decompile HittableLever
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/button.c | 2 | ||||
| -rw-r--r-- | src/object/hittableLever.c | 79 | ||||
| -rw-r--r-- | src/object/pullableLever.c | 2 |
3 files changed, 79 insertions, 4 deletions
diff --git a/src/object/button.c b/src/object/button.c index 3cc892d5..61f4e704 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -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; diff --git a/src/object/hittableLever.c b/src/object/hittableLever.c new file mode 100644 index 00000000..c7c1022c --- /dev/null +++ b/src/object/hittableLever.c @@ -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 }; diff --git a/src/object/pullableLever.c b/src/object/pullableLever.c index 3e122953..28109862 100644 --- a/src/object/pullableLever.c +++ b/src/object/pullableLever.c @@ -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; |
