Merge pull request #393 from octorock/objects

This commit is contained in:
notyourav
2022-02-18 13:47:12 -08:00
committed by GitHub
58 changed files with 2487 additions and 6572 deletions
+225
View File
@@ -0,0 +1,225 @@
/**
* @file bossDoor.c
* @ingroup Objects
*
* @brief Boss 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*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u8 unk_7e[6];
/*0x84*/ u16 unk_84;
/*0x86*/ u16 unk_86;
} BossDoorEntity;
extern Hitbox gHitbox_3;
extern bool32 gUnk_02036BB8;
extern const u8 gUnk_0811F740[];
void sub_0808C500(BossDoorEntity*);
void sub_0808C4BC(BossDoorEntity*);
void sub_0808C5D0(BossDoorEntity*);
void BossDoor_Init(BossDoorEntity*);
void BossDoor_Action1(BossDoorEntity*);
void BossDoor_Action2(BossDoorEntity*);
void BossDoor_Action3(BossDoorEntity*);
void BossDoor_Action4(BossDoorEntity*);
void BossDoor_Action5(BossDoorEntity*);
void BossDoor_Action6(BossDoorEntity*);
void BossDoor(BossDoorEntity* this) {
static void (*const BossDoor_Actions[])(BossDoorEntity*) = {
BossDoor_Init, BossDoor_Action1, BossDoor_Action2, BossDoor_Action3,
BossDoor_Action4, BossDoor_Action5, BossDoor_Action6,
};
BossDoor_Actions[super->action](this);
}
void BossDoor_Init(BossDoorEntity* this) {
if ((this->unk_84 != 0xffff) && CheckFlags(this->unk_84)) {
DeleteThisEntity();
}
if ((this->unk_86 != BEGIN) && CheckFlags(this->unk_86)) {
DeleteThisEntity();
}
super->type2 = super->type >> 2;
super->speed = 0x300;
this->unk_70 = super->x.HALF.HI;
this->unk_72 = super->y.HALF.HI;
super->hitbox = (Hitbox*)&gHitbox_3;
super->spritePriority.b0 = 5;
this->unk_76 = super->type & 3;
this->unk_74 = COORD_TO_TILE(super);
InitializeAnimation(super, super->type & 0x1f);
switch (super->type2) {
case 0:
super->action = 1;
super->spriteSettings.draw = 1;
sub_0808C500(this);
sub_08078800(super);
sub_08078850(super, 0, gUnk_0811F740[this->unk_76], 0);
break;
case 1:
super->action = 4;
super->spriteSettings.draw = 0;
break;
case 2:
super->action = 1;
super->spriteSettings.draw = 1;
sub_0808C500(this);
break;
}
}
void BossDoor_Action1(BossDoorEntity* this) {
if (super->interactType != 0) {
super->action = 2;
sub_080788E0(super);
SetFlag(this->unk_86);
}
}
void BossDoor_Action2(BossDoorEntity* this) {
if ((super->frame & 0x80) == 0) {
if ((gRoomTransition.frameCount & 3) == 0) {
SoundReq(SFX_185);
}
GetNextFrame(super);
} else {
sub_0808C4BC(this);
}
}
void BossDoor_Action3(BossDoorEntity* this) {
LinearMoveUpdate(super);
if (--super->actionDelay == 0) {
if (super->type < 4) {
sub_08078AC0(0x40, 0, 1);
gPlayerEntity.direction = super->type << 3;
}
DeleteThisEntity();
}
}
void BossDoor_Action4(BossDoorEntity* this) {
static const s8 gUnk_081214F4[] = { 0, -36, 36, 0, 0, 36, -36, 0 };
const s8* ptr;
if (sub_08083734(super, this->unk_76)) {
super->action = 5;
super->actionDelay = 0xc;
super->spriteSettings.draw = 1;
super->direction = *(u8*)&this->unk_76 << 3 ^ 0x10;
ptr = &gUnk_081214F4[this->unk_76 * 2];
super->x.HALF.HI += ptr[0];
super->y.HALF.HI += ptr[1];
sub_0808C500(this);
}
}
void BossDoor_Action5(BossDoorEntity* this) {
static const s8 gUnk_081214FC[] = { 12, 12, -12, 12, -12, 12, -12, -12, 12, -12, -12, -12, 12, 12, 12, -12 };
Entity* effect;
const s8* ptr;
LinearMoveUpdate(super);
if (--super->actionDelay == 0) {
super->action = 6;
super->z.HALF.HI = 0;
super->x.HALF.HI = this->unk_70;
super->y.HALF.HI = this->unk_72;
ptr = &gUnk_081214FC[this->unk_76 * 4];
effect = CreateFx(super, FX_DASH, 0x40);
if (effect != NULL) {
effect->x.HALF.HI += ptr[0];
effect->y.HALF.HI += ptr[1];
}
effect = CreateFx(super, FX_DASH, 0x40);
if (effect != NULL) {
effect->x.HALF.HI += ptr[2];
effect->y.HALF.HI += ptr[3];
}
EnqueueSFX(SFX_10B);
}
}
void BossDoor_Action6(BossDoorEntity* this) {
if (CheckFlags(this->unk_86)) {
super->action = 2;
}
}
void sub_0808C4BC(BossDoorEntity* this) {
static const s8 gUnk_0812150C[] = { 0, -2, 2, 0, 0, 2, -2, 0 };
const s8* ptr;
super->action = 3;
super->actionDelay = 0xc;
super->direction = this->unk_76 * 8;
ptr = &gUnk_0812150C[this->unk_76 * 2];
super->x.HALF.HI += ptr[0];
super->y.HALF.HI += ptr[1];
sub_0808C5D0(this);
SoundReq(SFX_10B);
}
void sub_0808C500(BossDoorEntity* this) {
if ((this->unk_76 == 0) || (this->unk_76 == 2)) {
this->unk_78 = GetTileIndex(this->unk_74 - 1, super->collisionLayer);
this->unk_7a = GetTileIndex(this->unk_74, super->collisionLayer);
this->unk_7c = GetTileIndex(this->unk_74 + 1, super->collisionLayer);
SetTile(0x4022, this->unk_74 - 1, super->collisionLayer);
SetTile(0x4022, this->unk_74, super->collisionLayer);
SetTile(0x4022, this->unk_74 + 1, super->collisionLayer);
} else {
this->unk_78 = GetTileIndex(this->unk_74 - 0x40, super->collisionLayer);
this->unk_7a = GetTileIndex(this->unk_74, super->collisionLayer);
this->unk_7c = GetTileIndex(this->unk_74 + 0x40, super->collisionLayer);
SetTile(0x4022, this->unk_74 - 0x40, super->collisionLayer);
SetTile(0x4022, this->unk_74, super->collisionLayer);
SetTile(0x4022, this->unk_74 + 0x40, super->collisionLayer);
}
}
void sub_0808C5D0(BossDoorEntity* this) {
if ((this->unk_76 == 0) || (this->unk_76 == 2)) {
SetTile(this->unk_78, this->unk_74 - 1, super->collisionLayer);
SetTile(this->unk_7a, this->unk_74, super->collisionLayer);
SetTile(this->unk_7c, this->unk_74 + 1, super->collisionLayer);
} else {
SetTile(this->unk_78, this->unk_74 - 0x40, super->collisionLayer);
SetTile(this->unk_7a, this->unk_74, super->collisionLayer);
SetTile(this->unk_7c, this->unk_74 + 0x40, super->collisionLayer);
}
}
void sub_0808C650(Entity* this, u32 param_2) {
Entity* obj = CreateObject(OBJECT_3A, 0, param_2);
if (obj != NULL) {
obj->parent = this;
gUnk_02036BB8 = FALSE;
} else {
gUnk_02036BB8 = TRUE;
}
}
bool32 sub_0808C67C(void) {
return gUnk_02036BB8;
}
void sub_0808C688(void) {
sub_0801E104();
gUnk_02036BB8 = TRUE;
}
+304 -18
View File
@@ -1,31 +1,317 @@
/**
* @file chestSpawner.c
* @ingroup Objects
*
* @brief Chest Spawner object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "entity.h"
#include "object.h"
#include "functions.h"
#include "screen.h"
#include "structures.h"
#include "item.h"
extern void sub_080842D8(Entity*);
extern void sub_08078828(Entity*);
extern void sub_08083E20(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[8];
/*0x70*/ u16 tilePosition;
/*0x72*/ u16 unk_72;
/*0x74*/ u8 unk_74[0x12];
/*0x86*/ u16 unk_86;
} ChestSpawnerEntity;
extern void (*const gUnk_0811F7E8[])(Entity*);
extern void (*const gUnk_0811F808[])(Entity*);
extern void (*const gUnk_0811F818[])(Entity*);
extern const Hitbox gUnk_0811F8A8;
extern const Hitbox gUnk_0811F8B0;
extern u32 gUnk_0811F8B0;
void ChestSpawner(Entity* this) {
gUnk_0811F7E8[this->type](this);
void sub_080842D8(ChestSpawnerEntity*);
void sub_08078828(ChestSpawnerEntity*);
void sub_08083E20(ChestSpawnerEntity*);
void sub_08084074(u32);
void sub_080840A8(s32, s32);
void ChestSpawner_Type0(ChestSpawnerEntity*);
void ChestSpawner_Type2(ChestSpawnerEntity*);
void ChestSpawner_Type0Init(ChestSpawnerEntity*);
void ChestSpawner_Type0Action1(ChestSpawnerEntity*);
void ChestSpawner_Type0Action2(ChestSpawnerEntity*);
void ChestSpawner_Type0Action3(ChestSpawnerEntity*);
void ChestSpawner_Type2Init(ChestSpawnerEntity*);
void ChestSpawner_Type2Action1(ChestSpawnerEntity*);
void ChestSpawner_Type2Action2(ChestSpawnerEntity*);
void ChestSpawner_Type2Action3(ChestSpawnerEntity*);
void ChestSpawner_Type2Action4(ChestSpawnerEntity*);
void ChestSpawner_Type2Action5(ChestSpawnerEntity*);
void ChestSpawner_Type2Action6(ChestSpawnerEntity*);
void ChestSpawner_Type2Action7(ChestSpawnerEntity*);
void ChestSpawner(ChestSpawnerEntity* this) {
static void (*const ChestSpawner_Types[])(ChestSpawnerEntity*) = {
ChestSpawner_Type0, ChestSpawner_Type0, ChestSpawner_Type2, ChestSpawner_Type2,
ChestSpawner_Type2, ChestSpawner_Type2, ChestSpawner_Type0, ChestSpawner_Type0,
};
ChestSpawner_Types[super->type](this);
}
void sub_08083DF0(Entity* this) {
gUnk_0811F808[this->action](this);
void ChestSpawner_Type0(ChestSpawnerEntity* this) {
static void (*const ChestSpawner_Type0Actions[])(ChestSpawnerEntity*) = {
ChestSpawner_Type0Init,
ChestSpawner_Type0Action1,
ChestSpawner_Type0Action2,
ChestSpawner_Type0Action3,
};
ChestSpawner_Type0Actions[super->action](this);
}
void sub_08083E08(Entity* this) {
gUnk_0811F818[this->action](this);
void ChestSpawner_Type2(ChestSpawnerEntity* this) {
static void (*const ChestSpawner_Type2Actions[])(ChestSpawnerEntity*) = {
ChestSpawner_Type2Init, ChestSpawner_Type2Action1, ChestSpawner_Type2Action2, ChestSpawner_Type2Action3,
ChestSpawner_Type2Action4, ChestSpawner_Type2Action5, ChestSpawner_Type2Action6, ChestSpawner_Type2Action7,
};
ChestSpawner_Type2Actions[super->action](this);
}
void sub_08083E20(Entity* this) {
this->action = 3;
this->spriteSettings.draw = 1;
this->spriteRendering.alphaBlend = 0;
void sub_08083E20(ChestSpawnerEntity* this) {
super->action = 3;
super->spriteSettings.draw = 1;
super->spriteRendering.alphaBlend = 0;
sub_080842D8(this);
sub_08078828(this);
}
void ChestSpawner_Type2Init(ChestSpawnerEntity* this) {
super->hitbox = (Hitbox*)&gUnk_0811F8B0;
if (CheckLocalFlag(super->type2)) {
super->spriteSettings.draw = 1;
super->action = 5;
sub_080842D8(this);
InitializeAnimation(super, 1);
} else {
if (CheckFlags(this->unk_86) || super->type == 4) {
sub_08083E20(this);
} else {
super->action = 1;
}
InitializeAnimation(super, 0);
}
}
void ChestSpawner_Type2Action1(ChestSpawnerEntity* this) {
if (CheckFlags(this->unk_86)) {
gScreen.controls.layerFXControl = 0xf40;
gScreen.controls.alphaBlend = 0x1000;
gUnk_02034490.unk0 = 1;
super->action = 2;
super->subAction = 0;
super->field_0xf = 0x1e;
super->spriteSettings.draw = 1;
super->spriteRendering.alphaBlend = 1;
RequestPriorityDuration(super, 0x1e);
sub_0805BC4C();
}
}
void ChestSpawner_Type2Action2(ChestSpawnerEntity* this) {
u32 tmp;
SetPriorityTimer(0x1e);
switch (super->subAction) {
case 0:
if (EntityInRectRadius(super, &gPlayerEntity, 0x10, 8)) {
sub_08078AC0(0x10, 0, 0);
gPlayerEntity.direction = 0x10;
}
super->subAction = 1;
break;
case 1:
if ((super->type == 5) || (gPlayerEntity.action == 1)) {
super->subAction = 2;
super->actionDelay = 8;
super->field_0xf = 0;
SoundReq(SFX_14A);
}
break;
default:
sub_0800445C(super);
CreateMagicSparkles(super->x.HALF.HI, super->y.HALF.HI, 2);
if (--super->actionDelay == 0) {
super->actionDelay = 8;
tmp = ++super->field_0xf;
gScreen.controls.alphaBlend = (((0x10 - tmp) * 0x100) & 0xff00) | tmp;
if (gScreen.controls.alphaBlend == 0x10) {
gUnk_02034490.unk0 = 0;
gScreen.controls.layerFXControl = 0;
sub_08083E20(this);
SoundReq(SFX_SECRET_BIG);
}
}
break;
}
}
void ChestSpawner_Type2Action3(ChestSpawnerEntity* this) {
sub_0800445C(super);
if (super->interactType != 0) {
super->action = 4;
super->field_0xf = 0x1e;
sub_080788E0(super);
RequestPriorityDuration(super, 0x3c);
SoundReq(SFX_CHEST_OPEN);
}
}
void ChestSpawner_Type2Action4(ChestSpawnerEntity* this) {
sub_0800445C(super);
GetNextFrame(super);
if ((super->frame & 0x80) != 0) {
if (--super->field_0xf == 0) {
if (super->actionDelay == 0x18) {
super->action = 6;
super->actionDelay = 8;
super->field_0xf = 0x10;
} else {
super->action = 5;
sub_08084074(super->type2);
}
}
SetLocalFlag(super->type2);
}
}
void sub_08084074(u32 param_1) {
u8* arr = (u8*)GetCurrentRoomProperty(3);
if (arr != NULL) {
for (; arr[0] != 0; arr += 8) {
if ((arr[0] == 3) && (param_1 == arr[1])) {
CreateItemEntity(arr[2], arr[3], 0);
return;
}
}
}
}
void sub_080840A8(s32 param_1, s32 param_2) {
static const u8 gUnk_0811F838[] = { 84, 84, 84, 84, 85, 85, 85, 86 };
static const s32 gUnk_0811F840[] = { 393216, 458752, 524288, 589824 };
static const s8 gUnk_0811F850[] = { -6, 0, 0, 6 };
Entity* obj = CreateObject(GROUND_ITEM, gUnk_0811F838[Random() & 7], 0);
if (obj != NULL) {
obj->actionDelay = 6;
obj->direction = ((Random() & 7) + 0xc) | 0x80;
obj->speed = (Random() & 0xf) * 2 + 0x20;
obj->zVelocity = gUnk_0811F840[Random() & 3];
obj->x.HALF.HI = gUnk_0811F850[Random() & 3] + param_1;
obj->y.HALF.HI = param_2 + 1;
obj->z.HALF.HI = 0xfff8;
ResolveCollisionLayer(obj);
obj = CreateFx(obj, FX_DASH, 0);
if (obj != NULL) {
SoundReq(SFX_124);
}
}
}
void ChestSpawner_Type2Action6(ChestSpawnerEntity* this) {
if (--super->actionDelay == 0) {
super->actionDelay = 8;
if (--super->field_0xf != 0) {
sub_080840A8(super->x.HALF.HI, super->y.HALF.HI);
} else {
super->action = 5;
}
}
}
void ChestSpawner_Type2Action5(ChestSpawnerEntity* this) {
sub_0800445C(super);
}
void ChestSpawner_Type2Action7(ChestSpawnerEntity* this) {
}
void ChestSpawner_Type0Init(ChestSpawnerEntity* this) {
super->action++;
this->tilePosition = COORD_TO_TILE(super);
super->hitbox = (Hitbox*)&gUnk_0811F8A8;
if (GetTileTypeByEntity(super) == 0x74) {
DeleteThisEntity();
}
if (CheckFlags(this->unk_86)) {
super->action = 3;
sub_0807B7D8(0x73, this->tilePosition, super->collisionLayer);
if ((super->type & 1) == 0) {
DeleteThisEntity();
}
}
}
void ChestSpawner_Type0Action1(ChestSpawnerEntity* this) {
if (CheckFlags(this->unk_86)) {
super->action = 2;
}
}
void ChestSpawner_Type0Action2(ChestSpawnerEntity* this) {
sub_0807B7D8(0x73, this->tilePosition, super->collisionLayer);
switch (super->type) {
case 6:
case 7:
SoundReq(SFX_215);
break;
default:
SoundReq(SFX_SECRET);
CreateDust(super);
break;
}
super->action = 3;
this->unk_72 = super->actionDelay * 0x3c;
if ((super->type & 1) == 0) {
DeleteThisEntity();
}
}
void ChestSpawner_Type0Action3(ChestSpawnerEntity* this) {
if ((super->type == 1) || (super->type == 7)) {
if (GetTileTypeByEntity(super) == 0x74) {
DeleteEntity(super);
} else {
if (!CheckFlags(this->unk_86)) {
if (this->unk_72 != 0) {
this->unk_72--;
} else {
super->action = 1;
sub_0807BA8C(this->tilePosition, super->collisionLayer);
CreateDust(super);
}
}
}
}
}
void sub_080842D8(ChestSpawnerEntity* this) {
static const u8 gUnk_0811F854[] = {
35, 64, 191, 255, 35, 64, 192, 255, 38, 64, 255, 255, 38, 64, 0, 0, 255, 255,
};
static const u8 gUnk_0811F866[] = {
39, 64, 191, 255, 35, 64, 192, 255, 40, 64, 193, 255, 41, 64, 255, 255, 38, 64, 0, 0, 42, 64, 1, 0, 255, 255,
};
static const u8 gUnk_0811F880[] = {
34, 64, 255, 255, 34, 64, 0, 0, 255, 255,
};
static const u8 gUnk_0811F88A[] = {
36, 64, 255, 255, 34, 64, 0, 0, 37, 64, 1, 0, 255, 255,
};
static const u8* const gUnk_0811F898[] = {
gUnk_0811F854,
gUnk_0811F866,
gUnk_0811F880,
gUnk_0811F88A,
};
s32 index = -(-(super->x.HALF.HI & 8) >> 0x1f);
if ((super->y.HALF.HI & 8) != 0) {
index += 2;
}
sub_0801AF18((u8*)gUnk_0811F898[index], COORD_TO_TILE(super), super->collisionLayer);
}
const Hitbox gUnk_0811F8A8 = { 0, -3, { 0, 0, 0, 0 }, 6, 6 };
const Hitbox gUnk_0811F8B0 = { 0, -3, { 0, 0, 0, 0 }, 12, 6 };
+215
View File
@@ -0,0 +1,215 @@
/**
* @file doubleBookshelf.c
* @ingroup Objects
*
* @brief Double Bookshelf object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x18];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
/*0x84*/ u8 unk_84;
/*0x85*/ u8 unk_85;
/*0x86*/ u16 unk_86;
} DoubleBookshelfEntity;
void sub_0809B334(DoubleBookshelfEntity*);
void sub_0809B0B0(DoubleBookshelfEntity*);
void sub_0809B234(DoubleBookshelfEntity*);
void sub_0809B274(DoubleBookshelfEntity*);
void sub_0809B358(DoubleBookshelfEntity*);
void sub_0809B38C(DoubleBookshelfEntity*);
void DoubleBookshelf_Init(DoubleBookshelfEntity*);
void DoubleBookshelf_Action1(DoubleBookshelfEntity*);
void DoubleBookshelf_Action2(DoubleBookshelfEntity*);
void DoubleBookshelf_Action3(DoubleBookshelfEntity*);
void DoubleBookshelf(DoubleBookshelfEntity* this) {
static void (*const DoubleBookshelf_Actions[])(DoubleBookshelfEntity*) = {
DoubleBookshelf_Init,
DoubleBookshelf_Action1,
DoubleBookshelf_Action2,
DoubleBookshelf_Action3,
};
DoubleBookshelf_Actions[super->action](this);
}
void DoubleBookshelf_Init(DoubleBookshelfEntity* this) {
DoubleBookshelfEntity* child;
super->frameIndex = super->type;
this->unk_80 = COORD_TO_TILE(super);
if (super->type != 0) {
super->action = 1;
if (this->unk_84 == 0) {
super->subAction = 0;
} else {
super->subAction = 1;
}
} else {
super->action = 3;
super->subAction = 4;
this->unk_84 = 0;
UpdateSpriteForCollisionLayer(super);
child = (DoubleBookshelfEntity*)CreateObject(DOUBLE_BOOKSHELF, 1, 0);
if (child != NULL) {
(child->base).parent = super;
super->child = &child->base;
if (CheckFlags(this->unk_86) == 0) {
PositionRelative(super, &child->base, 0x100000, 0x100000);
child->unk_84 = 0;
} else {
PositionRelative(super, &child->base, 0, 0x100000);
child->unk_84 = 1;
}
}
sub_0809B334(this);
}
sub_0809B0B0(this);
}
void DoubleBookshelf_Action1(DoubleBookshelfEntity* this) {
GetTileType(this->unk_82, super->collisionLayer);
sub_0809B234(this);
}
void DoubleBookshelf_Action2(DoubleBookshelfEntity* this) {
LinearMoveUpdate(super);
if (--super->actionDelay == 0) {
super->action = 1;
this->unk_80 = COORD_TO_TILE(super);
SetPlayerControl(CONTROL_ENABLED);
sub_0809B0B0(this);
EnqueueSFX(SFX_BUTTON_PRESS);
}
}
void DoubleBookshelf_Action3(DoubleBookshelfEntity* this) {
sub_0809B234(this);
}
void sub_0809B0B0(DoubleBookshelfEntity* this) {
u32 position = this->unk_80 - 1;
u32 layer = super->collisionLayer;
switch (super->subAction) {
case 0:
this->unk_84 = 0;
this->unk_82 = position + 2;
SetTile(0x4082, position - 1, layer);
SetTile(0x4022, position, layer);
SetTile(0x4022, position + 1, layer);
SetTile(0x4022, position + 2, layer);
break;
case 1:
this->unk_84 = 1;
this->unk_82 = position;
SetTile(0x405f, position, layer);
SetTile(0x4022, position + 1, layer);
SetTile(0x4022, position + 2, layer);
SetTile(0x4082, position + 3, layer);
break;
case 2:
this->unk_84 = 1;
this->unk_82 = position;
SetTile(0x4082, position + 3, layer);
SetTile(0x4022, position + 2, layer);
SetTile(0x405f, position, layer);
SetFlag(((DoubleBookshelfEntity*)super->parent)->unk_86);
break;
case 3:
this->unk_84 = 0;
this->unk_82 = position + 2;
SetTile(0x4082, position - 1, layer);
SetTile(0x4022, position, layer);
SetTile(0x405f, position + 2, layer);
ClearFlag(((DoubleBookshelfEntity*)super->parent)->unk_86);
break;
case 4:
SetTile(0x4022, position, layer);
SetTile(0x4022, position + 1, layer);
SetTile(0x4022, position + 2, layer);
break;
}
}
void sub_0809B234(DoubleBookshelfEntity* this) {
if (super->type != 0) {
super->spriteRendering.b3 = super->parent->spriteRendering.b3;
super->spritePriority.b0 = super->parent->spritePriority.b0;
} else {
sub_0809B274(this);
}
}
void sub_0809B274(DoubleBookshelfEntity* this) {
Entity* player = &gPlayerEntity;
switch (this->unk_84) {
case 0:
if (player->y.HALF.HI + 0x14 >= super->y.HALF.HI) {
return;
}
this->unk_84 = 1;
super->spritePriority.b0 = 5;
break;
case 1:
if (player->x.HALF.HI + 0x1c > super->x.HALF.HI) {
this->unk_84 = 2;
SetTile(0x4022, this->unk_80 + 2, 1);
sub_0809B358((DoubleBookshelfEntity*)super->child);
return;
}
if (player->y.HALF.HI + 0x10 <= super->y.HALF.HI) {
return;
}
this->unk_84 = 0;
super->spritePriority.b0 = 4;
break;
case 2:
if (player->x.HALF.HI + 0x20 >= super->x.HALF.HI) {
return;
}
this->unk_84 = 1;
sub_0807BA8C(this->unk_80 + 2, 1);
sub_0809B38C((DoubleBookshelfEntity*)super->child);
return;
}
}
void sub_0809B334(DoubleBookshelfEntity* this) {
s32 index;
u32 position = this->unk_80 - 0x81;
for (index = 2; index >= 0; index--, position++) {
SetTile(0x4026, position, 1);
}
}
void sub_0809B358(DoubleBookshelfEntity* this) {
static const u16 gUnk_08123D68[] = {
0x4022, 0x4022, 0x4074, 0x4026, 0x4074, 0x4074, 0x4026, 0x4074, 0x4022, 0x4022
};
s32 index;
const u16* array = &gUnk_08123D68[this->unk_84];
u32 position = this->unk_80 - 0x82;
for (index = 4; index >= 0;) {
SetTile(*array, position, 1);
index--;
position++;
array += 2;
}
}
void sub_0809B38C(DoubleBookshelfEntity* this) {
s32 index;
u32 uVar1 = this->unk_80 - 0x82;
for (index = 4; index >= 0;) {
sub_0807BA8C(uVar1, 1);
index--;
uVar1++;
}
}
+259
View File
@@ -0,0 +1,259 @@
/**
* @file fairy.c
* @ingroup Objects
*
* @brief Fairy 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[0xc];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u16 unk_78;
/*0x7a*/ u8 unk_7a[0xd];
/*0x87*/ u8 unk_87;
} FairyEntity;
extern Hitbox gUnk_080FD1A8;
void sub_0808D76C(FairyEntity*);
void sub_0808DAD0(FairyEntity*);
void sub_0808DB2C(FairyEntity*);
bool32 sub_0808DAA0(FairyEntity*);
void Fairy_Init(FairyEntity*);
void Fairy_Action1(FairyEntity*);
void Fairy_Action2(FairyEntity*);
void Fairy_Action3(FairyEntity*);
void Fairy_Action4(FairyEntity*);
void Fairy_SubAction0(FairyEntity*);
void Fairy_SubAction1(FairyEntity*);
void Fairy_SubAction2(FairyEntity*);
void Fairy(FairyEntity* this) {
static void (*const Fairy_Actions[])(FairyEntity*) = {
Fairy_Init, Fairy_Action1, Fairy_Action2, Fairy_Action3, Fairy_Action4,
};
if (((super->bitfield & 0x80) != 0)) {
switch (super->bitfield & 0x7f) {
case 0x14:
super->action = 3;
super->flags &= ~ENT_COLLIDE;
super->spriteSettings.draw = 1;
super->child = super->field_0x4c;
break;
case 0x1f:
DeleteThisEntity();
case 0:
case 1:
case 4:
case 5:
case 6:
case 8:
case 9:
case 10:
case 0xb:
case 0xc:
case 0x1e:
sub_0808DAD0(this);
break;
case 0x13:
sub_0808D76C(this);
return;
}
}
Fairy_Actions[super->action](this);
sub_08080CB4(super);
}
void sub_0808D76C(FairyEntity* this) {
static void (*const Fairy_SubActions[])(FairyEntity*) = {
Fairy_SubAction0,
Fairy_SubAction1,
Fairy_SubAction2,
};
Fairy_SubActions[super->subAction](this);
}
void Fairy_SubAction0(FairyEntity* this) {
super->subAction = 1;
super->field_0x1d = 1;
super->spriteSettings.draw = 1;
}
void Fairy_SubAction1(FairyEntity* this) {
sub_0806F4E8(super);
}
void Fairy_SubAction2(FairyEntity* this) {
if (sub_0806F3E4(super)) {
sub_0808DB2C(this);
}
}
void Fairy_Init(FairyEntity* this) {
super->collisionLayer = 3;
super->field_0x3c = 0x17;
super->hurtType = 0x49;
super->hitType = 7;
super->flags2 = 0x17;
super->health = 0xff;
super->hitbox = (Hitbox*)&gUnk_080FD1A8;
super->field_0x1c = 1;
this->unk_74 = super->x.HALF.HI;
this->unk_76 = super->y.HALF.HI;
SetDefaultPriority(super, 6);
EnqueueSFX(SFX_136);
switch (super->type2) {
case 0:
super->zVelocity = 0x1e000;
super->z.HALF.HI += 8;
// fallthrough
default:
super->action = 1;
break;
case 2:
sub_0808DAD0(this);
break;
case 3:
sub_0808DB2C(this);
break;
}
}
void Fairy_Action1(FairyEntity* this) {
super->z.WORD -= 0xe000;
if (super->frame != 0) {
if (super->actionDelay != 0) {
this->unk_78 *= 0x1e;
} else {
this->unk_78 = 600;
}
super->action = 2;
super->field_0xf = 1;
super->speed = 0x80;
}
}
void Fairy_Action2(FairyEntity* this) {
static const u8 gUnk_081217A4[] = {
128,
96,
0,
0,
};
if (--super->field_0xf == 0) {
u32 rand = Random();
super->flags |= ENT_COLLIDE;
super->field_0xf = 0x20;
super->speed = (u16)gUnk_081217A4[rand >> 8 & 1];
if (sub_0808DAA0(this)) {
super->direction = rand & 0x1f;
} else {
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_74, this->unk_76);
}
if ((super->direction & 0xf) != 0) {
super->spriteSettings.flipX = ((super->direction ^ 0x10) >> 4);
}
}
ProcessMovement1(super);
if ((AnyPrioritySet() == 0) && (super->type2 == 0)) {
if (--this->unk_78 == 0) {
sub_08081404(super, 0);
}
if (this->unk_78 < 0x78) {
super->spriteSettings.draw ^= 1;
}
}
}
void Fairy_Action3(FairyEntity* this) {
if (*(u16*)&super->child->kind != 0x308) {
sub_08081404(super, 0);
} else {
CopyPosition(super->child, super);
super->z.HALF.HI--;
if (IsColliding(super, &gPlayerEntity)) {
sub_0808DB2C(this);
}
}
}
void Fairy_Action4(FairyEntity* this) {
Entity* child;
s32 tmp;
child = super->child;
tmp = gSineTable[super->actionDelay] * 0xa00;
if (tmp < 0) {
tmp += 0xffff;
}
super->x.HALF.HI = (tmp >> 0x10) + child->x.HALF.HI;
tmp = gSineTable[super->actionDelay + 0x40] * 0x500;
if (tmp < 0) {
tmp += 0xffff;
}
super->y.HALF.HI = child->y.HALF.HI - (tmp >> 0x10);
super->actionDelay += 8;
super->z.HALF.HI = child->z.HALF.HI;
super->spriteOrientation.flipY = child->spriteOrientation.flipY;
super->spriteRendering.b3 = child->spriteRendering.b3;
if ((u8)(super->actionDelay - 0x41) < 0x7f) {
super->spritePriority.b0 = 3;
} else {
super->spritePriority.b0 = 5;
}
if (--super->field_0xf == 0) {
super->field_0xf = 6;
if (((--super->spriteOffsetY) * 0x1000000) >> 0x18 < -0x16) {
sub_08081404(super, 1);
}
}
if (super->spriteOffsetY < -0x11) {
super->spriteSettings.draw ^= 1;
}
if (this->unk_87 > 10) {
this->unk_87 = 10;
}
}
bool32 sub_0808DAA0(FairyEntity* this) {
if (((super->x.HALF.HI - (u32)this->unk_74) + 0x30 < 0x61) &&
((super->y.HALF.HI - (u32)this->unk_76) + 0x30 < 0x61)) {
return TRUE;
} else {
return FALSE;
}
}
void sub_0808DAD0(FairyEntity* this) {
if (super->health == 0) {
DeleteThisEntity();
}
super->action = 4;
super->actionDelay = 0x80;
super->field_0xf = 6;
super->flags &= ~ENT_COLLIDE;
super->spriteSettings.draw = 1;
super->spritePriority.b1 = 2;
super->spriteOffsetY = -5;
super->child = &gPlayerEntity;
CopyPosition(&gPlayerEntity, super);
}
void sub_0808DB2C(FairyEntity* this) {
super->action = 2;
super->subAction = 0;
super->flags |= ENT_COLLIDE;
super->flags2 = 1;
CopyPosition(&gPlayerEntity, super);
}
-3
View File
@@ -28,9 +28,6 @@ static bool32 sub_080867CC(u32);
void sub_0808681C(Entity*);
static u8 sub_08086954(Entity*);
extern u32 CheckRegionOnScreen(u32, u32, u32, u32);
extern void sub_08078AC0(u32, u32, u32);
extern void (*const gUnk_081206B4[])(Entity*);
extern Hitbox gUnk_081206AC; // TODO: should be const
-3
View File
@@ -19,9 +19,6 @@ void sub_080813BC(Entity*);
void sub_080810FC(Entity*);
bool32 CheckShouldPlayItemGetCutscene(Entity*);
extern u32 IsColliding(Entity*, Entity*);
extern void GiveItem(u32, u32);
extern void (*const gUnk_0811E7D4[])(Entity*);
extern void (*const gUnk_0811E7E8[])(Entity*);
extern void (*const gUnk_0811E814[])(Entity*);
-1
View File
@@ -5,7 +5,6 @@
extern void (*gUnk_08121488[])(Entity*);
extern u32 sub_08057810(void);
extern void CreateMagicSparkles(u32, u32, u32);
u32 sub_0808C128(Entity*);
void sub_0808C13C(Entity*);
+307
View File
@@ -0,0 +1,307 @@
/**
* @file lavaPlatform.c
* @ingroup Objects
*
* @brief Lava Platform 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 timer;
/*0x72*/ u16 wobbleTime; /**< Time the player can stand on the platform. */
/*0x74*/ u16 respawnTime; /**< Time until the platform respawns after it has sunk. */
/*0x76*/ u16 unk_76;
/*0x78*/ Entity* unk_78; // Typed same as second argument of sub_080A2CC0
} LavaPlatformEntity;
typedef struct {
/*0x00*/ Entity* unk_78; // Typed same as second argument of sub_080A2CC0
/*0x04*/ s16 x;
/*0x06*/ s16 y;
/*0x08*/ u8 collisionLayer;
/*0x09*/ u8 type2;
/*0x0a*/ u16 wobbleTime;
/*0x0c*/ u16 respawnTime;
/*0x0e*/ u8 unk_e[2];
} LavaPlatformEntry;
extern void sub_080A2CC0(Entity*, Entity**, u16*);
extern Hitbox gUnk_080FD280;
void sub_08092278(LavaPlatformEntity*);
void sub_08092344(LavaPlatformEntity*);
void LavaPlatform_SpawnPlatforms(LavaPlatformEntity*);
void sub_080926E4(LavaPlatformEntity*);
void sub_0809264C(LavaPlatformEntity*);
void sub_08092620(LavaPlatformEntity*);
bool32 LavaPlatform_IsPlayerOnPlatform(LavaPlatformEntity*);
void LavaPlatform_Type0Init(LavaPlatformEntity*);
void LavaPlatform_Type0Action1(LavaPlatformEntity*);
void LavaPlatform_Type0Action2(LavaPlatformEntity*);
void LavaPlatform_Type1Init(LavaPlatformEntity*);
void LavaPlatform_Type1Action1(LavaPlatformEntity*);
void LavaPlatform_Type1Action2(LavaPlatformEntity*);
void LavaPlatform_Type1Action3(LavaPlatformEntity*);
void LavaPlatform_Type1Action4(LavaPlatformEntity*);
void LavaPlatform_Type1Action5(LavaPlatformEntity*);
void LavaPlatform_Type1Action6(LavaPlatformEntity*);
void LavaPlatform_Type1Action7(LavaPlatformEntity*);
void LavaPlatform(LavaPlatformEntity* this) {
if (super->type == 0) {
sub_08092278(this);
} else {
sub_08092344(this);
}
}
void sub_08092278(LavaPlatformEntity* this) {
static void (*const LavaPlatform_Type0Actions[])(LavaPlatformEntity*) = {
LavaPlatform_Type0Init,
LavaPlatform_Type0Action1,
LavaPlatform_Type0Action2,
};
LavaPlatform_Type0Actions[super->action](this);
}
void LavaPlatform_Type0Init(LavaPlatformEntity* this) {
super->action = 1;
LavaPlatform_SpawnPlatforms(this);
}
void LavaPlatform_Type0Action1(LavaPlatformEntity* this) {
if (*(u8*)&this->timer != 0) {
// Use this entity to show the platform flipping animation.
super->action = 2;
super->zVelocity = 0x2c000;
super->spriteSettings.draw = 1;
UpdateSpriteForCollisionLayer(super);
InitAnimationForceUpdate(super, (super->child)->animationState);
EnqueueSFX(SFX_LAVA_TILE_FLIP);
InitializeAnimation(super->child, 3);
}
}
void LavaPlatform_Type0Action2(LavaPlatformEntity* this) {
if (GravityUpdate(super, 0x2400) == 0) {
// Finished flipping platform.
super->action = 1;
super->spriteSettings.draw = 0;
*(u8*)&this->timer = 0;
(super->child)->spriteOffsetY = 0;
InitializeAnimation(super->child, super->child->animationState);
CreateFx(super, FX_LAVA_SPLASH_HUGE, 0);
} else if ((super->zVelocity < 0x18000) && ((super->frame & 0x80) == 0)) {
UpdateAnimationSingleFrame(super);
}
}
void sub_08092344(LavaPlatformEntity* this) {
static void (*const LavaPlatform_Type1Actions[])(LavaPlatformEntity*) = {
LavaPlatform_Type1Init, LavaPlatform_Type1Action1, LavaPlatform_Type1Action2, LavaPlatform_Type1Action3,
LavaPlatform_Type1Action4, LavaPlatform_Type1Action5, LavaPlatform_Type1Action6, LavaPlatform_Type1Action7,
};
super->field_0xf = 0;
LavaPlatform_Type1Actions[super->action](this);
sub_080926E4(this);
}
void LavaPlatform_Type1Init(LavaPlatformEntity* this) {
super->animationState = super->type2;
super->spritePriority.b0 = 7;
super->hurtType = 0x48;
super->field_0x3c = 7;
super->flags2 = 0x81;
super->hitbox = (Hitbox*)&gUnk_080FD280;
sub_0809264C(this);
}
void LavaPlatform_Type1Action1(LavaPlatformEntity* this) {
if (super->animIndex != 3) {
if (super->subAction == 0) {
super->subAction = 1;
super->animationState ^= 1;
InitializeAnimation(super, (u32)super->animationState);
}
if (--super->spriteOffsetY * 0x1000000 >> 0x18 == -3) {
sub_0809264C(this);
}
}
}
void LavaPlatform_Type1Action2(LavaPlatformEntity* this) {
if (super->bitfield == 0x9d) {
sub_08092620(this);
} else {
if (LavaPlatform_IsPlayerOnPlatform(this)) {
super->action = 3;
super->flags &= ~ENT_COLLIDE;
super->actionDelay = 0x14;
gPlayerState.field_0x3f = 0xfd;
}
}
}
/** Player is standing on the platform. */
void LavaPlatform_Type1Action3(LavaPlatformEntity* this) {
if (LavaPlatform_IsPlayerOnPlatform(this)) {
gPlayerState.field_0x3f = 0xfd;
}
if (--super->actionDelay == 0) {
super->action = 4;
this->timer = this->wobbleTime;
super->spriteOffsetY = 0;
InitializeAnimation(super, 2);
EnqueueSFX(SFX_LAVA_TILE_STEP);
}
}
/** Platform begins to wobble */
void LavaPlatform_Type1Action4(LavaPlatformEntity* this) {
u32 tmp;
LavaPlatform_IsPlayerOnPlatform(this);
if (this->timer != 0) {
this->timer--;
}
if (this->timer < 0x8d) {
GetNextFrame(super);
tmp = super->frame & 0x80;
if (tmp) {
// Platform sank
super->action = 5;
this->timer = this->respawnTime;
super->spriteSettings.draw = 0;
} else {
if ((super->frame & 1) != 0) {
super->frame = tmp;
EnqueueSFX(SFX_LAVA_TILE_WOBBLE);
} else {
if ((super->frame & 2) != 0) {
super->frame = super->frame & 1;
EnqueueSFX(SFX_LAVA_TILE_SINK);
}
}
}
}
}
void LavaPlatform_Type1Action5(LavaPlatformEntity* this) {
if (--this->timer == 0) {
super->action = 6;
super->animationState = super->type2;
super->spriteSettings.draw = 1;
super->spriteOffsetY = 0;
InitializeAnimation(super, super->animationState + 4);
if (super->animationState == 0) {
LavaPlatform_IsPlayerOnPlatform(this);
}
}
}
void LavaPlatform_Type1Action6(LavaPlatformEntity* this) {
bool32 tmp;
if (super->animationState == 0) {
tmp = LavaPlatform_IsPlayerOnPlatform(this);
} else {
tmp = FALSE;
}
GetNextFrame(super);
if ((super->frame & 1) != 0) {
super->frame = 0;
super->flags |= ENT_COLLIDE;
super->hitType = 0xac;
} else {
if ((super->frame & 0x80) != 0) {
sub_0809264C(this);
if (tmp) {
gPlayerState.field_0x3f = 0xfd;
}
}
}
}
void LavaPlatform_Type1Action7(LavaPlatformEntity* this) {
if (super->bitfield == 0x9d) {
sub_08092620(this);
}
}
void LavaPlatform_SpawnPlatforms(LavaPlatformEntity* this) {
LavaPlatformEntry* entry = (LavaPlatformEntry*)GetCurrentRoomProperty(super->type2);
while (entry->type2 != 0xff) {
LavaPlatformEntity* platform = (LavaPlatformEntity*)CreateObject(LAVA_PLATFORM, 1, entry->type2);
if (platform != NULL) {
(platform->base).direction = 0xff;
(platform->base).speed = 0;
(platform->base).parent = super;
(platform->base).x.HALF.HI = entry->x + gRoomControls.origin_x;
(platform->base).y.HALF.HI = entry->y + gRoomControls.origin_y;
(platform->base).collisionLayer = entry->collisionLayer;
platform->wobbleTime = entry->wobbleTime;
platform->respawnTime = entry->respawnTime;
platform->unk_78 = entry->unk_78;
UpdateSpriteForCollisionLayer((Entity*)platform);
sub_080A2CC0(&platform->base, &platform->unk_78, &platform->unk_76);
}
entry++;
}
}
void sub_08092620(LavaPlatformEntity* this) {
LavaPlatformEntity* parent = (LavaPlatformEntity*)super->parent;
u32 one;
if (*(u8*)&parent->timer == 0) {
one = 1;
*(u8*)&parent->timer = one;
(parent->base).child = super;
CopyPosition(super, &parent->base);
super->action = one;
super->subAction = 0;
super->hitType = 0xac;
}
}
void sub_0809264C(LavaPlatformEntity* this) {
if ((super->animationState & 1) != 0) {
super->action = 7;
super->hitType = 0xac;
} else {
super->action = 2;
super->hitType = 1;
}
super->flags |= ENT_COLLIDE;
super->spriteSettings.draw = 1;
super->spriteOffsetY = -3;
InitializeAnimation(super, super->animationState);
}
bool32 LavaPlatform_IsPlayerOnPlatform(LavaPlatformEntity* this) {
if ((gPlayerState.flags & PL_MINISH) == 0 && EntityInRectRadius(super, &gPlayerEntity, 0x10, 0x10) &&
sub_08079F8C()) {
gPlayerState.field_0x14 = 1;
if (gPlayerEntity.z.HALF.HI == 0) {
super->field_0xf = 1;
return TRUE;
}
}
return FALSE;
}
void sub_080926E4(LavaPlatformEntity* this) {
sub_080A2BE4(super, super->field_0xf);
if (super->action == 1) {
(super->parent)->x.HALF.HI = super->x.HALF.HI;
(super->parent)->y.HALF.HI = super->y.HALF.HI;
}
if (--this->unk_76 == 0) {
sub_080A2CC0(super, &this->unk_78, &this->unk_76);
}
}
-2
View File
@@ -37,8 +37,6 @@ void LockedDoor(Entity* this) {
extern Hitbox gHitbox_2;
extern void sub_08078850(Entity*, u32, u32, u32);
typedef struct PACKED {
s8 x;
s8 y;
+255
View File
@@ -0,0 +1,255 @@
/**
* @file object3E.c
* @ingroup Objects
*
* @brief Object3E object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "screen.h"
typedef struct {
/*0x00*/ Entity base;
} Object3EEntity;
void Object3E_Type0(Object3EEntity*);
void Object3E_Type1(Object3EEntity*);
void Object3E_Type3(Object3EEntity*);
void Object3E_Type4(Object3EEntity*);
void Object3E_Type5(Object3EEntity*);
void Object3E_Type6(Object3EEntity*);
void Object3E_Type7(Object3EEntity*);
void Object3E_Type8(Object3EEntity*);
void Object3E_Type8_Init(Object3EEntity*);
void Object3E_Type8_Action1(Object3EEntity*);
void Object3E_Type8_Action2(Object3EEntity*);
void Object3E(Object3EEntity* this) {
static void (*const Object3E_Types[])(Object3EEntity*) = {
Object3E_Type0, Object3E_Type1, Object3E_Type1, Object3E_Type3, Object3E_Type4,
Object3E_Type5, Object3E_Type6, Object3E_Type7, Object3E_Type8, Object3E_Type1,
};
Object3E_Types[super->type](this);
}
void Object3E_Type0(Object3EEntity* this) {
u32 tmp;
u32 tmp2;
switch (super->action) {
case 0:
super->action = 1;
super->actionDelay = 0x40 - (Random() & 0x1f);
super->frameIndex = 0;
super->animationState = 0;
super->spriteRendering.b3 = 3;
super->spritePriority.b0 = 7;
super->collisionLayer = 1;
break;
case 1:
if (--super->actionDelay == 0) {
super->actionDelay = 8;
super->field_0xf = 4;
super->action = 2;
super->animationState = Random() & 3;
}
break;
case 2:
if (--super->actionDelay == 0) {
if (--super->field_0xf == 0) {
super->frameIndex = 0;
super->action = 1;
super->actionDelay = 0x40 - (Random() & 0x1f);
} else {
super->actionDelay = 8;
tmp2 = super->animationState;
if (super->frameIndex != tmp2) {
tmp = tmp2;
} else {
tmp = 0;
}
super->frameIndex = tmp;
}
}
break;
}
}
void Object3E_Type1(Object3EEntity* this) {
static const u16 gUnk_08121704[] = {
0x12d, 0x12e, 0x12f, 0x130, 0x131, 0x132, 0x133, 0x132, 0x131, 0x130, 0x12f, 0x12e, 0x12d, 0,
};
switch (super->action) {
case 0:
super->action = 1;
super->actionDelay = 8;
super->field_0xf = 0;
super->frameIndex = 0;
super->spritePriority.b0 = 7;
SetTile(0x4069, COORD_TO_TILE(super) - 0x40, 1);
break;
case 2:
if ((gRoomTransition.frameCount & 3U) == 0) {
gScreen.controls.alphaBlend = (super->subAction << 8) | (0x10 - super->subAction);
super->subAction++;
if (gScreen.controls.alphaBlend == 0x1000) {
gScreen.controls.layerFXControl = 0;
DeleteThisEntity();
}
}
break;
case 1:
break;
}
if (--super->actionDelay == 0) {
super->actionDelay = 8;
if (super->type == 9) {
super->actionDelay = 2;
}
ChangeObjPalette(super, gUnk_08121704[super->field_0xf++]);
if (gUnk_08121704[super->field_0xf] == 0) {
super->field_0xf = 0;
}
}
}
void sub_0808D280(void) {
Entity* obj = FindEntity(6, OBJECT_3E, 6, 9, 0);
if (obj != NULL) {
obj->action = 2;
obj->subAction = 0;
obj->spriteRendering.alphaBlend = 1;
gScreen.controls.layerFXControl = 0x640;
gScreen.controls.alphaBlend = 0x10;
SoundReq(SFX_EVAPORATE);
}
}
void sub_0808D2CC(void) {
Entity* obj = FindEntity(6, OBJECT_3E, 6, 1, 0);
if (obj != NULL) {
obj->type = 9;
SetDefaultPriority(obj, 2);
}
}
void Object3E_Type3(Object3EEntity* this) {
}
void Object3E_Type4(Object3EEntity* this) {
s32 tmp;
if (super->action == 0) {
super->action = 0;
super->frameIndex = 0;
super->spritePriority.b0 = 7;
sub_0807DD64(super);
}
tmp = super->x.HALF.HI;
ExecuteScriptForEntity(super, NULL);
HandleEntity0x82Actions(super);
if (((gRoomControls.shake_duration != 0) && (tmp != super->x.HALF.HI)) && ((gRoomTransition.frameCount & 8) == 0)) {
SoundReq(SFX_10F);
}
}
void Object3E_Type5(Object3EEntity* this) {
if (super->action == 0) {
super->action = 0;
super->frameIndex = 1;
super->spritePriority.b0 = 7;
sub_0807DD64(super);
}
ExecuteScriptForEntity(super, NULL);
HandleEntity0x82Actions(super);
}
void Object3E_Type6(Object3EEntity* this) {
static const u16 gUnk_08121720[] = { 0x149, 0x14a, 0x14b, 0x14a, 0, 0 };
if (super->action == 0) {
super->action = 1;
super->actionDelay = 8;
super->spritePriority.b0 = 7;
gScreen.controls.layerFXControl = 0x640;
gScreen.controls.alphaBlend = 0x1003;
}
if (--super->actionDelay == 0) {
super->actionDelay = 2;
sub_0801D28C(super, gUnk_08121720[super->field_0xf++]);
if (gUnk_08121720[super->field_0xf] == 0) {
super->field_0xf = 0;
}
}
}
void Object3E_Type7(Object3EEntity* this) {
if (super->action == 0) {
super->action = 1;
super->spriteRendering.b3 = 3;
super->spritePriority.b0 = 7;
super->spriteRendering.alphaBlend = 1;
super->frameIndex = super->type2;
sub_0805EC9C(super, (1 - super->type2) * 0x200 + 0x100, 0xffffff40, 0);
}
}
void Object3E_Type8(Object3EEntity* this) {
static void (*const Object3E_Type8_Actions[])(Object3EEntity*) = {
Object3E_Type8_Init,
Object3E_Type8_Action1,
Object3E_Type8_Action2,
};
Object3E_Type8_Actions[super->action](this);
}
void Object3E_Type8_Init(Object3EEntity* this) {
u32 tilePosition;
super->spritePriority.b0 = 7;
super->frameIndex = super->type2;
super->action = 2;
if ((super->type2 == 0) && (CheckLocalFlag(0x7c) == 0)) {
super->action = 1;
super->actionDelay = 0;
super->spriteRendering.alphaBlend = 1;
gScreen.controls.layerFXControl = 0x640;
gScreen.controls.alphaBlend = 0x1000;
SoundReq(SFX_179);
} else {
super->actionDelay = 8;
tilePosition = COORD_TO_TILE(super);
if (super->type2 != 0) {
tilePosition -= 0x40;
}
SetTile(0x4069, tilePosition, super->collisionLayer);
}
}
void Object3E_Type8_Action1(Object3EEntity* this) {
if ((gRoomTransition.frameCount & 3U) == 0) {
gScreen.controls.alphaBlend = ((0x10 - super->actionDelay) * 0x100) | super->actionDelay;
super->actionDelay++;
if (gScreen.controls.alphaBlend == 0x10) {
super->action = 2;
super->actionDelay = 8;
super->spriteRendering.alphaBlend = 0;
gScreen.controls.layerFXControl = 0;
SetTile(0x4069, COORD_TO_TILE(super), super->collisionLayer);
}
}
}
void Object3E_Type8_Action2(Object3EEntity* this) {
static const u16 gUnk_08121738[] = {
0x14c, 0x14d, 0x14e, 0x14f, 0x150, 0x151, 0x150, 0x14f, 0x14e, 0x14d, 0x14c, 0,
};
if (--super->actionDelay == 0) {
super->actionDelay = 8;
ChangeObjPalette(super, gUnk_08121738[super->field_0xf++]);
if (gUnk_08121738[super->field_0xf] == 0) {
super->field_0xf = 0;
}
}
}
-5
View File
@@ -103,11 +103,6 @@ Object6ATypeAction sub_080961F4;
Object6ATypeAction sub_08096284;
Object6ATypeAction sub_08096290;
extern void sub_08080CB4(Entity*);
extern u32 sub_080002B8(Entity*);
extern u32 CheckOnScreen(Entity*);
extern void sub_08078850(Entity*, u32, u32, u8*);
void sub_08095754(Object6AEntity*);
void sub_080957B4(Object6AEntity*);
void sub_08095954(Object6AEntity*);
+225 -11
View File
@@ -1,13 +1,47 @@
#include "entity.h"
#include "player.h"
/**
* @file objectA8.c
* @ingroup Objects
*
* @brief ObjectA8 object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "item.h"
extern void (*gUnk_08124824[])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0xc];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78[0xf];
/*0x87*/ u8 unk_87;
} ObjectA8Entity;
void ObjectA8(Entity* this) {
if ((this->bitfield & 0x80) != 0) {
switch (this->bitfield & 0x7f) {
extern Hitbox gUnk_080FD1A8;
void sub_0809FECC(ObjectA8Entity*);
bool32 sub_0809FE9C(ObjectA8Entity*);
void ObjectA8_Init(ObjectA8Entity*);
void ObjectA8_Action1(ObjectA8Entity*);
void ObjectA8_Action2(ObjectA8Entity*);
void ObjectA8_Action3(ObjectA8Entity*);
void ObjectA8_Action4(ObjectA8Entity*);
void ObjectA8_Action5(ObjectA8Entity*);
void ObjectA8_Action6(ObjectA8Entity*);
void ObjectA8_Action2Subaction0(ObjectA8Entity*);
void ObjectA8_Action2Subaction1(ObjectA8Entity*);
void ObjectA8_Action2Subaction2(ObjectA8Entity*);
void ObjectA8(ObjectA8Entity* this) {
static void (*const ObjectA8_Actions[])(ObjectA8Entity*) = {
ObjectA8_Init, ObjectA8_Action1, ObjectA8_Action2, ObjectA8_Action3,
ObjectA8_Action4, ObjectA8_Action5, ObjectA8_Action6,
};
if ((super->bitfield & 0x80) != 0) {
switch (super->bitfield & 0x7f) {
case 0:
case 1:
case 4:
@@ -20,12 +54,192 @@ void ObjectA8(Entity* this) {
case 0xc:
case 0x1e:
case 0x1f:
this->action = 5;
this->child = &gPlayerEntity;
CreateItemEntity(this->type, 0, 0);
super->action = 5;
super->child = &gPlayerEntity;
CreateItemEntity(super->type, 0, 0);
DeleteThisEntity();
}
}
gUnk_08124824[this->action](this);
sub_08080CB4(this);
ObjectA8_Actions[super->action](this);
sub_08080CB4(super);
}
void ObjectA8_Init(ObjectA8Entity* this) {
super->action = 1;
switch (super->type2) {
case 0:
super->zVelocity = 0x1e000;
super->z.HALF.HI += 8;
break;
case 2:
sub_0809FECC(this);
return;
}
super->collisionLayer = 3;
super->field_0x3c = 0x17;
super->hurtType = 0x48;
super->hitType = 7;
super->flags2 = 0x17;
super->hitbox = (Hitbox*)&gUnk_080FD1A8;
super->field_0x1c = 1;
this->unk_74 = super->x.HALF.HI;
this->unk_76 = super->y.HALF.HI;
SetDefaultPriority(super, 3);
EnqueueSFX(SFX_136);
}
void ObjectA8_Action1(ObjectA8Entity* this) {
super->z.WORD -= 0xe000;
if (super->frame != 0) {
if (super->actionDelay != 0) {
super->actionDelay *= 0x1e;
} else {
super->actionDelay = 0xf0;
}
super->action = 3;
super->field_0xf = 1;
super->speed = 0x80;
}
}
void ObjectA8_Action2(ObjectA8Entity* this) {
static void (*const ObjectA8_Action2Subactions[])(ObjectA8Entity*) = {
ObjectA8_Action2Subaction0,
ObjectA8_Action2Subaction1,
ObjectA8_Action2Subaction2,
};
ObjectA8_Action2Subactions[super->subAction](this);
}
void ObjectA8_Action2Subaction0(ObjectA8Entity* this) {
super->subAction = 1;
super->field_0x1d = 1;
super->spriteSettings.draw = 1;
}
void ObjectA8_Action2Subaction1(ObjectA8Entity* this) {
if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->bitfield & 0x7f) != 0x13) {
super->action = 3;
} else {
sub_0806F4E8(super);
}
}
void ObjectA8_Action2Subaction2(ObjectA8Entity* this) {
if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->bitfield & 0x7f) != 0x13) {
super->action = 3;
} else {
if (sub_0806F3E4(super)) {
super->flags &= ~ENT_COLLIDE;
super->action = 5;
super->child = &gPlayerEntity;
GiveItem(super->type, 0);
}
}
}
void ObjectA8_Action3(ObjectA8Entity* this) {
static const u8 gUnk_0812484C[] = {
128,
96,
0,
0,
};
if (--super->field_0xf == 0) {
u32 rand = Random();
super->flags |= ENT_COLLIDE;
super->field_0xf = 0x20;
super->speed = gUnk_0812484C[rand >> 8 & 1];
if (sub_0809FE9C(this)) {
super->direction = rand & 0x1f;
} else {
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_74, this->unk_76);
}
if ((super->direction & 0xf) != 0) {
super->spriteSettings.flipX = ((super->direction ^ 0x10) >> 4);
}
}
ProcessMovement1(super);
if ((AnyPrioritySet() == 0) && (super->type == 0)) {
if (((gRoomTransition.frameCount & 1) != 0) && (--super->actionDelay == 0)) {
sub_08081404(super, 0);
}
if (super->actionDelay < 0x3c) {
super->spriteSettings.draw ^= 1;
}
}
}
void ObjectA8_Action4(ObjectA8Entity* this) {
if (*(u16*)&super->child->kind != 0xb08) {
sub_08081404(super, 0);
} else {
CopyPosition(super->child, super);
super->z.HALF.HI--;
if (IsColliding(super, &gPlayerEntity)) {
sub_0809FECC(this);
GiveItem(super->type, 0);
}
}
}
void ObjectA8_Action5(ObjectA8Entity* this) {
super->action = 6;
super->actionDelay = 0x80;
super->field_0xf = 6;
super->flags &= ~ENT_COLLIDE;
super->spriteSettings.draw = 1;
super->spritePriority.b1 = 2;
super->spriteOffsetY = -5;
CopyPosition(super->child, super);
}
void ObjectA8_Action6(ObjectA8Entity* this) {
s32 tmp;
Entity* child = super->child;
tmp = gSineTable[super->actionDelay] * 0xa00;
if (tmp < 0) {
tmp += 0xffff;
}
super->x.HALF.HI = (s16)(tmp >> 0x10) + child->x.HALF.HI;
tmp = gSineTable[super->actionDelay + 0x40] * 0x500;
if (tmp < 0) {
tmp += 0xffff;
}
super->y.HALF.HI = super->child->y.HALF.HI - (tmp >> 0x10);
super->actionDelay += 8;
super->z.HALF.HI = super->child->z.HALF.HI;
super->spriteOrientation.flipY = super->child->spriteOrientation.flipY;
super->spriteRendering.b3 = super->child->spriteRendering.b3;
if ((u8)(super->actionDelay - 0x41) < 0x7f) {
super->spritePriority.b0 = 3;
} else {
super->spritePriority.b0 = 5;
}
if (--super->field_0xf == 0) {
super->field_0xf = 6;
if (((--super->spriteOffsetY) * 0x1000000) >> 0x18 < -0x16) {
sub_08081404(super, 1);
}
}
if (super->spriteOffsetY < -0x11) {
super->spriteSettings.draw ^= 1;
}
if (this->unk_87 > 10) {
this->unk_87 = 0xa;
}
}
bool32 sub_0809FE9C(ObjectA8Entity* this) {
if (((super->x.HALF.HI - (u32)this->unk_74) + 0x48 < 0x91) &&
((super->y.HALF.HI - (u32)this->unk_76) + 0x30 < 0x61)) {
return TRUE;
} else {
return FALSE;
}
}
void sub_0809FECC(ObjectA8Entity* this) {
super->child = &gPlayerEntity;
super->action = 5;
super->subAction = 0;
}
+303
View File
@@ -0,0 +1,303 @@
/**
* @file objectOnPillar.c
* @ingroup Objects
*
* @brief Object on Pillar 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 tileIndex;
/*0x72*/ u16 unk_72;
/*0x74*/ u16 tilePosition;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78[0x4];
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unk_7d;
/*0x7e*/ u8 unk_7e;
/*0x7f*/ u8 unk_7f;
/*0x80*/ u8 unk_80[0x4];
/*0x84*/ u16 hitFlag;
/*0x86*/ u16 unk_86;
} ObjectOnPillarEntity;
extern bool32 sub_080896B0(void); // pushableStatue
extern Hitbox gUnk_080FD1F4;
extern s16 gUnk_080B4488[];
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[10 + 0x14];
/*0x86*/ u16 hitFlag;
} EntityWithHitFlag;
typedef struct {
u16 key;
u16 value;
} KeyValuePair;
void sub_080970F4(ObjectOnPillarEntity*);
void sub_080971E0(ObjectOnPillarEntity*);
bool32 sub_08097194(ObjectOnPillarEntity*);
bool32 sub_08097008(ObjectOnPillarEntity*);
bool32 sub_08097144(ObjectOnPillarEntity*);
void sub_08097098(ObjectOnPillarEntity*);
u32 sub_08097074(u32);
bool32 sub_08097348(u32);
void ObjectOnPillar_Init(ObjectOnPillarEntity*);
void ObjectOnPillar_Action1(ObjectOnPillarEntity*);
void ObjectOnPillar_Action2(ObjectOnPillarEntity*);
void ObjectOnPillar_Action3(ObjectOnPillarEntity*);
void ObjectOnPillar_Action4(ObjectOnPillarEntity*);
void ObjectOnPillar_SubAction0(ObjectOnPillarEntity*);
void ObjectOnPillar_SubAction1(ObjectOnPillarEntity*);
void ObjectOnPillar(ObjectOnPillarEntity* this) {
static void (*const ObjectOnPillar_Actions[])(ObjectOnPillarEntity*) = {
ObjectOnPillar_Init, ObjectOnPillar_Action1, ObjectOnPillar_Action2,
ObjectOnPillar_Action3, ObjectOnPillar_Action4,
};
ObjectOnPillar_Actions[super->action](this);
}
void ObjectOnPillar_Init(ObjectOnPillarEntity* this) {
static const u8 gUnk_08123264[] = {
0, 2, 4, 3, 7, 5, 0, 0,
};
if (CheckFlags(this->unk_86) == 0) {
super->action = 1;
super->speed = 0x80;
super->updatePriority = 3;
super->spriteSettings.draw = 1;
super->spritePriority.b1 = 1;
super->spriteSettings.shadow = 1;
super->spriteOffsetY = 4;
super->hitbox = (Hitbox*)&gUnk_080FD1F4;
super->field_0x16 = 1;
this->unk_72 = 0;
super->collisionLayer = this->unk_7d >> 4;
UpdateSpriteForCollisionLayer(super);
sub_080970F4(this);
super->frameIndex = gUnk_08123264[super->type];
} else {
super->x.HALF.HI = (this->unk_7c | ((this->unk_7d & 0xf) << 8)) + gRoomControls.origin_x;
super->y.HALF.HI = (this->unk_7e | ((this->unk_7f & 0xf) << 8)) + gRoomControls.origin_y;
super->collisionLayer = this->unk_7f >> 4;
sub_080971E0(this);
}
}
void ObjectOnPillar_Action1(ObjectOnPillarEntity* this) {
if (sub_08097194(this) == FALSE) {
if (sub_08097008(this)) {
super->action = 3;
} else {
sub_08078930(super);
}
}
}
void ObjectOnPillar_Action2(ObjectOnPillarEntity* this) {
static void (*const ObjectOnPillar_SubActions[])(ObjectOnPillarEntity*) = {
ObjectOnPillar_SubAction0,
ObjectOnPillar_SubAction1,
};
if (this->unk_76 != 0) {
sub_08097144(this);
} else {
if (gPlayerState.heldObject == 0) {
super->subAction = 6;
}
ObjectOnPillar_SubActions[super->subAction - 5](this);
}
}
void ObjectOnPillar_SubAction0(ObjectOnPillarEntity* this) {
static const s8 gUnk_08123274[] = { 0, 14, -14, 2, 0, -14, 14, 2 };
const s8* ptr;
if (this->unk_72 == 0) {
this->unk_72 = 1;
ptr = &gUnk_08123274[gPlayerEntity.animationState];
PositionRelative(super, &gPlayerEntity, ptr[0] << 0x10, ptr[1] << 0x10);
}
sub_08097008(this);
if (sub_080896B0()) {
gPlayerState.queued_action = 0x10;
gPlayerState.field_0x38 = 0x20;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
super->direction = ((gPlayerEntity.animationState ^ 4) << 2);
sub_08097098(this);
}
}
void ObjectOnPillar_SubAction1(ObjectOnPillarEntity* this) {
super->action = 1;
this->unk_72 = 0;
}
void ObjectOnPillar_Action3(ObjectOnPillarEntity* this) {
if (sub_08097144(this)) {
super->action = 1;
}
}
void ObjectOnPillar_Action4(ObjectOnPillarEntity* this) {
}
bool32 sub_08097008(ObjectOnPillarEntity* this) {
Entity* effect;
u32 tileType = GetTileType(this->tilePosition, super->collisionLayer);
if (tileType != 0x4036) {
switch (sub_08097074(tileType)) {
case 1:
super->direction = (((tileType - 0x37) & 3) << 3);
sub_08097098(this);
return TRUE;
case 2:
this->tileIndex = tileType;
break;
default:
effect = CreateObject(SPECIAL_FX, 4, 0);
if (effect != NULL) {
CopyPosition(super, effect);
}
DeleteEntity(super);
break;
}
}
return FALSE;
}
u32 sub_08097074(u32 tileType) {
static const KeyValuePair gUnk_0812327C[] = {
{ 0x4037, 1 }, { 0x4038, 1 }, { 0x4039, 1 }, { 0x403a, 1 }, { 0x7a, 2 }, { 0x78, 2 }, { 0, 0 },
};
const KeyValuePair* entry = gUnk_0812327C;
for (; entry->key != 0; entry++) {
if (entry->key == tileType) {
return entry->value;
}
}
return 0;
}
void sub_08097098(ObjectOnPillarEntity* this) {
u16 tileType;
this->unk_76 = 0x20;
EnqueueSFX(SFX_10F);
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
tileType = GetTileType(gUnk_080B4488[super->direction >> 3] + this->tilePosition, super->collisionLayer);
if ((tileType == 0x79) || tileType == 0x77) {
super->spriteOffsetY = 2;
}
}
void sub_080970F4(ObjectOnPillarEntity* this) {
this->tilePosition = COORD_TO_TILE(super);
this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer);
SetTile(0x4036, this->tilePosition, super->collisionLayer);
}
bool32 sub_08097144(ObjectOnPillarEntity* this) {
LinearMoveUpdate(super);
sub_0800445C(super);
if (sub_080002B8(super) == 0x19) {
super->spriteOffsetY = 2;
}
if ((--this->unk_76 == 0) && sub_08097194(this) == FALSE) {
super->spriteOffsetY = 4;
sub_080970F4(this);
return TRUE;
} else {
return FALSE;
}
}
bool32 sub_08097194(ObjectOnPillarEntity* this) {
if (sub_0800442E(super)) {
return TRUE;
} else {
u32 tileType = GetTileTypeByEntity(super);
if (tileType == 0x71 || tileType == 0x72 || (tileType == 0x4020)) {
SetFlag(this->unk_86);
EnqueueSFX(SFX_10B);
sub_080971E0(this);
return TRUE;
} else {
return FALSE;
}
}
return FALSE;
}
void sub_080971E0(ObjectOnPillarEntity* this) {
EntityWithHitFlag* entity;
u32 tilePosition;
entity = (EntityWithHitFlag*)CreateObject(SPECIAL_FX, 0x11, 0x40);
if (entity != NULL) {
PositionRelative(super, &entity->base, -0x80000, 0x20000);
}
entity = (EntityWithHitFlag*)CreateObject(SPECIAL_FX, 0x11, 0x40);
if (entity != NULL) {
PositionRelative(super, &entity->base, 0x80000, 0x20000);
}
switch (super->type) {
case 0:
default:
super->action = 4;
super->frameIndex = 1;
super->spritePriority.b0 = 7;
SetTile(0, COORD_TO_TILE(super), super->collisionLayer);
DeleteThisEntity();
break;
case 1:
tilePosition = COORD_TO_TILE(super);
if (sub_08097348(tilePosition) == 0) {
SetTileType(0x73, tilePosition, super->collisionLayer);
}
DeleteThisEntity();
break;
case 2:
entity = (EntityWithHitFlag*)CreateObject(HITTABLE_LEVER, 0, 0);
if (entity != NULL) {
(entity->base).x.HALF.HI = (super->x.HALF.HI & 0xfff0) + 8;
(entity->base).y.HALF.HI = (super->y.HALF.HI & 0xfff0) + 8;
(entity->base).collisionLayer = super->collisionLayer;
entity->hitFlag = this->hitFlag;
}
DeleteThisEntity();
break;
case 3:
entity = (EntityWithHitFlag*)CreateObject(HITTABLE_LEVER, 1, 0);
if (entity != NULL) {
(entity->base).x.HALF.HI = (super->x.HALF.HI & 0xfff0) + 8;
(entity->base).y.HALF.HI = (super->y.HALF.HI & 0xfff0) + 8;
(entity->base).collisionLayer = super->collisionLayer;
entity->hitFlag = this->hitFlag;
}
DeleteThisEntity();
break;
}
}
bool32 sub_08097348(u32 tilePosition) {
u32 index;
TileEntity* tileEntity = gSmallChests;
for (index = 0; index < 8; index++, tileEntity++) {
if (tileEntity->_4 == tilePosition) {
return CheckLocalFlag(tileEntity->_1);
}
}
return FALSE;
}
+305
View File
@@ -0,0 +1,305 @@
/**
* @file objectOnSpinyBeetle.c
* @ingroup Objects
*
* @brief Object on Spiny Beetle object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
} ObjectOnSpinyBeetleEntity;
extern void (*const ObjectOnSpinyBeetle_Actions[])(ObjectOnSpinyBeetleEntity*);
extern void (*const ObjectOnSpinyBeetle_Action2Subactions[])(ObjectOnSpinyBeetleEntity*);
extern void (*const ObjectOnSpinyBeetle_Action3Subactions[])(ObjectOnSpinyBeetleEntity*);
extern const s8 gUnk_08123558[];
void sub_08098918(ObjectOnSpinyBeetleEntity*);
Entity* ObjectOnSpinyBeetle_GetParent(ObjectOnSpinyBeetleEntity*);
void sub_080989C0(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Init(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action1(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action2(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action3(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action4(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action5(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action2Subaction0(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action2Subaction1(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action2Subaction2(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action2Subaction3(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action2Subaction4(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action2Subaction5(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action2Subaction6(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action3Subaction0(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action3Subaction1(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action3Subaction2(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action3Subaction3(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action3Subaction4(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle_Action3Subaction5(ObjectOnSpinyBeetleEntity*);
void ObjectOnSpinyBeetle(ObjectOnSpinyBeetleEntity* this) {
static void (*const ObjectOnSpinyBeetle_Actions[])(ObjectOnSpinyBeetleEntity*) = {
ObjectOnSpinyBeetle_Init, ObjectOnSpinyBeetle_Action1, ObjectOnSpinyBeetle_Action2,
ObjectOnSpinyBeetle_Action3, ObjectOnSpinyBeetle_Action4, ObjectOnSpinyBeetle_Action5,
};
ObjectOnSpinyBeetle_Actions[super->action](this);
}
void ObjectOnSpinyBeetle_Init(ObjectOnSpinyBeetleEntity* this) {
super->action = 1;
super->flags |= ENT_COLLIDE;
super->spritePriority.b0 = 6;
super->spriteRendering.b3 = 2;
super->field_0xf = 0;
super->hitType = 0x6e;
super->flags2 = 0x86;
super->field_0x16 = 0;
if (super->type != 0) {
super->field_0x1c = 2;
} else {
super->field_0x1c = 1;
}
SortEntityBelow(super, super->parent);
sub_08098918(this);
}
void ObjectOnSpinyBeetle_Action1(ObjectOnSpinyBeetleEntity* this) {
Entity* parent = ObjectOnSpinyBeetle_GetParent(this);
if (parent != NULL) {
if (4 < parent->action) {
sub_080989C0(this);
return;
}
if ((super->bitfield & 0x80) != 0) {
switch (super->bitfield & 0x3f) {
case 0x13:
super->action = 3;
super->subAction = 0;
break;
case 0xf:
case 0x1d:
super->action = 4;
super->zVelocity = 0x2a000;
super->spriteOffsetY = 0;
super->spriteSettings.shadow = 1;
super->spritePriority.b1 = 3;
super->flags &= ~ENT_COLLIDE;
(super->parent)->child = NULL;
ObjectOnSpinyBeetle_Action4(this);
break;
case 4:
case 5:
case 6:
case 8:
case 9:
case 10:
case 0xb:
case 0xc:
case 0xd:
case 0x10:
case 0x11:
case 0x12:
case 0x18:
case 0x19:
case 0x1a:
if (super->type == 0 || (gPlayerState.field_0xac & 8) != 0) {
sub_080989C0(this);
}
break;
case 0x14:
case 0x16:
case 0x20:
if (super->type == 0) {
sub_080989C0(this);
}
}
} else {
sub_08098918(this);
sub_08078930(super);
}
} else {
sub_080989C0(this);
}
}
void ObjectOnSpinyBeetle_Action2(ObjectOnSpinyBeetleEntity* this) {
static void (*const ObjectOnSpinyBeetle_Action2Subactions[])(ObjectOnSpinyBeetleEntity*) = {
ObjectOnSpinyBeetle_Action2Subaction0, ObjectOnSpinyBeetle_Action2Subaction1,
ObjectOnSpinyBeetle_Action2Subaction2, ObjectOnSpinyBeetle_Action2Subaction3,
ObjectOnSpinyBeetle_Action2Subaction4, ObjectOnSpinyBeetle_Action2Subaction5,
ObjectOnSpinyBeetle_Action2Subaction6,
};
ObjectOnSpinyBeetle_Action2Subactions[super->subAction](this);
}
void ObjectOnSpinyBeetle_Action2Subaction0(ObjectOnSpinyBeetleEntity* this) {
super->flags |= ENT_COLLIDE;
super->field_0x3c = 7;
super->hitType = 1;
super->flags2 = gPlayerEntity.flags2;
super->spriteOffsetY = 0;
(super->parent)->child = NULL;
super->subAction += 1;
}
void ObjectOnSpinyBeetle_Action2Subaction1(ObjectOnSpinyBeetleEntity* this) {
}
void ObjectOnSpinyBeetle_Action2Subaction2(ObjectOnSpinyBeetleEntity* this) {
super->spritePriority.b1 = 3;
}
void ObjectOnSpinyBeetle_Action2Subaction3(ObjectOnSpinyBeetleEntity* this) {
switch (sub_080043E8(super)) {
case 2:
CreateFx(super, FX_WATER_SPLASH, 0);
break;
case 1:
CreateFx(super, FX_FALL_DOWN, 0);
break;
case 3:
CreateFx(super, FX_LAVA_SPLASH, 0);
break;
default:
sub_080989C0(this);
return;
}
DeleteThisEntity();
}
void ObjectOnSpinyBeetle_Action2Subaction4(ObjectOnSpinyBeetleEntity* this) {
DeleteThisEntity();
}
void ObjectOnSpinyBeetle_Action2Subaction5(ObjectOnSpinyBeetleEntity* this) {
if (gPlayerState.heldObject == 0) {
ObjectOnSpinyBeetle_Action2Subaction6(this);
}
}
void ObjectOnSpinyBeetle_Action2Subaction6(ObjectOnSpinyBeetleEntity* this) {
super->action = 1;
super->subAction = 0;
}
void ObjectOnSpinyBeetle_Action3(ObjectOnSpinyBeetleEntity* this) {
static void (*const ObjectOnSpinyBeetle_Action3Subactions[])(ObjectOnSpinyBeetleEntity*) = {
ObjectOnSpinyBeetle_Action3Subaction0, ObjectOnSpinyBeetle_Action3Subaction1,
ObjectOnSpinyBeetle_Action3Subaction2, ObjectOnSpinyBeetle_Action3Subaction3,
ObjectOnSpinyBeetle_Action3Subaction4, ObjectOnSpinyBeetle_Action3Subaction5,
};
ObjectOnSpinyBeetle_Action3Subactions[super->subAction](this);
if ((super->subAction < 2) && (ObjectOnSpinyBeetle_GetParent(this) == NULL)) {
sub_080989C0(this);
}
}
void ObjectOnSpinyBeetle_Action3Subaction0(ObjectOnSpinyBeetleEntity* this) {
super->subAction = 1;
super->field_0x1d = 0x30;
super->actionDelay = 0;
}
void ObjectOnSpinyBeetle_Action3Subaction1(ObjectOnSpinyBeetleEntity* this) {
if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->bitfield & 0x7f) != 0x13) {
super->spriteOffsetX = 0;
super->action = 1;
} else {
sub_0806F4E8(super);
}
}
void ObjectOnSpinyBeetle_Action3Subaction2(ObjectOnSpinyBeetleEntity* this) {
if (super->actionDelay == 0) {
super->actionDelay = 1;
super->spriteOffsetX = 0;
super->spriteOffsetY = -2;
(super->parent)->child = NULL;
}
if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->bitfield & 0x7f) != 0x13) {
sub_080989C0(this);
} else {
if ((sub_0806F3E4(super) != 0) && (super->type == 0)) {
DeleteThisEntity();
}
}
}
void ObjectOnSpinyBeetle_Action3Subaction3(ObjectOnSpinyBeetleEntity* this) {
if (gPlayerState.field_0x1c == 0) {
sub_080989C0(this);
} else {
(this->base).flags &= ~ENT_COLLIDE;
}
}
void ObjectOnSpinyBeetle_Action3Subaction4(ObjectOnSpinyBeetleEntity* this) {
}
void ObjectOnSpinyBeetle_Action3Subaction5(ObjectOnSpinyBeetleEntity* this) {
sub_080989C0(this);
}
void ObjectOnSpinyBeetle_Action4(ObjectOnSpinyBeetleEntity* this) {
if (super->zVelocity < 0) {
super->spriteSettings.flipY = 1;
}
if (GravityUpdate(super, 0x2000) == 0) {
sub_080989C0(this);
}
}
void ObjectOnSpinyBeetle_Action5(ObjectOnSpinyBeetleEntity* this) {
sub_080989C0(this);
}
void sub_08098918(ObjectOnSpinyBeetleEntity* this) {
static const s8 gUnk_08123558[] = { 1, 2, 2, 2, 0, -3, -3, -4, -3, -4, -3, -3, -3, 0, 0, 0 };
u16 tmp;
Entity* parent = ObjectOnSpinyBeetle_GetParent(this);
if (parent == NULL) {
sub_080989C0(this);
} else {
CopyPosition(parent, super);
tmp = parent->flags & 0x80;
if ((parent->flags & ENT_COLLIDE) != 0) {
if (super->field_0xf == 0) {
super->field_0xf += 1;
super->spritePriority.b0 = 3;
SortEntityBelow(super, super->parent);
}
super->z.HALF.HI = gUnk_08123558[parent->frame & 0xf] - 8;
super->spriteOffsetY = 0;
} else {
if (super->field_0xf != 0) {
super->field_0xf = tmp;
super->spritePriority.b0 = 6;
SortEntityBelow(super, super->parent);
}
super->z.HALF.HI = tmp;
super->spriteOffsetY = 3;
}
}
}
void sub_080989C0(ObjectOnSpinyBeetleEntity* this) {
if (ObjectOnSpinyBeetle_GetParent(this) != NULL) {
(super->parent)->child = NULL;
}
CreateFx(super, super->type + FX_BUSH, 0);
DeleteThisEntity();
}
Entity* ObjectOnSpinyBeetle_GetParent(ObjectOnSpinyBeetleEntity* this) {
Entity* parent = super->parent;
if ((parent != NULL) && (parent->next == NULL)) {
parent = NULL;
}
return parent;
}
+1 -2
View File
@@ -4,8 +4,7 @@
#include "save.h"
#include "script.h"
#include "effects.h"
extern void sub_08078850(Entity*, u32, u32, u8*);
#include "functions.h"
extern u8 gUnk_08125010;