From 4d67e6fe1ff97f964e700b27dc2b1f8911002a12 Mon Sep 17 00:00:00 2001 From: octorock <79596758+octorock@users.noreply.github.com> Date: Mon, 31 Jul 2023 21:31:30 +0200 Subject: [PATCH] Create new entity structs for Objects --- assets/assets.json | 6 +- data/animations/object/thunderbold.s | 20 - data/animations/object/thunderbolt.s | 20 + data/gfx/sprite_ptrs.s | 2 +- include/asm.h | 2 +- include/item.h | 1 - include/object.h | 4 +- include/object/cutsceneOrchestrator.h | 12 + include/object/itemOnGround.h | 18 + include/object/lilypadLarge.h | 21 + linker.ld | 6 +- src/manager/vaati3StartManager.c | 2 +- src/object.c | 2 +- src/object/ambientClouds.c | 45 +- src/object/angryStatue.c | 1 + src/object/archway.c | 1 + src/object/backgroundCloud.c | 84 ++-- src/object/bakerOven.c | 123 ++--- src/object/barrelInside.c | 1 + src/object/barrelSpiderweb.c | 140 +++--- src/object/beanstalk.c | 3 +- src/object/bedCover.c | 2 - src/object/bell.c | 27 +- src/object/bench.c | 4 +- src/object/bigBarrel.c | 60 +-- src/object/bigIceBlock.c | 2 - src/object/bigPushableLever.c | 2 - src/object/bigVortex.c | 96 ++-- src/object/bird.c | 389 +++++++-------- src/object/blockPushed.c | 2 - src/object/book.c | 157 ++++--- src/object/bossDoor.c | 2 - src/object/bush.c | 3 +- src/object/button.c | 216 +++++---- src/object/carlovObject.c | 1 - src/object/chestSpawner.c | 2 - src/object/chuchuBossCutscene.c | 136 +++--- src/object/chuchuBossParticle.c | 2 +- src/object/chuchuBossStartParticle.c | 347 +++++++------- src/object/cloud.c | 152 +++--- src/object/crackingGround.c | 1 - src/object/crenelBeanSprout.c | 2 - src/object/cuccoMinigame.c | 2 +- src/object/cutsceneMiscObject.c | 167 ++++--- src/object/cutsceneOrchestrator.c | 3 +- src/object/deathFx.c | 2 +- src/object/dirtParticle.c | 1 - src/object/doubleBookshelf.c | 1 - src/object/enemyItem.c | 2 - src/object/eyeSwitch.c | 26 +- src/object/ezloCap.c | 2 - src/object/ezloCapFlying.c | 1 - src/object/fairy.c | 4 +- src/object/fan.c | 1 - src/object/fanWind.c | 2 +- src/object/figurineDevice.c | 3 +- src/object/fileScreenObjects.c | 399 ++++++++-------- src/object/fireballChain.c | 8 +- src/object/fireplace.c | 53 ++- src/object/flame.c | 88 ++-- src/object/floatingBlock.c | 1 + src/object/floatingPlatform.c | 18 +- src/object/fourElements.c | 2 - src/object/frozenFlower.c | 1 + src/object/frozenOctorok.c | 1 - src/object/frozenWaterElement.c | 1 - src/object/furniture.c | 4 +- src/object/giantLeaf.c | 27 +- src/object/giantRock.c | 1 + src/object/giantRock2.c | 8 +- src/object/giantTwig.c | 2 - src/object/greatFairy.c | 497 ++++++++++---------- src/object/gustJarParticle.c | 6 +- src/object/gyorgBossObject.c | 1 - src/object/heartContainer.c | 72 +-- src/object/hiddenLadderDown.c | 68 +-- src/object/hitSwitch.c | 49 +- src/object/hittableLever.c | 4 +- src/object/houseDoorExterior.c | 183 +++---- src/object/houseDoorInterior.c | 4 +- src/object/houseSign.c | 22 +- src/object/itemForSale.c | 2 - src/object/itemOnGround.c | 424 ++++++++--------- src/object/jailBars.c | 62 +-- src/object/japaneseSubtitle.c | 4 +- src/object/jarPortal.c | 190 ++++---- src/object/keyStealingTakkuri.c | 2 - src/object/kinstoneSpark.c | 1 - src/object/ladderHoleInBookshelf.c | 1 + src/object/ladderUp.c | 1 + src/object/lamp.c | 1 + src/object/lavaPlatform.c | 2 - src/object/lightDoor.c | 2 - src/object/lightRay.c | 1 - src/object/lightableSwitch.c | 165 ++++--- src/object/lilypadLarge.c | 58 +-- src/object/lilypadLargeFalling.c | 7 +- src/object/lilypadSmall.c | 53 ++- src/object/linkAnimation.c | 1 - src/object/linkEmptyingBottle.c | 18 +- src/object/linkFire.c | 1 - src/object/linkHoldingItem.c | 1 - src/object/litArea.c | 55 ++- src/object/lockedDoor.c | 240 +++++----- src/object/macroAcorn.c | 59 ++- src/object/macroBook.c | 4 +- src/object/macroDecorations.c | 1 - src/object/macroMushroomStalk.c | 1 + src/object/macroPlayer.c | 8 +- src/object/macroShoe.c | 1 + src/object/mask.c | 100 ++-- src/object/mazaalBossObject.c | 5 +- src/object/mazaalObject.c | 2 +- src/object/metalDoor.c | 147 +++--- src/object/minecart.c | 18 +- src/object/minecartDoor.c | 2 - src/object/mineralWaterSource.c | 5 +- src/object/minishEmoticon.c | 1 + src/object/minishLight.c | 1 + src/object/minishPortalCloseup.c | 2 - src/object/minishPortalStone.c | 17 +- src/object/minishSizedArchway.c | 1 + src/object/minishSizedEntrance.c | 1 + src/object/minishVillageObject.c | 244 +++++----- src/object/moleMittsParticle.c | 1 - src/object/object1D.c | 1 + src/object/object30.c | 2 - src/object/object70.c | 4 +- src/object/objectA.c | 36 +- src/object/objectA2.c | 1 + src/object/objectA8.c | 4 +- src/object/objectBF.c | 1 + src/object/objectBlockingStairs.c | 5 +- src/object/objectOnPillar.c | 2 - src/object/objectOnSpinyBeetle.c | 2 - src/object/octorokBossObject.c | 338 ++++++------- src/object/palaceArchway.c | 1 + src/object/paper.c | 2 - src/object/parallaxRoomView.c | 57 ++- src/object/pinwheel.c | 47 +- src/object/playerClone.c | 6 +- src/object/pot.c | 299 ++++++------ src/object/pressurePlate.c | 8 +- src/object/pullableLever.c | 2 - src/object/pullableMushroom.c | 2 - src/object/pushableFurniture.c | 6 +- src/object/pushableGrave.c | 2 - src/object/pushableLever.c | 2 - src/object/pushableRock.c | 2 - src/object/pushableStatue.c | 3 +- src/object/railtrack.c | 163 ++++--- src/object/rupee.c | 52 +- src/object/smallIceBlock.c | 4 +- src/object/smoke.c | 17 +- src/object/smokeParticle.c | 1 - src/object/specialFx.c | 19 +- src/object/stoneTablet.c | 1 + src/object/swordParticle.c | 1 - src/object/swordsmanNewsletter.c | 2 +- src/object/thoughtBubble.c | 6 +- src/object/{thunderbold.c => thunderbolt.c} | 40 +- src/object/titleScreenObject.c | 1 - src/object/trapdoor.c | 1 + src/object/treeHidingPortal.c | 70 +-- src/object/treeThorns.c | 2 +- src/object/unusedSkull.c | 1 - src/object/vaati2Particle.c | 1 - src/object/vaati3Arm.c | 2 +- src/object/vaati3PlayerObject.c | 1 + src/object/warpPoint.c | 200 ++++---- src/object/waterDropObject.c | 4 +- src/object/waterElement.c | 1 - src/object/well.c | 38 +- src/object/whirlwind.c | 2 - src/object/whiteTriangleEffect.c | 2 - src/object/windTribeFlag.c | 1 + src/object/windTribeTeleporter.c | 2 - src/object/windcrest.c | 2 +- 178 files changed, 3741 insertions(+), 3500 deletions(-) delete mode 100644 data/animations/object/thunderbold.s create mode 100644 data/animations/object/thunderbolt.s create mode 100644 include/object/cutsceneOrchestrator.h create mode 100644 include/object/itemOnGround.h create mode 100644 include/object/lilypadLarge.h rename src/object/{thunderbold.c => thunderbolt.c} (73%) diff --git a/assets/assets.json b/assets/assets.json index ae44f992..74524b6e 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -22883,19 +22883,19 @@ "type": "animation" }, { - "path": "animations/gSpriteAnimations_Thunderbold_0.bin", + "path": "animations/gSpriteAnimations_Thunderbolt_0.bin", "start": 1190252, "size": 16, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Thunderbold_1.bin", + "path": "animations/gSpriteAnimations_Thunderbolt_1.bin", "start": 1190268, "size": 12, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Thunderbold_2.bin", + "path": "animations/gSpriteAnimations_Thunderbolt_2.bin", "start": 1190280, "size": 28, "type": "animation" diff --git a/data/animations/object/thunderbold.s b/data/animations/object/thunderbold.s deleted file mode 100644 index e221b379..00000000 --- a/data/animations/object/thunderbold.s +++ /dev/null @@ -1,20 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gSpriteAnimations_Thunderbold_0:: @ 0812296C - .include "animations/gSpriteAnimations_Thunderbold_0.s" - -gSpriteAnimations_Thunderbold_1:: @ 0812297C - .include "animations/gSpriteAnimations_Thunderbold_1.s" - -gSpriteAnimations_Thunderbold_2:: @ 08122988 - .include "animations/gSpriteAnimations_Thunderbold_2.s" - -gSpriteAnimations_Thunderbold:: @ 081229A4 - .4byte gSpriteAnimations_Thunderbold_0 - .4byte gSpriteAnimations_Thunderbold_1 - .4byte gSpriteAnimations_Thunderbold_2 - .4byte 00000000 diff --git a/data/animations/object/thunderbolt.s b/data/animations/object/thunderbolt.s new file mode 100644 index 00000000..3b84b360 --- /dev/null +++ b/data/animations/object/thunderbolt.s @@ -0,0 +1,20 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + .align 2 + +gSpriteAnimations_Thunderbolt_0:: @ 0812296C + .include "animations/gSpriteAnimations_Thunderbolt_0.s" + +gSpriteAnimations_Thunderbolt_1:: @ 0812297C + .include "animations/gSpriteAnimations_Thunderbolt_1.s" + +gSpriteAnimations_Thunderbolt_2:: @ 08122988 + .include "animations/gSpriteAnimations_Thunderbolt_2.s" + +gSpriteAnimations_Thunderbolt:: @ 081229A4 + .4byte gSpriteAnimations_Thunderbolt_0 + .4byte gSpriteAnimations_Thunderbolt_1 + .4byte gSpriteAnimations_Thunderbolt_2 + .4byte 00000000 diff --git a/data/gfx/sprite_ptrs.s b/data/gfx/sprite_ptrs.s index d2ebeb6f..364bf75e 100644 --- a/data/gfx/sprite_ptrs.s +++ b/data/gfx/sprite_ptrs.s @@ -825,7 +825,7 @@ gSpritePtrs:: @ 080029B4 .4byte 00000000 .4byte 00000000 - .4byte gSpriteAnimations_Thunderbold + .4byte gSpriteAnimations_Thunderbolt .4byte 00000000 .4byte 00000000 .4byte 00000000 diff --git a/include/asm.h b/include/asm.h index 1f15a0ea..391ba768 100644 --- a/include/asm.h +++ b/include/asm.h @@ -19,7 +19,7 @@ extern void sub_08001290(struct Entity_*, u32); extern void GenericKnockback(struct Entity_*); extern u32 GetFuserId(struct Entity_*); extern u32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY); -extern u32 GravityUpdate(struct Entity_*, u32); +extern u32 GravityUpdate(struct Entity_* entity, u32 gravity); extern u32 CheckOnScreen(struct Entity_*); extern bool32 EntityInRectRadius(struct Entity_*, struct Entity_*, u32, u32); extern void UpdateAnimationVariableFrames(struct Entity_*, u32); diff --git a/include/item.h b/include/item.h index 20087141..ec20160d 100644 --- a/include/item.h +++ b/include/item.h @@ -6,7 +6,6 @@ #include "player.h" void CreateItemEntity(u32, u32, u32); -void sub_08081404(Entity*, u32); extern void ExecuteItemFunction(ItemBehavior* this, u32 index); extern void ItemDebug(ItemBehavior*, u32); diff --git a/include/object.h b/include/object.h index 34160b18..67c000cf 100644 --- a/include/object.h +++ b/include/object.h @@ -134,7 +134,7 @@ typedef enum { EZLO_CAP_FLYING, GIANT_TWIG, OBJECT_63, - THUNDERBOLD, + THUNDERBOLT, LADDER_HOLE, WATER_DROP_OBJECT, GLEEROK_PARTICLE, @@ -330,7 +330,7 @@ void SwordsmanNewsletter(); void EzloCapFlying(); void GiantTwig(); void Object63(); -void Thunderbold(); +void Thunderbolt(); void LadderHoleInBookshelf(); void WaterDropObject(); void GleerokParticle(); diff --git a/include/object/cutsceneOrchestrator.h b/include/object/cutsceneOrchestrator.h new file mode 100644 index 00000000..d5ee110e --- /dev/null +++ b/include/object/cutsceneOrchestrator.h @@ -0,0 +1,12 @@ +#ifndef CUTSCENEORCHESTRATOR_H +#define CUTSCENEORCHESTRATOR_H + +#include "script.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[28]; + /*0x84*/ ScriptExecutionContext* context; +} CutsceneOrchestratorEntity; + +#endif // CUTSCENEORCHESTRATOR_H diff --git a/include/object/itemOnGround.h b/include/object/itemOnGround.h new file mode 100644 index 00000000..47ab89a8 --- /dev/null +++ b/include/object/itemOnGround.h @@ -0,0 +1,18 @@ +#ifndef ITEMONGROUND_H +#define ITEMONGROUND_H + +#include "entity.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68; + /*0x69*/ u8 unk_69; + /*0x6a*/ u8 unk_6a; + /*0x6b*/ u8 unused1[1]; + /*0x6c*/ u16 unk_6c; + /*0x6e*/ u16 unk_6e; + /*0x70*/ u8 unused2[22]; + /*0x86*/ u16 unk_86; +} ItemOnGroundEntity; + +#endif // ITEMONGROUND_H diff --git a/include/object/lilypadLarge.h b/include/object/lilypadLarge.h new file mode 100644 index 00000000..b3cb6192 --- /dev/null +++ b/include/object/lilypadLarge.h @@ -0,0 +1,21 @@ +#ifndef LILYPADLARGE_H +#define LILYPADLARGE_H + +#include "entity.h" + +typedef struct { + Entity base; + u8 unk_68[4]; + s32 unk_6c; + s32 unk_70; + s16 unk_74; + s16 unk_76; + union SplitWord unk_78; + union SplitWord unk_7c; + u8 unk_80[2]; + u16 unk_82; + u8 unk_84; + u8 unk_85; +} LilypadLargeEntity; + +#endif // LILYPADLARGE_H diff --git a/linker.ld b/linker.ld index 479e7328..0bd2b1de 100644 --- a/linker.ld +++ b/linker.ld @@ -706,7 +706,7 @@ SECTIONS { src/object/ezloCapFlying.o(.text); src/object/giantTwig.o(.text); src/object/object63.o(.text); - src/object/thunderbold.o(.text); + src/object/thunderbolt.o(.text); src/object/ladderHoleInBookshelf.o(.text); src/object/waterDropObject.o(.text); src/object/gleerokParticle.o(.text); @@ -1487,8 +1487,8 @@ SECTIONS { src/object/ezloCapFlying.o(.rodata); src/object/giantTwig.o(.rodata); src/object/object63.o(.rodata); - src/object/thunderbold.o(.rodata); - data/animations/object/thunderbold.o(.rodata); + src/object/thunderbolt.o(.rodata); + data/animations/object/thunderbolt.o(.rodata); src/object/ladderHoleInBookshelf.o(.rodata); src/object/gleerokParticle.o(.rodata); src/object/linkEmptyingBottle.o(.rodata); diff --git a/src/manager/vaati3StartManager.c b/src/manager/vaati3StartManager.c index c53528d8..9a57b25a 100644 --- a/src/manager/vaati3StartManager.c +++ b/src/manager/vaati3StartManager.c @@ -71,7 +71,7 @@ void Vaati3StartManager_Type0_Action1(Vaati3StartManager* this) { super->timer = 120; SetPlayerControl(2); sub_08078B48(); - object = CreateObject(THUNDERBOLD, 0, 0); + object = CreateObject(THUNDERBOLT, 0, 0); if (object != NULL) { object->x.HALF.HI = gRoomControls.origin_x + 0x88; object->y.HALF.HI = gRoomControls.origin_y + 0x48; diff --git a/src/object.c b/src/object.c index 96729ee1..58806614 100644 --- a/src/object.c +++ b/src/object.c @@ -102,7 +102,7 @@ void (*const gObjectFunctions[])(Entity*) = { [EZLO_CAP_FLYING] = EzloCapFlying, [GIANT_TWIG] = GiantTwig, [OBJECT_63] = Object63, - [THUNDERBOLD] = Thunderbold, + [THUNDERBOLT] = Thunderbolt, [LADDER_HOLE] = LadderHoleInBookshelf, [WATER_DROP_OBJECT] = WaterDropObject, [GLEEROK_PARTICLE] = GleerokParticle, diff --git a/src/object/ambientClouds.c b/src/object/ambientClouds.c index 3cd73953..c24b16f4 100644 --- a/src/object/ambientClouds.c +++ b/src/object/ambientClouds.c @@ -4,6 +4,7 @@ * * @brief Ambient Clouds object */ +#define NENT_DEPRECATED #include "asm.h" #include "effects.h" #include "entity.h" @@ -27,8 +28,6 @@ void AmbientClouds(Entity* this) { } void AmbientClouds_Init(Entity* this) { - Entity* pEVar2; - #ifndef EU if ((this->flags & ENT_DID_INIT) != 0) { #endif @@ -44,10 +43,10 @@ void AmbientClouds_Init(Entity* this) { this->parent = NULL; CreateObjectWithParent(this, AMBIENT_CLOUDS, 0, 0xff); for (; this->type != 0; --this->type) { - pEVar2 = CreateObjectWithParent(this, AMBIENT_CLOUDS, 0, this->type); - this->child = pEVar2; - if (pEVar2 != NULL) { - pEVar2->parent = this->parent; + Entity* entity = CreateObjectWithParent(this, AMBIENT_CLOUDS, 0, this->type); + this->child = entity; + if (entity != NULL) { + entity->parent = this->parent; if (this->parent != NULL) { this->parent->child = this->child; } @@ -77,9 +76,6 @@ void AmbientClouds_Init(Entity* this) { } void AmbientClouds_Action1(Entity* this) { - int iVar1; - Entity* pEVar2; - if (this->type2 == 0xff) { this->spritePriority.b0 = 7; this->spriteRendering.b3 = 3; @@ -92,8 +88,7 @@ void AmbientClouds_Action1(Entity* this) { else this->timer = 0; this->y.HALF.HI += (this->type2 - 1) * -0x24; - iVar1 = EntityInRectRadius(this, &gPlayerEntity, 0xf, 0xf); - if ((iVar1 != 0) && (this->timer != 0)) { + if (EntityInRectRadius(this, &gPlayerEntity, 15, 15) && (this->timer != 0)) { this->action = 2; this->spriteOrientation.flipY = 2; this->spriteRendering.b3 = 3; @@ -105,21 +100,21 @@ void AmbientClouds_Action1(Entity* this) { gPlayerEntity.z.HALF.HI += 0x24; sub_0807AA80(&gPlayerEntity); if (this->subtimer == 0) { - pEVar2 = CreateFx(&gPlayerEntity, FX_DEATH, 0); - if (pEVar2 != NULL) { - pEVar2->x.HALF.HI += 8; + Entity* fx = CreateFx(&gPlayerEntity, FX_DEATH, 0); + if (fx != NULL) { + fx->x.HALF.HI += 8; } - pEVar2 = CreateFx(&gPlayerEntity, FX_DEATH, 0); - if (pEVar2 != NULL) { - pEVar2->x.HALF.HI -= 8; + fx = CreateFx(&gPlayerEntity, FX_DEATH, 0); + if (fx != NULL) { + fx->x.HALF.HI -= 8; } - pEVar2 = CreateFx(&gPlayerEntity, FX_DEATH, 0); - if (pEVar2 != NULL) { - pEVar2->y.HALF.HI += 8; + fx = CreateFx(&gPlayerEntity, FX_DEATH, 0); + if (fx != NULL) { + fx->y.HALF.HI += 8; } - pEVar2 = CreateFx(&gPlayerEntity, FX_DEATH, 0); - if (pEVar2 != NULL) { - pEVar2->y.HALF.HI -= 8; + fx = CreateFx(&gPlayerEntity, FX_DEATH, 0); + if (fx != NULL) { + fx->y.HALF.HI -= 8; } } } @@ -131,7 +126,7 @@ void AmbientClouds_Action1(Entity* this) { void AmbientClouds_Action2(Entity* this) { this->y.HALF.HI += this->type2 * -0x24; - if (EntityInRectRadius(this, &gPlayerEntity, 0xf, 0xf)) { + if (EntityInRectRadius(this, &gPlayerEntity, 15, 15)) { gPlayerState.field_0x14 = 1; gPlayerState.flags |= PL_FLAGS2; } else { @@ -144,7 +139,7 @@ void AmbientClouds_Action2(Entity* this) { } void AmbientClouds_Action3(Entity* this) { - if (EntityInRectRadius(this, &gPlayerEntity, 0xf, 0xf)) { + if (EntityInRectRadius(this, &gPlayerEntity, 15, 15)) { gPlayerState.field_0x14 = 1; } } diff --git a/src/object/angryStatue.c b/src/object/angryStatue.c index 0204c90e..75e705e3 100644 --- a/src/object/angryStatue.c +++ b/src/object/angryStatue.c @@ -4,6 +4,7 @@ * * @brief Angry Statue object */ +#define NENT_DEPRECATED #include "asm.h" #include "entity.h" #include "hitbox.h" diff --git a/src/object/archway.c b/src/object/archway.c index 76a9df16..2feceae8 100644 --- a/src/object/archway.c +++ b/src/object/archway.c @@ -4,6 +4,7 @@ * * @brief Archway object */ +#define NENT_DEPRECATED #include "entity.h" #include "game.h" diff --git a/src/object/backgroundCloud.c b/src/object/backgroundCloud.c index 658b5e5d..691ff2cb 100644 --- a/src/object/backgroundCloud.c +++ b/src/object/backgroundCloud.c @@ -4,66 +4,74 @@ * * @brief BackgroundCloud object */ +#define NENT_DEPRECATED #include "object.h" -void BackgroundCloud_Init(Entity*); -void BackgroundCloud_Action1(Entity*); -void BackgroundCloud_Action2(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[16]; + /*0x78*/ s16 unk_78; + /*0x7a*/ s16 unk_7a; +} BackgroundCloudEntity; -void BackgroundCloud(Entity* this) { - static void (*const BackgroundCloud_Actions[])(Entity*) = { +void BackgroundCloud_Init(BackgroundCloudEntity* this); +void BackgroundCloud_Action1(BackgroundCloudEntity* this); +void BackgroundCloud_Action2(BackgroundCloudEntity* this); + +void BackgroundCloud(BackgroundCloudEntity* this) { + static void (*const BackgroundCloud_Actions[])(BackgroundCloudEntity*) = { BackgroundCloud_Init, BackgroundCloud_Action1, BackgroundCloud_Action2, }; - BackgroundCloud_Actions[this->action](this); + BackgroundCloud_Actions[super->action](this); } -void BackgroundCloud_Init(Entity* this) { +void BackgroundCloud_Init(BackgroundCloudEntity* this) { static const u8 gUnk_08121EB0[] = { 0x30, 0x28, 0x20 }; - this->action = 1; - this->spriteSettings.draw = 1; - this->spriteOrientation.flipY = 3; - this->spriteRendering.b3 = 3; - this->spritePriority.b0 = this->type; - this->frameIndex = this->type; - this->direction = 8; - this->speed = gUnk_08121EB0[this->type]; - this->field_0x78.HWORD = gRoomControls.origin_x - 0x60; - this->field_0x7a.HWORD = gRoomControls.origin_x + gRoomControls.width + 0x60; - this->animationState = 0; - this->x.HALF.HI += (Random() & 0xf) << 4; - this->timer = 0; - this->subAction = 0; + super->action = 1; + super->spriteSettings.draw = 1; + super->spriteOrientation.flipY = 3; + super->spriteRendering.b3 = 3; + super->spritePriority.b0 = super->type; + super->frameIndex = super->type; + super->direction = 8; + super->speed = gUnk_08121EB0[super->type]; + this->unk_78 = gRoomControls.origin_x - 0x60; + this->unk_7a = gRoomControls.origin_x + gRoomControls.width + 0x60; + super->animationState = 0; + super->x.HALF.HI += (Random() & 0xf) << 4; + super->timer = 0; + super->subAction = 0; } -void BackgroundCloud_Action1(Entity* this) { - LinearMoveUpdate(this); +void BackgroundCloud_Action1(BackgroundCloudEntity* this) { + LinearMoveUpdate(super); - if ((s16)this->x.HALF.HI < (s16)this->field_0x78.HWORD || (s16)this->x.HALF.HI > (s16)this->field_0x7a.HWORD) - this->action = 2; + if (super->x.HALF.HI < this->unk_78 || super->x.HALF.HI > this->unk_7a) + super->action = 2; } -void BackgroundCloud_Action2(Entity* this) { +void BackgroundCloud_Action2(BackgroundCloudEntity* this) { static const u8 gUnk_08121EB3[] = { 0x8, 0x28, 0x48, 0x98, 0 }; - if (this->subAction == 0) { - this->subAction = 1; - this->timer = ((Random() & 7) << 3) + 31; + if (super->subAction == 0) { + super->subAction = 1; + super->timer = ((Random() & 7) << 3) + 31; - if ((this->direction & 0x10)) { - this->x.HALF.HI = this->field_0x7a.HWORD; + if ((super->direction & 0x10)) { + super->x.HALF.HI = this->unk_7a; } else { - this->x.HALF.HI = this->field_0x78.HWORD; + super->x.HALF.HI = this->unk_78; } - if (this->type == 2) - this->y.HALF.HI = gUnk_08121EB3[this->type2 * 2 + (Random() & 1)]; + if (super->type == 2) + super->y.HALF.HI = gUnk_08121EB3[super->type2 * 2 + (Random() & 1)]; } - if (this->subAction == 1) { - if (--this->timer == 0) { - this->action = 1; - this->subAction = 0; + if (super->subAction == 1) { + if (--super->timer == 0) { + super->action = 1; + super->subAction = 0; } } } diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index f1689675..a84472db 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -4,74 +4,81 @@ * * @brief Baker Oven object */ +#define NENT_DEPRECATED #include "functions.h" #include "object.h" -extern void SoundReqClipped(Entity*, u32); -void sub_0809CDF0(Entity*); -void BakerOven_Init(Entity*); -void BakerOven_Action1(Entity*); -void BakerOven_Action2(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[24]; + /*0x80*/ u16 unk_80; +} BakerOvenEntity; -void BakerOven(Entity* this) { - static void (*const BakerOven_Actions[])(Entity*) = { +extern void SoundReqClipped(Entity*, u32); +void sub_0809CDF0(BakerOvenEntity* this); +void BakerOven_Init(BakerOvenEntity* this); +void BakerOven_Action1(BakerOvenEntity* this); +void BakerOven_Action2(BakerOvenEntity* this); + +void BakerOven(BakerOvenEntity* this) { + static void (*const BakerOven_Actions[])(BakerOvenEntity*) = { BakerOven_Init, BakerOven_Action1, BakerOven_Action2, }; - BakerOven_Actions[this->action](this); + BakerOven_Actions[super->action](this); } -void BakerOven_Init(Entity* this) { +void BakerOven_Init(BakerOvenEntity* this) { u32 i; - Entity* ent; + Entity* entity; - this->action = 1; - UpdateSpriteForCollisionLayer(this); + super->action = 1; + UpdateSpriteForCollisionLayer(super); - if (this->type == 0) { - this->spritePriority.b0 = 5; + if (super->type == 0) { + super->spritePriority.b0 = 5; /* Create steam clouds */ for (i = 0; i < 3; i++) { - ent = CreateObject(BAKER_OVEN, 1, i); - if (ent != NULL) { - ent->parent = this; - PositionRelative(this, ent, 16 * Q_16_16((i + 1) / 2) - Q_16_16(8.0), Q_16_16(-14.0)); + entity = CreateObject(BAKER_OVEN, 1, i); + if (entity != NULL) { + entity->parent = super; + PositionRelative(super, entity, 16 * Q_16_16((i + 1) / 2) - Q_16_16(8.0), Q_16_16(-14.0)); } } sub_0809CDF0(this); } else { - if (this->type2 & 1) { - this->spriteSettings.draw = 1; - this->timer = 20; + if (super->type2 & 1) { + super->spriteSettings.draw = 1; + super->timer = 20; } else { - this->action = 2; - this->timer = (this->type2 & 2) ? 20 : 18; + super->action = 2; + super->timer = (super->type2 & 2) ? 20 : 18; } - InitializeAnimation(this, 0); + InitializeAnimation(super, 0); } } -void BakerOven_Action1(Entity* this) { - u8* frames; +void BakerOven_Action1(BakerOvenEntity* this) { + u8* frame; - if (this->type) { - GetNextFrame(this); - frames = &this->frame; - if (this->frame & 1) { - this->frame &= ~1; - this->y.HALF.HI++; + if (super->type) { + GetNextFrame(super); + frame = &super->frame; + if (super->frame & 1) { + super->frame &= ~1; + super->y.HALF.HI++; } - if ((*frames & ANIM_DONE) && this->frameDuration == 1) { - this->action = 2; - this->spriteSettings.draw = 0; + if ((*frame & ANIM_DONE) && super->frameDuration == 1) { + super->action = 2; + super->spriteSettings.draw = 0; } /* Damage minish link if he touches a steam cloud */ - if (this->subtimer == 0 && gPlayerEntity.iframes == 0 && this->frameIndex && - sub_0806FC80(this, &gPlayerEntity, 4)) { - this->subtimer++; + if (super->subtimer == 0 && gPlayerEntity.iframes == 0 && super->frameIndex && + sub_0806FC80(super, &gPlayerEntity, 4)) { + super->subtimer++; ModHealth(-2); SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6); gPlayerEntity.iframes = 16; @@ -82,31 +89,31 @@ void BakerOven_Action1(Entity* this) { } } -void BakerOven_Action2(Entity* this) { +void BakerOven_Action2(BakerOvenEntity* this) { /* Reset cloud position and start animation. */ - if (--this->timer == 0) { - this->action = 1; - this->timer = 30; - this->subtimer = 0; - this->spriteSettings.draw = 1; - this->y.HALF.HI = this->parent->y.HALF.HI - 0xe; - InitializeAnimation(this, 0); + if (--super->timer == 0) { + super->action = 1; + super->timer = 30; + super->subtimer = 0; + super->spriteSettings.draw = 1; + super->y.HALF.HI = super->parent->y.HALF.HI - 0xe; + InitializeAnimation(super, 0); } } -void sub_0809CDF0(Entity* this) { +void sub_0809CDF0(BakerOvenEntity* this) { u32 y; - this->field_0x80.HWORD = (((this->x.HALF.HI - gRoomControls.origin_x) >> 4) & 0x3f) | - (((this->y.HALF.HI - gRoomControls.origin_y) >> 4 & 0x3f) << 6); + this->unk_80 = (((super->x.HALF.HI - gRoomControls.origin_x) >> 4) & 0x3f) | + (((super->y.HALF.HI - gRoomControls.origin_y) >> 4 & 0x3f) << 6); - y = this->field_0x80.HWORD; - SetTile(0x402e, y - 0x01, this->collisionLayer); - SetTile(0x4022, y - 0x00, this->collisionLayer); - SetTile(0x4022, y + 0x01, this->collisionLayer); - SetTile(0x4026, y - 0x41, this->collisionLayer); - SetTile(0x4026, y - 0x40, this->collisionLayer); - SetTile(0x4024, y - 0x3f, this->collisionLayer); - SetTile(0x4026, y - 0x81, this->collisionLayer); - SetTile(0x4026, y - 0x80, this->collisionLayer); + y = this->unk_80; + SetTile(0x402e, y - 0x01, super->collisionLayer); + SetTile(0x4022, y - 0x00, super->collisionLayer); + SetTile(0x4022, y + 0x01, super->collisionLayer); + SetTile(0x4026, y - 0x41, super->collisionLayer); + SetTile(0x4026, y - 0x40, super->collisionLayer); + SetTile(0x4024, y - 0x3f, super->collisionLayer); + SetTile(0x4026, y - 0x81, super->collisionLayer); + SetTile(0x4026, y - 0x80, super->collisionLayer); } diff --git a/src/object/barrelInside.c b/src/object/barrelInside.c index 3ef99da4..1bd43f7e 100644 --- a/src/object/barrelInside.c +++ b/src/object/barrelInside.c @@ -4,6 +4,7 @@ * * @brief Barrel Inside object */ +#define NENT_DEPRECATED #include "entity.h" typedef struct { diff --git a/src/object/barrelSpiderweb.c b/src/object/barrelSpiderweb.c index 3e555ece..a3dcc448 100644 --- a/src/object/barrelSpiderweb.c +++ b/src/object/barrelSpiderweb.c @@ -4,149 +4,143 @@ * * @brief Barrel Spiderweb object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" -typedef struct { - /*0x00*/ Entity base; -} BarrelSpiderwebEntity; +void BarrelSpiderweb_Init(Entity*); +void BarrelSpiderweb_Action1(Entity*); +void BarrelSpiderweb_Action2(Entity*); +void sub_0808BDB0(Entity*); +void sub_0808BBE0(Entity*); +void sub_0808BD00(Entity*); -void BarrelSpiderweb_Init(BarrelSpiderwebEntity*); -void BarrelSpiderweb_Action1(BarrelSpiderwebEntity*); -void BarrelSpiderweb_Action2(BarrelSpiderwebEntity*); -void sub_0808BDB0(BarrelSpiderwebEntity*); -void sub_0808BBE0(BarrelSpiderwebEntity*); -void sub_0808BD00(BarrelSpiderwebEntity*); - -void BarrelSpiderweb(BarrelSpiderwebEntity* this) { - static void (*const BarrelSpiderweb_Actions[])(BarrelSpiderwebEntity*) = { +void BarrelSpiderweb(Entity* this) { + static void (*const BarrelSpiderweb_Actions[])(Entity*) = { BarrelSpiderweb_Init, BarrelSpiderweb_Action1, BarrelSpiderweb_Action2, }; - BarrelSpiderweb_Actions[super->action](this); + BarrelSpiderweb_Actions[this->action](this); } -void BarrelSpiderweb_Init(BarrelSpiderwebEntity* this) { +void BarrelSpiderweb_Init(Entity* this) { if (CheckGlobalFlag(LV1TARU_OPEN)) { LoadGfxGroup(0x4a); DeleteThisEntity(); } else { - super->action = 1; - super->flags |= ENT_COLLIDE; - super->timer = 120; - super->subtimer = 0; - super->spriteRendering.b3 = 3; - super->spritePriority.b0 = 4; - super->spriteOrientation.flipY = 2; - super->speed = 0x300; - super->hitType = 1; - super->collisionFlags = 7; - super->hurtType = 0x48; - super->flags2 = 4; - super->hitbox = (Hitbox*)&gHitbox_0; - super->frameIndex = 2; - super->collisionLayer = gPlayerEntity.collisionLayer; + this->action = 1; + this->flags |= ENT_COLLIDE; + this->timer = 120; + this->subtimer = 0; + this->spriteRendering.b3 = 3; + this->spritePriority.b0 = 4; + this->spriteOrientation.flipY = 2; + this->speed = 0x300; + this->hitType = 1; + this->collisionFlags = 7; + this->hurtType = 0x48; + this->flags2 = 4; + this->hitbox = (Hitbox*)&gHitbox_0; + this->frameIndex = 2; + this->collisionLayer = gPlayerEntity.collisionLayer; sub_0808BDB0(this); - super->y.HALF.HI = 0x170 - (super->parent)->zVelocity; + this->y.HALF.HI = 0x170 - (this->parent)->zVelocity; sub_0808BBE0(this); } } -void sub_0808BBE0(BarrelSpiderwebEntity* this) { +void sub_0808BBE0(Entity* this) { static const u16 gUnk_0812144C[] = { 192, 256, 208, 240, 224, 224, 240, 208, 256, 192, 256, 192, 240, 208, 224, 224, 208, 240, 192, 256 }; static const u8 gUnk_08121474[] = { 248, 250, 252, 254, 0, 0, 2, 4, 6, 8, 0, 0, }; const u16* ptr; - s32 diff = super->y.HALF.HI - gRoomControls.scroll_y; + s32 diff = this->y.HALF.HI - gRoomControls.scroll_y; if ((u32)diff < 0xa0) { diff /= 0x10; - super->spriteOffsetY = gUnk_08121474[diff]; + this->spriteOffsetY = gUnk_08121474[diff]; ptr = &gUnk_0812144C[diff * 2]; - SetAffineInfo(super, ptr[0], ptr[1], 0); + SetAffineInfo(this, ptr[0], ptr[1], 0); } else { - super->contactFlags &= ~0x80; + this->contactFlags &= ~0x80; } } -void BarrelSpiderweb_Action1(BarrelSpiderwebEntity* this) { +void BarrelSpiderweb_Action1(Entity* this) { s32 tmp; - super->x.HALF.HI = gRoomControls.origin_x + 0x78; + this->x.HALF.HI = gRoomControls.origin_x + 0x78; tmp = -0x170; - super->y.HALF.HI = gRoomControls.origin_y - ((super->parent)->zVelocity + tmp); + this->y.HALF.HI = gRoomControls.origin_y - ((this->parent)->zVelocity + tmp); sub_0808BBE0(this); - if (super->contactFlags == 0x93) { - super->timer--; - super->spriteSettings.draw = 1; - if (super->timer == 0) { + if (this->contactFlags == 0x93) { + this->timer--; + this->spriteSettings.draw = 1; + if (this->timer == 0) { SetGlobalFlag(LV1TARU_OPEN); - super->action = 2; - super->subtimer = 128; - super->spriteOffsetY = 0; + this->action = 2; + this->subtimer = 128; + this->spriteOffsetY = 0; } else { - if ((super->timer & 1) != 0) { - super->x.HALF.HI += ((Random() & 3) - 2); - super->y.HALF.HI += ((Random() & 3) - 1); + if ((this->timer & 1) != 0) { + this->x.HALF.HI += ((Random() & 3) - 2); + this->y.HALF.HI += ((Random() & 3) - 1); } - if (super->subtimer != 1) { - super->subtimer = 1; + if (this->subtimer != 1) { + this->subtimer = 1; LoadGfxGroup(0x4a); } } } else { - super->timer = 120; - super->spriteSettings.draw = 0; - if (super->subtimer != 0) { - super->subtimer = 0; + this->timer = 120; + this->spriteSettings.draw = 0; + if (this->subtimer != 0) { + this->subtimer = 0; LoadGfxGroup(0x49); } } } -void sub_0808BD00(BarrelSpiderwebEntity* this) { +void sub_0808BD00(Entity* this) { SetGlobalFlag(LV1TARU_OPEN); SoundReq(SFX_SECRET); DeleteThisEntity(); } -void BarrelSpiderweb_Action2(BarrelSpiderwebEntity* this) { +void BarrelSpiderweb_Action2(Entity* this) { - if (super->subtimer != 0) { - super->subtimer -= 8; - SetAffineInfo(super, 0x200 - super->subtimer, 0x200 - super->subtimer, 0); + if (this->subtimer != 0) { + this->subtimer -= 8; + SetAffineInfo(this, 0x200 - this->subtimer, 0x200 - this->subtimer, 0); } - if (super->contactFlags == 0x93) { - super->direction = GetFacingDirection(super, &gPlayerEntity); - LinearMoveUpdate(super); - if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 6, 0x1c)) { + if (this->contactFlags == 0x93) { + this->direction = GetFacingDirection(this, &gPlayerEntity); + LinearMoveUpdate(this); + if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 6, 0x1c)) { sub_0808BD00(this); } } else { - if ((super->flags & ENT_COLLIDE) != 0) { - super->flags &= ~ENT_COLLIDE; - super->timer = 30; + if ((this->flags & ENT_COLLIDE) != 0) { + this->flags &= ~ENT_COLLIDE; + this->timer = 30; } else { - super->spriteSettings.draw ^= 1; - if (--super->timer == 0) { + this->spriteSettings.draw ^= 1; + if (--this->timer == 0) { sub_0808BD00(this); } } } } -void sub_0808BDB0(BarrelSpiderwebEntity* this) { +void sub_0808BDB0(Entity* this) { LinkedList* list = &gEntityLists[6]; Entity* it = list->first; - super->parent = NULL; + this->parent = NULL; for (; it != (Entity*)list; it = it->next) { if (it->kind == 0x9 && it->id == 0xc) { - super->parent = it; + this->parent = it; return; } } diff --git a/src/object/beanstalk.c b/src/object/beanstalk.c index 801c89d2..d265052e 100644 --- a/src/object/beanstalk.c +++ b/src/object/beanstalk.c @@ -5,9 +5,8 @@ * @brief Beanstalk object */ #define NENT_DEPRECATED -#include "global.h" -#include "object.h" #include "functions.h" +#include "object.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/bedCover.c b/src/object/bedCover.c index fe21b77e..7e9f62a3 100644 --- a/src/object/bedCover.c +++ b/src/object/bedCover.c @@ -4,10 +4,8 @@ * * @brief Bed Cover object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/bell.c b/src/object/bell.c index 28edcb79..59d9baf5 100644 --- a/src/object/bell.c +++ b/src/object/bell.c @@ -4,28 +4,29 @@ * * @brief Bell object */ +#define NENT_DEPRECATED #include "object.h" -void Bell_Init(Entity*); -void Bell_Action1(Entity*); +void Bell_Init(Entity* this); +void Bell_Action1(Entity* this); -void Bell(Entity* ent) { +void Bell(Entity* this) { static void (*const Bell_Actions[])(Entity*) = { Bell_Init, Bell_Action1, }; - Bell_Actions[ent->action](ent); + Bell_Actions[this->action](this); } -void Bell_Init(Entity* ent) { - ent->action = 1; - ent->spriteSettings.draw = 1; - ent->collisionLayer = 1; - ent->spritePriority.b0 = 0; - UpdateSpriteForCollisionLayer(ent); - InitAnimationForceUpdate(ent, 0); +void Bell_Init(Entity* this) { + this->action = 1; + this->spriteSettings.draw = 1; + this->collisionLayer = 1; + this->spritePriority.b0 = 0; + UpdateSpriteForCollisionLayer(this); + InitAnimationForceUpdate(this, 0); } -void Bell_Action1(Entity* ent) { - UpdateAnimationSingleFrame(ent); +void Bell_Action1(Entity* this) { + UpdateAnimationSingleFrame(this); } diff --git a/src/object/bench.c b/src/object/bench.c index 47514668..5c196409 100644 --- a/src/object/bench.c +++ b/src/object/bench.c @@ -16,8 +16,8 @@ typedef struct { u16 tilePos; } BenchEntity; -void Bench_Init(BenchEntity*); -void Bench_Action1(BenchEntity*); +void Bench_Init(BenchEntity* this); +void Bench_Action1(BenchEntity* this); void Bench(Entity* this) { static void (*const Bench_Actions[])(BenchEntity*) = { diff --git a/src/object/bigBarrel.c b/src/object/bigBarrel.c index f40c90a3..2ecc63be 100644 --- a/src/object/bigBarrel.c +++ b/src/object/bigBarrel.c @@ -16,17 +16,17 @@ typedef struct { Entity base; - const u8* unk68; + const u8* unk_68; } BigBarrelEntity; -void sub_08088A68(BigBarrelEntity*); -void sub_08088C9C(BigBarrelEntity*); -void sub_08088DB4(BigBarrelEntity*); -void sub_08088E74(BigBarrelEntity*); -void sub_08088F20(BigBarrelEntity*); -void sub_08088BE0(BigBarrelEntity*); -void sub_08089094(BigBarrelEntity*); -void sub_080890EC(BigBarrelEntity*, const s16*, s32); +void BigBarrel_Type0(BigBarrelEntity* this); +void BigBarrel_Type1(BigBarrelEntity* this); +void BigBarrel_Type2(BigBarrelEntity* this); +void BigBarrel_Type3(BigBarrelEntity* this); +void BigBarrel_Type4(BigBarrelEntity* this); +void sub_08088BE0(BigBarrelEntity* this); +void sub_08089094(BigBarrelEntity* this); +void sub_080890EC(BigBarrelEntity* this, const s16*, s32); Entity* sub_08088C78(BigBarrelEntity*, u32, u32, u32); @@ -38,13 +38,13 @@ const s8 gUnk_08120C25[] = { 5, 0, 4, 0, 4, 0, 2, 0, -1 }; const s8 gUnk_08120C2E[] = { 3, 0, -1, 0, 0, 0 }; void BigBarrel(Entity* this) { - static void (*const typeFuncs[])(BigBarrelEntity*) = { - sub_08088A68, sub_08088C9C, sub_08088DB4, sub_08088E74, sub_08088F20, + static void (*const BigBarrel_Types[])(BigBarrelEntity*) = { + BigBarrel_Type0, BigBarrel_Type1, BigBarrel_Type2, BigBarrel_Type3, BigBarrel_Type4, }; - typeFuncs[this->type]((BigBarrelEntity*)this); + BigBarrel_Types[this->type]((BigBarrelEntity*)this); } -void sub_08088A68(BigBarrelEntity* this) { +void BigBarrel_Type0(BigBarrelEntity* this) { u32 uVar3; const u8* pcVar3; @@ -66,30 +66,30 @@ void sub_08088A68(BigBarrelEntity* this) { if (gRoomVars.animFlags & 1) { gRoomVars.animFlags &= ~1; super->timer = 1; - this->unk68 = gUnk_08120C1C; + this->unk_68 = gUnk_08120C1C; SoundReq(SFX_BARREL_ENTER); } if (gRoomVars.animFlags & 2) { gRoomVars.animFlags &= ~2; super->timer = 1; - this->unk68 = gUnk_08120C25; + this->unk_68 = gUnk_08120C25; SoundReq(SFX_BARREL_RELEASE); } if (gRoomVars.animFlags & 4) { gRoomVars.animFlags &= ~4; super->timer = 1; - this->unk68 = gUnk_08120C2E; + this->unk_68 = gUnk_08120C2E; SoundReq(SFX_BARREL_ENTER); } if (super->timer) { if (super->timer-- == 1) { - pcVar3 = this->unk68; + pcVar3 = this->unk_68; uVar3 = pcVar3[0]; *(u8*)&super->spriteOffsetY = uVar3; pcVar3++; if (*pcVar3 != 0xff) { super->timer = 8; - this->unk68 = pcVar3; + this->unk_68 = pcVar3; } else { super->spriteOffsetY = 0; } @@ -141,7 +141,7 @@ Entity* sub_08088C78(BigBarrelEntity* this, u32 type, u32 type2, u32 xOffset) { return pEVar1; } -void sub_08088C9C(BigBarrelEntity* this) { +void BigBarrel_Type1(BigBarrelEntity* this) { static const u8 gUnk_08120C48[] = { 2, 3, 4, 5, 6, 7, 7, 7 }; static const s8 gUnk_08120C50[] = { 8, -8 }; u32 localFlag; @@ -201,7 +201,7 @@ void sub_08088C9C(BigBarrelEntity* this) { } } -void sub_08088DB4(BigBarrelEntity* this) { +void BigBarrel_Type2(BigBarrelEntity* this) { switch (super->action) { case 0: super->action = 1; @@ -240,7 +240,7 @@ void sub_08088DB4(BigBarrelEntity* this) { } } -void sub_08088E74(BigBarrelEntity* this) { +void BigBarrel_Type3(BigBarrelEntity* this) { static const s8 gUnk_08120C52[] = { -2, 0, 2, 0 }; Entity* ent; @@ -266,8 +266,8 @@ void sub_08088E74(BigBarrelEntity* this) { } } -void sub_08088F20(BigBarrelEntity* this) { - Entity* pEVar3; +void BigBarrel_Type4(BigBarrelEntity* this) { + Entity* flame; switch (super->action) { case 0: @@ -285,13 +285,13 @@ void sub_08088F20(BigBarrelEntity* this) { super->action = 2; super->timer = 30; RequestPriorityDuration(super, 270); - pEVar3 = CreateObject(FLAME, 1, 0); - if (pEVar3 != NULL) { - pEVar3->updatePriority = 3; - pEVar3->x.HALF.HI = super->x.HALF.HI; - pEVar3->y.HALF.HI = super->y.HALF.HI; - pEVar3->collisionLayer = 2; - pEVar3->spritePriority.b0 = 2; + flame = CreateObject(FLAME, 1, 0); + if (flame != NULL) { + flame->updatePriority = 3; + flame->x.HALF.HI = super->x.HALF.HI; + flame->y.HALF.HI = super->y.HALF.HI; + flame->collisionLayer = 2; + flame->spritePriority.b0 = 2; } SetTileType(0x76, COORD_TO_TILE(super), 2); break; diff --git a/src/object/bigIceBlock.c b/src/object/bigIceBlock.c index b52fe780..6ad61e85 100644 --- a/src/object/bigIceBlock.c +++ b/src/object/bigIceBlock.c @@ -4,10 +4,8 @@ * * @brief Big Ice Block object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "item.h" #include "object.h" diff --git a/src/object/bigPushableLever.c b/src/object/bigPushableLever.c index 1f62e640..be0c1a32 100644 --- a/src/object/bigPushableLever.c +++ b/src/object/bigPushableLever.c @@ -4,10 +4,8 @@ * * @brief Big Pushable Lever object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c index 6d11e27a..f7bacd3d 100644 --- a/src/object/bigVortex.c +++ b/src/object/bigVortex.c @@ -4,92 +4,98 @@ * * @brief Big Vortex object */ +#define NENT_DEPRECATED #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "object.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[30]; + /*0x86*/ u16 unk_86; +} BigVortexEntity; + void sub_08098E3C(Entity*); void sub_08098E88(Entity*); -void BigVortex_Init(Entity*); -void BigVortex_Action1(Entity*); -void BigVortex_Action2(Entity*); -void BigVortex_Action3(Entity*); -void BigVortex_Action4(Entity*); +void BigVortex_Init(BigVortexEntity* this); +void BigVortex_Action1(BigVortexEntity* this); +void BigVortex_Action2(BigVortexEntity* this); +void BigVortex_Action3(BigVortexEntity* this); +void BigVortex_Action4(BigVortexEntity* this); -void BigVortex(Entity* this) { - static void (*const BigVortex_Actions[])(Entity*) = { +void BigVortex(BigVortexEntity* this) { + static void (*const BigVortex_Actions[])(BigVortexEntity*) = { BigVortex_Init, BigVortex_Action1, BigVortex_Action2, BigVortex_Action3, BigVortex_Action4, }; - if (this->type == 0) { - BigVortex_Actions[this->action](this); + if (super->type == 0) { + BigVortex_Actions[super->action](this); } else { - sub_08098E3C(this); + sub_08098E3C(super); } } -void BigVortex_Init(Entity* this) { +void BigVortex_Init(BigVortexEntity* this) { u32 temp; - this->action = 1; - this->z.HALF.HI = -0x10; + super->action = 1; + super->z.HALF.HI = -0x10; - temp = this->field_0x86.HWORD; + temp = this->unk_86; if ((temp != 0) && !CheckFlags(temp)) { - this->action = 1; + super->action = 1; } else { - this->action = 3; - this->spriteSettings.draw = TRUE; - sub_08098E88(this); + super->action = 3; + super->spriteSettings.draw = TRUE; + sub_08098E88(super); } - SetDefaultPriority(this, PRIO_PLAYER_EVENT); - InitAnimationForceUpdate(this, 0); + SetDefaultPriority(super, PRIO_PLAYER_EVENT); + InitAnimationForceUpdate(super, 0); } -void BigVortex_Action1(Entity* this) { - Entity* ent; +void BigVortex_Action1(BigVortexEntity* this) { + Entity* fx; - if (CheckFlags(this->field_0x86.HWORD)) { - this->action = 2; - this->timer = 45; - ent = CreateFx(this, FX_BIG_EXPLOSION2, 0); - if (ent != NULL) { - ent->y.HALF.HI += 8; + if (CheckFlags(this->unk_86)) { + super->action = 2; + super->timer = 45; + fx = CreateFx(super, FX_BIG_EXPLOSION2, 0); + if (fx != NULL) { + fx->y.HALF.HI += 8; } } } -void BigVortex_Action2(Entity* this) { - if (--this->timer == 0) { - this->action = 3; - this->spriteSettings.draw = TRUE; - sub_08098E88(this); +void BigVortex_Action2(BigVortexEntity* this) { + if (--super->timer == 0) { + super->action = 3; + super->spriteSettings.draw = TRUE; + sub_08098E88(super); } } -void BigVortex_Action3(Entity* this) { +void BigVortex_Action3(BigVortexEntity* this) { - if (sub_0800419C(this, &gPlayerEntity, 8, 8) != 0) { - CopyPosition(this, &gPlayerEntity); - sub_08004542(this); + if (sub_0800419C(super, &gPlayerEntity, 8, 8) != 0) { + CopyPosition(super, &gPlayerEntity); + sub_08004542(super); sub_08004542(&gPlayerEntity); gPlayerEntity.collisionLayer = 1; - SortEntityAbove(this, &gPlayerEntity); + SortEntityAbove(super, &gPlayerEntity); gPlayerState.queued_action = PLAYER_PARACHUTE; gPlayerState.field_0x38 = 1; - gPlayerState.field_0x39 = this->type2; - this->action = 4; - if (this->type2 == 1) { + gPlayerState.field_0x39 = super->type2; + super->action = 4; + if (super->type2 == 1) { SetGlobalFlag(TATSUMAKI); } PutAwayItems(); } - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } -void BigVortex_Action4(Entity* this) { - UpdateAnimationSingleFrame(this); +void BigVortex_Action4(BigVortexEntity* this) { + UpdateAnimationSingleFrame(super); } void sub_08098E3C(Entity* this) { diff --git a/src/object/bird.c b/src/object/bird.c index e6243f22..2fc5ed83 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -4,234 +4,241 @@ * * @brief Bird object */ +#define NENT_DEPRECATED #include "collision.h" #include "functions.h" #include "game.h" #include "item.h" #include "message.h" #include "object.h" +#include "object/cutsceneOrchestrator.h" #include "save.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ s16 gravity; +} BirdEntity; + extern u16 script_EzloTalkOcarina[]; -void Bird_Type0(Entity*); -void Bird_Type1(Entity*); -void Bird_Type2(Entity*); -void Bird_Type3(Entity*); -void Bird_Type8(Entity*); -void Bird_Type9(Entity*); -void Bird_Type10(Entity*); -void Bird_Type0_Init(Entity*); -void Bird_Type0_Action1(Entity*); -void Bird_Type1_Init(Entity*); -void Bird_Type1_Action1(Entity*); -void Bird_Type1_Action1_Subaction0(Entity*); -void Bird_Type1_Action1_Subaction1(Entity*); -void Bird_Type2_Init(Entity*); -void Bird_Type2_Action1(Entity*); +void Bird_Type0(BirdEntity* this); +void Bird_Type1(BirdEntity* this); +void Bird_Type2(BirdEntity* this); +void Bird_Type3(BirdEntity* this); +void Bird_Type8(BirdEntity* this); +void Bird_Type9(BirdEntity* this); +void Bird_Type10(BirdEntity* this); +void Bird_Type0_Init(BirdEntity* this); +void Bird_Type0_Action1(BirdEntity* this); +void Bird_Type1_Init(BirdEntity* this); +void Bird_Type1_Action1(BirdEntity* this); +void Bird_Type1_Action1_Subaction0(BirdEntity* this); +void Bird_Type1_Action1_Subaction1(BirdEntity* this); +void Bird_Type2_Init(BirdEntity* this); +void Bird_Type2_Action1(BirdEntity* this); -void Bird(Entity* this) { - static void (*const typeFuncs[])(Entity*) = { +void Bird(BirdEntity* this) { + static void (*const typeFuncs[])(BirdEntity*) = { Bird_Type0, Bird_Type1, Bird_Type2, Bird_Type3, Bird_Type3, Bird_Type3, Bird_Type3, Bird_Type3, Bird_Type8, Bird_Type9, Bird_Type10, }; - typeFuncs[this->type](this); + typeFuncs[super->type](this); } -void Bird_Type0(Entity* this) { - static void (*const Bird_Type0_Actions[])(Entity*) = { +void Bird_Type0(BirdEntity* this) { + static void (*const Bird_Type0_Actions[])(BirdEntity*) = { Bird_Type0_Init, Bird_Type0_Action1, }; - Bird_Type0_Actions[this->action](this); + Bird_Type0_Actions[super->action](this); } -void Bird_Type0_Init(Entity* this) { +void Bird_Type0_Init(BirdEntity* this) { Entity* target; - this->action++; - this->spriteSettings.draw = TRUE; - this->timer = 49; - this->subtimer = 1; - this->zVelocity = Q_16_16(-1.5); - this->z.WORD = Q_16_16(-56.75); - this->field_0x68.HWORD = Q_8_8(-8.0); - this->speed = 0x280; - this->direction = 8; - this->collisionLayer = 2; - this->x.HALF.HI = gRoomControls.scroll_x; + super->action++; + super->spriteSettings.draw = TRUE; + super->timer = 49; + super->subtimer = 1; + super->zVelocity = Q_16_16(-1.5); + super->z.WORD = Q_16_16(-56.75); + this->gravity = Q_8_8(-8.0); + super->speed = 0x280; + super->direction = 8; + super->collisionLayer = 2; + super->x.HALF.HI = gRoomControls.scroll_x; SoundReq(SFX_123); - UpdateSpriteForCollisionLayer(this); - InitAnimationForceUpdate(this, 0); + UpdateSpriteForCollisionLayer(super); + InitAnimationForceUpdate(super, 0); target = CreateObject(BIRD, 1, 0); if (target != NULL) { - target->parent = this; - PositionRelative(this, target, 0, Q_16_16(8.0)); - SortEntityAbove(this, target); + target->parent = super; + PositionRelative(super, target, 0, Q_16_16(8.0)); + SortEntityAbove(super, target); } } -void Bird_Type0_Action1(Entity* this) { - LinearMoveUpdate(this); - GravityUpdate(this, *(s16*)&this->field_0x68.HWORD); - if (this->timer != 0) { - if (--this->timer == 0) { - this->subtimer = 0; +void Bird_Type0_Action1(BirdEntity* this) { + LinearMoveUpdate(super); + GravityUpdate(super, this->gravity); + if (super->timer != 0) { + if (--super->timer == 0) { + super->subtimer = 0; } - } else if (CheckOnScreen(this) == 0) { + } else if (CheckOnScreen(super) == 0) { DeleteThisEntity(); } - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } -void Bird_Type1(Entity* this) { - static void (*const Bird_Type1_Actions[])(Entity*) = { +void Bird_Type1(BirdEntity* this) { + static void (*const Bird_Type1_Actions[])(BirdEntity*) = { Bird_Type1_Init, Bird_Type1_Action1, }; - Bird_Type1_Actions[this->action](this); + Bird_Type1_Actions[super->action](this); } -void Bird_Type1_Init(Entity* this) { - this->action++; - this->collisionLayer = 1; - UpdateSpriteForCollisionLayer(this); - InitAnimationForceUpdate(this, 0x17); +void Bird_Type1_Init(BirdEntity* this) { + super->action++; + super->collisionLayer = 1; + UpdateSpriteForCollisionLayer(super); + InitAnimationForceUpdate(super, 0x17); } -void Bird_Type1_Action1(Entity* this) { - static void (*const Bird_Type1_Action1_Subactions[])(Entity*) = { +void Bird_Type1_Action1(BirdEntity* this) { + static void (*const Bird_Type1_Action1_Subactions[])(BirdEntity*) = { Bird_Type1_Action1_Subaction0, Bird_Type1_Action1_Subaction1, }; - Bird_Type1_Action1_Subactions[this->subAction](this); + Bird_Type1_Action1_Subactions[super->subAction](this); } -void Bird_Type1_Action1_Subaction0(Entity* this) { +void Bird_Type1_Action1_Subaction0(BirdEntity* this) { u32 temp; - if (this->parent != NULL) { - temp = this->parent->subtimer; + if (super->parent != NULL) { + temp = super->parent->subtimer; if (temp != 0) { - PositionRelative(this->parent, this, 0, Q_16_16(8.0)); + PositionRelative(super->parent, super, 0, Q_16_16(8.0)); } else { - this->subAction++; - this->zVelocity = temp; + super->subAction++; + super->zVelocity = temp; } } } -void Bird_Type1_Action1_Subaction1(Entity* this) { +void Bird_Type1_Action1_Subaction1(BirdEntity* this) { Entity* fx; - if (sub_080044EC(this, 0x1800) < 2) { - this->type = 2; - this->action = 1; - this->z.WORD = 0; - this->collisionLayer = 1; + if (sub_080044EC(super, 0x1800) < 2) { + super->type = 2; + super->action = 1; + super->z.WORD = 0; + super->collisionLayer = 1; SetLocalFlag(LV3_OCARINA_FALL); SoundReq(SFX_SECRET); - fx = CreateFx(this, FX_DASH, 0); + fx = CreateFx(super, FX_DASH, 0); if (fx != NULL) { - SortEntityBelow(this, fx); + SortEntityBelow(super, fx); } } } -void Bird_Type2(Entity* this) { - static void (*const Bird_Type2_Actions[])(Entity*) = { +void Bird_Type2(BirdEntity* this) { + static void (*const Bird_Type2_Actions[])(BirdEntity*) = { Bird_Type2_Init, Bird_Type2_Action1, }; - Bird_Type2_Actions[this->action](this); + Bird_Type2_Actions[super->action](this); } -void Bird_Type2_Init(Entity* this) { - this->action++; - this->collisionLayer = 1; - UpdateSpriteForCollisionLayer(this); - InitAnimationForceUpdate(this, 0x17); +void Bird_Type2_Init(BirdEntity* this) { + super->action++; + super->collisionLayer = 1; + UpdateSpriteForCollisionLayer(super); + InitAnimationForceUpdate(super, 0x17); } -void Bird_Type2_Action1(Entity* this) { +void Bird_Type2_Action1(BirdEntity* this) { if ((gPlayerState.flags & PL_MINISH) != 0) { - sub_0800445C(this); - } else if (IsCollidingPlayer(this) != 0) { + sub_0800445C(super); + } else if (IsCollidingPlayer(super) != 0) { CreateItemEntity(ITEM_OCARINA, 0, 0); gSave.windcrests |= 0x10000000; DeleteThisEntity(); } } -void Bird_Type3(Entity* this) { +void Bird_Type3(BirdEntity* this) { - if (this->action == 0) { - this->action++; - this->collisionLayer = 2; - UpdateSpriteForCollisionLayer(this); - this->frame = 0x80; + if (super->action == 0) { + super->action++; + super->collisionLayer = 2; + UpdateSpriteForCollisionLayer(super); + super->frame = 0x80; } - if ((this->frame & ANIM_DONE) != 0) { - InitializeAnimation(this, Random() & 3); - this->frameDuration = (Random() & 0xf) + 0x10; - this->spriteSettings.flipX = FALSE; + if ((super->frame & ANIM_DONE) != 0) { + InitializeAnimation(super, Random() & 3); + super->frameDuration = (Random() & 0xf) + 0x10; + super->spriteSettings.flipX = FALSE; if ((Random() & 1) != 0) { - this->spriteSettings.flipX = TRUE; + super->spriteSettings.flipX = TRUE; } } else { - GetNextFrame(this); + GetNextFrame(super); } } -void Bird_Type8(Entity* this) { +void Bird_Type8(BirdEntity* this) { Entity* pEVar5; - switch (this->action) { + switch (super->action) { case 0: - if (this->timer != 0) { - this->frameIndex = 0xff; - this->timer--; + if (super->timer != 0) { + super->frameIndex = 0xff; + super->timer--; return; } - this->action = 1; - this->zVelocity = 0; - this->z.WORD = Q_16_16(-20.0); - this->speed = 0x180; - this->direction = 8; - this->collisionLayer = 1; - this->spritePriority.b0 = 0; - this->spriteRendering.b3 = 0; - this->spriteOrientation.flipY = 1; - this->x.HALF.HI = gRoomControls.scroll_x; - this->y.HALF.HI = gPlayerEntity.y.HALF.HI; - this->child = NULL; - SetDefaultPriority(this, 6); - InitAnimationForceUpdate(this, 0); + super->action = 1; + super->zVelocity = 0; + super->z.WORD = Q_16_16(-20.0); + super->speed = 0x180; + super->direction = 8; + super->collisionLayer = 1; + super->spritePriority.b0 = 0; + super->spriteRendering.b3 = 0; + super->spriteOrientation.flipY = 1; + super->x.HALF.HI = gRoomControls.scroll_x; + super->y.HALF.HI = gPlayerEntity.y.HALF.HI; + super->child = NULL; + SetDefaultPriority(super, 6); + InitAnimationForceUpdate(super, 0); SoundReq(0x123); break; case 1: - this->collisionLayer = gPlayerEntity.collisionLayer; - this->speed += 8; - if (this->speed > 0x300) { - this->speed = 0x300; + super->collisionLayer = gPlayerEntity.collisionLayer; + super->speed += 8; + if (super->speed > 0x300) { + super->speed = 0x300; } if ((gPlayerEntity.flags & ENT_COLLIDE) && (gMessage.doTextBox & 0x7f) == 0 && gPlayerEntity.action != PLAYER_SLEEP && gPlayerEntity.action != PLAYER_BOUNCE && gPlayerEntity.action != PLAYER_MINISH && gPlayerState.framestate != PL_STATE_CLIMB && gPlayerState.framestate != PL_STATE_JUMP && gPlayerState.framestate != PL_STATE_PARACHUTE && - PlayerCanBeMoved() && (EntityInRectRadius(this, &gPlayerEntity, 0xe, 0xe))) { - s32 z = gPlayerEntity.z.HALF.HI - this->z.HALF.HI - 8; + PlayerCanBeMoved() && (EntityInRectRadius(super, &gPlayerEntity, 0xe, 0xe))) { + s32 z = gPlayerEntity.z.HALF.HI - super->z.HALF.HI - 8; if ((u16)z < 0x20 && gPlayerEntity.health != 0) { pEVar5 = CreateObject(BIRD, 10, 0); if (pEVar5 != NULL) { - this->child = pEVar5; - this->action = 2; - this->timer = 8; - this->speed = 0x300; - this->field_0x68.HWORD = Q_8_8(-32.0); + super->child = pEVar5; + super->action = 2; + super->timer = 8; + super->speed = 0x300; + this->gravity = Q_8_8(-32.0); PlayerDropHeldObject(); sub_08078B48(); ResetPlayerAnimationAndAction(); @@ -251,33 +258,33 @@ void Bird_Type8(Entity* this) { gPlayerEntity.spriteSettings.draw = 0; break; } - LinearMoveUpdate(this); - GravityUpdate(this, (s16)this->field_0x68.HWORD); - UpdateAnimationSingleFrame(this); - pEVar5 = this->child; + LinearMoveUpdate(super); + GravityUpdate(super, (s16)this->gravity); + UpdateAnimationSingleFrame(super); + pEVar5 = super->child; if (pEVar5 != NULL) { - if (gPlayerEntity.x.HALF.HI < this->x.HALF.HI - 8) { - this->timer = 0; + if (gPlayerEntity.x.HALF.HI < super->x.HALF.HI - 8) { + super->timer = 0; } - if (this->timer == 0) { - PositionRelative(this, pEVar5, 0xfff80000, 0); + if (super->timer == 0) { + PositionRelative(super, pEVar5, 0xfff80000, 0); pEVar5->z.HALF.HI += 0x18; - pEVar5->spritePriority.b0 = this->spritePriority.b0; - pEVar5->spriteRendering.b3 = this->spriteRendering.b3; - pEVar5->spriteOrientation.flipY = this->spriteOrientation.flipY; + pEVar5->spritePriority.b0 = super->spritePriority.b0; + pEVar5->spriteRendering.b3 = super->spriteRendering.b3; + pEVar5->spriteOrientation.flipY = super->spriteOrientation.flipY; } else { - this->timer--; + super->timer--; CopyPosition(&gPlayerEntity, pEVar5); } } - if (CheckOnScreen(this) == 0) { - if (this->action == 2) { + if (CheckOnScreen(super) == 0) { + if (super->action == 2) { gSave.windcrests |= 0x10000000; MenuFadeIn(9, 0); } - pEVar5 = this->child; + pEVar5 = super->child; if (pEVar5 != NULL) { DeleteEntityAny(pEVar5); } @@ -285,43 +292,42 @@ void Bird_Type8(Entity* this) { } } -void Bird_Type9(Entity* this) { - Entity* pEVar1; +void Bird_Type9(BirdEntity* this) { Entity* child; - if (this->action == 0) { - this->action = 1; - this->spriteSettings.draw = 1; - this->zVelocity = Q_16_16(-2.5); - this->z.WORD = Q_16_16(-75.25); - this->field_0x68.HWORD = Q_8_8(-16.0); - this->speed = 0x300; - this->direction = 8; - this->collisionLayer = 1; - this->spritePriority.b0 = 0; - this->spriteRendering.b3 = 0; - this->spriteOrientation.flipY = 1; - SetDefaultPriority(this, 6); - this->x.HALF.HI = gRoomControls.scroll_x; - this->y.HALF.HI = gPlayerEntity.y.HALF.HI; + if (super->action == 0) { + super->action = 1; + super->spriteSettings.draw = 1; + super->zVelocity = Q_16_16(-2.5); + super->z.WORD = Q_16_16(-75.25); + this->gravity = Q_8_8(-16.0); + super->speed = 0x300; + super->direction = 8; + super->collisionLayer = 1; + super->spritePriority.b0 = 0; + super->spriteRendering.b3 = 0; + super->spriteOrientation.flipY = 1; + SetDefaultPriority(super, 6); + super->x.HALF.HI = gRoomControls.scroll_x; + super->y.HALF.HI = gPlayerEntity.y.HALF.HI; SoundReq(SFX_123); - this->spritePriority.b1 = 2; - InitAnimationForceUpdate(this, 0); + super->spritePriority.b1 = 2; + InitAnimationForceUpdate(super, 0); sub_08078B48(); - } else if (this->action == 1) { + } else if (super->action == 1) { gPlayerEntity.spriteSettings.draw = 0; - child = this->child; + child = super->child; if (child != NULL) { - PositionRelative(this, child, Q_16_16(-8), 0); + PositionRelative(super, child, Q_16_16(-8), 0); child->z.HALF.HI += 0x18; - child->spritePriority.b0 = this->spritePriority.b0; - child->spriteRendering.b3 = this->spriteRendering.b3; - child->spriteOrientation.flipY = this->spriteOrientation.flipY; + child->spritePriority.b0 = super->spritePriority.b0; + child->spriteRendering.b3 = super->spriteRendering.b3; + child->spriteOrientation.flipY = super->spriteOrientation.flipY; } sub_08078B48(); - if (gRoomControls.scroll_x + 0x78 < this->x.HALF.HI) { - this->action++; - this->spritePriority.b1 = 1; + if (gRoomControls.scroll_x + 0x78 < super->x.HALF.HI) { + super->action++; + super->spritePriority.b1 = 1; if (child != NULL) { child->action++; } @@ -331,39 +337,40 @@ void Bird_Type9(Entity* this) { ResetPlayerEventPriority(); gPauseMenuOptions.disabled = 0; if (!CheckGlobalFlag(WARP_1ST)) { - pEVar1 = CreateObject(CUTSCENE_ORCHESTRATOR, 0, 0); - if (pEVar1 != NULL) { - *(ScriptExecutionContext**)&pEVar1->cutsceneBeh = StartCutscene(pEVar1, script_EzloTalkOcarina); + CutsceneOrchestratorEntity* orchestrator = + (CutsceneOrchestratorEntity*)CreateObject(CUTSCENE_ORCHESTRATOR, 0, 0); + if (orchestrator != NULL) { + orchestrator->context = StartCutscene(&orchestrator->base, script_EzloTalkOcarina); SetGlobalFlag(WARP_1ST); } } } } - LinearMoveUpdate(this); - GravityUpdate(this, (short)this->field_0x68.HWORD); - UpdateAnimationSingleFrame(this); - if (!CheckOnScreen(this)) { + LinearMoveUpdate(super); + GravityUpdate(super, (short)this->gravity); + UpdateAnimationSingleFrame(super); + if (!CheckOnScreen(super)) { DeleteThisEntity(); } } -void Bird_Type10(Entity* this) { - this->palette.b.b0 = gPlayerEntity.palette.b.b0; - switch (this->action) { +void Bird_Type10(BirdEntity* this) { + super->palette.b.b0 = gPlayerEntity.palette.b.b0; + switch (super->action) { case 0: - this->action = 1; - this->spriteSettings.draw = 1; - this->collisionLayer = 1; - this->spritePriority.b0 = 0; - this->spriteRendering.b3 = 0; - this->spriteOrientation.flipY = 1; - SetDefaultPriority(this, 6); - InitAnimationForceUpdate(this, 0xe0); + super->action = 1; + super->spriteSettings.draw = 1; + super->collisionLayer = 1; + super->spritePriority.b0 = 0; + super->spriteRendering.b3 = 0; + super->spriteOrientation.flipY = 1; + SetDefaultPriority(super, 6); + InitAnimationForceUpdate(super, 0xe0); case 1: - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); break; case 2: - this->action = 3; + super->action = 3; break; case 3: DeleteThisEntity(); @@ -372,17 +379,15 @@ void Bird_Type10(Entity* this) { } void CreateBird(Entity* this) { - Entity* birdEnt; - #ifndef EU if (AreaAllowsWarp()) { #else if (AreaIsOverworld()) { #endif if (!FindEntity(OBJECT, BIRD, 6, 8, 0)) { - birdEnt = CreateObject(BIRD, 8, 0); - if (birdEnt != NULL) { - birdEnt->timer = 0; + Entity* bird = CreateObject(BIRD, 8, 0); + if (bird != NULL) { + bird->timer = 0; } } } diff --git a/src/object/blockPushed.c b/src/object/blockPushed.c index eb19a284..d871f4ac 100644 --- a/src/object/blockPushed.c +++ b/src/object/blockPushed.c @@ -4,10 +4,8 @@ * * @brief Block Pushed object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/book.c b/src/object/book.c index ece50550..31d07e34 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -4,6 +4,7 @@ * * @brief Book object */ +#define NENT_DEPRECATED #include "collision.h" #include "functions.h" #include "item.h" @@ -11,19 +12,27 @@ #include "npc.h" #include "object.h" -extern void (*const Book_Actions[])(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[24]; + /*0x80*/ u8 unk_80; + /*0x81*/ u8 unused2[5]; + /*0x86*/ u16 unk_86; +} BookEntity; + +extern void (*const Book_Actions[])(BookEntity*); extern s8 const gUnk_08123D94[]; u32 sub_0809B688(Entity*); void sub_0809B6B0(Entity*, Entity*); -void Book(Entity* this) { - Book_Actions[this->action](this); +void Book(BookEntity* this) { + Book_Actions[super->action](this); } -void Book_Init(Entity* this) { - u32 obtained = GetInventoryValue(this->type + ITEM_QST_BOOK1); - if (this->type2 != 3) { +void Book_Init(BookEntity* this) { + u32 obtained = GetInventoryValue(super->type + ITEM_QST_BOOK1); + if (super->type2 != 3) { if (obtained != 0) { DeleteThisEntity(); } @@ -33,70 +42,70 @@ void Book_Init(Entity* this) { } if (obtained != 2) { - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; } } - this->spriteOffsetY = 3; - if (CheckFlags(this->field_0x86.HWORD)) { - if (this->type2 == 0) { - this->y.HALF.HI += 48; + super->spriteOffsetY = 3; + if (CheckFlags(this->unk_86)) { + if (super->type2 == 0) { + super->y.HALF.HI += 48; } - this->type2 = 2; + super->type2 = 2; } - UpdateSpriteForCollisionLayer(this); - InitAnimationForceUpdate(this, this->type + ITEM_QST_BOOK1); + UpdateSpriteForCollisionLayer(super); + InitAnimationForceUpdate(super, super->type + ITEM_QST_BOOK1); - switch (this->type2) { + switch (super->type2) { case 0: - this->action = 1; - this->timer = 22; - this->subtimer = 2; - this->field_0x80.HALF.LO = 0; - this->spritePriority.b0 = 3; + super->action = 1; + super->timer = 22; + super->subtimer = 2; + this->unk_80 = 0; + super->spritePriority.b0 = 3; break; case 1: { u32 scroll; u32 height; - this->action = 3; + super->action = 3; scroll = (u16)gRoomControls.scroll_y - 0x10; - height = (u16)this->y.HALF.HI - scroll; - this->z.HALF.HI -= height; + height = (u16)super->y.HALF.HI - scroll; + super->z.HALF.HI -= height; break; } case 2: - this->action = 4; + super->action = 4; break; case 3: - this->action = 5; - this->subAction = 0; - this->spritePriority.b0 = 3; + super->action = 5; + super->subAction = 0; + super->spritePriority.b0 = 3; break; default: break; } } -void Book_Action1(Entity* this) { - sub_0800445C(this); +void Book_Action1(BookEntity* this) { + sub_0800445C(super); - if (this->field_0x80.HALF.LO != 0) { - this->field_0x80.HALF.LO--; + if (this->unk_80 != 0) { + this->unk_80--; return; } - if (sub_0809B688(this)) { - if (--this->timer) { + if (sub_0809B688(super)) { + if (--super->timer) { return; } - this->action = 2; - this->timer = 30; - this->speed = 0x40; - this->direction = 0x10; + super->action = 2; + super->timer = 30; + super->speed = 0x40; + super->direction = 0x10; gPlayerState.pushedObject = TREE_THORNS; gPlayerState.queued_action = PLAYER_PUSH; @@ -107,79 +116,79 @@ void Book_Action1(Entity* this) { gPlayerEntity.direction = gPlayerEntity.animationState << 2; EnqueueSFX(SFX_10F); } else { - this->timer = 22; + super->timer = 22; } } -void Book_Action2(Entity* this) { - if (--this->timer == 0) { - if (--this->subtimer == 0) { - this->action = 3; - this->y.HALF.HI += 0x20; - this->z.HALF.HI -= 0x20; +void Book_Action2(BookEntity* this) { + if (--super->timer == 0) { + if (--super->subtimer == 0) { + super->action = 3; + super->y.HALF.HI += 0x20; + super->z.HALF.HI -= 0x20; } else { - this->action = 1; - this->timer = 22; - this->field_0x80.HALF.LO = 0x18; + super->action = 1; + super->timer = 22; + this->unk_80 = 0x18; } } - LinearMoveUpdate(this); + LinearMoveUpdate(super); } -void Book_Action3(Entity* this) { +void Book_Action3(BookEntity* this) { Entity* fx; - if (sub_080044EC(this, 0x2800) != 1) { + if (sub_080044EC(super, 0x2800) != 1) { return; } - this->action = 4; - this->spritePriority.b0 = 4; + super->action = 4; + super->spritePriority.b0 = 4; - SetFlag(this->field_0x86.HWORD); + SetFlag(this->unk_86); - fx = CreateFx(this, FX_DEATH, 0); + fx = CreateFx(super, FX_DEATH, 0); if (fx != NULL) { - SortEntityAbove(this, fx); + SortEntityAbove(super, fx); } } -void Book_Action4(Entity* this) { +void Book_Action4(BookEntity* this) { if (gPlayerState.flags & PL_MINISH) { - sub_0800445C(this); - } else if (IsCollidingPlayer(this)) { - CreateItemEntity(this->type + ITEM_QST_BOOK1, 0, 0); + sub_0800445C(super); + } else if (IsCollidingPlayer(super)) { + CreateItemEntity(super->type + ITEM_QST_BOOK1, 0, 0); DeleteThisEntity(); } } -void Book_Action5(Entity* this) { - if (this->spriteSettings.draw == 1) { - switch (this->subAction) { +void Book_Action5(BookEntity* this) { + if (super->spriteSettings.draw == 1) { + switch (super->subAction) { case 0: { Entity* parent = FindEntityByID(NPC, STURGEON, 7); if (parent == NULL) { return; } - if (parent->x.HALF.HI < this->x.HALF.HI) { + if (parent->x.HALF.HI < super->x.HALF.HI) { return; } if (parent->animationState != 4) { return; } - this->parent = parent; - this->subAction = 1; - sub_0809B6B0(this->parent, this); + super->parent = parent; + super->subAction = 1; + sub_0809B6B0(super->parent, super); break; } case 1: { - if ((this->parent == NULL) || (this->parent->next == NULL)) { + if ((super->parent == NULL) || (super->parent->next == NULL)) { DeleteThisEntity(); return; } - sub_0809B6B0(this->parent, this); + sub_0809B6B0(super->parent, super); break; } default: @@ -187,22 +196,22 @@ void Book_Action5(Entity* this) { } } else { - switch (this->subAction) { + switch (super->subAction) { default: { DeleteThisEntity(); break; } case 0: { - if (GetInventoryValue(this->type + ITEM_QST_BOOK1) == 2) { - this->subAction = 1; + if (GetInventoryValue(super->type + ITEM_QST_BOOK1) == 2) { + super->subAction = 1; } break; } case 1: { u8 doTextBox = gMessage.doTextBox & 0x7f; if (!doTextBox) { - this->spriteSettings.draw = 1; - this->subAction = doTextBox; + super->spriteSettings.draw = 1; + super->subAction = doTextBox; } break; } @@ -229,7 +238,7 @@ void sub_0809B6B0(Entity* parent, Entity* this) { this->spritePriority.b0 = 3 - this->type; } -void (*const Book_Actions[])(Entity*) = { +void (*const Book_Actions[])(BookEntity*) = { Book_Init, Book_Action1, Book_Action2, Book_Action3, Book_Action4, Book_Action5, }; diff --git a/src/object/bossDoor.c b/src/object/bossDoor.c index c1b3bcff..58f24666 100644 --- a/src/object/bossDoor.c +++ b/src/object/bossDoor.c @@ -4,10 +4,8 @@ * * @brief Boss Door object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" diff --git a/src/object/bush.c b/src/object/bush.c index acdac424..e12d3883 100644 --- a/src/object/bush.c +++ b/src/object/bush.c @@ -5,10 +5,9 @@ * @brief Bush object */ #define NENT_DEPRECATED -#include "global.h" -#include "object.h" #include "functions.h" #include "hitbox.h" +#include "object.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/button.c b/src/object/button.c index 33dfcefe..0bf4bb7e 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -4,176 +4,188 @@ * * @brief Button object */ -#include "object.h" +#define NENT_DEPRECATED #include "functions.h" +#include "object.h" -void Button_Init(Entity*); -void Button_Action1(Entity*); -void Button_Action2(Entity*); -void Button_Action3(Entity*); -void Button_Action4(Entity*); -void Button_Action5(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[8]; + /*0x70*/ u16 unk_70; + /*0x72*/ u16 unk_72; + /*0x74*/ u16 unk_74; + /*0x76*/ u8 unused2[14]; + /*0x84*/ u16 unk_84; + /*0x86*/ u16 unk_86; +} ButtonEntity; -void Button(Entity* this) { - static void (*const Button_Actions[])(Entity*) = { +void Button_Init(ButtonEntity* this); +void Button_Action1(ButtonEntity* this); +void Button_Action2(ButtonEntity* this); +void Button_Action3(ButtonEntity* this); +void Button_Action4(ButtonEntity* this); +void Button_Action5(ButtonEntity* this); + +void Button(ButtonEntity* this) { + static void (*const Button_Actions[])(ButtonEntity*) = { Button_Init, Button_Action1, Button_Action2, Button_Action3, Button_Action4, Button_Action5, }; - Button_Actions[this->action](this); + Button_Actions[super->action](this); } -extern u32 sub_08081E3C(Entity*); +extern u32 sub_08081E3C(ButtonEntity*); -void Button_Init(Entity* this) { - COLLISION_OFF(this); - this->updatePriority = PRIO_NO_BLOCK; - this->y.HALF.HI++; - if (this->cutsceneBeh.HWORD != 0) { - this->collisionLayer = this->cutsceneBeh.HWORD; +void Button_Init(ButtonEntity* this) { + COLLISION_OFF(super); + super->updatePriority = PRIO_NO_BLOCK; + super->y.HALF.HI++; + if (this->unk_84 != 0) { + super->collisionLayer = this->unk_84; } - this->field_0x74.HWORD = (((this->x.HALF.HI - gRoomControls.origin_x) >> 4) & 0x3F) | - ((((this->y.HALF.HI - gRoomControls.origin_y) >> 4) & 0x3F) << 6); - this->field_0x70.HALF.HI = GetTileType(this->field_0x74.HWORD, this->collisionLayer); - if (this->type == 0 && CheckFlags(this->field_0x86.HWORD)) { - this->action = 5; - SetTileType(0x7A, this->field_0x74.HWORD, this->collisionLayer); + this->unk_74 = (((super->x.HALF.HI - gRoomControls.origin_x) >> 4) & 0x3F) | + ((((super->y.HALF.HI - gRoomControls.origin_y) >> 4) & 0x3F) << 6); + this->unk_72 = GetTileType(this->unk_74, super->collisionLayer); + if (super->type == 0 && CheckFlags(this->unk_86)) { + super->action = 5; + SetTileType(0x7A, this->unk_74, super->collisionLayer); } else { if (sub_08081E3C(this)) { - this->action = 2; + super->action = 2; } else { - this->action = 1; + super->action = 1; } } } -void Button_Action1(Entity* this) { +void Button_Action1(ButtonEntity* this) { if (sub_08081E3C(this)) { - this->action = 2; - this->field_0x70.HALF.HI = GetTileType(this->field_0x74.HWORD, this->collisionLayer); + super->action = 2; + this->unk_72 = GetTileType(this->unk_74, super->collisionLayer); } } -u32 sub_08081CB0(Entity*); +u32 sub_08081CB0(ButtonEntity*); void sub_08081FF8(Entity*); -void Button_Action2(Entity* this) { +void Button_Action2(ButtonEntity* this) { if (sub_08081CB0(this)) { - this->subAction = 0; - this->timer = 10; - RequestPriorityDuration(this, 10); - sub_08081FF8(this); - if (this->type == 1) { - this->action = 3; + super->subAction = 0; + super->timer = 10; + RequestPriorityDuration(super, 10); + sub_08081FF8(super); + if (super->type == 1) { + super->action = 3; } else { - this->action = 5; + super->action = 5; } } } -u32 sub_08081F7C(Entity*, u32); -u32 sub_08081D28(Entity*); -void sub_08081E6C(Entity*); +u32 sub_08081F7C(ButtonEntity*, u32); +u32 sub_08081D28(ButtonEntity*); +void sub_08081E6C(ButtonEntity*); -void Button_Action3(Entity* this) { +void Button_Action3(ButtonEntity* this) { if (!sub_08081F7C(this, 0x78)) return; if (!sub_08081D28(this)) { - this->action = 4; - this->subtimer = 1; + super->action = 4; + super->subtimer = 1; if ((gPlayerState.heldObject == 2) || (!(gPlayerState.field_0x35 & 0x80))) { - this->timer = 24; + super->timer = 24; } else { - this->timer = 8; + super->timer = 8; } } else { sub_08081E6C(this); } } -void Button_Action4(Entity* this) { - if (this->timer != 0) { - this->timer--; - if (this->subtimer != 0) { - this->subtimer = 0; - SetTile(0x4035, this->field_0x74.HWORD, this->collisionLayer); +void Button_Action4(ButtonEntity* this) { + if (super->timer != 0) { + super->timer--; + if (super->subtimer != 0) { + super->subtimer = 0; + SetTile(0x4035, this->unk_74, super->collisionLayer); } if (sub_08081CB0(this)) { - this->action = 3; - this->timer = 0; + super->action = 3; + super->timer = 0; } } else { - this->action = 2; - ClearFlag(this->field_0x86.HWORD); - SetTileType(0x77, this->field_0x74.HWORD, this->collisionLayer); + super->action = 2; + ClearFlag(this->unk_86); + SetTileType(0x77, this->unk_74, super->collisionLayer); SoundReq(SFX_BUTTON_PRESS); } } -void Button_Action5(Entity* this) { +void Button_Action5(ButtonEntity* this) { if (sub_08081F7C(this, 0x7a)) { sub_08081E6C(this); } } -Entity* sub_08081D74(Entity*); +Entity* sub_08081D74(ButtonEntity*); -u32 sub_08081CB0(Entity* this) { +bool32 sub_08081CB0(ButtonEntity* this) { u16 tmp; if (sub_08081D74(this)) { - this->field_0x70.HALF.LO = -1; - if (GetTileType(this->field_0x74.HWORD, this->collisionLayer) == 0x4035) { - sub_0807B7D8(0x78, this->field_0x74.HWORD, this->collisionLayer); + this->unk_70 = -1; + if (GetTileType(this->unk_74, super->collisionLayer) == 0x4035) { + sub_0807B7D8(0x78, this->unk_74, super->collisionLayer); } - return 1; + return TRUE; } else { - tmp = GetTileType(this->field_0x74.HWORD, this->collisionLayer); + tmp = GetTileType(this->unk_74, super->collisionLayer); if (tmp != 0x77 && tmp != 0x79 && tmp != 0x4035) { - this->field_0x70.HALF.LO = GetTileIndex(this->field_0x74.HWORD, this->collisionLayer); - return 1; + this->unk_70 = GetTileIndex(this->unk_74, super->collisionLayer); + return TRUE; } } - return 0; + return FALSE; } -u32 sub_08081D28(Entity* this) { +bool32 sub_08081D28(ButtonEntity* this) { if (sub_08081D74(this)) { - this->field_0x70.HALF_U.LO = 0xFFFF; - return 1; + this->unk_70 = 0xFFFF; + return TRUE; } else { - if (this->field_0x70.HALF_U.LO == 0xFFFF) { - return 0; + if (this->unk_70 == 0xFFFF) { + return FALSE; } - if (GetTileIndex(this->field_0x74.HWORD, this->collisionLayer) != this->field_0x70.HALF_U.LO) { - return 0; + if (GetTileIndex(this->unk_74, super->collisionLayer) != this->unk_70) { + return FALSE; } } - return 1; + return TRUE; } extern Entity* gPlayerClones[3]; u32 sub_08081E0C(Entity*); -Entity* sub_08081D74(Entity* this) { +Entity* sub_08081D74(ButtonEntity* this) { Entity* ent; - if (sub_080B1B44(this->field_0x74.HWORD, this->collisionLayer) == 0xF) { + if (sub_080B1B44(this->unk_74, super->collisionLayer) == 0xF) { return 0; } ent = 0; - if (sub_08081E0C(this)) { + if (sub_08081E0C(super)) { if ((gPlayerState.flags & PL_CAPTURED) == 0 && (gPlayerState.flags & PL_MINISH) == 0) { ent = &gPlayerEntity; } } else { if (gPlayerState.flags & PL_CLONING) { - if (EntityInRectRadius(this, gPlayerClones[0], 5, 6)) { + if (EntityInRectRadius(super, gPlayerClones[0], 5, 6)) { ent = gPlayerClones[0]; - } else if (EntityInRectRadius(this, gPlayerClones[1], 5, 6)) { + } else if (EntityInRectRadius(super, gPlayerClones[1], 5, 6)) { ent = gPlayerClones[1]; - } else if (EntityInRectRadius(this, gPlayerClones[2], 5, 6)) { + } else if (EntityInRectRadius(super, gPlayerClones[2], 5, 6)) { ent = gPlayerClones[2]; } } } - this->child = ent; + super->child = ent; return ent; } @@ -186,13 +198,13 @@ u32 sub_08081E0C(Entity* this) { } } -u32 sub_08081E3C(Entity* this) { +u32 sub_08081E3C(ButtonEntity* this) { static const u16 gUnk_0811EE50[] = { 0x77, 0x78, 0x79, 0x7a, 0, 0, }; const u16* tmp1; s32 tmp2; - tmp2 = GetTileType(this->field_0x74.HWORD, this->collisionLayer); + tmp2 = GetTileType(this->unk_74, super->collisionLayer); tmp1 = gUnk_0811EE50; do { if (*tmp1 == tmp2) @@ -207,20 +219,20 @@ extern u16 gMapDataTopSpecial[0x2000]; extern u16 gMapDataBottomSpecial[]; -void sub_08081E6C(Entity* this) { +void sub_08081E6C(ButtonEntity* this) { u32 r4; LayerStruct* r1; u16* tmp2; u16* tmp; u16* tmp3; - u32 r6 = this->field_0x74.HWORD; - u32 r5 = this->collisionLayer; + u32 r6 = this->unk_74; + u32 r5 = super->collisionLayer; u32 tile = GetTileType(r6, r5); if (tile < 0x4000) return; r1 = GetLayerByIndex(r5); - r4 = (this->type == 0 ? 0x7a : 0x78); + r4 = (super->type == 0 ? 0x7a : 0x78); tmp = r1->metatiles; tmp = tmp + (r1->unkData2[r4] << 2); tmp2 = (r5 == 2 ? gMapDataTopSpecial : gMapDataBottomSpecial); @@ -254,25 +266,25 @@ void sub_08081F24(Entity* this) { } } -u32 sub_08081F7C(Entity* this, u32 r7) { +bool32 sub_08081F7C(ButtonEntity* this, u32 r7) { u16 tmp; - if (this->timer == 0) - return 1; - if (--this->timer > 6) { - if (this->child != NULL) - this->child->spriteOffsetY = -4; + if (super->timer == 0) + return TRUE; + if (--super->timer > 6) { + if (super->child != NULL) + super->child->spriteOffsetY = -4; } else { - if (this->timer == 6) { - SetFlag(this->field_0x86.HWORD); - SetTileType(r7, this->field_0x74.HWORD, this->collisionLayer); - sub_08081F24(this); + if (super->timer == 6) { + SetFlag(this->unk_86); + SetTileType(r7, this->unk_74, super->collisionLayer); + sub_08081F24(super); SoundReq(SFX_BUTTON_PRESS); - if (this->field_0x70.HALF_U.LO != 0xFFFF) - SetTile(this->field_0x70.HALF_U.LO, this->field_0x74.HWORD, this->collisionLayer); - return 0; + if (this->unk_70 != 0xFFFF) + SetTile(this->unk_70, this->unk_74, super->collisionLayer); + return FALSE; } } - return 1; + return TRUE; } void sub_08081FF8(Entity* this) { diff --git a/src/object/carlovObject.c b/src/object/carlovObject.c index f4ffa8a9..003b61f0 100644 --- a/src/object/carlovObject.c +++ b/src/object/carlovObject.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index 8a721a58..fadf1afd 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -4,10 +4,8 @@ * * @brief Chest Spawner object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "item.h" #include "object.h" #include "screen.h" diff --git a/src/object/chuchuBossCutscene.c b/src/object/chuchuBossCutscene.c index 808782e1..564c420b 100644 --- a/src/object/chuchuBossCutscene.c +++ b/src/object/chuchuBossCutscene.c @@ -4,114 +4,108 @@ * * @brief Chuchu Boss Cutscene object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "menu.h" #include "object.h" -typedef struct { - /*0x00*/ Entity base; -} ChuchuBossCutsceneEntity; +void ChuchuBossCutscene_Init(Entity*); +void ChuchuBossCutscene_Action1(Entity*); +void ChuchuBossCutscene_Action2(Entity*); +void ChuchuBossCutscene_Action3(Entity*); +void ChuchuBossCutscene_Action4(Entity*); +void ChuchuBossCutscene_Action5(Entity*); +void ChuchuBossCutscene_Action6(Entity*); +void ChuchuBossCutscene_Action7(Entity*); -void ChuchuBossCutscene_Init(ChuchuBossCutsceneEntity*); -void ChuchuBossCutscene_Action1(ChuchuBossCutsceneEntity*); -void ChuchuBossCutscene_Action2(ChuchuBossCutsceneEntity*); -void ChuchuBossCutscene_Action3(ChuchuBossCutsceneEntity*); -void ChuchuBossCutscene_Action4(ChuchuBossCutsceneEntity*); -void ChuchuBossCutscene_Action5(ChuchuBossCutsceneEntity*); -void ChuchuBossCutscene_Action6(ChuchuBossCutsceneEntity*); -void ChuchuBossCutscene_Action7(ChuchuBossCutsceneEntity*); - -void ChuchuBossCutscene(ChuchuBossCutsceneEntity* this) { - static void (*const ChuchuBossCutscene_Actions[])(ChuchuBossCutsceneEntity*) = { +void ChuchuBossCutscene(Entity* this) { + static void (*const ChuchuBossCutscene_Actions[])(Entity*) = { ChuchuBossCutscene_Init, ChuchuBossCutscene_Action1, ChuchuBossCutscene_Action2, ChuchuBossCutscene_Action3, ChuchuBossCutscene_Action4, ChuchuBossCutscene_Action5, ChuchuBossCutscene_Action6, ChuchuBossCutscene_Action7, }; - ChuchuBossCutscene_Actions[super->action](this); + ChuchuBossCutscene_Actions[this->action](this); } -void ChuchuBossCutscene_Init(ChuchuBossCutsceneEntity* this) { - super->action = 1; - super->timer = 60; - InitializeAnimation(super, 0); +void ChuchuBossCutscene_Init(Entity* this) { + this->action = 1; + this->timer = 60; + InitializeAnimation(this, 0); } -void ChuchuBossCutscene_Action1(ChuchuBossCutsceneEntity* this) { - if (--super->timer == 0) { - super->timer = 120; - super->action++; - super->spriteSettings.draw = 1; +void ChuchuBossCutscene_Action1(Entity* this) { + if (--this->timer == 0) { + this->timer = 120; + this->action++; + this->spriteSettings.draw = 1; } } -void ChuchuBossCutscene_Action2(ChuchuBossCutsceneEntity* this) { - GetNextFrame(super); - if ((super->frame & ANIM_DONE) != 0) { - super->action++; - super->spritePriority.b1 = 3; - InitializeAnimation(super, 2); +void ChuchuBossCutscene_Action2(Entity* this) { + GetNextFrame(this); + if ((this->frame & ANIM_DONE) != 0) { + this->action++; + this->spritePriority.b1 = 3; + InitializeAnimation(this, 2); } } -void ChuchuBossCutscene_Action3(ChuchuBossCutsceneEntity* this) { - GetNextFrame(super); - if (--super->timer == 0) { - super->action++; - super->direction = 0; - super->speed = 0x100; - super->zVelocity = Q_16_16(2.0); - super->spriteOrientation.flipY = 0; - super->timer = 0; - InitializeAnimation(super, 3); +void ChuchuBossCutscene_Action3(Entity* this) { + GetNextFrame(this); + if (--this->timer == 0) { + this->action++; + this->direction = 0; + this->speed = 0x100; + this->zVelocity = Q_16_16(2.0); + this->spriteOrientation.flipY = 0; + this->timer = 0; + InitializeAnimation(this, 3); SoundReq(SFX_12B); } } -void ChuchuBossCutscene_Action4(ChuchuBossCutsceneEntity* this) { - if ((super->frame & 0x10) != 0) { - LinearMoveUpdate(super); - if (GravityUpdate(super, Q_8_8(32.0)) == 0) { - GetNextFrame(super); +void ChuchuBossCutscene_Action4(Entity* this) { + if ((this->frame & 0x10) != 0) { + LinearMoveUpdate(this); + if (GravityUpdate(this, Q_8_8(32.0)) == 0) { + GetNextFrame(this); } } else { - GetNextFrame(super); + GetNextFrame(this); } - if ((super->y.HALF.HI - gRoomControls.origin_y) < 0x231) { - super->y.HALF.HI = gRoomControls.origin_y + 0x230; - if ((super->frame & ANIM_DONE) != 0) { - super->action++; - super->timer = 120; - InitializeAnimation(super, 2); + if ((this->y.HALF.HI - gRoomControls.origin_y) < 0x231) { + this->y.HALF.HI = gRoomControls.origin_y + 0x230; + if ((this->frame & ANIM_DONE) != 0) { + this->action++; + this->timer = 120; + InitializeAnimation(this, 2); } - } else if ((super->frame & ANIM_DONE) != 0) { - super->zVelocity = Q_16_16(2.0); - InitializeAnimation(super, 3); + } else if ((this->frame & ANIM_DONE) != 0) { + this->zVelocity = Q_16_16(2.0); + InitializeAnimation(this, 3); SoundReq(SFX_12B); } } -void ChuchuBossCutscene_Action5(ChuchuBossCutsceneEntity* this) { - GetNextFrame(super); - if (--super->timer == 0) { - super->action++; - InitializeAnimation(super, 5); +void ChuchuBossCutscene_Action5(Entity* this) { + GetNextFrame(this); + if (--this->timer == 0) { + this->action++; + InitializeAnimation(this, 5); } } -void ChuchuBossCutscene_Action6(ChuchuBossCutsceneEntity* this) { - GetNextFrame(super); - if ((super->frame & ANIM_DONE) != 0) { - super->action++; - super->timer = 60; - InitializeAnimation(super, 1); +void ChuchuBossCutscene_Action6(Entity* this) { + GetNextFrame(this); + if ((this->frame & ANIM_DONE) != 0) { + this->action++; + this->timer = 60; + InitializeAnimation(this, 1); } } -void ChuchuBossCutscene_Action7(ChuchuBossCutsceneEntity* this) { - GetNextFrame(super); - if (--super->timer == 0) { +void ChuchuBossCutscene_Action7(Entity* this) { + GetNextFrame(this); + if (--this->timer == 0) { gMenu.overlayType++; DeleteThisEntity(); } diff --git a/src/object/chuchuBossParticle.c b/src/object/chuchuBossParticle.c index 9b73f0d1..b0b0da51 100644 --- a/src/object/chuchuBossParticle.c +++ b/src/object/chuchuBossParticle.c @@ -1,10 +1,10 @@ -#define NENT_DEPRECATED /** * @file chuchuBossParticle.c * @ingroup Objects * * @brief Chuchu Boss Particle object */ +#define NENT_DEPRECATED #include "entity.h" void ChuchuBossParticle_Init(Entity*); diff --git a/src/object/chuchuBossStartParticle.c b/src/object/chuchuBossStartParticle.c index ae8dfd15..25763c0f 100644 --- a/src/object/chuchuBossStartParticle.c +++ b/src/object/chuchuBossStartParticle.c @@ -4,247 +4,264 @@ * * @brief Chuchu Boss Start Particle object */ +#define NENT_DEPRECATED #include "functions.h" #include "object.h" -static void sub_0808F2B0(Entity*); -void sub_0808F14C(Entity*); -void sub_0808F244(Entity*); -void sub_0808F0B8(Entity*); -void sub_0808F1E0(Entity*); -void sub_0808F2C0(Entity*); -void sub_0808F370(Entity*); -void sub_0808F3DC(Entity*); -void sub_0808F498(Entity*); -void sub_0808F554(Entity*); -void sub_0808F0D0(Entity*); -void sub_0808F170(Entity*); -void sub_0808F1A4(Entity*); -void sub_0808F244(Entity*); -void sub_0808F1F8(Entity*); -void sub_0808F5EC(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[5]; + /*0x6d*/ u8 unk_6d; + /*0x6e*/ u8 unused2[2]; + /*0x70*/ u32 unk_70; + /*0x74*/ u32 unk_74; + /*0x78*/ u32 unk_78; + /*0x7c*/ u8 unused3[3]; + /*0x7f*/ u8 unk_7f; + /*0x80*/ u8 unused4[4]; + /*0x84*/ u32 unk_84; +} ChuchuBossStartParticleEntity; -void ChuchuBossStartParticle(Entity* this) { - static void (*const typeFuncs[])(Entity*) = { - sub_0808F0B8, sub_0808F1E0, sub_0808F2C0, sub_0808F370, sub_0808F0B8, sub_0808F3DC, - sub_0808F3DC, sub_0808F3DC, sub_0808F3DC, sub_0808F498, sub_0808F554, +static void sub_0808F2B0(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type0_Action1(ChuchuBossStartParticleEntity* this); +void sub_0808F244(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type0(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type1(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type2(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type3(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type5(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type9(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type10(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type0_Init(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type0_Action2(ChuchuBossStartParticleEntity* this); +void ChuchuBossStartParticle_Type0_Action3(ChuchuBossStartParticleEntity* this); +void sub_0808F244(ChuchuBossStartParticleEntity* this); +void sub_0808F1F8(ChuchuBossStartParticleEntity* this); +void sub_0808F5EC(ChuchuBossStartParticleEntity* this); + +void ChuchuBossStartParticle(ChuchuBossStartParticleEntity* this) { + static void (*const ChuchuBossStartParticle_Types[])(ChuchuBossStartParticleEntity*) = { + ChuchuBossStartParticle_Type0, ChuchuBossStartParticle_Type1, ChuchuBossStartParticle_Type2, + ChuchuBossStartParticle_Type3, ChuchuBossStartParticle_Type0, ChuchuBossStartParticle_Type5, + ChuchuBossStartParticle_Type5, ChuchuBossStartParticle_Type5, ChuchuBossStartParticle_Type5, + ChuchuBossStartParticle_Type9, ChuchuBossStartParticle_Type10, }; - typeFuncs[this->type](this); + ChuchuBossStartParticle_Types[super->type](this); } -void sub_0808F0B8(Entity* this) { - static void (*const actionFuncs[])(Entity*) = { - sub_0808F0D0, - sub_0808F14C, - sub_0808F170, - sub_0808F1A4, +void ChuchuBossStartParticle_Type0(ChuchuBossStartParticleEntity* this) { + static void (*const ChuchuBossStartParticle_Type0_Actions[])(ChuchuBossStartParticleEntity*) = { + ChuchuBossStartParticle_Type0_Init, + ChuchuBossStartParticle_Type0_Action1, + ChuchuBossStartParticle_Type0_Action2, + ChuchuBossStartParticle_Type0_Action3, }; - actionFuncs[this->action](this); + ChuchuBossStartParticle_Type0_Actions[super->action](this); } -void sub_0808F0D0(Entity* this) { +void ChuchuBossStartParticle_Type0_Init(ChuchuBossStartParticleEntity* this) { u32 offsetX; u32 offsetY; Entity* ent; u32 uVar3; - ent = CreateObjectWithParent(this, CHUCHU_BOSS_START_PARTICLE, 2, 0); - this->child = ent; + ent = CreateObjectWithParent(super, CHUCHU_BOSS_START_PARTICLE, 2, 0); + super->child = ent; if (ent == NULL) { DeleteThisEntity(); } - this->action = 1; - this->z.HALF.HI = -0xc0; + super->action = 1; + super->z.HALF.HI = -0xc0; offsetX = Random() % 64; if ((Random() & 1) != 0) { offsetX = -offsetX; } - this->x.HALF.HI = this->parent->x.HALF.HI + offsetX; + super->x.HALF.HI = super->parent->x.HALF.HI + offsetX; offsetY = Random() % 32; if ((Random() & 1) != 0) { offsetY = -offsetY; } - this->y.HALF.HI = this->parent->y.HALF.HI + offsetY; - *(u32*)&this->field_0x74 = 0x240; - *(u32*)&this->field_0x78 = 0x140; - InitializeAnimation(this, 3); - sub_0808F14C(this); + super->y.HALF.HI = super->parent->y.HALF.HI + offsetY; + this->unk_74 = 0x240; + this->unk_78 = 0x140; + InitializeAnimation(super, 3); + ChuchuBossStartParticle_Type0_Action1(this); } -void sub_0808F14C(Entity* this) { +void ChuchuBossStartParticle_Type0_Action1(ChuchuBossStartParticleEntity* this) { sub_0808F2B0(this); - if (GravityUpdate(this, Q_8_8(32.0)) == 0) { - this->action++; + if (GravityUpdate(super, Q_8_8(32.0)) == 0) { + super->action++; SoundReq(SFX_WATER_SPLASH); } } -void sub_0808F170(Entity* this) { - *(u32*)&this->field_0x74 -= 0x20; - *(u32*)&this->field_0x78 += 0x20; - sub_0806FCF4(this, *(u32*)&this->field_0x78, 8, 2); - if (*(u32*)&this->field_0x78 > 0x1ff) { - this->action++; +void ChuchuBossStartParticle_Type0_Action2(ChuchuBossStartParticleEntity* this) { + this->unk_74 -= 0x20; + this->unk_78 += 0x20; + sub_0806FCF4(super, this->unk_78, 8, 2); + if (this->unk_78 > 0x1ff) { + super->action++; } sub_0808F2B0(this); } -void sub_0808F1A4(Entity* this) { - *(u32*)&this->field_0x78 += 0x10; - *(u32*)&this->field_0x74 += 0x10; - sub_0806FCF4(this, *(u32*)&this->field_0x78, 8, 2); - if (*(u32*)&this->field_0x78 > 0x3ff) { - this->child->action = 0xff; +void ChuchuBossStartParticle_Type0_Action3(ChuchuBossStartParticleEntity* this) { + this->unk_78 += 0x10; + this->unk_74 += 0x10; + sub_0806FCF4(super, this->unk_78, 8, 2); + if (this->unk_78 > 0x3ff) { + super->child->action = 0xff; DeleteThisEntity(); } else { sub_0808F2B0(this); } } -void sub_0808F1E0(Entity* this) { - static void (*const actionFuncs[])(Entity*) = { +void ChuchuBossStartParticle_Type1(ChuchuBossStartParticleEntity* this) { + static void (*const actionFuncs[])(ChuchuBossStartParticleEntity*) = { sub_0808F1F8, sub_0808F244, }; - actionFuncs[this->action](this); + actionFuncs[super->action](this); } -void sub_0808F1F8(Entity* this) { +void sub_0808F1F8(ChuchuBossStartParticleEntity* this) { u8 bVar1; - this->spriteRendering.b0 = 3; - this->action++; - this->spriteRendering.b3 = this->parent->spriteRendering.b3; - this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY; - this->spritePriority.b0 = 7; - InitializeAnimation(this, 1); + super->spriteRendering.b0 = 3; + super->action++; + super->spriteRendering.b3 = super->parent->spriteRendering.b3; + super->spriteOrientation.flipY = super->parent->spriteOrientation.flipY; + super->spritePriority.b0 = 7; + InitializeAnimation(super, 1); sub_0808F244(this); } -void sub_0808F244(Entity* this) { +void sub_0808F244(ChuchuBossStartParticleEntity* this) { - this->spriteSettings.draw = this->parent->spriteSettings.draw; - this->y.HALF.HI = this->parent->y.HALF.HI + 3; - this->x.HALF.HI = (*(s8*)&this->child->spriteOffsetX + this->child->x.HALF.HI); - this->z.WORD = 0; - *(u32*)&this->field_0x74 = 0x80 - this->parent->z.HALF.HI; - *(u32*)&this->field_0x78 = 0x100 - this->parent->z.HALF.HI; - *(u32*)&this->field_0x70.WORD = *((u8*)&this->parent->field_0x7c + 3); + super->spriteSettings.draw = super->parent->spriteSettings.draw; + super->y.HALF.HI = super->parent->y.HALF.HI + 3; + super->x.HALF.HI = (*(s8*)&super->child->spriteOffsetX + super->child->x.HALF.HI); + super->z.WORD = 0; + this->unk_74 = 0x80 - super->parent->z.HALF.HI; + this->unk_78 = 0x100 - super->parent->z.HALF.HI; + this->unk_70 = ((ChuchuBossStartParticleEntity*)super->parent)->unk_7f; sub_0808F2B0(this); - if ((this->parent->field_0x6c.HALF.HI & 2) != 0) { + if ((((ChuchuBossStartParticleEntity*)super->parent)->unk_6d & 2) != 0) { DeleteThisEntity(); } } -static void sub_0808F2B0(Entity* this) { - SetAffineInfo(this, *(u32*)&this->field_0x74, *(u32*)&this->field_0x78, this->field_0x70.WORD); +static void sub_0808F2B0(ChuchuBossStartParticleEntity* this) { + SetAffineInfo(super, this->unk_74, this->unk_78, this->unk_70); } -void sub_0808F2C0(Entity* this) { - if (this->action == 0) { - this->action++; - this->spriteRendering.b3 = this->parent->spriteRendering.b3; - this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY; - this->spriteSettings.draw = 1; - this->spritePriority.b0 = 7; - this->z.WORD = 0; +void ChuchuBossStartParticle_Type2(ChuchuBossStartParticleEntity* this) { + if (super->action == 0) { + super->action++; + super->spriteRendering.b3 = super->parent->spriteRendering.b3; + super->spriteOrientation.flipY = super->parent->spriteOrientation.flipY; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 7; + super->z.WORD = 0; - this->y.HALF.HI = this->parent->y.HALF.HI + 3; - this->x.HALF.HI = this->parent->x.HALF.HI; - InitializeAnimation(this, 3); + super->y.HALF.HI = super->parent->y.HALF.HI + 3; + super->x.HALF.HI = super->parent->x.HALF.HI; + InitializeAnimation(super, 3); } - if (this->parent->z.HALF.HI == 0) { - *(u32*)&this->field_0x74 = *(u32*)&this->parent->field_0x74; - *(u32*)&this->field_0x78 = *(u32*)&this->parent->field_0x78; + if (super->parent->z.HALF.HI == 0) { + this->unk_74 = ((ChuchuBossStartParticleEntity*)super->parent)->unk_74; + this->unk_78 = ((ChuchuBossStartParticleEntity*)super->parent)->unk_78; } else { - *(u32*)&this->field_0x74 = 0x200 - this->parent->z.HALF.HI; - *(u32*)&this->field_0x78 = this->parent->z.HALF.HI * -2 + 0x300; + this->unk_74 = 0x200 - super->parent->z.HALF.HI; + this->unk_78 = super->parent->z.HALF.HI * -2 + 0x300; } - *(u32*)&this->field_0x70 = 0; + this->unk_70 = 0; sub_0808F2B0(this); - sub_0806FCF4(this, *(u32*)&this->field_0x78, 8, 2); - if (this->action == 0xff) { + sub_0806FCF4(super, this->unk_78, 8, 2); + if (super->action == 0xff) { DeleteThisEntity(); } } -void sub_0808F370(Entity* this) { +void ChuchuBossStartParticle_Type3(ChuchuBossStartParticleEntity* this) { static const u16 gUnk_08121EA0[] = { 0x1a4, 0x12c }; - if (this->action == 0) { - if (this->parent->subAction == 1) { - this->action = 1; - this->field_0x70.WORD = 0; + if (super->action == 0) { + if (super->parent->subAction == 1) { + super->action = 1; + this->unk_70 = 0; sub_0808F5EC(this); } } else { - u8 flag = this->parent->subAction - 1; + u8 flag = super->parent->subAction - 1; if (flag < 5) { - if (this->field_0x70.WORD == 0) { - if (--(*(u32*)&this->field_0x74) == -1) { - this->field_0x70.WORD = gUnk_08121EA0[Random() & 1]; + if (this->unk_70 == 0) { + if (--(this->unk_74) == -1) { + this->unk_70 = gUnk_08121EA0[Random() & 1]; } } else { - if (--this->field_0x70.WORD == 0) { + if (--this->unk_70 == 0) { sub_0808F5EC(this); } } } else { - this->action = 0; - *(u32*)&this->field_0x74 = 0; + super->action = 0; + this->unk_74 = 0; } } } -void sub_0808F3DC(Entity* this) { - if (this->action == 0) { - this->spriteSettings.draw = 1; - this->action = 1; - this->timer = 120; - InitializeAnimation(this, this->type + 1); +void ChuchuBossStartParticle_Type5(ChuchuBossStartParticleEntity* this) { + if (super->action == 0) { + super->spriteSettings.draw = 1; + super->action = 1; + super->timer = 120; + InitializeAnimation(super, super->type + 1); // TODO: This block of code might supposed to be a switch statement. - if (this->type != 8) { - if (this->type == 7) { - SortEntityBelow(this->child, this); + if (super->type != 8) { + if (super->type == 7) { + SortEntityBelow(super->child, super); return; } } else { - this->hitType = this->child->hitType; - this->child->hitType = 0x7E; + super->hitType = super->child->hitType; + super->child->hitType = 0x7E; } - SortEntityAbove(this->child, this); + SortEntityAbove(super->child, super); } else { - if (*(u32*)&this->parent->field_0x74 == 0) { - if (this->type == 8) { - this->child->hitType = this->hitType; + if (((ChuchuBossStartParticleEntity*)super->parent)->unk_74 == 0) { + if (super->type == 8) { + super->child->hitType = super->hitType; } DeleteThisEntity(); } - if (this->type == 5 && (this->frame & 1)) { - Entity* entity = CreateObjectWithParent(this->child, CHUCHU_BOSS_START_PARTICLE, 8, 0); + if (super->type == 5 && (super->frame & 1)) { + Entity* entity = CreateObjectWithParent(super->child, CHUCHU_BOSS_START_PARTICLE, 8, 0); if (entity != NULL) { - entity->parent = this->parent; - entity->child = this->parent->parent; + entity->parent = super->parent; + entity->child = super->parent->parent; } } - GetNextFrame(this); - CopyPositionAndSpriteOffset(this->child, this); + GetNextFrame(super); + CopyPositionAndSpriteOffset(super->child, super); } } -void sub_0808F498(Entity* this) { +void ChuchuBossStartParticle_Type9(ChuchuBossStartParticleEntity* this) { u32 var0; - if (this->action != 0) { - if (sub_0806F3E4(this)) { + if (super->action != 0) { + if (sub_0806F3E4(super)) { if (gRoomTransition.frameCount % 16 == 0) { SoundReq(SFX_EF); } DeleteThisEntity(); } - if (this->timer-- == 0) { + if (super->timer-- == 0) { DeleteThisEntity(); } @@ -252,59 +269,59 @@ void sub_0808F498(Entity* this) { DeleteThisEntity(); } } else { - this->action = 1; - this->timer = 64; - var0 = this->type2 != 0 ? 44 : 43; - this->x.HALF.HI -= this->parent->hitbox->width; - this->x.HALF.HI += (s32)Random() % (this->parent->hitbox->width * 2); - this->y.HALF.HI -= this->parent->hitbox->height; - this->y.HALF.HI += (s32)Random() % (this->parent->hitbox->height * 2); - ChangeObjPalette(this, var0); - InitializeAnimation(this, 4); + super->action = 1; + super->timer = 64; + var0 = super->type2 != 0 ? 44 : 43; + super->x.HALF.HI -= super->parent->hitbox->width; + super->x.HALF.HI += (s32)Random() % (super->parent->hitbox->width * 2); + super->y.HALF.HI -= super->parent->hitbox->height; + super->y.HALF.HI += (s32)Random() % (super->parent->hitbox->height * 2); + ChangeObjPalette(super, var0); + InitializeAnimation(super, 4); } } -void sub_0808F554(Entity* this) { - CopyPositionAndSpriteOffset(this->parent, this); - this->spriteOffsetY -= 24; - if ((s8)this->parent->spriteOffsetX != 0) { - this->spriteOffsetX += (s8)this->parent->spriteOffsetX / 2; +void ChuchuBossStartParticle_Type10(ChuchuBossStartParticleEntity* this) { + CopyPositionAndSpriteOffset(super->parent, super); + super->spriteOffsetY -= 24; + if ((s8)super->parent->spriteOffsetX != 0) { + super->spriteOffsetX += (s8)super->parent->spriteOffsetX / 2; } - if (this->action != 0) { - if (*(u32*)&this->cutsceneBeh) { - if (--(*(u32*)&this->cutsceneBeh) == 0) { + if (super->action != 0) { + if (this->unk_84) { + if (--(this->unk_84) == 0) { DeleteThisEntity(); } } - GetNextFrame(this); + GetNextFrame(super); } else { - this->action = 1; - this->spriteRendering.b3 = this->parent->spriteRendering.b3; - this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY; - this->spritePriority.b0 = 0; - InitializeAnimation(this, 3); + super->action = 1; + super->spriteRendering.b3 = super->parent->spriteRendering.b3; + super->spriteOrientation.flipY = super->parent->spriteOrientation.flipY; + super->spritePriority.b0 = 0; + InitializeAnimation(super, 3); } } -void sub_0808F5EC(Entity* this) { - Entity* entity = CreateObjectWithParent(this->child, CHUCHU_BOSS_START_PARTICLE, 5, 0); +void sub_0808F5EC(ChuchuBossStartParticleEntity* this) { + Entity* entity = CreateObjectWithParent(super->child, CHUCHU_BOSS_START_PARTICLE, 5, 0); if (entity != NULL) { - entity->parent = this; - entity->child = this->child; + entity->parent = super; + entity->child = super->child; } - entity = CreateObjectWithParent(this->child, CHUCHU_BOSS_START_PARTICLE, 6, 0); + entity = CreateObjectWithParent(super->child, CHUCHU_BOSS_START_PARTICLE, 6, 0); if (entity != NULL) { - entity->parent = this; - entity->child = this->child; + entity->parent = super; + entity->child = super->child; } - entity = CreateObjectWithParent(this->child, CHUCHU_BOSS_START_PARTICLE, 7, 0); + entity = CreateObjectWithParent(super->child, CHUCHU_BOSS_START_PARTICLE, 7, 0); if (entity != NULL) { - entity->parent = this; - entity->child = this->child; + entity->parent = super; + entity->child = super->child; } - *(u32*)&this->field_0x74 = 600; + this->unk_74 = 600; } diff --git a/src/object/cloud.c b/src/object/cloud.c index f0aa0d55..1252aca6 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -4,69 +4,75 @@ * * @brief Cloud object */ +#define NENT_DEPRECATED #include "functions.h" #include "object.h" #include "structures.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68; +} CloudEntity; + void sub_0809F814(u32 r0); -void sub_0809F7BC(Entity*); -void sub_0809F7F4(Entity*); -void Cloud_Type0(Entity*); -void Cloud_Type1(Entity*); -void sub_0809F514(Entity*); -void sub_0809F548(Entity*); -void sub_0809F5B0(Entity*); -void sub_0809F6CC(Entity*); -void sub_0809F69C(Entity*); -void sub_0809F61C(Entity*); -void sub_0809F5F0(Entity*); -void sub_0809F5DC(Entity*); +void sub_0809F7BC(CloudEntity* this); +void sub_0809F7F4(CloudEntity* this); +void Cloud_Type0(CloudEntity* this); +void Cloud_Type1(CloudEntity* this); +void sub_0809F514(CloudEntity* this); +void sub_0809F548(CloudEntity* this); +void sub_0809F5B0(CloudEntity* this); +void sub_0809F6CC(CloudEntity* this); +void sub_0809F69C(CloudEntity* this); +void sub_0809F61C(CloudEntity* this); +void sub_0809F5F0(CloudEntity* this); +void sub_0809F5DC(CloudEntity* this); extern void* gUnk_080DD750; -void Cloud(Entity* this) { - static void (*const Cloud_Types[])(Entity*) = { +void Cloud(CloudEntity* this) { + static void (*const Cloud_Types[])(CloudEntity*) = { Cloud_Type0, Cloud_Type1, }; - Cloud_Types[this->type](this); + Cloud_Types[super->type](this); } -void Cloud_Type0(Entity* this) { - static void (*const gUnk_081247A0[])(Entity*) = { +void Cloud_Type0(CloudEntity* this) { + static void (*const gUnk_081247A0[])(CloudEntity*) = { sub_0809F514, sub_0809F548, sub_0809F5B0, }; - static void (*const gUnk_081247AC[])(Entity*) = { + static void (*const gUnk_081247AC[])(CloudEntity*) = { sub_0809F5DC, sub_0809F5F0, sub_0809F61C, sub_0809F69C, sub_0809F6CC, }; - if (this->type2 == 0) { - gUnk_081247A0[this->action](this); + if (super->type2 == 0) { + gUnk_081247A0[super->action](this); } else { - gUnk_081247AC[this->action](this); + gUnk_081247AC[super->action](this); } } -void sub_0809F514(Entity* this) { - this->action = 1; - this->timer = 120; - this->spriteSettings.draw = 0; - this->field_0x68.HALF.LO = 12; - gRoomControls.camera_target = this; +void sub_0809F514(CloudEntity* this) { + super->action = 1; + super->timer = 120; + super->spriteSettings.draw = 0; + this->unk_68 = 12; + gRoomControls.camera_target = super; gPauseMenuOptions.disabled = 255; sub_0809F7BC(this); } -void sub_0809F548(Entity* this) { +void sub_0809F548(CloudEntity* this) { - if (--this->timer == 0) { - this->action = 2; - this->timer = 90; + if (--super->timer == 0) { + super->action = 2; + super->timer = 90; SoundReq(SFX_11D); - sub_0809F814((((this->x.HALF.HI - gRoomControls.origin_x) >> 4) & 63) | - (((this->y.HALF.HI - gRoomControls.origin_y) >> 4) & 63) << 6); + sub_0809F814((((super->x.HALF.HI - gRoomControls.origin_x) >> 4) & 63) | + (((super->y.HALF.HI - gRoomControls.origin_y) >> 4) & 63) << 6); } else { if ((gRoomTransition.frameCount & 7) == 0) { sub_0809F7BC(this); @@ -75,8 +81,8 @@ void sub_0809F548(Entity* this) { } } -void sub_0809F5B0(Entity* this) { - if (--this->timer == 0) { +void sub_0809F5B0(CloudEntity* this) { + if (--super->timer == 0) { SoundReq(SFX_SECRET_BIG); SetGlobalFlag(KUMOTATSUMAKI); LoadRoomEntityList((EntityData*)&gUnk_080DD750); @@ -84,37 +90,37 @@ void sub_0809F5B0(Entity* this) { } } -void sub_0809F5DC(Entity* this) { - this->action = 1; - this->spriteSettings.draw = 0; - this->field_0x68.HALF.LO = 12; +void sub_0809F5DC(CloudEntity* this) { + super->action = 1; + super->spriteSettings.draw = 0; + this->unk_68 = 12; } -void sub_0809F5F0(Entity* this) { +void sub_0809F5F0(CloudEntity* this) { u32 iVar1; - iVar1 = CheckRoomFlag(this->timer); + iVar1 = CheckRoomFlag(super->timer); if (iVar1 != 0) { - this->action = 2; - this->timer = 120; + super->action = 2; + super->timer = 120; SetPlayerControl(3); sub_08078B48(); - gRoomControls.camera_target = this; + gRoomControls.camera_target = super; } } -void sub_0809F61C(Entity* this) { +void sub_0809F61C(CloudEntity* this) { if ((gRoomControls.scroll_flags & 4) == 0) { - if (this->timer == 30) { - SetLocalFlag(this->type2); + if (super->timer == 30) { + SetLocalFlag(super->type2); } - if (--this->timer == 0) { - this->action = 3; - this->timer = 120; + if (--super->timer == 0) { + super->action = 3; + super->timer = 120; SoundReq(SFX_11D); - sub_0809F814((((this->x.HALF.HI - gRoomControls.origin_x) >> 4) & 63) | - (((this->y.HALF.HI - gRoomControls.origin_y) >> 4) & 63) << 6); + sub_0809F814((((super->x.HALF.HI - gRoomControls.origin_x) >> 4) & 63) | + (((super->y.HALF.HI - gRoomControls.origin_y) >> 4) & 63) << 6); } else { if ((gRoomTransition.frameCount & 7) == 0) { sub_0809F7BC(this); @@ -124,54 +130,54 @@ void sub_0809F61C(Entity* this) { } } -void sub_0809F69C(Entity* this) { +void sub_0809F69C(CloudEntity* this) { - if (--this->timer == 0) { - this->timer = 30; - this->action = 4; + if (--super->timer == 0) { + super->timer = 30; + super->action = 4; gRoomControls.camera_target = &gPlayerEntity; SoundReq(SFX_SECRET_BIG); } } -void sub_0809F6CC(Entity* this) { +void sub_0809F6CC(CloudEntity* this) { - if (((gRoomControls.scroll_flags & 4) == 0) && (--this->timer == 0)) { + if (((gRoomControls.scroll_flags & 4) == 0) && (--super->timer == 0)) { gPlayerState.controlMode = CONTROL_1; DeleteThisEntity(); } } -void Cloud_Type1(Entity* this) { +void Cloud_Type1(CloudEntity* this) { static const s8 gUnk_081247C0[] = { -1, 1, 2, -2, 0, 1, 0, -1, }; u8 bVar1; u32 uVar2; - if (this->action == 0) { - this->action = 1; - this->timer = (Random() & 30) + 8; - this->flags = this->flags | 12; + if (super->action == 0) { + super->action = 1; + super->timer = (Random() & 30) + 8; + super->flags = super->flags | 12; } if ((gRoomTransition.frameCount & 3) == 0) { uVar2 = Random(); - this->spriteOffsetX = gUnk_081247C0[uVar2 & 7]; - this->spriteOffsetY = gUnk_081247C0[uVar2 >> 4 & 7]; + super->spriteOffsetX = gUnk_081247C0[uVar2 & 7]; + super->spriteOffsetY = gUnk_081247C0[uVar2 >> 4 & 7]; } - LinearMoveUpdate(this); - if (--this->timer == 0) { + LinearMoveUpdate(super); + if (--super->timer == 0) { DeleteThisEntity(); } } -Entity* sub_0809F770(Entity* this) { +Entity* sub_0809F770(CloudEntity* this) { Entity* cloud; int uVar1; cloud = CreateObject(CLOUD, 1, 0); if (cloud) { - PositionEntityOnTop(this, cloud); + PositionEntityOnTop(super, cloud); uVar1 = Random(); cloud->x.HALF.HI += ((uVar1 >> 0) & 31) - 16; cloud->y.HALF.HI += ((uVar1 >> 8) & 31) - 16; @@ -181,7 +187,7 @@ Entity* sub_0809F770(Entity* this) { return cloud; } -void sub_0809F7BC(Entity* this) { +void sub_0809F7BC(CloudEntity* this) { static const u16 gUnk_081247C8[] = { 0x100, 0x180, 0x200, 0x280 }; Entity* cloud; u32 uVar1; @@ -197,9 +203,9 @@ void sub_0809F7BC(Entity* this) { } } -void sub_0809F7F4(Entity* this) { - if (--this->field_0x68.HALF.LO == 0) { - this->field_0x68.HALF.LO = 12; +void sub_0809F7F4(CloudEntity* this) { + if (--this->unk_68 == 0) { + this->unk_68 = 12; SoundReq(SFX_184); } } diff --git a/src/object/crackingGround.c b/src/object/crackingGround.c index bf84577b..21845417 100644 --- a/src/object/crackingGround.c +++ b/src/object/crackingGround.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" void CrackingGround(Entity* this) { diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index ecd20008..f40e7de2 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -4,10 +4,8 @@ * * @brief Crenel Bean Sprout object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" diff --git a/src/object/cuccoMinigame.c b/src/object/cuccoMinigame.c index f6b02dd1..2b546d19 100644 --- a/src/object/cuccoMinigame.c +++ b/src/object/cuccoMinigame.c @@ -10,10 +10,10 @@ #include "entity.h" #include "fileselect.h" #include "functions.h" +#include "item.h" #include "npc.h" #include "object.h" #include "script.h" -#include "item.h" typedef struct { Entity base; diff --git a/src/object/cutsceneMiscObject.c b/src/object/cutsceneMiscObject.c index 54423cc0..225657e4 100644 --- a/src/object/cutsceneMiscObject.c +++ b/src/object/cutsceneMiscObject.c @@ -67,49 +67,41 @@ typedef struct { typedef void(CutsceneMiscObjectTypeAction)(CutsceneMiscObjectEntity*); -CutsceneMiscObjectTypeAction sub_08094A5C; -CutsceneMiscObjectTypeAction sub_08094A90; -CutsceneMiscObjectTypeAction sub_08094C30; -CutsceneMiscObjectTypeAction sub_08094C88; -CutsceneMiscObjectTypeAction sub_08094D94; -CutsceneMiscObjectTypeAction sub_08094E30; -CutsceneMiscObjectTypeAction sub_08094FA8; -CutsceneMiscObjectTypeAction sub_08095088; -CutsceneMiscObjectTypeAction sub_08095120; -CutsceneMiscObjectTypeAction sub_08095188; -CutsceneMiscObjectTypeAction sub_080951C4; -CutsceneMiscObjectTypeAction sub_08095288; -CutsceneMiscObjectTypeAction sub_080953A4; -CutsceneMiscObjectTypeAction sub_080953A4; -CutsceneMiscObjectTypeAction sub_080954DC; -CutsceneMiscObjectTypeAction sub_080956B4; -CutsceneMiscObjectTypeAction sub_0809577C; -CutsceneMiscObjectTypeAction sub_080957DC; -CutsceneMiscObjectTypeAction sub_0809584C; -CutsceneMiscObjectTypeAction sub_080958D8; -CutsceneMiscObjectTypeAction sub_08095918; -CutsceneMiscObjectTypeAction sub_08094C88; -CutsceneMiscObjectTypeAction sub_080959CC; -CutsceneMiscObjectTypeAction sub_08095A8C; -CutsceneMiscObjectTypeAction sub_08095B48; -CutsceneMiscObjectTypeAction sub_08095C00; -CutsceneMiscObjectTypeAction sub_080953A4; -CutsceneMiscObjectTypeAction sub_08095C68; -CutsceneMiscObjectTypeAction sub_08095CE0; -CutsceneMiscObjectTypeAction sub_08095CE0; -CutsceneMiscObjectTypeAction sub_08095DBC; -CutsceneMiscObjectTypeAction sub_08095F38; -CutsceneMiscObjectTypeAction sub_08096058; -CutsceneMiscObjectTypeAction sub_08096058; -CutsceneMiscObjectTypeAction sub_08094A90; -CutsceneMiscObjectTypeAction sub_08096084; -CutsceneMiscObjectTypeAction sub_08096084; -CutsceneMiscObjectTypeAction sub_08096168; -CutsceneMiscObjectTypeAction sub_080961F4; -CutsceneMiscObjectTypeAction sub_080961F4; -CutsceneMiscObjectTypeAction sub_080961F4; -CutsceneMiscObjectTypeAction sub_08096284; -CutsceneMiscObjectTypeAction sub_08096290; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type0; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type1; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type2; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type3; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type4; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type5; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type6; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type7; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type8; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type9; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type10; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type11; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type12; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type14; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type15; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type16; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type17; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type18; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type19; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type20; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type22; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type23; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type24; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type25; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type27; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type28; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type30; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type31; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type32; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type35; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type35; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type37; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type38; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type41; +CutsceneMiscObjectTypeAction CutsceneMiscObject_Type42; void sub_08095754(CutsceneMiscObjectEntity*); void sub_080957B4(CutsceneMiscObjectEntity*); @@ -119,18 +111,23 @@ void sub_08095D30(CutsceneMiscObjectEntity*, u32); static void sub_0809629C(CutsceneMiscObjectEntity*, u32); void CutsceneMiscObject(Entity* this) { - static CutsceneMiscObjectTypeAction* const sTypeTable[] = { - sub_08094A5C, sub_08094A90, sub_08094C30, sub_08094C88, sub_08094D94, sub_08094E30, sub_08094FA8, sub_08095088, - sub_08095120, sub_08095188, sub_080951C4, sub_08095288, sub_080953A4, sub_080953A4, sub_080954DC, sub_080956B4, - sub_0809577C, sub_080957DC, sub_0809584C, sub_080958D8, sub_08095918, sub_08094C88, sub_080959CC, sub_08095A8C, - sub_08095B48, sub_08095C00, sub_080953A4, sub_08095C68, sub_08095CE0, sub_08095CE0, sub_08095DBC, sub_08095F38, - sub_08096058, sub_08096058, sub_08094A90, sub_08096084, sub_08096084, sub_08096168, sub_080961F4, sub_080961F4, - sub_080961F4, sub_08096284, sub_08096290, + static CutsceneMiscObjectTypeAction* const CutsceneMiscObject_Types[] = { + CutsceneMiscObject_Type0, CutsceneMiscObject_Type1, CutsceneMiscObject_Type2, CutsceneMiscObject_Type3, + CutsceneMiscObject_Type4, CutsceneMiscObject_Type5, CutsceneMiscObject_Type6, CutsceneMiscObject_Type7, + CutsceneMiscObject_Type8, CutsceneMiscObject_Type9, CutsceneMiscObject_Type10, CutsceneMiscObject_Type11, + CutsceneMiscObject_Type12, CutsceneMiscObject_Type12, CutsceneMiscObject_Type14, CutsceneMiscObject_Type15, + CutsceneMiscObject_Type16, CutsceneMiscObject_Type17, CutsceneMiscObject_Type18, CutsceneMiscObject_Type19, + CutsceneMiscObject_Type20, CutsceneMiscObject_Type3, CutsceneMiscObject_Type22, CutsceneMiscObject_Type23, + CutsceneMiscObject_Type24, CutsceneMiscObject_Type25, CutsceneMiscObject_Type12, CutsceneMiscObject_Type27, + CutsceneMiscObject_Type28, CutsceneMiscObject_Type28, CutsceneMiscObject_Type30, CutsceneMiscObject_Type31, + CutsceneMiscObject_Type32, CutsceneMiscObject_Type32, CutsceneMiscObject_Type1, CutsceneMiscObject_Type35, + CutsceneMiscObject_Type35, CutsceneMiscObject_Type37, CutsceneMiscObject_Type38, CutsceneMiscObject_Type38, + CutsceneMiscObject_Type38, CutsceneMiscObject_Type41, CutsceneMiscObject_Type42, }; - sTypeTable[this->type]((CutsceneMiscObjectEntity*)this); + CutsceneMiscObject_Types[this->type]((CutsceneMiscObjectEntity*)this); } -void sub_08094A5C(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type0(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; sub_0807DD64(super); @@ -141,7 +138,7 @@ void sub_08094A5C(CutsceneMiscObjectEntity* this) { GetNextFrame(super); } -void sub_08094A90(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type1(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->collisionLayer = 2; @@ -209,7 +206,7 @@ void sub_08094BE0(Entity* this) { } } -void sub_08094C30(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type2(CutsceneMiscObjectEntity* this) { Entity* p = super->parent; if (p == NULL || p->next == NULL) DeleteThisEntity(); @@ -223,7 +220,7 @@ void sub_08094C30(CutsceneMiscObjectEntity* this) { UpdateAnimationSingleFrame(super); } -void sub_08094C88(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type3(CutsceneMiscObjectEntity* this) { u32 tmp; if (super->action != 0) { @@ -282,7 +279,7 @@ void sub_08094D70(CutsceneMiscObjectEntity* this) { } } -void sub_08094D94(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type4(CutsceneMiscObjectEntity* this) { u32 tmp; if (super->action != 0) { @@ -315,7 +312,7 @@ void sub_08094E0C(CutsceneMiscObjectEntity* this) { } } -void sub_08094E30(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type5(CutsceneMiscObjectEntity* this) { if (super->type2 == 0) { if ((gRoomTransition.frameCount % 32) == 0) { Entity* e = CreateObject(0x6A, 5, 1); @@ -389,7 +386,7 @@ void sub_08094F98(CutsceneMiscObjectEntity* this) { CreateObject(CUTSCENE_MISC_OBJECT, 5, 0); } -void sub_08094FA8(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type6(CutsceneMiscObjectEntity* this) { switch (super->action) { case 0: super->action = 1; @@ -440,7 +437,7 @@ void sub_08094FA8(CutsceneMiscObjectEntity* this) { } } -void sub_08095088(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type7(CutsceneMiscObjectEntity* this) { u32 tmp; switch (super->action) { @@ -472,7 +469,7 @@ void sub_08095088(CutsceneMiscObjectEntity* this) { super->type = tmp; } -void sub_08095120(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type8(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action = 1; SetDefaultPriority(super, PRIO_NO_BLOCK); @@ -492,7 +489,7 @@ void sub_08095164(CutsceneMiscObjectEntity* this) { } } -void sub_08095188(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type9(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action = 1; SetDefaultPriority(super, PRIO_NO_BLOCK); @@ -504,7 +501,7 @@ void sub_08095188(CutsceneMiscObjectEntity* this) { HandleEntity0x82Actions(super); } -void sub_080951C4(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type10(CutsceneMiscObjectEntity* this) { Entity* p; if (super->action == 0) { @@ -544,7 +541,7 @@ void sub_08095244(CutsceneMiscObjectEntity* this) { } } -void sub_08095288(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type11(CutsceneMiscObjectEntity* this) { Entity* p; if (super->action == 0) { @@ -606,7 +603,7 @@ void sub_08095364(CutsceneMiscObjectEntity* this) { } } -void sub_080953A4(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type12(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->z.HALF.HI = -16; @@ -658,7 +655,7 @@ void sub_080954AC(CutsceneMiscObjectEntity* this, u32 arg2) { } } -void sub_080954DC(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type14(CutsceneMiscObjectEntity* this) { switch (super->action) { case 0: if (super->timer != 0) { @@ -717,7 +714,7 @@ void sub_0809567C(CutsceneMiscObjectEntity* this) { super->direction = sub_080045DA(super->x.WORD - ((s16)this->px << 16), super->y.WORD - ((s16)this->py << 16)); } -void sub_080956B4(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type15(CutsceneMiscObjectEntity* this) { Entity* p; u16* p1; u16* p2; @@ -771,7 +768,7 @@ void sub_08095754(CutsceneMiscObjectEntity* this) { } } -void sub_0809577C(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type16(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->z.HALF.HI = -16; @@ -791,7 +788,7 @@ void sub_080957B4(CutsceneMiscObjectEntity* this) { } } -void sub_080957DC(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type17(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; sub_0807DD64(super); @@ -812,7 +809,7 @@ void sub_08095810(CutsceneMiscObjectEntity* this) { } } -void sub_0809584C(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type18(CutsceneMiscObjectEntity* this) { u32 tmp, idx; idx = super->health; @@ -835,7 +832,7 @@ void sub_0809584C(CutsceneMiscObjectEntity* this) { super->type = tmp; } -void sub_080958D8(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type19(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; sub_0807DD64(super); @@ -847,7 +844,7 @@ void sub_080958D8(CutsceneMiscObjectEntity* this) { sub_08095954(this); } -void sub_08095918(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type20(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; SetDefaultPriority(super, PRIO_PLAYER_EVENT); @@ -881,7 +878,7 @@ void sub_08095954(CutsceneMiscObjectEntity* this) { } } -void sub_080959CC(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type22(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->spriteSettings.draw = 0; @@ -912,7 +909,7 @@ void sub_08095A68(CutsceneMiscObjectEntity* this) { } } -void sub_08095A8C(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type23(CutsceneMiscObjectEntity* this) { switch (super->action) { case 0: super->action++; @@ -945,7 +942,7 @@ void sub_08095A8C(CutsceneMiscObjectEntity* this) { } } -void sub_08095B48(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type24(CutsceneMiscObjectEntity* this) { Entity* p; u32 tmp; @@ -985,7 +982,7 @@ void sub_08095BE0(CutsceneMiscObjectEntity* this, u32 val) { } } -void sub_08095C00(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type25(CutsceneMiscObjectEntity* this) { if (super->action & 0x80) { DeleteThisEntity(); } else { @@ -1009,7 +1006,7 @@ void sub_08095C48(Entity* this) { } } -void sub_08095C68(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type27(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; sub_080042D0(super, super->frameIndex, (u16)super->spriteIndex); @@ -1037,7 +1034,7 @@ void sub_08095CB0(CutsceneMiscObjectEntity* this) { } } -void sub_08095CE0(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type28(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->spriteSettings.draw = 0; @@ -1072,7 +1069,7 @@ void sub_08095D8C(CutsceneMiscObjectEntity* this, ScriptExecutionContext* ctx) { } } -void sub_08095DBC(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type30(CutsceneMiscObjectEntity* this) { if (gActiveScriptInfo.syncFlags & 0x10) DeleteThisEntity(); if (super->type2 == 0) { @@ -1139,7 +1136,7 @@ void sub_08095EAC(Entity* this, ScriptExecutionContext* ctx) { } #define local ((Type1F*)this) -void sub_08095F38(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type31(CutsceneMiscObjectEntity* this) { u32 tmp; if (super->action == 0) { @@ -1193,7 +1190,7 @@ void sub_08096028(CutsceneMiscObjectEntity* this) { CreateObject(CUTSCENE_MISC_OBJECT, 0x1F, type2); } -void sub_08096058(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type32(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; sub_0807DD64(super); @@ -1203,7 +1200,7 @@ void sub_08096058(CutsceneMiscObjectEntity* this) { GetNextFrame(super); } -void sub_08096084(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type35(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; sub_0807DD64(super); @@ -1237,7 +1234,7 @@ void sub_080960C4(CutsceneMiscObjectEntity* this, ScriptExecutionContext* ctx) { } } -void sub_08096168(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type37(CutsceneMiscObjectEntity* this) { if (super->action == 0) { super->action++; super->spriteSettings.draw = 1; @@ -1261,7 +1258,7 @@ void sub_080961B0(CutsceneMiscObjectEntity* this) { } } -void sub_080961F4(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type38(CutsceneMiscObjectEntity* this) { super->spriteSettings.draw = 1; super->frameIndex = 0; } @@ -1288,11 +1285,11 @@ void sub_08096260(CutsceneMiscObjectEntity* this) { } } -void sub_08096284(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type41(CutsceneMiscObjectEntity* this) { sub_0809629C(this, 0xd); } -void sub_08096290(CutsceneMiscObjectEntity* this) { +void CutsceneMiscObject_Type42(CutsceneMiscObjectEntity* this) { sub_0809629C(this, 0xe); } diff --git a/src/object/cutsceneOrchestrator.c b/src/object/cutsceneOrchestrator.c index cdd0a4eb..5e93c5d8 100644 --- a/src/object/cutsceneOrchestrator.c +++ b/src/object/cutsceneOrchestrator.c @@ -2,8 +2,9 @@ * @file cutsceneOrchestrator.c * @ingroup Objects * - * @brief CutsceneO rchestrator object + * @brief Cutscene Orchestrator object */ +#define NENT_DEPRECATED #include "entity.h" #include "functions.h" #include "hitbox.h" diff --git a/src/object/deathFx.c b/src/object/deathFx.c index cf1d53ed..e6121ec0 100644 --- a/src/object/deathFx.c +++ b/src/object/deathFx.c @@ -5,11 +5,11 @@ * @brief Death Fx object */ #define NENT_DEPRECATED +#include "object/deathFx.h" #include "enemy.h" #include "entity.h" #include "functions.h" #include "global.h" -#include "object/deathFx.h" #include "sound.h" void sub_08081790(DeathFxObject* this); diff --git a/src/object/dirtParticle.c b/src/object/dirtParticle.c index 7e6b594d..8bf6bd31 100644 --- a/src/object/dirtParticle.c +++ b/src/object/dirtParticle.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/doubleBookshelf.c b/src/object/doubleBookshelf.c index 877c3014..3003c776 100644 --- a/src/object/doubleBookshelf.c +++ b/src/object/doubleBookshelf.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/enemyItem.c b/src/object/enemyItem.c index 862f184e..3f199ff8 100644 --- a/src/object/enemyItem.c +++ b/src/object/enemyItem.c @@ -4,10 +4,8 @@ * * @brief Enemy Item object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/eyeSwitch.c b/src/object/eyeSwitch.c index 6a584d68..8769fd4f 100644 --- a/src/object/eyeSwitch.c +++ b/src/object/eyeSwitch.c @@ -19,20 +19,20 @@ typedef struct { u16 eyeSwitchFlags2; } EyeSwitchEntity; -void sub_080886A4(EyeSwitchEntity* this); -void sub_08088718(EyeSwitchEntity* this); -void sub_08088760(EyeSwitchEntity* this); -void sub_08088790(EyeSwitchEntity* this); -void sub_080887D8(EyeSwitchEntity* this); +void EyeSwitch_Init(EyeSwitchEntity* this); +void EyeSwitch_Action1(EyeSwitchEntity* this); +void EyeSwitch_Action2(EyeSwitchEntity* this); +void EyeSwitch_Action3(EyeSwitchEntity* this); +void EyeSwitch_Action4(EyeSwitchEntity* this); void EyeSwitch(Entity* this) { - static void (*const actionFuncs[])(EyeSwitchEntity*) = { - sub_080886A4, sub_08088718, sub_08088760, sub_08088790, sub_080887D8, + static void (*const EyeSwitch_Actions[])(EyeSwitchEntity*) = { + EyeSwitch_Init, EyeSwitch_Action1, EyeSwitch_Action2, EyeSwitch_Action3, EyeSwitch_Action4, }; - actionFuncs[this->action]((EyeSwitchEntity*)this); + EyeSwitch_Actions[this->action]((EyeSwitchEntity*)this); } -void sub_080886A4(EyeSwitchEntity* this) { +void EyeSwitch_Init(EyeSwitchEntity* this) { super->animationState = super->type & 3; super->spritePriority.b0 = 6; super->collisionFlags = 7; @@ -50,7 +50,7 @@ void sub_080886A4(EyeSwitchEntity* this) { } } -void sub_08088718(EyeSwitchEntity* this) { +void EyeSwitch_Action1(EyeSwitchEntity* this) { if ((super->contactFlags == 0x95 || super->contactFlags == 0x8e) && (DirectionRoundUp(super->contactedEntity->direction) >> 3 == (super->animationState & 3))) { super->action = 2; @@ -60,7 +60,7 @@ void sub_08088718(EyeSwitchEntity* this) { } } -void sub_08088760(EyeSwitchEntity* this) { +void EyeSwitch_Action2(EyeSwitchEntity* this) { GetNextFrame(super); if ((super->frame & ANIM_DONE) != 0) { super->action = 3; @@ -69,7 +69,7 @@ void sub_08088760(EyeSwitchEntity* this) { } } -void sub_08088790(EyeSwitchEntity* this) { +void EyeSwitch_Action3(EyeSwitchEntity* this) { if (super->timer != 0) { if ((this->eyeSwitchFlags2 != this->eyeSwitchFlags) && (CheckFlags(this->eyeSwitchFlags))) { super->timer = 0; @@ -82,7 +82,7 @@ void sub_08088790(EyeSwitchEntity* this) { } } -void sub_080887D8(EyeSwitchEntity* this) { +void EyeSwitch_Action4(EyeSwitchEntity* this) { GetNextFrame(super); if ((super->frame & ANIM_DONE) != 0) { super->action = 1; diff --git a/src/object/ezloCap.c b/src/object/ezloCap.c index 256a505c..6465dad9 100644 --- a/src/object/ezloCap.c +++ b/src/object/ezloCap.c @@ -4,10 +4,8 @@ * * @brief Ezlo Cap object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "message.h" #include "object.h" diff --git a/src/object/ezloCapFlying.c b/src/object/ezloCapFlying.c index f2d40b72..d05ada5f 100644 --- a/src/object/ezloCapFlying.c +++ b/src/object/ezloCapFlying.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "new_player.h" #include "object.h" diff --git a/src/object/fairy.c b/src/object/fairy.c index 8b177ced..ba3b6703 100644 --- a/src/object/fairy.c +++ b/src/object/fairy.c @@ -4,11 +4,9 @@ * * @brief Fairy object */ - #define NENT_DEPRECATED #include "collision.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "item.h" #include "object.h" @@ -36,6 +34,8 @@ void Fairy_SubAction0(FairyEntity*); void Fairy_SubAction1(FairyEntity*); void Fairy_SubAction2(FairyEntity*); +extern void sub_08081404(Entity*, u32); + void Fairy(FairyEntity* this) { static void (*const Fairy_Actions[])(FairyEntity*) = { Fairy_Init, Fairy_Action1, Fairy_Action2, Fairy_Action3, Fairy_Action4, diff --git a/src/object/fan.c b/src/object/fan.c index f9ee5fc5..b1197147 100644 --- a/src/object/fan.c +++ b/src/object/fan.c @@ -9,7 +9,6 @@ #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "object.h" #include "player.h" #include "sound.h" diff --git a/src/object/fanWind.c b/src/object/fanWind.c index 9b8762f8..3f6d74b3 100644 --- a/src/object/fanWind.c +++ b/src/object/fanWind.c @@ -4,10 +4,10 @@ * * @brief Fan Wind object */ +#define NENT_DEPRECATED #include "collision.h" #include "entity.h" #include "functions.h" -#include "global.h" void FanWind(Entity* this) { u8* collisionData; diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c index bf406be3..927d74ad 100644 --- a/src/object/figurineDevice.c +++ b/src/object/figurineDevice.c @@ -4,13 +4,12 @@ * * @brief Figurine Device object */ - #define NENT_DEPRECATED #include "figurineMenu.h" #include "fileselect.h" #include "functions.h" -#include "kinstone.h" #include "item.h" +#include "kinstone.h" #include "message.h" #include "object.h" #include "screen.h" diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c index 23233f96..0b346a52 100644 --- a/src/object/fileScreenObjects.c +++ b/src/object/fileScreenObjects.c @@ -4,6 +4,7 @@ * * @brief File Screen Objects object */ +#define NENT_DEPRECATED #include "fileselect.h" #include "functions.h" #include "main.h" @@ -11,30 +12,39 @@ #include "object.h" #include "player.h" -extern u32 sub_080041EC(int, int); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; + /*0x6a*/ u16 unk_6a; + /*0x6c*/ u16 unk_6c; + /*0x6e*/ u8 unused1[2]; + /*0x70*/ u8 unk_70; +} FileScreenObjectsEntity; + +extern u32 sub_080041EC(s32, s32); static bool32 sub_0808E950(void); -static void sub_0808EABC(Entity*); -static Entity* sub_0808EC80(int); -static u32 sub_0808EF6C(Entity*); -static void sub_0808EFF0(Entity*); -static void sub_0808EA28(Entity*); -static void sub_0808E7D8(Entity*); -static void sub_0808E988(Entity*); -static void sub_0808E9F4(Entity*); -static void sub_0808EBB8(Entity*); -static void sub_0808ECBC(Entity*); -static void sub_0808ED64(Entity*); -static void sub_0808E9F4(Entity*); -static void sub_0808ED98(Entity*); -static void sub_0808EE00(Entity*); -static void nullsub_522(Entity*); -static void sub_0808EB74(Entity*); -static void sub_0808EE98(Entity*); -static void sub_0808EED8(Entity*); -static void sub_0808EF24(Entity*); -static void sub_0808E818(Entity*); -static void sub_0808E7F0(Entity*); +static void sub_0808EABC(FileScreenObjectsEntity*); +static Entity* sub_0808EC80(s32); +static u32 sub_0808EF6C(FileScreenObjectsEntity*); +static void sub_0808EFF0(FileScreenObjectsEntity*); +static void FileScreenObjects_Type0(FileScreenObjectsEntity*); +static void FileScreenObjects_Type23(FileScreenObjectsEntity*); +static void FileScreenObjects_Type24(FileScreenObjectsEntity*); +static void FileScreenObjects_Type25(FileScreenObjectsEntity*); +static void FileScreenObjects_Type16(FileScreenObjectsEntity*); +static void FileScreenObjects_Type4(FileScreenObjectsEntity*); +static void FileScreenObjects_Type8(FileScreenObjectsEntity*); +static void FileScreenObjects_Type25(FileScreenObjectsEntity*); +static void FileScreenObjects_Type9(FileScreenObjectsEntity*); +static void FileScreenObjects_Type10(FileScreenObjectsEntity*); +static void FileScreenObjects_Type17(FileScreenObjectsEntity*); +static void FileScreenObjects_Type15(FileScreenObjectsEntity*); +static void FileScreenObjects_Type18(FileScreenObjectsEntity*); +static void FileScreenObjects_Type19(FileScreenObjectsEntity*); +static void FileScreenObjects_Type21(FileScreenObjectsEntity*); +static void FileScreenObjects_Type23_Action1(FileScreenObjectsEntity*); +static void FileScreenObjects_Type23_Init(FileScreenObjectsEntity*); typedef struct { u8 unk0; @@ -52,58 +62,61 @@ typedef struct { u8 unk7; } struct_08121D54; -extern const int gUnk_08133368[]; +extern const s32 gUnk_08133368[]; -void FileScreenObjects(Entity* this) { - static void (*const gUnk_08121C64[])(Entity*) = { - sub_0808EA28, sub_0808EA28, sub_0808EA28, sub_0808EA28, sub_0808ECBC, sub_0808ECBC, sub_0808ECBC, - sub_0808ECBC, sub_0808ED64, sub_0808ED98, sub_0808EE00, sub_0808EE00, sub_0808EE00, sub_0808EE00, - sub_0808EE00, sub_0808EB74, sub_0808EBB8, nullsub_522, sub_0808EE98, sub_0808EED8, sub_0808EED8, - sub_0808EF24, sub_0808EF24, sub_0808E7D8, sub_0808E988, sub_0808E9F4, +void FileScreenObjects(FileScreenObjectsEntity* this) { + static void (*const FileScreenObjects_Types[])(FileScreenObjectsEntity*) = { + FileScreenObjects_Type0, FileScreenObjects_Type0, FileScreenObjects_Type0, FileScreenObjects_Type0, + FileScreenObjects_Type4, FileScreenObjects_Type4, FileScreenObjects_Type4, FileScreenObjects_Type4, + FileScreenObjects_Type8, FileScreenObjects_Type9, FileScreenObjects_Type10, FileScreenObjects_Type10, + FileScreenObjects_Type10, FileScreenObjects_Type10, FileScreenObjects_Type10, FileScreenObjects_Type15, + FileScreenObjects_Type16, FileScreenObjects_Type17, FileScreenObjects_Type18, FileScreenObjects_Type19, + FileScreenObjects_Type19, FileScreenObjects_Type21, FileScreenObjects_Type21, FileScreenObjects_Type23, + FileScreenObjects_Type24, FileScreenObjects_Type25, }; - if (this->health == 0) { + if (super->health == 0) { sub_0808EFF0(this); } - gUnk_08121C64[this->type](this); - if (this->animIndex < 64) { - UpdateAnimationSingleFrame(this); + FileScreenObjects_Types[super->type](this); + if (super->animIndex < 64) { + UpdateAnimationSingleFrame(super); } } -void sub_0808E7D8(Entity* this) { - static void (*const gUnk_08121CCC[])(Entity*) = { - sub_0808E7F0, - sub_0808E818, +void FileScreenObjects_Type23(FileScreenObjectsEntity* this) { + static void (*const FileScreenObjects_Type23_Actions[])(FileScreenObjectsEntity*) = { + FileScreenObjects_Type23_Init, + FileScreenObjects_Type23_Action1, }; - gUnk_08121CCC[this->action](this); + FileScreenObjects_Type23_Actions[super->action](this); } -void sub_0808E7F0(Entity* this) { - LoadSwapGFX(this, 1, 2); - this->palette.b.b0 = 0xF; - this->spriteSettings.draw = 0; - this->type2 = 0xFF; - this->action = 1; +void FileScreenObjects_Type23_Init(FileScreenObjectsEntity* this) { + LoadSwapGFX(super, 1, 2); + super->palette.b.b0 = 0xF; + super->spriteSettings.draw = 0; + super->type2 = 0xFF; + super->action = 1; } -void sub_0808E818(Entity* this) { +void FileScreenObjects_Type23_Action1(FileScreenObjectsEntity* this) { u32 var0; u32 offset; if (!sub_0808E950()) { - int var2 = -1; - this->type2 = var2; - this->field_0x68.HWORD = var2; - this->field_0x6a.HWORD = var2; - this->spriteSettings.draw = 0; + s32 var2 = -1; + super->type2 = var2; + this->unk_68 = var2; + this->unk_6a = var2; + super->spriteSettings.draw = 0; return; } - if (this->type2 != gMapDataBottomSpecial.unk6) { - this->type2 = gMapDataBottomSpecial.unk6; - this->field_0x68.HWORD = CheckGlobalFlag(EZERO_1ST) == 0 ? 0x400 : 0x100; - this->field_0x70.BYTES.byte0 = 4; - this->animationState = 2; + if (super->type2 != gMapDataBottomSpecial.unk6) { + super->type2 = gMapDataBottomSpecial.unk6; + this->unk_68 = CheckGlobalFlag(EZERO_1ST) == 0 ? 0x400 : 0x100; + this->unk_70 = 4; + super->animationState = 2; offset = gUnk_08133368[GetPlayerPalette(TRUE) - 22] & 0xFFFFFF; LoadPalettes(&gGlobalGfxAndPalettes[offset], 31, 1); } @@ -112,33 +125,33 @@ void sub_0808E818(Entity* this) { if (gInput.heldKeys & L_BUTTON) { switch (gInput.newKeys) { case DPAD_UP: - this->animationState = 0; + super->animationState = 0; break; case DPAD_RIGHT: - this->animationState = 1; + super->animationState = 1; break; case DPAD_DOWN: - this->animationState = 2; + super->animationState = 2; break; case DPAD_LEFT: - this->animationState = 3; + super->animationState = 3; break; case B_BUTTON: - this->field_0x70.BYTES.byte0 = this->field_0x70.BYTES.byte0 ? 0 : 4; + this->unk_70 = this->unk_70 ? 0 : 4; break; } } } - this->spriteSettings.flipX = this->animationState == 3; - var0 = this->field_0x68.HWORD + this->field_0x70.BYTES.byte0 + this->animationState; - if (this->field_0x6a.HWORD != var0) { - this->field_0x6a.HWORD = var0; - this->spriteIndex = var0 >> 8; - InitAnimationForceUpdate(this, (u8)var0); + super->spriteSettings.flipX = super->animationState == 3; + var0 = this->unk_68 + this->unk_70 + super->animationState; + if (this->unk_6a != var0) { + this->unk_6a = var0; + super->spriteIndex = var0 >> 8; + InitAnimationForceUpdate(super, (u8)var0); } - this->spriteSettings.draw = 2; + super->spriteSettings.draw = 2; } static bool32 sub_0808E950(void) { @@ -155,20 +168,20 @@ static bool32 sub_0808E950(void) { return result; } -void sub_0808E988(Entity* this) { - if (this->action == 0) { - this->action = 1; +void FileScreenObjects_Type24(FileScreenObjectsEntity* this) { + if (super->action == 0) { + super->action = 1; #ifdef EU - this->spriteIndex = 0x141; + super->spriteIndex = 0x141; #else - this->spriteIndex = 0x142; + super->spriteIndex = 0x142; #endif - this->type2 = 0xFF; - LoadSwapGFX(this, 1, 3); + super->type2 = 0xFF; + LoadSwapGFX(super, 1, 3); } if (sub_0808E950()) { - int i; + s32 i; for (i = 6; i != 0; i--) { if (GetInventoryValue(i)) { break; @@ -176,42 +189,42 @@ void sub_0808E988(Entity* this) { } if (i != 0) { - if (this->type2 != i) { - InitAnimationForceUpdate(this, i); + if (super->type2 != i) { + InitAnimationForceUpdate(super, i); } - this->spriteSettings.draw = 2; + super->spriteSettings.draw = 2; return; } } - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; } -void sub_0808E9F4(Entity* this) { +void FileScreenObjects_Type25(FileScreenObjectsEntity* this) { if (sub_0808E950() && gSave.saw_staffroll) { - this->spriteSettings.draw = 2; + super->spriteSettings.draw = 2; } else { - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; } } -void sub_0808EA28(Entity* this) { +void FileScreenObjects_Type0(FileScreenObjectsEntity* this) { u32 var0; u32 var1; - if (this->type == 3) { + if (super->type == 3) { if (gSaveHeader->language > LANGUAGE_EN) { - this->spriteSettings.draw = 2; + super->spriteSettings.draw = 2; } else { - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; } } - if (this->type == gMapDataBottomSpecial.unk6) { + if (super->type == gMapDataBottomSpecial.unk6) { var0 = 12; var1 = 1; } else { - if (gUI.lastState == 5 && this->type == gMapDataBottomSpecial.unk7) { + if (gUI.lastState == 5 && super->type == gMapDataBottomSpecial.unk7) { var0 = 13; var1 = 2; } else { @@ -220,16 +233,16 @@ void sub_0808EA28(Entity* this) { } } - this->palette.b.b0 = var0; - this->spriteRendering.b3 = var1; + super->palette.b.b0 = var0; + super->spriteRendering.b3 = var1; sub_0808EABC(this); gMapDataBottomSpecial.isTransitioning |= sub_0808EF6C(this); } -void sub_0808EABC(Entity* this) { - int var0 = -72; - int var1 = this->type * 32 + 40; - int var2 = gMapDataBottomSpecial.unk6 == this->type; +void sub_0808EABC(FileScreenObjectsEntity* this) { + s32 var0 = -72; + s32 var1 = super->type * 32 + 40; + s32 var2 = gMapDataBottomSpecial.unk6 == super->type; switch (gUI.lastState) { case 0: var0 = 24; @@ -244,7 +257,7 @@ void sub_0808EABC(Entity* this) { } break; case 5: - switch (gGenericMenu.unk10.a[this->type]) { + switch (gGenericMenu.unk10.a[super->type]) { case 0: var0 = 42; var1 = 40; @@ -253,7 +266,7 @@ void sub_0808EABC(Entity* this) { case 2: var0 = 20; var1 = 144; - var1 -= (gGenericMenu.unk16 - gGenericMenu.unk10.a[this->type]) * 32; + var1 -= (gGenericMenu.unk16 - gGenericMenu.unk10.a[super->type]) * 32; break; } break; @@ -271,24 +284,24 @@ void sub_0808EABC(Entity* this) { break; } - this->field_0x68.HWORD = var0; - this->field_0x6a.HWORD = var1; + this->unk_68 = var0; + this->unk_6a = var1; } -void sub_0808EB74(Entity* this) { +void FileScreenObjects_Type15(FileScreenObjectsEntity* this) { Entity* entity = sub_0808EC80(gMapDataBottomSpecial.unk6); if (entity != NULL) { - this->x.WORD = entity->x.WORD; - this->y.WORD = entity->y.WORD; - this->spriteRendering.b3 = entity->spriteRendering.b3; - SortEntityBelow(entity, this); + super->x.WORD = entity->x.WORD; + super->y.WORD = entity->y.WORD; + super->spriteRendering.b3 = entity->spriteRendering.b3; + SortEntityBelow(entity, super); } else { - this->x.HALF.HI = 0xF000; - this->y.HALF.HI = 0xF000; + super->x.HALF.HI = 0xF000; + super->y.HALF.HI = 0xF000; } } -void sub_0808EBB8(Entity* this) { +void FileScreenObjects_Type16(FileScreenObjectsEntity* this) { u32 var0; u32 x, y; Entity* entity; @@ -331,19 +344,19 @@ void sub_0808EBB8(Entity* this) { default: entity = sub_0808EC80(var0); if (entity != NULL) { - SortEntityBelow(entity, this); - this->spriteRendering.b3 = entity->spriteRendering.b3; + SortEntityBelow(entity, super); + super->spriteRendering.b3 = entity->spriteRendering.b3; x = entity->x.HALF.HI; y = entity->y.HALF.HI; } break; } - this->x.HALF.HI = x; - this->y.HALF.HI = y; + super->x.HALF.HI = x; + super->y.HALF.HI = y; } -static Entity* sub_0808EC80(int form) { +static Entity* sub_0808EC80(s32 form) { Entity* entityA = (Entity*)&gEntityLists[6]; Entity* entityB = entityA->next; while (entityB != entityA) { @@ -355,7 +368,7 @@ static Entity* sub_0808EC80(int form) { return NULL; } -void sub_0808ECBC(Entity* this) { +void FileScreenObjects_Type4(FileScreenObjectsEntity* this) { static const struct_08121CD4 gUnk_08121CD4[][4] = { { { 0x9, 0x18, 0xb0 }, { 0x9, 0x60, 0xb0 }, { 0x9, 0xa8, 0xb0 }, { 0x9, 0x40, 0xb0 } }, { { 0x0, 0x18, 0x90 }, { 0x1, 0x60, 0x90 }, { 0x2, 0xa8, 0x90 }, { 0x9, 0x40, 0xb0 } }, @@ -363,9 +376,9 @@ void sub_0808ECBC(Entity* this) { { { 0x9, 0x18, 0xb0 }, { 0x9, 0x60, 0xb0 }, { 0x1, 0x88, 0x90 }, { 0x0, 0x40, 0x90 } }, { { 0x0, 0x18, 0x90 }, { 0x9, 0x60, 0xb0 }, { 0x9, 0xa8, 0xb0 }, { 0x9, 0x40, 0xb0 } } }; - int var0; - int var1; - int var2; + s32 var0; + s32 var1; + s32 var2; const struct_08121CD4* var3; var0 = gMenu.column_idx; @@ -388,66 +401,66 @@ void sub_0808ECBC(Entity* this) { break; } - var2 = this->type - 4; + var2 = super->type - 4; var3 = &gUnk_08121CD4[var1][var2]; - this->field_0x68.HWORD = var3->unk1; - this->field_0x6a.HWORD = var3->unk2; + this->unk_68 = var3->unk1; + this->unk_6a = var3->unk2; if (var3->unk0 == var0) { - this->palette.b.b0 = 13; + super->palette.b.b0 = 13; } else { - this->palette.b.b0 = 14; + super->palette.b.b0 = 14; } gMapDataBottomSpecial.isTransitioning |= sub_0808EF6C(this); } -void sub_0808ED64(Entity* this) { - int y = 255; +void FileScreenObjects_Type8(FileScreenObjectsEntity* this) { + s32 y = 255; if (gUI.lastState == 1 && gGenericMenu.unk10.a[1] != 5) { - this->x.HALF.HI = gGenericMenu.unk10.a[0] * 16 + 28; + super->x.HALF.HI = gGenericMenu.unk10.a[0] * 16 + 28; y = gGenericMenu.unk10.a[1] * 16 + 58; } - this->y.HALF.HI = y; + super->y.HALF.HI = y; } -void sub_0808ED98(Entity* this) { +void FileScreenObjects_Type9(FileScreenObjectsEntity* this) { static const s8 gUnk_08121D10[] = { 0, -1, -3, -2, -2, -1, 0, 0, }; - int y; + s32 y; if (gUI.lastState != 1) { - this->field_0x68.HWORD = 27; + this->unk_68 = 27; y = -10; } else { u32 var0 = gGenericMenu.unk10.a[3]; if (var0 > 5) { var0 = 5; } - this->field_0x68.HWORD = var0 * 8 + 27; + this->unk_68 = var0 * 8 + 27; y = 24; } - this->y.HALF.HI = y; - this->field_0x6a.HWORD = y; - this->subtimer++; - this->spriteOffsetY = gUnk_08121D10[(this->subtimer / 4) & 0x7]; + super->y.HALF.HI = y; + this->unk_6a = y; + super->subtimer++; + super->spriteOffsetY = gUnk_08121D10[(super->subtimer / 4) & 0x7]; sub_0808EF6C(this); } -void sub_0808EE00(Entity* this) { +void FileScreenObjects_Type10(FileScreenObjectsEntity* this) { static const u16 gUnk_08121D18[][8] = { { 0x2c, 0x54, 0x7c, 0xa4, 0xcc, 0x0, 0x0, 0x0 }, { 0xfff, 0x2e, 0x62, 0x96, 0xca, 0x0, 0x0, 0x0 } }; static const u8 gUnk_08121D38[][8] = { { 12, 13, 14, 16, 17, 0, 0, 0 }, { -1, 14, 15, 16, 17, 0, 0, 0 }, }; - int var0, var1, var2; + s32 var0, var1, var2; var0 = ((SaveHeader*)0x2000000)->language != 0; - var1 = this->type - 10; - this->frameIndex = gUnk_08121D38[var0][var1]; - this->x.HALF.HI = gUnk_08121D18[var0][var1]; - this->field_0x68.HWORD = gUnk_08121D18[var0][var1]; + var1 = super->type - 10; + super->frameIndex = gUnk_08121D38[var0][var1]; + super->x.HALF.HI = gUnk_08121D18[var0][var1]; + this->unk_68 = gUnk_08121D18[var0][var1]; var1 -= var0; if (gUI.lastState != 1) { var1 = 128; @@ -456,81 +469,81 @@ void sub_0808EE00(Entity* this) { var2 = 140; } - this->field_0x6a.HWORD = var2; - this->palette.b.b0 = gGenericMenu.unk10.a[1] == 5 && var1 == gGenericMenu.unk10.a[2] ? 11 : 9; + this->unk_6a = var2; + super->palette.b.b0 = gGenericMenu.unk10.a[1] == 5 && var1 == gGenericMenu.unk10.a[2] ? 11 : 9; gMapDataBottomSpecial.isTransitioning |= sub_0808EF6C(this); } -void nullsub_522(Entity* this) { +void FileScreenObjects_Type17(FileScreenObjectsEntity* this) { } -void sub_0808EE98(Entity* this) { +void FileScreenObjects_Type18(FileScreenObjectsEntity* this) { static const u8 gUnk_08121D48[] = { 0x28, 0x27, 0x28, 0x28, 0x28, 0x2a, 0x29, 0x28, 0xff, 0x0, 0x0, 0x0 }; - this->timer = gUI.lastState; - this->frameIndex = gUnk_08121D48[this->timer]; - if (this->timer != 2) { - this->field_0x68.HWORD = 96; + super->timer = gUI.lastState; + super->frameIndex = gUnk_08121D48[super->timer]; + if (super->timer != 2) { + this->unk_68 = 96; } else { - this->field_0x68.HWORD = -96; + this->unk_68 = -96; } sub_0808EF6C(this); } -void sub_0808EED8(Entity* this) { - int var0; +void FileScreenObjects_Type19(FileScreenObjectsEntity* this) { + s32 var0; if (gUI.lastState != 3) { - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; } else { - this->spriteSettings.draw = 2; - var0 = this->type - 19; - this->palette.b.b0 = gMenu.column_idx == var0 ? 4 : 3; + super->spriteSettings.draw = 2; + var0 = super->type - 19; + super->palette.b.b0 = gMenu.column_idx == var0 ? 4 : 3; } } -void sub_0808EF24(Entity* this) { - int var0; +void FileScreenObjects_Type21(FileScreenObjectsEntity* this) { + s32 var0; if (gUI.lastState != 3) { - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; } else { - this->spriteSettings.draw = 2; - if (this->type == 21) { + super->spriteSettings.draw = 2; + if (super->type == 21) { var0 = ((SaveHeader*)0x2000000)->msg_speed; } else { var0 = ((SaveHeader*)0x2000000)->brightness; } - this->frameIndex = this->lastFrameIndex + var0; + super->frameIndex = super->lastFrameIndex + var0; } } -static u32 sub_0808EF6C(Entity* this) { - int var0; +static u32 sub_0808EF6C(FileScreenObjectsEntity* this) { + s32 var0; u32 var1; - int var2; + s32 var2; u32 var3; - int var4; + s32 var4; s16 var5; s16 var6; - int var7; + s32 var7; - var6 = this->field_0x68.HWORD; - var0 = var6 - this->x.HALF.HI; + var6 = this->unk_68; + var0 = var6 - super->x.HALF.HI; var1 = var0; if (var0 < 0) { var1 = -var0; } if (var1 < 2) { - this->x.WORD = var6 << 16; + super->x.WORD = var6 << 16; var0 = 0; } - var5 = this->field_0x6a.HWORD; - var2 = var5 - this->y.HALF.HI; + var5 = this->unk_6a; + var2 = var5 - super->y.HALF.HI; var3 = var2; if (var2 < 0) { var3 = -var2; } if (var3 < 2) { - this->y.WORD = var5 << 16; + super->y.WORD = var5 << 16; var2 = 0; } @@ -541,16 +554,16 @@ static u32 sub_0808EF6C(Entity* this) { var4 = var7 = sub_080041EC(var0, var2); var4 += 128; var7 = var4 + var7 * 16; - if (this->field_0x6c.HWORD < var7) { - var7 = this->field_0x6c.HWORD; + if (this->unk_6c < var7) { + var7 = this->unk_6c; } - this->speed = var7; - this->direction = sub_080045DA(var0, var2) >> 3; - LinearMoveUpdate(this); + super->speed = var7; + super->direction = sub_080045DA(var0, var2) >> 3; + LinearMoveUpdate(super); return 1; } -static void sub_0808EFF0(Entity* this) { +static void sub_0808EFF0(FileScreenObjectsEntity* this) { static const struct_08121D54 gUnk_08121D54[] = { { 0x800, -0x40, 0x28, 2, 4, 1, 0x80 }, { 0x800, -0x40, 0x48, 2, 4, 1, 0x81 }, { 0x800, -0x40, 0x68, 2, 4, 1, 0x82 }, { 0x800, -0x40, 0x88, 2, 4, 1, 0x83 }, @@ -569,26 +582,26 @@ static void sub_0808EFF0(Entity* this) { const struct_08121D54* var0; u8 var1; - this->spriteSettings.draw = 2; - this->speed = 0x400; - this->health = 1; - this->frameIndex = 0xFF; - this->animIndex = 0xFF; - var0 = &gUnk_08121D54[this->type]; - this->x.HALF.HI = var0->unk2; - this->field_0x68.HWORD = var0->unk2; - this->y.HALF.HI = var0->unk4; - this->field_0x6a.HWORD = var0->unk4; - this->spriteRendering.b3 = var0->unk6_0; - this->spritePriority.b0 = var0->unk6_3; - this->spriteOrientation.flipY = var0->unk6_6; - this->field_0x6c.HWORD = var0->unk0; + super->spriteSettings.draw = 2; + super->speed = 0x400; + super->health = 1; + super->frameIndex = 0xFF; + super->animIndex = 0xFF; + var0 = &gUnk_08121D54[super->type]; + super->x.HALF.HI = var0->unk2; + this->unk_68 = var0->unk2; + super->y.HALF.HI = var0->unk4; + this->unk_6a = var0->unk4; + super->spriteRendering.b3 = var0->unk6_0; + super->spritePriority.b0 = var0->unk6_3; + super->spriteOrientation.flipY = var0->unk6_6; + this->unk_6c = var0->unk0; var1 = var0->unk7; if (var1 & 0x80) { var1 &= ~(0x80); - this->frameIndex = var1; - this->lastFrameIndex = var1; + super->frameIndex = var1; + super->lastFrameIndex = var1; } else { - InitAnimationForceUpdate(this, var1); + InitAnimationForceUpdate(super, var1); } } diff --git a/src/object/fireballChain.c b/src/object/fireballChain.c index 4e5577a5..3e9905a7 100644 --- a/src/object/fireballChain.c +++ b/src/object/fireballChain.c @@ -11,7 +11,7 @@ #include "projectile.h" #include "projectile/winder.h" -void FireballChain(Entity* thisx) { +void FireballChain(Entity* this) { WinderEntity* newSegment; Entity* parent; Entity* child; @@ -33,11 +33,11 @@ void FireballChain(Entity* thisx) { newSegment->base.type = i; newSegment->base.parent = parent; newSegment->base.child = child; - CopyPosition(thisx, &newSegment->base); + CopyPosition(this, &newSegment->base); for (j = 0, tmp = newSegment->positions; j < WINDER_NUM_SEGMENTS; j++) { - *tmp++ = thisx->x.HALF.HI; - *tmp++ = thisx->y.HALF.HI; + *tmp++ = this->x.HALF.HI; + *tmp++ = this->y.HALF.HI; } child = &newSegment->base; diff --git a/src/object/fireplace.c b/src/object/fireplace.c index 57a7cef9..50b959c3 100644 --- a/src/object/fireplace.c +++ b/src/object/fireplace.c @@ -4,53 +4,60 @@ * * @brief Fireplace object */ +#define NENT_DEPRECATED #include "functions.h" #include "object.h" -void Fireplace_Action1(Entity* this); -void sub_0809B7DC(Entity* this); -void sub_0809B7C0(Entity* this); -void Fireplace_Init(Entity* this); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[30]; + /*0x86*/ u16 unk_86; +} FireplaceEntity; -void Fireplace(Entity* e) { - static void (*const Fireplace_Actions[])(Entity*) = { +void Fireplace_Action1(FireplaceEntity* this); +void sub_0809B7DC(FireplaceEntity* this); +void sub_0809B7C0(FireplaceEntity* this); +void Fireplace_Init(FireplaceEntity* this); + +void Fireplace(FireplaceEntity* this) { + static void (*const Fireplace_Actions[])(FireplaceEntity*) = { Fireplace_Init, Fireplace_Action1, }; - Fireplace_Actions[e->action](e); + Fireplace_Actions[super->action](this); } -void Fireplace_Init(Entity* this) { - this->action = 1; - this->spriteSettings.draw = 1; - this->speed = 0x80; - if (CheckFlags(this->field_0x86.HWORD)) { +void Fireplace_Init(FireplaceEntity* this) { + super->action = 1; + super->spriteSettings.draw = 1; + super->speed = 0x80; + if (CheckFlags(this->unk_86)) { sub_0809B7DC(this); DeleteThisEntity(); } else { - sub_0807B7D8(0x30b, TILE(this->x.HALF.HI, this->y.HALF.HI), 2); - SetTile(0x4061, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); + sub_0807B7D8(0x30b, TILE(super->x.HALF.HI, super->y.HALF.HI), 2); + SetTile(0x4061, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); } Fireplace_Action1(this); } -void Fireplace_Action1(Entity* this) { +void Fireplace_Action1(FireplaceEntity* this) { sub_0809B7C0(this); - if (this->timer) { - SetFlag(this->field_0x86.HWORD); + if (super->timer) { + SetFlag(this->unk_86); DeleteThisEntity(); } } -void sub_0809B7C0(Entity* this) { - u32 tileType = GetTileTypeByEntity(this); +void sub_0809B7C0(FireplaceEntity* this) { + u32 tileType = GetTileTypeByEntity(super); if (tileType != 0x4061 && tileType != 0x4062) { sub_0809B7DC(this); } } -void sub_0809B7DC(Entity* this) { - sub_0807B7D8(0xc3 << 2, TILE(this->x.HALF.HI, this->y.HALF.HI), 2); - SetTile(0x4062, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); - this->timer = 1; +void sub_0809B7DC(FireplaceEntity* this) { + sub_0807B7D8(0xc3 << 2, TILE(super->x.HALF.HI, super->y.HALF.HI), 2); + SetTile(0x4062, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + super->timer = 1; } diff --git a/src/object/flame.c b/src/object/flame.c index 7f2508b5..b31ae8a2 100644 --- a/src/object/flame.c +++ b/src/object/flame.c @@ -4,101 +4,107 @@ * * @brief Flame object */ +#define NENT_DEPRECATED #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "sound.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[30]; + /*0x86*/ u16 unk_86; +} FlameEntity; + extern void sub_0807AB44(Entity*, s32, s32); -void (*const Flame_Actions[])(Entity*); +void (*const Flame_Actions[])(FlameEntity*); -void Flame(Entity* this) { - Flame_Actions[this->action](this); +void Flame(FlameEntity* this) { + Flame_Actions[super->action](this); } -void Flame_Init(Entity* this) { - this->action = 1; - this->spriteSettings.draw = TRUE; - if (this->type2 != 0) { - this->timer = this->type2; +void Flame_Init(FlameEntity* this) { + super->action = 1; + super->spriteSettings.draw = TRUE; + if (super->type2 != 0) { + super->timer = super->type2; } - InitializeAnimation(this, 0); - switch (this->type) { + InitializeAnimation(super, 0); + switch (super->type) { case 1: - this->y.HALF.HI -= 8; - this->timer = 40; + super->y.HALF.HI -= 8; + super->timer = 40; break; case 2: - this->timer = 15; - sub_08004168(this); + super->timer = 15; + sub_08004168(super); break; case 3: - CopyPosition(this->parent, this); + CopyPosition(super->parent, super); break; case 4: - if (!CheckFlags(this->field_0x86.HWORD)) { - this->spriteSettings.draw = FALSE; - this->subAction = 1; + if (!CheckFlags(this->unk_86)) { + super->spriteSettings.draw = FALSE; + super->subAction = 1; return; } } EnqueueSFX(SFX_124); } -void Flame_Action1(Entity* this) { +void Flame_Action1(FlameEntity* this) { u32 val; - GetNextFrame(this); + GetNextFrame(super); - switch (this->type) { + switch (super->type) { case 0: default: - if (this->type2 == 0) + if (super->type2 == 0) return; case 1: case 2: - if (this->timer-- != 0) + if (super->timer-- != 0) return; - if (this->type == 2) { - sub_0807B7D8(((u16*)this->child)[3], COORD_TO_TILE(this), this->collisionLayer); - sub_0807AB44(this, 0, 0x10); - sub_0807AB44(this, 0, -0x10); - sub_0807AB44(this, 0x10, 0); - sub_0807AB44(this, -0x10, 0); + if (super->type == 2) { + sub_0807B7D8(((u16*)super->child)[3], COORD_TO_TILE(super), super->collisionLayer); + sub_0807AB44(super, 0, 0x10); + sub_0807AB44(super, 0, -0x10); + sub_0807AB44(super, 0x10, 0); + sub_0807AB44(super, -0x10, 0); } DeleteThisEntity(); break; case 3: - if (this->parent->next == NULL) { + if (super->parent->next == NULL) { DeleteThisEntity(); } - if (--this->timer == 0) { + if (--super->timer == 0) { DeleteThisEntity(); } - CopyPosition(this->parent, this); + CopyPosition(super->parent, super); break; case 4: - val = CheckFlags(this->field_0x86.HWORD); - if (this->subAction == 0) { + val = CheckFlags(this->unk_86); + if (super->subAction == 0) { if (val) return; - this->subAction = 1; - this->spriteSettings.draw = 0; + super->subAction = 1; + super->spriteSettings.draw = 0; } else { if (!val) return; - this->subAction = 0; - this->spriteSettings.draw = 1; - InitializeAnimation(this, 0); + super->subAction = 0; + super->spriteSettings.draw = 1; + InitializeAnimation(super, 0); EnqueueSFX(SFX_124); } break; } } -void (*const Flame_Actions[])(Entity*) = { +void (*const Flame_Actions[])(FlameEntity*) = { Flame_Init, Flame_Action1, }; diff --git a/src/object/floatingBlock.c b/src/object/floatingBlock.c index 79b784b5..7457797f 100644 --- a/src/object/floatingBlock.c +++ b/src/object/floatingBlock.c @@ -4,6 +4,7 @@ * * @brief Floating Block object */ +#define NENT_DEPRECATED #include "object.h" void FloatingBlock(Entity* this) { diff --git a/src/object/floatingPlatform.c b/src/object/floatingPlatform.c index 15919a40..76f00964 100644 --- a/src/object/floatingPlatform.c +++ b/src/object/floatingPlatform.c @@ -1,10 +1,10 @@ -#define NENT_DEPRECATED /** * @file floatingPlatform.c * @ingroup Objects * * @brief Floating Platform object */ +#define NENT_DEPRECATED #include "entity.h" #include "functions.h" #include "object.h" @@ -15,20 +15,20 @@ typedef struct { u16 unk70; } FloatingPlatformEntity; -void sub_080860D8(FloatingPlatformEntity*); -void sub_0808611C(FloatingPlatformEntity*); +void FloatingPlatform_Init(FloatingPlatformEntity*); +void FloatingPlatform_Action1(FloatingPlatformEntity*); bool32 sub_08086168(FloatingPlatformEntity*); void FloatingPlatform(Entity* this) { - static void (*const actionFuncs[])(FloatingPlatformEntity*) = { - sub_080860D8, - sub_0808611C, + static void (*const FloatingPlatform_Action[])(FloatingPlatformEntity*) = { + FloatingPlatform_Init, + FloatingPlatform_Action1, }; - actionFuncs[this->action]((FloatingPlatformEntity*)this); + FloatingPlatform_Action[this->action]((FloatingPlatformEntity*)this); } -void sub_080860D8(FloatingPlatformEntity* this) { +void FloatingPlatform_Init(FloatingPlatformEntity* this) { super->action = 1; super->speed = 0x100; super->spriteSettings.draw = 1; @@ -38,7 +38,7 @@ void sub_080860D8(FloatingPlatformEntity* this) { UpdateRailMovement(super, (u16**)&super->child, &this->unk70); } -void sub_0808611C(FloatingPlatformEntity* this) { +void FloatingPlatform_Action1(FloatingPlatformEntity* this) { bool32 iVar2 = sub_08086168(this); if (super->timer != 0 && super->parent->timer == 0) { diff --git a/src/object/fourElements.c b/src/object/fourElements.c index ef79e2f0..a9e02140 100644 --- a/src/object/fourElements.c +++ b/src/object/fourElements.c @@ -4,11 +4,9 @@ * * @brief Four Elements object */ - #define NENT_DEPRECATED #include "collision.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "message.h" #include "object.h" diff --git a/src/object/frozenFlower.c b/src/object/frozenFlower.c index 0b93b1de..d046715c 100644 --- a/src/object/frozenFlower.c +++ b/src/object/frozenFlower.c @@ -4,6 +4,7 @@ * * @brief Frozen Flower object */ +#define NENT_DEPRECATED #include "object.h" void FrozenFlower_Init(Entity*); diff --git a/src/object/frozenOctorok.c b/src/object/frozenOctorok.c index 9bde8f4a..7aaaac94 100644 --- a/src/object/frozenOctorok.c +++ b/src/object/frozenOctorok.c @@ -7,7 +7,6 @@ #define NENT_DEPRECATED #include "enemy/octorokBoss.h" #include "functions.h" -#include "global.h" #include "message.h" #include "object.h" diff --git a/src/object/frozenWaterElement.c b/src/object/frozenWaterElement.c index 377dd87c..eb91890c 100644 --- a/src/object/frozenWaterElement.c +++ b/src/object/frozenWaterElement.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/furniture.c b/src/object/furniture.c index 38a111d0..0e88178c 100644 --- a/src/object/furniture.c +++ b/src/object/furniture.c @@ -194,12 +194,12 @@ static void sub_08090E4C(FurnitureEntity*); static void sub_08090CDC(u32, u32, u32); void Furniture(Entity* this) { - static FurnitureAction* const sFurnitureActions[] = { + static FurnitureAction* const Furniture_Actions[] = { FurnitureInit, FurnitureUpdate, }; - sFurnitureActions[this->action]((FurnitureEntity*)this); + Furniture_Actions[this->action]((FurnitureEntity*)this); } static void FurnitureInit(FurnitureEntity* this) { diff --git a/src/object/giantLeaf.c b/src/object/giantLeaf.c index caab128c..15923716 100644 --- a/src/object/giantLeaf.c +++ b/src/object/giantLeaf.c @@ -4,22 +4,23 @@ * * @brief Giant Leaf object */ +#define NENT_DEPRECATED #include "object.h" -void sub_0808D618(Entity* ent); +void sub_0808D618(Entity* this); -void GiantLeaf(Entity* ent) { - if (ent->action == 0) { - ent->action = 1; - ent->spriteSettings.draw = 1; - ent->spriteRendering.b3 = 3; - ent->spritePriority.b0 = 7; - ent->frameIndex = ent->type; - sub_0808D618(ent); +void GiantLeaf(Entity* this) { + if (this->action == 0) { + this->action = 1; + this->spriteSettings.draw = 1; + this->spriteRendering.b3 = 3; + this->spritePriority.b0 = 7; + this->frameIndex = this->type; + sub_0808D618(this); } } -void sub_0808D618(Entity* ent) { +void sub_0808D618(Entity* this) { static const s16 gUnk_08121750[] = { 0x41, 0x40, 0x3f, 0x3e, 0x1, 0x0, -0x1, -0x2, -0x3e, -0x3f, -0x40, -0x41, -0x7e, }; @@ -30,9 +31,9 @@ void sub_0808D618(Entity* ent) { const s16* arr; u32 i; - arr = (ent->type != 0) ? gUnk_0812176A : gUnk_08121750; - tilePos = (((ent->x.HALF.HI - gRoomControls.origin_x) >> 4) & 0x3F) | - ((((ent->y.HALF.HI - gRoomControls.origin_y) >> 4) & 0x3F) * 64); + arr = (this->type != 0) ? gUnk_0812176A : gUnk_08121750; + tilePos = (((this->x.HALF.HI - gRoomControls.origin_x) >> 4) & 0x3F) | + ((((this->y.HALF.HI - gRoomControls.origin_y) >> 4) & 0x3F) * 64); for (i = 0; i < 13; i++) { SetTile(16500, tilePos + arr[i], 1); diff --git a/src/object/giantRock.c b/src/object/giantRock.c index c8a5747e..9c7cf68f 100644 --- a/src/object/giantRock.c +++ b/src/object/giantRock.c @@ -4,6 +4,7 @@ * * @brief Giant Rock object */ +#define NENT_DEPRECATED #include "entity.h" void GiantRock(Entity* this) { diff --git a/src/object/giantRock2.c b/src/object/giantRock2.c index 923a4dbe..09080f29 100644 --- a/src/object/giantRock2.c +++ b/src/object/giantRock2.c @@ -15,15 +15,15 @@ typedef struct { u16 tile; } GiantRock2Entity; -void GiantRock2_Init(GiantRock2Entity*); -void GiantRock2_Idle(GiantRock2Entity*); +void GiantRock2_Init(GiantRock2Entity* this); +void GiantRock2_Idle(GiantRock2Entity* this); void GiantRock2(Entity* this) { - static void (*const actionFuncs[])(GiantRock2Entity*) = { + static void (*const GiantRock2_Action[])(GiantRock2Entity*) = { GiantRock2_Init, GiantRock2_Idle, }; - actionFuncs[this->action]((GiantRock2Entity*)this); + GiantRock2_Action[this->action]((GiantRock2Entity*)this); } void GiantRock2_Init(GiantRock2Entity* this) { diff --git a/src/object/giantTwig.c b/src/object/giantTwig.c index 7927c32c..6bb928ce 100644 --- a/src/object/giantTwig.c +++ b/src/object/giantTwig.c @@ -4,10 +4,8 @@ * * @brief Giant Twig object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index fa4266c5..6820317a 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -4,28 +4,37 @@ * * @brief Great Fairy object */ +#define NENT_DEPRECATED #include "functions.h" #include "object.h" #include "save.h" #include "screen.h" #include "script.h" -void GreatFairy_InitializeAnimation(Entity*); -Entity* GreatFairy_CreateForm(Entity*, u32, u32); -void sub_080873D0(Entity*); -extern void (*const GreatFairy_Main[])(Entity*); -extern void (*const GreatFairy_Behaviors[])(Entity*); -extern void (*const GreatFairy_WingsBehaviors[])(Entity*); -extern void (*const GreatFairy_WakeBehaviors[])(Entity*); -extern void (*const GreatFairy_MiniBehaviors[])(Entity*); -extern void (*const GreatFairy_MiniAffineBehaviors[])(Entity*); -extern void (*const GreatFairy_DropletBehaviors[])(Entity*); -extern void (*const GreatFairy_RippleBehaviors[])(Entity*); -extern void (*const GreatFairy_BigRippleBehaviors[])(Entity*); -extern void (*const GreatFairy_EnergyBehaviors[])(Entity*); -extern void (*const GreatFairy_Form1Behaviors[])(Entity*); -extern void (*const GreatFairy_Form2Behaviors[])(Entity*); -extern void (*const gUnk_081207A4[])(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ s16 unk_68; + /*0x6a*/ s16 unk_6a; + /*0x6c*/ u8 unused1[24]; + /*0x84*/ u16 unk_84; +} GreatFairyEntity; + +void GreatFairy_InitializeAnimation(GreatFairyEntity*); +Entity* GreatFairy_CreateForm(GreatFairyEntity*, u32, u32); +void sub_080873D0(GreatFairyEntity*); +extern void (*const GreatFairy_Main[])(GreatFairyEntity*); +extern void (*const GreatFairy_Behaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_WingsBehaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_WakeBehaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_MiniBehaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_MiniAffineBehaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_DropletBehaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_RippleBehaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_BigRippleBehaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_EnergyBehaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_Form1Behaviors[])(GreatFairyEntity*); +extern void (*const GreatFairy_Form2Behaviors[])(GreatFairyEntity*); +extern void (*const gUnk_081207A4[])(GreatFairyEntity*); extern const s16 GreatFairy_RippleOffsets[10]; extern u8 gUnk_0812079C[8]; @@ -45,21 +54,21 @@ enum { }; // Main -void GreatFairy(Entity* this) { - if (this->action == 0) { +void GreatFairy(GreatFairyEntity* this) { + if (super->action == 0) { s32 temp = 11; - this->type2 = this->type % temp; + super->type2 = super->type % temp; } - GreatFairy_Main[this->type2](this); + GreatFairy_Main[super->type2](this); } // Behaviors -void GreatFairy_CallBehavior(Entity* this) { - GreatFairy_Behaviors[this->action](this); +void GreatFairy_CallBehavior(GreatFairyEntity* this) { + GreatFairy_Behaviors[super->action](this); if ((gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) < 168) { - gRoomControls.camera_target = this; + gRoomControls.camera_target = super; gRoomControls.scrollSpeed = 2; } else { gRoomControls.camera_target = &gPlayerEntity; @@ -68,13 +77,13 @@ void GreatFairy_CallBehavior(Entity* this) { } // Init -void GreatFairy_Init(Entity* this) { +void GreatFairy_Init(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->timer = 0; - this->cutsceneBeh.HWORD = 290; + super->timer = 0; + this->unk_84 = 290; } -void GreatFairy_DormantUpdate(Entity* this) { +void GreatFairy_DormantUpdate(GreatFairyEntity* this) { u16* pFrame; // r1@2 s32 frame; // r1@4 Entity* ripple; // r5@16 @@ -82,13 +91,13 @@ void GreatFairy_DormantUpdate(Entity* this) { if (!CheckRoomFlag(0)) return; - pFrame = &this->cutsceneBeh.HWORD; + pFrame = &this->unk_84; if (*pFrame != 0) { --*pFrame; } switch (*pFrame) { case 0: - this->action = 2; + super->action = 2; break; case 130: case 150: @@ -97,421 +106,421 @@ void GreatFairy_DormantUpdate(Entity* this) { case 289: ripple = GreatFairy_CreateForm(this, RIPPLE, 0); if (ripple) { - PositionRelative(this, ripple, Q_16_16(GreatFairy_RippleOffsets[this->timer]), - Q_16_16(GreatFairy_RippleOffsets[this->timer + 1])); - this->timer += 2; + PositionRelative(super, ripple, Q_16_16(GreatFairy_RippleOffsets[super->timer]), + Q_16_16(GreatFairy_RippleOffsets[super->timer + 1])); + super->timer += 2; break; } } } -void GreatFairy_CreateBigRipple(Entity* this) { +void GreatFairy_CreateBigRipple(GreatFairyEntity* this) { Entity* ripple; ripple = GreatFairy_CreateForm(this, BIGRIPPLE, 0); if (ripple != NULL) { - PositionRelative(this, ripple, 0, Q_16_16(8.0)); - this->action = 3; + PositionRelative(super, ripple, 0, Q_16_16(8.0)); + super->action = 3; } } // Great Fairy spawning in update -void GreatFairy_SpawningUpdate(Entity* this) { +void GreatFairy_SpawningUpdate(GreatFairyEntity* this) { Entity* mini; u32 var; if (gRoomVars.animFlags & 1) { mini = GreatFairy_CreateForm(this, WAKE, 0); //??? if (mini != NULL) { - CopyPosition(this, mini); + CopyPosition(super, mini); SetFade(FADE_BLACK_WHITE | FADE_INSTANT, 4); SoundReq(SFX_145); - this->action = 4; - this->timer = 60; - this->spriteSettings.draw = 1; + super->action = 4; + super->timer = 60; + super->spriteSettings.draw = 1; } } } -void GreatFairy_MiniUpdate(Entity* this) { +void GreatFairy_MiniUpdate(GreatFairyEntity* this) { Entity* target; - GetNextFrame(this); - if (this->timer != 0) { - --this->timer; + GetNextFrame(super); + if (super->timer != 0) { + --super->timer; } else { target = GreatFairy_CreateForm(this, WINGS, 0); if (target != NULL) { - PositionRelative(this, target, 0, Q_16_16(-20.0)); - this->action = 5; - this->timer = 120; - this->subtimer = 0; + PositionRelative(super, target, 0, Q_16_16(-20.0)); + super->action = 5; + super->timer = 120; + super->subtimer = 0; } } } // This is the great fairy's "normal" form -void GreatFairy_FinalUpdate(Entity* this) { +void GreatFairy_FinalUpdate(GreatFairyEntity* this) { Entity* target; - if (this->timer != 0) { - --this->timer; + if (super->timer != 0) { + --super->timer; } else { - if ((this->subtimer == 0) && (target = GreatFairy_CreateForm(this, FORM9, 0), target != NULL)) { - PositionRelative(this, target, 0, Q_16_16(-76.0)); - target->parent = this; - this->subtimer = 1; + if ((super->subtimer == 0) && (target = GreatFairy_CreateForm(this, FORM9, 0), target != NULL)) { + PositionRelative(super, target, 0, Q_16_16(-76.0)); + target->parent = super; + super->subtimer = 1; } } - GetNextFrame(this); + GetNextFrame(super); } -void GreatFairy_WingsCallBehavior(Entity* this) { - GreatFairy_WingsBehaviors[this->action](this); +void GreatFairy_WingsCallBehavior(GreatFairyEntity* this) { + GreatFairy_WingsBehaviors[super->action](this); } -void GreatFairy_WingsInit(Entity* this) { +void GreatFairy_WingsInit(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->spritePriority.b0 = 5; - this->spriteSettings.draw = 1; - this->spriteRendering.alphaBlend = 1; + super->spritePriority.b0 = 5; + super->spriteSettings.draw = 1; + super->spriteRendering.alphaBlend = 1; gScreen.controls.layerFXControl = 0xF40; gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 8); - this->speed = 1024; - SetAffineInfo(this, 1024, 256, 0); + super->speed = 1024; + SetAffineInfo(super, 1024, 256, 0); } -void GreatFairy_WingsUpdate(Entity* this) { - this->speed -= 32; - if (this->speed == 256) { - this->action = 2; - sub_0805EC60(this); +void GreatFairy_WingsUpdate(GreatFairyEntity* this) { + super->speed -= 32; + if (super->speed == 256) { + super->action = 2; + sub_0805EC60(super); gRoomVars.animFlags |= 32; gActiveScriptInfo.syncFlags |= 4; } else { - SetAffineInfo(this, this->speed, 256, 0); + SetAffineInfo(super, super->speed, 256, 0); } } -void nullsub_116(Entity* this) { +void nullsub_116(GreatFairyEntity* this) { } // The wake that appears beneath the Great Fairy as she stands in the water -void GreatFairy_WakeCallBehavior(Entity* this) { - GreatFairy_WakeBehaviors[this->action](this); +void GreatFairy_WakeCallBehavior(GreatFairyEntity* this) { + GreatFairy_WakeBehaviors[super->action](this); } -void GreatFairy_WakeInit(Entity* this) { +void GreatFairy_WakeInit(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.draw = 1; - this->spritePriority.b0 = 6; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 6; } -void GreatFairy_WakeUpdate(Entity* this) { - GetNextFrame(this); +void GreatFairy_WakeUpdate(GreatFairyEntity* this) { + GetNextFrame(super); } // The miniature sprite that emerges from the water when Great Fairy is spawned -void GreatFairy_MiniCallBehavior(Entity* this) { - GreatFairy_MiniBehaviors[this->action](this); +void GreatFairy_MiniCallBehavior(GreatFairyEntity* this) { + GreatFairy_MiniBehaviors[super->action](this); } -void GreatFairy_MiniInit(Entity* this) { +void GreatFairy_MiniInit(GreatFairyEntity* this) { Entity* aff; aff = GreatFairy_CreateForm(this, MINIAFFINE, 0); if (aff != NULL) { - CopyPosition(this, aff); - aff->parent = this; + CopyPosition(super, aff); + aff->parent = super; GreatFairy_InitializeAnimation(this); - this->spriteSettings.draw = 1; - this->subtimer = 0; + super->spriteSettings.draw = 1; + super->subtimer = 0; } } // Spawns a droplet of water once it reaches a certain height -void GreatFairy_MiniRisingUpdate(Entity* this) { +void GreatFairy_MiniRisingUpdate(GreatFairyEntity* this) { Entity* target; - GetNextFrame(this); - this->z.WORD -= Q_16_16(0.5); - if (this->z.HALF.HI == -20) { - this->action = 2; + GetNextFrame(super); + super->z.WORD -= Q_16_16(0.5); + if (super->z.HALF.HI == -20) { + super->action = 2; SoundReq(SFX_HEART_CONTAINER_SPAWN); } else { - if (((this->z.HALF.HI == -10) && (this->subtimer == 0)) && + if (((super->z.HALF.HI == -10) && (super->subtimer == 0)) && (target = GreatFairy_CreateForm(this, DROPLET, 0), target != NULL)) { - PositionRelative(this, target, 0, Q_16_16(4.0)); - this->subtimer = 1; + PositionRelative(super, target, 0, Q_16_16(4.0)); + super->subtimer = 1; } } } // Deletes itself -void GreatFairy_MiniRemoveMe(Entity* this) { - GetNextFrame(this); +void GreatFairy_MiniRemoveMe(GreatFairyEntity* this) { + GetNextFrame(super); sub_080873D0(this); if (gRoomVars.animFlags & 1) { - DeleteEntity(this); + DeleteEntity(super); } } // Same as mini Great Fairy except it is able to stretch -void GreatFairy_MiniAffineCallBehavior(Entity* this) { - GreatFairy_MiniAffineBehaviors[this->action](this); +void GreatFairy_MiniAffineCallBehavior(GreatFairyEntity* this) { + GreatFairy_MiniAffineBehaviors[super->action](this); } -void GreatFairy_MiniAffineInit(Entity* this) { +void GreatFairy_MiniAffineInit(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->spritePriority.b0 = 6; - this->spriteSettings.draw = 1; + super->spritePriority.b0 = 6; + super->spriteSettings.draw = 1; } // Getting ready for affine transformation -void GreatFairy_MiniAffineInit2(Entity* this) { - Entity* parent = this->parent; +void GreatFairy_MiniAffineInit2(GreatFairyEntity* this) { + Entity* parent = super->parent; - CopyPosition(parent, this); + CopyPosition(parent, super); - if (this->z.HALF.HI == -20) { - this->action = 2; - this->timer = 90; - this->speed = 4096; - this->spriteRendering.b0 = 3; - SetAffineInfo(this, 256, 256, 0); + if (super->z.HALF.HI == -20) { + super->action = 2; + super->timer = 90; + super->speed = 4096; + super->spriteRendering.b0 = 3; + SetAffineInfo(super, 256, 256, 0); } } // Mini great fairy stretch -void GreatFairy_MiniAffineUpdate(Entity* this) { - if (--this->timer == 0) { +void GreatFairy_MiniAffineUpdate(GreatFairyEntity* this) { + if (--super->timer == 0) { gRoomVars.animFlags |= 1; - this->action = 3; - sub_0805EC60(this); + super->action = 3; + sub_0805EC60(super); } else { - this->speed -= 24; - SetAffineInfo(this, 256, this->speed >> 4, 0); + super->speed -= 24; + SetAffineInfo(super, 256, super->speed >> 4, 0); } } // The droplet that falls off of the mini Great Fairy emerging from the water -void GreatFairy_DropletCallBehavior(Entity* this) { - GreatFairy_DropletBehaviors[this->action](this); +void GreatFairy_DropletCallBehavior(GreatFairyEntity* this) { + GreatFairy_DropletBehaviors[super->action](this); } -void GreatFairy_DropletInit(Entity* this) { +void GreatFairy_DropletInit(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.draw = 1; - this->z.HALF.HI = 0; - this->spritePriority.b0 = 5; + super->spriteSettings.draw = 1; + super->z.HALF.HI = 0; + super->spritePriority.b0 = 5; SoundReq(SFX_140); } -void GreatFairy_DropletUpdate(Entity* this) { - GetNextFrame(this); - if (this->frame & ANIM_DONE) { - DeleteEntity(this); +void GreatFairy_DropletUpdate(GreatFairyEntity* this) { + GetNextFrame(super); + if (super->frame & ANIM_DONE) { + DeleteEntity(super); } } // Ripples that appear before the great fairy emerges -void GreatFairy_RippleCallBehavior(Entity* this) { - GreatFairy_RippleBehaviors[this->action](this); +void GreatFairy_RippleCallBehavior(GreatFairyEntity* this) { + GreatFairy_RippleBehaviors[super->action](this); } -void GreatFairy_RippleInit(Entity* this) { +void GreatFairy_RippleInit(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.draw = 1; - this->spritePriority.b0 = 6; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 6; } -void GreatFairy_RippleUpdate(Entity* this) { +void GreatFairy_RippleUpdate(GreatFairyEntity* this) { if (gRoomVars.animFlags & 2) { - DeleteEntity(this); + DeleteEntity(super); } else { - GetNextFrame(this); + GetNextFrame(super); } } // Big ripple that appears in the spot where the fairy emerges from -void GreatFairy_BigRippleCallBehavior(Entity* this) { - GreatFairy_BigRippleBehaviors[this->action](this); +void GreatFairy_BigRippleCallBehavior(GreatFairyEntity* this) { + GreatFairy_BigRippleBehaviors[super->action](this); } -void GreatFairy_BigRippleInit(Entity* this) { +void GreatFairy_BigRippleInit(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->timer = 120; - this->spriteSettings.draw = 1; - this->spritePriority.b0 = 5; + super->timer = 120; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 5; SoundReq(SFX_TELEPORTER); } -void GreatFairy_BigRippleUpdate(Entity* this) { +void GreatFairy_BigRippleUpdate(GreatFairyEntity* this) { Entity* target; - GetNextFrame(this); - if (this->timer != 0) { - --this->timer; + GetNextFrame(super); + if (super->timer != 0) { + --super->timer; } else { target = GreatFairy_CreateForm(this, MINI, 0); if (target != NULL) { - PositionRelative(this, target, 0, Q_16_16(-8.0)); + PositionRelative(super, target, 0, Q_16_16(-8.0)); gRoomVars.animFlags |= 2; - DeleteEntity(this); + DeleteEntity(super); } } } // Energy bands that surround the mini Great Fairy as it is transforming -void GreatFairy_EnergyCallBehavior(Entity* this) { - GreatFairy_EnergyBehaviors[this->action](this); +void GreatFairy_EnergyCallBehavior(GreatFairyEntity* this) { + GreatFairy_EnergyBehaviors[super->action](this); } -void GreatFairy_EnergyInit(Entity* this) { +void GreatFairy_EnergyInit(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.draw = 1; - this->spritePriority.b0 = 5; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 5; } -void GreatFairy_EnergyUpdate(Entity* this) { - GetNextFrame(this); - if (this->frame & ANIM_DONE) { - DeleteEntity(this); +void GreatFairy_EnergyUpdate(GreatFairyEntity* this) { + GetNextFrame(super); + if (super->frame & ANIM_DONE) { + DeleteEntity(super); } } -void sub_08087114(Entity* this) { - if (this->type2 == 0) { - GreatFairy_Form1Behaviors[this->action](this); +void sub_08087114(GreatFairyEntity* this) { + if (super->type2 == 0) { + GreatFairy_Form1Behaviors[super->action](this); } else { - GreatFairy_Form2Behaviors[this->action](this); - GetNextFrame(this); + GreatFairy_Form2Behaviors[super->action](this); + GetNextFrame(super); } } -void sub_08087150(Entity* this) { +void sub_08087150(GreatFairyEntity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.draw = 1; - this->spriteOrientation.flipY = 0; - this->spriteRendering.b3 = 0; - this->spritePriority.b0 = 3; - this->speed = 0x80; - this->direction = 0x10; - this->palette.b.b4 = gUnk_0812079C[0]; - this->palette.b.b0 = gUnk_0812079C[0]; + super->spriteSettings.draw = 1; + super->spriteOrientation.flipY = 0; + super->spriteRendering.b3 = 0; + super->spritePriority.b0 = 3; + super->speed = 0x80; + super->direction = 0x10; + super->palette.b.b4 = gUnk_0812079C[0]; + super->palette.b.b0 = gUnk_0812079C[0]; } -void nullsub_516(Entity* this) { +void nullsub_516(GreatFairyEntity* this) { } -void sub_080871A8(Entity* this) { - if (--this->timer == 0) { - this->action = 3; - this->timer = 60; +void sub_080871A8(GreatFairyEntity* this) { + if (--super->timer == 0) { + super->action = 3; + super->timer = 60; gRoomVars.animFlags |= 4; } } -void sub_080871D0(Entity* this) { - if (--this->timer == 0) { +void sub_080871D0(GreatFairyEntity* this) { + if (--super->timer == 0) { gRoomVars.animFlags |= 8; - DeleteEntity(this); + DeleteEntity(super); } } -void sub_080871F8(Entity* this) { - Entity* temp = this->child; +void sub_080871F8(GreatFairyEntity* this) { + Entity* temp = super->child; - if ((temp->x.HALF.HI == this->x.HALF.HI) && (temp->y.HALF.HI - 32 == this->y.HALF.HI)) { - this->action = 2; + if ((temp->x.HALF.HI == super->x.HALF.HI) && (temp->y.HALF.HI - 32 == super->y.HALF.HI)) { + super->action = 2; } else { - this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, temp->x.HALF.HI, temp->y.HALF.HI - 32); - LinearMoveUpdate(this); + super->direction = + CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, temp->x.HALF.HI, temp->y.HALF.HI - 32); + LinearMoveUpdate(super); } } -void sub_08087240(Entity* this) { +void sub_08087240(GreatFairyEntity* this) { if (gRoomVars.animFlags & 4) { - this->action = 3; - this->timer = 20; - this->direction = 16; + super->action = 3; + super->timer = 20; + super->direction = 16; } } -void sub_08087264(Entity* this) { - if (this->timer != 0) { - this->timer--; - LinearMoveUpdate(this); +void sub_08087264(GreatFairyEntity* this) { + if (super->timer != 0) { + super->timer--; + LinearMoveUpdate(super); } } -void sub_0808727C(Entity* this) { - if (--this->timer == 0) { - DeleteEntity(this); +void sub_0808727C(GreatFairyEntity* this) { + if (--super->timer == 0) { + DeleteEntity(super); } } -void sub_08087294(Entity* this) { - gUnk_081207A4[this->action](this); +void sub_08087294(GreatFairyEntity* this) { + gUnk_081207A4[super->action](this); } -void sub_080872AC(Entity* this) { - this->spriteSettings.draw = 1; - this->spriteOrientation.flipY = 1; - this->spriteRendering.b3 = 0; - this->field_0x68.HWORD = this->x.HALF.HI; - this->field_0x6a.HWORD = this->y.HALF.HI; - this->direction = (u8)Random() & 0x1F; - this->speed = 32; +void sub_080872AC(GreatFairyEntity* this) { + super->spriteSettings.draw = 1; + super->spriteOrientation.flipY = 1; + super->spriteRendering.b3 = 0; + this->unk_68 = super->x.HALF.HI; + this->unk_6a = super->y.HALF.HI; + super->direction = (u8)Random() & 0x1F; + super->speed = 32; GreatFairy_InitializeAnimation(this); } -void sub_080872F8(Entity* this) { +void sub_080872F8(GreatFairyEntity* this) { s32 temp; - LinearMoveUpdate(this); - GetNextFrame(this); - if (((u16)(this->field_0x68.HWORD - this->x.HALF.HI) > 0xc) || - ((u16)(this->field_0x6a.HWORD - this->y.HALF.HI) > 0xc)) { - this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, (s16)this->field_0x68.HWORD, - (s16)this->field_0x6a.HWORD); - this->direction = (this->direction + gUnk_081207AC[Random() & 3]) & 0x1f; + LinearMoveUpdate(super); + GetNextFrame(super); + if (((u16)(this->unk_68 - super->x.HALF.HI) > 0xc) || ((u16)(this->unk_6a - super->y.HALF.HI) > 0xc)) { + super->direction = + CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, (s16)this->unk_68, (s16)this->unk_6a); + super->direction = (super->direction + gUnk_081207AC[Random() & 3]) & 0x1f; } - temp = gSineTable[this->timer + 64]; - this->z.HALF.HI = (temp >> 6) - 8; - this->timer++; + temp = gSineTable[super->timer + 64]; + super->z.HALF.HI = (temp >> 6) - 8; + super->timer++; } -void GreatFairy_InitializeAnimation(Entity* this) { +void GreatFairy_InitializeAnimation(GreatFairyEntity* this) { s32 temp = 11; - this->action = 1; - this->type2 = this->type % temp; - this->collisionLayer = 2; - InitializeAnimation(this, this->type2); - SetDefaultPriority(this, PRIO_MESSAGE); + super->action = 1; + super->type2 = super->type % temp; + super->collisionLayer = 2; + InitializeAnimation(super, super->type2); + SetDefaultPriority(super, PRIO_MESSAGE); } -Entity* GreatFairy_CreateForm(Entity* this, u32 curForm, u32 parameter) { +Entity* GreatFairy_CreateForm(GreatFairyEntity* this, u32 curForm, u32 parameter) { s32 nextForm; Entity* ent; - nextForm = this->type; + nextForm = super->type; nextForm /= 11; ent = CreateObject(GREAT_FAIRY, (u8)nextForm * 11 + curForm, parameter); return ent; } -void sub_080873D0(Entity* this) { +void sub_080873D0(GreatFairyEntity* this) { Entity* ent; - if (this->timer != 0) { - this->timer--; + if (super->timer != 0) { + super->timer--; } else { ent = GreatFairy_CreateForm(this, 8, 0); if (ent != NULL) { - CopyPosition(this, ent); - this->timer = 48; + CopyPosition(super, ent); + super->timer = 48; } } } @@ -527,11 +536,11 @@ void sub_080873FC(void) { } } -void sub_08087424(Entity* this, ScriptExecutionContext* context) { +void sub_08087424(GreatFairyEntity* this, ScriptExecutionContext* context) { Entity* ent; ResetPlayerAnimationAndAction(); - ent = CreateObject(THUNDERBOLD, 0, 0); + ent = CreateObject(THUNDERBOLT, 0, 0); if (ent != NULL) { ent->parent = &gPlayerEntity; CopyPosition(&gPlayerEntity, ent); @@ -548,7 +557,7 @@ void sub_08087424(Entity* this, ScriptExecutionContext* context) { } } -void sub_0808747C(Entity* this, ScriptExecutionContext* context) { +void sub_0808747C(GreatFairyEntity* this, ScriptExecutionContext* context) { u32 iVar1 = 0; iVar1 = (u32)FindEntity(OBJECT, SPECIAL_FX, 0x6, 0xb, 0x0); @@ -558,7 +567,7 @@ void sub_0808747C(Entity* this, ScriptExecutionContext* context) { context->condition = iVar1; } -void (*const GreatFairy_Main[])(Entity*) = { +void (*const GreatFairy_Main[])(GreatFairyEntity*) = { GreatFairy_CallBehavior, GreatFairy_WingsCallBehavior, GreatFairy_WakeCallBehavior, @@ -572,7 +581,7 @@ void (*const GreatFairy_Main[])(Entity*) = { sub_08087294, }; -void (*const GreatFairy_Behaviors[])(Entity*) = { +void (*const GreatFairy_Behaviors[])(GreatFairyEntity*) = { GreatFairy_Init, GreatFairy_DormantUpdate, GreatFairy_CreateBigRipple, GreatFairy_SpawningUpdate, GreatFairy_MiniUpdate, GreatFairy_FinalUpdate, }; @@ -581,57 +590,57 @@ const s16 GreatFairy_RippleOffsets[10] = { 0, 0, -32, -8, 16, 20, 24, -12, -16, 24, }; -void (*const GreatFairy_WingsBehaviors[])(Entity*) = { +void (*const GreatFairy_WingsBehaviors[])(GreatFairyEntity*) = { GreatFairy_WingsInit, GreatFairy_WingsUpdate, nullsub_116, }; -void (*const GreatFairy_WakeBehaviors[])(Entity*) = { +void (*const GreatFairy_WakeBehaviors[])(GreatFairyEntity*) = { GreatFairy_WakeInit, GreatFairy_WakeUpdate, }; -void (*const GreatFairy_MiniBehaviors[])(Entity*) = { +void (*const GreatFairy_MiniBehaviors[])(GreatFairyEntity*) = { GreatFairy_MiniInit, GreatFairy_MiniRisingUpdate, GreatFairy_MiniRemoveMe, }; -void (*const GreatFairy_MiniAffineBehaviors[])(Entity*) = { +void (*const GreatFairy_MiniAffineBehaviors[])(GreatFairyEntity*) = { GreatFairy_MiniAffineInit, GreatFairy_MiniAffineInit2, GreatFairy_MiniAffineUpdate, - DeleteEntity, + (void (*)(GreatFairyEntity*))DeleteEntity, }; -void (*const GreatFairy_DropletBehaviors[])(Entity*) = { +void (*const GreatFairy_DropletBehaviors[])(GreatFairyEntity*) = { GreatFairy_DropletInit, GreatFairy_DropletUpdate, }; -void (*const GreatFairy_RippleBehaviors[])(Entity*) = { +void (*const GreatFairy_RippleBehaviors[])(GreatFairyEntity*) = { GreatFairy_RippleInit, GreatFairy_RippleUpdate, }; -void (*const GreatFairy_BigRippleBehaviors[])(Entity*) = { +void (*const GreatFairy_BigRippleBehaviors[])(GreatFairyEntity*) = { GreatFairy_BigRippleInit, GreatFairy_BigRippleUpdate, }; -void (*const GreatFairy_EnergyBehaviors[])(Entity*) = { +void (*const GreatFairy_EnergyBehaviors[])(GreatFairyEntity*) = { GreatFairy_EnergyInit, GreatFairy_EnergyUpdate, }; -void (*const GreatFairy_Form1Behaviors[])(Entity*) = { +void (*const GreatFairy_Form1Behaviors[])(GreatFairyEntity*) = { sub_08087150, nullsub_516, sub_080871A8, sub_080871D0, }; -void (*const GreatFairy_Form2Behaviors[])(Entity*) = { +void (*const GreatFairy_Form2Behaviors[])(GreatFairyEntity*) = { sub_08087150, sub_080871F8, sub_08087240, sub_08087264, sub_0808727C, }; diff --git a/src/object/gustJarParticle.c b/src/object/gustJarParticle.c index 4cbcb580..4c03551f 100644 --- a/src/object/gustJarParticle.c +++ b/src/object/gustJarParticle.c @@ -5,11 +5,11 @@ * @brief Gust Jar Particle object */ #define NENT_DEPRECATED -#include "entity.h" -#include "player.h" #include "asm.h" -#include "room.h" +#include "entity.h" #include "physics.h" +#include "player.h" +#include "room.h" void GustJarParticle_Init(Entity*); void GustJarParticle_Action1(Entity*); diff --git a/src/object/gyorgBossObject.c b/src/object/gyorgBossObject.c index 103352ce..a5c34d89 100644 --- a/src/object/gyorgBossObject.c +++ b/src/object/gyorgBossObject.c @@ -9,7 +9,6 @@ #include "enemy/gyorg.h" #include "entity.h" #include "functions.h" -#include "global.h" #include "object.h" #include "room.h" #include "screen.h" diff --git a/src/object/heartContainer.c b/src/object/heartContainer.c index a0694601..95d1b074 100644 --- a/src/object/heartContainer.c +++ b/src/object/heartContainer.c @@ -4,6 +4,7 @@ * * @brief HeartContainer object */ +#define NENT_DEPRECATED #include "collision.h" #include "entity.h" #include "flags.h" @@ -11,12 +12,19 @@ #include "item.h" #include "sound.h" -static void HeartContainer_Init(Entity*); -static void HeartContainer_Action1(Entity*); -static void HeartContainer_Action2(Entity*); -static void HeartContainer_Action3(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[28]; + /*0x84*/ u16 unk_84; + /*0x86*/ u16 unk_86; +} HeartContainerEntity; -static void (*const HeartContainer_Actions[])(Entity*) = { +static void HeartContainer_Init(HeartContainerEntity* this); +static void HeartContainer_Action1(HeartContainerEntity* this); +static void HeartContainer_Action2(HeartContainerEntity* this); +static void HeartContainer_Action3(HeartContainerEntity* this); + +static void (*const HeartContainer_Actions[])(HeartContainerEntity*) = { HeartContainer_Init, HeartContainer_Action1, HeartContainer_Action2, @@ -25,49 +33,49 @@ static void (*const HeartContainer_Actions[])(Entity*) = { const Hitbox3D gUnk_08121C58 = { 0, -3, { 5, 3, 3, 5 }, 6, 6, 12, {} }; -void HeartContainer(Entity* this) { - HeartContainer_Actions[this->action](this); +void HeartContainer(HeartContainerEntity* this) { + HeartContainer_Actions[super->action](this); } -static void HeartContainer_Init(Entity* this) { - if (CheckFlags(this->cutsceneBeh.HWORD)) { +static void HeartContainer_Init(HeartContainerEntity* this) { + if (CheckFlags(this->unk_84)) { DeleteThisEntity(); } - this->action = 1; - this->type = 0x62; - this->spriteSettings.draw = 0; - this->hitbox = (Hitbox*)&gUnk_08121C58; - this->collisionLayer = 3; - this->updatePriority = PRIO_NO_BLOCK; + super->action = 1; + super->type = 0x62; + super->spriteSettings.draw = 0; + super->hitbox = (Hitbox*)&gUnk_08121C58; + super->collisionLayer = 3; + super->updatePriority = PRIO_NO_BLOCK; } -static void HeartContainer_Action1(Entity* this) { - if (CheckFlags(this->field_0x86.HWORD)) { - this->action = 2; - this->spriteSettings.draw = 1; - this->spriteRendering.b0 = 3; +static void HeartContainer_Action1(HeartContainerEntity* this) { + if (CheckFlags(this->unk_86)) { + super->action = 2; + super->spriteSettings.draw = 1; + super->spriteRendering.b0 = 3; HeartContainer_Action2(this); } } -static void HeartContainer_Action2(Entity* this) { - int var0 = 0x400 - this->subtimer * 8; +static void HeartContainer_Action2(HeartContainerEntity* this) { + int var0 = 0x400 - super->subtimer * 8; if (var0 > 0x100) { - this->subtimer++; - SetAffineInfo(this, var0, var0, 0); + super->subtimer++; + SetAffineInfo(super, var0, var0, 0); } else { - this->action = 3; - this->collisionFlags |= 0x10; - sub_0805EC60(this); + super->action = 3; + super->collisionFlags |= 0x10; + sub_0805EC60(super); SoundReq(SFX_HEART_CONTAINER_SPAWN); } - sub_08080CB4(this); + sub_08080CB4(super); } -static void HeartContainer_Action3(Entity* this) { - sub_08080CB4(this); - if (!(gPlayerState.flags & PL_MINISH) && IsCollidingPlayer(this)) { - SetFlag(this->cutsceneBeh.HWORD); +static void HeartContainer_Action3(HeartContainerEntity* this) { + sub_08080CB4(super); + if (!(gPlayerState.flags & PL_MINISH) && IsCollidingPlayer(super)) { + SetFlag(this->unk_84); CreateItemEntity(ITEM_HEART_CONTAINER, 0, 0); DeleteThisEntity(); } diff --git a/src/object/hiddenLadderDown.c b/src/object/hiddenLadderDown.c index d2369721..b17d9717 100644 --- a/src/object/hiddenLadderDown.c +++ b/src/object/hiddenLadderDown.c @@ -4,52 +4,60 @@ * * @brief Hidden Ladder Down object */ +#define NENT_DEPRECATED #include "asm.h" #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" -void HiddenLadderDown_Init(Entity*); -void HiddenLadderDown_Action1(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[8]; + /*0x70*/ u16 unk_70; + /*0x72*/ u8 unused2[20]; + /*0x86*/ u16 unk_86; +} HiddenLadderDownEntity; -void HiddenLadderDown(Entity* this) { - static void (*const HiddenLadderDown_Actions[])(Entity*) = { +void HiddenLadderDown_Init(HiddenLadderDownEntity* this); +void HiddenLadderDown_Action1(HiddenLadderDownEntity* this); + +void HiddenLadderDown(HiddenLadderDownEntity* this) { + static void (*const HiddenLadderDown_Actions[])(HiddenLadderDownEntity*) = { HiddenLadderDown_Init, HiddenLadderDown_Action1, }; - if (this->action < 2) { - HiddenLadderDown_Actions[this->action](this); + if (super->action < 2) { + HiddenLadderDown_Actions[super->action](this); } } -void HiddenLadderDown_Init(Entity* this) { +void HiddenLadderDown_Init(HiddenLadderDownEntity* this) { u16* puVar3; - this->action = 1; - this->spritePriority.b0 = 7; - this->animIndex = 0; - this->field_0x70.HALF.LO = COORD_TO_TILE(this); - puVar3 = &this->field_0x70.HALF.LO; - if (CheckFlags(this->field_0x86.HWORD) != 0) { - this->action = 2; - this->spriteSettings.draw = TRUE; - SetTileType(0x1a2, *puVar3 - 0x41, this->collisionLayer); - SetTileType(0x1a3, *puVar3 - 0x40, this->collisionLayer); - SetTileType(0x1a4, *puVar3 - 0x3f, this->collisionLayer); - SetTileType(0x1a5, *puVar3 - 1, this->collisionLayer); - SetTileType(0x1a6, *puVar3, this->collisionLayer); - SetTileType(0x1a7, *puVar3 + 1, this->collisionLayer); - SetTileType(0x1a8, *puVar3 + 0x3f, this->collisionLayer); - SetTileType(0x1a9, *puVar3 + 0x40, this->collisionLayer); - SetTileType(0x1aa, *puVar3 + 0x41, this->collisionLayer); + super->action = 1; + super->spritePriority.b0 = 7; + super->animIndex = 0; + this->unk_70 = COORD_TO_TILE(super); + puVar3 = &this->unk_70; + if (CheckFlags(this->unk_86) != 0) { + super->action = 2; + super->spriteSettings.draw = TRUE; + SetTileType(0x1a2, *puVar3 - 0x41, super->collisionLayer); + SetTileType(0x1a3, *puVar3 - 0x40, super->collisionLayer); + SetTileType(0x1a4, *puVar3 - 0x3f, super->collisionLayer); + SetTileType(0x1a5, *puVar3 - 1, super->collisionLayer); + SetTileType(0x1a6, *puVar3, super->collisionLayer); + SetTileType(0x1a7, *puVar3 + 1, super->collisionLayer); + SetTileType(0x1a8, *puVar3 + 0x3f, super->collisionLayer); + SetTileType(0x1a9, *puVar3 + 0x40, super->collisionLayer); + SetTileType(0x1aa, *puVar3 + 0x41, super->collisionLayer); } } -void HiddenLadderDown_Action1(Entity* this) { - if (GetTileType(*(u16*)&this->field_0x70.HALF.LO, this->collisionLayer) == 0x1a6) { - this->action = 2; - this->spriteSettings.draw = TRUE; - SetFlag(this->field_0x86.HWORD); +void HiddenLadderDown_Action1(HiddenLadderDownEntity* this) { + if (GetTileType(this->unk_70, super->collisionLayer) == 0x1a6) { + super->action = 2; + super->spriteSettings.draw = TRUE; + SetFlag(this->unk_86); } } diff --git a/src/object/hitSwitch.c b/src/object/hitSwitch.c index 0b32dce4..a0931519 100644 --- a/src/object/hitSwitch.c +++ b/src/object/hitSwitch.c @@ -4,40 +4,49 @@ * * @brief Hit Switch object */ +#define NENT_DEPRECATED #include "entity.h" #include "physics.h" -void HitSwitch(Entity* this) { - Entity* parent = this->parent; +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[12]; + /*0x74*/ u8 unk_74; + /*0x75*/ u8 unk_75; + /*0x76*/ u8 unk_76; +} HitSwitchEntity; + +void HitSwitch(HitSwitchEntity* this) { + Entity* parent = super->parent; if (parent->next == NULL) { DeleteThisEntity(); } - if (this->action == 0) { - this->action = 1; - this->field_0x76.HALF.LO = parent->animationState; - this->field_0x74.HALF.LO = this->spriteOffsetX; - this->field_0x74.HALF.HI = this->spriteOffsetY; - InitializeAnimation(this, this->animationState); + if (super->action == 0) { + super->action = 1; + this->unk_76 = parent->animationState; + this->unk_74 = super->spriteOffsetX; + this->unk_75 = super->spriteOffsetY; + InitializeAnimation(super, super->animationState); } - if (parent->animationState != this->field_0x76.HALF.LO) { + if (parent->animationState != this->unk_76) { DeleteThisEntity(); } - this->spriteSettings.draw = parent->spriteSettings.draw; - CopyPositionAndSpriteOffset(parent, this); - this->spriteOffsetX += this->field_0x74.HALF.LO; - this->spriteOffsetY += this->field_0x74.HALF.HI; - if (this->animationState != 2) { - this->y.HALF.HI++; - this->spriteOffsetY--; + super->spriteSettings.draw = parent->spriteSettings.draw; + CopyPositionAndSpriteOffset(parent, super); + super->spriteOffsetX += this->unk_74; + super->spriteOffsetY += this->unk_75; + if (super->animationState != 2) { + super->y.HALF.HI++; + super->spriteOffsetY--; } else { - this->y.HALF.HI--; - this->spriteOffsetY++; + super->y.HALF.HI--; + super->spriteOffsetY++; } - GetNextFrame(this); - if (this->frame & 0x80) { + GetNextFrame(super); + if (super->frame & 0x80) { DeleteThisEntity(); } } diff --git a/src/object/hittableLever.c b/src/object/hittableLever.c index 293035a8..d92fbfa3 100644 --- a/src/object/hittableLever.c +++ b/src/object/hittableLever.c @@ -4,11 +4,9 @@ * * @brief Hittable Lever object */ - #define NENT_DEPRECATED -#include "global.h" -#include "object.h" #include "functions.h" +#include "object.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 332a3ab4..5b0a94f6 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -4,16 +4,25 @@ * * @brief House Door Exterior object */ +#define NENT_DEPRECATED #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "npc.h" #include "object.h" #include "room.h" #include "script.h" #include "sound.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; + /*0x6a*/ u16 unk_6a; + /*0x6c*/ u8 unk_6c; + /*0x6d*/ u8 unused1[23]; + /*0x84*/ ScriptExecutionContext* context; +} HouseDoorExteriorEntity; + typedef struct { /*0x00*/ u16 unk0; /*0x02*/ u16 unk2; @@ -24,62 +33,57 @@ typedef struct { /*0x08*/ u8* unk8; } unk_DoorProperty; -typedef struct { - /*0x00*/ u8 filler0[0x8]; - /*0x08*/ u32 unk8; -} unk_80868EC; - -static void sub_080868EC(Entity* entity, unk_80868EC* arg1); +static void sub_080868EC(Entity* entity, ScriptExecutionContext* context); static bool32 sub_080867CC(u32); -void sub_0808681C(Entity*); -void sub_080866D8(Entity*); -void sub_080867E4(Entity*); -void sub_080868B0(Entity*); -static u8 sub_08086954(Entity*); +void HouseDoorExterior_Type2(HouseDoorExteriorEntity* this); +void HouseDoorExterior_Type0(HouseDoorExteriorEntity* this); +void HouseDoorExterior_Type1(HouseDoorExteriorEntity* this); +void HouseDoorExterior_Type3(HouseDoorExteriorEntity* this); +static u8 sub_08086954(HouseDoorExteriorEntity* this); static const Hitbox gUnk_081206AC = { 0, -5, { 5, 3, 3, 5 }, 10, 4 }; -void HouseDoorExterior(Entity* this) { - static void (*const typeFuncs[])(Entity*) = { - sub_080866D8, - sub_080867E4, - sub_0808681C, - sub_080868B0, +void HouseDoorExterior(HouseDoorExteriorEntity* this) { + static void (*const HouseDoorExterior_Types[])(HouseDoorExteriorEntity*) = { + HouseDoorExterior_Type0, + HouseDoorExterior_Type1, + HouseDoorExterior_Type2, + HouseDoorExterior_Type3, }; - typeFuncs[this->type2](this); + HouseDoorExterior_Types[super->type2](this); } -void sub_080866D8(Entity* this) { +void HouseDoorExterior_Type0(HouseDoorExteriorEntity* this) { unk_DoorProperty* prop; - Entity* entity; + HouseDoorExteriorEntity* entity; u32 i; - if (this->action == 0) { - this->action = 1; - *((u32*)(&this->field_0x68)) = 0; - this->field_0x6c.HALF.LO = this->timer; - SetDefaultPriority(this, PRIO_PLAYER_EVENT); + if (super->action == 0) { + super->action = 1; + *((u32*)(&this->unk_68)) = 0; + this->unk_6c = super->timer; + SetDefaultPriority(super, PRIO_PLAYER_EVENT); } - prop = GetCurrentRoomProperty(this->field_0x6c.HALF.LO); + prop = GetCurrentRoomProperty(this->unk_6c); for (i = 0; prop->unk0 != 0xFFFF && i < 32; prop++, i++) { int mask = 1 << i; - if ((*((u32*)(&this->field_0x68)) & mask) == 0 && sub_080867CC(prop->unk5) && + if ((*((u32*)(&this->unk_68)) & mask) == 0 && sub_080867CC(prop->unk5) && CheckRegionOnScreen(prop->unk0, prop->unk2, 32, 32)) { - entity = CreateObject(HOUSE_DOOR_EXT, prop->unk7, prop->unk6); + entity = (HouseDoorExteriorEntity*)CreateObject(HOUSE_DOOR_EXT, prop->unk7, prop->unk6); if (entity != NULL) { - entity->field_0x6c.HALF.LO = i; - entity->x.HALF.HI = gRoomControls.origin_x + prop->unk0 + 16; - entity->y.HALF.HI = gRoomControls.origin_y + prop->unk2 + 32; - entity->parent = this; - entity->field_0x68.HWORD = prop->unk0; - entity->field_0x6a.HWORD = prop->unk2; - entity->collisionLayer = prop->unk4; - entity->subAction = prop->unk5; - UpdateSpriteForCollisionLayer(entity); - *((u32*)(&this->field_0x68)) |= mask; + entity->unk_6c = i; + entity->base.x.HALF.HI = gRoomControls.origin_x + prop->unk0 + 16; + entity->base.y.HALF.HI = gRoomControls.origin_y + prop->unk2 + 32; + entity->base.parent = super; + entity->unk_68 = prop->unk0; + entity->unk_6a = prop->unk2; + entity->base.collisionLayer = prop->unk4; + entity->base.subAction = prop->unk5; + UpdateSpriteForCollisionLayer(&entity->base); + *((u32*)(&this->unk_68)) |= mask; if (prop->unk8) { - *((ScriptExecutionContext**)(&entity->cutsceneBeh)) = StartCutscene(entity, (u16*)prop->unk8); + entity->context = StartCutscene(&entity->base, (u16*)prop->unk8); } } } @@ -96,63 +100,64 @@ static bool32 sub_080867CC(u32 arg0) { return CheckGlobalFlag(TATEKAKE_HOUSE); } -void sub_080867E4(Entity* this) { - if (!CheckRegionOnScreen(this->field_0x68.HWORD, this->field_0x6a.HWORD, 32, 32)) { - *((u32*)(&this->parent->field_0x68)) = *((u32*)(&this->parent->field_0x68)) & ~(1 << this->field_0x6c.HALF.LO); +void HouseDoorExterior_Type1(HouseDoorExteriorEntity* this) { + if (!CheckRegionOnScreen(this->unk_68, this->unk_6a, 32, 32)) { + *((u32*)(&((HouseDoorExteriorEntity*)super->parent)->unk_68)) = + *((u32*)(&((HouseDoorExteriorEntity*)super->parent)->unk_68)) & ~(1 << this->unk_6c); DeleteThisEntity(); } - sub_0808681C(this); + HouseDoorExterior_Type2(this); } -void sub_0808681C(Entity* this) { - switch (this->action) { +void HouseDoorExterior_Type2(HouseDoorExteriorEntity* this) { + switch (super->action) { case 0: - this->action = 1; - this->timer = 8; - this->spriteSettings.draw = 1; - this->frameIndex = 0; - this->hitbox = (Hitbox*)&gUnk_081206AC; - if (this->subAction == 1) { - this->action = 2; - this->frameIndex = 1; + super->action = 1; + super->timer = 8; + super->spriteSettings.draw = 1; + super->frameIndex = 0; + super->hitbox = (Hitbox*)&gUnk_081206AC; + if (super->subAction == 1) { + super->action = 2; + super->frameIndex = 1; } - if (this->flags & ENT_SCRIPTED) { - this->action = 2; + if (super->flags & ENT_SCRIPTED) { + super->action = 2; } break; case 1: if (!sub_08086954(this)) { - this->action++; - this->frameIndex = 1; + super->action++; + super->frameIndex = 1; sub_08078AC0(16, 0, 1); SoundReq(SFX_111); } break; } - if (this->flags & ENT_SCRIPTED) { - ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh); - sub_080868EC(this, *(void**)&this->cutsceneBeh); + if (super->flags & ENT_SCRIPTED) { + ExecuteScript(super, this->context); + sub_080868EC(super, this->context); } } -void sub_080868B0(Entity* this) { - if (this->action == 0) { - this->action = 1; - this->spriteSettings.draw = 1; - this->hitbox = (Hitbox*)&gUnk_081206AC; - this->timer = 8; +void HouseDoorExterior_Type3(HouseDoorExteriorEntity* this) { + if (super->action == 0) { + super->action = 1; + super->spriteSettings.draw = 1; + super->hitbox = (Hitbox*)&gUnk_081206AC; + super->timer = 8; } - ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh); - sub_080868EC(this, *(void**)&this->cutsceneBeh); + ExecuteScript(super, this->context); + sub_080868EC(super, this->context); } -static void sub_080868EC(Entity* entity, unk_80868EC* arg1) { - u32 var0 = arg1->unk8; - arg1->unk8 = 0; - while (var0 != 0) { - u32 rightMostSetBit = var0 & (~var0 + 1); - var0 ^= rightMostSetBit; +static void sub_080868EC(Entity* entity, ScriptExecutionContext* context) { + u32 postScriptActions = context->postScriptActions; + context->postScriptActions = 0; + while (postScriptActions != 0) { + u32 rightMostSetBit = postScriptActions & (~postScriptActions + 1); + postScriptActions ^= rightMostSetBit; switch (rightMostSetBit) { case 0x80: entity->frameIndex = 0; @@ -168,30 +173,30 @@ static void sub_080868EC(Entity* entity, unk_80868EC* arg1) { } } -void sub_0808692C(Entity* this) { - this->flags &= ~ENT_SCRIPTED; - this->type2 = 2; - this->action = (this->frameIndex == 0) ? 1 : 2; - this->subAction = 0; - this->timer = 8; +void sub_0808692C(HouseDoorExteriorEntity* this) { + super->flags &= ~ENT_SCRIPTED; + super->type2 = 2; + super->action = (super->frameIndex == 0) ? 1 : 2; + super->subAction = 0; + super->timer = 8; } -static u8 sub_08086954(Entity* this) { - if (sub_0800445C(this)) { - if (GetAnimationStateInRectRadius(this, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && +static u8 sub_08086954(HouseDoorExteriorEntity* this) { + if (sub_0800445C(super)) { + if (GetAnimationStateInRectRadius(super, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && (u16)gPlayerState.playerInput.heldInput == PLAYER_INPUT_UP && gPlayerState.jump_status == 0) { - this->timer--; + super->timer--; } } else { - this->timer = 8; + super->timer = 8; } - return this->timer; + return super->timer; } -void sub_080869A4(Entity* this, ScriptExecutionContext* context) { +void sub_080869A4(HouseDoorExteriorEntity* this, ScriptExecutionContext* context) { context->condition = 0; if (!sub_08086954(this)) { - this->timer = 8; + super->timer = 8; context->condition = 1; } } diff --git a/src/object/houseDoorInterior.c b/src/object/houseDoorInterior.c index 50e8a7ba..8e69feef 100644 --- a/src/object/houseDoorInterior.c +++ b/src/object/houseDoorInterior.c @@ -33,12 +33,12 @@ static const HouseDoorInteriorFrameIndices_struct HouseDoorInteriorFrameIndices[ }; void HouseDoorInterior(Entity* this) { - static void (*const actionFuncs[])(HouseDoorInteriorEntity*) = { + static void (*const HouseDoorInterior_Actions[])(HouseDoorInteriorEntity*) = { HouseDoorInterior_Init, HouseDoorInterior_Action1, HouseDoorInterior_Delete, }; - actionFuncs[this->action]((HouseDoorInteriorEntity*)this); + HouseDoorInterior_Actions[this->action]((HouseDoorInteriorEntity*)this); } typedef struct { diff --git a/src/object/houseSign.c b/src/object/houseSign.c index b8972164..4353e3ad 100644 --- a/src/object/houseSign.c +++ b/src/object/houseSign.c @@ -4,20 +4,28 @@ * * @brief HouseSign object */ -#include "entity.h" +#define NENT_DEPRECATED #include "asm.h" +#include "entity.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[24]; + /*0x80*/ s16 unk_80; + /*0x82*/ s16 unk_82; +} HouseSignEntity; /* This object is created by HouseSignManager. It checks whether the 0x10 x 0x10 rect at field_0x80, field_0x82 is still on the screen. -If not, then it deletes itself and unsets the this->type2 bit in the managers field_0x20 bitfield. +If not, then it deletes itself and unsets the super->type2 bit in the managers field_0x20 bitfield. */ -void HouseSign(Entity* this) { - if (this->action == 0) { - this->action = 1; +void HouseSign(HouseSignEntity* this) { + if (super->action == 0) { + super->action = 1; } - if (CheckRectOnScreen((s16)this->field_0x80.HWORD, (s16)this->field_0x82.HWORD, 0x10, 0x10) == 0) { - this->parent->zVelocity &= ~(1 << this->type2); + if (CheckRectOnScreen(this->unk_80, this->unk_82, 0x10, 0x10) == 0) { + super->parent->zVelocity &= ~(1 << super->type2); DeleteThisEntity(); } } diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index 916f71d0..8ea4cced 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -4,10 +4,8 @@ * * @brief Item for Sale object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "kinstone.h" #include "message.h" diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index eaf97830..bf70e601 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -4,11 +4,12 @@ * * @brief Item On Ground object */ +#define NENT_DEPRECATED +#include "object/itemOnGround.h" #include "collision.h" #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "item.h" #include "itemMetaData.h" @@ -16,40 +17,41 @@ #include "player.h" #include "sound.h" -void sub_08081150(Entity*); +void sub_08081150(ItemOnGroundEntity* this); u8 sub_0808147C(u32); -void sub_080814A4(Entity*); -u32 sub_080814C0(Entity*); -void sub_08081500(Entity*); -void sub_0808153C(Entity*); -void sub_08081598(Entity*); -void sub_080813BC(Entity*); -void sub_080810FC(Entity*); -void ItemOnGround_Init(Entity*); -void ItemOnGround_Action1(Entity*); -void ItemOnGround_Action2(Entity*); -void ItemOnGround_Action3(Entity*); -void ItemOnGround_Action4(Entity*); -void sub_080810A8(Entity*); -void sub_080810FC(Entity*); -void sub_08081150(Entity*); -void sub_08081134(Entity*); -void sub_08081188(Entity*); -void sub_080811AC(Entity*); -void sub_080811C8(Entity*); -void sub_080811D8(Entity*); -void sub_08081248(Entity*); -void sub_0808126C(Entity*); -void sub_0808127C(Entity*); -void nullsub_113(Entity*); -void sub_080812A0(Entity*); -void sub_080812A8(Entity*); -void sub_080812E8(Entity*); -void nullsub_510(Entity*); -void sub_080813D4(Entity*); -void sub_080813E8(Entity*); -void sub_080813F0(Entity*); -bool32 CheckShouldPlayItemGetCutscene(Entity*); +void sub_080814A4(ItemOnGroundEntity* this); +u32 sub_080814C0(ItemOnGroundEntity* this); +void sub_08081500(ItemOnGroundEntity* this); +void sub_0808153C(ItemOnGroundEntity* this); +void sub_08081598(ItemOnGroundEntity* this); +void sub_080813BC(ItemOnGroundEntity* this); +void sub_080810FC(ItemOnGroundEntity* this); +void ItemOnGround_Init(ItemOnGroundEntity* this); +void ItemOnGround_Action1(ItemOnGroundEntity* this); +void ItemOnGround_Action2(ItemOnGroundEntity* this); +void ItemOnGround_Action3(ItemOnGroundEntity* this); +void ItemOnGround_Action4(ItemOnGroundEntity* this); +void sub_080810A8(ItemOnGroundEntity* this); +void sub_080810FC(ItemOnGroundEntity* this); +void sub_08081150(ItemOnGroundEntity* this); +void sub_08081134(ItemOnGroundEntity* this); +void sub_08081188(ItemOnGroundEntity* this); +void sub_080811AC(ItemOnGroundEntity* this); +void sub_080811C8(ItemOnGroundEntity* this); +void sub_080811D8(ItemOnGroundEntity* this); +void sub_08081248(ItemOnGroundEntity* this); +void sub_0808126C(ItemOnGroundEntity* this); +void sub_0808127C(ItemOnGroundEntity* this); +void nullsub_113(ItemOnGroundEntity* this); +void sub_080812A0(ItemOnGroundEntity* this); +void sub_080812A8(ItemOnGroundEntity* this); +void sub_080812E8(ItemOnGroundEntity* this); +void nullsub_510(ItemOnGroundEntity* this); +void sub_080813D4(ItemOnGroundEntity* this); +void sub_080813E8(ItemOnGroundEntity* this); +void sub_080813F0(ItemOnGroundEntity* this); +bool32 CheckShouldPlayItemGetCutscene(ItemOnGroundEntity* this); +void sub_08081404(ItemOnGroundEntity*, u32); typedef struct { u8 unk0[2]; @@ -58,18 +60,18 @@ typedef struct { u8 unk5[3]; } Unk_0811E84C; -void ItemOnGround(Entity* this) { - static void (*const ItemOnGround_Actions[])(Entity*) = { +void ItemOnGround(ItemOnGroundEntity* this) { + static void (*const ItemOnGround_Actions[])(ItemOnGroundEntity*) = { ItemOnGround_Init, ItemOnGround_Action1, ItemOnGround_Action2, ItemOnGround_Action3, ItemOnGround_Action4, }; - if (this->contactFlags & 0x80) { - switch (this->contactFlags & 0x7F) { + if (super->contactFlags & 0x80) { + switch (super->contactFlags & 0x7F) { case 20: - this->action = 3; - COLLISION_OFF(this); - this->spriteSettings.draw = 1; - this->collisionFlags |= 0x10; - this->child = this->contactedEntity; + super->action = 3; + COLLISION_OFF(super); + super->spriteSettings.draw = 1; + super->collisionFlags |= 0x10; + super->child = super->contactedEntity; break; case 0: case 1: @@ -87,38 +89,38 @@ void ItemOnGround(Entity* this) { } } - if (sub_0806F520(this)) { + if (sub_0806F520(super)) { sub_080813BC(this); } else { - ItemOnGround_Actions[this->action](this); + ItemOnGround_Actions[super->action](this); } - if (this->type == 0x5C) { + if (super->type == 0x5C) { gRoomVars.field_0x4++; } - sub_08080CB4(this); + sub_08080CB4(super); } -void ItemOnGround_Init(Entity* this) { - static void (*const gUnk_0811E7E8[])(Entity*) = { +void ItemOnGround_Init(ItemOnGroundEntity* this) { + static void (*const gUnk_0811E7E8[])(ItemOnGroundEntity*) = { sub_080810A8, sub_080810FC, sub_08081150, sub_08081134, sub_08081188, sub_080810A8, sub_080810A8, sub_080811AC, sub_080811C8, sub_080811D8, sub_080810A8, }; - if (this->field_0x86.HWORD && CheckFlags(this->field_0x86.HWORD)) { + if (this->unk_86 && CheckFlags(this->unk_86)) { DeleteThisEntity(); } - if (this->type != ITEM_FAIRY) { - this->spriteSettings.draw = 1; - this->spritePriority.b1 = 3; - this->spriteSettings.shadow = 0; - this->hitType = 7; - this->collisionFlags = 0x47; - this->hurtType = 0x44; - this->health = 0xFF; - this->hitbox = (Hitbox*)&gUnk_080FD1A8; - switch (this->type) { + if (super->type != ITEM_FAIRY) { + super->spriteSettings.draw = 1; + super->spritePriority.b1 = 3; + super->spriteSettings.shadow = 0; + super->hitType = 7; + super->collisionFlags = 0x47; + super->hurtType = 0x44; + super->health = 0xFF; + super->hitbox = (Hitbox*)&gUnk_080FD1A8; + switch (super->type) { case ITEM_SHELLS: case ITEM_RUPEE1: case ITEM_RUPEE5: @@ -129,144 +131,144 @@ void ItemOnGround_Init(Entity* this) { case ITEM_BOMBS5: case ITEM_ARROWS5: case ITEM_HEART: - this->flags2 = 0x17; + super->flags2 = 0x17; break; default: - this->flags2 = 0x11; + super->flags2 = 0x11; break; } - this->field_0x68.HALF.HI = this->timer; - this->field_0x6a.HALF.LO = 0; - this->field_0x6c.HWORD = 0; - this->field_0x68.HALF.LO = 0; - this->timer = 0; - SetDefaultPriority(this, PRIO_NO_BLOCK); - this->gustJarFlags = sub_0808147C(this->type); - gUnk_0811E7E8[this->field_0x68.HALF.HI](this); + this->unk_69 = super->timer; + this->unk_6a = 0; + this->unk_6c = 0; + this->unk_68 = 0; + super->timer = 0; + SetDefaultPriority(super, PRIO_NO_BLOCK); + super->gustJarFlags = sub_0808147C(super->type); + gUnk_0811E7E8[this->unk_69](this); } else { Entity* entity = CreateObject(FAIRY, 0x60, 0); if (entity != NULL) { entity->timer = 0; - if (this->timer == 1) { + if (super->timer == 1) { entity->type2 = 2; } - CopyPosition(this, entity); + CopyPosition(super, entity); DeleteThisEntity(); } } } -void sub_080810A8(Entity* this) { - this->action = 1; +void sub_080810A8(ItemOnGroundEntity* this) { + super->action = 1; sub_080814A4(this); - if (this->direction & 0x80) { - this->direction &= 0x1F; - if (this->speed == 0) { - this->speed = 0x100; + if (super->direction & 0x80) { + super->direction &= 0x1F; + if (super->speed == 0) { + super->speed = 0x100; } } else { - this->direction |= 0xFF; + super->direction |= 0xFF; } - if (this->zVelocity == 0) { - this->zVelocity = Q_16_16(1.875); + if (super->zVelocity == 0) { + super->zVelocity = Q_16_16(1.875); } - if (this->collisionLayer == 2) { - ResolveCollisionLayer(this); + if (super->collisionLayer == 2) { + ResolveCollisionLayer(super); } } -void sub_080810FC(Entity* this) { - if (this->type != ITEM_HEART) { +void sub_080810FC(ItemOnGroundEntity* this) { + if (super->type != ITEM_HEART) { sub_08081598(this); } else { - this->action = 2; - this->subAction = 0; - COLLISION_ON(this); - this->flags2 = 0x11; - CopyPosition(&gPlayerEntity, this); + super->action = 2; + super->subAction = 0; + COLLISION_ON(super); + super->flags2 = 0x11; + CopyPosition(&gPlayerEntity, super); } } -void sub_08081134(Entity* this) { +void sub_08081134(ItemOnGroundEntity* this) { sub_080814A4(this); - this->field_0x6c.HWORD += 80; + this->unk_6c += 80; sub_08081150(this); } -void sub_08081150(Entity* this) { - this->action = 2; - COLLISION_ON(this); - this->z.HALF.HI = -0x80; - this->spriteOrientation.flipY = 1; - this->spriteRendering.b3 = 1; +void sub_08081150(ItemOnGroundEntity* this) { + super->action = 2; + COLLISION_ON(super); + super->z.HALF.HI = -0x80; + super->spriteOrientation.flipY = 1; + super->spriteRendering.b3 = 1; SoundReq(SFX_12D); } -void sub_08081188(Entity* this) { - this->action = 2; - COLLISION_ON(this); - if (this->collisionLayer == 2) { - ResolveCollisionLayer(this); +void sub_08081188(ItemOnGroundEntity* this) { + super->action = 2; + COLLISION_ON(super); + if (super->collisionLayer == 2) { + ResolveCollisionLayer(super); } } -void sub_080811AC(Entity* this) { - this->action = 2; - this->spriteSettings.draw = 0; - this->field_0x6e.HWORD = GetTileTypeByEntity(this); +void sub_080811AC(ItemOnGroundEntity* this) { + super->action = 2; + super->spriteSettings.draw = 0; + this->unk_6e = GetTileTypeByEntity(super); } -void sub_080811C8(Entity* this) { - this->action = 2; - this->spriteSettings.draw = 0; +void sub_080811C8(ItemOnGroundEntity* this) { + super->action = 2; + super->spriteSettings.draw = 0; } -void sub_080811D8(Entity* this) { +void sub_080811D8(ItemOnGroundEntity* this) { sub_08081188(this); SoundReq(SFX_215); } -void ItemOnGround_Action1(Entity* this) { - if (this->field_0x68.HALF.HI != 6) { - ProcessMovement2(this); +void ItemOnGround_Action1(ItemOnGroundEntity* this) { + if (this->unk_69 != 6) { + ProcessMovement2(super); } else { - LinearMoveUpdate(this); + LinearMoveUpdate(super); } - GravityUpdate(this, Q_8_8(40.0)); - if (this->zVelocity <= 0) { - this->action = 2; - COLLISION_ON(this); + GravityUpdate(super, Q_8_8(40.0)); + if (super->zVelocity <= 0) { + super->action = 2; + COLLISION_ON(super); sub_080814A4(this); } } -void ItemOnGround_Action2(Entity* this) { - static void (*const gUnk_0811E814[])(Entity*) = { +void ItemOnGround_Action2(ItemOnGroundEntity* this) { + static void (*const gUnk_0811E814[])(ItemOnGroundEntity*) = { sub_08081248, sub_08081248, sub_0808126C, sub_0808127C, nullsub_113, sub_080812A0, sub_08081248, sub_080812A8, sub_080812E8, nullsub_510, sub_08081248, }; - gUnk_0811E814[this->field_0x68.HALF.HI](this); + gUnk_0811E814[this->unk_69](this); } -void sub_08081248(Entity* this) { +void sub_08081248(ItemOnGroundEntity* this) { sub_08081500(this); if (sub_080814C0(this)) { sub_08081404(this, 0); } else { - sub_0800442E(this); + sub_0800442E(super); } } -void sub_0808126C(Entity* this) { - UpdateAnimationSingleFrame(this); +void sub_0808126C(ItemOnGroundEntity* this) { + UpdateAnimationSingleFrame(super); sub_0808153C(this); } -void sub_0808127C(Entity* this) { +void sub_0808127C(ItemOnGroundEntity* this) { if (sub_080814C0(this)) { sub_08081404(this, 0); } else { @@ -274,111 +276,111 @@ void sub_0808127C(Entity* this) { } } -void nullsub_113(Entity* this) { +void nullsub_113(ItemOnGroundEntity* this) { } -void sub_080812A0(Entity* this) { +void sub_080812A0(ItemOnGroundEntity* this) { sub_08081500(this); } -void sub_080812A8(Entity* this) { - if (sub_080B1B0C(this) != 0xF && this->field_0x6e.HWORD != GetTileTypeByEntity(this)) { - this->direction = 0; - this->speed = 0; - this->spriteSettings.draw = 1; - this->field_0x68.HALF.HI = 0; +void sub_080812A8(ItemOnGroundEntity* this) { + if (sub_080B1B0C(super) != 0xF && this->unk_6e != GetTileTypeByEntity(super)) { + super->direction = 0; + super->speed = 0; + super->spriteSettings.draw = 1; + this->unk_69 = 0; sub_080810A8(this); } } -void sub_080812E8(Entity* this) { +void sub_080812E8(ItemOnGroundEntity* this) { PlayerState* playerState = &gPlayerState; #ifdef EU - if ((playerState->swim_state & 0x80) && IsColliding(this, &gPlayerEntity)) { + if ((playerState->swim_state & 0x80) && IsColliding(super, &gPlayerEntity)) { #else if ((playerState->swim_state & 0x80) && (playerState->flags & PL_MINISH) == 0 && - IsColliding(this, &gPlayerEntity)) { + IsColliding(super, &gPlayerEntity)) { #endif sub_080810FC(this); } } -void nullsub_510(Entity* this) { +void nullsub_510(ItemOnGroundEntity* this) { } -void ItemOnGround_Action3(Entity* this) { - Entity* other = this->child; +void ItemOnGround_Action3(ItemOnGroundEntity* this) { + Entity* other = super->child; if (!(other->kind == PLAYER_ITEM && other->id == 3)) { sub_08081404(this, 0); } else { - CopyPosition(other, this); - this->z.HALF.HI--; + CopyPosition(other, super); + super->z.HALF.HI--; other = &gPlayerEntity; - if (IsColliding(this, other)) { + if (IsColliding(super, other)) { sub_080810FC(this); } } } -void ItemOnGround_Action4(Entity* this) { - if (--this->timer) { - Entity* other = this->child; - this->x.WORD = other->x.WORD; - this->y.WORD = other->y.WORD; - this->spriteOrientation.flipY = other->spriteOrientation.flipY; - this->spriteRendering.b3 = other->spriteRendering.b3; - GravityUpdate(this, Q_8_8(40.0)); +void ItemOnGround_Action4(ItemOnGroundEntity* this) { + if (--super->timer) { + Entity* other = super->child; + super->x.WORD = other->x.WORD; + super->y.WORD = other->y.WORD; + super->spriteOrientation.flipY = other->spriteOrientation.flipY; + super->spriteRendering.b3 = other->spriteRendering.b3; + GravityUpdate(super, Q_8_8(40.0)); } else { sub_08081404(this, 1); } } -void sub_080813BC(Entity* this) { - static void (*const subActionFuncs[])(Entity*) = { +void sub_080813BC(ItemOnGroundEntity* this) { + static void (*const subActionFuncs[])(ItemOnGroundEntity*) = { sub_080813D4, sub_080813E8, sub_080813F0, }; - subActionFuncs[this->subAction](this); + subActionFuncs[super->subAction](this); } -void sub_080813D4(Entity* this) { - this->subAction = 1; - this->gustJarTolerance = 1; - this->spriteSettings.draw = 1; +void sub_080813D4(ItemOnGroundEntity* this) { + super->subAction = 1; + super->gustJarTolerance = 1; + super->spriteSettings.draw = 1; } -void sub_080813E8(Entity* this) { - sub_0806F4E8(this); +void sub_080813E8(ItemOnGroundEntity* this) { + sub_0806F4E8(super); } -void sub_080813F0(Entity* this) { - if (sub_0806F3E4(this)) { +void sub_080813F0(ItemOnGroundEntity* this) { + if (sub_0806F3E4(super)) { sub_080810FC(this); } } -void sub_08081404(Entity* this, u32 arg1) { - if (arg1 && this->field_0x86.HWORD) { - SetFlag(this->field_0x86.HWORD); +void sub_08081404(ItemOnGroundEntity* this, u32 arg1) { + if (arg1 && this->unk_86) { + SetFlag(this->unk_86); } DeleteThisEntity(); } -bool32 sub_08081420(Entity* this) { +bool32 sub_08081420(ItemOnGroundEntity* this) { if (CheckShouldPlayItemGetCutscene(this)) { - SetDefaultPriority(this, PRIO_PLAYER_EVENT); - CreateItemEntity(this->type, this->type2, 0); + SetDefaultPriority(super, PRIO_PLAYER_EVENT); + CreateItemEntity(super->type, super->type2, 0); return TRUE; } else { - GiveItem(this->type, this->type2); + GiveItem(super->type, super->type2); return FALSE; } } -bool32 CheckShouldPlayItemGetCutscene(Entity* this) { - return ((gItemMetaData[this->type].unk3 & 0x2) || !GetInventoryValue(this->type)); +bool32 CheckShouldPlayItemGetCutscene(ItemOnGroundEntity* this) { + return ((gItemMetaData[super->type].unk3 & 0x2) || !GetInventoryValue(super->type)); } static const Unk_0811E84C gUnk_0811E84C[118] = { @@ -411,79 +413,79 @@ void sub_0808148C(u32 arg0) { } } -void sub_080814A4(Entity* this) { - if (this->field_0x68.HALF.HI == 10) { - this->field_0x6c.HWORD = 120; +void sub_080814A4(ItemOnGroundEntity* this) { + if (this->unk_69 == 10) { + this->unk_6c = 120; } else { - this->field_0x6c.HWORD = 600; + this->unk_6c = 600; } } -u32 sub_080814C0(Entity* this) { +u32 sub_080814C0(ItemOnGroundEntity* this) { if (!AnyPrioritySet()) { - if (--this->field_0x6c.HWORD == 0) { + if (--this->unk_6c == 0) { return TRUE; } - if (this->field_0x6c.HWORD < 90) { - this->spriteSettings.draw ^= 1; + if (this->unk_6c < 90) { + super->spriteSettings.draw ^= 1; } } return FALSE; } -void sub_08081500(Entity* this) { - if (this->field_0x68.HALF.LO == 0) { - u32 var0 = sub_080044EC(this, 0x2800); +void sub_08081500(ItemOnGroundEntity* this) { + if (this->unk_68 == 0) { + u32 var0 = sub_080044EC(super, 0x2800); if (var0 == 0) { - this->field_0x68.HALF.LO = 1; + this->unk_68 = 1; } else { if (var0 == 1) { - sub_0808148C(this->type); - UpdateSpriteForCollisionLayer(this); + sub_0808148C(super->type); + UpdateSpriteForCollisionLayer(super); } - ProcessMovement2(this); + ProcessMovement2(super); } } } -void sub_0808153C(Entity* this) { - if (this->field_0x68.HALF.LO > 1) +void sub_0808153C(ItemOnGroundEntity* this) { + if (this->unk_68 > 1) return; - if (this->field_0x68.HALF.LO == 0) { - if (!GravityUpdate(this, Q_8_8(16.0)) && !sub_0800442E(this)) { - this->field_0x68.HALF.LO = 1; - this->zVelocity = Q_16_16(1.875); - sub_0808148C(this->type); - UpdateSpriteForCollisionLayer(this); + if (this->unk_68 == 0) { + if (!GravityUpdate(super, Q_8_8(16.0)) && !sub_0800442E(super)) { + this->unk_68 = 1; + super->zVelocity = Q_16_16(1.875); + sub_0808148C(super->type); + UpdateSpriteForCollisionLayer(super); } } else { - if (!GravityUpdate(this, Q_8_8(40.0))) { - this->field_0x68.HALF.LO = 2; - sub_0808148C(this->type); + if (!GravityUpdate(super, Q_8_8(40.0))) { + this->unk_68 = 2; + sub_0808148C(super->type); } } } -void sub_08081598(Entity* this) { - if (this->health == 0) { +void sub_08081598(ItemOnGroundEntity* this) { + if (super->health == 0) { sub_08081404(this, 1); } - COLLISION_OFF(this); - this->action = 4; - this->timer = 14; - this->zVelocity = Q_16_16(2.0); - this->spriteSettings.draw = 1; - this->spritePriority.b1 = 2; - this->spritePriority.b0 = 3; - this->child = &gPlayerEntity; - CopyPosition(this->child, this); - this->z.HALF.HI -= 4; - if (this->type != 0x5F && sub_08081420(this)) { + COLLISION_OFF(super); + super->action = 4; + super->timer = 14; + super->zVelocity = Q_16_16(2.0); + super->spriteSettings.draw = 1; + super->spritePriority.b1 = 2; + super->spritePriority.b0 = 3; + super->child = &gPlayerEntity; + CopyPosition(super->child, super); + super->z.HALF.HI -= 4; + if (super->type != 0x5F && sub_08081420(this)) { sub_08081404(this, 1); } } diff --git a/src/object/jailBars.c b/src/object/jailBars.c index 870ce4a2..fb81b2b8 100644 --- a/src/object/jailBars.c +++ b/src/object/jailBars.c @@ -4,63 +4,69 @@ * * @brief Jail Bars object */ +#define NENT_DEPRECATED #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "room.h" #include "sound.h" -static void SetJailBarTiles(Entity*, u32); -void JailBars_Init(Entity*); -void JailBars_Action1(Entity*); -void JailBars_Action2(Entity*); -void JailBars_Action3(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[30]; + /*0x86*/ u16 unk_86; +} JailBarsEntity; -void JailBars(Entity* this) { - static void (*const JailBars_Actions[])(Entity*) = { +static void SetJailBarTiles(JailBarsEntity* this, u32); +void JailBars_Init(JailBarsEntity* this); +void JailBars_Action1(JailBarsEntity* this); +void JailBars_Action2(JailBarsEntity* this); +void JailBars_Action3(JailBarsEntity* this); + +void JailBars(JailBarsEntity* this) { + static void (*const JailBars_Actions[])(JailBarsEntity*) = { JailBars_Init, JailBars_Action1, JailBars_Action2, JailBars_Action3, }; - JailBars_Actions[this->action](this); + JailBars_Actions[super->action](this); } -void JailBars_Init(Entity* this) { - if (CheckFlags(this->field_0x86.HWORD) == 0) { - this->action = 1; +void JailBars_Init(JailBarsEntity* this) { + if (CheckFlags(this->unk_86) == 0) { + super->action = 1; SetJailBarTiles(this, 0); } else { - this->action = 3; - InitializeAnimation(this, 1); + super->action = 3; + InitializeAnimation(super, 1); SetJailBarTiles(this, 1); } - this->spriteSettings.draw = 3; // ??? - this->collisionLayer = 1; - UpdateSpriteForCollisionLayer(this); + super->spriteSettings.draw = 3; // ??? + super->collisionLayer = 1; + UpdateSpriteForCollisionLayer(super); } -void JailBars_Action1(Entity* this) { - if (CheckFlags(this->field_0x86.HWORD) != 0) { - this->action = 2; +void JailBars_Action1(JailBarsEntity* this) { + if (CheckFlags(this->unk_86) != 0) { + super->action = 2; SetJailBarTiles(this, 1); SoundReq(SFX_10B); } } -void JailBars_Action2(Entity* this) { - GetNextFrame(this); - if (this->frame & ANIM_DONE) { - this->action = 3; - InitializeAnimation(this, 1); +void JailBars_Action2(JailBarsEntity* this) { + GetNextFrame(super); + if (super->frame & ANIM_DONE) { + super->action = 3; + InitializeAnimation(super, 1); } } -void JailBars_Action3(Entity* this) { +void JailBars_Action3(JailBarsEntity* this) { } -static void SetJailBarTiles(Entity* this, u32 arg1) { +static void SetJailBarTiles(JailBarsEntity* this, u32 arg1) { static const s16 gUnk_08124960[] = { 0x4023, -0x3, 0x4023, -0x2, 0x4023, -0x1, 0x4023, 0x0, 0x4023, 0x1, 0x4023, 0x2, -0x1 }; static const s16 gUnk_0812497A[] = { 0x4023, -0x3, 0x4023, -0x2, 0x4088, -0x1, 0x4087, @@ -71,5 +77,5 @@ static void SetJailBarTiles(Entity* this, u32 arg1) { if (arg1 == 1) { puVar1 = gUnk_0812497A; } - SetMultipleTiles((const TileData*)puVar1, COORD_TO_TILE(this), 1); + SetMultipleTiles((const TileData*)puVar1, COORD_TO_TILE(super), 1); } diff --git a/src/object/japaneseSubtitle.c b/src/object/japaneseSubtitle.c index 5d66eb04..745b7b1a 100644 --- a/src/object/japaneseSubtitle.c +++ b/src/object/japaneseSubtitle.c @@ -21,14 +21,14 @@ void JapaneseSubtitle_Type3(Entity*); const u16 gUnk_08124B10[] = { 0x40, 0x58, 0x68, 0x80, 0x94, 0xA8, 0xB0, 0x0 }; void JapaneseSubtitle(Entity* this) { - static void (*const typeFuncs[])(Entity*) = { + static void (*const JapaneseSubtitle_Types[])(Entity*) = { JapaneseSubtitle_Type0, JapaneseSubtitle_Type1, JapaneseSubtitle_Type2, JapaneseSubtitle_Type3, }; - typeFuncs[this->type]((Entity*)this); + JapaneseSubtitle_Types[this->type]((Entity*)this); } void JapaneseSubtitle_Type0(Entity* this) { diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index 04720216..5c5fdc2d 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -4,115 +4,123 @@ * * @brief Jar Portal object */ +#define NENT_DEPRECATED #include "area.h" #include "functions.h" #include "object.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68; + /*0x69*/ u8 unused1[19]; + /*0x7c*/ u8 unk_7c; +} JarPortalEntity; + extern u32 PortalReadyForMinish(void); -u32 sub_0808C128(Entity*); -void sub_0808C13C(Entity*); -void JarPortal_Init(Entity*); -void JarPortal_Action1(Entity*); -void JarPortal_Action2(Entity*); -void JarPortal_Action3(Entity*); -void JarPortal_Action4(Entity*); -void sub_0808C148(Entity*, u32); -void sub_0808C01C(Entity*, u32); +u32 sub_0808C128(JarPortalEntity* this); +void sub_0808C13C(JarPortalEntity* this); +void JarPortal_Init(JarPortalEntity* this); +void JarPortal_Action1(JarPortalEntity* this); +void JarPortal_Action2(JarPortalEntity* this); +void JarPortal_Action3(JarPortalEntity* this); +void JarPortal_Action4(JarPortalEntity* this); +void sub_0808C148(JarPortalEntity* this, u32); +void sub_0808C01C(JarPortalEntity* this, u32); -void JarPortal(Entity* this) { - static void (*const JarPortal_Actions[])(Entity*) = { +void JarPortal(JarPortalEntity* this) { + static void (*const JarPortal_Actions[])(JarPortalEntity*) = { JarPortal_Init, JarPortal_Action1, JarPortal_Action2, JarPortal_Action3, JarPortal_Action4, }; - JarPortal_Actions[this->action](this); + JarPortal_Actions[super->action](this); } -void JarPortal_Init(Entity* this) { - COLLISION_ON(this); - this->hitType = 1; - this->collisionFlags = 0x47; - this->hurtType = 0x44; - this->flags2 = 0x80; - this->field_0x68.HALF.LO = 0; - if (CheckLocalFlag(this->type)) { - if (this->field_0x7c.BYTES.byte0 != 0) { - this->action = 1; - InitAnimationForceUpdate(this, 0); +void JarPortal_Init(JarPortalEntity* this) { + COLLISION_ON(super); + super->hitType = 1; + super->collisionFlags = 0x47; + super->hurtType = 0x44; + super->flags2 = 0x80; + this->unk_68 = 0; + if (CheckLocalFlag(super->type)) { + if (this->unk_7c != 0) { + super->action = 1; + InitAnimationForceUpdate(super, 0); } else { - this->action = 3; - InitAnimationForceUpdate(this, 1); + super->action = 3; + InitAnimationForceUpdate(super, 1); } } else { - if (this->field_0x7c.BYTES.byte0 == 0) { - this->action = 1; - InitAnimationForceUpdate(this, 0); + if (this->unk_7c == 0) { + super->action = 1; + InitAnimationForceUpdate(super, 0); } else { - this->action = 3; - InitAnimationForceUpdate(this, 1); + super->action = 3; + InitAnimationForceUpdate(super, 1); } } } -void JarPortal_Action1(Entity* this) { +void JarPortal_Action1(JarPortalEntity* this) { if (sub_0808C128(this)) { - this->action++; + super->action++; sub_0808C13C(this); - if (this->field_0x7c.BYTES.byte0 == 0) { - SetLocalFlag(this->type); + if (this->unk_7c == 0) { + SetLocalFlag(super->type); } else { - ClearLocalFlag(this->type); + ClearLocalFlag(super->type); } sub_0808C148(this, 0); } sub_0808C01C(this, 0); } -void JarPortal_Action2(Entity* this) { - GravityUpdate(this, Q_8_8(32.0)); - switch (this->subAction) { +void JarPortal_Action2(JarPortalEntity* this) { + GravityUpdate(super, Q_8_8(32.0)); + switch (super->subAction) { case 0: - if (this->zVelocity < Q_16_16(1.5)) { - ++this->subAction; - InitAnimationForceUpdate(this, 2); + if (super->zVelocity < Q_16_16(1.5)) { + ++super->subAction; + InitAnimationForceUpdate(super, 2); } break; case 1: - UpdateAnimationSingleFrame(this); - if (!this->z.HALF.HI) { - ++this->subAction; - this->zVelocity = Q_16_16(0.5); + UpdateAnimationSingleFrame(super); + if (!super->z.HALF.HI) { + ++super->subAction; + super->zVelocity = Q_16_16(0.5); } break; case 2: - UpdateAnimationSingleFrame(this); - if (!this->z.HALF.HI) { - ++this->action; - this->subtimer = 0; - InitAnimationForceUpdate(this, 1); + UpdateAnimationSingleFrame(super); + if (!super->z.HALF.HI) { + ++super->action; + super->subtimer = 0; + InitAnimationForceUpdate(super, 1); sub_0808C148(this, 1); } break; } } -void JarPortal_Action3(Entity* this) { +void JarPortal_Action3(JarPortalEntity* this) { if (sub_0808C128(this)) { - ++this->action; + ++super->action; sub_0808C13C(this); - if (!this->field_0x7c.BYTES.byte0) - ClearLocalFlag(this->type); + if (!this->unk_7c) + ClearLocalFlag(super->type); else - SetLocalFlag(this->type); + SetLocalFlag(super->type); sub_0808C148(this, 0); } sub_0808C01C(this, 1); } -void sub_0808C01C(Entity* this, u32 r1) { - if (CheckPlayerProximity(this->x.HALF.HI - 0x18, this->y.HALF.HI - 0x18, 0x30, 0x30)) { +void sub_0808C01C(JarPortalEntity* this, u32 r1) { + if (CheckPlayerProximity(super->x.HALF.HI - 0x18, super->y.HALF.HI - 0x18, 0x30, 0x30)) { u32 type; - gArea.portal_x = this->x.HALF.HI; - gArea.portal_y = this->y.HALF.HI; + gArea.portal_x = super->x.HALF.HI; + gArea.portal_y = super->y.HALF.HI; gArea.portal_exit_dir = 2; type = 4; if (r1 != 0) @@ -126,64 +134,64 @@ void sub_0808C01C(Entity* this, u32 r1) { gArea.portal_mode = 3; } } - CreateMagicSparkles(this->x.HALF.HI, this->y.HALF.HI, this->collisionLayer); - if (this->subtimer == 0) { - this->subtimer = 1; + CreateMagicSparkles(super->x.HALF.HI, super->y.HALF.HI, super->collisionLayer); + if (super->subtimer == 0) { + super->subtimer = 1; SoundReq(SFX_NEAR_PORTAL); } } } } -void JarPortal_Action4(Entity* this) { - GravityUpdate(this, Q_8_8(32.0)); - switch (this->subAction) { +void JarPortal_Action4(JarPortalEntity* this) { + GravityUpdate(super, Q_8_8(32.0)); + switch (super->subAction) { case 0: - if (this->zVelocity < Q_16_16(1.5)) { - this->subAction = 1; - InitAnimationForceUpdate(this, 3); + if (super->zVelocity < Q_16_16(1.5)) { + super->subAction = 1; + InitAnimationForceUpdate(super, 3); } break; case 1: - UpdateAnimationSingleFrame(this); - if (!this->z.HALF.HI) { - ++this->subAction; - this->zVelocity = Q_16_16(0.5); + UpdateAnimationSingleFrame(super); + if (!super->z.HALF.HI) { + ++super->subAction; + super->zVelocity = Q_16_16(0.5); } break; case 2: - UpdateAnimationSingleFrame(this); - if (!this->z.HALF.HI) { - this->action = 1; - InitAnimationForceUpdate(this, 0); + UpdateAnimationSingleFrame(super); + if (!super->z.HALF.HI) { + super->action = 1; + InitAnimationForceUpdate(super, 0); sub_0808C148(this, 1); } break; } } -u32 sub_0808C128(Entity* this) { - return this->contactFlags == 157; +u32 sub_0808C128(JarPortalEntity* this) { + return super->contactFlags == 157; } -void sub_0808C13C(Entity* this) { - this->subAction = 0; - this->zVelocity = Q_16_16(2.5); +void sub_0808C13C(JarPortalEntity* this) { + super->subAction = 0; + super->zVelocity = Q_16_16(2.5); } -void sub_0808C148(Entity* this, u32 a2) { +void sub_0808C148(JarPortalEntity* this, u32 a2) { u32 pos; - pos = COORD_TO_TILE(this); + pos = COORD_TO_TILE(super); if (!a2) { - SetTile(16530, pos - 1, this->collisionLayer); - SetTile(16531, pos, this->collisionLayer); - SetTile(16532, pos + 63, this->collisionLayer); - SetTile(16533, pos + 64, this->collisionLayer); + SetTile(16530, pos - 1, super->collisionLayer); + SetTile(16531, pos, super->collisionLayer); + SetTile(16532, pos + 63, super->collisionLayer); + SetTile(16533, pos + 64, super->collisionLayer); } else { - RestorePrevTileEntity(pos - 1, this->collisionLayer); - RestorePrevTileEntity(pos, this->collisionLayer); - RestorePrevTileEntity(pos + 63, this->collisionLayer); - RestorePrevTileEntity(pos + 64, this->collisionLayer); + RestorePrevTileEntity(pos - 1, super->collisionLayer); + RestorePrevTileEntity(pos, super->collisionLayer); + RestorePrevTileEntity(pos + 63, super->collisionLayer); + RestorePrevTileEntity(pos + 64, super->collisionLayer); } } diff --git a/src/object/keyStealingTakkuri.c b/src/object/keyStealingTakkuri.c index 1b166cab..7b306f47 100644 --- a/src/object/keyStealingTakkuri.c +++ b/src/object/keyStealingTakkuri.c @@ -4,10 +4,8 @@ * * @brief Key Stealing Takkuri object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/kinstoneSpark.c b/src/object/kinstoneSpark.c index 89126c82..56da199c 100644 --- a/src/object/kinstoneSpark.c +++ b/src/object/kinstoneSpark.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "kinstone.h" #include "object.h" diff --git a/src/object/ladderHoleInBookshelf.c b/src/object/ladderHoleInBookshelf.c index dd55d741..9c856fe8 100644 --- a/src/object/ladderHoleInBookshelf.c +++ b/src/object/ladderHoleInBookshelf.c @@ -4,6 +4,7 @@ * * @brief Ladder Hole In Bookshelf object */ +#define NENT_DEPRECATED #include "entity.h" #include "player.h" diff --git a/src/object/ladderUp.c b/src/object/ladderUp.c index 8743fadc..8722022a 100644 --- a/src/object/ladderUp.c +++ b/src/object/ladderUp.c @@ -4,6 +4,7 @@ * * @brief Ladder Up object */ +#define NENT_DEPRECATED #include "asm.h" #include "effects.h" #include "entity.h" diff --git a/src/object/lamp.c b/src/object/lamp.c index 1992f36a..705d43e5 100644 --- a/src/object/lamp.c +++ b/src/object/lamp.c @@ -4,6 +4,7 @@ * * @brief Lamp object */ +#define NENT_DEPRECATED #include "entity.h" void Lamp_Init(Entity* this); diff --git a/src/object/lavaPlatform.c b/src/object/lavaPlatform.c index a79e8c4f..be968d08 100644 --- a/src/object/lavaPlatform.c +++ b/src/object/lavaPlatform.c @@ -4,10 +4,8 @@ * * @brief Lava Platform object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" diff --git a/src/object/lightDoor.c b/src/object/lightDoor.c index 5a90de45..b8c30d7b 100644 --- a/src/object/lightDoor.c +++ b/src/object/lightDoor.c @@ -4,10 +4,8 @@ * * @brief Light Door object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" #include "screen.h" diff --git a/src/object/lightRay.c b/src/object/lightRay.c index c1e58d1a..bd437bc6 100644 --- a/src/object/lightRay.c +++ b/src/object/lightRay.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" #include "screen.h" diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index ba0ba466..4484c9c4 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -4,164 +4,173 @@ * * @brief Lightable Switch object */ +#define NENT_DEPRECATED #include "asm.h" #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" #include "room.h" #include "sound.h" -static void sub_0809EB30(Entity*); -static void sub_0809EAD8(Entity*); -static void sub_0809EABC(Entity*); -static void LightableSwitch_Type0(Entity*); -static void LightableSwitch_Type1(Entity*); -static void LightableSwitch_Type0_Init(Entity*); -static void LightableSwitch_Type0_Action1(Entity*); -static void LightableSwitch_Type1_Action3(Entity*); -static void LightableSwitch_Type1_Action2(Entity*); -static void LightableSwitch_Type1_Action1(Entity*); -static void LightableSwitch_Type1_Init(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[12]; + /*0x74*/ u16 unk_74; + /*0x76*/ u8 unused2[14]; + /*0x84*/ u16 unk_84; + /*0x86*/ u16 unk_86; +} LightableSwitchEntity; -void LightableSwitch(Entity* this) { - static void (*const LightableSwitch_Types[])(Entity*) = { +static void sub_0809EB30(LightableSwitchEntity* this); +static void sub_0809EAD8(LightableSwitchEntity* this); +static void sub_0809EABC(LightableSwitchEntity* this); +static void LightableSwitch_Type0(LightableSwitchEntity* this); +static void LightableSwitch_Type1(LightableSwitchEntity* this); +static void LightableSwitch_Type0_Init(LightableSwitchEntity* this); +static void LightableSwitch_Type0_Action1(LightableSwitchEntity* this); +static void LightableSwitch_Type1_Action3(LightableSwitchEntity* this); +static void LightableSwitch_Type1_Action2(LightableSwitchEntity* this); +static void LightableSwitch_Type1_Action1(LightableSwitchEntity* this); +static void LightableSwitch_Type1_Init(LightableSwitchEntity* this); + +void LightableSwitch(LightableSwitchEntity* this) { + static void (*const LightableSwitch_Types[])(LightableSwitchEntity*) = { LightableSwitch_Type0, LightableSwitch_Type1, }; - LightableSwitch_Types[this->type](this); + LightableSwitch_Types[super->type](this); sub_0809EB30(this); } -void LightableSwitch_Type0(Entity* this) { - static void (*const LightableSwitch_Type0_Actions[])(Entity*) = { +void LightableSwitch_Type0(LightableSwitchEntity* this) { + static void (*const LightableSwitch_Type0_Actions[])(LightableSwitchEntity*) = { LightableSwitch_Type0_Init, LightableSwitch_Type0_Action1, }; - LightableSwitch_Type0_Actions[this->action](this); + LightableSwitch_Type0_Actions[super->action](this); } -void LightableSwitch_Type0_Init(Entity* this) { - this->action = 1; - COLLISION_ON(this); - this->frameIndex = 0; - this->collisionFlags = 7; - this->hurtType = 0x48; - this->hitType = 0x28; - this->flags2 = 10; - this->hitbox = (Hitbox*)&gHitbox_0; +void LightableSwitch_Type0_Init(LightableSwitchEntity* this) { + super->action = 1; + COLLISION_ON(super); + super->frameIndex = 0; + super->collisionFlags = 7; + super->hurtType = 0x48; + super->hitType = 0x28; + super->flags2 = 10; + super->hitbox = (Hitbox*)&gHitbox_0; sub_0809EAD8(this); - UpdateSpriteForCollisionLayer(this); + UpdateSpriteForCollisionLayer(super); sub_0809EABC(this); } -void LightableSwitch_Type0_Action1(Entity* this) { +void LightableSwitch_Type0_Action1(LightableSwitchEntity* this) { - if ((this->contactFlags & 0x80) != 0) { - if (CheckFlags(this->field_0x86.HWORD) != 0) { - ClearFlag(this->field_0x86.HWORD); + if ((super->contactFlags & 0x80) != 0) { + if (CheckFlags(this->unk_86) != 0) { + ClearFlag(this->unk_86); } else { - SetFlag(this->field_0x86.HWORD); + SetFlag(this->unk_86); } EnqueueSFX(SFX_110); } sub_0809EABC(this); } -static void sub_0809EABC(Entity* this) { +static void sub_0809EABC(LightableSwitchEntity* this) { bool32 anySet = 0; - if (CheckFlags(this->field_0x86.HWORD)) { + if (CheckFlags(this->unk_86)) { anySet = 1; } - if (this->frameIndex != anySet) { - this->frameIndex = anySet; + if (super->frameIndex != anySet) { + super->frameIndex = anySet; } } -static void sub_0809EAD8(Entity* this) { +static void sub_0809EAD8(LightableSwitchEntity* this) { u8 bVar1; Entity* pEVar2; - if (this->type2 != 0) { + if (super->type2 != 0) { - this->child = GetCurrentRoomProperty(this->type2); - UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); + super->child = GetCurrentRoomProperty(super->type2); + UpdateRailMovement(super, (u16**)&super->child, &this->unk_74); } else { - SetTile(0x4050, COORD_TO_TILE(this), this->collisionLayer); + SetTile(0x4050, COORD_TO_TILE(super), super->collisionLayer); } } -static void sub_0809EB30(Entity* this) { +static void sub_0809EB30(LightableSwitchEntity* this) { u16 uVar1; u16* puVar2; - if (this->type2 != 0) { - if ((this->direction & 0x80) == 0) { - LinearMoveUpdate(this); + if (super->type2 != 0) { + if ((super->direction & 0x80) == 0) { + LinearMoveUpdate(super); } - puVar2 = &this->field_0x74.HWORD; + puVar2 = &this->unk_74; if (!--*puVar2) { - UpdateRailMovement(this, (u16**)&this->child, puVar2); + UpdateRailMovement(super, (u16**)&super->child, puVar2); } } } -void LightableSwitch_Type1(Entity* this) { - static void (*const LightableSwitch_Type1_Actions[])(Entity*) = { +void LightableSwitch_Type1(LightableSwitchEntity* this) { + static void (*const LightableSwitch_Type1_Actions[])(LightableSwitchEntity*) = { LightableSwitch_Type1_Init, LightableSwitch_Type1_Action1, LightableSwitch_Type1_Action2, LightableSwitch_Type1_Action3, }; - LightableSwitch_Type1_Actions[this->action](this); + LightableSwitch_Type1_Actions[super->action](this); } -void LightableSwitch_Type1_Init(Entity* this) { +void LightableSwitch_Type1_Init(LightableSwitchEntity* this) { - this->action = 1; - COLLISION_ON(this); - this->frameIndex = 3; - this->collisionFlags = 7; - this->hurtType = 0x48; - this->hitType = 0x28; - this->flags2 = 10; - this->hitbox = (Hitbox*)&gHitbox_0; + super->action = 1; + COLLISION_ON(super); + super->frameIndex = 3; + super->collisionFlags = 7; + super->hurtType = 0x48; + super->hitType = 0x28; + super->flags2 = 10; + super->hitbox = (Hitbox*)&gHitbox_0; sub_0809EAD8(this); - UpdateSpriteForCollisionLayer(this); - if (CheckFlags(this->cutsceneBeh.HWORD) != 0) { - this->action = 3; - this->frameIndex = 2; + UpdateSpriteForCollisionLayer(super); + if (CheckFlags(this->unk_84)) { + super->action = 3; + super->frameIndex = 2; } } -void LightableSwitch_Type1_Action1(Entity* this) { - if ((this->contactFlags & 0x80) != 0) { - this->action = 2; - this->timer = 16; - this->frameIndex = 2; - SetFlag(this->field_0x86.HWORD); +void LightableSwitch_Type1_Action1(LightableSwitchEntity* this) { + if ((super->contactFlags & 0x80) != 0) { + super->action = 2; + super->timer = 16; + super->frameIndex = 2; + SetFlag(this->unk_86); EnqueueSFX(SFX_110); } } -void LightableSwitch_Type1_Action2(Entity* this) { +void LightableSwitch_Type1_Action2(LightableSwitchEntity* this) { - if (CheckFlags(this->cutsceneBeh.HWORD) != 0) { - this->action = 3; + if (CheckFlags(this->unk_84)) { + super->action = 3; } else { - if (--this->timer == 0) { - this->action = 1; - this->frameIndex = 3; - ClearFlag(this->field_0x86.HWORD); + if (--super->timer == 0) { + super->action = 1; + super->frameIndex = 3; + ClearFlag(this->unk_86); EnqueueSFX(SFX_110); } } } -void LightableSwitch_Type1_Action3(Entity* this) { +void LightableSwitch_Type1_Action3(LightableSwitchEntity* this) { } diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index 84b11274..9b380797 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -1,61 +1,47 @@ -#define NENT_DEPRECATED /** * @file lilypadLarge.c * @ingroup Objects * * @brief Large Lilypad object */ -#include "global.h" +#define NENT_DEPRECATED +#include "object/lilypadLarge.h" #include "area.h" #include "functions.h" #include "item.h" #include "object.h" -typedef struct { - Entity base; - u8 unk_68[4]; - s32 unk_6c; - s32 unk_70; - s16 unk_74; - s16 unk_76; - union SplitWord unk_78; - union SplitWord unk_7c; - u8 unk_80[2]; - u16 unk_82; - u8 unk_84; - u8 unk_85; -} LilypadLargeEntity; - extern s8 gUnk_08126EE4[]; -void sub_080855E8(LilypadLargeEntity*); -void sub_08085CDC(LilypadLargeEntity*); +void LilypadLarge_Action1(LilypadLargeEntity*); +void LilypadLarge_Action4(LilypadLargeEntity*); void sub_08085EFC(LilypadLargeEntity*); void sub_08085F1C(LilypadLargeEntity*); void sub_08085E74(LilypadLargeEntity*); void sub_08085F48(LilypadLargeEntity*); void sub_08085D28(LilypadLargeEntity*); void sub_08085D60(LilypadLargeEntity*); -void sub_08085504(LilypadLargeEntity*); -void sub_080855E8(LilypadLargeEntity*); -void sub_08085A1C(LilypadLargeEntity*); -void sub_08085C5C(LilypadLargeEntity*); -void sub_08085CDC(LilypadLargeEntity*); -void sub_08085D10(LilypadLargeEntity*); +void LilypadLarge_Init(LilypadLargeEntity*); +void LilypadLarge_Action1(LilypadLargeEntity*); +void LilypadLarge_Action2(LilypadLargeEntity*); +void LilypadLarge_Action3(LilypadLargeEntity*); +void LilypadLarge_Action4(LilypadLargeEntity*); +void LilypadLarge_Action5(LilypadLargeEntity*); void sub_08085B40(LilypadLargeEntity*); void sub_08085A98(LilypadLargeEntity*); void sub_08085A44(LilypadLargeEntity*); void LilypadLarge(LilypadLargeEntity* this) { - static void (*const actionFuncs[])(LilypadLargeEntity*) = { - sub_08085504, sub_080855E8, sub_08085A1C, sub_08085C5C, sub_08085CDC, sub_08085D10, + static void (*const LilypadLarge_actions[])(LilypadLargeEntity*) = { + LilypadLarge_Init, LilypadLarge_Action1, LilypadLarge_Action2, + LilypadLarge_Action3, LilypadLarge_Action4, LilypadLarge_Action5, }; - actionFuncs[super->action](this); + LilypadLarge_actions[super->action](this); } static const Hitbox gUnk_08120640; -void sub_08085504(LilypadLargeEntity* this) { +void LilypadLarge_Init(LilypadLargeEntity* this) { if (super->type == 0xff) { if (GetInventoryValue(ITEM_FLIPPERS)) { DeleteThisEntity(); @@ -97,10 +83,10 @@ void sub_08085504(LilypadLargeEntity* this) { this->unk_85 = 0; this->unk_84 = 0; InitializeAnimation(super, 9); - sub_080855E8(this); + LilypadLarge_Action1(this); } -void sub_080855E8(LilypadLargeEntity* this) { +void LilypadLarge_Action1(LilypadLargeEntity* this) { static const u32 gUnk_08120620[] = { 0x5000, 0x18000, @@ -331,7 +317,7 @@ void sub_080855E8(LilypadLargeEntity* this) { sub_08085F48(this); } -void sub_08085A1C(LilypadLargeEntity* this) { +void LilypadLarge_Action2(LilypadLargeEntity* this) { static void (*const subActionFuncs[])(LilypadLargeEntity*) = { sub_08085A44, sub_08085A98, @@ -403,7 +389,7 @@ void sub_08085B40(LilypadLargeEntity* this) { ResetCollisionLayer(super); if (GetTileUnderEntity(super) == 0xd) { ResetCollisionLayer(&gPlayerEntity); - sub_08085CDC(this); + LilypadLarge_Action4(this); super->direction = GetFacingDirection(&gPlayerEntity, super); LinearMoveDirection(&gPlayerEntity, 0x100, super->direction); } @@ -432,7 +418,7 @@ void sub_08085B40(LilypadLargeEntity* this) { } } -void sub_08085C5C(LilypadLargeEntity* this) { +void LilypadLarge_Action3(LilypadLargeEntity* this) { if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) { LinearMoveUpdate(super); gPlayerEntity.speed = super->speed; @@ -453,7 +439,7 @@ void sub_08085C5C(LilypadLargeEntity* this) { } } -void sub_08085CDC(LilypadLargeEntity* this) { +void LilypadLarge_Action4(LilypadLargeEntity* this) { this->unk_78.WORD += 0x100000; if (this->unk_78.WORD_U < 0x4000000) { SetAffineInfo(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); @@ -462,7 +448,7 @@ void sub_08085CDC(LilypadLargeEntity* this) { } } -void sub_08085D10(LilypadLargeEntity* this) { +void LilypadLarge_Action5(LilypadLargeEntity* this) { if (EntityHasDuplicateID(super) != 0) { SetLocalFlag(super->type2); DeleteThisEntity(); diff --git a/src/object/lilypadLargeFalling.c b/src/object/lilypadLargeFalling.c index 4a918c59..e32b0f88 100644 --- a/src/object/lilypadLargeFalling.c +++ b/src/object/lilypadLargeFalling.c @@ -4,9 +4,10 @@ * * @brief LilypadLargeFalling object */ +#define NENT_DEPRECATED #include "entity.h" #include "functions.h" -#include "global.h" +#include "object/lilypadLarge.h" void LilypadLargeFalling(Entity* this) { Entity* parent; @@ -22,7 +23,7 @@ void LilypadLargeFalling(Entity* this) { if (parent->z.WORD == 0) { DeleteThisEntity(); } else { - int position = 0x120 - parent->z.HALF.HI; - SetAffineInfo(this, position, position, parent->field_0x7c.HALF_U.HI); + s32 position = 0x120 - parent->z.HALF.HI; + SetAffineInfo(this, position, position, ((LilypadLargeEntity*)parent)->unk_7c.HALF_U.HI); } } diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c index d017b1d9..1d84c392 100644 --- a/src/object/lilypadSmall.c +++ b/src/object/lilypadSmall.c @@ -4,39 +4,46 @@ * * @brief Lilypad Small object */ +#define NENT_DEPRECATED #include "functions.h" #include "object.h" -static void sub_08097B24(Entity* this); -static bool32 CheckMovePlayer(Entity* this); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[8]; + /*0x70*/ u16 unk_70; +} LilypadSmallEntity; -void LilypadSmall(Entity* this) { +static void sub_08097B24(LilypadSmallEntity* this); +static bool32 CheckMovePlayer(LilypadSmallEntity* this); + +void LilypadSmall(LilypadSmallEntity* this) { u32 rand; u16* psVar4; - if (this->action == 0) { - this->action = 1; - this->timer = 90; + if (super->action == 0) { + super->action = 1; + super->timer = 90; rand = Random(); - this->subtimer = rand; - this->frameIndex = (rand >> 0x10) & 3; - this->spriteSettings.draw = TRUE; - this->spritePriority.b0 = 7; - this->child = GetCurrentRoomProperty(this->type2); - UpdateRailMovement(this, (u16**)&this->child, &this->field_0x70.HALF.LO); + super->subtimer = rand; + super->frameIndex = (rand >> 0x10) & 3; + super->spriteSettings.draw = TRUE; + super->spritePriority.b0 = 7; + super->child = GetCurrentRoomProperty(super->type2); + UpdateRailMovement(super, (u16**)&super->child, &this->unk_70); } - SyncPlayerToPlatform(this, CheckMovePlayer(this)); + SyncPlayerToPlatform(super, CheckMovePlayer(this)); sub_08097B24(this); - psVar4 = (u16*)&this->field_0x70; + psVar4 = &this->unk_70; if (--*psVar4 == 0) { - UpdateRailMovement(this, (u16**)&this->child, psVar4); + UpdateRailMovement(super, (u16**)&super->child, psVar4); } } -static bool32 CheckMovePlayer(Entity* this) { +static bool32 CheckMovePlayer(LilypadSmallEntity* this) { if (!(gPlayerState.flags & PL_MINISH)) { return FALSE; - } else if (EntityInRectRadius(this, &gPlayerEntity, 8, 8) == 0) { + } else if (EntityInRectRadius(super, &gPlayerEntity, 8, 8) == 0) { return FALSE; } else if (!PlayerCanBeMoved()) { return FALSE; @@ -50,7 +57,7 @@ static bool32 CheckMovePlayer(Entity* this) { } } -static void sub_08097B24(Entity* this) { +static void sub_08097B24(LilypadSmallEntity* this) { static const u16 gUnk_08123318[] = { 0x100, 0x101, 0x102, 0x101, 0x100, 0xff, 0xfe, 0xff, }; @@ -58,13 +65,13 @@ static void sub_08097B24(Entity* this) { u32 temp2; const u16* temp3; - if (--this->timer == 0) { - this->timer = 90; - this->frameIndex = (this->frameIndex + 1) & 3; + if (--super->timer == 0) { + super->timer = 90; + super->frameIndex = (super->frameIndex + 1) & 3; } temp3 = gUnk_08123318; - temp2 = ++this->subtimer; + temp2 = ++super->subtimer; temp = temp3[(temp2 >> 5) & 7]; - SetAffineInfo(this, temp, temp, 0); + SetAffineInfo(super, temp, temp, 0); } diff --git a/src/object/linkAnimation.c b/src/object/linkAnimation.c index 7d5d2cae..8a9d361d 100644 --- a/src/object/linkAnimation.c +++ b/src/object/linkAnimation.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "message.h" #include "object.h" diff --git a/src/object/linkEmptyingBottle.c b/src/object/linkEmptyingBottle.c index 8c8b4ac7..f9787ac4 100644 --- a/src/object/linkEmptyingBottle.c +++ b/src/object/linkEmptyingBottle.c @@ -5,10 +5,8 @@ * @brief Link Emptying Bottle object * Handles effects of using water, mineral water or a fairy in a bottle in PlayerItemBottle_UseOther. */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "item.h" #include "object.h" @@ -19,20 +17,20 @@ typedef struct { extern u32 sub_080B1A0C(Entity*, s32, s32); -void sub_08094774(LinkEmptyingBottleEntity*); -void sub_080948D0(LinkEmptyingBottleEntity*); +void LinkEmptyingBottle_Init(LinkEmptyingBottleEntity*); +void LinkEmptyingBottle_Action1(LinkEmptyingBottleEntity*); void sub_080948E8(LinkEmptyingBottleEntity*); void sub_08094980(LinkEmptyingBottleEntity*, u32, u32); void LinkEmptyingBottle(LinkEmptyingBottleEntity* this) { - static void (*const gUnk_08122A10[])(LinkEmptyingBottleEntity*) = { - sub_08094774, - sub_080948D0, + static void (*const LinkEmptyingBottle_Actions[])(LinkEmptyingBottleEntity*) = { + LinkEmptyingBottle_Init, + LinkEmptyingBottle_Action1, }; - gUnk_08122A10[super->action](this); + LinkEmptyingBottle_Actions[super->action](this); } -void sub_08094774(LinkEmptyingBottleEntity* this) { +void LinkEmptyingBottle_Init(LinkEmptyingBottleEntity* this) { static const s8 gUnk_08122A18[] = { 0, -8, 8, 1, 2, 8, -8, 1 }; Entity* effect; Entity* child; @@ -79,7 +77,7 @@ void sub_08094774(LinkEmptyingBottleEntity* this) { DeleteThisEntity(); } -void sub_080948D0(LinkEmptyingBottleEntity* this) { +void LinkEmptyingBottle_Action1(LinkEmptyingBottleEntity* this) { static void (*const gUnk_08122A20[])(LinkEmptyingBottleEntity*) = { NULL, sub_080948E8, diff --git a/src/object/linkFire.c b/src/object/linkFire.c index c67b6c45..7a5b4292 100644 --- a/src/object/linkFire.c +++ b/src/object/linkFire.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/linkHoldingItem.c b/src/object/linkHoldingItem.c index 61982614..ae982637 100644 --- a/src/object/linkHoldingItem.c +++ b/src/object/linkHoldingItem.c @@ -7,7 +7,6 @@ #define NENT_DEPRECATED #include "functions.h" #include "game.h" -#include "global.h" #include "item.h" #include "itemMetaData.h" #include "message.h" diff --git a/src/object/litArea.c b/src/object/litArea.c index b615672c..8d39ddf1 100644 --- a/src/object/litArea.c +++ b/src/object/litArea.c @@ -4,46 +4,55 @@ * * @brief Lit Area object */ +#define NENT_DEPRECATED #include "entity.h" #include "flags.h" #include "functions.h" #include "room.h" #include "screen.h" -void LitArea(Entity* this) { - if (this->action == 0) { - if (this->field_0x86.HWORD != 0 && CheckFlags(this->field_0x86.HWORD) == 0) { +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; + /*0x6a*/ u16 unk_6a; + /*0x6c*/ u8 unused1[26]; + /*0x86*/ u16 unk_86; +} LitAreaEntity; + +void LitArea(LitAreaEntity* this) { + if (super->action == 0) { + if (this->unk_86 != 0 && CheckFlags(this->unk_86) == 0) { return; } - this->spriteSettings.draw = 1; - this->action = 1; - this->spriteRendering.alphaBlend = 2; - this->spriteRendering.b0 = 3; - this->frameIndex = 3; - this->flags |= ENT_PERSIST; - this->subtimer = gRoomControls.room; - this->timer = 2; - this->field_0x68.HWORD = -2; - this->field_0x6a.HWORD = 0x80; - SetAffineInfo(this, 0x80, 0x80, 0); + super->spriteSettings.draw = 1; + super->action = 1; + super->spriteRendering.alphaBlend = 2; + super->spriteRendering.b0 = 3; + super->frameIndex = 3; + super->flags |= ENT_PERSIST; + super->subtimer = gRoomControls.room; + super->timer = 2; + this->unk_68 = -2; + this->unk_6a = 0x80; + SetAffineInfo(super, 0x80, 0x80, 0); } else { - if (--this->timer == 0) { - this->timer = 2; - this->field_0x6a.HWORD += this->field_0x68.HWORD; - if (this->field_0x6a.HWORD < 0x78) { - this->field_0x68.HWORD = 1; + if (--super->timer == 0) { + super->timer = 2; + this->unk_6a += this->unk_68; + if (this->unk_6a < 0x78) { + this->unk_68 = 1; } - if (0x88 < this->field_0x6a.HWORD) { - this->field_0x68.HWORD = -1; + if (this->unk_6a > 0x88) { + this->unk_68 = -1; } - SetAffineInfo(this, this->field_0x6a.HWORD, this->field_0x6a.HWORD, 0); + SetAffineInfo(super, this->unk_6a, this->unk_6a, 0); } } gScreen.lcd.displayControl |= DISPCNT_OBJWIN_ON; gScreen.controls.windowOutsideControl = (gScreen.controls.windowOutsideControl & 0xff) | WINOUT_WINOBJ_BG0 | WINOUT_WINOBJ_BG1 | WINOUT_WINOBJ_BG2 | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR; - if ((gRoomControls.room != this->subtimer) && (gRoomControls.reload_flags == 0)) { + if ((gRoomControls.room != super->subtimer) && (gRoomControls.reload_flags == 0)) { DeleteThisEntity(); } } diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index 6cc6c1a6..6f1812ac 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -4,6 +4,7 @@ * * @brief Looked Door object */ +#define NENT_DEPRECATED #include "asm.h" #include "common.h" #include "effects.h" @@ -11,35 +12,47 @@ #include "flags.h" #include "functions.h" #include "game.h" -#include "global.h" #include "hitbox.h" #include "sound.h" -void LockedDoor_Init(Entity*); -void LockedDoor_Action1(Entity*); -void LockedDoor_Action2(Entity*); -void LockedDoor_Action3(Entity*); -void LockedDoor_Action4(Entity*); -void LockedDoor_Action5(Entity*); -void LockedDoor_Action6(Entity*); -void LockedDoor_Action7(Entity*); -void LockedDoor_Action8(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[8]; + /*0x70*/ u16 unk_70; + /*0x72*/ u16 unk_72; + /*0x74*/ u16 unk_74; + /*0x76*/ u16 unk_76; + /*0x78*/ u8 unused2[6]; + /*0x7e*/ u8 unk_7e; + /*0x7f*/ u8 unused3[5]; + /*0x84*/ u16 unk_84; + /*0x86*/ u16 unk_86; +} LockedDoorEntity; -void sub_08083638(Entity*); -void sub_08083658(Entity*); -void sub_080836A0(Entity*); -void sub_080836DC(Entity*, u32, u32); -u32 sub_08083734(Entity*, u32); -u32 sub_080837B0(Entity*); -void sub_08083814(Entity*, u32); +void LockedDoor_Init(LockedDoorEntity* this); +void LockedDoor_Action1(LockedDoorEntity* this); +void LockedDoor_Action2(LockedDoorEntity* this); +void LockedDoor_Action3(LockedDoorEntity* this); +void LockedDoor_Action4(LockedDoorEntity* this); +void LockedDoor_Action5(LockedDoorEntity* this); +void LockedDoor_Action6(LockedDoorEntity* this); +void LockedDoor_Action7(LockedDoorEntity* this); +void LockedDoor_Action8(LockedDoorEntity* this); -void (*const LockedDoor_Actions[])(Entity*) = { +void sub_08083638(LockedDoorEntity* this); +void sub_08083658(LockedDoorEntity* this); +void sub_080836A0(LockedDoorEntity* this); +void sub_080836DC(Entity* this, u32, u32); +u32 sub_080837B0(LockedDoorEntity* this); +void sub_08083814(LockedDoorEntity* this, u32); + +void (*const LockedDoor_Actions[])(LockedDoorEntity*) = { LockedDoor_Init, LockedDoor_Action1, LockedDoor_Action2, LockedDoor_Action3, LockedDoor_Action4, LockedDoor_Action5, LockedDoor_Action6, LockedDoor_Action7, LockedDoor_Action8, }; -void LockedDoor(Entity* this) { - LockedDoor_Actions[this->action](this); +void LockedDoor(LockedDoorEntity* this) { + LockedDoor_Actions[super->action](this); } typedef struct PACKED { @@ -88,54 +101,53 @@ const u8 gLockedDoorInteractDirections[] = { 0xD7, }; -void LockedDoor_Init(Entity* this) { - if (this->cutsceneBeh.HWORD != 0xFFFF && CheckFlags(this->cutsceneBeh.HWORD)) { +void LockedDoor_Init(LockedDoorEntity* this) { + if (this->unk_84 != 0xFFFF && CheckFlags(this->unk_84)) { DeleteThisEntity(); } if (!sub_080837B0(this)) return; - this->type2 = (this->type >> 2) & 3; - this->frameIndex = this->type & 3; - this->speed = 0x300; - 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 = (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); - this->field_0x74.HWORD = GetTileIndex(this->field_0x76.HWORD, this->collisionLayer); - switch (this->type2) { + super->type2 = (super->type >> 2) & 3; + super->frameIndex = super->type & 3; + super->speed = 0x300; + this->unk_70 = super->x.HALF.HI; + this->unk_72 = super->y.HALF.HI; + this->unk_7e = super->type & 3; + super->hitbox = (Hitbox*)&gHitbox_2; + super->spritePriority.b0 = 5; + super->frame = super->type & 0xF; + this->unk_76 = TILE(super->x.HALF.HI, super->y.HALF.HI); + this->unk_74 = GetTileIndex(this->unk_76, super->collisionLayer); + switch (super->type2) { case 0: - if (!CheckFlags(this->field_0x86.HWORD)) { - if (this->type & 0x10) { - this->action = 3; + if (!CheckFlags(this->unk_86)) { + if (super->type & 0x10) { + super->action = 3; } else { sub_080836A0(this); } } else { - this->type &= ~0x10; + super->type &= ~0x10; sub_08083638(this); } break; case 1: - if (!CheckFlags(this->field_0x86.HWORD)) { + if (!CheckFlags(this->unk_86)) { sub_08083638(this); } else { sub_080836A0(this); } break; case 2: - if (!CheckFlags(this->field_0x86.HWORD)) { - this->frameIndex |= 4; - sub_080836DC(this, this->field_0x7c.BYTES.byte2, this->field_0x76.HWORD); + if (!CheckFlags(this->unk_86)) { + super->frameIndex |= 4; + sub_080836DC(super, this->unk_7e, this->unk_76); if (!AreaIsDungeon()) { - this->action = 5; + super->action = 5; } else { - this->action = 8; - AddInteractableSmallKeyLock(this); - SetInteractableObjectCollision(this, 0, gLockedDoorInteractDirections[this->field_0x7c.BYTES.byte2], - NULL); + super->action = 8; + AddInteractableSmallKeyLock(super); + SetInteractableObjectCollision(super, 0, gLockedDoorInteractDirections[this->unk_7e], NULL); } } else { DeleteThisEntity(); @@ -147,19 +159,19 @@ void LockedDoor_Init(Entity* this) { } } -void LockedDoor_Action1(Entity* this) { - if (--this->timer == 0) { - this->action = 2; - this->timer = 7; - SetTile(this->field_0x74.HWORD, this->field_0x76.HWORD, this->collisionLayer); +void LockedDoor_Action1(LockedDoorEntity* this) { + if (--super->timer == 0) { + super->action = 2; + super->timer = 7; + SetTile(this->unk_74, this->unk_76, super->collisionLayer); EnqueueSFX(SFX_10B); } } -void LockedDoor_Action2(Entity* this) { - LinearMoveUpdate(this); - if (--this->timer == 0) { - if (this->type & 0x80) { +void LockedDoor_Action2(LockedDoorEntity* this) { + LinearMoveUpdate(super); + if (--super->timer == 0) { + if (super->type & 0x80) { sub_08083638(this); } else { DeleteThisEntity(); @@ -167,91 +179,91 @@ void LockedDoor_Action2(Entity* this) { } } -void LockedDoor_Action3(Entity* this) { - if (sub_08083734(this, this->field_0x7c.BYTES.byte2)) { - this->action = 4; - sub_080836DC(this, this->field_0x7c.BYTES.byte2, this->field_0x76.HWORD); +void LockedDoor_Action3(LockedDoorEntity* this) { + if (sub_08083734(super, this->unk_7e)) { + super->action = 4; + sub_080836DC(super, this->unk_7e, this->unk_76); } } -void LockedDoor_Action4(Entity* this) { - LinearMoveUpdate(this); - if (!--this->timer) { - if (this->type & 0x10) { - this->type &= ~0x10; +void LockedDoor_Action4(LockedDoorEntity* this) { + LinearMoveUpdate(super); + if (!--super->timer) { + if (super->type & 0x10) { + super->type &= ~0x10; sub_080836A0(this); } else { - if (this->type & 0x80) { + if (super->type & 0x80) { sub_080836A0(this); } else { - this->action = 5; + super->action = 5; } } - sub_08083814(this, this->field_0x7c.BYTES.byte2); + sub_08083814(this, this->unk_7e); EnqueueSFX(SFX_10B); } } -void LockedDoor_Action5(Entity* this) { +void LockedDoor_Action5(LockedDoorEntity* this) { } -void LockedDoor_Action6(Entity* this) { - if (this->type2 == 0) { - if (!CheckFlags(this->field_0x86.HWORD)) +void LockedDoor_Action6(LockedDoorEntity* this) { + if (super->type2 == 0) { + if (!CheckFlags(this->unk_86)) return; } else { - if (CheckFlags(this->field_0x86.HWORD)) + if (CheckFlags(this->unk_86)) return; } sub_08083658(this); } -void LockedDoor_Action7(Entity* this) { - if (this->type2 == 0) { - if (CheckFlags(this->field_0x86.HWORD)) +void LockedDoor_Action7(LockedDoorEntity* this) { + if (super->type2 == 0) { + if (CheckFlags(this->unk_86)) return; } else { - if (!CheckFlags(this->field_0x86.HWORD)) + if (!CheckFlags(this->unk_86)) return; } - this->action = 3; + super->action = 3; } -void LockedDoor_Action8(Entity* this) { - if (this->interactType == 0 && !CheckFlags(this->field_0x86.HWORD)) +void LockedDoor_Action8(LockedDoorEntity* this) { + if (super->interactType == 0 && !CheckFlags(this->unk_86)) return; - this->action = 1; - this->timer = 20; + super->action = 1; + super->timer = 20; sub_08083658(this); - SetFlag(this->field_0x86.HWORD); + SetFlag(this->unk_86); ModDungeonKeys(-1); } -void sub_08083638(Entity* this) { - this->action = 7; - this->spriteSettings.draw = 0; - this->x.HALF.HI = this->field_0x70.HALF.LO; - this->y.HALF.HI = this->field_0x70.HALF.HI; +void sub_08083638(LockedDoorEntity* this) { + super->action = 7; + super->spriteSettings.draw = 0; + super->x.HALF.HI = this->unk_70; + super->y.HALF.HI = this->unk_72; } -void sub_08083658(Entity* this) { +void sub_08083658(LockedDoorEntity* this) { const struct_0811F680* tmp; - this->action = 1; - this->timer = 20; - this->direction = this->field_0x7c.BYTES.byte2 << 3; - tmp = &gUnk_0811F680[this->field_0x7c.BYTES.byte2]; - this->x.HALF.HI += tmp->x; - this->y.HALF.HI += tmp->y; - RequestPriorityDuration(this, 60); + super->action = 1; + super->timer = 20; + super->direction = this->unk_7e << 3; + tmp = &gUnk_0811F680[this->unk_7e]; + super->x.HALF.HI += tmp->x; + super->y.HALF.HI += tmp->y; + RequestPriorityDuration(super, 60); SoundReq(SFX_10B); } -void sub_080836A0(Entity* this) { - this->action = 6; - this->spriteSettings.draw = 1; - this->x.HALF.HI = this->field_0x70.HALF.LO; - this->y.HALF.HI = this->field_0x70.HALF.HI; - SetTile(0x4022, this->field_0x76.HWORD, this->collisionLayer); +void sub_080836A0(LockedDoorEntity* this) { + super->action = 6; + super->spriteSettings.draw = 1; + super->x.HALF.HI = this->unk_70; + super->y.HALF.HI = this->unk_72; + SetTile(0x4022, this->unk_76, super->collisionLayer); } void sub_080836DC(Entity* this, u32 unk_0, u32 unk_1) { @@ -268,28 +280,30 @@ void sub_080836DC(Entity* this, u32 unk_0, u32 unk_1) { } u32 sub_08083734(Entity* this, u32 unk0) { + // TODO this is used in bossDoor, carlovObject, lockedDoor, metalDoor and minecartDoor. Do they have the same entity + // struct? switch (unk0) { case 0: - if (this->field_0x70.HALF_U.HI + 0xd - gPlayerEntity.y.HALF.HI < 0) + if (((LockedDoorEntity*)this)->unk_72 + 0xd - gPlayerEntity.y.HALF.HI < 0) return 1; break; case 1: - if (gPlayerEntity.x.HALF.HI - (this->field_0x70.HALF_U.LO - 0xb) < 0) + if (gPlayerEntity.x.HALF.HI - (((LockedDoorEntity*)this)->unk_70 - 0xb) < 0) return 1; break; case 2: - if (gPlayerEntity.y.HALF.HI - (this->field_0x70.HALF_U.HI - 0x8) < 0) + if (gPlayerEntity.y.HALF.HI - (((LockedDoorEntity*)this)->unk_72 - 0x8) < 0) return 1; break; case 3: - if (this->field_0x70.HALF_U.LO + 0xa - gPlayerEntity.x.HALF.HI < 0) + if (((LockedDoorEntity*)this)->unk_70 + 0xa - gPlayerEntity.x.HALF.HI < 0) return 1; break; } return 0; } -u32 sub_080837B0(Entity* this) { +u32 sub_080837B0(LockedDoorEntity* this) { u32 tmp; u32 tmp2 = gRoomControls.area; if (tmp2 < 0x40) { @@ -308,24 +322,24 @@ u32 sub_080837B0(Entity* this) { tmp = gUnk_0811F690[tmp2 - 0x40]; } if (tmp2 == 0x68) { - ChangeObjPalette(this, 0); + ChangeObjPalette(super, 0); } else { if (tmp2 == 0x88) { - ChangeObjPalette(this, 1); + ChangeObjPalette(super, 1); } } - LoadFixedGFX(this, tmp); + LoadFixedGFX(super, tmp); } -void sub_08083814(Entity* this, u32 unk0) { +void sub_08083814(LockedDoorEntity* this, u32 unk0) { Entity* fx; const struct_0811F730* tmp = &gUnk_0811F730[unk0]; - fx = CreateFx(this, FX_DASH, 0x40); + fx = CreateFx(super, FX_DASH, 0x40); if (fx) { fx->x.HALF.HI += tmp->unk_00.x; fx->y.HALF.HI += tmp->unk_00.y; } - fx = CreateFx(this, FX_DASH, 0x40); + fx = CreateFx(super, FX_DASH, 0x40); if (fx) { fx->x.HALF.HI += tmp->unk_02.x; fx->y.HALF.HI += tmp->unk_02.y; diff --git a/src/object/macroAcorn.c b/src/object/macroAcorn.c index c52f503d..044ab9f1 100644 --- a/src/object/macroAcorn.c +++ b/src/object/macroAcorn.c @@ -4,41 +4,48 @@ * * @brief Macro Acorn object */ +#define NENT_DEPRECATED #include "entity.h" #include "object.h" #include "physics.h" -void MacroAcorn_Init(Entity*); -void MacroAcorn_Action1(Entity*); -void sub_0809E5F0(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[24]; + /*0x80*/ u16 unk_80; +} MacroAcornEntity; -void MacroAcorn(Entity* this) { - static void (*const MacroAcorn_Actions[])(Entity*) = { +void MacroAcorn_Init(MacroAcornEntity* this); +void MacroAcorn_Action1(MacroAcornEntity* this); +void sub_0809E5F0(MacroAcornEntity* this); + +void MacroAcorn(MacroAcornEntity* this) { + static void (*const MacroAcorn_Actions[])(MacroAcornEntity*) = { MacroAcorn_Init, MacroAcorn_Action1, }; - MacroAcorn_Actions[this->action](this); + MacroAcorn_Actions[super->action](this); } -void MacroAcorn_Init(Entity* this) { +void MacroAcorn_Init(MacroAcornEntity* this) { u32 bVar2; Entity* pEVar3; - this->action = 1; - if (this->type == 0xff) { - this->frameIndex = this->type2; + super->action = 1; + if (super->type == 0xff) { + super->frameIndex = super->type2; } else { - bVar2 = (this->type & 1) ? 4 : 0; - if ((this->type & 2)) { + bVar2 = (super->type & 1) ? 4 : 0; + if ((super->type & 2)) { if (gEntCount < 0x45) { - this->frameIndex = bVar2; + super->frameIndex = bVar2; pEVar3 = CreateObject(HUGE_ACORN, 0xff, ++bVar2); - CopyPosition(this, pEVar3); + CopyPosition(super, pEVar3); pEVar3 = CreateObject(HUGE_ACORN, 0xff, ++bVar2); - PositionRelative(this, pEVar3, 0, 0x10000); + PositionRelative(super, pEVar3, 0, 0x10000); pEVar3->spriteOffsetY = -1; pEVar3 = CreateObject(HUGE_ACORN, 0xff, ++bVar2); - CopyPosition(this, pEVar3); + CopyPosition(super, pEVar3); } else { DeleteThisEntity(); } @@ -47,26 +54,26 @@ void MacroAcorn_Init(Entity* this) { if (pEVar3 == NULL) { DeleteThisEntity(); } else { - this->frameIndex = bVar2; - CopyPosition(this, pEVar3); + super->frameIndex = bVar2; + CopyPosition(super, pEVar3); } } sub_0809E5F0(this); } - if ((this->frameIndex & 1) != 0) { - this->spriteRendering.b3 = 3; - this->spritePriority.b0 = 7; + if ((super->frameIndex & 1) != 0) { + super->spriteRendering.b3 = 3; + super->spritePriority.b0 = 7; } } -void MacroAcorn_Action1(Entity* this) { +void MacroAcorn_Action1(MacroAcornEntity* this) { } -void sub_0809E5F0(Entity* this) { - u32 position = COORD_TO_TILE(this); - this->field_0x80.HWORD = position; - switch (this->type) { +void sub_0809E5F0(MacroAcornEntity* this) { + u32 position = COORD_TO_TILE(super); + this->unk_80 = position; + switch (super->type) { case 2: SetTile(0x4022, position - 0x3d, 1); SetTile(0x406d, position - 0x3c, 1); diff --git a/src/object/macroBook.c b/src/object/macroBook.c index 59f025a4..0c116b44 100644 --- a/src/object/macroBook.c +++ b/src/object/macroBook.c @@ -30,13 +30,13 @@ void sub_0809A9D4(MacroBookEntity*); void sub_0809AA9C(MacroBookEntity*, Entity*, u32); void MacroBook(Entity* this) { - static void (*const actionFuncs[])(MacroBookEntity*) = { + static void (*const MacroBook_Actions[])(MacroBookEntity*) = { MacroBook_Init, MacroBook_Action1, MacroBook_Action2, MacroBook_Action3, }; - actionFuncs[this->action]((MacroBookEntity*)this); + MacroBook_Actions[this->action]((MacroBookEntity*)this); } void MacroBook_Init(MacroBookEntity* this) { diff --git a/src/object/macroDecorations.c b/src/object/macroDecorations.c index f68ce765..5227ec46 100644 --- a/src/object/macroDecorations.c +++ b/src/object/macroDecorations.c @@ -32,7 +32,6 @@ void MacroDecoration(Entity* this) { void MacroDecoration_Init(MacroDecorationEntity* this) { u32 bVar1; - u32 uVar2; super->action = 1; UpdateSpriteForCollisionLayer(super); diff --git a/src/object/macroMushroomStalk.c b/src/object/macroMushroomStalk.c index 45eb8fe0..92f70fa0 100644 --- a/src/object/macroMushroomStalk.c +++ b/src/object/macroMushroomStalk.c @@ -4,6 +4,7 @@ * * @brief Macro Mushroom Stalk object */ +#define NENT_DEPRECATED #include "area.h" #include "entity.h" #include "main.h" diff --git a/src/object/macroPlayer.c b/src/object/macroPlayer.c index 075d749e..deb5a7c8 100644 --- a/src/object/macroPlayer.c +++ b/src/object/macroPlayer.c @@ -34,20 +34,20 @@ void MacroPlayer_Type0_Action10(MacroPlayerEntity*); void sub_0808CB9C(MacroPlayerEntity*); void MacroPlayer(Entity* this) { - static void (*const typeFuncs[])(MacroPlayerEntity*) = { + static void (*const MacroPlayer_Types[])(MacroPlayerEntity*) = { MacroPlayer_Type0, MacroPlayer_Type1, }; - typeFuncs[this->type]((MacroPlayerEntity*)this); + MacroPlayer_Types[this->type]((MacroPlayerEntity*)this); } void MacroPlayer_Type0(MacroPlayerEntity* this) { - static void (*const actionFuncs[])(MacroPlayerEntity*) = { + static void (*const MacroPlayer_Type0_Actions[])(MacroPlayerEntity*) = { MacroPlayer_Type0_Init, MacroPlayer_Type0_Action1, MacroPlayer_Type0_Action2, MacroPlayer_Type0_Action3, MacroPlayer_Type0_Action4, MacroPlayer_Type0_Action5, MacroPlayer_Type0_Action6, MacroPlayer_Type0_Action7, MacroPlayer_Type0_Action8, MacroPlayer_Type0_Action9, MacroPlayer_Type0_Action10, }; - actionFuncs[super->action](this); + MacroPlayer_Type0_Actions[super->action](this); sub_0808CB9C(this); } diff --git a/src/object/macroShoe.c b/src/object/macroShoe.c index 2d4b5ac2..e9b12000 100644 --- a/src/object/macroShoe.c +++ b/src/object/macroShoe.c @@ -4,6 +4,7 @@ * * @brief Macro Shoe object */ +#define NENT_DEPRECATED #include "asm.h" #include "entity.h" diff --git a/src/object/mask.c b/src/object/mask.c index 886105e9..e6934e5a 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -4,30 +4,42 @@ * * @brief Mask object */ +#define NENT_DEPRECATED #include "functions.h" #include "object.h" -void Mask_Init(Entity*); -void Mask_Action1(Entity*); -void Mask_Action2(Entity*); -void Mask_Delete(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[16]; + /*0x78*/ u16 unk_78; + /*0x7a*/ u16 unk_7a; + /*0x7c*/ u16 unk_7c; + /*0x7e*/ u16 unk_7e; + /*0x80*/ u8 unused2[6]; + /*0x86*/ u16 unk_86; +} MaskEntity; -void Mask(Entity* this) { - static void (*const Mask_Actions[])(Entity*) = { +void Mask_Init(MaskEntity* this); +void Mask_Action1(MaskEntity* this); +void Mask_Action2(MaskEntity* this); +void Mask_Delete(MaskEntity* this); + +void Mask(MaskEntity* this) { + static void (*const Mask_Actions[])(MaskEntity*) = { Mask_Init, Mask_Action1, Mask_Action2, Mask_Delete, }; - Mask_Actions[this->action](this); + Mask_Actions[super->action](this); } -void Mask_Init(Entity* this) { - if (this->type2 & 0xC0) { - if (CheckFlags(this->field_0x86.HWORD)) { +void Mask_Init(MaskEntity* this) { + if (super->type2 & 0xC0) { + if (CheckFlags(this->unk_86)) { s32 field_0x0a; - switch (this->type2 & 0xC0) { + switch (super->type2 & 0xC0) { case 0x40: field_0x0a = gRoomTransition.stairs_idx; @@ -37,7 +49,7 @@ void Mask_Init(Entity* this) { DeleteThisEntity(); break; default: - ClearFlag(this->field_0x86.HWORD); + ClearFlag(this->unk_86); } break; @@ -48,26 +60,26 @@ void Mask_Init(Entity* this) { } } - this->action = 1; - this->zVelocity = Q_16_16(1.5); + super->action = 1; + super->zVelocity = Q_16_16(1.5); - this->field_0x78.HWORD = ((Random() & 7) << 10) | 0x2000; + this->unk_78 = ((Random() & 7) << 10) | 0x2000; - this->subtimer = this->timer >> 1; - this->timer = 0; + super->subtimer = super->timer >> 1; + super->timer = 0; - this->frameIndex = this->type2 & 0x3f; + super->frameIndex = super->type2 & 0x3f; - this->field_0x7c.HALF_U.HI = COORD_TO_TILE(this); - this->field_0x7c.HALF_U.LO = GetTileIndex(this->field_0x7c.HALF_U.HI, 1); + this->unk_7e = COORD_TO_TILE(super); + this->unk_7c = GetTileIndex(this->unk_7e, 1); - this->field_0x7a.HWORD = sub_080B1B44((u16)this->field_0x7c.HALF.HI, 1); + this->unk_7a = sub_080B1B44(this->unk_7e, 1); - SetTile(0x4022, this->field_0x7c.HALF_U.HI, 1); + SetTile(0x4022, this->unk_7e, 1); } // Probably related to knocking it down -void Mask_Action1(Entity* this) { +void Mask_Action1(MaskEntity* this) { // Check for the first frame of bonking animation if (gPlayerEntity.action != PLAYER_BOUNCE) { return; @@ -78,54 +90,54 @@ void Mask_Action1(Entity* this) { } // Check if link is close enough to the mask - if (this->y.HALF.HI + 40 < gPlayerEntity.y.HALF.HI) { + if (super->y.HALF.HI + 40 < gPlayerEntity.y.HALF.HI) { return; } - if (this->x.HALF.HI - gPlayerEntity.x.HALF.HI >= this->subtimer || - this->x.HALF.HI - gPlayerEntity.x.HALF.HI <= -this->subtimer) { + if (super->x.HALF.HI - gPlayerEntity.x.HALF.HI >= super->subtimer || + super->x.HALF.HI - gPlayerEntity.x.HALF.HI <= -super->subtimer) { return; } // Presumably, make the mask fall - SetTile(this->field_0x7c.HALF_U.LO, this->field_0x7c.HALF_U.HI, 1); + SetTile(this->unk_7c, this->unk_7e, 1); - sub_08000148(this->field_0x7a.HWORD, (u16)this->field_0x7c.HALF.HI, 1); + sub_08000148(this->unk_7a, this->unk_7e, 1); - this->action = 2; + super->action = 2; - this->z.HALF.HI -= 0x20; - this->y.HALF.HI += 0x20; + super->z.HALF.HI -= 0x20; + super->y.HALF.HI += 0x20; - this->spriteRendering.b3 = 2; + super->spriteRendering.b3 = 2; } // Probably falling down -void Mask_Action2(Entity* this) { - if (this->timer == 1) { - this->action = 3; +void Mask_Action2(MaskEntity* this) { + if (super->timer == 1) { + super->action = 3; - this->timer = 0; - switch (this->type2 & 0xC0) { + super->timer = 0; + switch (super->type2 & 0xC0) { case 0x80: EnqueueSFX(SFX_SECRET); case 0x40: - SetFlag(this->field_0x86.HWORD); + SetFlag(this->unk_86); break; } - CreateFx(this, FX_POT_SHATTER, 0); + CreateFx(super, FX_POT_SHATTER, 0); - CreateRandomItemDrop(this, 3); + CreateRandomItemDrop(super, 3); } else { - sub_080044EC(this, this->field_0x78.HWORD); + sub_080044EC(super, this->unk_78); - if (this->z.HALF.HI == 0) { - this->timer++; + if (super->z.HALF.HI == 0) { + super->timer++; } } } -void Mask_Delete(Entity* this) { +void Mask_Delete(MaskEntity* this) { DeleteThisEntity(); } diff --git a/src/object/mazaalBossObject.c b/src/object/mazaalBossObject.c index 75dbc35b..c65e7c02 100644 --- a/src/object/mazaalBossObject.c +++ b/src/object/mazaalBossObject.c @@ -8,7 +8,6 @@ #include "enemy.h" #include "entity.h" #include "functions.h" -#include "global.h" #include "item.h" #include "new_player.h" #include "object.h" @@ -49,14 +48,14 @@ void MazaalBossObject_Action8(MazaalBossObjectEntity* this); // 0809ACE8 void sub_0809AD68(MazaalBossObjectEntity* this); // 0809AD68 void sub_0809AD8C(MazaalBossObjectEntity* this); // 0809AD8C -void MazaalBossObject(Entity* thisx) { +void MazaalBossObject(Entity* this) { static void (*const MazaalBossObject_Actions[])(MazaalBossObjectEntity*) = { MazaalBossObject_Action0, MazaalBossObject_Action1, MazaalBossObject_Action2, MazaalBossObject_Action3, MazaalBossObject_Action4, MazaalBossObject_Action5, MazaalBossObject_Action6, MazaalBossObject_Action7, MazaalBossObject_Action8, }; - MazaalBossObject_Actions[thisx->action]((MazaalBossObjectEntity*)thisx); + MazaalBossObject_Actions[this->action]((MazaalBossObjectEntity*)this); } void MazaalBossObject_Action0(MazaalBossObjectEntity* this) { diff --git a/src/object/mazaalObject.c b/src/object/mazaalObject.c index c9de1bcd..68c76041 100644 --- a/src/object/mazaalObject.c +++ b/src/object/mazaalObject.c @@ -4,8 +4,8 @@ * * @brief Mazaal Object object */ +#define NENT_DEPRECATED #include "entity.h" -#include "global.h" #include "physics.h" void MazaalObject(Entity* this) { diff --git a/src/object/metalDoor.c b/src/object/metalDoor.c index f7236beb..0703a301 100644 --- a/src/object/metalDoor.c +++ b/src/object/metalDoor.c @@ -4,115 +4,128 @@ * * @brief Metal Door object */ +#define NENT_DEPRECATED #include "asm.h" #include "effects.h" #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "room.h" #include "sound.h" -extern u32 sub_08083734(Entity*, u32); -void sub_080A080C(Entity*); -void sub_080A0870(Entity*); -void MetalDoor_Init(Entity*); -void MetalDoor_Action1(Entity*); -void MetalDoor_Action2(Entity*); -void MetalDoor_Action3(Entity*); -void MetalDoor_Action4(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[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*/ u8 unused2[8]; + /*0x84*/ u16 unk_84; + /*0x86*/ u16 unk_86; +} MetalDoorEntity; -void MetalDoor(Entity* this) { - static void (*const MetalDoor_Actions[])(Entity*) = { +void sub_080A080C(MetalDoorEntity* this); +void sub_080A0870(MetalDoorEntity* this); +void MetalDoor_Init(MetalDoorEntity* this); +void MetalDoor_Action1(MetalDoorEntity* this); +void MetalDoor_Action2(MetalDoorEntity* this); +void MetalDoor_Action3(MetalDoorEntity* this); +void MetalDoor_Action4(MetalDoorEntity* this); + +void MetalDoor(MetalDoorEntity* this) { + static void (*const MetalDoor_Actions[])(MetalDoorEntity*) = { MetalDoor_Init, MetalDoor_Action1, MetalDoor_Action2, MetalDoor_Action3, MetalDoor_Action4, }; - MetalDoor_Actions[this->action](this); + MetalDoor_Actions[super->action](this); } -void MetalDoor_Init(Entity* this) { - if ((this->cutsceneBeh.HWORD != 0xffff) && CheckFlags(this->cutsceneBeh.HWORD)) { +void MetalDoor_Init(MetalDoorEntity* this) { + if ((this->unk_84 != 0xffff) && CheckFlags(this->unk_84)) { DeleteThisEntity(); } - this->action = 1; - this->speed = 0x300; - this->spriteSettings.draw = 0; - this->frameIndex = 0; - this->spriteSettings.flipY = 1; - 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; - this->field_0x74.HWORD = COORD_TO_TILE(this); + super->action = 1; + super->speed = 0x300; + super->spriteSettings.draw = 0; + super->frameIndex = 0; + super->spriteSettings.flipY = 1; + super->hitbox = (Hitbox*)&gHitbox_3; + super->spritePriority.b0 = 5; + this->unk_70 = super->x.HALF.HI; + this->unk_72 = super->y.HALF.HI; + this->unk_74 = COORD_TO_TILE(super); } -void MetalDoor_Action1(Entity* this) { - if (sub_08083734(this, 2) != 0) { - this->action = 2; - this->timer = 12; - this->spriteSettings.draw = TRUE; - this->direction = 0; - this->y.HALF.HI += 0x24; +void MetalDoor_Action1(MetalDoorEntity* this) { + if (sub_08083734(super, 2) != 0) { + super->action = 2; + super->timer = 12; + super->spriteSettings.draw = TRUE; + super->direction = 0; + super->y.HALF.HI += 0x24; sub_080A080C(this); } } -void MetalDoor_Action2(Entity* this) { +void MetalDoor_Action2(MetalDoorEntity* this) { u8 bVar1; - Entity* ent; + Entity* fx; - LinearMoveUpdate(this); + LinearMoveUpdate(super); - if (--this->timer == 0) { - this->action = 3; - this->z.HALF.HI = 0; - this->x.HALF.HI = this->field_0x70.HALF.LO; - this->y.HALF.HI = this->field_0x70.HALF.HI; - ent = CreateFx(this, FX_DASH, 0x40); - if (ent != NULL) { - ent->x.HALF.HI += 0xc; - ent->y.HALF.HI -= 0xc; + if (--super->timer == 0) { + super->action = 3; + super->z.HALF.HI = 0; + super->x.HALF.HI = this->unk_70; + super->y.HALF.HI = this->unk_72; + fx = CreateFx(super, FX_DASH, 0x40); + if (fx != NULL) { + fx->x.HALF.HI += 0xc; + fx->y.HALF.HI -= 0xc; } - ent = CreateFx(this, FX_DASH, 0x40); - if (ent != NULL) { - ent->x.HALF.HI -= 0xc; - ent->y.HALF.HI -= 0xc; + fx = CreateFx(super, FX_DASH, 0x40); + if (fx != NULL) { + fx->x.HALF.HI -= 0xc; + fx->y.HALF.HI -= 0xc; } EnqueueSFX(SFX_10B); } } -void MetalDoor_Action3(Entity* this) { - if (CheckFlags(this->field_0x86.HWORD)) { - this->action = 4; - this->timer = 12; - this->direction = 0x10; - this->y.HALF.HI += 2; +void MetalDoor_Action3(MetalDoorEntity* this) { + if (CheckFlags(this->unk_86)) { + super->action = 4; + super->timer = 12; + super->direction = 0x10; + super->y.HALF.HI += 2; sub_080A0870(this); SoundReq(SFX_10B); } } -void MetalDoor_Action4(Entity* this) { +void MetalDoor_Action4(MetalDoorEntity* this) { - LinearMoveUpdate(this); + LinearMoveUpdate(super); - if (--this->timer == 0) { + if (--super->timer == 0) { DeleteThisEntity(); } } -void sub_080A080C(Entity* this) { - this->field_0x76.HWORD = GetTileIndex(this->field_0x74.HWORD - 1, this->collisionLayer); - this->field_0x78.HWORD = GetTileIndex(this->field_0x74.HWORD, this->collisionLayer); - this->field_0x7a.HWORD = GetTileIndex(this->field_0x74.HWORD + 1, this->collisionLayer); - SetTile(0x4022, this->field_0x74.HWORD - 1, this->collisionLayer); - SetTile(0x4022, this->field_0x74.HWORD, this->collisionLayer); - SetTile(0x4022, this->field_0x74.HWORD + 1, this->collisionLayer); +void sub_080A080C(MetalDoorEntity* this) { + this->unk_76 = GetTileIndex(this->unk_74 - 1, super->collisionLayer); + this->unk_78 = GetTileIndex(this->unk_74, super->collisionLayer); + this->unk_7a = 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); } -void sub_080A0870(Entity* this) { - SetTile(this->field_0x76.HWORD, this->field_0x74.HWORD - 1, this->collisionLayer); - SetTile(this->field_0x78.HWORD, this->field_0x74.HWORD, this->collisionLayer); - SetTile(this->field_0x7a.HWORD, this->field_0x74.HWORD + 1, this->collisionLayer); +void sub_080A0870(MetalDoorEntity* this) { + SetTile(this->unk_76, this->unk_74 - 1, super->collisionLayer); + SetTile(this->unk_78, this->unk_74, super->collisionLayer); + SetTile(this->unk_7a, this->unk_74 + 1, super->collisionLayer); } diff --git a/src/object/minecart.c b/src/object/minecart.c index 3a4c434e..ffdef749 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -17,15 +17,15 @@ typedef struct { extern void sub_08017744(Entity*); -u32 sub_08091DDC(MinecartEntity*); -void Minecart_Init(MinecartEntity*); -void Minecart_Action1(MinecartEntity*); -void Minecart_Action2(MinecartEntity*); -void Minecart_Action3(MinecartEntity*); -void Minecart_Action4(MinecartEntity*); -void Minecart_Action5(MinecartEntity*); -void Minecart_Action6(MinecartEntity*); -void Minecart_Action7(MinecartEntity*); +u32 sub_08091DDC(MinecartEntity* this); +void Minecart_Init(MinecartEntity* this); +void Minecart_Action1(MinecartEntity* this); +void Minecart_Action2(MinecartEntity* this); +void Minecart_Action3(MinecartEntity* this); +void Minecart_Action4(MinecartEntity* this); +void Minecart_Action5(MinecartEntity* this); +void Minecart_Action6(MinecartEntity* this); +void Minecart_Action7(MinecartEntity* this); extern const u16* const gUnk_081223D8[]; diff --git a/src/object/minecartDoor.c b/src/object/minecartDoor.c index edb60f48..a6746467 100644 --- a/src/object/minecartDoor.c +++ b/src/object/minecartDoor.c @@ -4,10 +4,8 @@ * * @brief Minecart Door object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/mineralWaterSource.c b/src/object/mineralWaterSource.c index 2fca29e6..56667b11 100644 --- a/src/object/mineralWaterSource.c +++ b/src/object/mineralWaterSource.c @@ -4,6 +4,7 @@ * * @brief Mineral Water Source object */ +#define NENT_DEPRECATED #include "object.h" void MineralWaterSource_Init(Entity*); @@ -17,11 +18,11 @@ typedef struct { } UnkStruct_MineralWater; void MineralWaterSource(Entity* this) { - static void (*const MineralWaterSourceActionFuncs[])(Entity*) = { + static void (*const MineralWaterSource_Actions[])(Entity*) = { MineralWaterSource_Init, MineralWaterSource_Action1, }; - MineralWaterSourceActionFuncs[this->action](this); + MineralWaterSource_Actions[this->action](this); } void MineralWaterSource_Init(Entity* this) { diff --git a/src/object/minishEmoticon.c b/src/object/minishEmoticon.c index 0904b1cb..279c66e4 100644 --- a/src/object/minishEmoticon.c +++ b/src/object/minishEmoticon.c @@ -4,6 +4,7 @@ * * @brief Minish Emoticon object */ +#define NENT_DEPRECATED #include "entity.h" #include "functions.h" diff --git a/src/object/minishLight.c b/src/object/minishLight.c index 382056ee..36569b66 100644 --- a/src/object/minishLight.c +++ b/src/object/minishLight.c @@ -4,6 +4,7 @@ * * @brief Minish Light object */ +#define NENT_DEPRECATED #include "entity.h" void MinishLight_Init(Entity*); diff --git a/src/object/minishPortalCloseup.c b/src/object/minishPortalCloseup.c index f0e3c8c4..e683e3bc 100644 --- a/src/object/minishPortalCloseup.c +++ b/src/object/minishPortalCloseup.c @@ -4,11 +4,9 @@ * * @brief Minish Portal Closeup object */ - #define NENT_DEPRECATED #include "area.h" #include "functions.h" -#include "global.h" #include "main.h" #include "object.h" #include "screen.h" diff --git a/src/object/minishPortalStone.c b/src/object/minishPortalStone.c index e038c31f..5dc4bfcf 100644 --- a/src/object/minishPortalStone.c +++ b/src/object/minishPortalStone.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" #include "screen.h" @@ -16,14 +15,14 @@ typedef struct { /*0x86*/ u16 unk_86; } MinishPortalStoneEntity; -void MinishPortalStone_Init(MinishPortalStoneEntity*); -void MinishPortalStone_Action1(MinishPortalStoneEntity*); -void MinishPortalStone_Action2(MinishPortalStoneEntity*); -void MinishPortalStone_Action3(MinishPortalStoneEntity*); -void MinishPortalStone_Action4(MinishPortalStoneEntity*); -void sub_08097CFC(MinishPortalStoneEntity*); -bool32 sub_08097CB0(MinishPortalStoneEntity*); -void sub_08097CB4(MinishPortalStoneEntity*); +void MinishPortalStone_Init(MinishPortalStoneEntity* this); +void MinishPortalStone_Action1(MinishPortalStoneEntity* this); +void MinishPortalStone_Action2(MinishPortalStoneEntity* this); +void MinishPortalStone_Action3(MinishPortalStoneEntity* this); +void MinishPortalStone_Action4(MinishPortalStoneEntity* this); +void sub_08097CFC(MinishPortalStoneEntity* this); +bool32 sub_08097CB0(MinishPortalStoneEntity* this); +void sub_08097CB4(MinishPortalStoneEntity* this); const Hitbox gUnk_08123328 = { 0, 0, { 4, 0, 0, 4 }, 18, 18 }; diff --git a/src/object/minishSizedArchway.c b/src/object/minishSizedArchway.c index 01a81cfc..e92e6fef 100644 --- a/src/object/minishSizedArchway.c +++ b/src/object/minishSizedArchway.c @@ -4,6 +4,7 @@ * * @brief Minish Sized Archway object */ +#define NENT_DEPRECATED #include "entity.h" #include "game.h" diff --git a/src/object/minishSizedEntrance.c b/src/object/minishSizedEntrance.c index c12192c2..d63eba55 100644 --- a/src/object/minishSizedEntrance.c +++ b/src/object/minishSizedEntrance.c @@ -4,6 +4,7 @@ * * @brief MinishSizedEntrance object */ +#define NENT_DEPRECATED #include "functions.h" #include "game.h" #include "object.h" diff --git a/src/object/minishVillageObject.c b/src/object/minishVillageObject.c index 417c3f99..7abd4675 100644 --- a/src/object/minishVillageObject.c +++ b/src/object/minishVillageObject.c @@ -4,98 +4,92 @@ * * @brief Minish Village Object object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" #include "screen.h" -typedef struct { - /*0x00*/ Entity base; -} MinishVillageObjectEntity; +void MinishVillageObject_Type0(Entity*); +void MinishVillageObject_Type1(Entity*); +void MinishVillageObject_Type3(Entity*); +void MinishVillageObject_Type4(Entity*); +void MinishVillageObject_Type5(Entity*); +void MinishVillageObject_Type6(Entity*); +void MinishVillageObject_Type7(Entity*); +void MinishVillageObject_Type8(Entity*); +void MinishVillageObject_Type8_Init(Entity*); +void MinishVillageObject_Type8_Action1(Entity*); +void MinishVillageObject_Type8_Action2(Entity*); -void MinishVillageObject_Type0(MinishVillageObjectEntity*); -void MinishVillageObject_Type1(MinishVillageObjectEntity*); -void MinishVillageObject_Type3(MinishVillageObjectEntity*); -void MinishVillageObject_Type4(MinishVillageObjectEntity*); -void MinishVillageObject_Type5(MinishVillageObjectEntity*); -void MinishVillageObject_Type6(MinishVillageObjectEntity*); -void MinishVillageObject_Type7(MinishVillageObjectEntity*); -void MinishVillageObject_Type8(MinishVillageObjectEntity*); -void MinishVillageObject_Type8_Init(MinishVillageObjectEntity*); -void MinishVillageObject_Type8_Action1(MinishVillageObjectEntity*); -void MinishVillageObject_Type8_Action2(MinishVillageObjectEntity*); - -void MinishVillageObject(MinishVillageObjectEntity* this) { - static void (*const MinishVillageObject_Types[])(MinishVillageObjectEntity*) = { +void MinishVillageObject(Entity* this) { + static void (*const MinishVillageObject_Types[])(Entity*) = { MinishVillageObject_Type0, MinishVillageObject_Type1, MinishVillageObject_Type1, MinishVillageObject_Type3, MinishVillageObject_Type4, MinishVillageObject_Type5, MinishVillageObject_Type6, MinishVillageObject_Type7, MinishVillageObject_Type8, MinishVillageObject_Type1, }; - MinishVillageObject_Types[super->type](this); + MinishVillageObject_Types[this->type](this); } -void MinishVillageObject_Type0(MinishVillageObjectEntity* this) { +void MinishVillageObject_Type0(Entity* this) { u32 tmp; u32 tmp2; - switch (super->action) { + switch (this->action) { case 0: - super->action = 1; - super->timer = 64 - (Random() & 0x1F); - super->frameIndex = 0; - super->animationState = 0; - super->spriteRendering.b3 = 3; - super->spritePriority.b0 = 7; - super->collisionLayer = 1; + this->action = 1; + this->timer = 64 - (Random() & 0x1F); + this->frameIndex = 0; + this->animationState = 0; + this->spriteRendering.b3 = 3; + this->spritePriority.b0 = 7; + this->collisionLayer = 1; break; case 1: - if (--super->timer == 0) { - super->timer = 8; - super->subtimer = 4; - super->action = 2; - super->animationState = Random() & 3; + if (--this->timer == 0) { + this->timer = 8; + this->subtimer = 4; + this->action = 2; + this->animationState = Random() & 3; } break; case 2: - if (--super->timer == 0) { - if (--super->subtimer == 0) { - super->frameIndex = 0; - super->action = 1; - super->timer = 64 - (Random() & 0x1F); + if (--this->timer == 0) { + if (--this->subtimer == 0) { + this->frameIndex = 0; + this->action = 1; + this->timer = 64 - (Random() & 0x1F); } else { - super->timer = 8; - tmp2 = super->animationState; - if (super->frameIndex != tmp2) { + this->timer = 8; + tmp2 = this->animationState; + if (this->frameIndex != tmp2) { tmp = tmp2; } else { tmp = 0; } - super->frameIndex = tmp; + this->frameIndex = tmp; } } break; } } -void MinishVillageObject_Type1(MinishVillageObjectEntity* this) { +void MinishVillageObject_Type1(Entity* this) { static const u16 gUnk_08121704[] = { 0x12d, 0x12e, 0x12f, 0x130, 0x131, 0x132, 0x133, 0x132, 0x131, 0x130, 0x12f, 0x12e, 0x12d, 0, }; - switch (super->action) { + switch (this->action) { case 0: - super->action = 1; - super->timer = 8; - super->subtimer = 0; - super->frameIndex = 0; - super->spritePriority.b0 = 7; - SetTile(0x4069, COORD_TO_TILE(super) - 0x40, 1); + this->action = 1; + this->timer = 8; + this->subtimer = 0; + this->frameIndex = 0; + this->spritePriority.b0 = 7; + SetTile(0x4069, COORD_TO_TILE(this) - 0x40, 1); break; case 2: if ((gRoomTransition.frameCount & 3U) == 0) { - gScreen.controls.alphaBlend = (super->subAction << 8) | (0x10 - super->subAction); - super->subAction++; + gScreen.controls.alphaBlend = (this->subAction << 8) | (0x10 - this->subAction); + this->subAction++; if (gScreen.controls.alphaBlend == 0x1000) { gScreen.controls.layerFXControl = 0; DeleteThisEntity(); @@ -105,14 +99,14 @@ void MinishVillageObject_Type1(MinishVillageObjectEntity* this) { case 1: break; } - if (--super->timer == 0) { - super->timer = 8; - if (super->type == 9) { - super->timer = 2; + if (--this->timer == 0) { + this->timer = 8; + if (this->type == 9) { + this->timer = 2; } - ChangeObjPalette(super, gUnk_08121704[super->subtimer++]); - if (gUnk_08121704[super->subtimer] == 0) { - super->subtimer = 0; + ChangeObjPalette(this, gUnk_08121704[this->subtimer++]); + if (gUnk_08121704[this->subtimer] == 0) { + this->subtimer = 0; } } } @@ -137,120 +131,120 @@ void sub_0808D2CC(void) { } } -void MinishVillageObject_Type3(MinishVillageObjectEntity* this) { +void MinishVillageObject_Type3(Entity* this) { } -void MinishVillageObject_Type4(MinishVillageObjectEntity* this) { +void MinishVillageObject_Type4(Entity* this) { s32 tmp; - if (super->action == 0) { - super->action = 0; - super->frameIndex = 0; - super->spritePriority.b0 = 7; - sub_0807DD64(super); + if (this->action == 0) { + this->action = 0; + this->frameIndex = 0; + this->spritePriority.b0 = 7; + sub_0807DD64(this); } - tmp = super->x.HALF.HI; - ExecuteScriptForEntity(super, NULL); - HandleEntity0x82Actions(super); - if (((gRoomControls.shake_duration != 0) && (tmp != super->x.HALF.HI)) && ((gRoomTransition.frameCount & 8) == 0)) { + tmp = this->x.HALF.HI; + ExecuteScriptForEntity(this, NULL); + HandleEntity0x82Actions(this); + if (((gRoomControls.shake_duration != 0) && (tmp != this->x.HALF.HI)) && ((gRoomTransition.frameCount & 8) == 0)) { SoundReq(SFX_10F); } } -void MinishVillageObject_Type5(MinishVillageObjectEntity* this) { - if (super->action == 0) { - super->action = 0; - super->frameIndex = 1; - super->spritePriority.b0 = 7; - sub_0807DD64(super); +void MinishVillageObject_Type5(Entity* this) { + if (this->action == 0) { + this->action = 0; + this->frameIndex = 1; + this->spritePriority.b0 = 7; + sub_0807DD64(this); } - ExecuteScriptForEntity(super, NULL); - HandleEntity0x82Actions(super); + ExecuteScriptForEntity(this, NULL); + HandleEntity0x82Actions(this); } -void MinishVillageObject_Type6(MinishVillageObjectEntity* this) { +void MinishVillageObject_Type6(Entity* this) { static const u16 gUnk_08121720[] = { 0x149, 0x14a, 0x14b, 0x14a, 0, 0 }; - if (super->action == 0) { - super->action = 1; - super->timer = 8; - super->spritePriority.b0 = 7; + if (this->action == 0) { + this->action = 1; + this->timer = 8; + this->spritePriority.b0 = 7; gScreen.controls.layerFXControl = 0x640; gScreen.controls.alphaBlend = 0x1003; } - if (--super->timer == 0) { - super->timer = 2; - sub_0801D28C(super, gUnk_08121720[super->subtimer++]); - if (gUnk_08121720[super->subtimer] == 0) { - super->subtimer = 0; + if (--this->timer == 0) { + this->timer = 2; + sub_0801D28C(this, gUnk_08121720[this->subtimer++]); + if (gUnk_08121720[this->subtimer] == 0) { + this->subtimer = 0; } } } -void MinishVillageObject_Type7(MinishVillageObjectEntity* this) { - if (super->action == 0) { - super->action = 1; - super->spriteRendering.b3 = 3; - super->spritePriority.b0 = 7; - super->spriteRendering.alphaBlend = 1; - super->frameIndex = super->type2; - SetAffineInfo(super, (1 - super->type2) * 0x200 + 0x100, 0xffffff40, 0); +void MinishVillageObject_Type7(Entity* this) { + if (this->action == 0) { + this->action = 1; + this->spriteRendering.b3 = 3; + this->spritePriority.b0 = 7; + this->spriteRendering.alphaBlend = 1; + this->frameIndex = this->type2; + SetAffineInfo(this, (1 - this->type2) * 0x200 + 0x100, 0xffffff40, 0); } } -void MinishVillageObject_Type8(MinishVillageObjectEntity* this) { - static void (*const MinishVillageObject_Type8_Actions[])(MinishVillageObjectEntity*) = { +void MinishVillageObject_Type8(Entity* this) { + static void (*const MinishVillageObject_Type8_Actions[])(Entity*) = { MinishVillageObject_Type8_Init, MinishVillageObject_Type8_Action1, MinishVillageObject_Type8_Action2, }; - MinishVillageObject_Type8_Actions[super->action](this); + MinishVillageObject_Type8_Actions[this->action](this); } -void MinishVillageObject_Type8_Init(MinishVillageObjectEntity* this) { +void MinishVillageObject_Type8_Init(Entity* 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->timer = 0; - super->spriteRendering.alphaBlend = 1; + this->spritePriority.b0 = 7; + this->frameIndex = this->type2; + this->action = 2; + if ((this->type2 == 0) && (CheckLocalFlag(0x7c) == 0)) { + this->action = 1; + this->timer = 0; + this->spriteRendering.alphaBlend = 1; gScreen.controls.layerFXControl = 0x640; gScreen.controls.alphaBlend = 0x1000; SoundReq(SFX_179); } else { - super->timer = 8; - tilePosition = COORD_TO_TILE(super); - if (super->type2 != 0) { + this->timer = 8; + tilePosition = COORD_TO_TILE(this); + if (this->type2 != 0) { tilePosition -= 0x40; } - SetTile(0x4069, tilePosition, super->collisionLayer); + SetTile(0x4069, tilePosition, this->collisionLayer); } } -void MinishVillageObject_Type8_Action1(MinishVillageObjectEntity* this) { +void MinishVillageObject_Type8_Action1(Entity* this) { if ((gRoomTransition.frameCount & 3U) == 0) { - gScreen.controls.alphaBlend = ((0x10 - super->timer) * 0x100) | super->timer; - super->timer++; + gScreen.controls.alphaBlend = ((0x10 - this->timer) * 0x100) | this->timer; + this->timer++; if (gScreen.controls.alphaBlend == 0x10) { - super->action = 2; - super->timer = 8; - super->spriteRendering.alphaBlend = 0; + this->action = 2; + this->timer = 8; + this->spriteRendering.alphaBlend = 0; gScreen.controls.layerFXControl = 0; - SetTile(0x4069, COORD_TO_TILE(super), super->collisionLayer); + SetTile(0x4069, COORD_TO_TILE(this), this->collisionLayer); } } } -void MinishVillageObject_Type8_Action2(MinishVillageObjectEntity* this) { +void MinishVillageObject_Type8_Action2(Entity* this) { static const u16 gUnk_08121738[] = { 0x14c, 0x14d, 0x14e, 0x14f, 0x150, 0x151, 0x150, 0x14f, 0x14e, 0x14d, 0x14c, 0, }; - if (--super->timer == 0) { - super->timer = 8; - ChangeObjPalette(super, gUnk_08121738[super->subtimer++]); - if (gUnk_08121738[super->subtimer] == 0) { - super->subtimer = 0; + if (--this->timer == 0) { + this->timer = 8; + ChangeObjPalette(this, gUnk_08121738[this->subtimer++]); + if (gUnk_08121738[this->subtimer] == 0) { + this->subtimer = 0; } } } diff --git a/src/object/moleMittsParticle.c b/src/object/moleMittsParticle.c index 69dcfcd4..15b19439 100644 --- a/src/object/moleMittsParticle.c +++ b/src/object/moleMittsParticle.c @@ -7,7 +7,6 @@ #define NENT_DEPRECATED #include "area.h" #include "functions.h" -#include "global.h" #include "object.h" void MoleMittsParticle_Init(Entity*); diff --git a/src/object/object1D.c b/src/object/object1D.c index 0635d64c..4252f9b0 100644 --- a/src/object/object1D.c +++ b/src/object/object1D.c @@ -4,6 +4,7 @@ * * @brief Object1D object */ +#define NENT_DEPRECATED #include "entity.h" void Object1D_Init(Entity*); diff --git a/src/object/object30.c b/src/object/object30.c index 196a3bc4..fdda1933 100644 --- a/src/object/object30.c +++ b/src/object/object30.c @@ -4,11 +4,9 @@ * * @brief Object30 object */ - #define NENT_DEPRECATED #include "collision.h" #include "functions.h" -#include "global.h" #include "item.h" #include "object.h" diff --git a/src/object/object70.c b/src/object/object70.c index 064f6808..8cc5a576 100644 --- a/src/object/object70.c +++ b/src/object/object70.c @@ -4,11 +4,9 @@ * * @brief Object70 object */ - #define NENT_DEPRECATED -#include "global.h" -#include "object.h" #include "functions.h" +#include "object.h" void Object70_Init(Entity*); void Object70_Action1(Entity*); diff --git a/src/object/objectA.c b/src/object/objectA.c index 77622f1f..1648250b 100644 --- a/src/object/objectA.c +++ b/src/object/objectA.c @@ -4,42 +4,50 @@ * * @brief ObjectA object */ +#define NENT_DEPRECATED #include "entity.h" #include "flags.h" #include "functions.h" #include "game.h" -#include "global.h" #include "hitbox.h" #include "object.h" #include "room.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[8]; + /*0x70*/ u16 unk_70; + /*0x72*/ u8 unused2[20]; + /*0x86*/ u16 unk_86; +} ObjectAEntity; + extern u8 gUpdateVisibleTiles; -void ObjectA(Entity* this) { +void ObjectA(ObjectAEntity* this) { u32 uVar2; - if (this->action == 0) { - this->action = 1; - this->hitbox = (Hitbox*)&gHitbox_2; - if (this->collisionLayer == 1) { + if (super->action == 0) { + super->action = 1; + super->hitbox = (Hitbox*)&gHitbox_2; + if (super->collisionLayer == 1) { uVar2 = 0x26; } else { uVar2 = 0x34; } - this->field_0x70.HALF.LO = uVar2; - if (CheckFlags(this->field_0x86.HWORD) != 0) { - SetTileType(*(u16*)&this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); + this->unk_70 = uVar2; + if (CheckFlags(this->unk_86) != 0) { + SetTileType(this->unk_70, COORD_TO_TILE(super), super->collisionLayer); if ((gRoomControls.reload_flags & 1) != 0) { gUpdateVisibleTiles = 0; } DeleteThisEntity(); } else { - AddInteractableSmallKeyLock(this); + AddInteractableSmallKeyLock(super); } - } else if (this->interactType != 0) { - SetTileType(*(u16*)&this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); - SetFlag(this->field_0x86.HWORD); - CreateDust(this); + } else if (super->interactType != 0) { + SetTileType(this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + SetFlag(this->unk_86); + CreateDust(super); ModDungeonKeys(-1); DeleteThisEntity(); } diff --git a/src/object/objectA2.c b/src/object/objectA2.c index 5618ebd2..1dedecaf 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -4,6 +4,7 @@ * * @brief Object A2 object */ +#define NENT_DEPRECATED #include "functions.h" #include "menu.h" #include "object.h" diff --git a/src/object/objectA8.c b/src/object/objectA8.c index fcaf3966..dca5a903 100644 --- a/src/object/objectA8.c +++ b/src/object/objectA8.c @@ -4,11 +4,9 @@ * * @brief ObjectA8 object */ - #define NENT_DEPRECATED #include "collision.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "item.h" #include "object.h" @@ -35,6 +33,8 @@ void ObjectA8_Action2Subaction0(ObjectA8Entity*); void ObjectA8_Action2Subaction1(ObjectA8Entity*); void ObjectA8_Action2Subaction2(ObjectA8Entity*); +extern void sub_08081404(Entity*, u32); + void ObjectA8(ObjectA8Entity* this) { static void (*const ObjectA8_Actions[])(ObjectA8Entity*) = { ObjectA8_Init, ObjectA8_Action1, ObjectA8_Action2, ObjectA8_Action3, diff --git a/src/object/objectBF.c b/src/object/objectBF.c index a66a2b61..0c884d18 100644 --- a/src/object/objectBF.c +++ b/src/object/objectBF.c @@ -4,6 +4,7 @@ * * @brief Object BF object */ +#define NENT_DEPRECATED #include "entity.h" void ObjectBF(Entity* this) { diff --git a/src/object/objectBlockingStairs.c b/src/object/objectBlockingStairs.c index 5473531d..18234b59 100644 --- a/src/object/objectBlockingStairs.c +++ b/src/object/objectBlockingStairs.c @@ -39,16 +39,15 @@ u32 sub_080932D8(u32); void sub_080931A4(ObjectBlockingStairsEntity*, u32); void ObjectBlockingStairs(Entity* this) { - static void (*const actionFuncs[])(ObjectBlockingStairsEntity*) = { + static void (*const ObjectBlockingStairs_Actions[])(ObjectBlockingStairsEntity*) = { ObjectBlockingStairs_Init, ObjectBlockingStairs_Action1, ObjectBlockingStairs_Action2, ObjectBlockingStairs_Action3, ObjectBlockingStairs_Action4, }; - actionFuncs[this->action]((ObjectBlockingStairsEntity*)this); + ObjectBlockingStairs_Actions[this->action]((ObjectBlockingStairsEntity*)this); } void ObjectBlockingStairs_Init(ObjectBlockingStairsEntity* this) { - int iVar1; u32 uVar2; switch (sub_080932D8(super->type)) { diff --git a/src/object/objectOnPillar.c b/src/object/objectOnPillar.c index 5b617169..6f3381dc 100644 --- a/src/object/objectOnPillar.c +++ b/src/object/objectOnPillar.c @@ -4,10 +4,8 @@ * * @brief Object on Pillar object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" diff --git a/src/object/objectOnSpinyBeetle.c b/src/object/objectOnSpinyBeetle.c index 2bccf348..8c6beccf 100644 --- a/src/object/objectOnSpinyBeetle.c +++ b/src/object/objectOnSpinyBeetle.c @@ -4,10 +4,8 @@ * * @brief Object on Spiny Beetle object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index 22e3561e..4619d170 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -4,25 +4,18 @@ * * @brief Octorok Boss Object object */ +#define NENT_DEPRECATED #include "functions.h" #include "game.h" #include "object.h" -extern void (*const OctorokBossObject_Actions[])(Entity*); -extern const u16 gUnk_0812384C[]; -extern const u16 gUnk_0812388C[]; -extern const u16 gUnk_081238A0[]; - -bool32 sub_0809A6F8(u32, u32, u32, u32); -bool32 sub_0809A758(u32, u32); - typedef struct HelperStruct { - u8 field_0x0; // [0,1,2,4] is later stored in this->subtimer + u8 field_0x0; // [0,1,2,4] is later stored in super->subtimer u8 tailCount; u8 field_0x2; // [0,1] - u8 field_0x3; // relates to this->field_0x7a.HALF.HI + u8 field_0x3; // relates to super->field_0x7a.HALF.HI u8 field_0x4; // [0,1,0xff] - u8 field_0x5; // [0-4], sets this->field_0x80.HALF.HI + u8 field_0x5; // [0-4], sets super->field_0x80.HALF.HI u8 fallingStonesTimer; u8 field_0x7; // some sort of counter that is only set when hit for the first time? Entity* mouthObject; @@ -30,9 +23,29 @@ typedef struct HelperStruct { Entity* legObjects[4]; } HelperStruct; +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[12]; + /*0x74*/ u16 unk_74; + /*0x76*/ u16 unk_76; + /*0x78*/ union SplitWord unk_78; + /*0x7c*/ union SplitWord unk_7c; + /*0x80*/ u16 unk_80; + /*0x82*/ u16 unk_82; + /*0x84*/ HelperStruct* helper; +} OctorokBossObjectEntity; + +extern void (*const OctorokBossObject_Actions[])(OctorokBossObjectEntity*); +extern const u16 gUnk_0812384C[]; +extern const u16 gUnk_0812388C[]; +extern const u16 gUnk_081238A0[]; + +bool32 sub_0809A6F8(u32, u32, u32, u32); +bool32 sub_0809A758(u32, u32); + enum OctorokBossObjectType { TYPE0, // OctorokBoss_Action1 / TAIL_END - TYPE_FIRE, // this->OctorokBossObject_Action1 + TYPE_FIRE, // super->OctorokBossObject_Action1 TYPE_SUCKING, // OctorokBoss_ExecuteAttackVacuum TYPE_SMOKE, // OctorokBoss_ExecuteAttackSmoke TYPE4, // OctorokBoss_Action1_Attack_Type2_2 @@ -42,164 +55,162 @@ enum OctorokBossObjectType { TYPE8, // OctorokBoss_Hit_SubAction1 TYPE9 // OctorokBoss_Hit_SubAction4 }; -#define GET_HELPER(this) (*(HelperStruct**)&(this)->cutsceneBeh) -void OctorokBossObject(Entity* this) { - OctorokBossObject_Actions[this->action](this); +void OctorokBossObject(OctorokBossObjectEntity* this) { + OctorokBossObject_Actions[super->action](this); } -void OctorokBossObject_Init(Entity* this) { - this->action = 1; - this->speed = 0x200; - switch (this->type) { +void OctorokBossObject_Init(OctorokBossObjectEntity* this) { + super->action = 1; + super->speed = 0x200; + switch (super->type) { case 0: - this->field_0x78.HALF.HI = 0x96; - this->timer = 0; - this->subtimer = 30; + this->unk_78.BYTES.byte1 = 0x96; + super->timer = 0; + super->subtimer = 30; case 1: - InitializeAnimation(this, 0); + InitializeAnimation(super, 0); EnqueueSFX(SFX_124); break; case 2: - this->direction = -(this->parent->field_0x7a.HALF.HI + -0x80); + super->direction = -(((OctorokBossObjectEntity*)super->parent)->unk_78.BYTES.byte3 + -0x80); if ((Random() & 1) != 0) { switch (Random() & 3) { case 0: - this->direction = this->direction - 0x10; + super->direction = super->direction - 0x10; break; case 1: - this->direction = this->direction + 0x10; + super->direction = super->direction + 0x10; break; case 2: - this->direction = this->direction - 8; + super->direction = super->direction - 8; break; case 3: - this->direction = this->direction + 8; + super->direction = super->direction + 8; break; } } - this->speed = DISPLAY_WIDTH - (Random() & 0x3f); - LinearMoveAngle(this, ((s16)this->speed >> 1) << 8, (u32)this->direction); - LinearMoveAngle(this, ((s16)this->speed >> 1) << 8, (u32)this->direction); - InitializeAnimation(this, 5); + super->speed = DISPLAY_WIDTH - (Random() & 0x3f); + LinearMoveAngle(super, ((s16)super->speed >> 1) << 8, (u32)super->direction); + LinearMoveAngle(super, ((s16)super->speed >> 1) << 8, (u32)super->direction); + InitializeAnimation(super, 5); SoundReq(SFX_14C); break; case 3: - this->direction = -(this->parent->field_0x7a.HALF.HI + -0x80); - LinearMoveAngle(this, 0x4800, (u32)this->direction); + super->direction = -(((OctorokBossObjectEntity*)super->parent)->unk_78.BYTES.byte3 + -0x80); + LinearMoveAngle(super, 0x4800, (u32)super->direction); if ((Random() & 1) != 0) { - this->direction = (Random() & 0x3f) + this->direction; + super->direction = (Random() & 0x3f) + super->direction; } else { - this->direction = this->direction - (Random() & 0x3f); + super->direction = super->direction - (Random() & 0x3f); } - InitializeAnimation(this, 6); + InitializeAnimation(super, 6); break; case 6: - LinearMoveAngle(this, (0x30 - (Random() & 0x2f)) * 0x100, Random() & 0xff); + LinearMoveAngle(super, (0x30 - (Random() & 0x2f)) * 0x100, Random() & 0xff); if ((Random() & 1) != 0) { - this->direction = (Random() & 0x3f) + this->direction; + super->direction = (Random() & 0x3f) + super->direction; } else { - this->direction = this->direction - (Random() & 0x3f); + super->direction = super->direction - (Random() & 0x3f); } - InitializeAnimation(this, 5); + InitializeAnimation(super, 5); break; case 4: - *(u32*)&this->field_0x78 = 0x30c; + this->unk_78.WORD = 0x30c; break; case 5: - this->spritePriority.b0 = 0; - *(u32*)&this->field_0x78 = 0x18; - this->field_0x76.HWORD = 0x400; - this->field_0x74.HWORD = 0x400; - this->field_0x7a.HWORD = 0; - LinearMoveAngle(this, - ((-(u32)this->parent->field_0x7a.HALF.HI << 0x18) >> 0x18) + - (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1], - (u32)gUnk_0812388C[(u32)this->type2 * 2]); - SetAffineInfo(this, this->field_0x76.HWORD, this->field_0x74.HWORD, this->field_0x7a.HWORD); - InitializeAnimation(this, 7); + super->spritePriority.b0 = 0; + this->unk_78.WORD = 0x18; + this->unk_76 = 0x400; + this->unk_74 = 0x400; + this->unk_78.HALF_U.HI = 0; + LinearMoveAngle(super, + ((-(u32)((OctorokBossObjectEntity*)super->parent)->unk_78.BYTES.byte3 << 0x18) >> 0x18) + + (u32)gUnk_0812388C[(u32)super->type2 * 2 + 1], + (u32)gUnk_0812388C[(u32)super->type2 * 2]); + SetAffineInfo(super, this->unk_76, this->unk_74, this->unk_78.HALF_U.HI); + InitializeAnimation(super, 7); break; case 7: - this->timer = 0; - InitializeAnimation(this, 8); - CopyPosition(this->parent, this); + super->timer = 0; + InitializeAnimation(super, 8); + CopyPosition(super->parent, super); break; case 8: - this->type2 = this->parent->field_0x7c.BYTES.byte0; - this->timer = 4; - this->subtimer = 0; - this->field_0x82.HWORD = (this->x.HALF.HI - (gRoomControls.origin_x)) & 0x1f0; - this->field_0x80.HWORD = (this->y.HALF.HI - ((u32)gRoomControls.origin_y)) & 0x1f0; - *(int*)&this->cutsceneBeh = - ((s32)(this->field_0x82.HWORD - 0x10) >> 4) + (this->field_0x80.HWORD >> 4) * 0x1f; - sub_0809A6F8(this->field_0x82.HWORD, this->field_0x80.HWORD, *(int*)&this->cutsceneBeh, this->type2); - if ((this->parent->field_0x7c.BYTES.byte0 & 1) != 0) { + super->type2 = ((OctorokBossObjectEntity*)super->parent)->unk_7c.BYTES.byte0; + super->timer = 4; + super->subtimer = 0; + this->unk_82 = (super->x.HALF.HI - (gRoomControls.origin_x)) & 0x1f0; + this->unk_80 = (super->y.HALF.HI - ((u32)gRoomControls.origin_y)) & 0x1f0; + *(s32*)&this->helper = ((s32)(this->unk_82 - 0x10) >> 4) + (this->unk_80 >> 4) * 0x1f; + sub_0809A6F8(this->unk_82, this->unk_80, *(s32*)&this->helper, super->type2); + if ((((OctorokBossObjectEntity*)super->parent)->unk_7c.BYTES.byte0 & 1) != 0) { SoundReq(SFX_1A3); } else { SoundReq(SFX_WIND2); } break; case 9: - *(u32*)&this->field_0x78 = 0x1e0; + this->unk_78.WORD = 0x1e0; break; } } -void OctorokBossObject_Action1(Entity* this) { +void OctorokBossObject_Action1(OctorokBossObjectEntity* this) { s32 tmp_c; u32 loop_var; s32 t1, t2; - GetNextFrame(this); + GetNextFrame(super); - switch (this->type) { + switch (super->type) { case 0: - if (this->field_0x78.HALF.HI != 0) { - this->field_0x78.HALF.HI--; - if (this->subtimer-- == 0) { - this->subtimer = 5; - this->child = CreateObjectWithParent(this, OCTOROK_BOSS_OBJECT, 1, this->type2); - if (this->child != NULL) { - this->child->parent = this->parent; - GET_HELPER(this->child) = GET_HELPER(this); + if (this->unk_78.BYTES.byte1 != 0) { + this->unk_78.BYTES.byte1--; + if (super->subtimer-- == 0) { + super->subtimer = 5; + super->child = CreateObjectWithParent(super, OCTOROK_BOSS_OBJECT, 1, super->type2); + if (super->child != NULL) { + super->child->parent = super->parent; + ((OctorokBossObjectEntity*)super->child)->helper = this->helper; } - this->type2++; + super->type2++; } - CopyPosition(GET_HELPER(this)->tailObjects[0], this); + CopyPosition(this->helper->tailObjects[0], super); return; } case 1: - this->direction = sub_080045DA(GET_HELPER(this)->tailObjects[this->timer]->x.WORD - this->x.WORD, - GET_HELPER(this)->tailObjects[this->timer]->y.WORD - this->y.WORD); - LinearMoveAngle(this, this->speed, this->direction); - if (EntityInRectRadius(this, GET_HELPER(this)->tailObjects[this->timer], 2, 2) == 0) { + super->direction = sub_080045DA(this->helper->tailObjects[super->timer]->x.WORD - super->x.WORD, + this->helper->tailObjects[super->timer]->y.WORD - super->y.WORD); + LinearMoveAngle(super, super->speed, super->direction); + if (EntityInRectRadius(super, this->helper->tailObjects[super->timer], 2, 2) == 0) { return; } - if (this->type == 0) { - GET_HELPER(this)->tailObjects[this->timer]->spriteSettings.draw &= -2; + if (super->type == 0) { + this->helper->tailObjects[super->timer]->spriteSettings.draw &= -2; } - if ((u32)this->timer == GET_HELPER(this)->tailCount - 1) { - this->action = 2; - this->timer = 240; - this->direction = gUnk_0812384C[(u8)((this->type2 & 0xf) * 2)] + ((u8)Random() & 0xf); - this->speed = gUnk_0812384C[(this->type2 & 0xf) * 2 + 1] + ((u16)Random() & 0x1ff); - if (this->type != 0) { + if ((u32)super->timer == this->helper->tailCount - 1) { + super->action = 2; + super->timer = 240; + super->direction = gUnk_0812384C[(u8)((super->type2 & 0xf) * 2)] + ((u8)Random() & 0xf); + super->speed = gUnk_0812384C[(super->type2 & 0xf) * 2 + 1] + ((u16)Random() & 0x1ff); + if (super->type != 0) { return; } - this->parent->action = 4; - this->parent->subAction = 0; + super->parent->action = 4; + super->parent->subAction = 0; return; } - this->timer++; + super->timer++; return; case 2: - if (this->parent->type2 == 3) { - Entity* object = GET_HELPER(this->parent)->mouthObject; - this->direction = sub_080045DA(object->x.WORD - this->x.WORD, object->y.WORD - this->y.WORD); - LinearMoveAngle(this, 0x280, this->direction); - if (sub_0806FC80(this, this->parent, 0x48) == 0) { + if (super->parent->type2 == 3) { + Entity* object = ((OctorokBossObjectEntity*)super->parent)->helper->mouthObject; + super->direction = sub_080045DA(object->x.WORD - super->x.WORD, object->y.WORD - super->y.WORD); + LinearMoveAngle(super, 0x280, super->direction); + if (sub_0806FC80(super, super->parent, 0x48) == 0) { return; } } @@ -207,99 +218,98 @@ void OctorokBossObject_Action1(Entity* this) { break; case 3: case 6: - LinearMoveAngle(this, 0x80, this->direction); - if (this->frame != 0) { + LinearMoveAngle(super, 0x80, super->direction); + if (super->frame != 0) { DeleteThisEntity(); } break; case 4: - if (*(u32*)&this->field_0x78 == 0) { + if (this->unk_78.WORD == 0) { if ((s16)gRoomVars.lightLevel != 0x100) { ChangeLightLevel(8); return; } else { } } else { - if (this->parent->health == 0) { - this->subAction = 1; - *(u32*)&this->field_0x78 = 0; + if (super->parent->health == 0) { + super->subAction = 1; + this->unk_78.WORD = 0; return; } - if ((this->subAction == 0) && (this->parent->type2 != 0)) { + if ((super->subAction == 0) && (super->parent->type2 != 0)) { return; } - this->subAction = 1; - *(int*)&this->field_0x78 += -1; + super->subAction = 1; + this->unk_78.WORD--; return; } - GET_HELPER(this)->tailObjects[this->timer]->x = GET_HELPER(this)->tailObjects[this->timer]->x; + this->helper->tailObjects[super->timer]->x = this->helper->tailObjects[super->timer]->x; DeleteThisEntity(); break; case 5: - if (*(int*)&this->field_0x78 == 0) { - if (this->field_0x76.HWORD == 0x100) { - if ((*(u8*)&this->parent->field_0x7c & 1) != 0) { + if (this->unk_78.WORD == 0) { + if (this->unk_76 == 0x100) { + if ((((OctorokBossObjectEntity*)super->parent)->unk_7c.BYTES.byte0 & 1) != 0) { DeleteThisEntity(); } } else { - this->field_0x76.HWORD -= 0x20; - this->field_0x74.HWORD -= 0x20; + this->unk_76 -= 0x20; + this->unk_74 -= 0x20; } - SetAffineInfo(this, (u32)this->field_0x76.HWORD, (u32)(u16)this->field_0x74.HWORD, - (u32)(u16)this->field_0x7a.HWORD); + SetAffineInfo(super, (u32)this->unk_76, (u32)(u16)this->unk_74, (u32)(u16)this->unk_78.HALF_U.HI); } else { - (*(int*)&this->field_0x78)--; + (this->unk_78.WORD)--; } - CopyPosition(this->parent, this); - LinearMoveAngle(this, (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1], - ((u8) - this->parent->field_0x7a.HALF.HI & 0xff) + - (u32)gUnk_0812388C[(u32)this->type2 * 2]); + CopyPosition(super->parent, super); + LinearMoveAngle(super, (u32)gUnk_0812388C[(u32)super->type2 * 2 + 1], + ((u8) - ((OctorokBossObjectEntity*)super->parent)->unk_78.BYTES.byte3 & 0xff) + + (u32)gUnk_0812388C[(u32)super->type2 * 2]); return; case 7: - if (this->timer == 0) { - CopyPosition(this->parent, this); + if (super->timer == 0) { + CopyPosition(super->parent, super); return; } DeleteThisEntity(); break; case 8: - if (this->timer-- != 0) { + if (super->timer-- != 0) { return; } - this->timer = 4; - this->subtimer++; - t2 = t1 = (*(int*)&this->cutsceneBeh) - this->subtimer * 0x1f; - this->field_0x7c.HALF_U.HI = this->field_0x82.HWORD; - this->field_0x7a.HWORD = this->field_0x82.HWORD; - this->field_0x7c.HALF_U.LO = this->field_0x80.HWORD - this->subtimer * 0x10; - this->field_0x78.HWORD = this->field_0x7c.HALF.LO; - tmp_c = sub_0809A6F8(this->field_0x7a.HWORD, this->field_0x78.HWORD, t1, this->type2); - for (loop_var = this->subtimer; loop_var != 0; loop_var--) { - this->field_0x7a.HWORD -= 0x10; - this->field_0x78.HWORD += 0x10; + super->timer = 4; + super->subtimer++; + t2 = t1 = (*(s32*)&this->helper) - super->subtimer * 0x1f; + this->unk_7c.HALF_U.HI = this->unk_82; + this->unk_78.HALF_U.HI = this->unk_82; + this->unk_7c.HALF_U.LO = this->unk_80 - super->subtimer * 0x10; + this->unk_78.HALF_U.LO = this->unk_7c.HALF.LO; + tmp_c = sub_0809A6F8(this->unk_78.HALF_U.HI, this->unk_78.HALF_U.LO, t1, super->type2); + for (loop_var = super->subtimer; loop_var != 0; loop_var--) { + this->unk_78.HALF_U.HI -= 0x10; + this->unk_78.HALF_U.LO += 0x10; t1 += 0x1e; - tmp_c += sub_0809A6F8(this->field_0x7a.HWORD, this->field_0x78.HWORD, t1, this->type2); - this->field_0x7c.HALF.HI += 0x10; - this->field_0x7c.HALF.LO += 0x10; + tmp_c += sub_0809A6F8(this->unk_78.HALF_U.HI, this->unk_78.HALF_U.LO, t1, super->type2); + this->unk_7c.HALF.HI += 0x10; + this->unk_7c.HALF.LO += 0x10; t2 += 0x20; - tmp_c += sub_0809A6F8(this->field_0x7c.HALF_U.HI, this->field_0x7c.HALF_U.LO, t2, this->type2); + tmp_c += sub_0809A6F8(this->unk_7c.HALF_U.HI, this->unk_7c.HALF_U.LO, t2, super->type2); } - t2 = t1 = (*(int*)&this->cutsceneBeh) + this->subtimer * 0x1f; - this->field_0x7c.HALF.HI = this->field_0x82.HWORD; - this->field_0x7a.HWORD = this->field_0x82.HWORD; - this->field_0x7c.HALF.LO = this->subtimer * 0x10 + this->field_0x80.HWORD; - this->field_0x78.HWORD = this->field_0x7c.HALF.LO; - tmp_c += sub_0809A6F8(this->field_0x7a.HWORD, this->field_0x78.HWORD, t1, this->type2); - for (loop_var = this->subtimer - 1; loop_var != 0; loop_var--) { - this->field_0x7a.HWORD -= 0x10; - this->field_0x78.HWORD -= 0x10; + t2 = t1 = (*(s32*)&this->helper) + super->subtimer * 0x1f; + this->unk_7c.HALF.HI = this->unk_82; + this->unk_78.HALF_U.HI = this->unk_82; + this->unk_7c.HALF.LO = super->subtimer * 0x10 + this->unk_80; + this->unk_78.HALF_U.LO = this->unk_7c.HALF.LO; + tmp_c += sub_0809A6F8(this->unk_78.HALF_U.HI, this->unk_78.HALF_U.LO, t1, super->type2); + for (loop_var = super->subtimer - 1; loop_var != 0; loop_var--) { + this->unk_78.HALF_U.HI -= 0x10; + this->unk_78.HALF_U.LO -= 0x10; t1 -= 0x20; - tmp_c += sub_0809A6F8(this->field_0x7a.HWORD, this->field_0x78.HWORD, t1, this->type2); - this->field_0x7c.HALF_U.HI += 0x10; - this->field_0x7c.HALF_U.LO -= 0x10; + tmp_c += sub_0809A6F8(this->unk_78.HALF_U.HI, this->unk_78.HALF_U.LO, t1, super->type2); + this->unk_7c.HALF_U.HI += 0x10; + this->unk_7c.HALF_U.LO -= 0x10; t2 -= 0x1e; - tmp_c += sub_0809A6F8(this->field_0x7c.HALF_U.HI, this->field_0x7c.HALF_U.LO, t2, this->type2); + tmp_c += sub_0809A6F8(this->unk_7c.HALF_U.HI, this->unk_7c.HALF_U.LO, t2, super->type2); } if (tmp_c == 0) { DeleteThisEntity(); @@ -307,7 +317,7 @@ void OctorokBossObject_Action1(Entity* this) { break; case 9: sub_08078B48(); - if ((*(int*)&this->field_0x78)-- == 0) { + if ((this->unk_78.WORD_U)-- == 0) { gRoomControls.camera_target = &gPlayerEntity; DeleteThisEntity(); } @@ -315,22 +325,22 @@ void OctorokBossObject_Action1(Entity* this) { } } -void OctorokBossObject_Action2(Entity* this) { +void OctorokBossObject_Action2(OctorokBossObjectEntity* this) { s32 tmp; s32 radius; - GetNextFrame(this); - if (this->timer-- != 0) { - tmp = (0x10000 / this->parent->field_0x74.HWORD); - radius = (this->speed * tmp) >> 8; - this->field_0x7a.HALF.HI = -this->parent->field_0x7a.HALF.HI + this->direction; + GetNextFrame(super); + if (super->timer-- != 0) { + tmp = (0x10000 / ((OctorokBossObjectEntity*)super->parent)->unk_74); + radius = (super->speed * tmp) >> 8; + this->unk_78.BYTES.byte3 = -((OctorokBossObjectEntity*)super->parent)->unk_78.BYTES.byte3 + super->direction; - tmp = FixedMul(gSineTable[this->field_0x7a.HALF.HI], radius); + tmp = FixedMul(gSineTable[this->unk_78.BYTES.byte3], radius); tmp = FixedDiv(tmp, 0x100); - this->x.WORD = this->parent->x.WORD + ((tmp << 0x10) >> 8); - tmp = FixedMul(gSineTable[this->field_0x7a.HALF.HI + 0x40], radius); + super->x.WORD = super->parent->x.WORD + ((tmp << 0x10) >> 8); + tmp = FixedMul(gSineTable[this->unk_78.BYTES.byte3 + 0x40], radius); tmp = FixedDiv(tmp, 0x100); - this->y.WORD = this->parent->y.WORD - ((tmp << 0x10) >> 8); + super->y.WORD = super->parent->y.WORD - ((tmp << 0x10) >> 8); } else { DeleteThisEntity(); } @@ -360,7 +370,7 @@ bool32 sub_0809A758(u32 param_1, u32 param_2) { return FALSE; } -void (*const OctorokBossObject_Actions[])(Entity*) = { +void (*const OctorokBossObject_Actions[])(OctorokBossObjectEntity*) = { OctorokBossObject_Init, OctorokBossObject_Action1, OctorokBossObject_Action2, diff --git a/src/object/palaceArchway.c b/src/object/palaceArchway.c index 4f545bef..b7240a49 100644 --- a/src/object/palaceArchway.c +++ b/src/object/palaceArchway.c @@ -4,6 +4,7 @@ * * @brief Palace Archway object */ +#define NENT_DEPRECATED #include "object.h" void PalaceArchway_Init(Entity*); diff --git a/src/object/paper.c b/src/object/paper.c index ce3b8806..a3b515ee 100644 --- a/src/object/paper.c +++ b/src/object/paper.c @@ -4,10 +4,8 @@ * * @brief Paper object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" void Paper_Init(Entity*); diff --git a/src/object/parallaxRoomView.c b/src/object/parallaxRoomView.c index e796d683..f72cc80b 100644 --- a/src/object/parallaxRoomView.c +++ b/src/object/parallaxRoomView.c @@ -4,35 +4,42 @@ * * @brief Parallax Room View object */ +#define NENT_DEPRECATED #include "entity.h" #include "room.h" -void ParallaxRoomView(Entity* this) { - int iVar1; - int diffY; - int diffX; - int iVar4; - int temp; +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; + /*0x6a*/ u16 unk_6a; +} ParallaxRoomViewEntity; - if (this->action == 0) { - this->action = 1; - this->spriteSettings.draw = 3; - this->frameIndex = this->type2; - this->spriteOrientation.flipY = 3; - this->spriteRendering.b3 = 3; - if (this->type == 3) { - this->spritePriority.b0 = 6; +void ParallaxRoomView(ParallaxRoomViewEntity* this) { + s32 iVar1; + s32 diffY; + s32 diffX; + s32 iVar4; + s32 temp; + + if (super->action == 0) { + super->action = 1; + super->spriteSettings.draw = 3; + super->frameIndex = super->type2; + super->spriteOrientation.flipY = 3; + super->spriteRendering.b3 = 3; + if (super->type == 3) { + super->spritePriority.b0 = 6; } else { - this->spritePriority.b0 = 7; + super->spritePriority.b0 = 7; } - this->field_0x68.HWORD = this->x.HALF.HI; - this->field_0x6a.HWORD = this->y.HALF.HI; - SetDefaultPriority(this, 6); + this->unk_68 = super->x.HALF.HI; + this->unk_6a = super->y.HALF.HI; + SetDefaultPriority(super, 6); } - if ((this->flags & 0x10) == 0) { - iVar4 = (int)this->x.HALF.HI - (int)gRoomControls.scroll_x; + if ((super->flags & 0x10) == 0) { + iVar4 = super->x.HALF.HI - gRoomControls.scroll_x; diffX = iVar4 - 0x78; - iVar1 = (int)this->y.HALF.HI - (int)gRoomControls.scroll_y; + iVar1 = super->y.HALF.HI - gRoomControls.scroll_y; diffY = iVar1 - 0x50; if (diffX < 0) { temp = (iVar4 - 0x75); @@ -51,18 +58,18 @@ void ParallaxRoomView(Entity* this) { if (diffX < -0x10) { diffX = -0x10; } - if (0x10 < diffX) { + if (diffX > 0x10) { diffX = 0x10; } if (diffY < -0x10) { diffY = -0x10; } - if (0x10 < diffY) { + if (diffY > 0x10) { diffY = 0x10; } - this->x.HALF.HI = this->field_0x68.HWORD + diffX; - this->y.HALF.HI = this->field_0x6a.HWORD + diffY; + super->x.HALF.HI = this->unk_68 + diffX; + super->y.HALF.HI = this->unk_6a + diffY; } } diff --git a/src/object/pinwheel.c b/src/object/pinwheel.c index 34db5113..e98c5144 100644 --- a/src/object/pinwheel.c +++ b/src/object/pinwheel.c @@ -4,52 +4,57 @@ * * @brief Pinwheel object */ +#define NENT_DEPRECATED #include "entity.h" #include "flags.h" -#include "global.h" #include "object.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u16 unk_68; +} PinwheelEntity; + static const u16 gUnk_08125050[] = { KUMOUE_02_AWASE_01, KUMOUE_02_AWASE_02, KUMOUE_02_AWASE_03, KUMOUE_02_AWASE_04, KUMOUE_02_AWASE_05, BEGIN_1, }; extern u32 gUnk_020342F8; -void Pinwheel_Init(Entity*); -void Pinwheel_Action1(Entity*); -void Pinwheel_Action2(Entity*); +void Pinwheel_Init(PinwheelEntity* this); +void Pinwheel_Action1(PinwheelEntity* this); +void Pinwheel_Action2(PinwheelEntity* this); -void Pinwheel(Entity* this) { - static void (*const Pinwheel_Actions[])(Entity*) = { +void Pinwheel(PinwheelEntity* this) { + static void (*const Pinwheel_Actions[])(PinwheelEntity*) = { Pinwheel_Init, Pinwheel_Action1, Pinwheel_Action2, }; - u16 x = this->health; + u16 x = super->health; if ((x & 0x7f) != 0) { if (ReadBit(&gUnk_020342F8, x - 1) == 0) { DeleteThisEntity(); } } - Pinwheel_Actions[this->action](this); + Pinwheel_Actions[super->action](this); } -void Pinwheel_Init(Entity* this) { - this->field_0x68.HWORD = gUnk_08125050[this->type2]; - this->spritePriority.b0 = 7; - if (CheckLocalFlag(this->field_0x68.HWORD) != 0) { - this->action = 2; +void Pinwheel_Init(PinwheelEntity* this) { + this->unk_68 = gUnk_08125050[super->type2]; + super->spritePriority.b0 = 7; + if (CheckLocalFlag(this->unk_68) != 0) { + super->action = 2; } else { - this->action = 1; + super->action = 1; } - InitializeAnimation(this, 0); + InitializeAnimation(super, 0); } -void Pinwheel_Action1(Entity* this) { - if (CheckLocalFlag(this->field_0x68.HWORD) != 0) { - this->action = 2; - CreateDust(this); +void Pinwheel_Action1(PinwheelEntity* this) { + if (CheckLocalFlag(this->unk_68) != 0) { + super->action = 2; + CreateDust(super); } } -void Pinwheel_Action2(Entity* this) { - GetNextFrame(this); +void Pinwheel_Action2(PinwheelEntity* this) { + GetNextFrame(super); } diff --git a/src/object/playerClone.c b/src/object/playerClone.c index e898dcfe..56a3c8bf 100644 --- a/src/object/playerClone.c +++ b/src/object/playerClone.c @@ -1,10 +1,10 @@ -#define NENT_DEPRECATED /** * @file playerClone.c * @ingroup Objects * * @brief Player Clone object */ +#define NENT_DEPRECATED #include "asm.h" #include "collision.h" #include "effects.h" @@ -35,13 +35,13 @@ void sub_08084B1C(PlayerCloneEntity*); void sub_08084CAC(PlayerCloneEntity*); void PlayerClone(Entity* this) { - static void (*const actionFuncs[])(PlayerCloneEntity*) = { + static void (*const PlayerClone_Actions[])(PlayerCloneEntity*) = { PlayerClone_Init, PlayerClone_Action1, PlayerClone_Action2, }; - actionFuncs[this->action]((PlayerCloneEntity*)this); + PlayerClone_Actions[this->action]((PlayerCloneEntity*)this); } void PlayerClone_Init(PlayerCloneEntity* this) { diff --git a/src/object/pot.c b/src/object/pot.c index 0e024f6f..93bc1995 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -4,171 +4,182 @@ * * @brief Pot object */ +#define NENT_DEPRECATED #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" +#include "object/itemOnGround.h" #include "player.h" #include "room.h" #include "sound.h" -void Pot_Action5(Entity*); -static void sub_08082850(Entity*, Entity*); -void sub_08082608(Entity*); -void Pot_Init(Entity*); -void Pot_Action1(Entity*); -void Pot_Action2(Entity*); -void Pot_Action3(Entity*); -void Pot_Action4(Entity*); -void Pot_Action5(Entity*); -void sub_08082510(Entity*); -void nullsub_511(Entity*); -void sub_08082588(Entity*); -void sub_0808259C(Entity*); -void sub_080825E8(Entity*); -void sub_080825F0(Entity*); -void sub_08082608(Entity*); -void sub_08082818(Entity*); -void nullsub_512(Entity*); -void sub_080827F8(Entity*); -void sub_08082778(Entity*); -void sub_0808270C(Entity*); -void sub_080826FC(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[8]; + /*0x70*/ u16 unk_70; + /*0x72*/ u8 unused2[11]; + /*0x7d*/ u8 unk_7d; + /*0x7e*/ u8 unused3[8]; + /*0x86*/ u16 unk_86; +} PotEntity; + +void Pot_Action5(PotEntity*); +static void sub_08082850(PotEntity*, Entity*); +void sub_08082608(PotEntity* this); +void Pot_Init(PotEntity* this); +void Pot_Action1(PotEntity* this); +void Pot_Action2(PotEntity* this); +void Pot_Action3(PotEntity* this); +void Pot_Action4(PotEntity* this); +void Pot_Action5(PotEntity* this); +void sub_08082510(PotEntity* this); +void nullsub_511(PotEntity* this); +void sub_08082588(PotEntity* this); +void sub_0808259C(PotEntity* this); +void sub_080825E8(PotEntity* this); +void sub_080825F0(PotEntity* this); +void sub_08082608(PotEntity* this); +void sub_08082818(PotEntity* this); +void nullsub_512(PotEntity* this); +void sub_080827F8(PotEntity* this); +void sub_08082778(PotEntity* this); +void sub_0808270C(PotEntity* this); +void sub_080826FC(PotEntity* this); extern void RegisterCarryEntity(Entity*); extern void sub_08016A6C(Entity*); -void Pot(Entity* this) { - static void (*const Pot_Actions[])(Entity*) = { +void Pot(PotEntity* this) { + static void (*const Pot_Actions[])(PotEntity*) = { Pot_Init, Pot_Action1, Pot_Action2, Pot_Action3, Pot_Action4, Pot_Action5, }; - Pot_Actions[this->action](this); - this->contactFlags = 0; + Pot_Actions[super->action](this); + super->contactFlags = 0; } -void Pot_Init(Entity* this) { - if (this->type2 == 1 && CheckFlags(this->field_0x86.HWORD)) { +void Pot_Init(PotEntity* this) { + if (super->type2 == 1 && CheckFlags(this->unk_86)) { DeleteThisEntity(); } - this->action = 1; - this->hitbox = (Hitbox*)&gHitbox_18; - this->speed = 0x80; - this->y.HALF.HI += 3; - this->carryFlags = 0; - COLLISION_ON(this); - this->health = 1; - this->collisionFlags = 7; - this->hitType = 0x6E; - this->flags2 = 0x84; - this->gustJarFlags = 0x12; - if (this->collisionLayer == 0) { - ResolveCollisionLayer(this); + super->action = 1; + super->hitbox = (Hitbox*)&gHitbox_18; + super->speed = 0x80; + super->y.HALF.HI += 3; + super->carryFlags = 0; + COLLISION_ON(super); + super->health = 1; + super->collisionFlags = 7; + super->hitType = 0x6E; + super->flags2 = 0x84; + super->gustJarFlags = 0x12; + if (super->collisionLayer == 0) { + ResolveCollisionLayer(super); } - this->field_0x70.HALF.LO = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer); - if ((u16)this->field_0x70.HALF.LO == 0x4000) { + this->unk_70 = GetTileIndex(COORD_TO_TILE(super), super->collisionLayer); + if (this->unk_70 == 0x4000) { DeleteThisEntity(); } - SetTile(0x4000, COORD_TO_TILE(this), this->collisionLayer); - InitializeAnimation(this, 5); + SetTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); + InitializeAnimation(super, 5); } -void Pot_Action1(Entity* this) { +void Pot_Action1(PotEntity* this) { u32 tileType; - u32 var0 = this->contactFlags & 0x7F; + u32 var0 = super->contactFlags & 0x7F; switch (var0) { case 0x13: - this->action = 3; - this->subAction = 0; + super->action = 3; + super->subAction = 0; break; case 0x1D: - SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); - this->action = 5; - this->zVelocity = Q_16_16(2.625); - this->spriteOffsetY = 0; - this->spriteSettings.shadow = 1; - this->spritePriority.b1 = 3; - COLLISION_OFF(this); + SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + super->action = 5; + super->zVelocity = Q_16_16(2.625); + super->spriteOffsetY = 0; + super->spriteSettings.shadow = 1; + super->spritePriority.b1 = 3; + COLLISION_OFF(super); Pot_Action5(this); break; default: - tileType = GetTileTypeByEntity(this); + tileType = GetTileTypeByEntity(super); if (tileType != 0x4000) { switch (tileType) { case 0x4004: case 0x4003: case 0x4002: case 0x4001: - this->direction = (tileType - 0x4001) * 8; - this->timer = 32; - this->action = 4; + super->direction = (tileType - 0x4001) * 8; + super->timer = 32; + super->action = 4; if (gPlayerState.flags & PL_MINISH) { - this->speed >>= 1; - this->timer = 64; + super->speed >>= 1; + super->timer = 64; } - SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); + SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); EnqueueSFX(SFX_10F); break; case 0x4067: - SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); + SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); DeleteThisEntity(); break; default: - if (GetTileUnderEntity(this) == 13) { - CreateFx(this, FX_FALL_DOWN, 0); + if (GetTileUnderEntity(super) == 13) { + CreateFx(super, FX_FALL_DOWN, 0); } else if (tileType == 0x4005) { gPlayerState.lastSwordMove = SWORD_MOVE_BREAK_POT; - SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); + SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); } sub_08082850(this, NULL); break; } } else { - RegisterCarryEntity(this); + RegisterCarryEntity(super); } break; } } -void Pot_Action2(Entity* this) { - static void (*const subActionFuncs[])(Entity*) = { +void Pot_Action2(PotEntity* this) { + static void (*const subActionFuncs[])(PotEntity*) = { sub_08082510, nullsub_511, sub_08082588, sub_0808259C, sub_080825E8, sub_080825F0, sub_08082608, }; - subActionFuncs[this->subAction](this); + subActionFuncs[super->subAction](this); } -void sub_08082510(Entity* this) { - COLLISION_ON(this); - this->hitbox = (Hitbox*)&gUnk_080FD340; - this->collisionFlags = 7; - this->hitType = 1; - this->flags2 = gPlayerEntity.flags2; - this->spriteOffsetY = 0; - SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); - this->subAction++; +void sub_08082510(PotEntity* this) { + COLLISION_ON(super); + super->hitbox = (Hitbox*)&gUnk_080FD340; + super->collisionFlags = 7; + super->hitType = 1; + super->flags2 = gPlayerEntity.flags2; + super->spriteOffsetY = 0; + SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + super->subAction++; } -void nullsub_511(Entity* this) { +void nullsub_511(PotEntity* this) { } -void sub_08082588(Entity* this) { - this->spritePriority.b1 = 3; +void sub_08082588(PotEntity* this) { + super->spritePriority.b1 = 3; } -void sub_0808259C(Entity* this) { - switch (sub_080043E8(this)) { +void sub_0808259C(PotEntity* this) { + switch (sub_080043E8(super)) { case 2: - CreateFx(this, FX_WATER_SPLASH, 0); + CreateFx(super, FX_WATER_SPLASH, 0); break; case 1: - CreateFx(this, FX_FALL_DOWN, 0); + CreateFx(super, FX_FALL_DOWN, 0); break; case 3: - CreateFx(this, FX_LAVA_SPLASH, 0); + CreateFx(super, FX_LAVA_SPLASH, 0); break; default: sub_08082850(this, &gPlayerEntity); @@ -178,131 +189,131 @@ void sub_0808259C(Entity* this) { DeleteThisEntity(); } -void sub_080825E8(Entity* this) { +void sub_080825E8(PotEntity* this) { DeleteThisEntity(); } -void sub_080825F0(Entity* this) { +void sub_080825F0(PotEntity* this) { if (gPlayerState.heldObject == 0) { sub_08082608(this); } } -void sub_08082608(Entity* this) { - this->action = 1; - this->subAction = 0; +void sub_08082608(PotEntity* this) { + super->action = 1; + super->subAction = 0; } -void Pot_Action4(Entity* this) { +void Pot_Action4(PotEntity* this) { u32 tileType; - sub_0800445C(this); - if (this->timer-- != 0) { - LinearMoveUpdate(this); - sub_08016A6C(this); + sub_0800445C(super); + if (super->timer-- != 0) { + LinearMoveUpdate(super); + sub_08016A6C(super); return; } - if (sub_0800442E(this)) { + if (sub_0800442E(super)) { return; } - this->action = 1; + super->action = 1; if (gPlayerState.flags & PL_MINISH) { - this->speed <<= 1; + super->speed <<= 1; } - this->field_0x70.HALF.LO = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer); - tileType = GetTileTypeByEntity(this); + this->unk_70 = GetTileIndex(COORD_TO_TILE(super), super->collisionLayer); + tileType = GetTileTypeByEntity(super); switch (tileType) { case 0x71: case 0x72: sub_08082850(this, NULL); break; default: - SetTile(0x4000, COORD_TO_TILE(this), this->collisionLayer); - RegisterCarryEntity(this); + SetTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); + RegisterCarryEntity(super); break; } } -void Pot_Action3(Entity* this) { - static void (*const subActionFuncs[])(Entity*) = { +void Pot_Action3(PotEntity* this) { + static void (*const subActionFuncs[])(PotEntity*) = { sub_080826FC, sub_0808270C, sub_08082778, sub_080827F8, nullsub_512, sub_08082818, }; - subActionFuncs[this->subAction](this); + subActionFuncs[super->subAction](this); } -void sub_080826FC(Entity* this) { - this->subAction = 1; - this->gustJarTolerance = 48; - this->timer = 0; +void sub_080826FC(PotEntity* this) { + super->subAction = 1; + super->gustJarTolerance = 48; + super->timer = 0; } -void sub_0808270C(Entity* this) { - if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (this->contactFlags & 0x7F) != 0x13) { - this->spriteOffsetX = 0; - this->action = 1; - SetTile(0x4000, COORD_TO_TILE(this), this->collisionLayer); +void sub_0808270C(PotEntity* this) { + if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { + super->spriteOffsetX = 0; + super->action = 1; + SetTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); } else { - sub_0806F4E8(this); + sub_0806F4E8(super); } } -void sub_08082778(Entity* this) { - if (this->timer == 0) { - this->timer = 1; - this->spriteOffsetX = 0; - this->spriteOffsetY = -2; - SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); +void sub_08082778(PotEntity* this) { + if (super->timer == 0) { + super->timer = 1; + super->spriteOffsetX = 0; + super->spriteOffsetY = -2; + SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); } - if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (this->contactFlags & 0x7F) != 0x13) { + if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { sub_08082850(this, NULL); } else { - sub_0806F3E4(this); + sub_0806F3E4(super); } } -void sub_080827F8(Entity* this) { +void sub_080827F8(PotEntity* this) { if (gPlayerState.field_0x1c == 0) { sub_08082850(this, NULL); } } -void nullsub_512(Entity* this) { +void nullsub_512(PotEntity* this) { } -void sub_08082818(Entity* this) { +void sub_08082818(PotEntity* this) { sub_08082850(this, NULL); } -void Pot_Action5(Entity* this) { - if (this->zVelocity < 0) { - this->spriteSettings.flipY = 1; +void Pot_Action5(PotEntity* this) { + if (super->zVelocity < 0) { + super->spriteSettings.flipY = 1; } - if (GravityUpdate(this, Q_8_8(32.0)) == 0) { + if (GravityUpdate(super, Q_8_8(32.0)) == 0) { sub_08082850(this, NULL); } } -static void sub_08082850(Entity* this, Entity* parent) { - u32 parameter = sub_0808288C(this, this->type, this->field_0x7c.BYTES.byte1, this->type2); - Entity* fxEntity = CreateFx(this, FX_POT_SHATTER, parameter); +static void sub_08082850(PotEntity* this, Entity* parent) { + u32 parameter = sub_0808288C(super, super->type, this->unk_7d, super->type2); + Entity* fxEntity = CreateFx(super, FX_POT_SHATTER, parameter); if (fxEntity) { fxEntity->parent = parent; } - if (this->type2 == 1) { - SetFlag(this->field_0x86.HWORD); + if (super->type2 == 1) { + SetFlag(this->unk_86); } DeleteThisEntity(); } u32 sub_0808288C(Entity* this, u32 form, u32 arg2, u32 arg3) { - Entity* entity; + ItemOnGroundEntity* entity; u32 result = 0; switch (form) { case 0xFF: @@ -312,13 +323,13 @@ u32 sub_0808288C(Entity* this, u32 form, u32 arg2, u32 arg3) { result = 0x80; break; default: - entity = CreateObjectWithParent(this, GROUND_ITEM, form, arg2); + entity = (ItemOnGroundEntity*)CreateObjectWithParent(this, GROUND_ITEM, form, arg2); if (entity != NULL) { if (arg3 == 2) { - entity->timer = 5; - entity->field_0x86.HWORD = this->field_0x86.HWORD; + entity->base.timer = 5; + entity->unk_86 = ((PotEntity*)this)->unk_86; // This function is also used by flyingSkull. } else { - entity->timer = 0; + entity->base.timer = 0; } } break; diff --git a/src/object/pressurePlate.c b/src/object/pressurePlate.c index 42d8c172..a10818eb 100644 --- a/src/object/pressurePlate.c +++ b/src/object/pressurePlate.c @@ -59,9 +59,7 @@ void PressurePlate_Init(PressurePlateEntity* this) { } void PressurePlate_Action1(PressurePlateEntity* this) { - u8 weight; - - weight = sub_08088938(this) + get_standing_count(this); + u8 weight = sub_08088938(this) + get_standing_count(this); if (super->type + 2 <= weight) { super->action = 2; super->subtimer = 0; @@ -87,10 +85,8 @@ void PressurePlate_Action1(PressurePlateEntity* this) { } void PressurePlate_Action2(PressurePlateEntity* this) { - u8 weight; - if (this->canToggle) { - weight = sub_08088938(this) + get_standing_count(this); + u8 weight = sub_08088938(this) + get_standing_count(this); if (super->type + 2 > weight) { super->action = 1; super->animationState = weight; diff --git a/src/object/pullableLever.c b/src/object/pullableLever.c index 7c2a738f..4b99f202 100644 --- a/src/object/pullableLever.c +++ b/src/object/pullableLever.c @@ -4,10 +4,8 @@ * * @brief Pullable Lever object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" #include "sound.h" diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c index 3200afbf..de34aa4c 100644 --- a/src/object/pullableMushroom.c +++ b/src/object/pullableMushroom.c @@ -4,11 +4,9 @@ * * @brief Pullable Mushroom object */ - #define NENT_DEPRECATED #include "functions.h" #include "game.h" -#include "global.h" #include "hitbox.h" #include "object.h" diff --git a/src/object/pushableFurniture.c b/src/object/pushableFurniture.c index 4f185253..58b1c1aa 100644 --- a/src/object/pushableFurniture.c +++ b/src/object/pushableFurniture.c @@ -4,10 +4,8 @@ * * @brief Pushable Furniture object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { @@ -58,7 +56,7 @@ void PushableFurniture(PushableFurnitureEntity* this) { } } -void sub_0808F990(PushableFurnitureEntity* this) { +void PushableFurniture_Init(PushableFurnitureEntity* this) { bool32 condition; super->action = 1; @@ -632,7 +630,7 @@ void sub_08090514(PushableFurnitureEntity* this) { } void (*const PushableFurniture_Actions[])(PushableFurnitureEntity*) = { - sub_0808F990, + PushableFurniture_Init, PushableFurniture_Action1, PushableFurniture_Action2, }; diff --git a/src/object/pushableGrave.c b/src/object/pushableGrave.c index 1cb2ecdf..245763e3 100644 --- a/src/object/pushableGrave.c +++ b/src/object/pushableGrave.c @@ -4,10 +4,8 @@ * * @brief Pushable Grave object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" diff --git a/src/object/pushableLever.c b/src/object/pushableLever.c index dec3fcb7..493bf92c 100644 --- a/src/object/pushableLever.c +++ b/src/object/pushableLever.c @@ -4,10 +4,8 @@ * * @brief Pushable Lever object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/pushableRock.c b/src/object/pushableRock.c index 29b3fdd8..ca862173 100644 --- a/src/object/pushableRock.c +++ b/src/object/pushableRock.c @@ -4,10 +4,8 @@ * * @brief Pushable Rock object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { diff --git a/src/object/pushableStatue.c b/src/object/pushableStatue.c index b29ca269..ed3de97f 100644 --- a/src/object/pushableStatue.c +++ b/src/object/pushableStatue.c @@ -5,10 +5,9 @@ * @brief Pushable Statue object */ #define NENT_DEPRECATED -#include "global.h" -#include "object.h" #include "functions.h" #include "hitbox.h" +#include "object.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/railtrack.c b/src/object/railtrack.c index 5a77c8db..9fe52d41 100644 --- a/src/object/railtrack.c +++ b/src/object/railtrack.c @@ -4,110 +4,123 @@ * * @brief Railtrack object */ +#define NENT_DEPRECATED #include "asm.h" #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "room.h" #include "sound.h" -void sub_08085394(Entity*); -void sub_0808543C(Entity*); -void Railtrack_Init(Entity*); -void Railtrack_Action1(Entity*); -void Railtrack_Action2(Entity*); -void Railtrack_Action3(Entity*); -u32 sub_080854A8(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[8]; + /*0x70*/ u16* unk_70; + /*0x74*/ u16 unk_74; + /*0x76*/ u16 unk_76; + /*0x78*/ u16 unk_78; + /*0x7a*/ u16 unk_7a; + /*0x7c*/ union SplitHWord unk_7c; + /*0x7e*/ u8 unused2[8]; + /*0x86*/ u16 unk_86; +} RailtrackEntity; + +void sub_08085394(RailtrackEntity* this); +void sub_0808543C(RailtrackEntity* this); +void Railtrack_Init(RailtrackEntity* this); +void Railtrack_Action1(RailtrackEntity* this); +void Railtrack_Action2(RailtrackEntity* this); +void Railtrack_Action3(RailtrackEntity* this); +u32 sub_080854A8(RailtrackEntity* this); extern s8 gUnk_080B4488[][2]; -void Railtrack(Entity* this) { - static void (*const Railtrack_Actions[])(Entity*) = { +void Railtrack(RailtrackEntity* this) { + static void (*const Railtrack_Actions[])(RailtrackEntity*) = { Railtrack_Init, Railtrack_Action1, Railtrack_Action2, Railtrack_Action3, }; - Railtrack_Actions[this->action](this); + Railtrack_Actions[super->action](this); } -void Railtrack_Init(Entity* this) { +void Railtrack_Init(RailtrackEntity* this) { u32 uVar1; - this->action = 1; - this->spriteSettings.draw = 1; - this->spritePriority.b0 = 7; - if ((this->type2 & 1) != 0) { - this->field_0x7c.HALF.LO = -1; + super->action = 1; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 7; + if ((super->type2 & 1) != 0) { + this->unk_7c.HWORD = -1; } else { - this->field_0x7c.HALF.LO = 1; + this->unk_7c.HWORD = 1; } - this->animationState = this->type2 & 2; - if (this->type == 3) { - uVar1 = CheckFlags(this->field_0x86.HWORD); - this->field_0x7a.HWORD = uVar1; + super->animationState = super->type2 & 2; + if (super->type == 3) { + uVar1 = CheckFlags(this->unk_86); + this->unk_7a = uVar1; if ((u16)(uVar1 & -1) != 0) { - this->animationState = (this->animationState + 2) & 3; - this->action = 3; + super->animationState = (super->animationState + 2) & 3; + super->action = 3; } } - InitializeAnimation(this, this->animationState); - this->field_0x70.WORD = (u32)&GetLayerByIndex(this->collisionLayer)->mapData[COORD_TO_TILE(this)]; + InitializeAnimation(super, super->animationState); + this->unk_70 = &GetLayerByIndex(super->collisionLayer)->mapData[COORD_TO_TILE(super)]; sub_08085394(this); } -void Railtrack_Action1(Entity* this) { - if (CheckFlags(this->field_0x86.HWORD)) { - this->action = 2; - this->subtimer = 8; - if (this->type == 1) { - ClearFlag(this->field_0x86.HWORD); +void Railtrack_Action1(RailtrackEntity* this) { + if (CheckFlags(this->unk_86)) { + super->action = 2; + super->subtimer = 8; + if (super->type == 1) { + ClearFlag(this->unk_86); } - this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; - InitializeAnimation(this, this->animationState); + super->animationState = (super->animationState + this->unk_7c.HALF.LO) & 3; + InitializeAnimation(super, super->animationState); sub_0808543C(this); EnqueueSFX(SFX_151); } } -void Railtrack_Action2(Entity* this) { - if (--this->subtimer == 0) { - this->action = 3; - this->subtimer = this->timer; - this->field_0x7a.HWORD = CheckFlags(this->field_0x86.HWORD); - this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; - InitializeAnimation(this, this->animationState); +void Railtrack_Action2(RailtrackEntity* this) { + if (--super->subtimer == 0) { + super->action = 3; + super->subtimer = super->timer; + this->unk_7a = CheckFlags(this->unk_86); + super->animationState = (super->animationState + this->unk_7c.HALF.LO) & 3; + InitializeAnimation(super, super->animationState); sub_08085394(this); EnqueueSFX(SFX_151); } } -void Railtrack_Action3(Entity* this) { +void Railtrack_Action3(RailtrackEntity* this) { if (sub_080854A8(this) == 0) { - switch (this->type) { + switch (super->type) { case 0: case 1: break; case 2: - if (CheckFlags(this->field_0x86.HWORD) == 0) { - this->action = 1; + if (CheckFlags(this->unk_86) == 0) { + super->action = 1; return; } break; case 3: - if (CheckFlags(this->field_0x86.HWORD) == *(u16*)&this->field_0x7a) { - this->subtimer = 255; + if (CheckFlags(this->unk_86) == this->unk_7a) { + super->subtimer = 255; } else { - this->subtimer = 1; + super->subtimer = 1; } } - if (--this->subtimer == 0) { - this->action = 2; - this->subtimer = 8; - this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; - InitializeAnimation(this, this->animationState); + if (--super->subtimer == 0) { + super->action = 2; + super->subtimer = 8; + super->animationState = (super->animationState + this->unk_7c.HALF.LO) & 3; + InitializeAnimation(super, super->animationState); sub_0808543C(this); EnqueueSFX(SFX_151); } @@ -116,47 +129,47 @@ void Railtrack_Action3(Entity* this) { static const u16 gUnk_081205E0[] = { 0x4018, 0x4019 }; -void sub_08085394(Entity* this) { +void sub_08085394(RailtrackEntity* this) { u32 uVar1; u16* layerData; u32 tile; - s8 off; + s8 offset; - uVar1 = gUnk_081205E0[this->animationState / 2]; - off = gUnk_080B4488[this->animationState / 2][0]; - layerData = (u16*)this->field_0x70.WORD; - tile = COORD_TO_TILE(this); + uVar1 = gUnk_081205E0[super->animationState / 2]; + offset = gUnk_080B4488[super->animationState / 2][0]; + layerData = this->unk_70; + tile = COORD_TO_TILE(super); - this->field_0x74.HWORD = *(layerData - off); - SetTile(uVar1, tile - off, this->collisionLayer); + this->unk_74 = *(layerData - offset); + SetTile(uVar1, tile - offset, super->collisionLayer); - this->field_0x76.HWORD = layerData[0x0]; - SetTile(uVar1, tile - 0x0, this->collisionLayer); + this->unk_76 = layerData[0x0]; + SetTile(uVar1, tile - 0x0, super->collisionLayer); - this->field_0x78.HWORD = layerData[off]; - SetTile(uVar1, tile + off, this->collisionLayer); + this->unk_78 = layerData[offset]; + SetTile(uVar1, tile + offset, super->collisionLayer); } -void sub_0808543C(Entity* this) { +void sub_0808543C(RailtrackEntity* this) { s8* cVar1; u32 uVar2; s8 temp; - temp = gUnk_080B4488[this->animationState / 2][0]; - uVar2 = COORD_TO_TILE(this); - SetTile(this->field_0x74.HWORD, uVar2 - temp, this->collisionLayer); - SetTile(this->field_0x76.HWORD, uVar2, this->collisionLayer); - SetTile(this->field_0x78.HWORD, uVar2 + temp, this->collisionLayer); + temp = gUnk_080B4488[super->animationState / 2][0]; + uVar2 = COORD_TO_TILE(super); + SetTile(this->unk_74, uVar2 - temp, super->collisionLayer); + SetTile(this->unk_76, uVar2, super->collisionLayer); + SetTile(this->unk_78, uVar2 + temp, super->collisionLayer); } -u32 sub_080854A8(Entity* this) { +u32 sub_080854A8(RailtrackEntity* this) { u16 var0; u16* var1; s8* var2; - var0 = gUnk_081205E0[this->animationState / 2]; - var2 = gUnk_080B4488[this->animationState / 2]; - var1 = (u16*)this->field_0x70.WORD; + var0 = gUnk_081205E0[super->animationState / 2]; + var2 = gUnk_080B4488[super->animationState / 2]; + var1 = this->unk_70; if (var0 != *(var1 - var2[0])) { return TRUE; } diff --git a/src/object/rupee.c b/src/object/rupee.c index 2d0756d8..fe38b3ad 100644 --- a/src/object/rupee.c +++ b/src/object/rupee.c @@ -4,6 +4,7 @@ * * @brief Rupee object */ +#define NENT_DEPRECATED #include "functions.h" #include "hitbox.h" #include "object.h" @@ -14,56 +15,55 @@ void Rupee_Action_1(Entity*); void Rupee_Action_2(Entity*); // Main -void Rupee(Entity* ent) { +void Rupee(Entity* this) { static void (*const Rupee_Actions[])(Entity*) = { Rupee_Init, Rupee_Action_1, Rupee_Action_2, }; - Rupee_Actions[ent->action](ent); + Rupee_Actions[this->action](this); } -void Rupee_Init(Entity* ent) { +void Rupee_Init(Entity* this) { Entity* itemEntity; - ent->action = 1; - ent->spriteSettings.draw = 0; - ent->hitbox = (Hitbox*)&gUnk_080FD1A8; - ent->collisionFlags |= 16; - itemEntity = CreateObject(GROUND_ITEM, ent->type, 0); + this->action = 1; + this->spriteSettings.draw = 0; + this->hitbox = (Hitbox*)&gUnk_080FD1A8; + this->collisionFlags |= 16; + itemEntity = CreateObject(GROUND_ITEM, this->type, 0); if (itemEntity != NULL) { itemEntity->timer = 10; - itemEntity->parent = ent; - ent->child = itemEntity; - CopyPosition(ent, itemEntity); - sub_08086A6C(ent); + itemEntity->parent = this; + this->child = itemEntity; + CopyPosition(this, itemEntity); + sub_08086A6C(this); } } -void Rupee_Action_1(Entity* ent) { - if (ent->child->next == NULL) { - ent->action = 2; +void Rupee_Action_1(Entity* this) { + if (this->child->next == NULL) { + this->action = 2; } else { - u32 iVar1 = sub_080044EC(ent, 10240); - if (iVar1 == 0) { - ent->action = 2; + if (sub_080044EC(this, 10240) == 0) { + this->action = 2; } - ProcessMovement0(ent); - CopyPosition(ent, ent->child); + ProcessMovement0(this); + CopyPosition(this, this->child); } } -void Rupee_Action_2(Entity* ent) { - ent->child->parent = NULL; +void Rupee_Action_2(Entity* this) { + this->child->parent = NULL; DeleteThisEntity(); } -void sub_08086A6C(Entity* ent) { +void sub_08086A6C(Entity* this) { u32 uVar1; uVar1 = Random(); - ent->zVelocity = Q_16_16(2.5); - ent->direction = DirectionNormalize(uVar1 >> 16); - ent->speed = uVar1 & 480; + this->zVelocity = Q_16_16(2.5); + this->direction = DirectionNormalize(uVar1 >> 16); + this->speed = uVar1 & 480; } diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c index 1c5e048a..255dbb40 100644 --- a/src/object/smallIceBlock.c +++ b/src/object/smallIceBlock.c @@ -4,14 +4,12 @@ * * @brief Small Ice Block object */ - #define NENT_DEPRECATED -#include "global.h" #include "collision.h" -#include "object.h" #include "functions.h" #include "hitbox.h" #include "item.h" +#include "object.h" typedef struct { /*0x00*/ Entity base; diff --git a/src/object/smoke.c b/src/object/smoke.c index afe2f97e..06de5ca1 100644 --- a/src/object/smoke.c +++ b/src/object/smoke.c @@ -4,22 +4,23 @@ * * @brief Smoke object */ +#define NENT_DEPRECATED #include "object.h" -void sub_0808A40C(Entity*); -void sub_0808A46C(Entity*); +void Smoke_Type0(Entity*); +void Smoke_Type1(Entity*); void sub_0808A484(Entity*); void sub_0808A4D0(Entity*); void Smoke(Entity* this) { - static void (*const typeFuncs[])(Entity*) = { - sub_0808A40C, - sub_0808A46C, + static void (*const Smoke_Types[])(Entity*) = { + Smoke_Type0, + Smoke_Type1, }; - typeFuncs[this->type](this); + Smoke_Types[this->type](this); } -void sub_0808A40C(Entity* this) { +void Smoke_Type0(Entity* this) { static const s8 gUnk_08121068[] = { -1, 1, -2, 2, 0, 0, 0, 0, }; @@ -39,7 +40,7 @@ void sub_0808A40C(Entity* this) { } } -void sub_0808A46C(Entity* this) { +void Smoke_Type1(Entity* this) { static void (*const actionFuncs[])(Entity*) = { sub_0808A484, sub_0808A4D0, diff --git a/src/object/smokeParticle.c b/src/object/smokeParticle.c index de97206b..4e871bfc 100644 --- a/src/object/smokeParticle.c +++ b/src/object/smokeParticle.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" void SmokeParticle_Init(Entity*); diff --git a/src/object/specialFx.c b/src/object/specialFx.c index 46436ea8..37614788 100644 --- a/src/object/specialFx.c +++ b/src/object/specialFx.c @@ -1,13 +1,12 @@ -#define NENT_DEPRECATED /** * @file specialFx.c * @ingroup Objects * * @brief Special FX object */ +#define NENT_DEPRECATED #include "entity.h" #include "functions.h" -#include "global.h" #include "object.h" typedef struct { @@ -122,8 +121,8 @@ const struct_0811F960 gUnk_0811F960[] = { // clang-format on void SpecialFx(Entity*); -void sub_080844E0(SpecialFxObject*); -void sub_080845B8(SpecialFxObject*); +void SpecialFx_Init(SpecialFxObject*); +void SpecialFx_Action1(SpecialFxObject*); void sub_080845DC(SpecialFxObject*); void sub_080845F8(SpecialFxObject*); void sub_08084630(SpecialFxObject*); @@ -139,14 +138,14 @@ void sub_080847D0(SpecialFxObject*); void sub_080847E0(SpecialFxObject*); void SpecialFx(Entity* this) { - static void (*const gUnk_0811FAC0[])(SpecialFxObject*) = { - sub_080844E0, - sub_080845B8, + static void (*const SpecialFx_Actions[])(SpecialFxObject*) = { + SpecialFx_Init, + SpecialFx_Action1, }; - gUnk_0811FAC0[this->action]((SpecialFxObject*)this); + SpecialFx_Actions[this->action]((SpecialFxObject*)this); } -void sub_080844E0(SpecialFxObject* this) { +void SpecialFx_Init(SpecialFxObject* this) { static const u8 gUnk_0811FAC8[] = { 0x03, 0x37, 0x38, 0x39 }; static const u8 gUnk_0811FACC[] = { 0x17, 0x3e, 0x3f, 0x40 }; const struct_0811F960* ptr; @@ -183,7 +182,7 @@ void sub_080844E0(SpecialFxObject* this) { } } -void sub_080845B8(SpecialFxObject* this) { +void SpecialFx_Action1(SpecialFxObject* this) { static void (*const gUnk_0811FAD0[])(SpecialFxObject*) = { sub_080845DC, sub_080845F8, sub_08084630, sub_08084694, (void (*)(SpecialFxObject*))DeleteEntity, sub_08084680, sub_080846B0, sub_0808471C, sub_08084770, sub_08084798, diff --git a/src/object/stoneTablet.c b/src/object/stoneTablet.c index 06049ca9..15605a4b 100644 --- a/src/object/stoneTablet.c +++ b/src/object/stoneTablet.c @@ -4,6 +4,7 @@ * * @brief Stone Tablet object */ +#define NENT_DEPRECATED #include "entity.h" #include "functions.h" #include "room.h" diff --git a/src/object/swordParticle.c b/src/object/swordParticle.c index 3e197a29..a2fc8110 100644 --- a/src/object/swordParticle.c +++ b/src/object/swordParticle.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "item.h" #include "object.h" diff --git a/src/object/swordsmanNewsletter.c b/src/object/swordsmanNewsletter.c index 15f8eef5..36a2aedf 100644 --- a/src/object/swordsmanNewsletter.c +++ b/src/object/swordsmanNewsletter.c @@ -4,8 +4,8 @@ * * @brief Swordsman Newsletter object */ +#define NENT_DEPRECATED #include "entity.h" -#include "global.h" #include "message.h" extern void AddInteractableCheckableObject(Entity*); diff --git a/src/object/thoughtBubble.c b/src/object/thoughtBubble.c index d6f39c27..7ab561c5 100644 --- a/src/object/thoughtBubble.c +++ b/src/object/thoughtBubble.c @@ -4,8 +4,8 @@ * * @brief Thought Bubble object */ +#define NENT_DEPRECATED #include "entity.h" -#include "global.h" #include "sound.h" void ThoughtBubble_Init(Entity*); @@ -19,11 +19,11 @@ static const u16 ThoughtBubble_SFX[] = { }; void ThoughtBubble(Entity* this) { - static void (*const ThoughtBubble_Behaviors[])(Entity*) = { + static void (*const ThoughtBubble_Actions[])(Entity*) = { ThoughtBubble_Init, ThoughtBubble_Update, }; - ThoughtBubble_Behaviors[this->action](this); + ThoughtBubble_Actions[this->action](this); } void ThoughtBubble_Init(Entity* this) { diff --git a/src/object/thunderbold.c b/src/object/thunderbolt.c similarity index 73% rename from src/object/thunderbold.c rename to src/object/thunderbolt.c index 3b3f7fa3..697a32e3 100644 --- a/src/object/thunderbold.c +++ b/src/object/thunderbolt.c @@ -1,23 +1,21 @@ /** - * @file thunderbold.c + * @file thunderbolt.c * @ingroup Objects * - * @brief Thunderbold object + * @brief Thunderbolt object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" typedef struct { /*0x00*/ Entity base; -} ThunderboldEntity; +} ThunderboltEntity; -void Thunderbold_Init(ThunderboldEntity*); -void Thunderbold_Action1(ThunderboldEntity*); -void sub_08093ED0(ThunderboldEntity*); -void sub_08093EF0(ThunderboldEntity*); +void Thunderbolt_Init(ThunderboltEntity*); +void Thunderbolt_Action1(ThunderboltEntity*); +void sub_08093ED0(ThunderboltEntity*); +void sub_08093EF0(ThunderboltEntity*); typedef struct { u16 sfx; @@ -31,15 +29,15 @@ const struct_08122950 gUnk_08122950[] = { { 0, 31, 0 }, }; -void Thunderbold(ThunderboldEntity* this) { - static void (*const Thunderbold_Actions[])(ThunderboldEntity*) = { - Thunderbold_Init, - Thunderbold_Action1, +void Thunderbolt(ThunderboltEntity* this) { + static void (*const Thunderbolt_Actions[])(ThunderboltEntity*) = { + Thunderbolt_Init, + Thunderbolt_Action1, }; - Thunderbold_Actions[super->action](this); + Thunderbolt_Actions[super->action](this); } -void Thunderbold_Init(ThunderboldEntity* this) { +void Thunderbolt_Init(ThunderboltEntity* this) { const struct_08122950* ptr; super->action = 1; super->flags &= ~0x80; @@ -57,22 +55,22 @@ void Thunderbold_Init(ThunderboldEntity* this) { } } -void Thunderbold_Action1(ThunderboldEntity* this) { - static void (*const gUnk_08122964[])(ThunderboldEntity*) = { +void Thunderbolt_Action1(ThunderboltEntity* this) { + static void (*const gUnk_08122964[])(ThunderboltEntity*) = { sub_08093ED0, sub_08093EF0, }; gUnk_08122964[gUnk_08122950[super->type].unk_2 >> 4](this); } -void sub_08093ED0(ThunderboldEntity* this) { +void sub_08093ED0(ThunderboltEntity* this) { GetNextFrame(super); if ((super->frame & ANIM_DONE) != 0) { DeleteEntity(super); } } -void sub_08093EF0(ThunderboldEntity* this) { +void sub_08093EF0(ThunderboltEntity* this) { Entity* object; switch (super->type) { case 0: @@ -83,7 +81,7 @@ void sub_08093EF0(ThunderboldEntity* this) { if ((super->frame & ANIM_DONE) == 0) { return; } - object = CreateObject(THUNDERBOLD, 1, 0); + object = CreateObject(THUNDERBOLT, 1, 0); if (object != NULL) { object->parent = super->parent; CopyPosition(super, object); @@ -94,7 +92,7 @@ void sub_08093EF0(ThunderboldEntity* this) { GetNextFrame(super); if ((super->frame & 1) != 0) { super->frame = 0; - object = CreateObject(THUNDERBOLD, 2, 0); + object = CreateObject(THUNDERBOLT, 2, 0); if (object != NULL) { object->parent = super->parent; CopyPosition(super, object); diff --git a/src/object/titleScreenObject.c b/src/object/titleScreenObject.c index 27f15290..9144d0e3 100644 --- a/src/object/titleScreenObject.c +++ b/src/object/titleScreenObject.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" void TitleScreenObject_Type0(Entity*); diff --git a/src/object/trapdoor.c b/src/object/trapdoor.c index c28517e9..cb2ad703 100644 --- a/src/object/trapdoor.c +++ b/src/object/trapdoor.c @@ -4,6 +4,7 @@ * * @brief Trapdoor object */ +#define NENT_DEPRECATED #include "item.h" #include "object.h" diff --git a/src/object/treeHidingPortal.c b/src/object/treeHidingPortal.c index 9a5ac61e..4acf1d76 100644 --- a/src/object/treeHidingPortal.c +++ b/src/object/treeHidingPortal.c @@ -4,83 +4,89 @@ * * @brief Tree Hiding Portal object */ +#define NENT_DEPRECATED #include "effects.h" #include "entity.h" #include "flags.h" #include "functions.h" -#include "global.h" #include "object.h" #include "player.h" #include "room.h" #include "sound.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[30]; + /*0x86*/ u16 unk_86; +} TreeHidingPortalEntity; + extern const s16 gUnk_080B4468[]; -void TreeHidingPortal_Init(Entity* this); -void TreeHidingPortal_Action1(Entity* this); -void TreeHidingPortal_Action2(Entity* this); -void TreeHidingPortal_Action3(Entity* this); +void TreeHidingPortal_Init(TreeHidingPortalEntity* this); +void TreeHidingPortal_Action1(TreeHidingPortalEntity* this); +void TreeHidingPortal_Action2(TreeHidingPortalEntity* this); +void TreeHidingPortal_Action3(TreeHidingPortalEntity* this); -static void sub_0809E96C(Entity* this); +static void sub_0809E96C(TreeHidingPortalEntity* this); static u32 sub_0809E9A0(void); -static void sub_0809E918(Entity* this); +static void sub_0809E918(TreeHidingPortalEntity* this); -void TreeHidingPortal(Entity* this) { - static void (*const TreeHidingPortal_Actions[])(Entity*) = { +void TreeHidingPortal(TreeHidingPortalEntity* this) { + static void (*const TreeHidingPortal_Actions[])(TreeHidingPortalEntity*) = { TreeHidingPortal_Init, TreeHidingPortal_Action1, TreeHidingPortal_Action2, TreeHidingPortal_Action3, }; - TreeHidingPortal_Actions[this->action](this); + TreeHidingPortal_Actions[super->action](this); } -void TreeHidingPortal_Init(Entity* this) { - if (CheckFlags(this->field_0x86.HWORD)) { +void TreeHidingPortal_Init(TreeHidingPortalEntity* this) { + if (CheckFlags(this->unk_86)) { sub_0809E96C(this); DeleteThisEntity(); } - this->action = 1; - this->collisionLayer = 2; - UpdateSpriteForCollisionLayer(this); + super->action = 1; + super->collisionLayer = 2; + UpdateSpriteForCollisionLayer(super); } -void TreeHidingPortal_Action1(Entity* this) { +void TreeHidingPortal_Action1(TreeHidingPortalEntity* this) { - if (sub_0800419C(this, &gPlayerEntity, 0x30, 0x30)) { + if (sub_0800419C(super, &gPlayerEntity, 0x30, 0x30)) { if (CheckGlobalFlag(EZERO_1ST)) { if (((gRoomTransition.frameCount & 3) == 0)) { - CreateSparkle(this); + CreateSparkle(super); } } } if (sub_0809E9A0() == 0x54) { - this->action = 2; - this->timer = 15; + super->action = 2; + super->timer = 15; SetPlayerControl(1); } } -void TreeHidingPortal_Action2(Entity* this) { - if (--this->timer == 0) { - this->action = 3; - this->timer = 60; - this->spriteSettings.draw = 0; +void TreeHidingPortal_Action2(TreeHidingPortalEntity* this) { + if (--super->timer == 0) { + super->action = 3; + super->timer = 60; + super->spriteSettings.draw = 0; sub_0809E96C(this); sub_0809E918(this); } } -void TreeHidingPortal_Action3(Entity* this) { - if (--this->timer == 0) { - SetFlag(this->field_0x86.HWORD); +void TreeHidingPortal_Action3(TreeHidingPortalEntity* this) { + if (--super->timer == 0) { + SetFlag(this->unk_86); SetPlayerControl(0); SoundReq(SFX_SECRET_BIG); DeleteThisEntity(); } } -static void sub_0809E918(Entity* this) { +static void sub_0809E918(TreeHidingPortalEntity* this) { static const s16 gUnk_08124364[] = { 0, -4, 8, -4, 16, -4, 22, -4, -8, -4, -16, -4, -22, -4, 0, -12, 0, 4, 8, -12, 8, 4, -8, -12, -8, 4, 8, -16, -8, -16, 12, -16, -12, -16, 16, -14, -16, -14, -1000, 0, @@ -88,7 +94,7 @@ static void sub_0809E918(Entity* this) { Entity* fx; const s16* i = gUnk_08124364; while (*i != -1000) { - fx = CreateFx(this, FX_BUSH, 0); + fx = CreateFx(super, FX_BUSH, 0); if (fx != NULL) { fx->x.HALF.HI += i[0]; fx->y.HALF.HI += i[1]; @@ -99,8 +105,8 @@ static void sub_0809E918(Entity* this) { } } -static void sub_0809E96C(Entity* this) { - CreateMinishEntrance(COORD_TO_TILE_OFFSET(this, 0x20, 0x8)); +static void sub_0809E96C(TreeHidingPortalEntity* this) { + CreateMinishEntrance(COORD_TO_TILE_OFFSET(super, 0x20, 0x8)); } static u32 sub_0809E9A0(void) { diff --git a/src/object/treeThorns.c b/src/object/treeThorns.c index e01a832d..15aac684 100644 --- a/src/object/treeThorns.c +++ b/src/object/treeThorns.c @@ -4,8 +4,8 @@ * * @brief Three Thorns object */ +#define NENT_DEPRECATED #include "entity.h" -#include "global.h" #include "hitbox.h" #include "object.h" #include "physics.h" diff --git a/src/object/unusedSkull.c b/src/object/unusedSkull.c index c6a2e1f5..68a22cef 100644 --- a/src/object/unusedSkull.c +++ b/src/object/unusedSkull.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" diff --git a/src/object/vaati2Particle.c b/src/object/vaati2Particle.c index d3ce9d29..a9d42284 100644 --- a/src/object/vaati2Particle.c +++ b/src/object/vaati2Particle.c @@ -40,7 +40,6 @@ void sub_0809E7FC(Entity* this) { static const s8 gUnk_081242D8[] = { 0, -24, 16, -16, 24, 0, 16, 16, 0, 24, -16, 16, -24, 0, -16, -16, }; - int iVar1; const s8* ptr; ptr = &gUnk_081242D8[this->type2 * 2]; diff --git a/src/object/vaati3Arm.c b/src/object/vaati3Arm.c index 50d094a4..6ba31113 100644 --- a/src/object/vaati3Arm.c +++ b/src/object/vaati3Arm.c @@ -4,8 +4,8 @@ * * @brief Vaati3 Arm object */ +#define NENT_DEPRECATED #include "entity.h" -#include "global.h" #include "physics.h" void sub_080A0640(Entity*); diff --git a/src/object/vaati3PlayerObject.c b/src/object/vaati3PlayerObject.c index 0cec61c1..b491cb2a 100644 --- a/src/object/vaati3PlayerObject.c +++ b/src/object/vaati3PlayerObject.c @@ -4,6 +4,7 @@ * * @brief Vaati3 Player object */ +#define NENT_DEPRECATED #include "entity.h" #include "physics.h" #include "player.h" diff --git a/src/object/warpPoint.c b/src/object/warpPoint.c index d89c91fd..d83bc106 100644 --- a/src/object/warpPoint.c +++ b/src/object/warpPoint.c @@ -4,134 +4,146 @@ * * @brief Warp Point object */ +#define NENT_DEPRECATED #include "functions.h" #include "game.h" -#include "global.h" #include "hitbox.h" #include "object.h" +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[8]; + /*0x70*/ u8 unk_70; + /*0x71*/ u8 unused2[11]; + /*0x7c*/ u8 unk_7c; + /*0x7d*/ u8 unk_7d; + /*0x7e*/ u8 unused3[6]; + /*0x84*/ u16 unk_84; + /*0x86*/ u16 unk_86; +} WarpPointEntity; + extern void EnableDungeonWarp(u32); extern u32 IsDungeonWarpActive(u32); -void WarpPoint_Init(Entity*); -void WarpPoint_Action1(Entity*); -void WarpPoint_Action2(Entity*); -void WarpPoint_Action3(Entity*); -void WarpPoint_Action4(Entity*); -void WarpPoint_Action5(Entity*); -void sub_0808B73C(Entity*); -u32 sub_0808B7C8(Entity*); -void sub_0808B830(Entity*); +void WarpPoint_Init(WarpPointEntity* this); +void WarpPoint_Action1(WarpPointEntity* this); +void WarpPoint_Action2(WarpPointEntity* this); +void WarpPoint_Action3(WarpPointEntity* this); +void WarpPoint_Action4(WarpPointEntity* this); +void WarpPoint_Action5(WarpPointEntity* this); +void sub_0808B73C(WarpPointEntity* this); +u32 sub_0808B7C8(WarpPointEntity* this); +void sub_0808B830(WarpPointEntity* this); -void (*const WarpPoint_Actions[])(Entity*) = { +void (*const WarpPoint_Actions[])(WarpPointEntity*) = { WarpPoint_Init, WarpPoint_Action1, WarpPoint_Action2, WarpPoint_Action3, WarpPoint_Action4, WarpPoint_Action5, }; const u8 gUnk_08121380[3] = { 1, 0, 2 }; -void WarpPoint(Entity* this) { - if (!this->field_0x70.BYTES.byte0) { - WarpPoint_Actions[this->action](this); +void WarpPoint(WarpPointEntity* this) { + if (!this->unk_70) { + WarpPoint_Actions[super->action](this); } else { sub_0808B73C(this); } } -void WarpPoint_Init(Entity* this) { +void WarpPoint_Init(WarpPointEntity* this) { u32 tmp; - this->action = 1; - this->subtimer = 0; - tmp = gUnk_08121380[this->type]; - this->palette.b.b0 = tmp; - this->spritePriority.b0 = 6; - this->hitbox = (Hitbox*)&gHitbox_1; - this->updatePriority = PRIO_NO_BLOCK; - InitializeAnimation(this, 0); - if (CheckFlags(this->field_0x86.HWORD)) { + super->action = 1; + super->subtimer = 0; + tmp = gUnk_08121380[super->type]; + super->palette.b.b0 = tmp; + super->spritePriority.b0 = 6; + super->hitbox = (Hitbox*)&gHitbox_1; + super->updatePriority = PRIO_NO_BLOCK; + InitializeAnimation(super, 0); + if (CheckFlags(this->unk_86)) { sub_0808B830(this); } else { - if (AreaIsDungeon() && IsDungeonWarpActive(this->type)) { + if (AreaIsDungeon() && IsDungeonWarpActive(super->type)) { sub_0808B830(this); } } if (!sub_0808B7C8(this)) return; - this->action = 4; - this->subtimer = 96; - gPlayerEntity.x.HALF.HI = this->x.HALF.HI; - gPlayerEntity.y.HALF.HI = this->y.HALF.HI; + super->action = 4; + super->subtimer = 96; + gPlayerEntity.x.HALF.HI = super->x.HALF.HI; + gPlayerEntity.y.HALF.HI = super->y.HALF.HI; gPlayerEntity.animationState = 4; EnqueueSFX(SFX_112); - RequestPriorityDuration(this, this->subtimer + 16); + RequestPriorityDuration(super, super->subtimer + 16); } -void WarpPoint_Action1(Entity* this) { - if (CheckFlags(this->field_0x86.HWORD)) { +void WarpPoint_Action1(WarpPointEntity* this) { + if (CheckFlags(this->unk_86)) { sub_0808B830(this); if (AreaIsDungeon()) { - EnableDungeonWarp(this->type); + EnableDungeonWarp(super->type); } - this->action = 2; - this->subtimer = 60; + super->action = 2; + super->subtimer = 60; EnqueueSFX(SFX_112); } } -void WarpPoint_Action2(Entity* this) { - if (!--this->subtimer) { - this->action = 3; +void WarpPoint_Action2(WarpPointEntity* this) { + if (!--super->subtimer) { + super->action = 3; } else { - this->spriteSettings.draw = this->subtimer & 2 ? 0 : 1; + super->spriteSettings.draw = super->subtimer & 2 ? 0 : 1; } } -void WarpPoint_Action3(Entity* this) { - GetNextFrame(this); +void WarpPoint_Action3(WarpPointEntity* this) { + GetNextFrame(super); if (sub_0808B7C8(this)) { - if (this->timer) + if (super->timer) return; - this->action = 5; - this->subtimer = 96; + super->action = 5; + super->subtimer = 96; PutAwayItems(); - gPlayerEntity.x.HALF.HI = this->x.HALF.HI; - gPlayerEntity.y.HALF.HI = this->y.HALF.HI; + gPlayerEntity.x.HALF.HI = super->x.HALF.HI; + gPlayerEntity.y.HALF.HI = super->y.HALF.HI; gPlayerEntity.animationState = 4; gPlayerEntity.flags &= ~ENT_COLLIDE; - RequestPriorityDuration(this, this->subtimer + 16); + RequestPriorityDuration(super, super->subtimer + 16); SoundReq(SFX_113); } else { - this->timer = 0; + super->timer = 0; } } -void WarpPoint_Action4(Entity* this) { +void WarpPoint_Action4(WarpPointEntity* this) { u32 tmp; - if (!--this->subtimer) { - this->action = 3; - this->timer = 1; + if (!--super->subtimer) { + super->action = 3; + super->timer = 1; gPlayerEntity.animationState = 4; gPlayerEntity.direction = DirectionSouth; return; } tmp = 0; - switch (this->subtimer & 0x60) { + switch (super->subtimer & 0x60) { case 0x40: - if (this->subtimer == 0x58) { + if (super->subtimer == 0x58) { SoundReq(SFX_114); } - if (!(this->subtimer & 1)) { + if (!(super->subtimer & 1)) { tmp = 1; } break; case 0x20: - if (!(this->subtimer & 3)) { + if (!(super->subtimer & 3)) { tmp = 1; } break; case 0: - if (!(this->subtimer & 7)) { + if (!(super->subtimer & 7)) { if (gPlayerEntity.animationState == 4) { - if (this->subtimer > 0x18) { + if (super->subtimer > 0x18) { tmp = 1; } } else { @@ -146,38 +158,38 @@ void WarpPoint_Action4(Entity* this) { } } -void WarpPoint_Action5(Entity* this) { +void WarpPoint_Action5(WarpPointEntity* this) { u32 tmp; - if (!--this->subtimer) { + if (!--super->subtimer) { gRoomTransition.transitioningOut = 1; gRoomTransition.type = TRANSITION_DEFAULT; - gRoomTransition.player_status.area_next = this->field_0x7c.BYTES.byte0; - gRoomTransition.player_status.room_next = this->field_0x7c.BYTES.byte1; - gRoomTransition.player_status.start_pos_x = ((this->cutsceneBeh.HWORD & 0x3f) << 4) + 8; - gRoomTransition.player_status.start_pos_y = ((this->cutsceneBeh.HWORD & 0xfc0) >> 2) + 8; + gRoomTransition.player_status.area_next = this->unk_7c; + gRoomTransition.player_status.room_next = this->unk_7d; + gRoomTransition.player_status.start_pos_x = ((this->unk_84 & 0x3f) << 4) + 8; + gRoomTransition.player_status.start_pos_y = ((this->unk_84 & 0xfc0) >> 2) + 8; gRoomTransition.player_status.layer = 0; gRoomTransition.player_status.start_anim = 4; gRoomTransition.player_status.spawn_type = PL_SPAWN_DEFAULT; - if (this->type == 2) { + if (super->type == 2) { gRoomTransition.type = TRANSITION_FADE_WHITE_SLOW; } return; } tmp = 0; - switch (this->subtimer & 0x60) { + switch (super->subtimer & 0x60) { case 0x40: - if (!(this->subtimer & 7)) { + if (!(super->subtimer & 7)) { tmp = 1; } break; case 0x20: - if (!(this->subtimer & 3)) { + if (!(super->subtimer & 3)) { tmp = 1; } break; case 0: - if (this->subtimer > 0x10) { - if (!(this->subtimer & 1)) { + if (super->subtimer > 0x10) { + if (!(super->subtimer & 1)) { tmp = 1; } } else { @@ -191,28 +203,28 @@ void WarpPoint_Action5(Entity* this) { } } -void sub_0808B73C(Entity* this) { - if (this->action == 0) { - this->action = 1; - this->palette.b.b0 = this->parent->palette.b.b0; - InitializeAnimation(this, 1); +void sub_0808B73C(WarpPointEntity* this) { + if (super->action == 0) { + super->action = 1; + super->palette.b.b0 = super->parent->palette.b.b0; + InitializeAnimation(super, 1); } - if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28)) { - this->spriteSettings.draw = 1; + if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28)) { + super->spriteSettings.draw = 1; } else { - if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x2e)) { - this->spriteSettings.draw ^= 1; + if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x2e)) { + super->spriteSettings.draw ^= 1; } else { - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; } } - GetNextFrame(this); + GetNextFrame(super); } -u32 sub_0808B7C8(Entity* this) { +u32 sub_0808B7C8(WarpPointEntity* this) { if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.framestate != PL_STATE_DIE && gPlayerEntity.health != 0 && - PlayerCanBeMoved() && EntityInRectRadius(this, &gPlayerEntity, 5, 5) && gPlayerEntity.z.HALF.HI == 0) { - if (this->timer == 0 && gPlayerEntity.action == PLAYER_08072C9C) { + PlayerCanBeMoved() && EntityInRectRadius(super, &gPlayerEntity, 5, 5) && gPlayerEntity.z.HALF.HI == 0) { + if (super->timer == 0 && gPlayerEntity.action == PLAYER_08072C9C) { ResetPlayerAnimationAndAction(); } return 1; @@ -220,15 +232,15 @@ u32 sub_0808B7C8(Entity* this) { return 0; } -void sub_0808B830(Entity* this) { - Entity* tmp; - this->action = 3; - this->timer = 0; - this->spriteSettings.draw = 1; - tmp = CreateObject(WARP_POINT, 0, 0); - if (tmp) { - tmp->field_0x70.BYTES.byte0 = 1; - tmp->parent = this; - CopyPosition(this, tmp); +void sub_0808B830(WarpPointEntity* this) { + WarpPointEntity* warpPoint; + super->action = 3; + super->timer = 0; + super->spriteSettings.draw = 1; + warpPoint = (WarpPointEntity*)CreateObject(WARP_POINT, 0, 0); + if (warpPoint) { + warpPoint->unk_70 = 1; + warpPoint->base.parent = super; + CopyPosition(super, &warpPoint->base); } } diff --git a/src/object/waterDropObject.c b/src/object/waterDropObject.c index a32cad00..d1236267 100644 --- a/src/object/waterDropObject.c +++ b/src/object/waterDropObject.c @@ -9,8 +9,8 @@ #include "functions.h" void WaterDropObject(Entity* this) { - int iVar2; - int iVar4; + u32 iVar2; + u32 iVar4; Entity* parent; parent = this->parent; diff --git a/src/object/waterElement.c b/src/object/waterElement.c index 12aa538d..9b4d9902 100644 --- a/src/object/waterElement.c +++ b/src/object/waterElement.c @@ -6,7 +6,6 @@ */ #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" void WaterElement_Init(Entity*); diff --git a/src/object/well.c b/src/object/well.c index 29a04181..8b26a476 100644 --- a/src/object/well.c +++ b/src/object/well.c @@ -4,41 +4,45 @@ * * @brief Well object */ +#define NENT_DEPRECATED #include "asm.h" #include "entity.h" #include "functions.h" -#include "global.h" #include "player.h" #include "room.h" -void Well_Init(Entity*); -void Well_Action1(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unused1[24]; + /*0x80*/ u16 unk_80; +} WellEntity; -void Well(Entity* this) { - static void (*const Well_Actions[])(Entity*) = { +void Well_Init(WellEntity* this); +void Well_Action1(WellEntity* this); + +void Well(WellEntity* this) { + static void (*const Well_Actions[])(WellEntity*) = { Well_Init, Well_Action1, }; - Well_Actions[this->action](this); + Well_Actions[super->action](this); } -void Well_Init(Entity* this) { +void Well_Init(WellEntity* this) { u32 tilePos; - this->action = 1; - tilePos = COORD_TO_TILE(this); - this->field_0x80.HWORD = tilePos; - SetTile(16509, this->field_0x80.HWORD, 1); + super->action = 1; + tilePos = COORD_TO_TILE(super); + this->unk_80 = tilePos; + SetTile(16509, this->unk_80, 1); } -void Well_Action1(Entity* this) { - s32 tileIndex; - - tileIndex = GetTileType(this->field_0x80.HWORD, 1); +void Well_Action1(WellEntity* this) { + u32 tileIndex = GetTileType(this->unk_80, 1); if (tileIndex != 0x407D) { sub_08078B48(); - gPlayerEntity.x.WORD = this->x.WORD; - gPlayerEntity.y.HALF.HI = this->y.HALF.HI + 4; + gPlayerEntity.x.WORD = super->x.WORD; + gPlayerEntity.y.HALF.HI = super->y.HALF.HI + 4; DeleteThisEntity(); } } diff --git a/src/object/whirlwind.c b/src/object/whirlwind.c index 0193f063..5febac8c 100644 --- a/src/object/whirlwind.c +++ b/src/object/whirlwind.c @@ -4,11 +4,9 @@ * * @brief Whirlwind object */ - #define NENT_DEPRECATED #include "area.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" diff --git a/src/object/whiteTriangleEffect.c b/src/object/whiteTriangleEffect.c index c6746f80..16ba562c 100644 --- a/src/object/whiteTriangleEffect.c +++ b/src/object/whiteTriangleEffect.c @@ -4,10 +4,8 @@ * * @brief White Triangle Effect object */ - #define NENT_DEPRECATED #include "functions.h" -#include "global.h" #include "object.h" #include "screen.h" diff --git a/src/object/windTribeFlag.c b/src/object/windTribeFlag.c index 99b8572f..19aa7f63 100644 --- a/src/object/windTribeFlag.c +++ b/src/object/windTribeFlag.c @@ -4,6 +4,7 @@ * * @brief Wind Tribe Flag object */ +#define NENT_DEPRECATED #include "object.h" void WindTribeFlag(Entity* this) { diff --git a/src/object/windTribeTeleporter.c b/src/object/windTribeTeleporter.c index 082098c9..bd94a171 100644 --- a/src/object/windTribeTeleporter.c +++ b/src/object/windTribeTeleporter.c @@ -4,11 +4,9 @@ * * @brief Wind Tribe Teleporter object */ - #define NENT_DEPRECATED #include "collision.h" #include "functions.h" -#include "global.h" #include "hitbox.h" #include "object.h" #include "screenTransitions.h" diff --git a/src/object/windcrest.c b/src/object/windcrest.c index 815a0f4a..2ce20d42 100644 --- a/src/object/windcrest.c +++ b/src/object/windcrest.c @@ -4,10 +4,10 @@ * * @brief Windcrest object */ +#define NENT_DEPRECATED #include "effects.h" #include "entity.h" #include "functions.h" -#include "global.h" #include "save.h" #include "script.h" #include "sound.h"