mirror of
https://github.com/zeldaret/tmc
synced 2026-07-27 14:52:13 -04:00
Decompile PushableLever
This commit is contained in:
+2
-3
@@ -101,7 +101,6 @@ void sub_08081C98(Entity* this) {
|
||||
}
|
||||
|
||||
Entity* sub_08081D74(Entity*);
|
||||
u32 sub_080001DA(u32, u32);
|
||||
|
||||
u32 sub_08081CB0(Entity* this) {
|
||||
u16 tmp;
|
||||
@@ -114,7 +113,7 @@ u32 sub_08081CB0(Entity* this) {
|
||||
} else {
|
||||
tmp = GetTileType(this->field_0x74.HWORD, this->collisionLayer);
|
||||
if (tmp != 0x77 && tmp != 0x79 && tmp != 0x4035) {
|
||||
this->field_0x70.HALF.LO = sub_080001DA(this->field_0x74.HWORD, this->collisionLayer);
|
||||
this->field_0x70.HALF.LO = GetTileIndex(this->field_0x74.HWORD, this->collisionLayer);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +128,7 @@ u32 sub_08081D28(Entity* this) {
|
||||
if (this->field_0x70.HALF_U.LO == 0xFFFF) {
|
||||
return 0;
|
||||
}
|
||||
if (sub_080001DA(this->field_0x74.HWORD, this->collisionLayer) != this->field_0x70.HALF_U.LO) {
|
||||
if (GetTileIndex(this->field_0x74.HWORD, this->collisionLayer) != this->field_0x70.HALF_U.LO) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "object.h"
|
||||
|
||||
extern void sub_080001D0(u32, u32, u32);
|
||||
extern u32 sub_080001DA(u32, u32);
|
||||
|
||||
enum {
|
||||
FURNITURE_INIT,
|
||||
@@ -374,7 +373,7 @@ static void sub_08090B6C(FurnitureEntity* this) {
|
||||
}
|
||||
|
||||
static void sub_08090CDC(u32 id, u32 pos, u32 layer) {
|
||||
u16 cur = sub_080001DA(pos, layer);
|
||||
u16 cur = GetTileIndex(pos, layer);
|
||||
u32 next = cur;
|
||||
u32 id2;
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ void LockedDoor(Entity* this) {
|
||||
|
||||
extern Hitbox gHitbox_2;
|
||||
|
||||
extern u32 sub_080001DA(u32, u32);
|
||||
extern void sub_08078850(Entity*, u32, u32, u32);
|
||||
|
||||
typedef struct PACKED {
|
||||
@@ -102,7 +101,7 @@ void sub_08083338(Entity* this) {
|
||||
this->spritePriority.b0 = 5;
|
||||
this->frame = this->type & 0xF;
|
||||
this->field_0x76.HWORD = TILE(this->x.HALF.HI, this->y.HALF.HI);
|
||||
this->field_0x74.HWORD = sub_080001DA(this->field_0x76.HWORD, this->collisionLayer);
|
||||
this->field_0x74.HWORD = GetTileIndex(this->field_0x76.HWORD, this->collisionLayer);
|
||||
switch (this->type2) {
|
||||
case 0:
|
||||
if (!CheckFlags(this->field_0x86.HWORD)) {
|
||||
|
||||
+2
-3
@@ -4,7 +4,6 @@
|
||||
extern void (*MaskActionFuncs[])(Entity*);
|
||||
|
||||
extern void sub_08000148(u16, u16, u32);
|
||||
extern s16 sub_080001DA(u16, u32);
|
||||
|
||||
extern void sub_0805457C(Entity*, s32);
|
||||
|
||||
@@ -48,8 +47,8 @@ void sub_080929A4(Entity* this) {
|
||||
|
||||
this->frameIndex = this->type2 & 0x3f;
|
||||
|
||||
this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
|
||||
this->field_0x7c.HALF.LO = sub_080001DA(this->field_0x7c.HALF.HI, 1);
|
||||
this->field_0x7c.HALF_U.HI = COORD_TO_TILE(this);
|
||||
this->field_0x7c.HALF_U.LO = GetTileIndex(this->field_0x7c.HALF_U.HI, 1);
|
||||
|
||||
this->field_0x7a.HWORD = sub_080002E0((u16)this->field_0x7c.HALF.HI, 1);
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
extern u32 sub_08083734(Entity*, u32);
|
||||
extern void sub_080A080C(Entity*);
|
||||
extern void sub_080A0870(Entity*);
|
||||
extern u32 sub_080001DA(u32, u32);
|
||||
|
||||
extern void (*const gUnk_0812493C[])(Entity*);
|
||||
|
||||
@@ -93,9 +92,9 @@ void sub_080A07F0(Entity* this) {
|
||||
}
|
||||
|
||||
void sub_080A080C(Entity* this) {
|
||||
this->field_0x76.HWORD = sub_080001DA(this->field_0x74.HWORD - 1, this->collisionLayer);
|
||||
this->field_0x78.HWORD = sub_080001DA(this->field_0x74.HWORD, this->collisionLayer);
|
||||
this->field_0x7a.HWORD = sub_080001DA(this->field_0x74.HWORD + 1, this->collisionLayer);
|
||||
this->field_0x76.HWORD = GetTileIndex(this->field_0x74.HWORD - 1, this->collisionLayer);
|
||||
this->field_0x78.HWORD = GetTileIndex(this->field_0x74.HWORD, this->collisionLayer);
|
||||
this->field_0x7a.HWORD = GetTileIndex(this->field_0x74.HWORD + 1, this->collisionLayer);
|
||||
SetTile(0x4022, this->field_0x74.HWORD - 1, this->collisionLayer);
|
||||
SetTile(0x4022, this->field_0x74.HWORD, this->collisionLayer);
|
||||
SetTile(0x4022, this->field_0x74.HWORD + 1, this->collisionLayer);
|
||||
|
||||
+2
-3
@@ -18,7 +18,6 @@ extern void (*const gUnk_0811F0C4[])(Entity*);
|
||||
extern Hitbox gHitbox_18; // TODO: should be const
|
||||
extern Hitbox gUnk_080FD340; // TODO: should be const
|
||||
|
||||
extern u32 sub_080001DA(u32, u32);
|
||||
extern void sub_08078930(Entity*);
|
||||
extern void sub_08016A6C(Entity*);
|
||||
|
||||
@@ -47,7 +46,7 @@ void sub_0808222C(Entity* this) {
|
||||
ResolveCollisionLayer(this);
|
||||
}
|
||||
|
||||
this->field_0x70.HALF.LO = sub_080001DA(COORD_TO_TILE(this), this->collisionLayer);
|
||||
this->field_0x70.HALF.LO = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer);
|
||||
if ((u16)this->field_0x70.HALF.LO == 0x4000) {
|
||||
DeleteThisEntity();
|
||||
}
|
||||
@@ -188,7 +187,7 @@ void sub_08082614(Entity* this) {
|
||||
this->speed <<= 1;
|
||||
}
|
||||
|
||||
this->field_0x70.HALF.LO = sub_080001DA(COORD_TO_TILE(this), this->collisionLayer);
|
||||
this->field_0x70.HALF.LO = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer);
|
||||
tileType = GetTileTypeByEntity(this);
|
||||
switch (tileType) {
|
||||
case 0x71:
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* @file pushableLever.c
|
||||
* @ingroup Objects
|
||||
*
|
||||
* @brief Pushable 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 tilePosition;
|
||||
/*0x72*/ u16 tileIndex;
|
||||
/*0x74*/ u16 timer;
|
||||
/*0x76*/ u8 unk_76[16];
|
||||
/*0x86*/ u16 pushedFlag;
|
||||
} PushableLeverEntity;
|
||||
|
||||
enum PushableLeverAction {
|
||||
INIT,
|
||||
IDLE,
|
||||
PUSHING
|
||||
};
|
||||
|
||||
extern void (*const PushableLever_Actions[])(PushableLeverEntity*);
|
||||
extern const u16 PushableLever_Tiles[];
|
||||
extern const u8 PushableLever_InitialOffsets[];
|
||||
extern const u8 PushableLever_PushedOffsets[];
|
||||
|
||||
void PushableLever_SetIdle(PushableLeverEntity*);
|
||||
bool32 PushableLever_ShouldStartPushing(PushableLeverEntity* this);
|
||||
void PushableLever_SetTiles(PushableLeverEntity*);
|
||||
void PushableLever_CalculateSpriteOffsets(PushableLeverEntity*);
|
||||
|
||||
#define TILE_INITIAL 0x4053
|
||||
#define TILE_PUSHED 0x4052
|
||||
|
||||
void PushableLever(PushableLeverEntity* this) {
|
||||
PushableLever_Actions[super->action](this);
|
||||
}
|
||||
|
||||
void PushableLever_Init(PushableLeverEntity* this) {
|
||||
super->spritePriority.b0 = 5;
|
||||
PushableLever_SetIdle(this);
|
||||
}
|
||||
|
||||
void PushableLever_Idle(PushableLeverEntity* this) {
|
||||
if (PushableLever_ShouldStartPushing(this)) {
|
||||
super->action = PUSHING;
|
||||
super->spriteOffsetX = 0;
|
||||
super->spriteOffsetY = 0;
|
||||
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
|
||||
EnqueueSFX(SFX_16A);
|
||||
RequestPriorityDuration(super, 0x1e);
|
||||
if (sub_08079F8C()) {
|
||||
gPlayerState.pushedObject = 0x90;
|
||||
gPlayerState.queued_action = 5;
|
||||
gPlayerState.flags |= 1;
|
||||
gPlayerEntity.x.HALF.LO = 0;
|
||||
gPlayerEntity.y.HALF.LO = 0;
|
||||
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PushableLever_Pushing(PushableLeverEntity* this) {
|
||||
GetNextFrame(super);
|
||||
if ((super->frame & 0x80) != 0) {
|
||||
if (super->type2 == 0) {
|
||||
SetFlag(this->pushedFlag);
|
||||
} else {
|
||||
ClearFlag(this->pushedFlag);
|
||||
}
|
||||
PushableLever_SetIdle(this);
|
||||
}
|
||||
}
|
||||
|
||||
void PushableLever_SetIdle(PushableLeverEntity* this) {
|
||||
super->action = IDLE;
|
||||
this->timer = 0x3c;
|
||||
PushableLever_SetTiles(this);
|
||||
}
|
||||
|
||||
void PushableLever_SetTiles(PushableLeverEntity* this) {
|
||||
if (CheckFlags(this->pushedFlag) == FALSE) {
|
||||
super->type2 = 0;
|
||||
this->tilePosition = COORD_TO_TILE_OFFSET(super, 0, 0x10);
|
||||
this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer);
|
||||
SetTile(TILE_INITIAL, this->tilePosition, super->collisionLayer);
|
||||
InitializeAnimation(super, 1);
|
||||
} else {
|
||||
super->type2 = 1;
|
||||
this->tilePosition = COORD_TO_TILE_OFFSET(super, 0x10, 0);
|
||||
this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer);
|
||||
SetTile(TILE_PUSHED, this->tilePosition, super->collisionLayer);
|
||||
InitializeAnimation(super, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool32 PushableLever_ShouldStartPushing(PushableLeverEntity* this) {
|
||||
if (GetTileIndex(this->tilePosition, super->collisionLayer) == 0x4054) {
|
||||
if (--this->timer == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
PushableLever_CalculateSpriteOffsets(this);
|
||||
SetTile(PushableLever_Tiles[super->type2], this->tilePosition, super->collisionLayer);
|
||||
} else {
|
||||
this->timer = 0x3c;
|
||||
super->spriteOffsetX = 0;
|
||||
super->spriteOffsetY = 0;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void PushableLever_CalculateSpriteOffsets(PushableLeverEntity* this) {
|
||||
const u8* offsets;
|
||||
if (super->type2 == 0) {
|
||||
offsets = PushableLever_InitialOffsets;
|
||||
} else {
|
||||
offsets = PushableLever_PushedOffsets;
|
||||
}
|
||||
offsets = &offsets[(this->timer / 4) & 6];
|
||||
super->spriteOffsetX = offsets[0];
|
||||
super->spriteOffsetY = offsets[1];
|
||||
if ((this->timer & 3) == 0) {
|
||||
EnqueueSFX(SFX_104);
|
||||
}
|
||||
}
|
||||
|
||||
void (*const PushableLever_Actions[])(PushableLeverEntity*) = {
|
||||
PushableLever_Init,
|
||||
PushableLever_Idle,
|
||||
PushableLever_Pushing,
|
||||
};
|
||||
const u16 PushableLever_Tiles[] = {
|
||||
TILE_INITIAL,
|
||||
TILE_PUSHED,
|
||||
};
|
||||
const u8 PushableLever_InitialOffsets[] = {
|
||||
0, 0, 0, 0, 255, 0, 0, 0,
|
||||
};
|
||||
const u8 PushableLever_PushedOffsets[] = {
|
||||
0, 0, 0, 0, 0, 255, 0, 0,
|
||||
};
|
||||
Reference in New Issue
Block a user