From d29468c30bcf5d786e4d97446d8d3512063c71bc Mon Sep 17 00:00:00 2001 From: theo3 Date: Tue, 26 Oct 2021 20:33:33 -0700 Subject: [PATCH 1/4] add effects.h --- include/effects.h | 118 ++++++++++++++++++++++++ src/arm_proxy.c | 3 +- src/code_080A29BC.c | 9 +- src/createObject.c | 13 +-- src/enemy/businessScrub.c | 3 +- src/enemy/doorMimic.c | 5 +- src/enemy/fallingBoulder.c | 3 +- src/enemy/fireballGuy.c | 3 +- src/enemy/gyorgMale.c | 9 +- src/enemy/hangingSeed.c | 3 +- src/enemy/keaton.c | 3 +- src/enemy/lakitu.c | 11 ++- src/enemy/lakituCloud.c | 3 +- src/enemy/madderpillar.c | 5 +- src/enemy/mazaalBracelet.c | 3 +- src/enemy/mazaalHead.c | 3 +- src/enemy/mazaalMacro.c | 5 +- src/enemy/moldworm.c | 5 +- src/enemy/puffstool.c | 5 +- src/enemy/rockChuchu.c | 3 +- src/enemy/slime.c | 3 +- src/enemy/spark.c | 3 +- src/enemy/spearMoblin.c | 3 +- src/enemy/vaatiArm.c | 5 +- src/enemy/vaatiRebornEnemy.c | 3 +- src/enemy/vaatiTransfigured.c | 3 +- src/enemy/vaatiWrath.c | 3 +- src/enemy/vaatiWrathEye.c | 3 +- src/enemy/wisp.c | 3 +- src/item/itemPegasusBoots.c | 5 +- src/npc/bladeBrothers.c | 3 +- src/npc/castorWildsStatue.c | 3 +- src/npc/ezloCap.c | 3 +- src/npc/goron.c | 5 +- src/npc/mailbox.c | 3 +- src/npc/melari.c | 3 +- src/npc/percy.c | 3 +- src/npc/postman.c | 3 +- src/npc/smith.c | 3 +- src/npc/stamp.c | 3 +- src/npc/townsperson.c | 3 +- src/object/bigVortex.c | 3 +- src/object/bird.c | 3 +- src/object/book.c | 3 +- src/object/button.c | 5 +- src/object/lockedDoor.c | 5 +- src/object/mask.c | 3 +- src/object/metalDoor.c | 5 +- src/object/objectA2.c | 3 +- src/object/pot.c | 11 ++- src/object/treeHidingPortal.c | 3 +- src/object/windcrest.c | 3 +- src/player.c | 9 +- src/playerItem/playerItem14.c | 5 +- src/playerItem/playerItemBow.c | 3 +- src/playerItem/playerItemSwordBeam.c | 5 +- src/projectile/cannonballProjectile.c | 7 +- src/projectile/dirtBallProjectile.c | 9 +- src/projectile/gleerokProjectile.c | 3 +- src/projectile/lakituCloudProjectile.c | 5 +- src/projectile/lakituLightning.c | 3 +- src/projectile/octorokBossProjectile.c | 5 +- src/projectile/stalfosProjectile.c | 5 +- src/projectile/v2Projectile.c | 7 +- src/projectile/v3TennisBallProjectile.c | 3 +- src/room.c | 7 +- src/script.c | 3 +- 67 files changed, 297 insertions(+), 113 deletions(-) create mode 100644 include/effects.h diff --git a/include/effects.h b/include/effects.h new file mode 100644 index 00000000..696ab9ab --- /dev/null +++ b/include/effects.h @@ -0,0 +1,118 @@ +#ifndef EFFECTS_H +#define EFFECTS_H + +#include "entity.h" + +typedef enum { + FX_FALL_DOWN, + FX_EXPLOSION, + FX_DEATH, + FX_BUSH, + FX_ROCK, + FX_POT_SHATTER, + FX_6, + FX_SPARKLE, + FX_8, + FX_9, + FX_A, + FX_WATER_SPLASH, + FX_LAVA_SPLASH, + FX_ICE, + FX_ROCK_HUGE, + FX_ROCK_SMALL, + FX_REFLECT, + FX_DASH, + FX_BLUE_SPARKLE, + FX_RED_BUSH, + FX_SPARKLE2, + FX_ROCK2, + FX_FIRE, + FX_GRASS_CUT, + FX_18, + FX_SWORD_MAGIC, + FX_LIGHTNING, + FX_LIGHTNING_STRIKE, + FX_STARS, + FX_STARS_STRIKE, + FX_STARS_STRIKE2, + FX_REFLECT2, + FX_RIPPLE, + FX_RIPPLE_LARGE, + FX_BROWN_SMOKE, + FX_BROWN_SMOKE_LARGE, + FX_BROWN_SMOKE2, + FX_SWEAT, + FX_26, + FX_27, + FX_SLOW_EXPLOSION, + FX_CONFETTI, + FX_CONFETTI_LARGE, + FX_GREEN_SPLASH2, + FX_REFECT3, + FX_SIGN, + FX_SLOW_SMOKE2, + FX_SLOW_SMOKE_SMALL, + FX_SPARKLE_SECRET, + FX_MAILBOX_UNUSED, + FX_32, + FX_33, + FX_34, + FX_BIG_EXPLOSION, + FX_LAVA_SPLASH_HUGE, + FX_GRASS_CUT2, + FX_BUSH_CUT2, + FX_BUSH_CUT3, + FX_EGG, + FX_WOOD, + FX_BONE, + FX_STARS2, + FX_GRASS_CUT3, + FX_GRASS_CUT4, + FX_GRASS_CUT5, + FX_REFLECT4, + FX_STEAM_EFC, + FX_BIG_EXPLOSION2, + FX_WHITE_SPLASH, + FX_WHITE_ROCK, + FX_GIANT_EXPLOSION, + FX_GIANT_EXPLOSION2, + FX_GIANT_EXPLOSION3, + FX_GREEN_ORB, + FX_GREEN_ORB_SLOW, + FX_WHITE_AURA, + FX_WOOD2, + FX_SPARKLE3, + FX_MAGIC_STORM, + FX_BLUE_EFC, + FX_REFLECT5, + FX_GIANT_EXPLOSION4, + FX_GREEN_SPLASH, + FX_BLUE_PUFF, + FX_WHITE_PUFF, + FX_AURA_BASE, + FX_RED_AURA, + FX_BLUE_AURA, + FX_58, + FX_59, + FX_5A, + FX_5B, + FX_BARREL_BEAM, + FX_BARREL, + FX_5E, + FX_5F, + FX_60, + FX_STONE_BLOCK, + FX_62, + FX_63, + FX_64, + FX_65, + FX_66, + FX_67, + FX_68, + FX_69, + FX_6A, + FX_6B, + FX_6C, +} Effect; + +#endif // EFFECTS_H \ No newline at end of file diff --git a/src/arm_proxy.c b/src/arm_proxy.c index e1f13c74..982ddb65 100644 --- a/src/arm_proxy.c +++ b/src/arm_proxy.c @@ -10,6 +10,7 @@ #include "manager.h" #include "utils.h" #include "npc.h" +#include "effects.h" extern u8 gUnk_03003DE0; extern u8 gUnk_03000C30; @@ -227,7 +228,7 @@ void HandlePlayerLife(Entity* this) { } else if ((gSave.stats.effectTimer == 0) || --gSave.stats.effectTimer == 0) { gSave.stats.effect = 0; } else if ((gSave.stats.effectTimer & 0x3f) == 0) { - CreateFx(this, 0x55 + gSave.stats.effect, 0); + CreateFx(this, FX_AURA_BASE + gSave.stats.effect, 0); } } #endif diff --git a/src/code_080A29BC.c b/src/code_080A29BC.c index c085a684..17fb9fba 100644 --- a/src/code_080A29BC.c +++ b/src/code_080A29BC.c @@ -2,6 +2,7 @@ #include "entity.h" #include "room.h" #include "object.h" +#include "effects.h" void sub_080A29C8(s32 xOff, s32 yOff, u32 layer) { Entity* pEVar1; @@ -15,15 +16,15 @@ void sub_080A29C8(s32 xOff, s32 yOff, u32 layer) { } void sub_080A29FC(Entity* parent) { - CreateFx(parent, 0x11, 0); + CreateFx(parent, FX_DASH, 0); } void sub_080A2A08(Entity* parent) { - CreateFx(parent, 0x6, 0); + CreateFx(parent, FX_6, 0); } void sub_080A2A14(Entity* parent) { - CreateFx(parent, 0xb, 0); + CreateFx(parent, FX_WATER_SPLASH, 0); } Entity* sub_080A2A20(Entity* parent, u32 form, u32 parameter) { @@ -50,7 +51,7 @@ Entity* sub_080A2A3C(Entity* parent, u32 form, u32 subtype, u32 param_4) { Entity* sub_080A2A64(Entity* parent) { Entity* pEVar1; - pEVar1 = CreateFx(parent, 0x20, 0); + pEVar1 = CreateFx(parent, FX_SPARKLE2, 0); if (pEVar1 != NULL) { pEVar1->spritePriority.b0 = 7; } diff --git a/src/createObject.c b/src/createObject.c index cf3655c9..0d18f6b1 100644 --- a/src/createObject.c +++ b/src/createObject.c @@ -4,6 +4,7 @@ #include "room.h" #include "createObject.h" #include "object.h" +#include "effects.h" Entity* CreateObject(u32 subtype, u32 form, u32 parameter) { Entity* entity; @@ -36,13 +37,13 @@ Entity* CreateFx(Entity* parentEnt, u32 form, u32 parameter) { } void CreateDust(Entity* parent) { - CreateFx(parent, 2, 0); + CreateFx(parent, FX_DEATH, 0); } void CreateDustAt(s32 xOff, s32 yOff, u32 layer) { Entity* ent; - ent = CreateObject(SPECIAL_FX, 2, 0); + ent = CreateObject(SPECIAL_FX, FX_DEATH, 0); if (ent != NULL) { ent->x.HALF.HI = gRoomControls.roomOriginX + xOff; ent->y.HALF.HI = gRoomControls.roomOriginY + yOff; @@ -51,15 +52,15 @@ void CreateDustAt(s32 xOff, s32 yOff, u32 layer) { } void CreateDustSmall(Entity* parent) { - CreateFx(parent, 0x11, 0); + CreateFx(parent, FX_DASH, 0); } void CreateExplosionBroken(Entity* parent) { - CreateFx(parent, 0x6, 0); + CreateFx(parent, FX_6, 0); } void CreateWaterSplash(Entity* parent) { - CreateFx(parent, 0xb, 0); + CreateFx(parent, FX_WATER_SPLASH, 0); } Entity* sub_080A2A20(Entity* parent, u32 form, u32 parameter) { @@ -86,7 +87,7 @@ Entity* sub_080A2A3C(Entity* parent, u32 form, u32 subtype, u32 param_4) { Entity* CreateWaterTrace(Entity* parent) { Entity* ent; - ent = CreateFx(parent, 0x20, 0); + ent = CreateFx(parent, FX_RIPPLE, 0); if (ent != NULL) { ent->spritePriority.b0 = 7; } diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index afc9da4e..730f1aa7 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -6,6 +6,7 @@ #include "random.h" #include "npc.h" #include "functions.h" +#include "effects.h" extern void sub_0801D040(Entity*, u32); extern Entity* sub_08049DF4(u32); @@ -60,7 +61,7 @@ void sub_08028934(Entity* this) { this->actionDelay = 0x28; this->flags &= ~0x80; sub_080290E0(this, 4); - pEVar1 = CreateFx(this, 3, 0); + pEVar1 = CreateFx(this, FX_BUSH, 0); if (pEVar1 != NULL) { pEVar1->height.HALF.HI -= 8; } diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index 2bfc1fc4..ff59c26d 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -1,6 +1,7 @@ #include "enemy.h" #include "entity.h" #include "functions.h" +#include "effects.h" extern s16 sub_080001DA(u32, u32); // ? extern void sub_08049CF4(); @@ -37,7 +38,7 @@ void sub_08021FF4(Entity* this) { void sub_08022004(Entity* this) { SetTile((u16)this->field_0x7c.HALF.LO, (u16)this->field_0x7c.HALF.HI, this->collisionLayer); - CreateFx(this, 5, 0); + CreateFx(this, FX_POT_SHATTER, 0); sub_08049CF4(this); DeleteThisEntity(); } @@ -80,7 +81,7 @@ void sub_080220F0(Entity* this) { this->field_0x44 = 0; off = gUnk_080CB76C[this->type2]; for (i = 0; i < 6; i++, off++) { - Entity* fx = CreateFx(this, 0x11, 0); + Entity* fx = CreateFx(this, FX_DASH, 0); if (fx) { fx->x.HALF.HI += off->h; fx->y.HALF.HI += off->v; diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index 74135810..5195b542 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -1,6 +1,7 @@ #include "enemy.h" #include "random.h" #include "functions.h" +#include "effects.h" void sub_0802C4B0(Entity*); void sub_0802C62C(Entity*); @@ -92,7 +93,7 @@ NONMATCH("asm/non_matching/fallingBoulder/sub_0802C334.inc", void sub_0802C334(E u32 diff = 0; s32 i; for (i = 1; i > -1; i--) { - Entity* ent = CreateFx(this, 0x15, 0); + Entity* ent = CreateFx(this, FX_ROCK2, 0); if (ent) { ent->x.HALF.HI += 12; ent->x.HALF.HI -= diff; diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index f7851aad..42916d3e 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -3,6 +3,7 @@ #include "enemy.h" #include "random.h" #include "functions.h" +#include "effects.h" typedef struct { s8 h, v; @@ -88,7 +89,7 @@ void sub_08045454(Entity* this) { off++; } - ent = CreateFx(this, 2, 0); + ent = CreateFx(this, FX_DEATH, 0); if (ent) CopyPosition(this, ent); diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index effceb3b..7aaa2153 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -6,6 +6,7 @@ #include "fileScreen.h" #include "random.h" #include "functions.h" +#include "effects.h" void (*const gUnk_080D1AFC[8])(Entity*); void (*const gUnk_080D1B1C[7])(Entity*); @@ -935,7 +936,7 @@ void sub_08047BF0(Entity* this) { sub_08047E48(this); if (this->actionDelay == 0) { if ((this->field_0xf++ & 0xF) == 0) { - tmp = CreateFx(this, 0x51, 0); + tmp = CreateFx(this, FX_GIANT_EXPLOSION4, 0); if (tmp) { u32 rand = Random(); tmp->x.HALF.HI += (rand & 0x1E) + 0xFFF1; @@ -960,17 +961,17 @@ void sub_08047BF0(Entity* this) { if (this->actionDelay == 0x5A) { tmp = this->attachedEntity; tmp->spriteSettings.b.draw = 0; - CreateFx(tmp, 0x51, 0); + CreateFx(tmp, FX_GIANT_EXPLOSION4, 0); } else { if (this->actionDelay == 0x3C) { tmp = this->attachedEntity->attachedEntity; tmp->spriteSettings.b.draw = 0; - CreateFx(tmp, 0x51, 0); + CreateFx(tmp, FX_GIANT_EXPLOSION4, 0); } else { if (this->actionDelay == 0x1E) { tmp = this->attachedEntity->attachedEntity->attachedEntity; tmp->spriteSettings.b.draw = 0; - CreateFx(tmp, 0x51, 0); + CreateFx(tmp, FX_GIANT_EXPLOSION4, 0); } } } diff --git a/src/enemy/hangingSeed.c b/src/enemy/hangingSeed.c index fe6fe0fc..95593f7b 100644 --- a/src/enemy/hangingSeed.c +++ b/src/enemy/hangingSeed.c @@ -1,6 +1,7 @@ #include "entity.h" #include "enemy.h" #include "functions.h" +#include "effects.h" extern void (*const gHangingSeedFunctions[])(Entity*); extern void (*const gUnk_080CB588[])(Entity*); @@ -15,7 +16,7 @@ void HangingSeed_OnTick(Entity* this) { void sub_080216FC(Entity* this) { if (this->bitfield & 0x80) { - CreateFx(this, 3, 0x80); + CreateFx(this, FX_BUSH, 0x80); DeleteThisEntity(); } } diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index 1ed5af8e..1b4f20c0 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -3,6 +3,7 @@ #include "enemy.h" #include "random.h" #include "functions.h" +#include "effects.h" extern Entity* gUnk_020000B0; @@ -222,7 +223,7 @@ void sub_08032794(Entity* this) { Entity* target; s8* temp; - target = CreateFx(this, 0x11, 0x40); + target = CreateFx(this, FX_DASH, 0x40); if (target != NULL) { temp = &gUnk_080CE810[this->animationState * 2]; PositionRelative(this, target, temp[0] << 0x10, temp[1] << 0x10); diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index cbbab57f..b35d9540 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -5,6 +5,7 @@ #include "coord.h" #include "random.h" #include "player.h" +#include "effects.h" extern void (*const LakituActionFuncs[])(Entity*); @@ -61,7 +62,7 @@ void sub_0803C784(Entity* this) { sub_0803CBAC(this); } else { if (this->damageType == 0x43) { - Entity* fx = CreateFx(this, 2, 0); + Entity* fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { u32 angle = (this->knockbackDirection ^ 0x10) << 3; @@ -360,25 +361,25 @@ void sub_0803CC08(Entity* this) { return; } - fx = CreateFx(this, 2, 0); + fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { fx->x.HALF.HI += 6; fx->y.HALF.HI += 6; } - fx = CreateFx(this, 2, 0); + fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { fx->x.HALF.HI -= 6; fx->y.HALF.HI += 6; } - fx = CreateFx(this, 2, 0); + fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { fx->x.HALF.HI += 6; fx->y.HALF.HI -= 6; } - fx = CreateFx(this, 2, 0); + fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { fx->x.HALF.HI -= 6; fx->y.HALF.HI -= 6; diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index df0c0cca..b7301df7 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -2,6 +2,7 @@ #include "entity.h" #include "player.h" #include "functions.h" +#include "effects.h" extern u32 GetNextFunction(Entity*); @@ -126,7 +127,7 @@ void sub_0803CE14(Entity* this) { } void sub_0803CE3C(Entity* this) { - CreateFx(this, 2, 0); + CreateFx(this, FX_DEATH, 0); this->action = 2; this->actionDelay = 60; diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index 7d1fa2ee..513848d9 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -2,6 +2,7 @@ #include "entity.h" #include "random.h" #include "functions.h" +#include "effects.h" extern u8 gEntCount; extern Hitbox gUnk_080FD298; @@ -163,7 +164,7 @@ void sub_08029B2C(Entity* this) { if (sub_0802A14C(this)) { if (this->field_0x86.HALF.LO) { if (--this->actionDelay == 0) { - CreateFx(this, 0x48, 0); + CreateFx(this, FX_GIANT_EXPLOSION3, 0); DeleteEntity(this); } } else { @@ -241,7 +242,7 @@ void sub_08029C6C(Entity* this) { void sub_08029C98(Entity* this) { if (sub_0802A14C(this)) { - CreateFx(this, 0x48, 0); + CreateFx(this, FX_GIANT_EXPLOSION3, 0); DeleteEntity(this); } else { gUnk_080CCDA8[this->action](this); diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index be47d87f..a0f50903 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -4,6 +4,7 @@ #include "random.h" #include "object.h" #include "functions.h" +#include "effects.h" void sub_0803B538(Entity*); u32 sub_0803B4E4(Entity*); @@ -962,7 +963,7 @@ void sub_0803B1B8(Entity* this) { this->field_0x7c.HALF.HI = 0x5dc; this->spriteSettings.b.draw = 0; this->damageType = 0x14; - temp = CreateFx(this, 0x51, 0); + temp = CreateFx(this, FX_GIANT_EXPLOSION4, 0); if (temp != (Entity*)0x0) { temp->x.HALF.HI += this->hitbox->offset_x; temp->y.HALF.HI += this->hitbox->offset_y; diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index bfa45e69..04b80eff 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -6,6 +6,7 @@ #include "random.h" #include "object.h" #include "functions.h" +#include "effects.h" extern void UnloadOBJPalette(Entity*); @@ -78,7 +79,7 @@ void (*const gUnk_080CECB4[])(Entity*) = { }; const u8 gUnk_080CECEC[] = { 0xff, 0xfe, 0xff, 0x00, 0x01, 0x02, 0x01, 0x00 }; const s8 gUnk_080CECF4[] = { -2, 0x01, -8, -4, -0x14, 0x08, 0x0e, -0x10, -6, 0x0c, 0x12, -2, 0x00, 0x00 }; -const u8 gUnk_080CED02[] = { 0x46, 0x46, 0x47, 0x48 }; +const u8 gUnk_080CED02[] = { FX_GIANT_EXPLOSION, FX_GIANT_EXPLOSION, FX_GIANT_EXPLOSION2, FX_GIANT_EXPLOSION3 }; const u8 gUnk_080CED06[] = { 0xff, 0x00, 0x01, 0x00, 0x00, 0x00 }; void (*const gUnk_080CED0C[])(Entity*) = { sub_08034578, sub_080344E0, sub_0803451C, sub_080344E0, sub_08034558, sub_080344E0, sub_0803451C, sub_080346A0, diff --git a/src/enemy/mazaalMacro.c b/src/enemy/mazaalMacro.c index 0e32a810..e9cf7191 100644 --- a/src/enemy/mazaalMacro.c +++ b/src/enemy/mazaalMacro.c @@ -5,6 +5,7 @@ #include "script.h" #include "structures.h" #include "functions.h" +#include "effects.h" extern void sub_0807B600(u32); @@ -43,7 +44,7 @@ void (*const gUnk_080CEEB0[])(Entity*) = { sub_08034E30, sub_08034E68, sub_08034EC0, sub_08034ED8, sub_08034EE4, sub_08034F58, }; -const u8 gUnk_080CEEC8[] = { 0x46, 0x46, 0x47, 0x48 }; +const u8 gUnk_080CEEC8[] = { FX_GIANT_EXPLOSION, FX_GIANT_EXPLOSION, FX_GIANT_EXPLOSION2, FX_GIANT_EXPLOSION3 }; const u8 gUnk_080CEECC[] = { 0x58, 0x68, 0x88, 0x68, 0xb8, 0x68, 0x58, 0xa8, 0x88, 0xa8, 0xb8, 0xa8 }; const s16 gUnk_080CEED8[] = { -0x82, -0x81, -0x80, -0x7f, -0x7e, -0x42, -0x41, -0x40, -0x3f, -0x3e, -2, -1, 1, 2, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x7e, 0x7f, 0x80, 0x81, 0x82 }; @@ -113,7 +114,7 @@ void sub_08034D4C(Entity* this) { void sub_08034DC8(Entity* this) { if (gScreenTransition.field_0x39 == 0) { - CreateFx(this, 0x51, 0); + CreateFx(this, FX_GIANT_EXPLOSION4, 0); sub_0807BA8C(COORD_TO_TILE(this), this->collisionLayer); DeleteThisEntity(); } diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index cb27ab6d..8f805aaf 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -2,6 +2,7 @@ #include "entity.h" #include "random.h" #include "functions.h" +#include "effects.h" extern void sub_0800449C(Entity*, u32); extern bool32 sub_08023A38(u32); @@ -177,7 +178,7 @@ void sub_08023330(Entity* this) { this->field_0x7c.BYTES.byte3 = 0; sub_08023A88(this, this->animationState); CopyPosition(this, this->attachedEntity); - CreateFx(this, 4, 0); + CreateFx(this, FX_ROCK, 0); } } @@ -199,7 +200,7 @@ void sub_08023398(Entity* this) { this->damageType = 0x85; this->attachedEntity->actionDelay = 1; sub_08023A68(this); - CreateFx(this, 4, 0); + CreateFx(this, FX_ROCK, 0); return; } this->field_0x78.HWORD = 0x28; diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 69df19d6..b7139173 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -3,6 +3,7 @@ #include "random.h" #include "object.h" #include "functions.h" +#include "effects.h" extern u32 sub_080002E0(u32, u32); extern u32 sub_080002C8(u16, u8); @@ -520,12 +521,12 @@ bool32 sub_08025AB8(u32 tile, u32 layer) { void sub_08025AE8(Entity* this) { Entity* ent; - ent = CreateFx(this, 0x22, 0); + ent = CreateFx(this, FX_BROWN_SMOKE, 0); if (ent) { ent->y.WORD--; } - ent = CreateFx(this, 0x23, 0); + ent = CreateFx(this, FX_BROWN_SMOKE_LARGE, 0); if (ent) { ent->y.WORD++; } diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index 9e3ad499..e4f2bf30 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -2,6 +2,7 @@ #include "entity.h" #include "random.h" #include "functions.h" +#include "effects.h" extern void sub_0804A4E4(Entity*, Entity*); @@ -40,7 +41,7 @@ void sub_08022254(Entity* this) { break; case 0x16: case 0x1c: - CreateFx(this, 4, 0); + CreateFx(this, FX_ROCK, 0); ent = CreateEnemy(CHUCHU, 1); if (ent) { ent->type2 = 1; diff --git a/src/enemy/slime.c b/src/enemy/slime.c index cd79f8f7..34f9cb55 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -4,6 +4,7 @@ #include "room.h" #include "random.h" #include "functions.h" +#include "effects.h" typedef struct { s8 h, v; @@ -115,7 +116,7 @@ void sub_080450A8(Entity* this) { off++; } - ent = CreateFx(this, 2, 0); + ent = CreateFx(this, FX_DEATH, 0); if (ent) CopyPosition(this, ent); diff --git a/src/enemy/spark.c b/src/enemy/spark.c index e11228e6..71e913c5 100644 --- a/src/enemy/spark.c +++ b/src/enemy/spark.c @@ -2,6 +2,7 @@ #include "entity.h" #include "object.h" #include "functions.h" +#include "effects.h" extern void (*const gUnk_080CD234[])(Entity*); extern void (*const gUnk_080CD24C[])(Entity*); @@ -23,7 +24,7 @@ void sub_0802B2E0(Entity* this) { this->iframes = 0; this->spriteSettings.b.draw = 0; this->action = 2; - ent = CreateFx(this, 2, 0); + ent = CreateFx(this, FX_DEATH, 0); if (ent) { this->attachedEntity = ent; this->actionDelay = 14; diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index a66fe5b3..34beba3a 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -2,6 +2,7 @@ #include "entity.h" #include "random.h" #include "functions.h" +#include "effects.h" extern bool32 sub_0806FC80(Entity*, Entity*, u32); extern Entity* sub_08049DF4(u32); @@ -224,7 +225,7 @@ void sub_08028528(Entity* this) { if ((this->actionDelay & 7) == 0) { EnqueueSFX(0xf0); - CreateFx(this, 2, 0x40); + CreateFx(this, FX_DEATH, 0x40); } if (++this->field_0x7a.HALF.HI == 0x80) { diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index e7e1570b..c4d7037b 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -6,6 +6,7 @@ #include "random.h" #include "utils.h" #include "functions.h" +#include "effects.h" extern void DoExitTransition(ScreenTransitionData*); @@ -1064,7 +1065,7 @@ static inline void deleteThing(Entity* this, const u32 index) { if (index == 1) { this->spriteSettings.b.draw = 0; } - CreateFx(((VaatiArm_HeapStruct*)this->myHeap)->entities[index], 0x51, 0); + CreateFx(((VaatiArm_HeapStruct*)this->myHeap)->entities[index], FX_GIANT_EXPLOSION4, 0); ((VaatiArm_HeapStruct*)this->myHeap)->entities[index]->myHeap = NULL; DeleteEntity(((VaatiArm_HeapStruct*)this->myHeap)->entities[index]); } @@ -1331,7 +1332,7 @@ void sub_08043D08(Entity* this) { entity->spriteSettings.b.draw = 0; InitializeAnimation(entity, 0x13); sub_0804AA1C(entity); - fx = CreateFx(entity, 0x51, 0); + fx = CreateFx(entity, FX_GIANT_EXPLOSION4, 0); if (fx != NULL) { fx->x.HALF.HI += gUnk_080D13E9[this->type2]; fx->y.HALF.HI -= 6; diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index 9df23058..f96527e9 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -6,6 +6,7 @@ #include "audio.h" #include "area.h" #include "functions.h" +#include "effects.h" extern void sub_080AEFB4(Entity*); extern u8 gEntCount; @@ -477,7 +478,7 @@ void VaatiRebornEnemyType0Action7(Entity* this) { SetRoomFlag(1); } else { if ((this->actionDelay & 7) == 0) { - fx = CreateFx(this, 2, 0); + fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { tmp = Random() & 0x3f3f; fx->x.HALF.HI = ((tmp & 0xff) - 0x20) + fx->x.HALF.HI; diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 9efa55e8..94d7935a 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -5,6 +5,7 @@ #include "flags.h" #include "audio.h" #include "functions.h" +#include "effects.h" void sub_080409B0(Entity*); void sub_080408EC(Entity*); @@ -567,7 +568,7 @@ void VaatiTransfiguredType0Action7(Entity* this) { } this->field_0xf = (this->field_0xf + 1) & 7; if (this->field_0xf == 0) { - pEVar3 = CreateFx(this, 0x55, 0); + pEVar3 = CreateFx(this, FX_AURA_BASE, 0); if (pEVar3 != NULL) { uVar4 = Random() & 0x3f3f; pEVar3->x.HALF.HI += (uVar4 & 0xff) - 0x20; diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 6a4df2d7..9e319d8c 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -10,6 +10,7 @@ #include "structures.h" #include "functions.h" #include "save.h" +#include "effects.h" extern u8 gEntCount; @@ -708,7 +709,7 @@ void sub_08041E78(Entity* this) { const s8* temp; if ((this->field_0xf & 0xf) == 0) { - fx = CreateFx(this, 0x51, 0); + fx = CreateFx(this, FX_GIANT_EXPLOSION4, 0); if (fx != NULL) { temp = &gUnk_080D0E90[this->field_0xf >> 3 & 0xe]; fx->x.HALF.HI += *temp++; diff --git a/src/enemy/vaatiWrathEye.c b/src/enemy/vaatiWrathEye.c index 53434faa..2fd855f5 100644 --- a/src/enemy/vaatiWrathEye.c +++ b/src/enemy/vaatiWrathEye.c @@ -2,6 +2,7 @@ #include "audio.h" #include "structures.h" #include "functions.h" +#include "effects.h" void sub_080485D8(Entity*); void sub_080485FC(Entity*); @@ -158,7 +159,7 @@ void VaatiWrathEyeAction7(Entity* this) { this->actionDelay = 0x3c; this->flags &= 0x7f; this->spriteSettings.b.draw = 0; - CreateFx(this, 0x1f, 0x40); + CreateFx(this, FX_REFLECT2, 0x40); this->parent->field_0x7a.HALF.HI |= 0x10 << this->type; } else { if (--this->actionDelay != 0) { diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 247cf0a0..213665c3 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -6,6 +6,7 @@ #include "random.h" #include "createObject.h" #include "functions.h" +#include "effects.h" extern void (*const gUnk_080CEB74[])(Entity*); extern void (*const gUnk_080CEB8C[])(Entity*); @@ -52,7 +53,7 @@ void sub_08033564(Entity* this) { this->flags &= 0x7f; this->iframes = 0; this->spriteSettings.b.draw = FALSE; - ent = CreateFx(this, 2, 0); + ent = CreateFx(this, FX_DEATH, 0); if (ent != NULL) { this->attachedEntity = ent; this->actionDelay = 0xe; diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 0eca0fe9..9cd2ef72 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -2,6 +2,7 @@ #include "audio.h" #include "random.h" #include "functions.h" +#include "effects.h" extern void (*const gUnk_0811BDCC[])(ItemBehavior* beh, u32); @@ -26,10 +27,10 @@ void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { if (((gPlayerState.flags.all & 0x80) == 0) && ((this->field_0x5[2] & 7) == 0)) { if (gPlayerState.field_0x10[2] == 0x11) { if (gPlayerEntity.spriteOffsetY == 0) { - CreateFx(&gPlayerEntity, 0x52, 0); + CreateFx(&gPlayerEntity, FX_GREEN_SPLASH, 0); } } else { - fx = CreateFx(&gPlayerEntity, 0x11, 0x40); + fx = CreateFx(&gPlayerEntity, FX_DASH, 0x40); if ((fx != NULL) && (fx->y.HALF.HI = fx->y.HALF.HI + 2, this->stateID != 2)) { uVar4 = Random() & 3; if ((Random() & 1) != 0) { diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 37067485..6567e840 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -9,6 +9,7 @@ #include "npc.h" #include "audio.h" #include "functions.h" +#include "effects.h" extern void (*gUnk_081115C0[])(Entity*); extern void (*gUnk_081115D0[])(Entity*); @@ -165,7 +166,7 @@ void sub_08068BD0(Entity* this) { void sub_08068BEC(Entity* this, u32 unused) { Entity* target; - target = CreateFx(this, 0x44, 0); + target = CreateFx(this, FX_WHITE_SPLASH, 0); if (target) { target->spritePriority.b0 = 1; PositionRelative(this, target, 0, -0x100000); diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c index b508d100..f78e1d56 100644 --- a/src/npc/castorWildsStatue.c +++ b/src/npc/castorWildsStatue.c @@ -2,6 +2,7 @@ #include "script.h" #include "functions.h" #include "flags.h" +#include "effects.h" extern Hitbox gUnk_08110E94; @@ -87,7 +88,7 @@ void sub_08067534(Entity* this) { Entity* entity; s32 i; for (i = 0; i < 2; ++i) { - entity = CreateFx(this, 2, 0); + entity = CreateFx(this, FX_DEATH, 0); if (entity != NULL) { entity->x.HALF.HI += gUnk_08110E64[i]; entity->y.HALF.HI += 0x1c; diff --git a/src/npc/ezloCap.c b/src/npc/ezloCap.c index 6f1a16bd..3133fc00 100644 --- a/src/npc/ezloCap.c +++ b/src/npc/ezloCap.c @@ -3,6 +3,7 @@ #include "script.h" #include "audio.h" #include "functions.h" +#include "effects.h" const u8 gUnk_08114134[]; const u8 gUnk_08114144[]; @@ -55,7 +56,7 @@ void sub_0806D944(Entity* this) { // Ezlo Angry FX void sub_0806D96C(Entity* this) { - Entity* fx = CreateFx(this, 0x42, 0); + Entity* fx = CreateFx(this, FX_STEAM_EFC, 0); if (fx != NULL) { fx->spritePriority.b0 = 1; PositionRelative(this, fx, 0, 0xFFE80000); diff --git a/src/npc/goron.c b/src/npc/goron.c index 46a6e940..441a80a6 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -3,6 +3,7 @@ #include "functions.h" #include "textbox.h" #include "script.h" +#include "effects.h" extern void (*gUnk_08111A80[])(Entity*); extern void (*gUnk_08111A8C[])(Entity*); @@ -79,13 +80,13 @@ void sub_080693D0(Entity* this) { } void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65) { - Entity* fx = CreateFx(this, 4, 0); + Entity* fx = CreateFx(this, FX_ROCK, 0); if (fx) { PositionRelative(this, fx, offsetX, 0xFFF00000); ResolveEntityOnTop(this, fx); } if (createFx65 != 0) { - fx = CreateFx(this, 65, 0); + fx = CreateFx(this, FX_REFLECT4, 0); if (fx) { PositionRelative(this, fx, offsetX, 0xFFF00000); ResolveEntityOnTop(this, fx); diff --git a/src/npc/mailbox.c b/src/npc/mailbox.c index bab9a8ba..6309b2bd 100644 --- a/src/npc/mailbox.c +++ b/src/npc/mailbox.c @@ -2,6 +2,7 @@ #include "entity.h" #include "textbox.h" #include "functions.h" +#include "effects.h" extern void sub_08063280(); @@ -58,5 +59,5 @@ void sub_08063280(Entity* this, u32 unused) { var = e->frames.all & 0x7F; e->frames.all ^= var; if (var == 2) - CreateFx(e, 49, 0); + CreateFx(e, FX_MAILBOX_UNUSED, 0); } diff --git a/src/npc/melari.c b/src/npc/melari.c index 1e911439..99c04122 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -6,6 +6,7 @@ #include "random.h" #include "audio.h" #include "functions.h" +#include "effects.h" extern void sub_08068780(Entity*); extern s32 sub_0806EDD8(Entity*, u32, u32); @@ -91,7 +92,7 @@ void sub_08068780(Entity* this) { } else { EnqueueSFX(gUnk_08111538[(s32)Random() % 3]); } - ent = CreateFx(this, 0x3d, 0x20); + ent = CreateFx(this, FX_STARS2, 0x20); if (ent != NULL) { PositionRelative(this, ent, 0x180000, -0xa0000); } diff --git a/src/npc/percy.c b/src/npc/percy.c index 5bd1fc37..1317fce2 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -6,6 +6,7 @@ #include "flags.h" #include "script.h" #include "save.h" +#include "effects.h" extern void sub_0806B41C(Entity*); extern void sub_0806B3CC(Entity*); @@ -63,7 +64,7 @@ void sub_0806B41C(Entity* this) { this->action = 1; this->spriteSettings.b.draw = 1; if (this->type2 == 2) { - CreateFx(this, 0x25, 0); + CreateFx(this, FX_SWEAT, 0); } sub_0807DD50(this); } diff --git a/src/npc/postman.c b/src/npc/postman.c index c0708c12..3d61962e 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -9,6 +9,7 @@ #include "save.h" #include "script.h" #include "flags.h" +#include "effects.h" extern void sub_08060528(Entity*); extern void sub_0806EE04(Entity*, void*, u32); @@ -99,7 +100,7 @@ void sub_080604DC(Entity* this) { if (((u32)(this->spriteSettings.raw << 0x1e) >> 0x1e == 1) && sub_080040A8(this)) { if ((this->frames.all & 1) != 0) { this->frames.all &= 0xfe; - ent = CreateFx(this, 0x11, 0x40); + ent = CreateFx(this, FX_DASH, 0x40); if (ent != NULL) { ent->y.HALF.HI++; sub_0805E3A0(ent, 3); diff --git a/src/npc/smith.c b/src/npc/smith.c index c15b1219..55471f6c 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -7,6 +7,7 @@ #include "npc.h" #include "audio.h" #include "functions.h" +#include "effects.h" extern void sub_08078850(Entity*, u32, u32, u32*); @@ -43,7 +44,7 @@ void Smith(Entity* this) { } if ((this->frames.all & 1) != 0) { this->frames.all &= 0xfe; - CreateFx(this, 0x3d, 0x20); + CreateFx(this, FX_STARS2, 0x20); SoundReq(gUnk_08110380[(Random() & 7)]); } } diff --git a/src/npc/stamp.c b/src/npc/stamp.c index 51b209b3..54cc7ec6 100644 --- a/src/npc/stamp.c +++ b/src/npc/stamp.c @@ -3,6 +3,7 @@ #include "textbox.h" #include "functions.h" #include "script.h" +#include "effects.h" extern void sub_08062CA4(); @@ -57,7 +58,7 @@ void sub_08062C7C(Entity* ent) { ent->action = 1; sub_0807DD64(ent); InitializeAnimation(ent, 0); - CreateFx(ent, 37, 0); + CreateFx(ent, FX_SWEAT, 0); sub_08062CA4(ent); } diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index de089fbe..3db8fd02 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -9,6 +9,7 @@ #include "random.h" #include "structures.h" #include "functions.h" +#include "effects.h" typedef struct { u8 frame1; @@ -228,7 +229,7 @@ void sub_08061E90(Entity* this, Entity* arg1) { void sub_08061F94(Entity* this) { Entity* ent; - ent = CreateFx(this, 0x35, 0); + ent = CreateFx(this, FX_BIG_EXPLOSION, 0); if (ent != NULL) { ResolveEntityOnTop(this, ent); } diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c index 866309ae..9a06d4ff 100644 --- a/src/object/bigVortex.c +++ b/src/object/bigVortex.c @@ -3,6 +3,7 @@ #include "flags.h" #include "object.h" #include "functions.h" +#include "effects.h" extern void sub_08098E3C(Entity*); extern void sub_08098E88(Entity*); @@ -43,7 +44,7 @@ void sub_08098D6C(Entity* this) { if (CheckFlags(this->field_0x86.HWORD)) { this->action = 2; this->actionDelay = 0x2d; - ent = CreateFx(this, 0x43, 0); + ent = CreateFx(this, FX_BIG_EXPLOSION2, 0); if (ent != NULL) { ent->y.HALF.HI += 8; } diff --git a/src/object/bird.c b/src/object/bird.c index 3d1558e3..0dad159f 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -6,6 +6,7 @@ #include "random.h" #include "object.h" #include "functions.h" +#include "effects.h" extern void (*const gUnk_08123EC0[])(Entity*); extern void (*const gUnk_08123EEC[])(Entity*); @@ -99,7 +100,7 @@ void sub_0809D0AC(Entity* this) { this->collisionLayer = 1; SetLocalFlag(0x45); SoundReq(SFX_SECRET); - fx = CreateFx(this, 0x11, 0); + fx = CreateFx(this, FX_DASH, 0); if (fx != NULL) { sub_0806FAD8(this, fx); } diff --git a/src/object/book.c b/src/object/book.c index b51c4716..356b85d9 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -5,6 +5,7 @@ #include "flags.h" #include "room.h" #include "textbox.h" +#include "effects.h" extern void (*const BookActionFuncs[])(Entity*); extern s8 const gUnk_08123D94[]; @@ -135,7 +136,7 @@ void sub_0809B56C(Entity* this) { SetFlag(this->field_0x86.HWORD); - fx = CreateFx(this, 2, 0); + fx = CreateFx(this, FX_DEATH, 0); if (fx) { ResolveEntityOnTop(this, fx); } diff --git a/src/object/button.c b/src/object/button.c index 5111575e..52876a45 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -4,6 +4,7 @@ #include "room.h" #include "audio.h" #include "functions.h" +#include "effects.h" extern void (*const gUnk_0811EE38[])(Entity*); @@ -231,13 +232,13 @@ u32 sub_08081F00(u32* unk1, u32* unk2) { } void sub_08081F24(Entity* this) { - Entity* fx = CreateFx(this, 0x11, 0x40); + Entity* fx = CreateFx(this, FX_DASH, 0x40); if (fx) { fx->scriptedScene = 3; fx->x.HALF.HI += 7; fx->y.HALF.HI += 5; } - fx = CreateFx(this, 0x11, 0x40); + fx = CreateFx(this, FX_DASH, 0x40); if (fx) { fx->scriptedScene = 3; fx->x.HALF.HI -= 7; diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index f7918284..d82a3e3d 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -4,6 +4,7 @@ #include "game.h" #include "audio.h" #include "functions.h" +#include "effects.h" void sub_08083338(Entity*); void sub_080834B4(Entity*); @@ -315,12 +316,12 @@ u32 sub_080837B0(Entity* this) { void sub_08083814(Entity* this, u32 unk0) { Entity* fx; const struct_0811F730* tmp = &gUnk_0811F730[unk0]; - fx = CreateFx(this, 0x11, 0x40); + fx = CreateFx(this, FX_DASH, 0x40); if (fx) { fx->x.HALF.HI += tmp->unk_00.x; fx->y.HALF.HI += tmp->unk_00.y; } - fx = CreateFx(this, 0x11, 0x40); + fx = CreateFx(this, 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/mask.c b/src/object/mask.c index b6d06206..05a49fb7 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -6,6 +6,7 @@ #include "player.h" #include "flags.h" #include "functions.h" +#include "effects.h" extern void (*MaskActionFuncs[])(Entity*); @@ -111,7 +112,7 @@ void sub_08092B0C(Entity* this) { break; } - CreateFx(this, 5, 0); + CreateFx(this, FX_POT_SHATTER, 0); sub_0805457C(this, 3); } else { diff --git a/src/object/metalDoor.c b/src/object/metalDoor.c index 475a35ac..a65cf709 100644 --- a/src/object/metalDoor.c +++ b/src/object/metalDoor.c @@ -4,6 +4,7 @@ #include "flags.h" #include "audio.h" #include "functions.h" +#include "effects.h" extern u32 sub_08083734(Entity*, u32); extern void sub_080A080C(Entity*); @@ -56,12 +57,12 @@ void sub_080A074C(Entity* this) { this->height.HALF.HI = 0; this->x.HALF.HI = this->field_0x70.HALF.LO; this->y.HALF.HI = this->field_0x70.HALF.HI; - ent = CreateFx(this, 0x11, 0x40); + ent = CreateFx(this, FX_DASH, 0x40); if (ent != NULL) { ent->x.HALF.HI += 0xc; ent->y.HALF.HI -= 0xc; } - ent = CreateFx(this, 0x11, 0x40); + ent = CreateFx(this, FX_DASH, 0x40); if (ent != NULL) { ent->x.HALF.HI -= 0xc; ent->y.HALF.HI -= 0xc; diff --git a/src/object/objectA2.c b/src/object/objectA2.c index 2cc132fe..73cb101f 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -5,6 +5,7 @@ #include "audio.h" #include "structures.h" #include "functions.h" +#include "effects.h" void sub_0809F318(Entity*); void sub_0809F374(Entity*); @@ -85,7 +86,7 @@ void sub_0809F408(Entity* this) { switch (this->frames.all) { case 9: this->frames.all = 0; - CreateFx(this, 0x43, 0); + CreateFx(this, FX_BIG_EXPLOSION2, 0); gMenu.field_0x0 = 1; break; case 0x80: diff --git a/src/object/pot.c b/src/object/pot.c index 7aff3672..f3423433 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -5,6 +5,7 @@ #include "room.h" #include "object.h" #include "functions.h" +#include "effects.h" void sub_08082824(Entity*); static void sub_08082850(Entity*, Entity*); @@ -97,7 +98,7 @@ void sub_08082310(Entity* this) { break; default: if (sub_080002B8(this) == 13) { - CreateFx(this, 0, 0); + CreateFx(this, FX_FALL_DOWN, 0); } else if (tileType == 0x4005) { gPlayerState.field_0xab = 4; SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); @@ -137,13 +138,13 @@ void sub_08082588(Entity* this) { void sub_0808259C(Entity* this) { switch (sub_080043E8(this)) { case 2: - CreateFx(this, 11, 0); + CreateFx(this, FX_WATER_SPLASH, 0); break; case 1: - CreateFx(this, 0, 0); + CreateFx(this, FX_FALL_DOWN, 0); break; case 3: - CreateFx(this, 12, 0); + CreateFx(this, FX_LAVA_SPLASH, 0); break; default: sub_08082850(this, &gPlayerEntity); @@ -261,7 +262,7 @@ void sub_08082824(Entity* this) { 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, 5, parameter); + Entity* fxEntity = CreateFx(this, FX_POT_SHATTER, parameter); if (fxEntity) { fxEntity->parent = parent; } diff --git a/src/object/treeHidingPortal.c b/src/object/treeHidingPortal.c index 53f593bb..dcaf3ebc 100644 --- a/src/object/treeHidingPortal.c +++ b/src/object/treeHidingPortal.c @@ -6,6 +6,7 @@ #include "room.h" #include "structures.h" #include "functions.h" +#include "effects.h" extern void sub_0809E96C(Entity*); extern void CreateSparkle(Entity*); @@ -70,7 +71,7 @@ void sub_0809E918(Entity* this) { Entity* fx; s16* i = gUnk_08124364; while (*i != -1000) { - fx = CreateFx(this, 3, 0); + fx = CreateFx(this, FX_BUSH, 0); if (fx != NULL) { fx->x.HALF.HI += i[0]; fx->y.HALF.HI += i[1]; diff --git a/src/object/windcrest.c b/src/object/windcrest.c index 91bdb37a..3ebaef24 100644 --- a/src/object/windcrest.c +++ b/src/object/windcrest.c @@ -4,6 +4,7 @@ #include "save.h" #include "script.h" #include "functions.h" +#include "effects.h" extern void sub_08078850(Entity*, u32, u32, u8*); @@ -26,5 +27,5 @@ void sub_080A2124(Entity* this) { void Windcrest_Unlock(Entity* this) { SoundReq(SFX_SECRET); gSave.windcrests = gSave.windcrests | 1 << (this->type2 + 0x18); - CreateFx(this, 0x46, 0); + CreateFx(this, FX_GIANT_EXPLOSION, 0); } diff --git a/src/player.c b/src/player.c index 92ddc33d..655f4a28 100644 --- a/src/player.c +++ b/src/player.c @@ -10,6 +10,7 @@ #include "object.h" #include "functions.h" #include "object.h" +#include "effects.h" static void (*const sPlayerActions[])(Entity*); extern void (*const gUnk_0811BA60[])(Entity*); @@ -501,7 +502,7 @@ void sub_0807127C(Entity* this) { if ((gPlayerState.flags.all & 0x10000) == 0) sub_08004168(this); - CreateFx(this, 11, 0); + CreateFx(this, FX_WATER_SPLASH, 0); if ((gPlayerState.flags.all & 8) == 0) gPlayerState.field_0x8 = 0x72c; @@ -1143,7 +1144,7 @@ void sub_08072008(Entity* this) { this->flags |= 0x80; this->spriteOffsetX = 0; gPlayerState.flags.all &= ~(0x800 | 0x1); - CreateFx(this, 0xd, 0); + CreateFx(this, FX_ICE, 0); sub_080791BC(); } @@ -1305,7 +1306,7 @@ void sub_08072354(Entity* this) { gPlayerState.field_0x8 = 0x2c1; gPlayerState.flags.all &= ~0x400; UpdateSpriteForCollisionLayer(this); - CreateFx(this, 0xc, 0); + CreateFx(this, FX_LAVA_SPLASH, 0); SoundReq(SFX_1A6); } @@ -1459,7 +1460,7 @@ void sub_080726F4(Entity* this) { this->direction = (this->animationState & 6) << 2; if (((gPlayerState.flags.all & 0x80) == 0) && (--this->actionDelay == 0xff)) { - CreateFx(&gPlayerEntity, 0x11, 0x40); + CreateFx(&gPlayerEntity, FX_DASH, 0x40); this->actionDelay = 4; } if ((gPlayerState.flags.all & 2) == 0) { diff --git a/src/playerItem/playerItem14.c b/src/playerItem/playerItem14.c index 5883ccc2..dca41640 100644 --- a/src/playerItem/playerItem14.c +++ b/src/playerItem/playerItem14.c @@ -3,6 +3,7 @@ #include "functions.h" #include "player.h" #include "room.h" +#include "effects.h" extern void (*const gUnk_08109AC8[])(Entity*); extern Hitbox gUnk_08109AD0; @@ -46,11 +47,11 @@ void sub_0805FC74(Entity* this) { } if (!sub_080002F0(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) && sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI)) { - CreateFx(this, 0x19, 0); + CreateFx(this, FX_SWORD_MAGIC, 0); DeleteThisEntity(); } if (this->bitfield != 0) { - CreateFx(this, 0x19, 0); + CreateFx(this, FX_SWORD_MAGIC, 0); DeleteThisEntity(); } } else { diff --git a/src/playerItem/playerItemBow.c b/src/playerItem/playerItemBow.c index 351a2907..7f6aaf22 100644 --- a/src/playerItem/playerItemBow.c +++ b/src/playerItem/playerItemBow.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "functions.h" +#include "effects.h" extern void (*const gUnk_080B3E30[])(Entity*); @@ -33,6 +34,6 @@ void sub_08019444(Entity* this) { void sub_08019468(Entity* this) { if (this->field_0x40 == 0x0e) { - CreateFx(this, 0x50, 0); + CreateFx(this, FX_REFLECT5, 0); } } diff --git a/src/playerItem/playerItemSwordBeam.c b/src/playerItem/playerItemSwordBeam.c index 7329b69b..8fb41232 100644 --- a/src/playerItem/playerItemSwordBeam.c +++ b/src/playerItem/playerItemSwordBeam.c @@ -3,6 +3,7 @@ #include "coord.h" #include "functions.h" #include "audio.h" +#include "effects.h" extern void (*const gUnk_080B43F4[])(Entity*); @@ -70,11 +71,11 @@ void sub_08019580(Entity* this) { } if ((sub_080002F0(TILE(this->x.HALF.HI, this->y.HALF.HI), gPlayerEntity.collisionLayer, 0x80) == 0) && (sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI) != 0)) { - CreateFx(this, 0x19, 0); + CreateFx(this, FX_SWORD_MAGIC, 0); DeleteThisEntity(); } if (this->bitfield != 0) { - CreateFx(this, 0x19, 0); + CreateFx(this, FX_SWORD_MAGIC, 0); DeleteThisEntity(); } if (sub_08008790(this, 0xc) != NULL) { diff --git a/src/projectile/cannonballProjectile.c b/src/projectile/cannonballProjectile.c index 8c6e7da4..150d5fe3 100644 --- a/src/projectile/cannonballProjectile.c +++ b/src/projectile/cannonballProjectile.c @@ -1,6 +1,7 @@ #include "entity.h" #include "enemy.h" #include "functions.h" +#include "effects.h" extern void CreateItemOnGround(Entity*); extern s32 sub_080AF090(Entity*); @@ -46,7 +47,7 @@ void CannonballProjectile_Init(Entity* this) { void CannonballProjectile_Action1(Entity* this) { GetNextFrame(this); if (sub_080AF090(this) == 0) { - CreateFx(this, 2, 0); + CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } sub_080AB5F4(this); @@ -56,7 +57,7 @@ void CannonballProjectile_Action2(Entity* this) { GetNextFrame(this); sub_080AF090(this); if ((sub_080AB634(this) == 0) && (this->collisions != 0)) { - CreateFx(this, 2, 0); + CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } } @@ -85,7 +86,7 @@ bool32 sub_080AB634(Entity* this) { entities[i]->action = 3; entities[i]->actionDelay = 0x1e; entities[i]->spriteSettings.b.draw = 0; - CreateFx(entities[i], 0x45, 0); + CreateFx(entities[i], FX_WHITE_ROCK, 0); } DeleteEntity(this); return TRUE; diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index fd2765e7..371473da 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -3,6 +3,7 @@ #include "player.h" #include "coord.h" #include "functions.h" +#include "effects.h" extern void sub_08078954(Entity*); @@ -129,13 +130,13 @@ void DirtBallProjectile_Action2(Entity* this) { if (tmp != 0) { switch (tmp) { case 2: - CreateFx(this, 0xb, 0); + CreateFx(this, FX_WATER_SPLASH, 0); break; case 1: - CreateFx(this, 0, 0); + CreateFx(this, FX_FALL_DOWN, 0); break; case 3: - CreateFx(this, 0xc, 0); + CreateFx(this, FX_LAVA_SPLASH, 0); break; } DeleteThisEntity(); @@ -148,7 +149,7 @@ void DirtBallProjectile_Action2(Entity* this) { this->action = 3; return; case 2: - entity = CreateFx(this, 5, 0x80); + entity = CreateFx(this, FX_POT_SHATTER, 0x80); if (entity != NULL) { entity->parent = NULL; } diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index 287b0013..d8eeff71 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -5,6 +5,7 @@ #include "functions.h" #include "random.h" #include "audio.h" +#include "effects.h" extern void sub_0806F5BC(Entity*, u32, u32); extern u32 sub_080041DC(Entity*, u32, u32); @@ -90,7 +91,7 @@ void GleerokProjectile_Action1(Entity* this) { if (this->type == 3) { if (sub_08003FC4(this, 0x1800) == 0) { sub_08008790(this, 7); - CreateFx(this, 4, 0); + CreateFx(this, FX_ROCK, 0); DeleteThisEntity(); } } else { diff --git a/src/projectile/lakituCloudProjectile.c b/src/projectile/lakituCloudProjectile.c index 76ac9ea5..25599826 100644 --- a/src/projectile/lakituCloudProjectile.c +++ b/src/projectile/lakituCloudProjectile.c @@ -2,6 +2,7 @@ #include "enemy.h" #include "functions.h" #include "player.h" +#include "effects.h" extern void sub_0800449C(Entity*, u32); extern void sub_08079D84(void); @@ -26,7 +27,7 @@ void nullsub_539(Entity* this) { void sub_080A9CF0(Entity* this) { if (sub_0806F520() == 0) { - CreateFx(this, 2, 0); + CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } LakituCloudProjectile_SubActions[this->subAction](this); @@ -46,7 +47,7 @@ void LakituCloudProjectile_SubAction2(Entity* this) { sub_0800449C(&gPlayerEntity, 0x7a); sub_08079D84(); } - CreateFx(this, 2, 0); + CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } } diff --git a/src/projectile/lakituLightning.c b/src/projectile/lakituLightning.c index 8d055ba6..975491c2 100644 --- a/src/projectile/lakituLightning.c +++ b/src/projectile/lakituLightning.c @@ -1,5 +1,6 @@ #include "entity.h" #include "enemy.h" +#include "effects.h" extern s32 sub_080AF090(Entity*); extern s32 sub_080A7EB0(Entity*); @@ -35,7 +36,7 @@ void LakituLightning_Action1(Entity* this) { GetNextFrame(this); sub_080AF090(this); if ((this->collisions != 0) || (--this->actionDelay == 0)) { - CreateFx(this, 0x4f, 0); + CreateFx(this, FX_BLUE_EFC, 0); DeleteThisEntity(); } if (sub_080A7EB0(this) != 0) { diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 5d41b4f1..6f677525 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -3,6 +3,7 @@ #include "random.h" #include "functions.h" #include "audio.h" +#include "effects.h" void OctorokBossProjectile_Action2(Entity*); extern void sub_080AE58C(Entity*, u32, u32); @@ -183,14 +184,14 @@ void OctorokBossProjectile_Action1(Entity* this) { if (sub_08003FC4(this, 0x1800) != 0) { return; } - CreateFx(this, 4, 0); + CreateFx(this, FX_ROCK, 0); DeleteThisEntity(); break; } } void OctorokBossProjectile_Action2(Entity* this) { - CreateFx(this, 4, 0); + CreateFx(this, FX_ROCK, 0); DeleteThisEntity(); } diff --git a/src/projectile/stalfosProjectile.c b/src/projectile/stalfosProjectile.c index c743fcbc..0c48006f 100644 --- a/src/projectile/stalfosProjectile.c +++ b/src/projectile/stalfosProjectile.c @@ -1,6 +1,7 @@ #include "entity.h" #include "enemy.h" #include "functions.h" +#include "effects.h" extern void (*const StalfosProjectile_Functions[])(Entity*); extern void (*const StalfosProjectile_Actions[])(Entity*); @@ -126,9 +127,9 @@ void StalfosProjectile_Action3(Entity* this) { void sub_080A9BA8(Entity* this) { if (this->type == 0) { - CreateFx(this, 5, 0); + CreateFx(this, FX_POT_SHATTER, 0); } else { - CreateFx(this, 0x3c, 0); + CreateFx(this, FX_BONE, 0); } DeleteThisEntity(); } diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index 0420790b..ffb558a1 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -4,6 +4,7 @@ #include "functions.h" #include "random.h" #include "audio.h" +#include "effects.h" extern void (*const V2Projectile_Functions[])(Entity*); extern void (*const gUnk_0812A7EC[])(Entity*); @@ -26,7 +27,7 @@ ASM_FUNC("asm/non_matching/v2Projectile/sub_080ABBF4.inc", void sub_080ABBF4(Ent void sub_080ABC54(Entity* this) { if (sub_0806F520() == 0) { - CreateFx(this, 2, 0); + CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } gUnk_0812A808[this->subAction](this); @@ -44,7 +45,7 @@ void sub_080ABC90(Entity* this) { ModHealth(-2); sub_0800449C(&gPlayerEntity, 0x7a); sub_08079D84(); - CreateFx(this, 2, 0); + CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } } @@ -96,7 +97,7 @@ ASM_FUNC("asm/non_matching/v2Projectile/sub_080ABE04.inc", void sub_080ABE04(Ent void sub_080ABE88(Entity* this) { if (sub_08003FC4(this, 0x1800) == 0) { - CreateFx(this, 4, 0); + CreateFx(this, FX_ROCK, 0); DeleteThisEntity(); } } diff --git a/src/projectile/v3TennisBallProjectile.c b/src/projectile/v3TennisBallProjectile.c index 82d64a3c..d2c4ef74 100644 --- a/src/projectile/v3TennisBallProjectile.c +++ b/src/projectile/v3TennisBallProjectile.c @@ -2,6 +2,7 @@ #include "enemy.h" #include "audio.h" #include "functions.h" +#include "effects.h" extern s32 sub_080AF090(Entity*); extern s32 sub_080A7EB0(Entity*); @@ -56,7 +57,7 @@ void sub_080ACB90(Entity* this) { Entity* parent = this->parent; if ((this->x.HALF.HI == parent->x.HALF.HI) && (this->y.HALF.HI <= parent->y.HALF.HI)) { parent->field_0xf = 1; - CreateFx(this, 0x1f, 0x40); + CreateFx(this, FX_REFLECT2, 0x40); EnqueueSFX(SFX_ITEM_GLOVES_KNOCKBACK); DeleteThisEntity(); } diff --git a/src/room.c b/src/room.c index 6e1c44d5..227073c2 100644 --- a/src/room.c +++ b/src/room.c @@ -13,6 +13,7 @@ #include "script.h" #include "random.h" #include "functions.h" +#include "effects.h" void sub_0804B3C4(void* arg0) { sub_0804B29C(arg0); @@ -5825,7 +5826,7 @@ void sub_0804F5E8(void) { void sub_0804F680(Entity* parent, s32 x, s32 y) { Entity* fx; - fx = CreateFx(parent, 2, 0); + fx = CreateFx(parent, FX_DEATH, 0); if (fx != NULL) { fx->x.HALF.HI = gRoomControls.roomOriginX + x; fx->y.HALF.HI = gRoomControls.roomOriginY + y; @@ -5866,13 +5867,13 @@ void sub_0804F760(Entity* this) { void sub_0804F79C(Entity* parent) { Entity* fx; - fx = CreateFx(parent, 0x35, 0); + fx = CreateFx(parent, FX_BIG_EXPLOSION, 0); if (fx != NULL) { fx->spriteRendering.b3 = 0; fx->x.HALF.HI = gRoomControls.roomOriginX + 0x1b8; fx->y.HALF.HI = gRoomControls.roomOriginY + 0x148; } - fx = CreateFx(parent, 0x35, 0); + fx = CreateFx(parent, FX_BIG_EXPLOSION, 0); if (fx != NULL) { fx->spriteRendering.b3 = 0; fx->x.HALF.HI = gRoomControls.roomOriginX + 0x238; diff --git a/src/script.c b/src/script.c index 9529156f..fd1c2dcf 100644 --- a/src/script.c +++ b/src/script.c @@ -12,6 +12,7 @@ #include "audio.h" #include "functions.h" #include "main.h" +#include "effects.h" void InitScriptForEntity(Entity*, ScriptExecutionContext*, u16*); void InitScriptExecutionContext(ScriptExecutionContext* context, u16* script); @@ -1684,7 +1685,7 @@ void sub_0807F360(Entity* entity, ScriptExecutionContext* context) { void sub_0807F36C(Entity* entity, ScriptExecutionContext* context) { Entity* fx; - fx = CreateFx(entity, 0x41, 0); + fx = CreateFx(entity, FX_REFLECT4, 0); if (fx != NULL) { fx->spritePriority.b0 = 1; PositionRelative(entity, fx, 0, -524288); From 6ecaea44c5944acd4a5e8e11582e280e69e22e08 Mon Sep 17 00:00:00 2001 From: theo3 Date: Tue, 26 Oct 2021 22:06:24 -0700 Subject: [PATCH 2/4] add tiles.h --- asm/code_08050038.s | 4 +-- asm/macros/scripts.inc | 2 +- data/scripts/script_0801232C.inc | 4 +-- data/scripts/script_08012430.inc | 2 +- data/scripts/script_0801319A.inc | 4 +-- data/scripts/script_08016384.inc | 2 +- include/main.h | 2 +- include/structures.h | 6 ++--- include/tiles.h | 18 +++++++++++++ src/audio.c | 4 +-- src/game.c | 4 +-- src/intro.c | 4 +-- src/main.c | 2 +- src/manager/managerF.c | 3 ++- src/script.c | 8 +++--- src/sub_08050008.c | 2 +- src/sub_0805E374.c | 2 +- src/sub_0807B820.c | 46 ++++++++++++++++---------------- src/sub_080A554C.c | 2 +- src/sub_08127D30.c | 3 --- 20 files changed, 69 insertions(+), 55 deletions(-) create mode 100644 include/tiles.h diff --git a/asm/code_08050038.s b/asm/code_08050038.s index 6f789d02..9e01870f 100644 --- a/asm/code_08050038.s +++ b/asm/code_08050038.s @@ -5,8 +5,8 @@ .text - thumb_func_start sub_08050154 -sub_08050154: @ 0x08050154 + thumb_func_start UpdateFade +UpdateFade: @ 0x08050154 push {r4, r5, r6, lr} ldr r4, _08050180 @ =gFadeControl ldrh r0, [r4, #8] diff --git a/asm/macros/scripts.inc b/asm/macros/scripts.inc index 240d481d..c165f8fe 100644 --- a/asm/macros/scripts.inc +++ b/asm/macros/scripts.inc @@ -329,7 +329,7 @@ .2byte \s .endm -.macro _0807E788 w:req +.macro SetFadeMask w:req .2byte 0x0c39 .4byte \w .endm diff --git a/data/scripts/script_0801232C.inc b/data/scripts/script_0801232C.inc index cca78f35..543e73ed 100644 --- a/data/scripts/script_0801232C.inc +++ b/data/scripts/script_0801232C.inc @@ -31,7 +31,7 @@ script_08012368: StopBgm BeginBlock _0807E778 0x0004 - _0807E788 0x00007fff + SetFadeMask 0x00007fff DoFade5 _0807E858 0x0080 EndBlock @@ -55,7 +55,7 @@ script_08012368: Wait 0x003c BeginBlock _0807E778 0x0004 - _0807E788 0xffffffff + SetFadeMask 0xffffffff DoFade4 _0807E858 0x0080 EndBlock diff --git a/data/scripts/script_08012430.inc b/data/scripts/script_08012430.inc index c18f6787..fbc1bae5 100644 --- a/data/scripts/script_08012430.inc +++ b/data/scripts/script_08012430.inc @@ -77,7 +77,7 @@ script_0801248A: MoveEntityToPlayer Call sub_0807F844 CameraTargetPlayer - _0807E788 0xffffffff + SetFadeMask 0xffffffff _0807E778 0x0004 _0807E800 0x00000000 WaitFor_2 diff --git a/data/scripts/script_0801319A.inc b/data/scripts/script_0801319A.inc index 4e7727b2..d3bac5c5 100644 --- a/data/scripts/script_0801319A.inc +++ b/data/scripts/script_0801319A.inc @@ -49,7 +49,7 @@ SCRIPT_START script_080131AC _0807EA94 _0807E5F8 0x00000020 WaitForSomething2 0x00000040 - _0807E788 0xffff7fff + SetFadeMask 0xffff7fff _0807E778 0x0004 DoFade5 WaitFor_2 @@ -60,7 +60,7 @@ SCRIPT_START script_080131AC Call sub_0807F5C0 TextboxNoOverlapFollowPos 0x1604, 0x0007 _0807EA94 - _0807E788 0xffffffff + SetFadeMask 0xffffffff _0807E778 0x0004 DoFade4 WaitFor_2 diff --git a/data/scripts/script_08016384.inc b/data/scripts/script_08016384.inc index 7887a419..cb512c2e 100644 --- a/data/scripts/script_08016384.inc +++ b/data/scripts/script_08016384.inc @@ -62,4 +62,4 @@ SCRIPT_START script_08016384 WaitFor_1 WaitFor_2 _0807E778 0x0004 - _0807E788 0x0000ffff + SetFadeMask 0x0000ffff diff --git a/include/main.h b/include/main.h index 679fd35f..0d3643ae 100644 --- a/include/main.h +++ b/include/main.h @@ -89,7 +89,7 @@ extern void DoSoftReset(void); extern void sub_08056260(void); extern void VBlankIntrWait(); extern void MessageUpdate(void); -extern void sub_08050154(void); +extern void UpdateFade(void); extern u8 gUnk_03003DE4; diff --git a/include/structures.h b/include/structures.h index 86962b43..5298e1f5 100644 --- a/include/structures.h +++ b/include/structures.h @@ -93,7 +93,7 @@ typedef struct { u8 field_0x1; u8 field_0x2; u8 field_0x3; - u32 field_0x4; + u32 mask; u16 fadeType; // fade in or out, are there others? u16 fadeSpeed; // subtracted from duration u16 fadeDuration; @@ -103,9 +103,9 @@ typedef struct { s16 field_0x14; u16 field_0x16; u16 field_0x18; -} struct_03000FD0; +} FadeControl; -extern struct_03000FD0 gFadeControl; +extern FadeControl gFadeControl; typedef struct { u8 filler0[0x1A]; diff --git a/include/tiles.h b/include/tiles.h new file mode 100644 index 00000000..9915face --- /dev/null +++ b/include/tiles.h @@ -0,0 +1,18 @@ +#ifndef TILES_H +#define TILES_H + +typedef enum { + CUT_BUSH = 0x1C, + CUT_GRASS = 0x1D, + CUT_SIGNPOST = 0x1E, + CUT_TREE = 0x1F, + ROCK = 0x55, + CHEST = 0x73, + SIGNPOST = 0x176, + PERMA_ROCK = 0x1D3, + PERMA_ROCK2 = 0x1D4, + PERMA_ROCK3 = 0x1D5, + PERMA_ROCK4 = 0x1D6, +} Tile; + +#endif // TILES_H diff --git a/src/audio.c b/src/audio.c index e8301fd6..32cd2f11 100644 --- a/src/audio.c +++ b/src/audio.c @@ -198,7 +198,6 @@ s32 fade(s32 target, s32 current) { void doPlaySound(u32 sound) { u32 volume; - u32 iVar2; MusicPlayerInfo* musicPlayerInfo; if (sound == 0) @@ -209,8 +208,7 @@ void doPlaySound(u32 sound) { } else { volume = gSoundPlayingInfo.volumeSfx; } - iVar2 = gSoundPlayingInfo.volumeMaster; - volume = iVar2 * volume / 0x100; + volume = gSoundPlayingInfo.volumeMaster * volume / 0x100; musicPlayerInfo = gMusicPlayers[gSongTable[sound].musicPlayerIndex].info; m4aMPlayImmInit(musicPlayerInfo); m4aMPlayVolumeControl(musicPlayerInfo, 0xffff, volume); diff --git a/src/game.c b/src/game.c index 69f344b8..ee37c155 100644 --- a/src/game.c +++ b/src/game.c @@ -67,7 +67,7 @@ void sub_0805212C(void) { #else sub_08052418(0, 0); gScreen.lcd.displayControl |= 0x600; - gFadeControl.field_0x4 = 0xffff; + gFadeControl.mask = 0x0000ffff; DoFade(4, 0x10); #endif } @@ -97,7 +97,7 @@ void sub_080521A0(void) { gMenu.field_0x3 = 0; sub_080A7114(1); sub_08052418(0, 0); - gFadeControl.field_0x4 = 0xffffffff; + gFadeControl.mask = 0xffffffff; break; case 1: if (gMenu.transitionTimer == 0) { diff --git a/src/intro.c b/src/intro.c index a181800e..55e7cad6 100644 --- a/src/intro.c +++ b/src/intro.c @@ -285,7 +285,7 @@ static void HandleJapaneseTitlescreenAnimationIntro(void) { gIntroState.subState++; gScreen.bg.bg1yOffset = 0; gScreen.bg.bg1Control = 0xc09; - gFadeControl.field_0x4 = 0x40; + gFadeControl.mask = 0x00000040; DoFade(6, 0x10); SoundReq(SFX_F8); } @@ -293,7 +293,7 @@ static void HandleJapaneseTitlescreenAnimationIntro(void) { break; case 1: if (!gFadeControl.active) { - gFadeControl.field_0x4 = -1; + gFadeControl.mask = 0xFFFFFFFF; gIntroState.subState++; #if defined(JP) || defined(EU) gIntroState.timer = 120; diff --git a/src/main.c b/src/main.c index 421fe0f1..08a6f0fc 100644 --- a/src/main.c +++ b/src/main.c @@ -81,7 +81,7 @@ void AgbMain(void) { gMain.ticks++; sScreenHandlers[gMain.screen](); MessageUpdate(); - sub_08050154(); + UpdateFade(); SoundLoop(); break; } diff --git a/src/manager/managerF.c b/src/manager/managerF.c index d7e1d7bb..76e49700 100644 --- a/src/manager/managerF.c +++ b/src/manager/managerF.c @@ -9,6 +9,7 @@ #include "textbox.h" #include "script.h" #include "utils.h" +#include "tiles.h" void sub_08058ECC(ManagerF*); @@ -335,7 +336,7 @@ void sub_0805930C(ManagerF* this) { } void SetDirtTile(u32 tile) { - SetTileType(0x1d, tile, 1); + SetTileType(CUT_GRASS, tile, 1); SetTileType(0, tile, 2); SetTileType(0, tile - 0x40, 2); } diff --git a/src/script.c b/src/script.c index fd1c2dcf..16cdac39 100644 --- a/src/script.c +++ b/src/script.c @@ -75,7 +75,7 @@ void ScriptCommand_WaitForPlayerAction0x17(Entity* entity, ScriptExecutionContex void ScriptCommand_WaitFor_1(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_WaitFor_2(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_0807E778(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_0807E788(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_SetFadeMask(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_0807E79C(Entity* entity, ScriptExecutionContext* context); void ScriptCommandNop2(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_DoFade4(Entity* entity, ScriptExecutionContext* context); @@ -220,7 +220,7 @@ const ScriptCommand gScriptCommands[] = { ScriptCommandNop, ScriptCommand_WaitFor_1, ScriptCommand_WaitFor_2, ScriptCommand_0807E778, - ScriptCommand_0807E788, + ScriptCommand_SetFadeMask, ScriptCommand_0807E79C, ScriptCommandNop2, ScriptCommand_DoFade4, @@ -1005,8 +1005,8 @@ void ScriptCommand_0807E778(Entity* entity, ScriptExecutionContext* context) { gActiveScriptInfo.unk_08 = context->scriptInstructionPointer[1]; } -void ScriptCommand_0807E788(Entity* entity, ScriptExecutionContext* context) { - gFadeControl.field_0x4 = GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer); +void ScriptCommand_SetFadeMask(Entity* entity, ScriptExecutionContext* context) { + gFadeControl.mask = GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer); } void ScriptCommand_0807E79C(Entity* entity, ScriptExecutionContext* context) { diff --git a/src/sub_08050008.c b/src/sub_08050008.c index df79883a..580c3a32 100644 --- a/src/sub_08050008.c +++ b/src/sub_08050008.c @@ -6,5 +6,5 @@ extern u32 gUnk_020354C0; void sub_08050008() { MemClear(&gUnk_020354C0, 128); - gFadeControl.field_0x4 = -1; + gFadeControl.mask = 0xFFFFFFFF; } diff --git a/src/sub_0805E374.c b/src/sub_0805E374.c index e035ce07..3ec3e287 100644 --- a/src/sub_0805E374.c +++ b/src/sub_0805E374.c @@ -9,7 +9,7 @@ Entity* sub_0805E374(Entity* param_1) { u8 r3 = gScreenTransition.field_0x24[8]; u8* array = gUnk_081091F8; - if (r3 != '\x02') { + if (r3 != 2) { array = gUnk_081091EE; } return sub_0805E3A0(param_1, array[param_1->kind]); diff --git a/src/sub_0807B820.c b/src/sub_0807B820.c index fabdc8d9..14da7b18 100644 --- a/src/sub_0807B820.c +++ b/src/sub_0807B820.c @@ -9,46 +9,46 @@ void sub_0807B7D8(u32 param_1, u32 param_2, u32 param_3) { sub_08000152(53); sub_0807B778(param_2, param_3); sub_0807B778(param_2 + 1, param_3); - sub_0807B778(param_2 + -1, param_3); + sub_0807B778(param_2 - 1, param_3); sub_0807B778(param_2 + 64, param_3); - sub_0807B778(param_2 + -64, param_3); + sub_0807B778(param_2 - 64, param_3); } else { SetTileType(param_1, param_2, param_3); } } void sub_0807B820(u32 param_1) { - SetTileType(620, param_1 + -65, 1); - SetTileType(627, param_1 + -65, 2); - SetTileType(621, param_1 + -64, 1); - SetTileType(628, param_1 + -64, 2); - SetTileType(622, param_1 + -63, 1); - SetTileType(629, param_1 + -63, 2); - SetTileType(623, param_1 + -1, 1); + SetTileType(620, param_1 - 65, 1); + SetTileType(627, param_1 - 65, 2); + SetTileType(621, param_1 - 64, 1); + SetTileType(628, param_1 - 64, 2); + SetTileType(622, param_1 - 63, 1); + SetTileType(629, param_1 - 63, 2); + SetTileType(623, param_1 - 1, 1); SetTileType(624, param_1, 1); SetTileType(626, param_1 + 1, 1); } void sub_0807B8A8(u32 param_1) { - SetTileType(636, param_1 + -65, 1); - SetTileType(643, param_1 + -65, 2); - SetTileType(637, param_1 + -64, 1); - SetTileType(644, param_1 + -64, 2); - SetTileType(638, param_1 + -63, 1); - SetTileType(645, param_1 + -63, 2); - SetTileType(639, param_1 + -1, 1); + SetTileType(636, param_1 - 65, 1); + SetTileType(643, param_1 - 65, 2); + SetTileType(637, param_1 - 64, 1); + SetTileType(644, param_1 - 64, 2); + SetTileType(638, param_1 - 63, 1); + SetTileType(645, param_1 - 63, 2); + SetTileType(639, param_1 - 1, 1); SetTileType(640, param_1, 1); SetTileType(642, param_1 + 1, 1); } void sub_0807B930(int param_1) { - SetTileType(652, param_1 + -65, 1); - SetTileType(659, param_1 + -65, 2); - SetTileType(653, param_1 + -64, 1); - SetTileType(660, param_1 + -64, 2); - SetTileType(654, param_1 + -63, 1); - SetTileType(661, param_1 + -63, 2); - SetTileType(655, param_1 + -1, 1); + SetTileType(652, param_1 - 65, 1); + SetTileType(659, param_1 - 65, 2); + SetTileType(653, param_1 - 64, 1); + SetTileType(660, param_1 - 64, 2); + SetTileType(654, param_1 - 63, 1); + SetTileType(661, param_1 - 63, 2); + SetTileType(655, param_1 - 1, 1); SetTileType(656, param_1, 1); SetTileType(658, param_1 + 1, 1); } diff --git a/src/sub_080A554C.c b/src/sub_080A554C.c index 4ec59e7f..dffcbab0 100644 --- a/src/sub_080A554C.c +++ b/src/sub_080A554C.c @@ -11,7 +11,7 @@ u32 sub_080A554C(u32 arg0) { if (arg0 != 0) { for (i = 0; i < 17; i++) { - if (arg0 == (&gUnk_02000090)[i]) + if (arg0 == gMenu.focusCoords[i]) return i; } } diff --git a/src/sub_08127D30.c b/src/sub_08127D30.c index aa953d3a..1ce3f625 100644 --- a/src/sub_08127D30.c +++ b/src/sub_08127D30.c @@ -3,8 +3,5 @@ extern u8 gUnk_08127D30[69]; u32 sub_08052654(u32 r0) { - // u32 r1 = gUnk_08127D30; - // u32 r1 = gUnk_08127D30; - return gUnk_08127D30[r0 * 4] == 129; } From 57eec4def41b5bd3cc3ac791ef4bc26b75125b5d Mon Sep 17 00:00:00 2001 From: theo3 Date: Tue, 26 Oct 2021 23:20:12 -0700 Subject: [PATCH 3/4] decompile jar portal --- asm/jarPortal.s | 441 ---------------------------------------- include/functions.h | 1 + linker.ld | 1 + src/enemy/doorMimic.c | 1 - src/manager/manager15.c | 2 - src/manager/manager1A.c | 1 - src/manager/manager3.c | 2 +- src/npc/bigGoron.c | 1 - src/object/jarPortal.c | 181 +++++++++++++++++ 9 files changed, 184 insertions(+), 447 deletions(-) create mode 100644 src/object/jarPortal.c diff --git a/asm/jarPortal.s b/asm/jarPortal.s index 8b057fc8..a42aa8ad 100644 --- a/asm/jarPortal.s +++ b/asm/jarPortal.s @@ -6,444 +6,3 @@ .text - - thumb_func_start JarPortal -JarPortal: @ 0x0808BE84 - push {lr} - ldr r2, _0808BE98 @ =gUnk_08121488 - ldrb r1, [r0, #0xc] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_0808BE98: .4byte gUnk_08121488 - - thumb_func_start sub_0808BE9C -sub_0808BE9C: @ 0x0808BE9C - push {r4, r5, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x10] - movs r0, #0x80 - movs r2, #0 - orrs r0, r1 - strb r0, [r4, #0x10] - adds r0, r4, #0 - adds r0, #0x3f - movs r5, #1 - strb r5, [r0] - adds r1, r4, #0 - adds r1, #0x3c - movs r0, #0x47 - strb r0, [r1] - adds r1, #4 - movs r0, #0x44 - strb r0, [r1] - subs r1, #5 - movs r0, #0x80 - strb r0, [r1] - adds r0, r4, #0 - adds r0, #0x68 - strb r2, [r0] - ldrb r0, [r4, #0xa] - bl CheckLocalFlag - cmp r0, #0 - beq _0808BEEE - adds r0, r4, #0 - adds r0, #0x7c - ldrb r0, [r0] - cmp r0, #0 - bne _0808BEF8 - movs r0, #3 - strb r0, [r4, #0xc] - adds r0, r4, #0 - movs r1, #1 - bl InitAnimationForceUpdate - b _0808BF10 -_0808BEEE: - adds r0, r4, #0 - adds r0, #0x7c - ldrb r0, [r0] - cmp r0, #0 - bne _0808BF04 -_0808BEF8: - strb r5, [r4, #0xc] - adds r0, r4, #0 - movs r1, #0 - bl InitAnimationForceUpdate - b _0808BF10 -_0808BF04: - movs r0, #3 - strb r0, [r4, #0xc] - adds r0, r4, #0 - movs r1, #1 - bl InitAnimationForceUpdate -_0808BF10: - pop {r4, r5, pc} - .align 2, 0 - - thumb_func_start sub_0808BF14 -sub_0808BF14: @ 0x0808BF14 - push {r4, lr} - adds r4, r0, #0 - bl sub_0808C128 - cmp r0, #0 - beq _0808BF4C - ldrb r0, [r4, #0xc] - adds r0, #1 - strb r0, [r4, #0xc] - adds r0, r4, #0 - bl sub_0808C13C - adds r0, r4, #0 - adds r0, #0x7c - ldrb r0, [r0] - cmp r0, #0 - bne _0808BF3E - ldrb r0, [r4, #0xa] - bl SetLocalFlag - b _0808BF44 -_0808BF3E: - ldrb r0, [r4, #0xa] - bl ClearLocalFlag -_0808BF44: - adds r0, r4, #0 - movs r1, #0 - bl sub_0808C148 -_0808BF4C: - adds r0, r4, #0 - movs r1, #0 - bl sub_0808C01C - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_0808BF58 -sub_0808BF58: @ 0x0808BF58 - push {r4, lr} - adds r4, r0, #0 - movs r1, #0x80 - lsls r1, r1, #6 - bl sub_08003FC4 - ldrb r0, [r4, #0xd] - cmp r0, #1 - beq _0808BF94 - cmp r0, #1 - bgt _0808BF74 - cmp r0, #0 - beq _0808BF7A - b _0808BFD6 -_0808BF74: - cmp r0, #2 - beq _0808BFB0 - b _0808BFD6 -_0808BF7A: - ldr r1, [r4, #0x20] - ldr r0, _0808BF90 @ =0x00017FFF - cmp r1, r0 - bgt _0808BFD6 - movs r0, #1 - strb r0, [r4, #0xd] - adds r0, r4, #0 - movs r1, #2 - bl InitAnimationForceUpdate - b _0808BFD6 - .align 2, 0 -_0808BF90: .4byte 0x00017FFF -_0808BF94: - adds r0, r4, #0 - bl UpdateAnimationSingleFrame - movs r1, #0x36 - ldrsh r0, [r4, r1] - cmp r0, #0 - bne _0808BFD6 - ldrb r0, [r4, #0xd] - adds r0, #1 - strb r0, [r4, #0xd] - movs r0, #0x80 - lsls r0, r0, #8 - str r0, [r4, #0x20] - b _0808BFD6 -_0808BFB0: - adds r0, r4, #0 - bl UpdateAnimationSingleFrame - movs r0, #0x36 - ldrsh r1, [r4, r0] - cmp r1, #0 - bne _0808BFD6 - ldrb r0, [r4, #0xc] - adds r0, #1 - strb r0, [r4, #0xc] - strb r1, [r4, #0xf] - adds r0, r4, #0 - movs r1, #1 - bl InitAnimationForceUpdate - adds r0, r4, #0 - movs r1, #1 - bl sub_0808C148 -_0808BFD6: - pop {r4, pc} - - thumb_func_start sub_0808BFD8 -sub_0808BFD8: @ 0x0808BFD8 - push {r4, lr} - adds r4, r0, #0 - bl sub_0808C128 - cmp r0, #0 - beq _0808C010 - ldrb r0, [r4, #0xc] - adds r0, #1 - strb r0, [r4, #0xc] - adds r0, r4, #0 - bl sub_0808C13C - adds r0, r4, #0 - adds r0, #0x7c - ldrb r0, [r0] - cmp r0, #0 - bne _0808C002 - ldrb r0, [r4, #0xa] - bl ClearLocalFlag - b _0808C008 -_0808C002: - ldrb r0, [r4, #0xa] - bl SetLocalFlag -_0808C008: - adds r0, r4, #0 - movs r1, #0 - bl sub_0808C148 -_0808C010: - adds r0, r4, #0 - movs r1, #1 - bl sub_0808C01C - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_0808C01C -sub_0808C01C: @ 0x0808C01C - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r5, r1, #0 - movs r1, #0x2e - ldrsh r0, [r4, r1] - subs r0, #0x18 - movs r2, #0x32 - ldrsh r1, [r4, r2] - subs r1, #0x18 - movs r2, #0x30 - movs r3, #0x30 - bl CheckPlayerProximity - cmp r0, #0 - beq _0808C0A6 - ldr r2, _0808C06C @ =gArea - ldrh r0, [r4, #0x2e] - strh r0, [r2, #0x12] - ldrh r0, [r4, #0x32] - strh r0, [r2, #0x14] - movs r6, #2 - strb r6, [r2, #0x16] - movs r0, #4 - cmp r5, #0 - beq _0808C050 - movs r0, #2 -_0808C050: - strb r0, [r2, #0x17] - cmp r5, #1 - bne _0808C0A6 - ldr r3, _0808C070 @ =gPlayerState - ldr r0, [r3, #0x30] - movs r1, #0x20 - ands r0, r1 - cmp r0, #0 - beq _0808C074 - ldrb r0, [r3, #2] - cmp r0, #0 - bne _0808C074 - strb r6, [r2, #0x18] - b _0808C082 - .align 2, 0 -_0808C06C: .4byte gArea -_0808C070: .4byte gPlayerState -_0808C074: - bl sub_08057810 - cmp r0, #0 - beq _0808C082 - ldr r1, _0808C0A8 @ =gArea - movs r0, #3 - strb r0, [r1, #0x18] -_0808C082: - movs r1, #0x2e - ldrsh r0, [r4, r1] - movs r2, #0x32 - ldrsh r1, [r4, r2] - adds r2, r4, #0 - adds r2, #0x38 - ldrb r2, [r2] - bl sub_080577AC - ldrb r0, [r4, #0xf] - cmp r0, #0 - bne _0808C0A6 - movs r0, #1 - strb r0, [r4, #0xf] - movs r0, #0xa9 - lsls r0, r0, #1 - bl SoundReq -_0808C0A6: - pop {r4, r5, r6, pc} - .align 2, 0 -_0808C0A8: .4byte gArea - - thumb_func_start sub_0808C0AC -sub_0808C0AC: @ 0x0808C0AC - push {r4, lr} - adds r4, r0, #0 - movs r1, #0x80 - lsls r1, r1, #6 - bl sub_08003FC4 - ldrb r0, [r4, #0xd] - cmp r0, #1 - beq _0808C0E8 - cmp r0, #1 - bgt _0808C0C8 - cmp r0, #0 - beq _0808C0CE - b _0808C126 -_0808C0C8: - cmp r0, #2 - beq _0808C104 - b _0808C126 -_0808C0CE: - ldr r1, [r4, #0x20] - ldr r0, _0808C0E4 @ =0x00017FFF - cmp r1, r0 - bgt _0808C126 - movs r0, #1 - strb r0, [r4, #0xd] - adds r0, r4, #0 - movs r1, #3 - bl InitAnimationForceUpdate - b _0808C126 - .align 2, 0 -_0808C0E4: .4byte 0x00017FFF -_0808C0E8: - adds r0, r4, #0 - bl UpdateAnimationSingleFrame - movs r1, #0x36 - ldrsh r0, [r4, r1] - cmp r0, #0 - bne _0808C126 - ldrb r0, [r4, #0xd] - adds r0, #1 - strb r0, [r4, #0xd] - movs r0, #0x80 - lsls r0, r0, #8 - str r0, [r4, #0x20] - b _0808C126 -_0808C104: - adds r0, r4, #0 - bl UpdateAnimationSingleFrame - movs r1, #0x36 - ldrsh r0, [r4, r1] - cmp r0, #0 - bne _0808C126 - movs r0, #1 - strb r0, [r4, #0xc] - adds r0, r4, #0 - movs r1, #0 - bl InitAnimationForceUpdate - adds r0, r4, #0 - movs r1, #1 - bl sub_0808C148 -_0808C126: - pop {r4, pc} - - thumb_func_start sub_0808C128 -sub_0808C128: @ 0x0808C128 - push {lr} - movs r1, #0 - adds r0, #0x41 - ldrb r0, [r0] - cmp r0, #0x9d - bne _0808C136 - movs r1, #1 -_0808C136: - adds r0, r1, #0 - pop {pc} - .align 2, 0 - - thumb_func_start sub_0808C13C -sub_0808C13C: @ 0x0808C13C - movs r1, #0 - strb r1, [r0, #0xd] - movs r1, #0xa0 - lsls r1, r1, #0xa - str r1, [r0, #0x20] - bx lr - - thumb_func_start sub_0808C148 -sub_0808C148: @ 0x0808C148 - push {r4, r5, r6, lr} - adds r6, r0, #0 - movs r2, #0x2e - ldrsh r0, [r6, r2] - ldr r4, _0808C1A4 @ =gRoomControls - ldrh r2, [r4, #6] - subs r0, r0, r2 - asrs r5, r0, #4 - movs r3, #0x3f - ands r5, r3 - movs r2, #0x32 - ldrsh r0, [r6, r2] - ldrh r2, [r4, #8] - subs r0, r0, r2 - asrs r0, r0, #4 - ands r0, r3 - lsls r0, r0, #6 - orrs r5, r0 - cmp r1, #0 - bne _0808C1B8 - ldr r0, _0808C1A8 @ =0x00004092 - subs r1, r5, #1 - adds r4, r6, #0 - adds r4, #0x38 - ldrb r2, [r4] - bl SetTile - ldr r0, _0808C1AC @ =0x00004093 - ldrb r2, [r4] - adds r1, r5, #0 - bl SetTile - ldr r0, _0808C1B0 @ =0x00004094 - adds r1, r5, #0 - adds r1, #0x3f - ldrb r2, [r4] - bl SetTile - ldr r0, _0808C1B4 @ =0x00004095 - adds r1, r5, #0 - adds r1, #0x40 - ldrb r2, [r4] - bl SetTile - b _0808C1E0 - .align 2, 0 -_0808C1A4: .4byte gRoomControls -_0808C1A8: .4byte 0x00004092 -_0808C1AC: .4byte 0x00004093 -_0808C1B0: .4byte 0x00004094 -_0808C1B4: .4byte 0x00004095 -_0808C1B8: - subs r0, r5, #1 - adds r4, r6, #0 - adds r4, #0x38 - ldrb r1, [r4] - bl sub_0807BA8C - ldrb r1, [r4] - adds r0, r5, #0 - bl sub_0807BA8C - adds r0, r5, #0 - adds r0, #0x3f - ldrb r1, [r4] - bl sub_0807BA8C - adds r0, r5, #0 - adds r0, #0x40 - ldrb r1, [r4] - bl sub_0807BA8C -_0808C1E0: - pop {r4, r5, r6, pc} - .align 2, 0 diff --git a/include/functions.h b/include/functions.h index ad271fa5..662227a4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -58,6 +58,7 @@ extern void DoExitTransition(ScreenTransitionData*); extern void CreateDustAt(u32, u32, u32); extern void PutItemOnSlot(u32 itemID); extern void CreateSpeechBubbleSleep(Entity*, u32, u32); +extern u32 CheckPlayerProximity(u32, u32, u32, u32); // Unidentified extern u32 sub_0806ED78(Entity*); diff --git a/linker.ld b/linker.ld index b1030355..32157850 100644 --- a/linker.ld +++ b/linker.ld @@ -761,6 +761,7 @@ SECTIONS { asm/object35.o(.text); asm/object36.o(.text); asm/object37.o(.text); + src/object/jarPortal.o(.text); asm/jarPortal.o(.text); asm/bossDoor.o(.text); asm/object3A.o(.text); diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index ff59c26d..c3fd44ee 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -5,7 +5,6 @@ extern s16 sub_080001DA(u32, u32); // ? extern void sub_08049CF4(); -extern u32 CheckPlayerProximity(u32, u32, u32, u32); void sub_080221C0(); typedef struct { diff --git a/src/manager/manager15.c b/src/manager/manager15.c index 24b214b5..b0ce0828 100644 --- a/src/manager/manager15.c +++ b/src/manager/manager15.c @@ -253,8 +253,6 @@ void sub_0805A664(Manager15* this) { sub_0805A68C(this); } -extern u32 CheckPlayerProximity(u32, u32, u32, u32); - void sub_0805A68C(Manager15* this) { if (CheckPlayerProximity(this->unk_38 - 0x18, this->unk_3a - 0x18, 0x30, 0x30)) { if (this->unk_2c <= 0x1007) { diff --git a/src/manager/manager1A.c b/src/manager/manager1A.c index 2b4027a2..c006ddaf 100644 --- a/src/manager/manager1A.c +++ b/src/manager/manager1A.c @@ -32,7 +32,6 @@ void Manager1A_Main(Manager1A* this) { } extern void sub_08052D74(void*, void*, void*); -extern u32 CheckPlayerProximity(u32, u32, u32, u32); typedef struct struct_08108764 { u8 unk_00; diff --git a/src/manager/manager3.c b/src/manager/manager3.c index 5652ad89..272baabc 100644 --- a/src/manager/manager3.c +++ b/src/manager/manager3.c @@ -7,6 +7,7 @@ #include "random.h" #include "audio.h" #include "object.h" +#include "functions.h" // Facilitates the usage of minish portals. @@ -25,7 +26,6 @@ typedef struct { } Manager3; extern s8 gUnk_08107C6C[]; -extern u32 CheckPlayerProximity(u32, u32, u32, u32); extern u32 sub_08057810(void); extern u32 sub_080002C0(u16, u16, u8); extern void sub_080577AC(u32, u32, u32); diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 611f6b24..34a336ff 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -34,7 +34,6 @@ extern Hitbox gUnk_080FD180; Entity* sub_0806D00C(Entity* this); void sub_0806D4C0(Entity*, u32); -extern u32 CheckPlayerProximity(u32, u32, u32, u32); void BigGoron(Entity* this) { gUnk_081140D4[this->type](this); diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c new file mode 100644 index 00000000..b625bb1b --- /dev/null +++ b/src/object/jarPortal.c @@ -0,0 +1,181 @@ +#include "global.h" +#include "entity.h" +#include "flags.h" +#include "functions.h" +#include "area.h" +#include "audio.h" + +extern void (*gUnk_08121488[])(Entity*); + +extern u32 sub_08057810(void); +extern void sub_080577AC(u32, u32, u32); + +u32 sub_0808C128(Entity*); +void sub_0808C13C(Entity*); +void sub_0808C148(Entity*, u32); +void sub_0808C01C(Entity*, u32); + +void JarPortal(Entity* this) { + gUnk_08121488[this->action](this); +} + +void sub_0808BE9C(Entity* this) { + this->flags |= 0x80; + this->damageType = 1; + this->field_0x3c = 0x47; + this->field_0x40 = 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); + } else { + this->action = 3; + InitAnimationForceUpdate(this, 1); + } + } else { + if (this->field_0x7c.BYTES.byte0 == 0) { + this->action = 1; + InitAnimationForceUpdate(this, 0); + } else { + this->action = 3; + InitAnimationForceUpdate(this, 1); + } + } +} + +void sub_0808BF14(Entity* this) { + if (sub_0808C128(this)) { + this->action++; + sub_0808C13C(this); + if (this->field_0x7c.BYTES.byte0 == 0) { + SetLocalFlag(this->type); + } else { + ClearLocalFlag(this->type); + } + sub_0808C148(this, 0); + } + sub_0808C01C(this, 0); +} + +void sub_0808BF58(Entity* this) { + sub_08003FC4(this, 0x2000); + switch (this->subAction) { + case 0: + if (this->field_0x20 <= 98303) { + ++this->subAction; + InitAnimationForceUpdate(this, 2); + } + break; + case 1: + UpdateAnimationSingleFrame(this); + if (!this->height.HALF.HI) { + ++this->subAction; + this->field_0x20 = 0x8000; + } + break; + case 2: + UpdateAnimationSingleFrame(this); + if (!this->height.HALF.HI) { + ++this->action; + this->field_0xf = 0; + InitAnimationForceUpdate(this, 1); + sub_0808C148(this, 1); + } + break; + } +} + +void sub_0808BFD8(Entity* this) { + if (sub_0808C128(this)) { + ++this->action; + sub_0808C13C(this); + if (!this->field_0x7c.BYTES.byte0) + ClearLocalFlag(this->type); + else + SetLocalFlag(this->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)) { + u32 type; + gArea.curPortalX = this->x.HALF.HI; + gArea.curPortalY = this->y.HALF.HI; + gArea.curPortalExitDirection = 2; + type = 4; + if (r1 != 0) + type = 2; + gArea.curPortalType = type; + if (r1 == 1) { + if (((gPlayerState.flags.all & 0x20) != 0) && (gPlayerState.jumpStatus == 0)) { + gArea.field_0x18 = 2; + } else { + if (sub_08057810() != 0) { + gArea.field_0x18 = 3; + } + } + sub_080577AC(this->x.HALF.HI, this->y.HALF.HI, this->collisionLayer); + if (this->field_0xf == 0) { + this->field_0xf = 1; + SoundReq(0x152); + } + } + } +} + +void sub_0808C0AC(Entity* this) { + sub_08003FC4(this, 0x2000); + switch (this->subAction) { + case 0: + if (this->field_0x20 <= 98303) { + this->subAction = 1; + InitAnimationForceUpdate(this, 3); + } + break; + case 1: + UpdateAnimationSingleFrame(this); + if (!this->height.HALF.HI) { + ++this->subAction; + this->field_0x20 = 0x8000; + } + break; + case 2: + UpdateAnimationSingleFrame(this); + if (!this->height.HALF.HI) { + this->action = 1; + InitAnimationForceUpdate(this, 0); + sub_0808C148(this, 1); + } + break; + } +} + +u32 sub_0808C128(Entity* this) { + return this->bitfield == 157; +} + +void sub_0808C13C(Entity* this) { + this->subAction = 0; + this->field_0x20 = 163840; +} + +void sub_0808C148(Entity* this, u32 a2) { + u32 pos; + + pos = COORD_TO_TILE(this); + 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); + } else { + sub_0807BA8C(pos - 1, this->collisionLayer); + sub_0807BA8C(pos, this->collisionLayer); + sub_0807BA8C(pos + 63, this->collisionLayer); + sub_0807BA8C(pos + 64, this->collisionLayer); + } +} From 46d14fdc0ccfbd832a0d154407b64c7a85ad15be Mon Sep 17 00:00:00 2001 From: theo3 Date: Sun, 31 Oct 2021 22:59:41 -0700 Subject: [PATCH 4/4] asm notes --- asm/chestSpawner.s | 2 +- asm/code_080011C4.s | 13 +-- asm/code_08016B30.s | 4 +- asm/code_0801D79C.s | 4 +- asm/code_080A5574.s | 2 +- asm/crt0.s | 2 +- asm/intr.s | 163 +++++++++++++++++++--------------- asm/macros.inc | 2 + asm/macros/ram.inc | 20 +++++ asm/object74.s | 2 +- asmdiff.sh | 4 +- constants/audio_constants.inc | 2 +- data/sounds.s | 8 +- include/audio.h | 2 +- include/room.h | 4 +- linker.ld | 6 +- src/arm_proxy.c | 4 +- src/audio.c | 4 +- src/code_0805EC04.c | 3 +- src/manager/manager3.c | 14 +-- src/object/jarPortal.c | 6 +- 21 files changed, 161 insertions(+), 110 deletions(-) create mode 100644 asm/macros/ram.inc diff --git a/asm/chestSpawner.s b/asm/chestSpawner.s index 701e03dd..bc6f7bc2 100644 --- a/asm/chestSpawner.s +++ b/asm/chestSpawner.s @@ -126,7 +126,7 @@ sub_08083F14: @ 0x08083F14 movs r2, #0x32 ldrsh r1, [r4, r2] movs r2, #2 - bl sub_080577AC + bl CreateMagicSparkles ldrb r0, [r4, #0xe] subs r0, #1 strb r0, [r4, #0xe] diff --git a/asm/code_080011C4.s b/asm/code_080011C4.s index dece593a..b3ef8bab 100644 --- a/asm/code_080011C4.s +++ b/asm/code_080011C4.s @@ -1264,14 +1264,17 @@ _0800268C: .byte 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00 _0800269C: .4byte gUnk_0800232E _080026A0: .4byte gUnk_08002342 + gUnk_080026A4:: - .4byte gUnk_020000B0 - .4byte gUnk_03003D68 - .4byte gUnk_03003DB0 - .4byte gUnk_03005FBC +@ normal entities + .4byte gUnk_020000B0 @ enemy target? (player) + .4byte gUnk_03003D68 @ first linked list + .4byte gUnk_03003DB0 @ last linked list + .4byte gUnk_03005FBC @ entity table +@ managers .4byte gUnk_020000B0 .4byte gUnk_03003DA8 - .4byte gHitboxCount + .4byte gCollidableCount .4byte gUnk_03005FBC thumb_func_start sub_080026C4 diff --git a/asm/code_08016B30.s b/asm/code_08016B30.s index 059e1c4c..6726c90a 100644 --- a/asm/code_08016B30.s +++ b/asm/code_08016B30.s @@ -13,7 +13,7 @@ sub_08016B30: @ 0x08016B30 thumb_func_start sub_08016B34 sub_08016B34: @ 0x08016B34 ldr r1, _08016B54 @ =0x03007FFC - ldr r0, _08016B58 @ =IntrMain + ldr r0, _08016B58 @ =gIntrMain str r0, [r1] ldr r1, _08016B5C @ =0x04000004 ldr r2, _08016B60 @ =0x00005028 @@ -29,7 +29,7 @@ sub_08016B34: @ 0x08016B34 bx lr .align 2, 0 _08016B54: .4byte 0x03007FFC -_08016B58: .4byte IntrMain +_08016B58: .4byte gIntrMain _08016B5C: .4byte 0x04000004 _08016B60: .4byte 0x00005028 _08016B64: .4byte 0x04000200 diff --git a/asm/code_0801D79C.s b/asm/code_0801D79C.s index caed4ae5..2f3defb3 100644 --- a/asm/code_0801D79C.s +++ b/asm/code_0801D79C.s @@ -660,8 +660,8 @@ _0801DD7C: .4byte gAreaRoomHeaders _0801DD80: .4byte gArea _0801DD84: .4byte 0x0000085C - thumb_func_start sub_0801DD88 -sub_0801DD88: @ 0x0801DD88 + thumb_func_start LoadDungeonMap +LoadDungeonMap: @ 0x0801DD88 push {lr} ldr r0, _0801DD98 @ =gUnk_0201AEE0 ldr r1, _0801DD9C @ =0x06006000 diff --git a/asm/code_080A5574.s b/asm/code_080A5574.s index e7582e86..02f47ac8 100644 --- a/asm/code_080A5574.s +++ b/asm/code_080A5574.s @@ -1230,7 +1230,7 @@ sub_080A5CFC: @ 0x080A5CFC push {r4, lr} adds r4, r0, #0 bl sub_0801DDA0 - bl sub_0801DD88 + bl LoadDungeonMap ldr r1, _080A5D18 @ =gUnk_02019EE0 movs r2, #0x80 lsls r2, r2, #3 diff --git a/asm/crt0.s b/asm/crt0.s index d72915b1..84a9e59d 100644 --- a/asm/crt0.s +++ b/asm/crt0.s @@ -33,7 +33,7 @@ _080000F0: sp_irq: .4byte gUnk_03007FA0 sp_usr: .4byte gUnk_03007F00 INTR_VECTOR_BUF: .4byte 0x03007FFC -intr_main: .4byte IntrMain +intr_main: .4byte gIntrMain .ifdef EU unk_function: .4byte sub_08000118 .endif diff --git a/asm/intr.s b/asm/intr.s index ed83cba1..06ea086d 100644 --- a/asm/intr.s +++ b/asm/intr.s @@ -6,6 +6,10 @@ .text .code 16 + +.global RAMFUNCS_BASE +RAMFUNCS_BASE:: + sub_080B197C:: @ 0x080B197C push {r4, r5, r6} ldr r2, _080B19C0 @ =gRoomControls @@ -250,13 +254,14 @@ _080B1C48: .4byte gUnk_080B7A3E _080B1C4C: .4byte gRoomControls _080B1C50: .4byte gUnk_08000278 - arm_func_start sub_080B1C54 -sub_080B1C54: @ 0x080B1C54 + arm_func_start UpdateCollision +UpdateCollision: @ 0x080B1C54 + @ r0 : Entity* this ldrb r1, [r0, #0x10] - ands r1, r1, #0x80 + ands r1, r1, #0x80 @ disable collision flag bxeq lr - ldr r2, _080B200C @ =gUnk_03000E10 - ldr r3, _080B2010 @ =gHitboxCount + ldr r2, _080B200C @ =gCollidableList + ldr r3, _080B2010 @ =gCollidableCount ldrb r1, [r3] str r0, [r2, r1, lsl #2] add r1, r1, #1 @@ -340,8 +345,8 @@ _080B1D84: pop {r4, r5, r6, r7, r8, sb, sl, lr} bx lr _080B1D8C: .4byte gUnk_02018EA0 -_080B1D90: .4byte gUnk_03000E10 -_080B1D94: .4byte gHitboxCount +_080B1D90: .4byte gCollidableList +_080B1D94: .4byte gCollidableCount arm_func_start sub_080B1D98 sub_080B1D98: @ 0x080B1D98 @@ -525,33 +530,33 @@ _080B1FFC: .4byte gUnk_03005D5C _080B2000: .4byte gUnk_03005D24 _080B2004: .4byte gUnk_03005D18 _080B2008: .4byte gUnk_03005D58 -_080B200C: .4byte gUnk_03000E10 -_080B2010: .4byte gHitboxCount +_080B200C: .4byte gCollidableList +_080B2010: .4byte gCollidableCount _080B2014: .4byte gUnk_080B7B74 _080B2018: .4byte gUnk_080B3744 - arm_func_start sub_080B201C -sub_080B201C: @ 0x080B201C + arm_func_start IntrMain +IntrMain: mov r3, #0x4000000 add r3, r3, #0x200 - ldr r2, [r3] - ldrh r1, [r3, #8] + ldr r2, [r3] @ lo 16: interrupt_enable, hi 16: interrupt_request + ldrh r1, [r3, #8] @ interrupt master enable mrs r0, spsr push {r0, r1, r2, r3, lr} and r1, r2, r2, lsr #16 - ands r0, r1, #0x2000 + ands r0, r1, #0x2000 @ external irq bne _080B20D4 mov ip, #4 - ands r0, r1, #0x80 + ands r0, r1, #0x80 @ serial comm bne _080B2074 mov ip, #0xc - ands r0, r1, #4 + ands r0, r1, #4 @ vcount bne _080B2074 mov ip, #0x10 - ands r0, r1, #1 + ands r0, r1, #1 @ vblank bne _080B2074 mov ip, #0x14 - ands r0, r1, #0x40 + ands r0, r1, #0x40 @ timer 3 overflow bne _080B2074 mov ip, #0 _080B2074: @@ -610,8 +615,8 @@ _080B20FC: mov r0, #1 bx lr - arm_func_start sub_080B2124 -sub_080B2124: @ 0x080B2124 + arm_func_start MakeFadeBuff256 +MakeFadeBuff256: @ 0x080B2124 push {r4, r5, r6, r7, r8, sb, sl, fp} mul r3, r2, r3 mov r4, #0x400 @@ -652,50 +657,60 @@ _080B21AC: .4byte gUnk_08000F54 arm_func_start UpdateEntities UpdateEntities: @ 0x080B21B0 - ldr fp, _080B2270 @ =gUnk_03003DD0 - ldr r1, [fp] - ldm r1, {r7, r8, sb, sl} - ldr sp, [fp, #0xc] - ldr r8, [fp, #4] - ldr r0, [fp, #8] + ldr r11, _080B2270 @ =gUnk_03003DD0 + ldr r1, [r11] + ldm r1, {r7, r8, r9, r10} + ldr sp, [r11, #0xc] + ldr r8, [r11, #4] + ldr r0, [r11, #8] add pc, pc, #0x60 @ =_080B2230 + +@ gUnk_03003DD0 { +@ void* chosen_table; +@ void* linked_list_top; +@ void* curr_entity; +@ void* restore_sp; +@ } + @ UpdateEntities starts here + @ arg0 (r0) : 0 = entities, 1 = managers ldr r1, _080B2274 @ =gUnk_080026A4 add r1, r1, r0, lsl #4 - push {r4, r5, r6, r7, r8, sb, sl, fp, lr} - ldr fp, _080B2278 @ =gUnk_03003DD0 - str r1, [fp] - str sp, [fp, #0xc] - ldm r1, {r7, r8, sb, sl} -_080B21E8: + push {r4 - r11, lr} + ldr r11, _080B2278 @ =gUnk_03003DD0 + str r1, [r11, #0x0] + str sp, [r11, #0xc] + ldm r1, {r7, r8, r9, r10} +next_list: @ traverse entity linked list add r8, r8, #8 - str r8, [fp, #4] - cmp r8, sb - bhs _080B2238 - ldr r4, [r8, #4] -_080B21FC: + str r8, [r11, #4] + cmp r8, r9 + bhs lists_complete + ldr r4, [r8, #4] @ entity -> next +next_entity: cmp r4, r8 - beq _080B21E8 + beq next_list mov r0, #0 str r0, [r7] - str r4, [fp, #8] - ldrb r1, [r4, #8] - ldr r1, [sl, r1, lsl #2] + str r4, [r11, #8] + ldrb r1, [r4, #8] @ entity -> kind + ldr r1, [r10, r1, lsl #2] mov r0, r4 mov lr, pc - bx r1 @ Jump to address stored in r1 -_080B2224: - ldr r0, [fp, #8] - cmp r0, r4 - bleq sub_080B1C54 + bx r1 @ call entity kind update function + ldr r0, [r11, #8] + cmp r0, r4 @ update collision if entity is still alive + bleq UpdateCollision _080B2230: @ jumped here if ClearAndUpdateEntities ldr r4, [r0, #4] - b _080B21FC -_080B2238: + b next_entity +lists_complete: mov r0, #0 - str r0, [fp, #8] - pop {r4, r5, r6, r7, r8, sb, sl, fp, lr} + str r0, [r11, #8] + pop {r4 - r11, lr} bx lr + +_080B2248:: _080B2248: .4byte DeleteThisEntity @ 0x3005fbc _080B224C: .4byte PlayerUpdate _080B2250: .4byte DeleteThisEntity @@ -706,6 +721,7 @@ _080B2260: .4byte ObjectUpdate _080B2264: .4byte NPCUpdate _080B2268: .4byte ItemUpdate _080B226C: .4byte ManagerUpdate + _080B2270: .4byte gUnk_03003DD0 _080B2274: .4byte gUnk_080026A4 _080B2278: .4byte gUnk_03003DD0 @@ -860,7 +876,7 @@ sub_080B19C8: @ 0x080B19C8 mov r2, #0 strb r2, [r1] stmdb sp!, {lr} - bl sub_080B2478 + bl ResolveOamDrawPriority bl sub_080B2534 ldm sp!, {lr} b _080B1C40EU @@ -899,14 +915,17 @@ sub_080B2448: @ 0x080B2448 mov r2, #0 strb r2, [r1] stmdb sp!, {lr} - bl sub_080B2478 + bl ResolveOamDrawPriority bl sub_080B2534 ldm sp!, {lr} b _080B26B4 .endif - arm_func_start sub_080B2478 -sub_080B2478: @ 0x080B2478 + arm_func_start ResolveOamDrawPriority +ResolveOamDrawPriority: @ 0x080B2478 + prio_a .req r8 + prio_b .req r5 + mov sb, r0 mov r1, r0 ldrb r2, [r1], #4 @@ -914,7 +933,7 @@ sub_080B2478: @ 0x080B2478 sub sl, r2, #1 add r2, r1, sl, lsl #2 cmp sl, #0 - beq _080B252C + beq no_objs _080B2498: lsl r3, sl, #2 mov r6, #0 @@ -926,40 +945,44 @@ _080B24A0: _080B24B0: cmp r1, ip blo _080B251C +# sprite A ldr r4, [r1] +# pos ldr r8, [r4, #0x30] - add r8, r8, #-0x80000000 - lsr r8, r8, #3 + add r8, #0x80000000 + lsr r8, #3 +# load priority bits, NOT so 0 = highest priority ldrb r0, [r4, #0x29] mvn r0, r0 - orr r8, r8, r0, lsl #29 + orr prio_a, r8, r0, lsl #29 add r7, r1, r3 -_080B24D8: +next_sprite: cmp r2, r7 - blo _080B2510 + blo a_priority +# sprite B ldr r5, [r7] ldr r0, [r5, #0x30] - add r0, r0, #-0x80000000 - lsr r0, r0, #3 + add r0, #0x80000000 + lsr r0, #3 ldrb r5, [r5, #0x29] mvn r5, r5 - orr r5, r0, r5, lsl #29 - cmp r8, r5 - bhs _080B2510 + orr prio_b, r0, r5, lsl #29 + cmp prio_a, prio_b + bhs a_priority ldr r5, [r7], -r3 str r5, [r7], r3, lsl #1 - b _080B24D8 -_080B2510: + b next_sprite +a_priority: str r4, [r7, -r3]! sub r1, r1, r3 b _080B24B0 _080B251C: - add r6, r6, #1 + add r6, #1 b _080B24A0 _080B2524: - lsrs sl, sl, #1 + lsrs sl, #1 bne _080B2498 -_080B252C: +no_objs: mov r0, sb bx lr diff --git a/asm/macros.inc b/asm/macros.inc index 031b4cd1..ca814ebe 100644 --- a/asm/macros.inc +++ b/asm/macros.inc @@ -1,5 +1,7 @@ .include "asm/macros/asm.inc" .include "asm/macros/function.inc" + .include "asm/macros/ram.inc" .include "asm/macros/m4a.inc" .include "asm/macros/map.inc" .include "asm/macros/entity.inc" + diff --git a/asm/macros/ram.inc b/asm/macros/ram.inc new file mode 100644 index 00000000..d12c84e2 --- /dev/null +++ b/asm/macros/ram.inc @@ -0,0 +1,20 @@ + .ifndef GUARD_ASM_MACROS_RAM_INC + .set GUARD_ASM_MACROS_RAM_INC, 1 + +.ifdef EU + .set RAM_DIFF, 0x050AC28C - 0xaa0 +.endif + +.ifdef USA + .set RAM_DIFF, 0x050AC28C +.endif + +.ifdef JP + .set RAM_DIFF, 0x050AC28C - 0x260 +.endif + + .macro ram_addr x + .4byte \x - RAM_DIFF + .endm + + .endif @ GUARD_ASM_MACROS_RAM_INC diff --git a/asm/object74.s b/asm/object74.s index 9290d093..cc2ea1f6 100644 --- a/asm/object74.s +++ b/asm/object74.s @@ -118,7 +118,7 @@ sub_08097C20: @ 0x08097C20 adds r2, r4, #0 adds r2, #0x38 ldrb r2, [r2] - bl sub_080577AC + bl CreateMagicSparkles ldrb r0, [r4, #0xe] subs r0, #1 strb r0, [r4, #0xe] diff --git a/asmdiff.sh b/asmdiff.sh index bf6a907a..46f9e2ee 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -1,7 +1,7 @@ #!/bin/bash -buildname=tmc -baserom=baserom +buildname=$3 +baserom=$4 OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" diff --git a/constants/audio_constants.inc b/constants/audio_constants.inc index b7cb230c..07cb901e 100644 --- a/constants/audio_constants.inc +++ b/constants/audio_constants.inc @@ -336,7 +336,7 @@ .equiv SFX_14F, 0x14f .equiv SFX_150, 0x150 .equiv SFX_151, 0x151 - .equiv SFX_152, 0x152 + .equiv SFX_NEAR_PORTAL, 0x152 .equiv SFX_153, 0x153 .equiv SFX_154, 0x154 .equiv SFX_155, 0x155 diff --git a/data/sounds.s b/data/sounds.s index 670a54b2..28bf9d4b 100644 --- a/data/sounds.s +++ b/data/sounds.s @@ -8591,12 +8591,12 @@ sfx151_track0:: @ 08DE3684 sfx151:: @ 08DE36B0 sound_header 1 0 0x60 0 gUnk_08A10DC0 sfx151_track0 -sfx152_track0:: @ 08DE36BC +sfxNearPortal_track0:: @ 08DE36BC .incbin "baserom.gba", 0xDE36BC, 0x0000086 -sfx152_track1:: @ 08DE3742 +sfxNearPortal_track1:: @ 08DE3742 .incbin "baserom.gba", 0xDE3742, 0x000008A -sfx152:: @ 08DE37CC - sound_header 2 0 0x40 0 gUnk_08A10DD8 sfx152_track0 sfx152_track1 +sfxNearPortal:: @ 08DE37CC + sound_header 2 0 0x40 0 gUnk_08A10DD8 sfxNearPortal_track0 sfxNearPortal_track1 sfx153_track0:: @ 08DE37DC .incbin "baserom.gba", 0xDE37DC, 0x0000030 diff --git a/include/audio.h b/include/audio.h index 4f8ecb84..99ccf298 100644 --- a/include/audio.h +++ b/include/audio.h @@ -346,7 +346,7 @@ typedef enum { SFX_14F, SFX_150, SFX_151, - SFX_152, + SFX_NEAR_PORTAL, SFX_153, SFX_154, SFX_155, diff --git a/include/room.h b/include/room.h index f34f7297..b030d8e0 100644 --- a/include/room.h +++ b/include/room.h @@ -24,7 +24,9 @@ typedef struct { /*0x0E*/ u8 unk5; /*0x0F*/ u8 unk6; /*0x10*/ u8 unk_10; - /*0x11*/ u8 filler[3]; + /*0x11*/ s8 oam_offset_x; + /*0x12*/ s8 oam_offset_y; + /*0x13*/ u8 unk13; /*0x14*/ u8 screenShakeMagnitude; /*0x15*/ u8 unk7; /*0x16*/ u16 screenShakeTime; diff --git a/linker.ld b/linker.ld index 32157850..fce0ae80 100644 --- a/linker.ld +++ b/linker.ld @@ -181,7 +181,7 @@ SECTIONS { . = 0x00000BF8; gUnk_03000BF8 = .; . = 0x00000C24; gUnk_03000C24 = .; . = 0x00000C30; gUnk_03000C30 = .; - . = 0x00000E10; gUnk_03000E10 = .; + . = 0x00000E10; gCollidableList = .; . = 0x00000F50; gScreen = .; . = 0x00000F58; gBG0Settings = .; . = 0x00000F64; gBG1Settings = .; @@ -212,7 +212,7 @@ SECTIONS { . = 0x00003DA0; gUnk_03003DA0 = .; . = 0x00003DA8; gUnk_03003DA8 = .; . = 0x00003DB0; gUnk_03003DB0 = .; - . = 0x00003DB8; gHitboxCount = .; + . = 0x00003DB8; gCollidableCount = .; . = 0x00003DBC; gEntCount = .; . = 0x00003DC0; gUnk_03003DC0 = .; . = 0x00003DD0; gUnk_03003DD0 = .; @@ -274,7 +274,7 @@ SECTIONS { . = 0x00005D24; gUnk_03005D24 = .; . = 0x00005D58; gUnk_03005D58 = .; . = 0x00005D5C; gUnk_03005D5C = .; - . = 0x00005D90; IntrMain = .; + . = 0x00005D90; gIntrMain = .; . = 0x00005E60; gUnk_03005E60 = .; . = 0x00005E98; gUnk_03005E98 = .; . = 0x00005F24; _ClearAndUpdateEntities = .; diff --git a/src/arm_proxy.c b/src/arm_proxy.c index 982ddb65..d61749d7 100644 --- a/src/arm_proxy.c +++ b/src/arm_proxy.c @@ -22,7 +22,7 @@ extern u8 gUnk_03003DF0[]; extern u8 gUnk_03003BE0; extern Entity* gUnk_03004040[3]; extern u8 gUnk_020342F8; -extern u8 gHitboxCount; +extern u8 gCollidableCount; extern void gDoCollision(void); extern void sub_080ADD70(); @@ -371,7 +371,7 @@ NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this END_NONMATCH void ClearHitboxList(void) { - gHitboxCount = 0; + gCollidableCount = 0; } void CollisionMain(void) { diff --git a/src/audio.c b/src/audio.c index 32cd2f11..2c417705 100644 --- a/src/audio.c +++ b/src/audio.c @@ -533,7 +533,7 @@ extern const SongHeader sfx14E; extern const SongHeader sfx14F; extern const SongHeader sfx150; extern const SongHeader sfx151; -extern const SongHeader sfx152; +extern const SongHeader sfxNearPortal; extern const SongHeader sfx153; extern const SongHeader sfx154; extern const SongHeader sfx155; @@ -1165,7 +1165,7 @@ const Song gSongTable[] = { [SFX_14F] = { &sfx14F, MUSIC_PLAYER_15, MUSIC_PLAYER_15 }, [SFX_150] = { &sfx150, MUSIC_PLAYER_14, MUSIC_PLAYER_14 }, [SFX_151] = { &sfx151, MUSIC_PLAYER_13, MUSIC_PLAYER_13 }, - [SFX_152] = { &sfx152, MUSIC_PLAYER_18, MUSIC_PLAYER_18 }, + [SFX_NEAR_PORTAL] = { &sfxNearPortal, MUSIC_PLAYER_18, MUSIC_PLAYER_18 }, [SFX_153] = { &sfx153, MUSIC_PLAYER_11, MUSIC_PLAYER_11 }, [SFX_154] = { &sfx154, MUSIC_PLAYER_10, MUSIC_PLAYER_10 }, [SFX_155] = { &sfx155, MUSIC_PLAYER_0F, MUSIC_PLAYER_0F }, diff --git a/src/code_0805EC04.c b/src/code_0805EC04.c index bd38cac5..d49bb996 100644 --- a/src/code_0805EC04.c +++ b/src/code_0805EC04.c @@ -10,7 +10,8 @@ typedef struct { } VStruct; typedef struct { - u8 filler[0x420]; + u8 _0[0x20]; + struct OamData oam[0x80]; VStruct unk[0x100]; } UStruct; diff --git a/src/manager/manager3.c b/src/manager/manager3.c index 272baabc..2a6a4c24 100644 --- a/src/manager/manager3.c +++ b/src/manager/manager3.c @@ -28,7 +28,7 @@ typedef struct { extern s8 gUnk_08107C6C[]; extern u32 sub_08057810(void); extern u32 sub_080002C0(u16, u16, u8); -extern void sub_080577AC(u32, u32, u32); +extern void CreateMagicSparkles(u32, u32, u32); void Manager3_Main(Manager3* this) { s8 tmp; @@ -55,11 +55,11 @@ void Manager3_Main(Manager3* this) { } } if (sub_080002C0(this->unk_38, this->unk_3a, this->manager.unk_0e) == 0x3d) { - sub_080577AC(this->unk_38 + gRoomControls.roomOriginX, this->unk_3a + gRoomControls.roomOriginY, - this->manager.unk_0e); + CreateMagicSparkles(this->unk_38 + gRoomControls.roomOriginX, this->unk_3a + gRoomControls.roomOriginY, + this->manager.unk_0e); if (!this->manager.unk_0f) { this->manager.unk_0f = 1; - SoundReq(SFX_152); + SoundReq(SFX_NEAR_PORTAL); } } } @@ -69,15 +69,15 @@ void Manager3_Main(Manager3* this) { } } -void sub_080577AC(u32 baseX, u32 baseY, u32 layer) { +void CreateMagicSparkles(u32 baseX, u32 baseY, u32 layer) { u32 r; int offsetX, offsetY; Entity* spark; r = Random(); - if ((r & 0x7) != 0) + if (r & 0x7) return; spark = CreateObject(SPECIAL_FX, 0x26, 0); - if (!spark) + if (spark == NULL) return; offsetX = (r >> 0x8) & 0xF; offsetY = ((r >> 0x10) & 0xF); diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index b625bb1b..9d85f282 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -8,7 +8,7 @@ extern void (*gUnk_08121488[])(Entity*); extern u32 sub_08057810(void); -extern void sub_080577AC(u32, u32, u32); +extern void CreateMagicSparkles(u32, u32, u32); u32 sub_0808C128(Entity*); void sub_0808C13C(Entity*); @@ -118,10 +118,10 @@ void sub_0808C01C(Entity* this, u32 r1) { gArea.field_0x18 = 3; } } - sub_080577AC(this->x.HALF.HI, this->y.HALF.HI, this->collisionLayer); + CreateMagicSparkles(this->x.HALF.HI, this->y.HALF.HI, this->collisionLayer); if (this->field_0xf == 0) { this->field_0xf = 1; - SoundReq(0x152); + SoundReq(SFX_NEAR_PORTAL); } } }