Merge pull request #412 from octorock/objects

Decompile some objects
This commit is contained in:
notyourav
2022-02-27 14:23:32 -08:00
committed by GitHub
92 changed files with 1955 additions and 4736 deletions
+1 -2
View File
@@ -9,6 +9,7 @@
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -19,8 +20,6 @@ typedef struct {
/*0x86*/ u16 unk_86;
} BigIceBlockEntity;
extern const Hitbox gUnk_080FD190;
extern void (*const BigIceBlock_Actions[])(BigIceBlockEntity*);
extern const u16 gUnk_081237B0[];
+1 -1
View File
@@ -9,6 +9,7 @@
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -25,7 +26,6 @@ typedef struct {
/*0x86*/ u16 unk_86;
} BossDoorEntity;
extern Hitbox gHitbox_3;
extern bool32 gUnk_02036BB8;
extern const u8 gUnk_0811F740[];
+1 -2
View File
@@ -9,6 +9,7 @@
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -19,8 +20,6 @@ typedef struct {
extern u32 sub_080002BC(s32, s32, u32);
extern Hitbox gUnk_080FD2A8;
void sub_080969A4(CrenelBeanSproutEntity*);
void sub_08096A78(CrenelBeanSproutEntity*);
void CrenelBeanSprout_Init(CrenelBeanSproutEntity*);
+83
View File
@@ -0,0 +1,83 @@
/**
* @file enemyItem.c
* @ingroup Objects
*
* @brief Enemy Item object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x1e];
/*0x86*/ u16 unk_86;
} EnemyItemEntity;
void sub_080A2500(EnemyItemEntity*);
void sub_080A2534(EnemyItemEntity*);
void sub_080A2508(EnemyItemEntity*);
void EnemyItem(EnemyItemEntity* this) {
Entity* entity;
LinkedList* list;
if (CheckFlags(this->unk_86)) {
sub_080A2500(this);
}
if (super->action == 0) {
super->action++;
super->type = super->actionDelay;
super->child = NULL;
list = &gEntityLists[4];
for (entity = list->first; entity != (Entity*)list; entity = entity->next) {
if ((((entity->kind == 3) && (super->type2 == entity->id)) &&
(((entity->x.HALF.HI - super->x.HALF.HI) + 0x10U) << 0x10 >> 0x10 < 0x20)) &&
(((entity->y.HALF.HI - super->y.HALF.HI) + 0x10U) << 0x10 >> 0x10 < 0x20)) {
super->child = entity;
break;
}
}
if (super->child == NULL) {
sub_080A2534(this);
}
sub_08054564();
}
entity = super->child;
if (entity != NULL) {
PositionRelative(entity, super, 0x40000, 0x10000);
super->z.HALF.HI -= 4;
if (entity->next == NULL) {
sub_080A2508(this);
}
}
sub_08080CB4(super);
}
void sub_080A2500(EnemyItemEntity* this) {
DeleteThisEntity();
}
void sub_080A2508(EnemyItemEntity* this) {
EnemyItemEntity* entity;
entity = (EnemyItemEntity*)CreateObjectWithParent(super, GROUND_ITEM, super->type, 0);
if (entity != NULL) {
(entity->base).actionDelay = 5;
entity->unk_86 = this->unk_86;
}
sub_080A2500(this);
}
void sub_080A2534(EnemyItemEntity* this) {
EnemyItemEntity* entity;
entity = (EnemyItemEntity*)CreateObjectWithParent(super, GROUND_ITEM, super->type, 0);
if (entity != NULL) {
(entity->base).actionDelay = 4;
entity->unk_86 = this->unk_86;
}
sub_080A2500(this);
}
+1 -2
View File
@@ -10,6 +10,7 @@
#include "object.h"
#include "functions.h"
#include "item.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -21,8 +22,6 @@ typedef struct {
/*0x87*/ u8 unk_87;
} FairyEntity;
extern Hitbox gUnk_080FD1A8;
void sub_0808D76C(FairyEntity*);
void sub_0808DAD0(FairyEntity*);
void sub_0808DB2C(FairyEntity*);
+170
View File
@@ -0,0 +1,170 @@
/**
* @file fourElements.c
* @ingroup Objects
*
* @brief Four Elements object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
#include "screen.h"
#include "message.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u16 unk_68;
/*0x6a*/ u8 unk_6a;
} FourElementsEntity;
extern u32 sub_0805429C(u32);
extern void sub_0807DF50(void);
extern u16 script_PlayerGetElement[];
void FourElements_Init(FourElementsEntity*);
void FourElements_Action1(FourElementsEntity*);
void FourElements_Action2(FourElementsEntity*);
void FourElements_Action3(FourElementsEntity*);
void FourElements_Action4(FourElementsEntity*);
void FourElements_Action5(FourElementsEntity*);
void FourElements_Action6(FourElementsEntity*);
void sub_080A0424(FourElementsEntity*);
void sub_080A0444(FourElementsEntity*);
void FourElements(FourElementsEntity* this) {
static void (*const FourElements_Actions[])(FourElementsEntity*) = {
FourElements_Init, FourElements_Action1, FourElements_Action2, FourElements_Action3,
FourElements_Action4, FourElements_Action5, FourElements_Action6,
};
FourElements_Actions[super->action](this);
sub_08080CB4(super);
}
void FourElements_Init(FourElementsEntity* this) {
Entity* objectAD;
super->action = 1;
super->spriteSettings.draw = 1;
super->spritePriority.b1 = 2;
super->spriteRendering.b3 = 1;
super->hitbox = (Hitbox*)&gHitbox_6;
super->z.HALF.HI = 0xff40;
this->unk_6a = 0x40;
switch (super->type) {
case 0x41:
gScreen.lcd.displayControl &= 0xfdff;
super->collisionLayer = 1;
break;
case 0x40:
case 0x42:
case 0x43:
break;
}
StartPlayerScript(script_PlayerGetElement);
gScreen.controls.layerFXControl = 0x640;
gScreen.controls.alphaBlend = 0x1000;
sub_0805BC4C();
objectAD = CreateObjectWithParent(super, OBJECT_AD, super->type - 0x40, 0);
if (objectAD != NULL) {
objectAD->parent = super;
super->child = objectAD;
}
}
void FourElements_Action1(FourElementsEntity* this) {
if ((gActiveScriptInfo.syncFlags & 4) != 0) {
sub_080A0424(this);
if (super->z.HALF.HI < -8) {
super->z.HALF.HI++;
} else {
super->action = 2;
gActiveScriptInfo.syncFlags |= 2;
}
}
}
void FourElements_Action2(FourElementsEntity* this) {
sub_080A0424(this);
sub_080A0444(this);
if (IsCollidingPlayer(super)) {
DeleteEntity(super->child);
super->spriteSettings.draw = 0;
super->action = 3;
super->actionDelay = 0x2d;
gScreen.controls.layerFXControl = 0x640;
gScreen.controls.alphaBlend = 0;
sub_080A7C18(super->type, 0, 1);
sub_0808C650(super, 1);
SetFade(6, 2);
SoundReq(SFX_F8);
SoundReq(SFX_148);
SoundReq(BGM_ELEMENT_GET);
SoundReq(SONG_BGM_0);
}
}
void FourElements_Action3(FourElementsEntity* this) {
if (super->actionDelay != 0) {
sub_080A0424(this);
if (--super->actionDelay == 0) {
SetDefaultPriority(&gPlayerEntity, 0);
}
} else {
RequestPriorityDuration(NULL, 0x3c);
if (sub_0808C67C()) {
super->action = 4;
}
}
}
void FourElements_Action4(FourElementsEntity* this) {
RequestPriorityDuration(NULL, 0x3c);
if (gFadeControl.active == 0) {
super->action = 5;
this->unk_68 = 0x1a4;
}
}
void FourElements_Action5(FourElementsEntity* this) {
u32 index;
RequestPriorityDuration(NULL, 10);
if (--this->unk_68 == 0) {
super->action = 6;
index = sub_0805429C(super->type);
MessageNoOverlap(index, super);
}
}
void FourElements_Action6(FourElementsEntity* this) {
RequestPriorityDuration(NULL, 10);
if ((gMessage.doTextBox & 0x7f) == 0) {
SetPriorityTimer(0x5a);
gPlayerState.controlMode = 1;
sub_0807DF50();
SetRoomFlag(0);
DeleteThisEntity();
}
}
void sub_080A0424(FourElementsEntity* this) {
if (--this->unk_6a == 0) {
this->unk_6a = 0x40;
SoundReq(SFX_178);
}
}
void sub_080A0444(FourElementsEntity* this) {
static const u8 gUnk_081248B4[] = {
249, 248, 247, 246, 245, 246, 247, 248,
};
super->z.HALF.HI = gUnk_081248B4[(super->field_0xf++ >> 3) & 7] << 0x18 >> 0x18;
}
void sub_080A0464(FourElementsEntity* this, ScriptExecutionContext* context) {
Entity* element = FindEntityByID(6, FOUR_ELEMENTS, 6);
if (element != NULL) {
sub_0807DEDC(super, context, element->x.HALF.HI, element->y.HALF.HI + 0x18);
}
}
+182
View File
@@ -0,0 +1,182 @@
/**
* @file itemForSale.c
* @ingroup Objects
*
* @brief Item for Sale object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
#include "new_player.h"
#include "message.h"
#include "kinstone.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x18];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
} ItemForSaleEntity;
typedef struct {
u8 before[0x20];
u8 unk_20[0x4]; // TODO for Entity this is zVelocity which is not an array. spriteAnimation[super->field_0xf-6] does
// not match.
} ModifiedParentEntity;
extern u32 sub_080787D8(Entity*);
extern void* sub_080784E4(void);
void ItemForSale_Init(ItemForSaleEntity*);
void ItemForSale_Action1(ItemForSaleEntity*);
void ItemForSale_Action2(ItemForSaleEntity*);
void ItemForSale_Action3(ItemForSaleEntity*);
void sub_08081A5C(ItemForSaleEntity*);
void sub_080819B4(ItemForSaleEntity*);
void sub_08081AB0(void);
void ItemForSale(ItemForSaleEntity* this) {
static void (*const ItemForSale_Actions[])(ItemForSaleEntity*) = {
ItemForSale_Init,
ItemForSale_Action1,
ItemForSale_Action2,
ItemForSale_Action3,
};
ItemForSale_Actions[super->action](this);
if (CheckOnScreen(super)) {
sub_08080CB4(super);
}
switch (super->actionDelay) {
case 1:
case 2:
if (super->action == 1) {
sub_0800445C(super);
}
break;
case 0:
case 3:
break;
}
}
void ItemForSale_Init(ItemForSaleEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
super->spritePriority.b1 = 0;
super->field_0x16 = 0;
#ifdef EU
SetDefaultPriority(super, 6);
#endif
super->child = super;
sub_08081A5C(this);
switch (super->actionDelay) {
case 0:
super->hitbox = (Hitbox*)&gUnk_080FD328;
break;
case 1:
super->hitbox = (Hitbox*)&gHitbox_5;
break;
}
}
void ItemForSale_Action1(ItemForSaleEntity* this) {
if (super->subAction != 0) {
super->action = 2;
gUnk_0200AF00.filler25[10] = 2;
} else {
if (super->type == 0x36) {
if (super->interactType != 0) {
super->interactType = 0;
super->action = 3;
gRoomVars.animFlags = 1;
gPlayerState.queued_action = 7;
}
} else {
if (super->interactType != 0) {
super->interactType = 0;
super->subAction = 1;
sub_08078B48();
ResetPlayer();
gPlayerState.heldObject = 4;
gNewPlayerEntity.unk_74 = super;
gUnk_0200AF00.filler25[10] = 2;
MessageClose();
}
}
}
}
void ItemForSale_Action2(ItemForSaleEntity* this) {
void* ptr;
gUnk_0200AF00.filler25[10] = 2;
super->spriteSettings.draw = gPlayerEntity.spriteSettings.draw;
if ((gPlayerState.heldObject == 0) || (super != gNewPlayerEntity.unk_74)) {
sub_080819B4(this);
} else {
ptr = sub_080784E4();
if (((*(int*)(ptr + 8) == 0) ||
((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.filler25[10] = 7, (gPlayerState.field_0x92 & 0x88) == 0)))) &&
((gPlayerState.field_0x92 & 0x98) != 0)) {
sub_080819B4(this);
}
}
}
void sub_080819B4(ItemForSaleEntity* this) {
Entity* parent;
u8* puVar2;
struct_0200AF00* ptr;
if (gRoomVars.shopItemType == 0) {
if (super->parent != NULL) {
((ModifiedParentEntity*)super->parent)->unk_20[super->field_0xf] = 0xff;
}
DeleteThisEntity();
}
gPlayerState.heldObject = 0;
gNewPlayerEntity.unk_74 = 0;
ptr = &gUnk_0200AF00;
gRoomVars.shopItemType = 0;
ptr->filler25[7] = 0;
ptr->filler25[10] = 0;
gRoomVars.shopItemType2 = 0;
super->x.HALF.HI = this->unk_80 + gRoomControls.origin_x;
super->y.HALF.HI = this->unk_82 + gRoomControls.origin_y;
super->z.WORD = 0;
super->action = 1;
super->subAction = 0;
super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
super->collisionLayer = 1;
super->spritePriority.b0 = 4;
UpdateSpriteForCollisionLayer(super);
sub_08081A5C(this);
}
void sub_08081A5C(ItemForSaleEntity* this) {
u32 tmp = sub_080787D8(super);
if (super->actionDelay == 1) {
gUnk_03003DF0[tmp].unk4[2] = 0;
}
}
void ItemForSale_Action3(ItemForSaleEntity* this) {
if (gRoomVars.animFlags == 0) {
sub_08081AB0();
DeleteThisEntity();
} else if (gRoomVars.animFlags == 2) {
super->action = 1;
super->subAction = 0;
sub_08081AB0();
}
}
void sub_08081AB0(void) {
gRoomVars.animFlags = 0;
gRoomVars.shopItemType = 0;
gRoomVars.shopItemType2 = 0;
SetPlayerControl(CONTROL_ENABLED);
}
+2 -2
View File
@@ -7,6 +7,7 @@
#include "item.h"
#include "itemMetaData.h"
#include "functions.h"
#include "hitbox.h"
void sub_08081150(Entity*);
u8 sub_0808147C(u32);
@@ -23,7 +24,6 @@ extern void (*const gUnk_0811E7D4[])(Entity*);
extern void (*const gUnk_0811E7E8[])(Entity*);
extern void (*const gUnk_0811E814[])(Entity*);
extern void (*const gUnk_0811E840[])(Entity*);
extern Hitbox gUnk_080FD1A8;
typedef struct {
u8 unk0[2];
@@ -86,7 +86,7 @@ void sub_08080F20(Entity* this) {
this->field_0x3c = 0x47;
this->hurtType = 0x44;
this->health = 0xFF;
this->hitbox = &gUnk_080FD1A8;
this->hitbox = (Hitbox*)&gUnk_080FD1A8;
switch (this->type) {
case ITEM_SHELLS:
case ITEM_RUPEE1:
+1 -1
View File
@@ -9,6 +9,7 @@
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -32,7 +33,6 @@ typedef struct {
} LavaPlatformEntry;
extern void sub_080A2CC0(Entity*, Entity**, u16*);
extern Hitbox gUnk_080FD280;
void sub_08092278(LavaPlatformEntity*);
void sub_08092344(LavaPlatformEntity*);
+3 -4
View File
@@ -5,13 +5,12 @@
#include "room.h"
#include "flags.h"
#include "functions.h"
#include "hitbox.h"
extern void (*const gUnk_081243B4[])(Entity*);
extern void (*const gUnk_081243BC[])(Entity*);
extern void (*const gUnk_081243C4[])(Entity*);
extern Hitbox gHitbox_0;
void LightableSwitch(Entity* this) {
gUnk_081243B4[this->type](this);
sub_0809EB30(this);
@@ -29,7 +28,7 @@ void sub_0809EA34(Entity* this) {
this->hurtType = 0x48;
this->hitType = 0x28;
this->flags2 = 10;
this->hitbox = &gHitbox_0;
this->hitbox = (Hitbox*)&gHitbox_0;
sub_0809EAD8(this);
UpdateSpriteForCollisionLayer(this);
sub_0809EABC(this);
@@ -101,7 +100,7 @@ void sub_0809EB80(Entity* this) {
this->hurtType = 0x48;
this->hitType = 0x28;
this->flags2 = 10;
this->hitbox = &gHitbox_0;
this->hitbox = (Hitbox*)&gHitbox_0;
sub_0809EAD8(this);
UpdateSpriteForCollisionLayer(this);
if (CheckFlags(this->cutsceneBeh.HWORD) != 0) {
+2 -3
View File
@@ -7,6 +7,7 @@
#include "effects.h"
#include "game.h"
#include "common.h"
#include "hitbox.h"
void sub_08083338(Entity*);
void sub_080834B4(Entity*);
@@ -35,8 +36,6 @@ void LockedDoor(Entity* this) {
gUnk_0811F65C[this->action](this);
}
extern Hitbox gHitbox_2;
typedef struct PACKED {
s8 x;
s8 y;
@@ -95,7 +94,7 @@ void sub_08083338(Entity* this) {
this->field_0x70.HALF.LO = this->x.HALF.HI;
this->field_0x70.HALF.HI = this->y.HALF.HI;
this->field_0x7c.BYTES.byte2 = this->type & 3;
this->hitbox = &gHitbox_2;
this->hitbox = (Hitbox*)&gHitbox_2;
this->spritePriority.b0 = 5;
this->frame = this->type & 0xF;
this->field_0x76.HWORD = TILE(this->x.HALF.HI, this->y.HALF.HI);
+2 -3
View File
@@ -6,6 +6,7 @@
#include "sound.h"
#include "functions.h"
#include "effects.h"
#include "hitbox.h"
extern u32 sub_08083734(Entity*, u32);
extern void sub_080A080C(Entity*);
@@ -13,8 +14,6 @@ extern void sub_080A0870(Entity*);
extern void (*const gUnk_0812493C[])(Entity*);
extern Hitbox gHitbox_3;
void MetalDoor(Entity* this) {
gUnk_0812493C[this->action](this);
}
@@ -28,7 +27,7 @@ void sub_080A0684(Entity* this) {
this->spriteSettings.draw = 0;
this->frameIndex = 0;
this->spriteSettings.flipY = 1;
this->hitbox = &gHitbox_3;
this->hitbox = (Hitbox*)&gHitbox_3;
this->spritePriority.b0 = 5;
this->field_0x70.HALF.LO = this->x.HALF.HI;
this->field_0x70.HALF.HI = this->y.HALF.HI;
+2 -3
View File
@@ -1,5 +1,6 @@
#include "object.h"
#include "functions.h"
#include "hitbox.h"
extern u32 sub_08091DDC(Entity*);
extern u32 sub_08007DD6(u32, u32);
@@ -8,8 +9,6 @@ extern void sub_08091C0C(Entity*);
extern void (*const gUnk_081223A8[])(Entity*);
extern Hitbox gUnk_080FD310;
extern const s8 gUnk_081223C8[];
extern const u32 gUnk_081223D8[];
@@ -30,7 +29,7 @@ void sub_080916EC(Entity* this) {
this->animationState = unk->field_0x5;
this->type2 = unk->field_0x6;
this->action = 1;
this->hitbox = &gUnk_080FD310;
this->hitbox = (Hitbox*)&gUnk_080FD310;
COLLISION_ON(this);
this->hitType = 1;
this->field_0x3c = 0x47;
+194
View File
@@ -0,0 +1,194 @@
/**
* @file minecartDoor.c
* @ingroup Objects
*
* @brief Minecart Door 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 unk_70;
/*0x72*/ u16 unk_72;
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78[0x6];
/*0x7e*/ u8 unk_7e;
/*0x7f*/ u8 unk_7f[0x7];
/*0x86*/ u16 unk_86;
} MinecartDoorEntity;
extern bool32 sub_080837B0(Entity*); // lockedDoor
extern void sub_080836DC(Entity*, u32, u32); // lockedDoor
extern void sub_08083814(Entity*, u32); // lockedDoor
bool32 sub_08096CEC(MinecartDoorEntity*);
void sub_08096E04(MinecartDoorEntity*);
bool32 sub_08096D84(MinecartDoorEntity*);
bool32 sub_08096D68(s32, s32, s32, s32);
void MinecartDoor_Init(MinecartDoorEntity*);
void MinecartDoor_Action1(MinecartDoorEntity*);
void MinecartDoor_Action2(MinecartDoorEntity*);
void MinecartDoor_Action3(MinecartDoorEntity*);
void MinecartDoor_Action4(MinecartDoorEntity*);
void MinecartDoor(MinecartDoorEntity* this) {
static void (*const MinecartDoor_Actions[])(MinecartDoorEntity*) = { MinecartDoor_Init, MinecartDoor_Action1,
MinecartDoor_Action2, MinecartDoor_Action3,
MinecartDoor_Action4 };
MinecartDoor_Actions[super->action](this);
}
void MinecartDoor_Init(MinecartDoorEntity* this) {
if (sub_080837B0(super)) {
if ((super->type & 4) != 0) {
this->unk_7e = 1;
super->type &= 3;
}
super->speed = 0x300;
this->unk_70 = super->x.HALF.HI;
this->unk_72 = super->y.HALF.HI;
super->spritePriority.b0 = 5;
this->unk_76 = COORD_TO_TILE(super);
this->unk_74 = GetTileIndex(this->unk_76, super->collisionLayer);
super->frameIndex = super->type;
if (sub_08096CEC(this)) {
if (this->unk_7e != 0) {
DeleteThisEntity();
} else {
sub_08096E04(this);
}
} else {
super->action = 1;
super->spriteSettings.draw = 1;
SetTile(0x4022, this->unk_76, super->collisionLayer);
}
}
}
void MinecartDoor_Action1(MinecartDoorEntity* this) {
if (sub_08096CEC(this)) {
super->action = 2;
super->actionDelay = 7;
super->direction = super->type << 3;
SetTile(this->unk_74, this->unk_76, super->collisionLayer);
EnqueueSFX(SFX_10B);
}
}
void MinecartDoor_Action2(MinecartDoorEntity* this) {
LinearMoveUpdate(super);
if (--super->actionDelay == 0) {
sub_08096E04(this);
super->spriteSettings.draw = 0;
super->x.HALF.HI = this->unk_70;
super->y.HALF.HI = this->unk_72;
if (this->unk_7e != 0) {
DeleteThisEntity();
}
}
}
void MinecartDoor_Action3(MinecartDoorEntity* this) {
bool32 bVar3;
if ((this->unk_7e != 0) && (CheckFlags(this->unk_86))) {
return;
}
if ((gPlayerState.flags & PL_IN_MINECART) != 0) {
if (super->type * 2 - (u32)gPlayerEntity.animationState == 0) {
if (sub_08083734(super, super->type) == 0) {
return;
}
goto label;
} else {
bVar3 = --super->actionDelay * 0x1000000;
}
} else {
bVar3 = sub_08096D84(this);
}
if (bVar3 == FALSE) {
label:
super->action = 4;
sub_080836DC(super, super->type, this->unk_76);
}
}
void MinecartDoor_Action4(MinecartDoorEntity* this) {
LinearMoveUpdate(super);
if (--super->actionDelay == 0) {
super->action = 1;
super->x.HALF.HI = this->unk_70;
super->y.HALF.HI = this->unk_72;
sub_08083814(super, super->type);
EnqueueSFX(SFX_10B);
}
}
bool32 sub_08096CEC(MinecartDoorEntity* this) {
if (this->unk_7e != 0 && CheckFlags(this->unk_86)) {
return TRUE;
} else {
if ((gPlayerState.flags & PL_IN_MINECART) != 0) {
Entity* player = &gPlayerEntity;
if ((((super->type << 1) ^ player->animationState) & 2) == 0) {
if ((super->type & 1) != 0) {
if (sub_08096D68(gPlayerEntity.y.HALF.HI, super->y.HALF.HI, gPlayerEntity.x.HALF.HI,
super->x.HALF.HI)) {
return TRUE;
}
} else {
if (sub_08096D68(gPlayerEntity.x.HALF.HI, super->x.HALF.HI, gPlayerEntity.y.HALF.HI,
super->y.HALF.HI)) {
return TRUE;
}
}
}
}
}
return FALSE;
}
bool32 sub_08096D68(s32 param_1, s32 param_2, s32 param_3, s32 param_4) {
if (((param_1 - param_2) + 8U < 0x11) && ((param_3 - param_4) + 0x30U < 0x61)) {
return TRUE;
} else {
return FALSE;
}
}
bool32 sub_08096D84(MinecartDoorEntity* this) {
switch (super->type) {
case 0:
if (((super->y.HALF.HI + 10) - (gPlayerEntity.y.HALF.HI)) < 0x65U) {
return TRUE;
}
break;
case 1:
if (((gPlayerEntity.x.HALF.HI) - (super->x.HALF.HI - 10)) < 0x65U) {
return TRUE;
}
break;
case 2:
if (((gPlayerEntity.y.HALF.HI) - (super->y.HALF.HI - 10)) < 0x65U) {
return TRUE;
}
break;
case 3:
if (((super->x.HALF.HI + 10) - (gPlayerEntity.x.HALF.HI)) < 0x65U) {
return TRUE;
}
break;
}
return FALSE;
}
void sub_08096E04(MinecartDoorEntity* this) {
super->action = 3;
super->actionDelay = 8;
}
+180
View File
@@ -0,0 +1,180 @@
/**
* @file object35.c
* @ingroup Objects
*
* @brief Object35 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 unk_70;
/*0x72*/ u16 unk_72;
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
} Object35Entity;
extern void sub_080836DC(Entity*, u32, u32); // lockedDoor
extern void sub_08083814(Entity*, u32); // lockedDoor
void Object35_Type0(Object35Entity*);
void Object35_Type1(Object35Entity*);
void Object35_Type2(Object35Entity*);
void Object35_Type0Init(Object35Entity*);
void Object35_Type0Action1(Object35Entity*);
void Object35_Type0Action2(Object35Entity*);
void Object35_Type1Init(Object35Entity*);
void Object35_Type1Action1(Object35Entity*);
void Object35_Type1Action2(Object35Entity*);
void Object35_Type1Action3(Object35Entity*);
void Object35_Type1Action4(Object35Entity*);
void Object35_Type1Action5(Object35Entity*);
void Object35_Type2Init(Object35Entity*);
void Object35_Type2Action1(Object35Entity*);
void Object35(Object35Entity* this) {
static void (*const Object35_Types[])(Object35Entity*) = {
Object35_Type0,
Object35_Type1,
Object35_Type2,
};
Object35_Types[super->type](this);
}
void Object35_Type0(Object35Entity* this) {
static void (*const Object35_Type0Actions[])(Object35Entity*) = {
Object35_Type0Init,
Object35_Type0Action1,
Object35_Type0Action2,
};
Object35_Type0Actions[super->action](this);
}
void Object35_Type0Init(Object35Entity* this) {
super->action = 2;
super->type2 = 2;
super->collisionLayer = 2;
UpdateSpriteForCollisionLayer(super);
super->spritePriority.b0 = 1;
super->actionDelay = -0x4c;
InitializeAnimation(super, super->type2);
}
void Object35_Type0Action1(Object35Entity* this) {
s8 tmp;
GetNextFrame(super);
if (--super->actionDelay == 0) {
super->actionDelay = -0x4c;
super->type2++;
tmp = 3;
super->type2 = super->type2 % tmp;
InitializeAnimation(super, super->type2);
}
}
void Object35_Type0Action2(Object35Entity* this) {
GetNextFrame(super);
}
void Object35_Type1(Object35Entity* this) {
static void (*const Object35_Type1Actions[])(Object35Entity*) = {
Object35_Type1Init, Object35_Type1Action1, Object35_Type1Action2,
Object35_Type1Action3, Object35_Type1Action4, Object35_Type1Action5,
};
Object35_Type1Actions[super->action](this);
gPlayerState.mobility |= 0x80;
}
void Object35_Type1Init(Object35Entity* this) {
super->speed = 0x300;
super->frameIndex = 0;
this->unk_70 = super->x.HALF.HI;
this->unk_72 = super->y.HALF.HI;
super->spritePriority.b0 = 5;
this->unk_76 = COORD_TO_TILE(super);
this->unk_74 = GetTileIndex(this->unk_76, super->collisionLayer);
if (super->actionDelay == 0) {
super->action = 1;
super->field_0xf = 0x78;
SetTile(0x4022, this->unk_76, super->collisionLayer);
} else {
super->action = 3;
super->spriteSettings.draw = 0;
super->spriteSettings.flipY = 1;
super->actionDelay = 0;
}
}
void Object35_Type1Action1(Object35Entity* this) {
if (CheckRoomFlag(0)) {
super->action = 2;
super->actionDelay = 7;
super->direction = 0;
SetTile(this->unk_74, this->unk_76, super->collisionLayer);
EnqueueSFX(SFX_10B);
}
}
void Object35_Type1Action2(Object35Entity* this) {
LinearMoveUpdate(super);
if (--super->actionDelay == 0) {
super->action = 5;
super->actionDelay = 8;
super->spriteSettings.draw = 0;
super->x.HALF.HI = this->unk_70;
super->y.HALF.HI = this->unk_72;
}
}
void Object35_Type1Action3(Object35Entity* this) {
if (sub_08083734(super, 2)) {
super->action = 4;
sub_080836DC(super, 2, this->unk_76);
}
}
void Object35_Type1Action4(Object35Entity* this) {
LinearMoveUpdate(super);
if (--super->actionDelay == 0) {
super->action = 5;
sub_08083814(super, 2);
EnqueueSFX(SFX_10B);
SetTile(0x4022, this->unk_76, super->collisionLayer);
}
}
void Object35_Type1Action5(Object35Entity* this) {
}
void Object35_Type2(Object35Entity* this) {
static void (*const Object35_Type2Actions[])(Object35Entity*) = {
Object35_Type2Init,
Object35_Type2Action1,
};
Object35_Type2Actions[super->action](this);
}
void Object35_Type2Init(Object35Entity* this) {
super->action = 1;
super->actionDelay = 0x10;
super->z.HALF.HI -= 0x10;
if (super->type2 == 0) {
super->frameIndex = 2;
} else {
super->frameIndex = 0;
if (((super->parent)->x.HALF.HI & 0x10) != 0) {
super->frameIndex = 1;
}
}
CreateDust(super);
}
void Object35_Type2Action1(Object35Entity* this) {
if (--super->actionDelay == 0) {
DeleteThisEntity();
}
}
+203
View File
@@ -0,0 +1,203 @@
/**
* @file object43.c
* @ingroup Objects
*
* @brief Object43 object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "item.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[4];
/*0x6c*/ u16 unk_6c;
/*0x6e*/ u8 unk_7e[4];
/*0x72*/ u16 unk_72;
} Object43Entity;
void Object43_Init(Object43Entity*);
void Object43_Action1(Object43Entity*);
void Object43_Action2(Object43Entity*);
void Object43_Action3(Object43Entity*);
void Object43_Action4(Object43Entity*);
void Object43(Object43Entity* this) {
static void (*const Object43_Actions[])(Object43Entity*) = {
Object43_Init, Object43_Action1, Object43_Action2, Object43_Action3, Object43_Action4,
};
Object43_Actions[super->action](this);
}
void Object43_Init(Object43Entity* this) {
super->action = 1;
super->flags |= ENT_PERSIST;
super->spritePriority.b0 = 0;
super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
super->animationState = gPlayerEntity.animationState >> 1;
super->direction = (((super->animationState + 1) & 3) << 3);
super->field_0xf = 6;
super->speed = 0x140;
super->spriteVramOffset = 0x3c;
super->palette.b.b0 = 4;
this->unk_72 = 0;
this->unk_6c = 0;
super->updatePriority = 6;
InitializeAnimation(super, 7);
if (super->type2 != 0) {
super->actionDelay = 0x28;
} else {
super->spriteSettings.draw = 1;
if ((gPlayerState.field_0xac & 0x200) != 0) {
super->actionDelay = 0x28;
} else {
super->actionDelay = 0x50;
}
Object43_Action1(this);
}
}
void Object43_Action1(Object43Entity* this) {
static const s8 gUnk_081217D0[] = { -1, -14, 8, -4, 4, 4, -8, -4 };
static const s8 gUnk_081217D8[] = { -1, -14, 4, -4, 4, -1, -4, -4 };
Entity* effect;
const s8* ptr;
const s8* ptr2;
u32 tmp1;
u32 tmp2;
if (super->type2 != 0) {
if ((gPlayerState.field_0x1f[2] == 0) || ((gPlayerState.field_0x3[1] & 0x80) != 0)) {
DeleteThisEntity();
}
if (gPlayerState.field_0x1f[2] >= 0x50) {
super->spriteSettings.draw = 1;
tmp1 = gPlayerState.field_0x1f[2];
ptr = gUnk_081217D8;
} else {
if (gPlayerState.field_0x1f[2] != 0) {
super->spriteSettings.draw = 0;
return;
}
DeleteThisEntity();
}
} else {
if (gPlayerState.field_0x3[1] == 0) {
DeleteThisEntity();
}
if ((gPlayerState.sword_state & 1) != 0) {
tmp1 = gPlayerState.sword_state;
ptr = gUnk_081217D0;
} else {
DeleteThisEntity();
}
}
if (tmp1 != 0) {
GetNextFrame(super);
if (super->actionDelay != 0) {
super->actionDelay--;
tmp2 = 3;
if ((super->type2 == 0) && ((gPlayerState.field_0xac & 0x200) == 0)) {
tmp2 = 7;
}
if ((super->actionDelay & tmp2) == 0) {
this->unk_6c++;
}
} else {
if (this->unk_72 != 0) {
if (((gRoomTransition.frameCount & 0x1fU) == 0) &&
(effect = CreateFx(super, FX_SPARKLE, 0), effect != NULL)) {
effect->collisionLayer = super->collisionLayer;
}
} else {
EnqueueSFX(SFX_115);
effect = CreateFx(super, FX_BLUE_SPARKLE, 0);
if (effect != NULL) {
effect->collisionLayer = super->collisionLayer;
}
this->unk_72++;
}
}
super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3;
ptr2 = &ptr[super->animationState * 2];
super->x.HALF.HI = ptr2[0] + gPlayerEntity.x.HALF.HI;
super->y.HALF.HI = ptr[super->animationState * 2 + 1] + gPlayerEntity.y.HALF.HI;
super->z.HALF.HI = gPlayerEntity.z.HALF.HI;
super->collisionLayer = gPlayerEntity.collisionLayer;
switch (super->animationState) {
default:
super->y.HALF.HI -= this->unk_6c;
break;
case 0:
super->y.HALF.HI -= this->unk_6c;
break;
case 1:
super->x.HALF.HI += this->unk_6c;
break;
case 2:
super->y.HALF.HI += this->unk_6c;
break;
case 3:
super->x.HALF.HI -= this->unk_6c;
break;
}
if (--super->field_0xf == 0) {
super->field_0xf = 6;
super->direction ^= 0x10;
}
LinearMoveUpdate(super);
if ((super->type2 == 0) && ((gPlayerState.sword_state & 0x40) != 0)) {
super->flags &= ~ENT_PERSIST;
if (GetInventoryValue(ITEM_FOURSWORD) == 1) {
super->action++;
} else {
DeleteThisEntity();
}
}
} else {
DeleteThisEntity();
return;
}
}
void Object43_Action2(Object43Entity* this) {
sub_08079BD8(super);
super->action += 1;
super->spriteSettings.draw = 1;
super->animationState = gPlayerEntity.animationState;
super->spriteVramOffset = 0;
super->palette.b.b0 = 4;
super->spriteIndex = 0xaf;
InitializeAnimation(super, super->animationState >> 1);
}
void Object43_Action3(Object43Entity* this) {
sub_08079BD8(super);
GetNextFrame(super);
if (gPlayerState.sword_state != 0) {
if ((gRoomTransition.frameCount & 3U) == 0) {
u32 tmp = super->palette.b.b0;
tmp ^= 4;
super->palette.b.b0 = tmp;
}
} else {
DeleteThisEntity();
}
if ((super->frame & 1) != 0) {
super->action++;
}
}
void Object43_Action4(Object43Entity* this) {
GetNextFrame(super);
if ((super->frame & 0x80) != 0) {
DeleteThisEntity();
}
}
+168
View File
@@ -0,0 +1,168 @@
/**
* @file object61.c
* @ingroup Objects
*
* @brief Object61 object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "new_player.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[6];
/*0x6e*/ u16 unk_6e;
/*0x70*/ u8 unk_70[2];
/*0x72*/ u16 unk_72;
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
} Object61Entity;
void Object61_Init(Object61Entity*);
void Object61_Action1(Object61Entity*);
void Object61_Action1Type0(Object61Entity*);
void Object61_Action1Type1(Object61Entity*);
void sub_080936C8(Object61Entity*);
void Object61(Object61Entity* this) {
static void (*const Object61_Actions[])(Object61Entity*) = {
Object61_Init,
Object61_Action1,
};
if ((gPlayerState.flags & PL_PARACHUTE) == 0) {
if (super->type == 0) {
gRoomControls.camera_target = &gPlayerEntity;
}
DeleteThisEntity();
}
Object61_Actions[super->action](this);
}
void Object61_Init(Object61Entity* this) {
super->action = 1;
super->lastFrameIndex = 0xff;
super->palette.b.b0 = gPlayerEntity.palette.b.b0;
if (super->type == 0) {
gRoomControls.camera_target = super;
super->spriteRendering.b0 = 3;
this->unk_6e = 0x180;
this->unk_72 = 0x180;
CreateObjectWithParent(super, OBJECT_61, 1, 0);
}
Object61_Action1(this);
}
void Object61_Action1(Object61Entity* this) {
static void (*const Object61_Action1Types[])(Object61Entity*) = {
Object61_Action1Type0,
Object61_Action1Type1,
};
Object61_Action1Types[super->type](this);
}
void Object61_Action1Type0(Object61Entity* this) {
u32 tmp;
if ((s16)this->unk_6e < 0) {
this->unk_6e = -this->unk_6e;
}
switch (gPlayerEntity.subAction) {
case 1:
this->unk_72 -= 4;
break;
case 2:
if (super->field_0xf == 0) {
if (this->unk_72 > 0x80) {
this->unk_72 -= 0x20;
} else {
super->field_0xf += 1;
SoundReq(SFX_124);
}
if (this->unk_6e < 0x120) {
this->unk_6e += 0x40;
}
} else if (super->field_0xf != 0xff) {
if (this->unk_72 < 0x100) {
this->unk_72 += 0x20;
} else {
this->unk_72 = 0x100;
}
if (this->unk_6e > 0x100) {
this->unk_6e -= 0x20;
} else {
this->unk_6e = 0x100;
}
if (this->unk_6e == 0x100) {
super->field_0xf = 0xff;
}
} else {
sub_080936C8(this);
}
break;
case 3:
default:
sub_080936C8(this);
break;
}
tmp = gPlayerEntity.animationState & 2;
if (tmp != 0) {
super->frameIndex = 1;
if (gPlayerEntity.animationState == 2) {
this->unk_6e = -this->unk_6e;
}
} else {
super->frameIndex = tmp;
}
if (super->frameIndex != super->lastFrameIndex) {
super->lastFrameIndex = super->frameIndex;
sub_080042D0(super, super->frameIndex, super->spriteIndex);
}
CopyPosition(&gPlayerEntity, super);
super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3;
sub_0806FCF4(super, this->unk_72, 10, 2);
sub_0805EC9C(super, this->unk_6e, this->unk_72, 0);
sub_0806FEBC(&gPlayerEntity, 1, super);
}
void Object61_Action1Type1(Object61Entity* this) {
super->frameIndex = ((gPlayerEntity.direction + (gPlayerEntity.direction >> 1)) >> 2) + 2;
if (super->frameIndex != super->lastFrameIndex) {
super->lastFrameIndex = super->frameIndex;
sub_080042D0(super, super->frameIndex, super->spriteIndex);
}
CopyPosition(&gPlayerEntity, super);
super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3;
sub_0806FCF4(super, ((Object61Entity*)super->parent)->unk_72, 0x18, 0);
super->spriteOffsetY = -super->spriteOffsetY;
sub_0806FEBC(&gPlayerEntity, 0, super);
}
void sub_080936C8(Object61Entity* this) {
s32 tmp = gNewPlayerEntity.unk_7c;
this->unk_76 = 0x138 - (gNewPlayerEntity.unk_7c >> 2);
this->unk_74 = 8 - (tmp / 0x3c);
if (super->actionDelay == 0) {
if (this->unk_76 < this->unk_6e) {
this->unk_6e -= 8;
this->unk_72 += 8;
} else {
super->actionDelay++;
this->unk_6e = this->unk_76;
this->unk_72 = this->unk_76 + 0x30;
}
} else {
if (this->unk_76 + 0x30 > this->unk_6e) {
this->unk_6e += 8;
this->unk_72 -= 8;
} else {
super->actionDelay = 0;
this->unk_6e = this->unk_76 + 0x30;
this->unk_72 = this->unk_76;
}
}
}
+126
View File
@@ -0,0 +1,126 @@
/**
* @file object68.c
* @ingroup Objects
*
* @brief Object68 object
* Handles effects of using water, mineral water or a fairy in a bottle in PlayerItemBottle_UseOther.
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68;
} Object68Entity;
extern u32 sub_0800029C(Entity*, s32, s32);
void sub_08094774(Object68Entity*);
void sub_080948D0(Object68Entity*);
void sub_080948E8(Object68Entity*);
void sub_08094980(Object68Entity*, u32, u32);
void Object68(Object68Entity* this) {
static void (*const gUnk_08122A10[])(Object68Entity*) = {
sub_08094774,
sub_080948D0,
};
gUnk_08122A10[super->action](this);
}
void sub_08094774(Object68Entity* this) {
static const s8 gUnk_08122A18[] = { 0, -8, 8, 1, 2, 8, -8, 1 };
Entity* effect;
Entity* child;
super->action = 1;
switch (super->type) {
case 0:
effect = CreateFx(super, FX_WATER_SPLASH, 0);
super->child = effect;
if (effect != NULL) {
PositionRelative(&gPlayerEntity, effect, gUnk_08122A18[gPlayerEntity.animationState & 6] << 0x10,
gUnk_08122A18[gPlayerEntity.animationState | 1] << 0x10);
}
CopyPosition(super->child, super);
sub_08094980(this, 0x4032, 0x4033);
sub_08094980(this, 0x4061, 0x4022);
break;
case 1:
effect = CreateFx(super, FX_GREEN_SPLASH2, 0);
super->child = effect;
if (effect != NULL) {
PositionRelative(&gPlayerEntity, effect, gUnk_08122A18[gPlayerEntity.animationState & 6] << 0x10,
gUnk_08122A18[gPlayerEntity.animationState | 1] << 0x10);
}
if (super->type2 == 0) {
CopyPosition(super->child, super);
super->actionDelay = 0;
super->spritePriority.b0 = 0;
super->spriteRendering.b3 = 0;
sub_08094980(this, 0x403b, 0x403c);
sub_08094980(this, 0x4061, 0x4022);
return;
}
break;
case 2:
child = sub_080A2A20(&gPlayerEntity, 0x60, 0);
super->child = child;
if (child != NULL) {
child->actionDelay = 1;
}
break;
case 3 ... 8:
break;
}
DeleteThisEntity();
}
void sub_080948D0(Object68Entity* this) {
static void (*const gUnk_08122A20[])(Object68Entity*) = {
NULL,
sub_080948E8,
};
gUnk_08122A20[super->type](this);
}
void sub_080948E8(Object68Entity* this) {
if (super->actionDelay < 0x3c) {
super->z.WORD -= 0x4000;
if ((super->actionDelay & 3) == 0) {
super->child = CreateFx(super, FX_DASH, 0x40);
if (super->child != NULL) {
super->child->spriteRendering.b3 = super->spriteRendering.b3;
super->child->spritePriority.b0 = super->spritePriority.b0;
if ((Random() & 1) != 0) {
super->child->x.HALF.HI += (Random() & 0xf);
} else {
super->child->x.HALF.HI -= (Random() & 0xf);
}
}
}
super->actionDelay++;
} else {
DeleteThisEntity();
}
}
void sub_08094980(Object68Entity* this, u32 searchTileIndex, u32 replaceTileIndex) {
static const s8 gUnk_08122A28[] = {
0, 0, -8, 0, 8, 0, 0, 8, 0, -8, 0, 0,
};
s32 xOffset;
s32 yOffset;
u32 index = 0;
while (index < 10) {
xOffset = gUnk_08122A28[index];
yOffset = gUnk_08122A28[index + 1];
if (searchTileIndex == sub_0800029C(super, xOffset, yOffset)) {
SetTile(replaceTileIndex, TILE(super->x.HALF.HI + xOffset, super->y.HALF.HI + yOffset),
super->collisionLayer);
}
index += 2;
}
}
+23
View File
@@ -0,0 +1,23 @@
/**
* @file object69.c
* @ingroup Objects
*
* @brief Object69 object
*/
#include "entity.h"
#include "hitbox.h"
#include "functions.h"
void Object69(Entity* this) {
if ((this->flags & ENT_SCRIPTED) != 0) {
if (this->action == 0) {
this->action = 1;
this->hitbox = (Hitbox*)&gHitbox_2;
sub_0807DD50(this);
} else {
sub_0807DD94(this, NULL);
}
} else {
this->action = 1;
}
}
+2 -3
View File
@@ -5,8 +5,7 @@
#include "object.h"
#include "functions.h"
#include "game.h"
extern Hitbox gHitbox_2;
#include "hitbox.h"
extern u8 gUpdateVisibleTiles;
@@ -15,7 +14,7 @@ void ObjectA(Entity* this) {
if (this->action == 0) {
this->action = 1;
this->hitbox = &gHitbox_2;
this->hitbox = (Hitbox*)&gHitbox_2;
if (this->collisionLayer == 1) {
uVar2 = 0x26;
} else {
+1 -2
View File
@@ -10,6 +10,7 @@
#include "object.h"
#include "functions.h"
#include "item.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -20,8 +21,6 @@ typedef struct {
/*0x87*/ u8 unk_87;
} ObjectA8Entity;
extern Hitbox gUnk_080FD1A8;
void sub_0809FECC(ObjectA8Entity*);
bool32 sub_0809FE9C(ObjectA8Entity*);
void ObjectA8_Init(ObjectA8Entity*);
+4
View File
@@ -0,0 +1,4 @@
#include "entity.h"
void ObjectBF(Entity* this) {
}
+127
View File
@@ -0,0 +1,127 @@
/**
* @file objectC1.c
* @ingroup Objects
*
* @brief ObjectC1 object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "message.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68;
/*0x69*/ u8 unk_69;
/*0x6a*/ u8 unk_6a;
/*0x6b*/ u8 unk_6b;
/*0x6c*/ u8 unk_6c;
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unk_6e;
/*0x6f*/ u8 unk_6f;
/*0x70*/ u32 unk_70;
/*0x74*/ u8 unk_74;
} ObjectC1Entity;
void ObjectC1_Init(ObjectC1Entity*);
void ObjectC1_Action1(ObjectC1Entity*);
void ObjectC1_Action8(ObjectC1Entity*);
void ObjectC1(ObjectC1Entity* this) {
static void (*const ObjectC1_Actions[])(ObjectC1Entity*) = {
ObjectC1_Init, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1,
ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action8, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1,
ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1,
ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1,
ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1, ObjectC1_Action1,
ObjectC1_Action1, ObjectC1_Action1,
};
ObjectC1_Actions[super->action](this);
}
void ObjectC1_Init(ObjectC1Entity* this) {
super->action = 8;
ObjectC1_Action8(this);
}
void ObjectC1_Action1(ObjectC1Entity* this) {
ResetPlayerEventPriority();
gUnk_02034490.unk0 = 0;
DeleteThisEntity();
}
void ObjectC1_Action8(ObjectC1Entity* this) {
u32 one;
u32 tmp;
Entity* parent;
u8* ptr;
gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.spriteSettings.draw = 0;
super->palette.b.b0 = gPlayerEntity.palette.b.b0;
switch (super->subAction) {
case 0:
one = 1;
super->subAction = one;
super->spriteSettings.draw = one;
super->collisionLayer = gPlayerEntity.collisionLayer;
super->spritePriority.b0 = gPlayerEntity.spritePriority.b0;
super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3;
super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
super->spriteSettings.flipX = 0;
super->animationState = 4;
SetDefaultPriority(super, 6);
if ((gPlayerState.flags & PL_NO_CAP) != 0) {
if (sub_080542AC(super->type)) {
tmp = 0x45e;
} else {
tmp = 0x45b;
}
} else {
if (sub_080542AC(super->type)) {
tmp = 0x2e0;
} else {
tmp = 0x1b9;
}
}
super->spriteIndex = (tmp >> 8);
InitAnimationForceUpdate(super, tmp & 0xff);
break;
case 1:
UpdateAnimationSingleFrame(super);
if (super->frame != 0) {
super->subAction++;
}
break;
case 2:
UpdateAnimationSingleFrame(super);
if ((gMessage.doTextBox & 0x7f) != 0) {
return;
}
if ((super->frame & 0x80) != 0) {
super->action = 1;
gPlayerEntity.flags = this->unk_69;
gPlayerEntity.spriteSettings.draw = this->unk_68;
gPlayerEntity.iframes = this->unk_6a;
gPlayerState.field_0x7 = this->unk_6b;
gPlayerState.keepFacing = this->unk_6c;
gPlayerState.field_0xa = this->unk_6d;
gPlayerState.field_0x27[0] = this->unk_6e;
gPlayerState.mobility = this->unk_6f;
gPlayerState.flags = this->unk_70;
gPlayerState.field_0x82[8] = this->unk_74;
}
break;
}
parent = super->parent;
if (parent != NULL) {
PositionEntityOnTop(super, parent);
ptr = GetSpriteSubEntryOffsetDataPointer((u16)super->spriteIndex, super->frameIndex);
parent->spriteOffsetX = *ptr;
parent->spriteOffsetY = ptr[1];
}
}
+1 -1
View File
@@ -9,6 +9,7 @@
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -29,7 +30,6 @@ typedef struct {
extern bool32 sub_080896B0(void); // pushableStatue
extern Hitbox gUnk_080FD1F4;
extern s16 gUnk_080B4488[];
typedef struct {
+3 -5
View File
@@ -6,6 +6,7 @@
#include "room.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
void sub_08082824(Entity*);
static void sub_08082850(Entity*, Entity*);
@@ -15,9 +16,6 @@ extern void (*const gUnk_0811F090[])(Entity*);
extern void (*const gUnk_0811F0A8[])(Entity*);
extern void (*const gUnk_0811F0C4[])(Entity*);
extern Hitbox gHitbox_18; // TODO: should be const
extern Hitbox gUnk_080FD340; // TODO: should be const
extern void sub_08078930(Entity*);
extern void sub_08016A6C(Entity*);
@@ -32,7 +30,7 @@ void sub_0808222C(Entity* this) {
}
this->action = 1;
this->hitbox = &gHitbox_18;
this->hitbox = (Hitbox*)&gHitbox_18;
this->speed = 0x80;
this->y.HALF.HI += 3;
this->field_0x16 = 0;
@@ -118,7 +116,7 @@ void sub_080824F8(Entity* this) {
void sub_08082510(Entity* this) {
COLLISION_ON(this);
this->hitbox = &gUnk_080FD340;
this->hitbox = (Hitbox*)&gUnk_080FD340;
this->field_0x3c = 7;
this->hitType = 1;
this->flags2 = gPlayerEntity.flags2;
+2 -5
View File
@@ -1,8 +1,7 @@
#define NENT_DEPRECATED
#include "object.h"
#include "functions.h"
u32 IsColliding(Entity*, Entity*);
#include "hitbox.h"
typedef struct {
Entity base;
@@ -22,8 +21,6 @@ PressurePlateAction sub_08088840;
PressurePlateAction sub_0808886C;
PressurePlateAction sub_080888F4;
extern Hitbox gUnk_080FD1D4;
static u32 sub_08088938(PressurePlateEntity*);
static u32 get_standing_count(PressurePlateEntity*);
@@ -50,7 +47,7 @@ void sub_08088840(PressurePlateEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
super->spritePriority.b0 = 7;
super->hitbox = &gUnk_080FD1D4;
super->hitbox = (Hitbox*)&gUnk_080FD1D4;
this->dir = super->animationState;
}
+3 -4
View File
@@ -10,6 +10,7 @@
#include "object.h"
#include "functions.h"
#include "sound.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -31,8 +32,6 @@ typedef struct {
enum PullableLeverPart { HANDLE, MIDDLE, SOCKET };
extern u16 gUnk_02021F00[];
extern Hitbox gUnk_080FD270;
extern Hitbox gUnk_080FD278;
extern void (*const PullableLever_HandleActions[])(PullableLeverEntity*);
extern void (*const PullableLever_MiddleActions[])(PullableLeverEntity*);
@@ -76,9 +75,9 @@ void PullableLever_HandleInit(PullableLeverEntity* this) {
super->spriteSettings.draw = 1;
super->speed = 0x60;
if ((super->type2 & 1)) {
super->hitbox = &gUnk_080FD278;
super->hitbox = (Hitbox*)&gUnk_080FD278;
} else {
super->hitbox = &gUnk_080FD270;
super->hitbox = (Hitbox*)&gUnk_080FD270;
}
super->field_0x16 = 1;
super->x.HALF.HI += PullableLever_InitialOffsets[super->type2 * 2];
+1 -1
View File
@@ -10,6 +10,7 @@
#include "object.h"
#include "functions.h"
#include "game.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -20,7 +21,6 @@ typedef struct {
/*0x7c*/ u32 unk_7c;
} PullableMushroomEntity;
extern const Hitbox gUnk_080FD224;
extern const u8 gUnk_08126EE4[];
void PullableMushroom_Init(PullableMushroomEntity*);
+1 -3
View File
@@ -9,6 +9,7 @@
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -26,9 +27,6 @@ typedef struct {
/*0x86*/ u16 pushedFlag;
} PushableGraveEntity;
extern const Hitbox gUnk_080FD578;
extern const Hitbox gUnk_080FD570;
extern void (*const gUnk_081232AC[])(PushableGraveEntity*);
extern const u8 gUnk_081232C0[];
extern const u16 PushableGrave_Tiles[];
+1 -1
View File
@@ -9,6 +9,7 @@
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -20,7 +21,6 @@ typedef struct {
/*0x86*/ u16 unk_86;
} PushableStatueEntity;
extern const Hitbox gUnk_080FD1F4;
extern const s16 gUnk_080B4488[];
extern const s16 gUnk_080B4468[];
+2 -3
View File
@@ -1,12 +1,11 @@
#include "object.h"
#include "functions.h"
#include "hitbox.h"
void sub_08086A6C(Entity*);
void (*const gUnk_081206C4[])(Entity*);
extern Hitbox gUnk_080FD1A8;
// Main
void Rupee(Entity* ent) {
gUnk_081206C4[ent->action](ent);
@@ -17,7 +16,7 @@ void sub_080869DC(Entity* ent) {
ent->action = 1;
ent->spriteSettings.draw = 0;
ent->hitbox = &gUnk_080FD1A8;
ent->hitbox = (Hitbox*)&gUnk_080FD1A8;
ent->field_0x3c |= 16;
itemEntity = CreateObject(GROUND_ITEM, ent->type, 0);
if (itemEntity != NULL) {
+1 -1
View File
@@ -9,6 +9,7 @@
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
@@ -20,7 +21,6 @@ typedef struct {
/*0x86*/ u16 unk_86;
} SmallIceBlockEntity;
extern const Hitbox gUnk_080FD408;
extern const s16 gUnk_080B4488[];
void sub_080996AC(SmallIceBlockEntity*);
+2 -3
View File
@@ -3,8 +3,7 @@
#include "coord.h"
#include "room.h"
#include "object.h"
extern Hitbox gHitbox_1;
#include "hitbox.h"
void TreeThorns(Entity* this) {
Entity* ent;
@@ -23,7 +22,7 @@ void TreeThorns(Entity* this) {
this->hurtType = 0x48;
this->hitType = 0x7a;
this->flags2 = 1;
this->hitbox = &gHitbox_1;
this->hitbox = (Hitbox*)&gHitbox_1;
tilePos = COORD_TO_TILE(this);
SetTile(0x4066, tilePos - 1, *layer);
SetTile(0x4065, tilePos, *layer);
+2 -3
View File
@@ -2,8 +2,7 @@
#include "object.h"
#include "game.h"
#include "functions.h"
extern Hitbox gHitbox_1;
#include "hitbox.h"
extern void sub_0807CAC8(u32);
extern u32 sub_0807CAEC(u32);
@@ -39,7 +38,7 @@ void sub_0808B474(Entity* this) {
tmp = gUnk_08121380[this->type];
this->palette.b.b0 = tmp;
this->spritePriority.b0 = 6;
this->hitbox = &gHitbox_1;
this->hitbox = (Hitbox*)&gHitbox_1;
this->updatePriority = PRIO_NO_BLOCK;
InitializeAnimation(this, 0);
if (CheckFlags(this->field_0x86.HWORD)) {
+99
View File
@@ -0,0 +1,99 @@
/**
* @file whirlwind.c
* @ingroup Objects
*
* @brief Whirlwind object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "area.h"
#include "hitbox.h"
void Whirlwind_Init(Entity*);
void Whirlwind_Action1(Entity*);
void Whirlwind_Action2(Entity*);
void Whirlwind(Entity* this) {
static void (*const Whirlwind_Actions[])(Entity*) = {
Whirlwind_Init,
Whirlwind_Action1,
Whirlwind_Action2,
};
u32 tmp = this->health;
if (((tmp & 0x7f) != 0) && (ReadBit(gArea.filler5, tmp - 1) == 0)) {
DeleteThisEntity();
}
Whirlwind_Actions[this->action](this);
}
void Whirlwind_Init(Entity* this) {
this->action = 1;
this->hitbox = (Hitbox*)&gUnk_080FD320;
this->flags |= ENT_COLLIDE;
this->hitType = 1;
this->field_0x3c = 0x47;
this->hurtType = 0x44;
this->flags2 = 0x80;
this->spriteOrientation.flipY = 1;
this->spriteRendering.b3 = 1;
this->animationState = this->type;
this->direction = this->type << 3;
this->speed = 0x700;
if (this->type2 == 1) {
ChangeObjPalette(this, 0x161);
InitializeAnimation(this, 1);
} else {
this->z.HALF.HI = 0xffe8;
InitializeAnimation(this, 1);
}
if ((this->flags & ENT_SCRIPTED) != 0) {
sub_0807DD64(this);
ExecuteScriptForEntity(this, NULL);
}
}
void Whirlwind_Action1(Entity* this) {
if ((this->flags & ENT_SCRIPTED) != 0) {
ExecuteScriptForEntity(this, NULL);
}
if (this->spriteSettings.draw != 0) {
GetNextFrame(this);
if ((((((gPlayerState.flags & PL_MINISH) == 0)) && (gPlayerState.field_0x3c[0] == 0)) &&
((gPlayerEntity.action == 4 || ((gPlayerEntity.flags & ENT_COLLIDE) != 0)))) &&
((gPlayerEntity.action != 6 && (sub_0800419C(this, &gPlayerEntity, 0xc, 0xc) != 0)))) {
if (((gPlayerState.flags & PL_PARACHUTE) == 0) && (gPlayerEntity.action != 4)) {
if ((this->type2 != 1) && (-0x10 < gPlayerEntity.z.HALF.HI)) {
return;
}
} else if (gPlayerEntity.z.HALF.HI == 0) {
return;
}
CopyPosition(this, &gPlayerEntity);
sub_08004542(this);
sub_08004542(&gPlayerEntity);
gPlayerEntity.collisionLayer = 1;
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerState.queued_action = 0x1f;
gPlayerState.field_0x38 = this->type2;
gPlayerState.field_0x39 = 0xff;
this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1;
this->action++;
sub_08077B20();
SoundReq(SFX_153);
SoundReq(SFX_PLY_VO5);
}
}
}
void Whirlwind_Action2(Entity* this) {
UpdateAnimationSingleFrame(this);
if (sub_0800419C(this, &gPlayerEntity, 0xc, 0xc) == 0) {
ResetCollisionLayer(this);
this->spriteOrientation.flipY = 1;
this->spriteRendering.b3 = 1;
this->action--;
}
}
+195
View File
@@ -0,0 +1,195 @@
/**
* @file windTribeTeleporter.c
* @ingroup Objects
*
* @brief WindTribeTeleporter object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68;
} WindTribeTeleporterEntity;
extern ScreenTransitionData gUnk_0813ADEC[];
void WindTribeTeleporter_Init(WindTribeTeleporterEntity*);
void WindTribeTeleporter_Action1(WindTribeTeleporterEntity*);
void WindTribeTeleporter_Action2(WindTribeTeleporterEntity*);
void WindTribeTeleporter_Action3(WindTribeTeleporterEntity*);
void sub_080A11E0(WindTribeTeleporterEntity*);
bool32 sub_080A11C0(WindTribeTeleporterEntity*);
void WindTribeTeleporter(WindTribeTeleporterEntity* this) {
static void (*const WindTribeTeleporter_Actions[])(WindTribeTeleporterEntity*) = {
WindTribeTeleporter_Init,
WindTribeTeleporter_Action1,
WindTribeTeleporter_Action2,
WindTribeTeleporter_Action3,
};
WindTribeTeleporter_Actions[super->action](this);
sub_080A11E0(this);
}
void WindTribeTeleporter_Init(WindTribeTeleporterEntity* this) {
super->action = 1;
super->frameDuration = 8;
super->spritePriority.b0 = 7;
super->hitbox = (Hitbox*)&gHitbox_22;
SetDefaultPriority(super, 6);
if (sub_080A11C0(this)) {
gPlayerEntity.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.y.HALF.HI = super->y.HALF.HI;
SetPlayerControl(CONTROL_DISABLED);
sub_08078B48();
SetPlayerEventPriority();
SoundReq(SFX_112);
super->action = 3;
super->subAction = 0;
this->unk_68 = 1;
}
}
void WindTribeTeleporter_Action1(WindTribeTeleporterEntity* this) {
if (sub_080A11C0(this)) {
if (this->unk_68 == 0) {
gPlayerEntity.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.y.HALF.HI = super->y.HALF.HI;
SetPlayerControl(CONTROL_DISABLED);
sub_08078B48();
SetPlayerEventPriority();
SoundReq(SFX_112);
super->action = 2;
super->subAction = 0;
}
} else {
this->unk_68 = 0;
}
}
void WindTribeTeleporter_Action2(WindTribeTeleporterEntity* this) {
switch (super->subAction) {
case 0:
super->actionDelay = 0x1e;
super->subAction++;
break;
case 1:
if (--super->actionDelay == 0) {
super->subAction++;
super->actionDelay = 0x1e;
}
break;
case 2:
if (--super->actionDelay == 0) {
super->subAction++;
super->actionDelay = 0x1e;
SoundReq(SFX_113);
} else {
if ((gRoomTransition.frameCount & 7) == 0) {
gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6;
}
}
break;
case 3:
if (--super->actionDelay == 0) {
super->subAction++;
super->actionDelay = 0x1e;
} else {
if ((gRoomTransition.frameCount & 3) == 0) {
gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6;
}
}
break;
default:
if (--super->actionDelay == 0) {
#if defined(DEMO_JP) || defined(JP) || defined(EU)
#ifdef DEMO_JP
SetLocalFlag(0xfc);
#endif
DoExitTransition(&gUnk_0813ADEC[super->type2]);
#else
if (gRoomControls.area == 3) {
SetLocalFlag(0xf9);
}
DoExitTransition(&gUnk_0813ADEC[super->type2]);
#endif
} else {
if ((gRoomTransition.frameCount & 1) == 0) {
gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6;
}
}
break;
}
}
void WindTribeTeleporter_Action3(WindTribeTeleporterEntity* this) {
switch (super->subAction) {
case 0:
super->subAction = 1;
super->actionDelay = 0x1e;
SoundReq(SFX_114);
break;
case 1:
if (--super->actionDelay != 0) {
if ((gRoomTransition.frameCount & 1) == 0) {
gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6;
}
} else {
super->subAction++;
super->actionDelay = 0x1e;
}
break;
case 2:
if (--super->actionDelay == 0) {
super->subAction++;
super->actionDelay = 0x1e;
} else {
if ((gRoomTransition.frameCount & 3) == 0) {
gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6;
}
}
break;
case 3:
if (--super->actionDelay == 0) {
super->subAction++;
} else {
if ((gRoomTransition.frameCount & 7) == 0) {
gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6;
}
}
break;
default:
if (gPlayerEntity.animationState != 4) {
if ((gRoomTransition.frameCount & 7U) != 0) {
return;
}
gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6;
} else {
super->action = 1;
super->subAction = 0;
gPlayerState.controlMode = 1;
ResetPlayerEventPriority();
}
break;
}
}
bool32 sub_080A11C0(WindTribeTeleporterEntity* this) {
if (gPlayerEntity.z.HALF.HI != 0) {
return FALSE;
} else {
return IsCollidingPlayer(super);
}
}
void sub_080A11E0(WindTribeTeleporterEntity* this) {
if (--super->frameDuration == 0) {
super->frameDuration = 8;
super->frameIndex = (super->frameIndex + 1) & 3;
}
}