summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroctorock <79596758+octorock@users.noreply.github.com>2022-08-09 18:48:05 +0200
committeroctorock <79596758+octorock@users.noreply.github.com>2022-08-09 18:56:13 +0200
commitad44d63b73b52fa49f1698526e1d77b414a1991d (patch)
treedde40030bc6013105e5f9ac1234c4e50707310f0 /src
parentdd59d70447cab4676e66895440fe6809d092bd31 (diff)
Document some player item stuff
Diffstat (limited to 'src')
-rw-r--r--src/beanstalkSubtask.c80
-rw-r--r--src/collision.c299
-rw-r--r--src/color.c4
-rw-r--r--src/enemy/armos.c8
-rw-r--r--src/enemy/beetle.c2
-rw-r--r--src/enemy/chuchuBoss.c2
-rw-r--r--src/enemy/dust.c2
-rw-r--r--src/enemy/enemy64.c6
-rw-r--r--src/enemy/ghini.c2
-rw-r--r--src/enemy/gibdo.c2
-rw-r--r--src/enemy/gleerok.c2
-rw-r--r--src/enemy/gyorgMaleEye.c2
-rw-r--r--src/enemy/likeLike.c2
-rw-r--r--src/enemy/mazaalBracelet.c4
-rw-r--r--src/enemy/miniFireballGuy.c2
-rw-r--r--src/enemy/miniSlime.c2
-rw-r--r--src/enemy/mulldozer.c2
-rw-r--r--src/enemy/octorokBoss.c2
-rw-r--r--src/enemy/pesto.c2
-rw-r--r--src/enemy/rupeeLike.c2
-rw-r--r--src/enemy/vaatiProjectile.c2
-rw-r--r--src/enemy/wizzrobeFire.c2
-rw-r--r--src/enemy/wizzrobeIce.c2
-rw-r--r--src/enemy/wizzrobeWind.c4
-rw-r--r--src/game.c105
-rw-r--r--src/gba/m4a.c2
-rw-r--r--src/interrupts.c22
-rw-r--r--src/item.c42
-rw-r--r--src/item/itemBomb.c67
-rw-r--r--src/item/itemBoomerang.c26
-rw-r--r--src/item/itemBow.c57
-rw-r--r--src/item/itemDebug.c10
-rw-r--r--src/item/itemGustJar.c74
-rw-r--r--src/item/itemJarEmpty.c32
-rw-r--r--src/item/itemLantern.c63
-rw-r--r--src/item/itemMoleMitts.c34
-rw-r--r--src/item/itemOcarina.c23
-rw-r--r--src/item/itemPacciCane.c26
-rw-r--r--src/item/itemPegasusBoots.c60
-rw-r--r--src/item/itemRocsCape.c38
-rw-r--r--src/item/itemShield.c46
-rw-r--r--src/item/itemSword.c167
-rw-r--r--src/item/itemTryPickupObject.c123
-rw-r--r--src/itemDefinitions.c43
-rw-r--r--src/itemMetaData.c2
-rw-r--r--src/manager/minishPortalManager.c2
-rw-r--r--src/manager/miscManager.c2
-rw-r--r--src/menu/pause_menu.c6
-rw-r--r--src/npc.c3
-rw-r--r--src/npc/bigGoron.c8
-rw-r--r--src/npc/bladeBrothers.c17
-rw-r--r--src/npc/castleMaid.c4
-rw-r--r--src/npc/drLeft.c4
-rw-r--r--src/npc/epona.c2
-rw-r--r--src/npc/forestMinish.c2
-rw-r--r--src/npc/guardWithSpear.c14
-rw-r--r--src/npc/mama.c2
-rw-r--r--src/npc/npc4E.c4
-rw-r--r--src/npc/npc58.c2
-rw-r--r--src/npc/pina.c4
-rw-r--r--src/npc/townMinish.c2
-rw-r--r--src/object.c2
-rw-r--r--src/object/barrelSpiderweb.c2
-rw-r--r--src/object/bigIceBlock.c2
-rw-r--r--src/object/bird.c2
-rw-r--r--src/object/book.c2
-rw-r--r--src/object/crenelBeanSprout.c8
-rw-r--r--src/object/fileScreenObjects.c4
-rw-r--r--src/object/frozenOctorok.c2
-rw-r--r--src/object/houseDoorExterior.c2
-rw-r--r--src/object/houseDoorInterior.c2
-rw-r--r--src/object/itemForSale.c6
-rw-r--r--src/object/lampParticle.c2
-rw-r--r--src/object/lilypadLarge.c2
-rw-r--r--src/object/macroPlayer.c5
-rw-r--r--src/object/minecart.c8
-rw-r--r--src/object/minishSizedEntrance.c2
-rw-r--r--src/object/octorokBossObject.c4
-rw-r--r--src/object/playerClone.c2
-rw-r--r--src/object/pot.c2
-rw-r--r--src/object/pullableMushroom.c6
-rw-r--r--src/object/pushableRock.c2
-rw-r--r--src/object/smallIceBlock.c2
-rw-r--r--src/object/smokeParticle.c2
-rw-r--r--src/object/swordParticle.c4
-rw-r--r--src/object/thunderbold.c2
-rw-r--r--src/object/unusedSkull.c2
-rw-r--r--src/objectDefinitions.c176
-rw-r--r--src/objectUtils.c4
-rw-r--r--src/physics.c6
-rw-r--r--src/player.c191
-rw-r--r--src/playerItem.c51
-rw-r--r--src/playerItem/playerItemBomb.c10
-rw-r--r--src/playerItem/playerItemBoomerang.c30
-rw-r--r--src/playerItem/playerItemBow.c6
-rw-r--r--src/playerItem/playerItemFireRodProjectile.c2
-rw-r--r--src/playerItem/playerItemGust.c2
-rw-r--r--src/playerItem/playerItemHeldObject.c6
-rw-r--r--src/playerItem/playerItemLantern.c2
-rw-r--r--src/playerItem/playerItemShield.c16
-rw-r--r--src/playerItem/playerItemSword.c10
-rw-r--r--src/playerItem/playerItemSwordBeam.c4
-rw-r--r--src/playerItemUtils.c4
-rw-r--r--src/playerUtils.c581
-rw-r--r--src/projectile/v1DarkMagicProjectile.c4
-rw-r--r--src/scroll.c2
-rw-r--r--src/sound.c4
107 files changed, 1420 insertions, 1351 deletions
diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c
index c0a82532..0b872fca 100644
--- a/src/beanstalkSubtask.c
+++ b/src/beanstalkSubtask.c
@@ -39,7 +39,16 @@ extern const u16* gUnk_080B4550[];
extern const u16 gUnk_080B77C0[];
extern BgAnimationFrame* gUnk_080B7278[];
-void sub_0801AD6C(u16*, u32);
+typedef struct {
+ u16 tileType;
+ u16 kind;
+ u16 id;
+ u16 type;
+ u16 type2;
+ u16 unk_a;
+} Data;
+
+void sub_0801AD6C(const Data*, u32);
bool32 sub_0801A4F8(void);
bool32 sub_0801AA58(Entity*, u32, u32);
void sub_0801AB08(u16*, LayerStruct*);
@@ -146,7 +155,7 @@ NONMATCH("asm/non_matching/beanstalkSubtask/sub_0801A2B0.inc",
u32 temp5;
uVar1 = gUnk_080B4488[gPlayerEntity.animationState >> 1];
- if ((((gPlayerState.field_0x35 | gPlayerState.field_0xd) & 0x80) == 0) && ((gPlayerEntity.frame & 1) != 0)) {
+ if ((((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) == 0) && ((gPlayerEntity.frame & 1) != 0)) {
position = (u16)(position + uVar1);
temp4 = sub_080B1B54(GetTileType(position, gPlayerEntity.collisionLayer));
switch (temp4) {
@@ -264,10 +273,10 @@ bool32 sub_0801A4F8(void) {
if (GetInventoryValue(ITEM_POWER_BRACELETS) != 1) {
return FALSE;
}
- if ((gPlayerState.field_0xd & 0x80) != 0) {
+ if ((gPlayerState.direction & 0x80) != 0) {
return FALSE;
}
- if (gPlayerState.field_0xd != gPlayerEntity.direction) {
+ if (gPlayerState.direction != gPlayerEntity.direction) {
return FALSE;
}
tmp = (((gPlayerEntity.direction + 4) & 0x18) >> 3);
@@ -275,7 +284,7 @@ bool32 sub_0801A4F8(void) {
return FALSE;
}
} else {
- if (((gPlayerState.field_0x35 | gPlayerState.field_0xd) & 0x80) != 0) {
+ if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) {
return FALSE;
}
if ((gPlayerEntity.frame & 1) == 0) {
@@ -411,19 +420,18 @@ u32 sub_0801AC68(u32 position, u32 data) {
return data << 2;
}
-extern const u16 gUnk_080B44C0[];
-extern const u16 gUnk_080B44C2[];
+extern const Data gUnk_080B44C0[];
+extern const Data gUnk_080B44C2[];
extern const u32 gUnk_080B44B8[];
NONMATCH("asm/non_matching/beanstalkSubtask/sub_0801AC98.inc", void sub_0801AC98()) {
+ u32 width;
u32 height;
u32 indexX;
- u32 width;
u32 indexY;
- const u16* puVar7;
+ const Data* ptr1;
+ const Data* ptr2;
u32 position;
- const u32* ptr;
- u32 tmp;
width = gRoomControls.width >> 4;
height = gRoomControls.height >> 4;
@@ -431,32 +439,30 @@ NONMATCH("asm/non_matching/beanstalkSubtask/sub_0801AC98.inc", void sub_0801AC98
for (indexY = 0; indexY < height; indexY++) {
for (indexX = 0; indexX < width; indexX++, position++) {
- for (puVar7 = gUnk_080B44C0; puVar7[0] != 0xffff; puVar7 += 6) {
- if (puVar7[0] == GetTileType(position, 1)) {
- ptr = gUnk_080B44B8 + puVar7[5];
- if (ptr[0] != 0) {
- sub_0801AD6C((u16*)puVar7, position);
+ for (ptr1 = gUnk_080B44C0; ptr1->tileType != 0xffff; ptr1++) {
+ if (ptr1->tileType == GetTileType(position, 1)) {
+ if (gUnk_080B44B8[ptr1->unk_a] != 0) {
+ sub_0801AD6C(ptr1, position);
break;
}
}
}
- for (puVar7 = gUnk_080B44C2; puVar7[0] != 0xffff; puVar7 += 6) {
- if (puVar7[0] == GetTileType(position, 2)) {
- ptr = gUnk_080B44B8 + puVar7[5];
- if (ptr[0] != 0) {
- sub_0801AD6C((u16*)puVar7, position);
+
+ for (ptr2 = gUnk_080B44C2; ptr2->tileType != 0xffff; ptr2++) {
+ if (ptr2->tileType == GetTileType(position, 2)) {
+ if (gUnk_080B44B8[ptr2->unk_a] != 0) {
+ sub_0801AD6C(ptr2, position);
break;
}
}
}
}
- tmp = (position + 0x40);
- position = tmp - width;
+ position = position + (0x40 - width);
}
}
END_NONMATCH
-void sub_0801AD6C(u16* param_1, u32 param_2) {
+void sub_0801AD6C(const Data* param_1, u32 tilePosition) {
Entity* entity;
Manager* manager;
s32 tmpX1;
@@ -464,16 +470,16 @@ void sub_0801AD6C(u16* param_1, u32 param_2) {
s32 tmpX2;
s32 tmpY2;
- if (param_1[1] != MANAGER) {
+ if (param_1->kind != MANAGER) {
entity = GetEmptyEntity();
if (entity != NULL) {
- entity->kind = (u8)param_1[1];
- entity->id = (u8)param_1[2];
- entity->type = (u8)param_1[3];
- entity->type2 = (u8)param_1[4];
- tmpX1 = ((u16)param_2 & 0x3f) * 0x10 + 8;
+ entity->kind = (u8)param_1->kind;
+ entity->id = (u8)param_1->id;
+ entity->type = (u8)param_1->type;
+ entity->type2 = (u8)param_1->type2;
+ tmpX1 = ((u16)tilePosition & 0x3f) * 0x10 + 8;
entity->x.HALF.HI = tmpX1 + gRoomControls.origin_x;
- tmpY1 = (s16)((param_2 & 0xfc0) >> 2) + 8;
+ tmpY1 = (s16)((tilePosition & 0xfc0) >> 2) + 8;
entity->y.HALF.HI = tmpY1 + gRoomControls.origin_y;
entity->collisionLayer = 0;
ResolveCollisionLayer(entity);
@@ -482,14 +488,14 @@ void sub_0801AD6C(u16* param_1, u32 param_2) {
} else {
manager = GetEmptyManager();
if (manager != NULL) {
- manager->kind = (u8)param_1[1];
- manager->id = (u8)param_1[2];
- manager->type = (u8)param_1[3];
- manager->type2 = (u8)param_1[4];
+ manager->kind = (u8)param_1->kind;
+ manager->id = (u8)param_1->id;
+ manager->type = (u8)param_1->type;
+ manager->type2 = (u8)param_1->type2;
// TODO are these fields common for all managers or does this usually create managers of certain types?
- tmpX2 = ((u16)param_2 & 0x3f) * 0x10 + 8;
+ tmpX2 = ((u16)tilePosition & 0x3f) * 0x10 + 8;
*(u16*)(&manager[1].timer + 10) = tmpX2 + gRoomControls.origin_x;
- tmpY2 = (s16)((param_2 & 0xfc0) >> 2) + 8;
+ tmpY2 = (s16)((tilePosition & 0xfc0) >> 2) + 8;
*(u16*)(&manager[1].timer + 12) = tmpY2 + gRoomControls.origin_y;
AppendEntityToList((Entity*)manager, gUnk_081091E4[manager->kind]);
}
diff --git a/src/collision.c b/src/collision.c
index 7b6f2cb4..d857d56b 100644
--- a/src/collision.c
+++ b/src/collision.c
@@ -1,17 +1,26 @@
-#include "global.h"
#include "asm.h"
-#include "entity.h"
-#include "player.h"
-#include "save.h"
+#include "collision.h"
#include "common.h"
-#include "functions.h"
#include "enemy.h"
-#include "object.h"
+#include "entity.h"
+#include "functions.h"
#include "game.h"
+#include "global.h"
+#include "item.h"
+#include "object.h"
+#include "player.h"
+#include "save.h"
extern u8 gCollidableCount;
extern u8 gUnk_080B3740[];
+typedef enum {
+ COL_FLAG_1 = 1,
+ COL_FLAG_2 = 2,
+ COL_FLAG_4 = 4,
+ COL_FLAG_8 = 8,
+} ColSettingsFlags;
+
typedef struct {
/*0x00*/ u8 orgKnockbackSpeed;
/*0x01*/ u8 orgIframes;
@@ -23,8 +32,8 @@ typedef struct {
/*0x07*/ u8 tgtKnockbackDuration;
/*0x08*/ u8 orgDamage;
/*0x09*/ u8 tgtConfusedTime;
- /*0x0a*/ u8 _a;
- /*0x0b*/ u8 _b;
+ /*0x0a*/ u8 flags; /**< @see ColSettingsFlags */
+ /*0x0b*/ u8 pad;
} ColSettings;
extern ColSettings gCollisionMtx[173 * 34];
@@ -32,10 +41,8 @@ extern ColSettings gCollisionMtx[173 * 34];
extern void ram_CollideAll(void);
u32 sub_08081420(Entity*);
extern void SoundReqClipped(Entity*, u32);
-s32 sub_08018308(Entity*, Entity*, u32, ColSettings*);
void sub_08079D84(void);
void sub_080180BC(Entity*, Entity*);
-void sub_0807AFE8(void);
typedef struct {
void* last;
@@ -208,51 +215,49 @@ bool32 IsCollidingPlayer(Entity* this) {
return FALSE;
}
-s32 sub_08017874(Entity* a, Entity* b) {
- s32 newDmg;
- s32 v5;
- s32 v6;
+s32 CalculateDamage(Entity* org, Entity* tgt) {
+ s32 damage;
+ s32 health;
- asm("" ::: "r1");
- if (a->kind == PLAYER) {
- newDmg = b->damage;
+ if (org->kind == PLAYER) {
+ damage = tgt->damage;
switch (gSave.stats.charm) {
- case 47:
- newDmg /= 4;
+ case BOTTLE_CHARM_NAYRU:
+ damage /= 4;
break;
- case 48:
- newDmg /= 2;
+ case BOTTLE_CHARM_FARORE:
+ damage /= 2;
break;
}
- if (newDmg <= 0)
- newDmg = 1;
- v5 = ModHealth(-newDmg);
- SoundReqClipped(a, SFX_PLY_VO6);
+ if (damage <= 0)
+ damage = 1;
+ health = ModHealth(-damage);
+ SoundReqClipped(org, SFX_PLY_VO6);
} else {
- v6 = b->damage;
- if (b->kind == PLAYER_ITEM) {
+ damage = tgt->damage;
+ if (tgt->kind == PLAYER_ITEM) {
switch (gSave.stats.charm) {
- case 48:
- v6 = 3 * v6 / 2;
+ case BOTTLE_CHARM_FARORE:
+ damage = 3 * damage / 2;
break;
- case 49:
- v6 *= 2;
+ case BOTTLE_CHARM_DIN:
+ damage *= 2;
break;
}
}
- v5 = a->health - v6;
- if (a->kind == ENEMY) {
- if ((a->field_0x6c.HALF.HI & 1) != 0)
- SoundReqClipped(a, SFX_BOSS_HIT);
+ health = org->health - damage;
+ if (org->kind == ENEMY) {
+ if ((org->field_0x6c.HALF.HI & 1) != 0)
+ SoundReqClipped(org, SFX_BOSS_HIT);
else
- SoundReqClipped(a, SFX_HIT);
+ SoundReqClipped(org, SFX_HIT);
}
}
- if (v5 <= 0) {
- COLLISION_OFF(a);
+ if (health <= 0) {
+ COLLISION_OFF(org);
return 0;
}
- return v5;
+ return health;
}
void sub_08017940(Entity* org, Entity* tgt) {
@@ -308,51 +313,71 @@ Entity* sub_08017A90(Entity* a1, Entity* parent) {
return NULL;
}
-typedef s32 (*CollisionHandler)(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08018288(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
-
-const CollisionHandler gUnk_080B3744[] = {
- sub_08018308, CollisionNoOp, CollisionNoOp, CollisionGroundItem, sub_08017B58, sub_08017EB0,
- sub_08017F3C, sub_08017F40, sub_0801802C, sub_08017DD4, sub_080180E8, sub_08017BBC,
- sub_08017C40, sub_08017D6C, sub_08017D28, sub_08018168, sub_08018228, sub_08018250,
- sub_08018288, sub_080182A8, sub_08017B1C, sub_08017CBC, sub_08017E88,
+typedef CollisionResult (*CollisionHandler)(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult CollisionDefault(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult CollisionMazaalShrinkRay(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+CollisionResult sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
+
+const CollisionHandler gCollisionHandlers[] = {
+ CollisionDefault,
+ CollisionNoOp,
+ CollisionNoOp,
+ CollisionGroundItem,
+ sub_08017B58,
+ sub_08017EB0,
+ sub_08017F3C,
+ sub_08017F40,
+ sub_0801802C,
+ sub_08017DD4,
+ sub_080180E8,
+ sub_08017BBC,
+ sub_08017C40,
+ sub_08017D6C,
+ sub_08017D28,
+ sub_08018168,
+ sub_08018228,
+ sub_08018250,
+ CollisionMazaalShrinkRay,
+ sub_080182A8,
+ sub_08017B1C,
+ sub_08017CBC,
+ sub_08017E88,
};
-s32 CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
- return 0;
+CollisionResult CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+ return RESULT_NO_COLLISION;
}
// origin: player or sword
// target: item
-s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
COLLISION_OFF(tgt);
tgt->contactFlags = org->hurtType | 0x80;
if ((tgt->type == 0x5F || tgt->type == 0x60) && sub_08081420(tgt))
tgt->health = 0;
- return 2;
+ return RESULT_COLLISION_WITHOUT_SET;
}
-s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.dash_state & 0x60) != 0) {
COLLISION_OFF(tgt);
} else {
@@ -360,10 +385,10 @@ s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
org->iframes = -20;
org->knockbackSpeed = 640;
}
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((tgt->gustJarState & 4) != 0) {
if (tgt->gustJarTolerance) {
tgt->gustJarTolerance = tgt->gustJarTolerance - gPlayerState.gustJarSpeed;
@@ -379,10 +404,10 @@ s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
if (tgt->iframes == 0)
tgt->iframes = -1;
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.flags & (PL_BUSY | PL_MINISH | PL_BURNING | PL_IN_MINECART)) == 0) {
Entity* e = CreateObject(LINK_FIRE, 1, 0);
if (e != NULL) {
@@ -392,21 +417,21 @@ s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
}
tgt->damage = 4;
- org->health = sub_08017874(org, tgt);
+ org->health = CalculateDamage(org, tgt);
org->knockbackDuration = 12;
org->iframes = 30;
org->knockbackSpeed = 384;
if (tgt->iframes == 0)
tgt->iframes = -1;
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.flags & (PL_BUSY | PL_MINISH | PL_FROZEN | PL_IN_MINECART)) == 0 &&
gPlayerState.queued_action == PLAYER_INIT) {
if (org->action == 1 || org->action == 24) {
tgt->damage = 4;
- org->health = sub_08017874(org, tgt);
+ org->health = CalculateDamage(org, tgt);
gPlayerState.flags = PL_FROZEN;
gPlayerState.queued_action = PLAYER_FROZEN;
}
@@ -416,10 +441,10 @@ s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
org->knockbackSpeed = 640;
if (tgt->iframes == 0)
tgt->iframes = -1;
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
direction = DirectionNormalize(DirectionTurnAround(direction) - 0xc);
if (DirectionNormalize(-direction + tgt->direction) < 0x19) {
org->iframes = -12;
@@ -433,10 +458,10 @@ s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
if (org->iframes == 0)
org->iframes = -1;
}
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
gPlayerState.mobility = 1;
org->field_0x7a.HWORD = 600;
org->knockbackDuration = 12;
@@ -444,10 +469,10 @@ s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
org->knockbackSpeed = 640;
if (tgt->iframes == 0)
tgt->iframes = -1;
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 x;
u32 y;
ColSettings* p;
@@ -463,16 +488,16 @@ s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
y = 0xae4;
}
p = &gCollisionMtx[x + y];
- return sub_08018308(org, tgt, direction, p);
+ return CollisionDefault(org, tgt, direction, p);
}
-int sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->contactFlags = 0;
if (tgt->damage & 0x80)
tgt->damage &= ~0x80;
else
tgt->damage = 4;
- gPlayerEntity.health = sub_08017874(&gPlayerEntity, tgt);
+ gPlayerEntity.health = CalculateDamage(&gPlayerEntity, tgt);
tgt->iframes = -12;
if ((gPlayerState.flags & PL_MINISH) == 0) {
sub_08079D84();
@@ -486,25 +511,25 @@ int sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
if (tgt->iframes == 0)
tgt->iframes = -1;
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->knockbackDuration = 2;
org->knockbackSpeed = 640;
if (tgt->iframes == 0)
tgt->iframes = -1;
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->damage == 0)
- return 0;
+ return RESULT_NO_COLLISION;
if (org == &gPlayerEntity) {
- u32 temp = tgt->damage;
+ u32 prevDamage = tgt->damage;
tgt->damage = 8;
- gPlayerEntity.health = sub_08017874(&gPlayerEntity, tgt);
- tgt->damage = temp;
+ gPlayerEntity.health = CalculateDamage(&gPlayerEntity, tgt);
+ tgt->damage = prevDamage;
gPlayerEntity.knockbackDuration = 12;
gPlayerEntity.iframes = 16;
gPlayerEntity.knockbackSpeed = 384;
@@ -516,14 +541,14 @@ s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
if (tgt->iframes == 0)
tgt->iframes = -1;
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
- return 1;
+CollisionResult sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+ return RESULT_COLLISION;
}
-s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->confusedTime == 0) {
if (org == &gPlayerEntity) {
if (PlayerCanBeMoved() &&
@@ -548,8 +573,8 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
org->spriteOrientation.flipY = tgt->spriteOrientation.flipY;
org->iframes = -1;
tgt->iframes = -8;
- ResetPlayerItem();
- return 1;
+ ResetActiveItems();
+ return RESULT_COLLISION;
}
} else {
org->health = 0;
@@ -557,39 +582,39 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
} else if (tgt->kind == ENEMY && org == &gPlayerEntity) {
sub_08004484(tgt, org);
}
- return 0;
+ return RESULT_NO_COLLISION;
}
-s32 sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
int kind;
u32 x;
kind = org->kind;
- if (kind == 1) {
+ if (kind == PLAYER) {
if (PlayerCanBeMoved()) {
if (((DirectionNormalize(DirectionTurnAround(direction) -
Direction8FromAnimationState(tgt->animationState) + 5))) > 0xA) {
x = 0x11aa;
- return sub_08018308(org, tgt, direction, &gCollisionMtx[x + org->hurtType]);
+ return CollisionDefault(org, tgt, direction, &gCollisionMtx[x + org->hurtType]);
} else {
sub_080180BC(org, tgt);
- return 1;
+ return RESULT_COLLISION;
}
}
- } else if (kind == 8) {
+ } else if (kind == PLAYER_ITEM) {
if (DirectionNormalize(
(DirectionTurnAround(org->direction) - Direction8FromAnimationState(tgt->animationState) + 5)) <= 0xA) {
org->health = 0;
sub_080180BC(org, tgt);
- return 1;
+ return RESULT_COLLISION;
}
} else {
org->health = 0;
- return 0;
+ return RESULT_NO_COLLISION;
}
x = 0x11aa;
- return sub_08018308(org, tgt, direction, &gCollisionMtx[x + org->hurtType]);
+ return CollisionDefault(org, tgt, direction, &gCollisionMtx[x + org->hurtType]);
}
void sub_080180BC(Entity* org, Entity* tgt) {
@@ -600,7 +625,7 @@ void sub_080180BC(Entity* org, Entity* tgt) {
tgt->subAction = -1;
}
-s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 v3;
u32 x;
@@ -613,13 +638,13 @@ s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
tgt->iframes = -16;
tgt->knockbackSpeed = 768;
sub_08017940(org, tgt);
- return 1;
+ return RESULT_COLLISION;
}
x = 0x352;
- return sub_08018308(org, tgt, v3, &gCollisionMtx[org->hurtType + x]);
+ return CollisionDefault(org, tgt, v3, &gCollisionMtx[org->hurtType + x]);
}
-s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->confusedTime == 0) {
if (org == &gPlayerEntity) {
if (PlayerCanBeMoved() &&
@@ -639,7 +664,7 @@ s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
gPlayerEntity.iframes = 0xff;
tgt->iframes = -8;
PutAwayItems();
- return 1;
+ return RESULT_COLLISION;
}
} else {
org->health = 0;
@@ -647,16 +672,16 @@ s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
} else if ((tgt->kind == ENEMY) && (org == &gPlayerEntity)) {
sub_08004484(tgt, &gPlayerEntity);
}
- return 0;
+ return RESULT_NO_COLLISION;
}
-s32 sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (org == &gPlayerEntity && PlayerCanBeMoved())
sub_08004484(tgt, org);
- return 0;
+ return RESULT_NO_COLLISION;
}
-s32 sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->iframes = -1;
if (org->direction == 0) {
tgt->iframes = 16;
@@ -664,18 +689,18 @@ s32 sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
} else {
tgt->iframes = -1;
}
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08018288(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult CollisionMazaalShrinkRay(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (org == &gPlayerEntity)
- sub_0807AFE8();
+ PlayerShrinkByRay();
else
org->health = 0;
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->confusedTime == 0) {
if (org->iframes == 0)
org->iframes = -1;
@@ -683,12 +708,12 @@ s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
tgt->iframes = -1;
} else {
u32 x = 0x92a;
- return sub_08018308(org, tgt, direction, &gCollisionMtx[org->hurtType + x]);
+ return CollisionDefault(org, tgt, direction, &gCollisionMtx[org->hurtType + x]);
}
- return 1;
+ return RESULT_COLLISION;
}
-s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
+CollisionResult CollisionDefault(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 confused = 0;
if (tgt->confusedTime && tgt->kind == ENEMY && org == &gPlayerEntity) {
sub_08004484(tgt, org);
@@ -697,7 +722,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
if ((org->kind == PLAYER_ITEM && org->id == PL_ITEM_SHIELD) &&
gPlayerEntity.animationState ==
AnimationStateFlip180(Direction8ToAnimationState(DirectionRoundUp(direction)))) {
- return 0;
+ return RESULT_NO_COLLISION;
}
if (!confused) {
u32 tmp2;
@@ -709,7 +734,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
tgt->damage = settings->tgtDamage;
tmp2 = 0xFF;
if (settings->tgtDamage != 0)
- org->health = sub_08017874(org, tgt);
+ org->health = CalculateDamage(org, tgt);
if (settings->orgConfusedTime > org->confusedTime)
org->confusedTime = settings->orgConfusedTime;
tgt->knockbackSpeed = 16 * settings->tgtKnockbackSpeed;
@@ -719,15 +744,15 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
tgt->knockbackDuration = settings->tgtKnockbackDuration;
tmp2 &= (org->damage = settings->orgDamage);
if (tmp2 != 0)
- tgt->health = sub_08017874(tgt, org);
+ tgt->health = CalculateDamage(tgt, org);
if (settings->tgtConfusedTime > tgt->confusedTime)
tgt->confusedTime = settings->tgtConfusedTime;
}
- if (settings->_a & 1)
+ if (settings->flags & COL_FLAG_1)
sub_08017940(org, tgt);
- if (settings->_a & 2)
+ if (settings->flags & COL_FLAG_2)
org->contactFlags = 0xca;
- if (settings->_a & 4) {
+ if (settings->flags & COL_FLAG_4) {
Entity* parent = tgt->parent;
if (parent != NULL) {
parent->contactFlags = 0xcc;
@@ -746,7 +771,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
sub_080179EC(org, tgt);
}
} else if (org->id == PL_ITEM_BOW) {
- if (org->damage || (settings->_a & 8)) {
+ if (org->damage || (settings->flags & COL_FLAG_8)) {
sub_08017A90(org, tgt);
}
} else if (org->id == PL_ITEM_BOOMERANG) {
@@ -760,5 +785,5 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
if (tgt->kind == PLAYER_ITEM && org->id == PL_ITEM_SHIELD) {
gPlayerEntity.iframes = 0x80;
}
- return 1;
+ return RESULT_COLLISION;
}
diff --git a/src/color.c b/src/color.c
index 5add643a..01e678e8 100644
--- a/src/color.c
+++ b/src/color.c
@@ -30,8 +30,8 @@ void ResetPaletteTable(u32 a1) {
sub_0801D000(a1);
}
-void sub_0801CFD0(u32 a1) {
- Palette* p = &gPaletteList[a1];
+void sub_0801CFD0(u32 index) {
+ Palette* p = &gPaletteList[index];
p->_0_0 = 4;
p->_0_4 = 1;
p->_1 = 0x80;
diff --git a/src/enemy/armos.c b/src/enemy/armos.c
index 709f0630..7e0c3b7a 100644
--- a/src/enemy/armos.c
+++ b/src/enemy/armos.c
@@ -69,11 +69,11 @@ void sub_080300E8(void) {
}
}
-void sub_08030118(u32 param_1) {
- if (((s32)(u32)gRoomTransition.armos_data.field_0xac >> (param_1)&1) != 0) {
- SetLocalFlagByBank(FLAG_BANK_3, param_1 + 0x67);
+void sub_08030118(u32 armosId) {
+ if (((gRoomTransition.armos_data.field_0xac >> armosId) & 1) != 0) {
+ SetLocalFlagByBank(FLAG_BANK_3, armosId + 0x67);
} else {
- ClearLocalFlagByBank(FLAG_BANK_3, param_1 + 0x67);
+ ClearLocalFlagByBank(FLAG_BANK_3, armosId + 0x67);
}
}
diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c
index 63ef0959..ace73b7f 100644
--- a/src/enemy/beetle.c
+++ b/src/enemy/beetle.c
@@ -252,7 +252,7 @@ void sub_08021B64(Entity* this) {
} else {
gPlayerState.mobility |= 0x80;
gPlayerState.speed_modifier -= 0x50;
- gPlayerState.field_0xaa++;
+ gPlayerState.attachedBeetleCount++;
CopyPositionAndSpriteOffset(&gPlayerEntity, this);
this->x.HALF.HI += gUnk_080CB5E4[(this->subtimer++ & 0xe) >> 1];
this->z.HALF.HI--;
diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c
index ea2eab93..2726a05c 100644
--- a/src/enemy/chuchuBoss.c
+++ b/src/enemy/chuchuBoss.c
@@ -1830,7 +1830,7 @@ Entity* sub_08027D20(ChuchuBossEntity* this) {
r4->spriteVramOffset = super->spriteVramOffset;
r4->palette.b.b0 = super->palette.b.b0;
#endif
- r4->y.HALF.HI += 1;
+ r4->y.HALF.HI++;
r4->spriteOffsetY = 8;
#ifndef EU
LoadFixedGFX(r4, 0x3e);
diff --git a/src/enemy/dust.c b/src/enemy/dust.c
index 74da343e..9880333a 100644
--- a/src/enemy/dust.c
+++ b/src/enemy/dust.c
@@ -277,7 +277,7 @@ void sub_08044498(DustEntity* this) {
u32 xdiff, ydiff;
uVar4 = COORD_TO_TILE(&gPlayerEntity);
- tmp = (gPlayerState.playerInput.field_0x92 & 0xf00);
+ tmp = (gPlayerState.playerInput.newInput & 0xf00);
if (tmp != this->unk_75 || uVar4 != this->unk_76) {
this->unk_75 = tmp;
this->unk_76 = uVar4;
diff --git a/src/enemy/enemy64.c b/src/enemy/enemy64.c
index e1b3e51a..5cfd1a60 100644
--- a/src/enemy/enemy64.c
+++ b/src/enemy/enemy64.c
@@ -411,13 +411,13 @@ void Enemy64_Action4_SubAction5(Enemy64Entity* this) {
super->subAction = 6;
super->spriteSettings.draw = 0;
entity = super->child;
- entity->flags &= 0x7f;
+ entity->flags &= ~0x80;
entity->spriteSettings.draw = 0;
entity = entity->child;
- entity->flags &= 0x7f;
+ entity->flags &= ~0x80;
entity->spriteSettings.draw = 0;
entity = entity->child;
- entity->flags &= 0x7f;
+ entity->flags &= ~0x80;
entity->spriteSettings.draw = 0;
entity = &gPlayerEntity;
entity->x.HALF.HI = gRoomControls.origin_x + 0xa8;
diff --git a/src/enemy/ghini.c b/src/enemy/ghini.c
index 86b9f00c..d74709c7 100644
--- a/src/enemy/ghini.c
+++ b/src/enemy/ghini.c
@@ -384,7 +384,7 @@ void sub_0803F6EC(GhiniEntity* this) {
}
void sub_0803F738(GhiniEntity* this) {
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
sub_0806FA90(&gPlayerEntity, super, 0, 1);
diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c
index 5d6fac5d..f28fb1e4 100644
--- a/src/enemy/gibdo.c
+++ b/src/enemy/gibdo.c
@@ -166,7 +166,7 @@ void sub_08037690(GibdoEntity* this) {
void sub_080376D0(GibdoEntity* this) {
if (!sub_080379EC(this)) {
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
CopyPositionAndSpriteOffset(&gPlayerEntity, super);
diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c
index 319e9add..0fea006f 100644
--- a/src/enemy/gleerok.c
+++ b/src/enemy/gleerok.c
@@ -1076,7 +1076,7 @@ void sub_0802E300(GleerokEntity* this) {
}
}
- this->unk_79 &= 0x7f;
+ this->unk_79 &= ~0x80;
heap = this->unk_84;
dir = sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity)) << 3;
index = 0;
diff --git a/src/enemy/gyorgMaleEye.c b/src/enemy/gyorgMaleEye.c
index 51ecacd4..8f257b7c 100644
--- a/src/enemy/gyorgMaleEye.c
+++ b/src/enemy/gyorgMaleEye.c
@@ -90,7 +90,7 @@ void GyorgMaleEye_Action2(GyorgMaleEyeEntity* this) {
sub_08048F50(this);
if (--super->timer == 0) {
super->action = 3;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
InitializeAnimation(super, super->animIndex + 4);
}
}
diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c
index 9125158f..886aa8b7 100644
--- a/src/enemy/likeLike.c
+++ b/src/enemy/likeLike.c
@@ -198,7 +198,7 @@ void sub_0802805C(LikeLikeEntity* this) {
if (super->subtimer >= 0x19 || gSave.stats.health == 0) {
LikeLike_ReleasePlayer(this);
} else {
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.mobility |= 0x80;
PositionRelative(super, &gPlayerEntity, 0, Q_16_16(1.0));
diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c
index 08aadab8..d21e8636 100644
--- a/src/enemy/mazaalBracelet.c
+++ b/src/enemy/mazaalBracelet.c
@@ -557,7 +557,7 @@ void sub_0803A978(Entity* this) {
this->action = 0x12;
this->timer = 3;
COLLISION_OFF(this);
- *(u8*)(*(int*)&this->field_0x74 + 0x10) &= 0x7f;
+ *(u8*)(*(int*)&this->field_0x74 + 0x10) &= ~0x80;
InitializeAnimation(this, 8);
InitAnimationForceUpdate(this->child, 3);
}
@@ -1244,7 +1244,7 @@ void sub_0803B804(Entity* this) {
}
void sub_0803B824(Entity* this) {
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.mobility |= 0x80;
sub_0806FA90(this, &gPlayerEntity, gUnk_080CFD1D[this->type], 1);
gPlayerEntity.spriteOffsetY = -6;
diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c
index f0fb29b2..be66f3da 100644
--- a/src/enemy/miniFireballGuy.c
+++ b/src/enemy/miniFireballGuy.c
@@ -39,7 +39,7 @@ void MiniFireballGuy_OnCollision(Entity* this) {
void MiniFireballGuy_OnDeath(Entity* this) {
if ((this != this->parent) && (this->parent != NULL)) {
- this->field_0x6c.HALF.LO &= 0x7f;
+ this->field_0x6c.HALF.LO &= ~0x80;
this->parent->child = this->child;
this->child->parent = this->parent;
}
diff --git a/src/enemy/miniSlime.c b/src/enemy/miniSlime.c
index 6352e5ee..67e7675b 100644
--- a/src/enemy/miniSlime.c
+++ b/src/enemy/miniSlime.c
@@ -50,7 +50,7 @@ void MiniSlime_OnCollision(Entity* this) {
void MiniSlime_OnDeath(Entity* this) {
Entity* parent = this->parent;
if ((this != parent) && (parent != NULL)) {
- this->field_0x6c.HALF.LO &= 0x7f;
+ this->field_0x6c.HALF.LO &= ~0x80;
this->parent->child = this->child;
this->child->parent = this->parent;
if (this->field_0x6c.HALF.HI & 0x40)
diff --git a/src/enemy/mulldozer.c b/src/enemy/mulldozer.c
index 44404582..fbb376e0 100644
--- a/src/enemy/mulldozer.c
+++ b/src/enemy/mulldozer.c
@@ -237,7 +237,7 @@ void sub_08033000(MulldozerEntity* this) {
super->subtimer = 16;
if ((this->unk_82 & 0x80) != 0) {
super->direction = (super->direction + 0x18) & 0x1c;
- this->unk_82 &= 0x7f;
+ this->unk_82 &= ~0x80;
} else {
super->direction = (super->direction + 8) & 0x1c;
this->unk_82 |= 0x80;
diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c
index c9343196..aea3acb2 100644
--- a/src/enemy/octorokBoss.c
+++ b/src/enemy/octorokBoss.c
@@ -1226,7 +1226,7 @@ void sub_08036F60(OctorokBossEntity* this) {
void OctorokBoss_StepSound(OctorokBossEntity* this, u32 frameMask) {
if ((gRoomTransition.frameCount & frameMask) == 0) {
if (IS_FROZEN(this) == FALSE) {
- SoundReq(SFX_163);
+ SoundReq(SFX_TOGGLE_DIVING);
} else {
SoundReq(SFX_ICE_BLOCK_SLIDE);
}
diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c
index a9552cc9..b395ba9e 100644
--- a/src/enemy/pesto.c
+++ b/src/enemy/pesto.c
@@ -828,7 +828,7 @@ void sub_08024E4C(Entity* this) {
sub_08024A14(this, 0, 8);
} else {
Entity* player = &gPlayerEntity;
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.flags |= PL_DISABLE_ITEMS;
gPlayerState.field_0xa |= 0x80;
gPlayerState.queued_action = PLAYER_0807204C;
diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c
index c9e4833f..39a8e586 100644
--- a/src/enemy/rupeeLike.c
+++ b/src/enemy/rupeeLike.c
@@ -167,7 +167,7 @@ void sub_0802953C(Entity* this) {
if (((this->subtimer > 0x2d) || (gSave.stats.rupees == 0)) && (this->timer == 0)) {
sub_080296D8(this);
} else {
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.mobility |= 0x80;
PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0));
pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex);
diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c
index 8f013a02..49afbea7 100644
--- a/src/enemy/vaatiProjectile.c
+++ b/src/enemy/vaatiProjectile.c
@@ -226,7 +226,7 @@ void VaatiProjectileFunction0Action9(Entity* this) {
}
void sub_0803E444(Entity* this) {
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
sub_0806FA90(this, this->contactedEntity, 0, -2);
diff --git a/src/enemy/wizzrobeFire.c b/src/enemy/wizzrobeFire.c
index ef83c4f8..820bd8ea 100644
--- a/src/enemy/wizzrobeFire.c
+++ b/src/enemy/wizzrobeFire.c
@@ -113,7 +113,7 @@ void WizzrobeFire_Action2(WizzrobeEntity* this) {
this->timer1 = 0x28;
super->timer = 40;
super->subtimer = 0;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
EnqueueSFX(SFX_156);
InitializeAnimation(super, super->direction >> 3);
diff --git a/src/enemy/wizzrobeIce.c b/src/enemy/wizzrobeIce.c
index a467200d..edd48331 100644
--- a/src/enemy/wizzrobeIce.c
+++ b/src/enemy/wizzrobeIce.c
@@ -120,7 +120,7 @@ void WizzrobeIce_Action2(WizzrobeEntity* this) {
this->timer1 = 0x28;
super->timer = 40;
super->subtimer = 0;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
EnqueueSFX(SFX_156);
InitializeAnimation(super, super->direction >> 3);
diff --git a/src/enemy/wizzrobeWind.c b/src/enemy/wizzrobeWind.c
index ed28e49f..4d407677 100644
--- a/src/enemy/wizzrobeWind.c
+++ b/src/enemy/wizzrobeWind.c
@@ -136,7 +136,7 @@ void WizzrobeWind_Action2(WizzrobeEntity* this) {
this->timer1 = 0x28;
super->timer = 40;
super->subtimer = 0;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
EnqueueSFX(SFX_156);
SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
InitializeAnimation(super, super->direction >> 3);
@@ -264,7 +264,7 @@ void sub_0802F9C8(WizzrobeEntity* this) {
if (super->type2 != 0) {
ProcessMovement0(super);
if (super->collisions != COL_NONE) {
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
this->timer1 = 0x28;
}
}
diff --git a/src/game.c b/src/game.c
index 19740478..d70d19fd 100644
--- a/src/game.c
+++ b/src/game.c
@@ -972,10 +972,10 @@ static void InitializePlayer(void) {
Entity* pl;
sub_080784C8();
- MemClear(&gUnk_03000B80, sizeof gUnk_03000B80);
- MemClear(&gPlayerState, sizeof gPlayerState);
- MemFill32(0xffffffff, &gPlayerState.path_memory, sizeof gPlayerState.path_memory);
- MemClear(&gPlayerEntity, sizeof gPlayerEntity);
+ MemClear(&gActiveItems, sizeof(gActiveItems));
+ MemClear(&gPlayerState, sizeof(gPlayerState));
+ MemFill32(0xffffffff, &gPlayerState.path_memory, sizeof(gPlayerState.path_memory));
+ MemClear(&gPlayerEntity, sizeof(gPlayerEntity));
pl = &gPlayerEntity;
@@ -2463,68 +2463,69 @@ void ModArrows(s32 arrows) {
* 1: B
* 2: Not equipped
*/
-u32 IsItemEquipped(u32 itemID) {
- u32 itemSlot;
-
- if (itemID == gSave.stats.itemButtons[SLOT_A])
- itemSlot = 0;
- else if (itemID == gSave.stats.itemButtons[SLOT_B])
- itemSlot = 1;
- else
- itemSlot = 2;
- return itemSlot;
-}
-
-void PutItemOnSlot(u32 itemID) {
- u32 itemSlot;
- u32 itemID2 = itemID;
- if (itemID2 < 0x47) {
+EquipSlot IsItemEquipped(u32 itemId) {
+ EquipSlot equipSlot;
+
+ if (itemId == gSave.stats.itemButtons[SLOT_A]) {
+ equipSlot = EQUIP_SLOT_A;
+ } else if (itemId == gSave.stats.itemButtons[SLOT_B]) {
+ equipSlot = EQUIP_SLOT_B;
+ } else {
+ equipSlot = EQUIP_SLOT_NONE;
+ }
+ return equipSlot;
+}
+
+void PutItemOnSlot(u32 itemId) {
+ EquipSlot equipSlot;
+ u32 itemId2 = itemId;
+ if (itemId2 < 0x47) {
SetInventoryValue(0, 1);
}
- if (itemID2 - 1 < 0x1f) {
- itemSlot = 2;
+ if (itemId2 - 1 < 0x1f) {
+ equipSlot = EQUIP_SLOT_NONE;
if (gSave.stats.itemButtons[SLOT_A] == ITEM_NONE) {
- itemSlot = 0;
+ equipSlot = EQUIP_SLOT_A;
} else if (gSave.stats.itemButtons[SLOT_B] == ITEM_NONE) {
- itemSlot = 1;
+ equipSlot = EQUIP_SLOT_B;
}
- if (itemSlot == 2) {
- u32 temp = gItemMetaData[itemID2].menuSlot;
+ if (equipSlot == EQUIP_SLOT_NONE) {
+ u32 temp = gItemMetaData[itemId2].menuSlot;
if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_A]].menuSlot) {
- itemSlot = 0;
+ equipSlot = EQUIP_SLOT_A;
} else {
if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_B]].menuSlot) {
- itemSlot = 1;
+ equipSlot = EQUIP_SLOT_B;
}
}
- if (itemSlot == 2) {
+ if (equipSlot == EQUIP_SLOT_NONE) {
return;
}
}
- ForceEquipItem(itemID2, itemSlot);
+ ForceEquipItem(itemId2, equipSlot);
}
}
-void ForceEquipItem(u32 itemID, u32 itemSlot) {
+void ForceEquipItem(u32 itemId, u32 equipSlot) {
u32 otherItem;
- u32 otherItemIndex;
+ u32 otherItemSlot;
u32 replacedItem;
- if ((itemID - 1 < 0x1f) && (itemSlot < 2)) {
- otherItemIndex = itemSlot == 0;
- replacedItem = gSave.stats.itemButtons[itemSlot];
- otherItem = gSave.stats.itemButtons[otherItemIndex];
- if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemID].menuSlot) {
+ if ((itemId - 1 < 0x1f) && (equipSlot < EQUIP_SLOT_NONE)) {
+ otherItemSlot = equipSlot == EQUIP_SLOT_A;
+ replacedItem = gSave.stats.itemButtons[equipSlot];
+ otherItem = gSave.stats.itemButtons[otherItemSlot];
+ if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemId].menuSlot) {
otherItem = replacedItem;
}
- gSave.stats.itemButtons[itemSlot] = itemID;
- gSave.stats.itemButtons[otherItemIndex] = otherItem;
+ gSave.stats.itemButtons[equipSlot] = itemId;
+ gSave.stats.itemButtons[otherItemSlot] = otherItem;
gUnk_0200AF00.unk_13 = 0x7f;
gUnk_0200AF00.unk_14 = 0x7f;
}
}
-u32 SetBottleContents(u32 itemID, u32 bottleIndex) {
+u32 SetBottleContents(u32 itemId, u32 bottleIndex) {
if (bottleIndex > 3) {
bottleIndex = 0;
for (bottleIndex = 0; gSave.stats.bottles[bottleIndex] != ITEM_BOTTLE_EMPTY;) {
@@ -2536,7 +2537,7 @@ u32 SetBottleContents(u32 itemID, u32 bottleIndex) {
return bottleIndex;
}
}
- gSave.stats.bottles[bottleIndex] = itemID;
+ gSave.stats.bottles[bottleIndex] = itemId;
return bottleIndex;
}
@@ -2614,7 +2615,7 @@ void EnableRandomDrops(void) {
extern void sub_08000F14(s16*, const s16*, const s16*, const s16*);
extern u32 sub_08000F2C(s16*, const s16*, const s16*, const s16*);
-u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter);
+u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter);
u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
extern const u8 gUnk_080FE1B4[] /* = {
ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY,
@@ -2717,11 +2718,11 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
return ITEM_NONE;
}
-u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
+u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) {
u32 adjustedParam = itemParameter;
Entity* itemEntity;
- switch (itemID) {
+ switch (itemId) {
case ITEM_ENEMY_BEETLE:
if (!GetInventoryValue(ITEM_SMITH_SWORD)) {
return ITEM_NONE;
@@ -2757,22 +2758,22 @@ u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
return ITEM_NONE;
}
- if (itemID != ITEM_KINSTONE) {
- adjustedParam = itemID - ITEM_KINSTONE_GREEN;
+ if (itemId != ITEM_KINSTONE) {
+ adjustedParam = itemId - ITEM_KINSTONE_GREEN;
rand = (Random() & 0x3f);
adjustedParam = gUnk_080FE1DD[(rand + adjustedParam * 0x40)];
if (adjustedParam == 0) {
- itemID = ITEM_NONE;
+ itemId = ITEM_NONE;
} else {
- itemID = ITEM_KINSTONE;
+ itemId = ITEM_KINSTONE;
}
}
break;
}
}
- if (itemID != ITEM_NONE) {
- if (itemID != ITEM_ENEMY_BEETLE) {
- itemEntity = CreateObject(GROUND_ITEM, itemID, adjustedParam);
+ if (itemId != ITEM_NONE) {
+ if (itemId != ITEM_ENEMY_BEETLE) {
+ itemEntity = CreateObject(GROUND_ITEM, itemId, adjustedParam);
if (itemEntity != NULL) {
if (arg0 == &gPlayerEntity) {
itemEntity->timer = 1;
@@ -2800,7 +2801,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
}
}
}
- return itemID;
+ return itemId;
}
void Subtask_WorldEvent(void) {
diff --git a/src/gba/m4a.c b/src/gba/m4a.c
index b5e2e13e..e1f30b0e 100644
--- a/src/gba/m4a.c
+++ b/src/gba/m4a.c
@@ -1313,7 +1313,7 @@ void CgbSound(void) {
if (channels->n4 & 0x80) {
*nrx0ptr = 0x80;
*nrx4ptr = channels->n4;
- channels->n4 &= 0x7f;
+ channels->n4 &= ~0x80;
}
} else {
envelopeStepTimeAndDir &= 0xf;
diff --git a/src/interrupts.c b/src/interrupts.c
index 84784698..33a7d5e7 100644
--- a/src/interrupts.c
+++ b/src/interrupts.c
@@ -1,14 +1,14 @@
+#include "functions.h"
+#include "gba/m4a.h"
#include "global.h"
-#include "sound.h"
#include "main.h"
+#include "message.h"
+#include "object.h"
#include "player.h"
-#include "structures.h"
#include "save.h"
-#include "message.h"
-#include "functions.h"
#include "screen.h"
-#include "gba/m4a.h"
-#include "object.h"
+#include "sound.h"
+#include "structures.h"
#include "ui.h"
extern u8 gUnk_03003DE0;
@@ -197,7 +197,7 @@ void PlayerUpdate(Entity* this) {
else
gPlayerState.flags &= ~PL_DRUGGED;
- if (EntityIsDeleted(this) == 0) {
+ if (!EntityIsDeleted(this)) {
if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) {
PutAwayItems();
if (gPlayerState.flags & PL_MOLDWORM_RELEASED) {
@@ -218,7 +218,7 @@ void PlayerUpdate(Entity* this) {
}
sub_08078FB0(this);
DrawEntity(this);
- sub_0807A050();
+ UpdatePlayerPalette();
}
// Responsible for some life things like low health beep and initiating the death sequence
@@ -234,7 +234,7 @@ static void HandlePlayerLife(Entity* this) {
gPlayerState.flags &= ~(PL_FALLING | PL_CONVEYOR_PUSHED);
if (gPlayerState.flags & PL_BURNING)
- ResetPlayerItem();
+ ResetActiveItems();
if ((gPlayerState.flags & PL_CLONING) && gPlayerState.chargeState.action == 0)
DeleteClones();
if (sub_08079B24() == 0)
@@ -309,7 +309,7 @@ static void HandlePlayerLife(Entity* this) {
static void sub_080171F0(void) {
if (gPlayerState.mobility != 0)
- ResetPlayerItem();
+ ResetActiveItems();
if (gPlayerState.field_0x14 != 0)
gPlayerState.field_0x14--;
if (gPlayerEntity.field_0x7a.HWORD != 0)
@@ -331,7 +331,7 @@ static void sub_080171F0(void) {
gPlayerState.keepFacing &= ~0x80;
gPlayerState.mobility = 0;
gPlayerState.speed_modifier = 0;
- gPlayerState.field_0xaa = 0;
+ gPlayerState.attachedBeetleCount = 0;
MemClear(&gCarriedEntity, sizeof(gCarriedEntity));
gPlayerEntity.spriteOffsetY = gPlayerState.spriteOffsetY;
gPlayerState.spriteOffsetY = 0;
diff --git a/src/item.c b/src/item.c
index 3e6cbb2d..1fa970e3 100644
--- a/src/item.c
+++ b/src/item.c
@@ -3,14 +3,40 @@
// TODO - How does this relate to PlayerItemFunctions? Is this just a lookup table?
void (*const gItemFunctions[])(ItemBehavior*, u32) = {
-
- ItemDebug, ItemSword, ItemSword, ItemSword, ItemSword, ItemSword, ItemSword,
- ItemBomb, ItemBomb, ItemBow, ItemBow, ItemBoomerang, ItemBoomerang, ItemShield,
- ItemShield, ItemLantern, ItemLantern, ItemGustJar, ItemPacciCane, ItemMoleMitts, ItemRocsCape,
- ItemPegasusBoots, ItemDebug, ItemOcarina, ItemDebug, ItemDebug, ItemDebug, ItemTryPickupObject,
- ItemJarEmpty, ItemJarEmpty, ItemJarEmpty, ItemJarEmpty,
+ [ITEM_NONE] = ItemDebug,
+ [ITEM_SMITH_SWORD] = ItemSword,
+ [ITEM_GREEN_SWORD] = ItemSword,
+ [ITEM_RED_SWORD] = ItemSword,
+ [ITEM_BLUE_SWORD] = ItemSword,
+ [ITEM_UNUSED_SWORD] = ItemSword,
+ [ITEM_FOURSWORD] = ItemSword,
+ [ITEM_BOMBS] = ItemBomb,
+ [ITEM_REMOTE_BOMBS] = ItemBomb,
+ [ITEM_BOW] = ItemBow,
+ [ITEM_LIGHT_ARROW] = ItemBow,
+ [ITEM_BOOMERANG] = ItemBoomerang,
+ [ITEM_MAGIC_BOOMERANG] = ItemBoomerang,
+ [ITEM_SHIELD] = ItemShield,
+ [ITEM_MIRROR_SHIELD] = ItemShield,
+ [ITEM_LANTERN_OFF] = ItemLantern,
+ [ITEM_LANTERN_ON] = ItemLantern,
+ [ITEM_GUST_JAR] = ItemGustJar,
+ [ITEM_PACCI_CANE] = ItemPacciCane,
+ [ITEM_MOLE_MITTS] = ItemMoleMitts,
+ [ITEM_ROCS_CAPE] = ItemRocsCape,
+ [ITEM_PEGASUS_BOOTS] = ItemPegasusBoots,
+ [ITEM_FIRE_ROD] = ItemDebug,
+ [ITEM_OCARINA] = ItemOcarina,
+ [ITEM_ORB_GREEN] = ItemDebug,
+ [ITEM_ORB_BLUE] = ItemDebug,
+ [ITEM_ORB_RED] = ItemDebug,
+ [ITEM_TRY_PICKUP_OBJECT] = ItemTryPickupObject,
+ [ITEM_BOTTLE1] = ItemJarEmpty,
+ [ITEM_BOTTLE2] = ItemJarEmpty,
+ [ITEM_BOTTLE3] = ItemJarEmpty,
+ [ITEM_BOTTLE4] = ItemJarEmpty,
};
-void sub_080752E8(ItemBehavior* behavior, u32 idx) {
- gItemFunctions[behavior->behaviorID](behavior, idx);
+void ExecuteItemFunction(ItemBehavior* behavior, u32 index) {
+ gItemFunctions[behavior->behaviorId](behavior, index);
}
diff --git a/src/item/itemBomb.c b/src/item/itemBomb.c
index ce5358a4..74264e17 100644
--- a/src/item/itemBomb.c
+++ b/src/item/itemBomb.c
@@ -10,14 +10,14 @@ void sub_08076488(ItemBehavior*, u32);
void sub_08076518(ItemBehavior*, u32);
void sub_080765E0(ItemBehavior*, u32);
-void ItemBomb(ItemBehavior* this, u32 idx) {
+void ItemBomb(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075FF8, NULL, sub_08076488, sub_08076518, sub_080765E0,
};
- stateFuncs[this->stateID](this, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08075FF8(ItemBehavior* this, u32 idx) {
+void sub_08075FF8(ItemBehavior* this, u32 index) {
static const s8 gUnk_0811BDAC[] = {
0, -8, 4, -1, 0, 2, -4, -1,
};
@@ -28,13 +28,13 @@ void sub_08075FF8(ItemBehavior* this, u32 idx) {
s32 x;
s32 y;
- if ((gPlayerState.jump_status | gPlayerState.field_0x3[1]) == 0) {
+ if ((gPlayerState.jump_status | gPlayerState.attack_status) == 0) {
bombCount = 0;
for (entity = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2); entity != NULL;
entity = FindNextDuplicateID(entity, 2)) {
bombCount++;
}
- maxBombs = this->behaviorID == 7 ? 3 : 1;
+ maxBombs = this->behaviorId == 7 ? 3 : 1;
if (maxBombs > bombCount) {
entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_BOMB);
if (entity != NULL) {
@@ -45,60 +45,5 @@ void sub_08075FF8(ItemBehavior* this, u32 idx) {
}
}
}
- DeletePlayerItem(this, idx);
-}
-
-void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
- if (param_2 != NULL) {
- if ((param_2->carryFlags & 1) != 0) {
- return;
- }
- param_2->action = 2;
- param_2->subAction = param_2->carryFlags & 1;
- }
-
- this->field_0x18 = param_2;
- if ((gPlayerState.flags & PL_NO_CAP)) {
- sub_08077DF4(this, 0x928);
- } else {
- sub_08077DF4(this, 0x338);
- }
- gPlayerState.heldObject = 3;
- gPlayerState.framestate = PL_STATE_HOLD;
- this->stateID = 2;
- this->field_0xf = 0xf;
- if ((gPlayerEntity.field_0x78.HALF.HI & 0x80)) {
- gPlayerEntity.field_0x78.HALF.HI = 0;
- COLLISION_ON(&gPlayerEntity);
- gPlayerState.heldObject = 4;
- gPlayerState.keepFacing = ~(8 >> param_3) & gPlayerState.keepFacing;
- gPlayerState.field_0xa = ~(8 >> param_3) & gPlayerState.field_0xa;
- this->stateID = 3;
- this->field_0xf = 0;
- } else {
- gPlayerState.field_0xa |= (8 >> param_3);
- gPlayerState.keepFacing |= (8 >> param_3);
- }
-
- param_2 = CreatePlayerItemWithParent(this, PLAYER_ITEM_13);
- if (param_2 == NULL) {
- PlayerCancelHoldItem(this, param_3);
- } else {
- Entity* playerEnt = &gPlayerEntity;
- *(Entity**)&playerEnt->field_0x74 = param_2;
- playerEnt->subtimer = 0;
- param_2->child = this->field_0x18;
- param_2->carryFlags = playerEnt->carryFlags;
- param_2->parent = (Entity*)this;
- this->field_0x18 = param_2;
- param_2->type2 = this->field_0x2[1];
- param_2->timer = this->timer;
- param_2->subtimer = this->subtimer;
- if ((this->field_0x18->carryFlags & 0xf0) == 0x10) {
- this->timer = 8;
- } else {
- this->timer = 0;
- }
- SoundReq(SFX_PLY_LIFT);
- }
+ DeleteItemBehavior(this, index);
}
diff --git a/src/item/itemBoomerang.c b/src/item/itemBoomerang.c
index 34475d09..64c78d87 100644
--- a/src/item/itemBoomerang.c
+++ b/src/item/itemBoomerang.c
@@ -4,29 +4,29 @@
void sub_08075D2C(ItemBehavior*, u32);
void sub_08075D88(ItemBehavior*, u32);
-void ItemBoomerang(ItemBehavior* this, u32 idx) {
+void ItemBoomerang(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075D2C,
sub_08075D88,
};
- stateFuncs[this->stateID](this, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08075D2C(ItemBehavior* this, u32 idx) {
- if (((gPlayerState.field_0x3[1] & 8) == 0) && (sub_08077C94(this, this->behaviorID) == NULL)) {
- this->field_0x9 |= 0xf;
+void sub_08075D2C(ItemBehavior* this, u32 index) {
+ if (((gPlayerState.attack_status & 8) == 0) && (FindPlayerItemForItem(this, this->behaviorId) == NULL)) {
+ this->priority |= 0xf;
sub_0806F948(&gPlayerEntity);
- sub_08077C0C(this, 0xb);
- sub_08077D38(this, idx);
- gPlayerState.field_0x3[1] |= 8;
+ CreatePlayerItemIfNotExists(this, ITEM_BOOMERANG);
+ sub_08077D38(this, index);
+ gPlayerState.attack_status |= 8;
} else {
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
}
-void sub_08075D88(ItemBehavior* this, u32 idx) {
- if ((gPlayerState.field_0x3[1] & 0x80) == 0) {
- if (((this->behaviorID == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->playerFrame & 2) != 0)) {
+void sub_08075D88(ItemBehavior* this, u32 index) {
+ if ((gPlayerState.attack_status & 0x80) == 0) {
+ if (((this->behaviorId == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->playerFrame & 2) != 0)) {
ResetPlayerVelocity();
return;
}
@@ -35,5 +35,5 @@ void sub_08075D88(ItemBehavior* this, u32 idx) {
return;
}
}
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
diff --git a/src/item/itemBow.c b/src/item/itemBow.c
index 8e916091..7714734f 100644
--- a/src/item/itemBow.c
+++ b/src/item/itemBow.c
@@ -9,81 +9,78 @@ void sub_08075F38(ItemBehavior*, u32);
void sub_08075F84(ItemBehavior*, u32);
void sub_08075D88(ItemBehavior*, u32);
-void ItemBow(ItemBehavior* this, u32 idx) {
+void ItemBow(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075DF4, sub_08075E40, sub_08075EC0, sub_08075F38, sub_08075F84, sub_08075D88,
};
- stateFuncs[this->stateID](this, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08075DF4(ItemBehavior* this, u32 idx) {
- if ((gPlayerState.field_0x3[1] & 8) == 0) {
- this->field_0x9 |= 0x80;
+void sub_08075DF4(ItemBehavior* this, u32 index) {
+ if ((gPlayerState.attack_status & 8) == 0) {
+ this->priority |= 0x80;
sub_0806F948(&gPlayerEntity);
sub_08077BB8(this);
- sub_08077D38(this, idx);
+ sub_08077D38(this, index);
gPlayerState.field_0x1f[2] = 1;
} else {
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
}
-void sub_08075E40(ItemBehavior* this, u32 idx) {
- u8 bVar1;
-
+void sub_08075E40(ItemBehavior* this, u32 index) {
if (gPlayerState.field_0x1f[2] != 0) {
- bVar1 = gPlayerState.field_0x3[1] & 0x80;
- if (bVar1 == 0) {
+ if ((gPlayerState.attack_status & 0x80) == 0) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
this->stateID = 2;
- this->field_0x9 &= ~0x80;
+ this->priority &= ~0x80;
if (gSave.stats.arrowCount != 0) {
- this->field_0xf = bVar1;
- gPlayerState.field_0xa &= ~(8 >> idx);
+ this->animPriority = 0;
+ gPlayerState.field_0xa &= ~(8 >> index);
}
}
return;
}
}
gPlayerState.field_0x1f[2] = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
-void sub_08075EC0(ItemBehavior* this, u32 idx) {
+void sub_08075EC0(ItemBehavior* this, u32 index) {
u8 arrowCount;
s32 iVar2;
arrowCount = gSave.stats.arrowCount;
- iVar2 = sub_08077EFC(this);
+ iVar2 = IsItemActive(this);
if (iVar2 != 0 && arrowCount != 0) {
- if (((gPlayerState.field_0x3[1] & 0x80) != 0) || (gPlayerState.field_0x1f[2] == 0)) {
+ if (((gPlayerState.attack_status & 0x80) != 0) || (gPlayerState.field_0x1f[2] == 0)) {
gPlayerState.field_0x1f[2] = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
} else {
- gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa;
- sub_08077DF4(this, 0x27c);
- this->field_0xf = 0xf;
- this->field_0x9 |= 0xf;
+ gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
+ SetItemAnim(this, 0x27c);
+ this->animPriority = 0xf;
+ this->priority |= 0xf;
this->stateID = 3;
}
}
-void sub_08075F38(ItemBehavior* this, u32 idx) {
- if (((gPlayerState.field_0x3[1] & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
+void sub_08075F38(ItemBehavior* this, u32 index) {
+ if (((gPlayerState.attack_status & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
UpdateItemAnim(this);
if ((this->playerFrame & 1) != 0) {
this->stateID = 4;
}
} else {
gPlayerState.field_0x1f[2] = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
}
-void sub_08075F84(ItemBehavior* this, u32 idx) {
- if (((gPlayerState.field_0x3[1] & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
+void sub_08075F84(ItemBehavior* this, u32 index) {
+ if (((gPlayerState.attack_status & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
if (GetInventoryValue(ITEM_ARROW_BUTTERFLY) == 1) {
sub_08077E3C(this, 5);
} else {
@@ -94,5 +91,5 @@ void sub_08075F84(ItemBehavior* this, u32 idx) {
}
}
gPlayerState.field_0x1f[2] = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
diff --git a/src/item/itemDebug.c b/src/item/itemDebug.c
index e0d9f2f9..0cfd333b 100644
--- a/src/item/itemDebug.c
+++ b/src/item/itemDebug.c
@@ -1,9 +1,9 @@
#include "item.h"
-extern Entity* sub_08077BD4(ItemBehavior*);
-extern void DeletePlayerItem(ItemBehavior*, u32);
+extern Entity* CreatePlayerItemForItemIfNotExists(ItemBehavior*);
+extern void DeleteItemBehavior(ItemBehavior*, u32);
-void ItemDebug(ItemBehavior* beh, u32 idx) {
- sub_08077BD4(beh);
- DeletePlayerItem(beh, idx);
+void ItemDebug(ItemBehavior* this, u32 index) {
+ CreatePlayerItemForItemIfNotExists(this);
+ DeleteItemBehavior(this, index);
}
diff --git a/src/item/itemGustJar.c b/src/item/itemGustJar.c
index c26314e1..c567f197 100644
--- a/src/item/itemGustJar.c
+++ b/src/item/itemGustJar.c
@@ -4,41 +4,41 @@
#include "functions.h"
#include "playeritem.h"
-void (*const ItemGustJar_StateFunctions[])(ItemBehavior* beh, u32);
+void (*const ItemGustJar_StateFunctions[])(ItemBehavior* this, u32);
-void ItemGustJar(ItemBehavior* this, u32 idx) {
+void ItemGustJar(ItemBehavior* this, u32 index) {
gPlayerState.framestate = PL_STATE_GUSTJAR;
- ItemGustJar_StateFunctions[this->stateID](this, idx);
+ ItemGustJar_StateFunctions[this->stateID](this, index);
}
-void sub_08076DF4(ItemBehavior* this, u32 idx) {
- if (sub_0807A894(&gPlayerEntity) != 0x29 && gPlayerState.floor_type != SURFACE_DOOR &&
+void sub_08076DF4(ItemBehavior* this, u32 index) {
+ if (GetCollisionTileInFront(&gPlayerEntity) != 0x29 && gPlayerState.floor_type != SURFACE_DOOR &&
gPlayerState.floor_type != SURFACE_DOOR_13 && gPlayerState.jump_status == 0) {
- sub_08077D38(this, idx);
+ sub_08077D38(this, index);
this->timer = 0;
this->playerAnimationState = gPlayerEntity.animationState;
- this->field_0x9 |= 0x80;
- this->field_0x9++;
+ this->priority |= 0x80;
+ this->priority++;
gPlayerState.gustJarSpeed = 1;
*(u32*)&gPlayerEntity.field_0x74 = 0;
gPlayerState.field_0x1c = 1;
sub_08077BB8(this);
} else {
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
}
-void sub_08076E60(ItemBehavior* this, u32 idx) {
+void sub_08076E60(ItemBehavior* this, u32 index) {
Entity* playerItem;
if ((gPlayerState.field_0x1c & 0xf) == 0) {
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
if ((this->playerFrame & 0x80) != 0) {
this->stateID = 2;
- sub_08077DF4(this, 0x504);
- gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx);
- playerItem = CreatePlayerItem(PLAYER_ITEM_10, 0, 0, 0);
+ SetItemAnim(this, 0x504);
+ gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
+ playerItem = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (playerItem != NULL) {
playerItem->parent = &gPlayerEntity;
}
@@ -47,14 +47,14 @@ void sub_08076E60(ItemBehavior* this, u32 idx) {
}
}
-void sub_08076EC8(ItemBehavior* this, u32 idx) {
+void sub_08076EC8(ItemBehavior* this, u32 index) {
if ((gPlayerState.field_0x1c & 0xf) == 0) {
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
return;
}
- if (sub_08077EFC(this)) {
- u32 val;
+ if (IsItemActive(this)) {
+ u32 animIndex;
if (this->timer > 0xef) {
gPlayerState.gustJarSpeed = 3;
} else if (++this->timer > 0x77) {
@@ -64,17 +64,17 @@ void sub_08076EC8(ItemBehavior* this, u32 idx) {
}
if (gPlayerEntity.subAction == 0x1b) {
- val = 0x524;
+ animIndex = 0x524;
} else {
- if (gPlayerState.field_0xd & 0x80) {
- val = 0x504;
+ if (gPlayerState.direction & 0x80) {
+ animIndex = 0x504;
} else {
- val = 0x518;
+ animIndex = 0x518;
}
}
- if (val != *(u16*)&this->field_0x10) {
- sub_08077DF4(this, val);
+ if (animIndex != this->animIndex) {
+ SetItemAnim(this, animIndex);
} else {
UpdateItemAnim(this);
}
@@ -82,10 +82,10 @@ void sub_08076EC8(ItemBehavior* this, u32 idx) {
}
this->stateID++;
- gPlayerState.field_0xa |= 8 >> idx;
+ gPlayerState.field_0xa |= 8 >> index;
}
-void sub_08076F64(ItemBehavior* this, u32 idx) {
+void sub_08076F64(ItemBehavior* this, u32 index) {
Entity* item;
Entity* player;
switch (gPlayerState.field_0x1c & 0xf) {
@@ -98,21 +98,21 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
player = &gPlayerEntity;
*(u32*)&player->field_0x74 = 0;
gPlayerState.field_0x1c = 1;
- gPlayerState.field_0xa &= ~(8 >> idx);
+ gPlayerState.field_0xa &= ~(8 >> index);
this->stateID = 2;
- sub_08077DF4(this, 0x504);
- item = CreatePlayerItem(PLAYER_ITEM_10, 0, 0, 0);
+ SetItemAnim(this, 0x504);
+ item = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (item) {
item->parent = player;
}
return;
} else {
gPlayerState.field_0x1c = 6;
- sub_08077DF4(this, 0x510);
+ SetItemAnim(this, 0x510);
return;
}
} else {
- if (sub_08077EFC(this)) {
+ if (IsItemActive(this)) {
this->subtimer = 1;
}
@@ -130,7 +130,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
case 3:
gPlayerState.field_0x1c = 4;
case 4:
- if (sub_08077EFC(this)) {
+ if (IsItemActive(this)) {
this->subtimer = 1;
}
@@ -139,7 +139,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
gPlayerState.field_0x1c = 5;
gPlayerEntity.field_0x70.WORD = 0;
if (gPlayerState.gustJarSpeed) {
- CreatePlayerItem(PLAYER_ITEM_11, 0, 0, 0);
+ CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0);
}
}
@@ -155,7 +155,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
return;
break;
case 7:
- sub_08077DF4(this, 0x514);
+ SetItemAnim(this, 0x514);
gPlayerState.field_0x1c = 3;
gPlayerState.gustJarSpeed = 0;
return;
@@ -163,17 +163,17 @@ void sub_08076F64(ItemBehavior* this, u32 idx) {
case 2:
default:
gPlayerState.field_0x1c = 3;
- sub_08077DF4(this, 0x514);
+ SetItemAnim(this, 0x514);
return;
case 0:
break;
}
gPlayerState.field_0x1c = 0;
gPlayerEntity.field_0x70.WORD = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
-void (*const ItemGustJar_StateFunctions[])(ItemBehavior* beh, u32) = {
+void (*const ItemGustJar_StateFunctions[])(ItemBehavior*, u32) = {
sub_08076DF4,
sub_08076E60,
sub_08076EC8,
diff --git a/src/item/itemJarEmpty.c b/src/item/itemJarEmpty.c
index ff2e1c61..60997922 100644
--- a/src/item/itemJarEmpty.c
+++ b/src/item/itemJarEmpty.c
@@ -7,27 +7,27 @@ void sub_08077618(ItemBehavior*, u32);
void sub_08077640(ItemBehavior*, u32);
void sub_0807766C(ItemBehavior*, u32);
-void ItemJarEmpty(ItemBehavior* this, u32 idx) {
+void ItemJarEmpty(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08077534,
sub_08077618,
sub_08077640,
sub_0807766C,
};
- stateFuncs[this->stateID](this, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08077534(ItemBehavior* this, u32 idx) {
+void sub_08077534(ItemBehavior* this, u32 index) {
u32 tmp;
- sub_08077D38(this, idx);
+ sub_08077D38(this, index);
sub_0806F948(&gPlayerEntity);
sub_08077BB8(this);
- this->field_0x9 |= 0xf;
- tmp = this->behaviorID;
+ this->priority |= 0xf;
+ tmp = this->behaviorId;
this->timer = gSave.filler86[tmp + 0x14];
switch (this->timer) {
case 0x20:
- sub_08077DF4(this, 0x614);
+ SetItemAnim(this, 0x614);
return;
case 0x21:
case 0x22:
@@ -43,40 +43,40 @@ void sub_08077534(ItemBehavior* this, u32 idx) {
this->stateID = 3;
gPlayerEntity.animationState = 4;
gPlayerEntity.spriteSettings.flipX = 0;
- sub_08077DF4(this, 0x2df);
+ SetItemAnim(this, 0x2df);
break;
case 0x2f:
case 0x30:
case 0x31:
default:
this->stateID = 3;
- sub_08077DF4(this, 0x610);
+ SetItemAnim(this, 0x610);
break;
}
gPlayerEntity.flags &= ~ENT_COLLIDE;
}
-void sub_08077618(ItemBehavior* this, u32 idx) {
+void sub_08077618(ItemBehavior* this, u32 index) {
if ((this->playerFrame & 0x80) != 0) {
- sub_08077DF4(this, 0x618);
- this->stateID += 1;
+ SetItemAnim(this, 0x618);
+ this->stateID++;
} else {
UpdateItemAnim(this);
}
}
-void sub_08077640(ItemBehavior* this, u32 idx) {
+void sub_08077640(ItemBehavior* this, u32 index) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
}
-void sub_0807766C(ItemBehavior* this, u32 idx) {
+void sub_0807766C(ItemBehavior* this, u32 index) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
}
diff --git a/src/item/itemLantern.c b/src/item/itemLantern.c
index 758b6244..4e9902a0 100644
--- a/src/item/itemLantern.c
+++ b/src/item/itemLantern.c
@@ -5,41 +5,41 @@
#include "game.h"
extern s8 gUnk_08126EEC[];
-extern Entity* sub_08077BD4(ItemBehavior*);
+extern Entity* CreatePlayerItemForItemIfNotExists(ItemBehavior*);
extern void sub_0807AB44(Entity*, s32, s32);
void sub_08075A0C(ItemBehavior*, u32);
void sub_08075ADC(ItemBehavior*, u32);
void sub_08075B54(ItemBehavior*, u32);
void sub_08075C9C(ItemBehavior*, u32);
-void ItemLantern(ItemBehavior* this, u32 idx) {
+void ItemLantern(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075A0C,
sub_08075ADC,
sub_08075B54,
sub_08075C9C,
};
- stateFuncs[this->stateID](this, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08075A0C(ItemBehavior* this, u32 idx) {
+void sub_08075A0C(ItemBehavior* this, u32 index) {
Entity* object;
- u32 itemSlot;
+ EquipSlot equipSlot;
s8* tmp;
- itemSlot = IsItemEquipped(this->behaviorID);
+ equipSlot = IsItemEquipped(this->behaviorId);
if (gPlayerState.heldObject != 0 || gPlayerState.queued_action == PLAYER_ROLL || gPlayerState.jump_status != 0 ||
gPlayerState.item != NULL || (gPlayerState.flags & PL_MINISH) != 0) {
- ForceEquipItem(ITEM_LANTERN_OFF, itemSlot);
+ ForceEquipItem(ITEM_LANTERN_OFF, equipSlot);
gPlayerState.flags &= ~PL_USE_LANTERN;
- ForceEquipItem(ITEM_LANTERN_OFF, itemSlot);
- DeletePlayerItem(this, idx);
+ ForceEquipItem(ITEM_LANTERN_OFF, equipSlot);
+ DeleteItemBehavior(this, index);
} else {
- this->field_0x9 |= 0x80;
- sub_08077D38(this, idx);
- sub_08077BD4(this);
+ this->priority |= 0x80;
+ sub_08077D38(this, index);
+ CreatePlayerItemForItemIfNotExists(this);
sub_0806F948(&gPlayerEntity);
- this->behaviorID = 0x10;
- ForceEquipItem(ITEM_LANTERN_ON, itemSlot);
+ this->behaviorId = 0x10;
+ ForceEquipItem(ITEM_LANTERN_ON, equipSlot);
tmp = &gUnk_08126EEC[gPlayerEntity.animationState & 6];
object = CreateObjectWithParent(&gPlayerEntity, LAMP_PARTICLE, 1, 0);
if (object != NULL) {
@@ -50,7 +50,7 @@ void sub_08075A0C(ItemBehavior* this, u32 idx) {
}
}
-void sub_08075ADC(ItemBehavior* this, u32 idx) {
+void sub_08075ADC(ItemBehavior* this, u32 index) {
u32 bVar1;
if (
@@ -59,11 +59,11 @@ void sub_08075ADC(ItemBehavior* this, u32 idx) {
#endif
(this->playerFrame & 1) == 0 || (gPlayerState.flags & (PL_DISABLE_ITEMS | PL_CAPTURED)) != 0 ||
sub_08079D48() == 0) {
- this->field_0xf = 0;
+ this->animPriority = 0;
this->stateID++;
gPlayerState.flags |= PL_USE_LANTERN;
- bVar1 = 8 >> idx;
- gPlayerState.field_0x3[1] = gPlayerState.field_0x3[1] & ~((bVar1 << 4) | bVar1);
+ bVar1 = 8 >> index;
+ gPlayerState.attack_status &= ~((bVar1 << 4) | bVar1);
bVar1 = ~bVar1;
gPlayerState.field_0xa = bVar1 & gPlayerState.field_0xa;
gPlayerState.keepFacing = bVar1 & gPlayerState.keepFacing;
@@ -73,18 +73,19 @@ void sub_08075ADC(ItemBehavior* this, u32 idx) {
}
}
-void sub_08075B54(ItemBehavior* this, u32 idx) {
+void sub_08075B54(ItemBehavior* this, u32 index) {
u32 bVar1;
- u32 itemSlot;
+ EquipSlot equipSlot;
Entity* object;
s8* tmp;
if ((gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS)) == 0) {
- itemSlot = IsItemEquipped(this->behaviorID);
- if (!(((sub_08077F10(this) == 0) && (itemSlot < 2)) || (gPlayerState.jump_status != 0))) {
- ForceEquipItem(ITEM_LANTERN_OFF, itemSlot);
+ equipSlot = IsItemEquipped(this->behaviorId);
+ if (!(((IsItemActivatedThisFrame(this) == 0) && (equipSlot < EQUIP_SLOT_NONE)) ||
+ (gPlayerState.jump_status != 0))) {
+ ForceEquipItem(ITEM_LANTERN_OFF, equipSlot);
gPlayerState.flags &= ~PL_USE_LANTERN;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
SoundReq(SFX_ITEM_LANTERN_OFF);
} else {
if (((gPlayerState.queued_action != PLAYER_ROLL) && (gPlayerEntity.frameIndex < 0x37)) &&
@@ -94,7 +95,7 @@ void sub_08075B54(ItemBehavior* this, u32 idx) {
if ((gPlayerState.jump_status == 0) &&
(sub_080B1BA4(TILE(gPlayerEntity.x.HALF.HI + tmp[0], gPlayerEntity.y.HALF.HI + tmp[1]),
gPlayerEntity.collisionLayer, 0x40) != 0)) {
- this->field_0xf = 0xf;
+ this->animPriority = 0xf;
this->stateID++;
gPlayerEntity.field_0x7a.HWORD = 2;
object = CreateObjectWithParent(&gPlayerEntity, LAMP_PARTICLE, 1, 0);
@@ -103,8 +104,8 @@ void sub_08075B54(ItemBehavior* this, u32 idx) {
object->x.HALF.HI = tmp[0] + object->x.HALF.HI;
object->y.HALF.HI = tmp[1] + object->y.HALF.HI;
}
- sub_08077DF4(this, 0x60c);
- bVar1 = (8 >> (idx));
+ SetItemAnim(this, 0x60c);
+ bVar1 = (8 >> (index));
gPlayerState.field_0xa |= bVar1;
gPlayerState.keepFacing |= bVar1;
}
@@ -113,7 +114,7 @@ void sub_08075B54(ItemBehavior* this, u32 idx) {
}
}
-void sub_08075C9C(ItemBehavior* this, u32 idx) {
+void sub_08075C9C(ItemBehavior* this, u32 index) {
s8* tmp;
UpdateItemAnim(this);
@@ -122,10 +123,10 @@ void sub_08075C9C(ItemBehavior* this, u32 idx) {
sub_0807AB44(&gPlayerEntity, tmp[0], tmp[1]);
}
if ((this->playerFrame & 0x80) != 0) {
- this->field_0xf = 0;
+ this->animPriority = 0;
this->stateID--;
- gPlayerState.field_0xa = (~(8 >> idx)) & gPlayerState.field_0xa;
- gPlayerState.keepFacing = (~(8 >> idx)) & gPlayerState.keepFacing;
+ gPlayerState.field_0xa = (~(8 >> index)) & gPlayerState.field_0xa;
+ gPlayerState.keepFacing = (~(8 >> index)) & gPlayerState.keepFacing;
} else {
gPlayerEntity.field_0x7a.HWORD++;
}
diff --git a/src/item/itemMoleMitts.c b/src/item/itemMoleMitts.c
index d3a938a6..ee3aaa1b 100644
--- a/src/item/itemMoleMitts.c
+++ b/src/item/itemMoleMitts.c
@@ -14,27 +14,27 @@ void sub_080771C8(ItemBehavior*, u32);
void sub_080772A8(ItemBehavior*, u32);
void sub_08077448(ItemBehavior*, u32);
-void ItemMoleMitts(ItemBehavior* this, u32 idx) {
+void ItemMoleMitts(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08077130,
sub_080771C8,
sub_080772A8,
sub_08077448,
};
- stateFuncs[this->stateID](this, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08077130(ItemBehavior* this, u32 idx) {
+void sub_08077130(ItemBehavior* this, u32 index) {
s32 iVar1;
if (gPlayerState.jump_status == 0) {
- sub_08077D38(this, idx);
+ sub_08077D38(this, index);
gPlayerState.moleMittsState = 1;
- this->field_0x9 |= 0x80;
+ this->priority |= 0x80;
iVar1 = sub_080774A0();
if (iVar1 != 0) {
if (this->timer == 0) {
- sub_08077DF4(this, 0x50c);
+ SetItemAnim(this, 0x50c);
this->stateID = 2;
if (iVar1 == 0x56) {
if ((gPlayerEntity.animationState & 2) != 0) {
@@ -45,16 +45,16 @@ void sub_08077130(ItemBehavior* this, u32 idx) {
}
}
} else {
- sub_08077DF4(this, 0x508);
+ SetItemAnim(this, 0x508);
this->stateID = 1;
}
} else {
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
gPlayerState.moleMittsState = 0;
}
}
-void sub_080771C8(ItemBehavior* this, u32 idx) {
+void sub_080771C8(ItemBehavior* this, u32 index) {
static const u8 gUnk_0811BE14[] = {
0x1,
0x12,
@@ -63,7 +63,7 @@ void sub_080771C8(ItemBehavior* this, u32 idx) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
gPlayerState.moleMittsState = 0;
} else {
if (((this->playerFrame & 0x20) != 0) && (this->subtimer == 0xff)) {
@@ -71,7 +71,7 @@ void sub_080771C8(ItemBehavior* this, u32 idx) {
}
if ((this->playerFrame & 0x10) != 0) {
if (sub_0800875A(&gPlayerEntity, 0xd, this) == 0) {
- sub_08077DF4(this, 0x520);
+ SetItemAnim(this, 0x520);
this->stateID = 3;
SoundReq(SFX_107);
} else {
@@ -95,7 +95,7 @@ void sub_080771C8(ItemBehavior* this, u32 idx) {
}
}
-void sub_080772A8(ItemBehavior* this, u32 idx) {
+void sub_080772A8(ItemBehavior* this, u32 index) {
static const s16 gUnk_0811BE16[] = {
0,
0xc0,
@@ -104,7 +104,7 @@ void sub_080772A8(ItemBehavior* this, u32 idx) {
};
Entity* effect;
- if (((this->playerFrame & 8) != 0) && sub_08077F10(this)) {
+ if (((this->playerFrame & 8) != 0) && IsItemActivatedThisFrame(this)) {
this->timer = 1;
}
if (GetInventoryValue(ITEM_DIG_BUTTERFLY) == 1) {
@@ -131,7 +131,7 @@ void sub_080772A8(ItemBehavior* this, u32 idx) {
return;
}
}
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
gPlayerState.moleMittsState = 0;
} else {
if ((this->playerFrame & 0x60) != 0) {
@@ -140,7 +140,7 @@ void sub_080772A8(ItemBehavior* this, u32 idx) {
SoundReq(SFX_108);
CreateObjectWithParent(&gPlayerEntity, MOLE_MITTS_PARTICLE, this->playerFrame, 0);
} else {
- sub_08077DF4(this, 0x51c);
+ SetItemAnim(this, 0x51c);
effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0);
if (effect != NULL) {
effect->animationState = this->playerAnimationState;
@@ -160,7 +160,7 @@ void sub_080772A8(ItemBehavior* this, u32 idx) {
}
}
-void sub_08077448(ItemBehavior* this, u32 idx) {
+void sub_08077448(ItemBehavior* this, u32 index) {
gPlayerEntity.direction = gPlayerEntity.animationState << 2 ^ 0x10;
gPlayerEntity.speed = 0x100;
if (((this->playerFrame & 1) != 0) && (this->field_0x5 != 0)) {
@@ -169,7 +169,7 @@ void sub_08077448(ItemBehavior* this, u32 idx) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
gPlayerState.moleMittsState = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
}
diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c
index a3310c7b..e4b2ad0e 100644
--- a/src/item/itemOcarina.c
+++ b/src/item/itemOcarina.c
@@ -7,20 +7,20 @@ extern void CreateBird(Entity*);
void OcarinaUse(ItemBehavior*, u32);
void OcarinaUpdate(ItemBehavior*, u32);
-void ItemOcarina(ItemBehavior* this, u32 idx) {
+void ItemOcarina(ItemBehavior* this, u32 index) {
static void (*const gOcarinaStates[])(ItemBehavior*, u32) = {
OcarinaUse,
OcarinaUpdate,
};
- gOcarinaStates[this->stateID](this, idx);
- gPlayerEntity.field_0x7a.HWORD += 1;
+ gOcarinaStates[this->stateID](this, index);
+ gPlayerEntity.field_0x7a.HWORD++;
}
-void OcarinaUse(ItemBehavior* this, u32 idx) {
+void OcarinaUse(ItemBehavior* this, u32 index) {
if (gPlayerState.queued_action == PLAYER_ROLL) {
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
} else {
- this->field_0x9 |= 0xf;
+ this->priority |= 0xf;
gPlayerEntity.animationState = 0x04;
gPlayerEntity.spriteSettings.flipX = 0;
gPlayerEntity.flags &= ~ENT_COLLIDE;
@@ -28,17 +28,16 @@ void OcarinaUse(ItemBehavior* this, u32 idx) {
gPlayerState.flags |= PL_USE_OCARINA;
gPlayerState.field_0x27[0] = -1;
gPauseMenuOptions.disabled = 1;
- gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa;
- gPlayerState.keepFacing = (8 >> idx) | gPlayerState.keepFacing;
+ gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
+ gPlayerState.keepFacing = (8 >> index) | gPlayerState.keepFacing;
ResetPlayerVelocity();
- sub_08077D38(this, idx);
+ sub_08077D38(this, index);
SoundReq(SFX_216);
SetPlayerEventPriority();
}
}
-void OcarinaUpdate(ItemBehavior* this, u32 idx) {
- // TODO regalloc
+void OcarinaUpdate(ItemBehavior* this, u32 index) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
@@ -47,6 +46,6 @@ void OcarinaUpdate(ItemBehavior* this, u32 idx) {
gPauseMenuOptions.disabled = 0;
CreateBird(&gPlayerEntity);
ResetPlayerEventPriority();
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
}
diff --git a/src/item/itemPacciCane.c b/src/item/itemPacciCane.c
index 42c3f53b..879f2051 100644
--- a/src/item/itemPacciCane.c
+++ b/src/item/itemPacciCane.c
@@ -7,28 +7,28 @@
void sub_08076C98(ItemBehavior*, u32);
void sub_08076CBC(ItemBehavior*, u32);
-void ItemPacciCane(ItemBehavior* beh, u32 idx) {
- static void (*const stateFuncs[])(ItemBehavior * beh, u32) = {
+void ItemPacciCane(ItemBehavior* this, u32 index) {
+ static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08076C98,
sub_08076CBC,
};
- stateFuncs[beh->stateID](beh, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08076C98(ItemBehavior* beh, u32 idx) {
- beh->field_0x9 |= 0xf;
- sub_08077D38(beh, idx);
+void sub_08076C98(ItemBehavior* this, u32 index) {
+ this->priority |= 0xf;
+ sub_08077D38(this, index);
sub_0806F948(&gPlayerEntity);
- sub_08077BB8(beh);
+ sub_08077BB8(this);
}
-void sub_08076CBC(ItemBehavior* beh, u32 idx) {
- if ((beh->playerFrame & 0x80) != 0) {
- DeletePlayerItem(beh, idx);
+void sub_08076CBC(ItemBehavior* this, u32 index) {
+ if ((this->playerFrame & 0x80) != 0) {
+ DeleteItemBehavior(this, index);
} else {
- if ((beh->playerFrame & 0x40) != 0) {
- CreatePlayerItemWithParent(beh, PLAYER_ITEM_12);
+ if ((this->playerFrame & 0x40) != 0) {
+ CreatePlayerItemWithParent(this, PLAYER_ITEM_PACCI_CANE_PROJECTILE);
}
- UpdateItemAnim(beh);
+ UpdateItemAnim(this);
}
}
diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c
index 81cdf137..7b487cee 100644
--- a/src/item/itemPegasusBoots.c
+++ b/src/item/itemPegasusBoots.c
@@ -14,7 +14,7 @@ void sub_08076A88(ItemBehavior*, u32);
extern u16 gUnk_0800275C[];
extern u8 gUnk_0811BE38[];
-void ItemPegasusBoots(ItemBehavior* this, u32 idx) {
+void ItemPegasusBoots(ItemBehavior* this, u32 index) {
static void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior * beh, u32) = {
sub_080768F8,
sub_08076964,
@@ -26,8 +26,8 @@ void ItemPegasusBoots(ItemBehavior* this, u32 idx) {
if (gPlayerEntity.field_0x7a.HWORD != 0) {
gPlayerState.dash_state = 0;
- gPlayerState.field_0xe = 0;
- DeletePlayerItem(this, idx);
+ gPlayerState.itemAnimPriority = 0;
+ DeleteItemBehavior(this, index);
} else {
--this->timer;
if ((this->timer & 7) == 0) {
@@ -54,15 +54,15 @@ void ItemPegasusBoots(ItemBehavior* this, u32 idx) {
}
}
}
- ItemPegasusBoots_StateFunctions[this->stateID](this, idx);
+ ItemPegasusBoots_StateFunctions[this->stateID](this, index);
}
}
-void sub_080768F8(ItemBehavior* this, u32 idx) {
+void sub_080768F8(ItemBehavior* this, u32 index) {
u32 bVar1;
u32 bVar2;
- bVar1 = gPlayerState.field_0x1c | gPlayerState.field_0x3[1] | gPlayerState.heldObject | gPlayerState.jump_status;
+ bVar1 = gPlayerState.field_0x1c | gPlayerState.attack_status | gPlayerState.heldObject | gPlayerState.jump_status;
bVar2 = (gPlayerState.flags & PL_IN_MINECART);
bVar1 |= bVar2;
if (bVar1 == 0) {
@@ -73,19 +73,19 @@ void sub_080768F8(ItemBehavior* this, u32 idx) {
} else {
gPlayerState.animation = 0xc14;
}
- sub_08077D38(this, idx);
- sub_08076964(this, idx);
+ sub_08077D38(this, index);
+ sub_08076964(this, index);
} else {
gPlayerState.dash_state = 0;
- gPlayerState.field_0xe = 0;
- DeletePlayerItem(this, idx);
+ gPlayerState.itemAnimPriority = 0;
+ DeleteItemBehavior(this, index);
}
}
-void sub_08076964(ItemBehavior* this, u32 idx) {
- Entity* bombEntity;
+void sub_08076964(ItemBehavior* this, u32 index) {
+ Entity* entity;
u32 uVar3;
- if (sub_08077EFC(this) && gPlayerEntity.z.WORD == 0 && gPlayerState.dash_state) {
+ if (IsItemActive(this) && gPlayerEntity.z.WORD == 0 && gPlayerState.dash_state) {
UpdateItemAnim(this);
if ((gPlayerState.flags & PL_MINISH) == 0) {
@@ -95,28 +95,28 @@ void sub_08076964(ItemBehavior* this, u32 idx) {
if ((++gPlayerState.dash_state) == 0x1e) {
if ((gPlayerState.flags & PL_FLAGS2) != 0) {
gPlayerState.dash_state = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
return;
}
gPlayerState.dash_state = 0x40;
- gPlayerState.field_0xa &= ~(8 >> idx);
+ gPlayerState.field_0xa &= ~(8 >> index);
this->stateID++;
if (HasSwordEquipped() && (gPlayerState.flags & PL_MINISH) == 0 &&
(gPlayerState.skills & SKILL_DASH_ATTACK) != 0) {
- gPlayerState.field_0xab = 3;
- sub_08077DF4(this, 0x298);
- bombEntity = CreatePlayerItemWithParent(this, PLAYER_ITEM_C);
- if (bombEntity != NULL) {
+ gPlayerState.lastSwordMove = SWORD_MOVE_DASH;
+ SetItemAnim(this, 0x298);
+ entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_DASH_SWORD);
+ if (entity != NULL) {
if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) {
uVar3 = gSave.stats.itemButtons[SLOT_A];
} else {
uVar3 = gSave.stats.itemButtons[SLOT_B];
}
- bombEntity->field_0x68.HALF.LO = uVar3;
+ entity->field_0x68.HALF.LO = uVar3;
return;
}
} else if ((gPlayerState.flags & PL_MINISH) == 0) {
- sub_08077DF4(this, 0x104);
+ SetItemAnim(this, 0x104);
return;
} else {
gPlayerState.animation = 0xc10;
@@ -127,15 +127,15 @@ void sub_08076964(ItemBehavior* this, u32 idx) {
}
}
gPlayerState.dash_state = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
-void sub_08076A88(ItemBehavior* this, u32 idx) {
+void sub_08076A88(ItemBehavior* this, u32 index) {
u32 uVar1;
u32 uVar2;
u8* ptr;
- if ((sub_08077EFC(this) != 0) && (gPlayerState.dash_state != 0)) {
+ if ((IsItemActive(this) != 0) && (gPlayerState.dash_state != 0)) {
if ((gPlayerState.flags & PL_MINISH) == 0) {
gPlayerEntity.speed = 0x300;
} else {
@@ -148,27 +148,27 @@ void sub_08076A88(ItemBehavior* this, u32 idx) {
gPlayerEntity.subAction = 0;
COLLISION_OFF(&gPlayerEntity);
gPlayerState.field_0x38 = 0;
- gPlayerState.field_0xd = 0xff;
+ gPlayerState.direction = 0xff;
return;
}
this->subtimer = 1;
return;
}
ptr = gUnk_0811BE38;
- if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.field_0x90) == 0) {
+ if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.heldInput) == 0) {
this->direction = (this->playerAnimationState & 0xe) * 4;
- if ((gPlayerState.field_0xd != 0xff) && (gPlayerState.field_0xd != this->direction)) {
- if (((gPlayerState.field_0xd - this->direction) & 0x1f) < 0x10) {
+ if ((gPlayerState.direction != 0xff) && (gPlayerState.direction != this->direction)) {
+ if (((gPlayerState.direction - this->direction) & 0x1f) < 0x10) {
this->direction = this->direction + 2;
}
this->direction--;
this->direction &= 0x1f;
}
- gPlayerState.field_0xd = this->direction;
+ gPlayerState.direction = this->direction;
UpdateItemAnim(this);
return;
}
}
gPlayerState.dash_state = 0;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
diff --git a/src/item/itemRocsCape.c b/src/item/itemRocsCape.c
index 75b74e49..dee55950 100644
--- a/src/item/itemRocsCape.c
+++ b/src/item/itemRocsCape.c
@@ -5,23 +5,23 @@
void sub_08076758(ItemBehavior*, u32);
extern void sub_08077F84(void);
-void ItemRocsCape(ItemBehavior* this, u32 arg1) {
+void ItemRocsCape(ItemBehavior* this, u32 index) {
if (this->stateID != 0) {
- sub_08076758(this, arg1);
+ sub_08076758(this, index);
return;
}
if (gPlayerState.item == NULL) {
- if (gPlayerState.field_0x0[1]) {
- if (((gPlayerState.field_0x3[1] | gPlayerState.heldObject) == 0) &&
+ if (gPlayerState.grab_status) {
+ if (((gPlayerState.attack_status | gPlayerState.heldObject) == 0) &&
(((gPlayerState.floor_type != SURFACE_DOOR && (gPlayerState.floor_type != SURFACE_PIT)) ||
((gPlayerEntity.z.WORD != 0 || (gPlayerState.field_0x14 != 0)))))) {
if ((gPlayerState.jump_status == 0) || ((gPlayerState.jump_status & 7) == 3)) {
if (-1 < gPlayerEntity.z.WORD) {
- gPlayerState.field_0x0[1] = 0;
- this->stateID += 1;
+ gPlayerState.grab_status = 0;
+ this->stateID++;
gPlayerState.keepFacing = 0;
gPlayerState.jump_status = 1;
- gPlayerState.field_0xe = -1;
+ gPlayerState.itemAnimPriority = -1;
gPlayerState.item = NULL;
gPlayerEntity.zVelocity = Q_16_16(2.0);
sub_08077F84();
@@ -29,25 +29,25 @@ void ItemRocsCape(ItemBehavior* this, u32 arg1) {
return;
}
} else {
- sub_08076758(this, arg1);
+ sub_08076758(this, index);
return;
}
}
} else {
- if (((u8)(gPlayerState.sword_state | gPlayerState.field_0xa | gPlayerState.field_0x3[1] |
+ if (((u8)(gPlayerState.sword_state | gPlayerState.field_0xa | gPlayerState.attack_status |
gPlayerState.heldObject | gPlayerState.field_0x1c | gPlayerState.moleMittsState) == 0) &&
((((gPlayerState.floor_type != SURFACE_DOOR && gPlayerState.floor_type != SURFACE_DOOR_13 &&
gPlayerState.floor_type != SURFACE_PIT) ||
(gPlayerEntity.z.WORD != 0)) ||
(gPlayerState.field_0x14 != 0)))) {
if ((gPlayerState.jump_status != 0) && ((gPlayerState.jump_status & 7) != 3)) {
- sub_08076758(this, arg1);
+ sub_08076758(this, index);
return;
} else if (gPlayerEntity.z.WORD >= 0) {
gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerState.jump_status = 1;
gPlayerState.item = NULL;
- this->stateID += 1;
+ this->stateID++;
sub_08077F84();
SoundReq(SFX_PLY_VO4);
return;
@@ -55,16 +55,14 @@ void ItemRocsCape(ItemBehavior* this, u32 arg1) {
}
}
}
- DeletePlayerItem(this, arg1);
+ DeleteItemBehavior(this, index);
}
-void sub_08076758(ItemBehavior* this, u32 arg1) {
- s32 iVar1;
-
- gPlayerState.field_0xe = 0;
+void sub_08076758(ItemBehavior* this, u32 index) {
+ gPlayerState.itemAnimPriority = 0;
if ((((gPlayerState.jump_status & 0x28) == 0) && (gPlayerState.jump_status != 0)) &&
((gPlayerState.jump_status & 7) != 3)) {
- if (sub_08077EFC(this)) {
+ if (IsItemActive(this)) {
if (this->stateID < 2) {
if ((gPlayerEntity.zVelocity <= 0) && ((gPlayerState.jump_status & 0x10) == 0)) {
this->stateID = 2;
@@ -75,15 +73,15 @@ void sub_08076758(ItemBehavior* this, u32 arg1) {
SoundReq(SFX_172);
}
} else {
- gPlayerEntity.field_0x7a.HWORD += 1;
+ gPlayerEntity.field_0x7a.HWORD++;
}
} else {
if (this->stateID > 1) {
- gPlayerEntity.field_0x7a.HWORD += 1;
+ gPlayerEntity.field_0x7a.HWORD++;
gPlayerState.jump_status &= 0xef;
}
}
} else {
- DeletePlayerItem(this, arg1);
+ DeleteItemBehavior(this, index);
}
}
diff --git a/src/item/itemShield.c b/src/item/itemShield.c
index 4ab16a4e..f9320d79 100644
--- a/src/item/itemShield.c
+++ b/src/item/itemShield.c
@@ -8,45 +8,45 @@ void sub_08076D04(ItemBehavior*, u32);
void sub_08076D34(ItemBehavior*, u32);
void sub_08076D94(ItemBehavior*, u32);
-void ItemShield(ItemBehavior* beh, u32 idx) {
+void ItemShield(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08076D04,
sub_08076D34,
sub_08076D94,
};
- stateFuncs[beh->stateID](beh, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08076D04(ItemBehavior* beh, u32 idx) {
- gPlayerState.field_0x3[0] = 0x81;
- beh->field_0x9 = 2;
+void sub_08076D04(ItemBehavior* this, u32 index) {
+ gPlayerState.shield_status = 0x81;
+ this->priority = 2;
sub_0806F948(&gPlayerEntity);
- sub_08077D38(beh, idx);
- sub_08077BB8(beh);
+ sub_08077D38(this, index);
+ sub_08077BB8(this);
}
-void sub_08076D34(ItemBehavior* beh, u32 idx) {
- if (sub_08077EFC(beh) != 0) {
- gPlayerState.field_0x3[0] |= 1;
- UpdateItemAnim(beh);
- if (beh->playerFrame != 0) {
- beh->stateID++;
- beh->field_0xf = 0;
- gPlayerState.field_0xa &= ~(u8)(8 >> idx);
+void sub_08076D34(ItemBehavior* this, u32 index) {
+ if (IsItemActive(this) != 0) {
+ gPlayerState.shield_status |= 1;
+ UpdateItemAnim(this);
+ if (this->playerFrame != 0) {
+ this->stateID++;
+ this->animPriority = 0;
+ gPlayerState.field_0xa &= ~(u8)(8 >> index);
SoundReq(SFX_15D);
}
} else {
- gPlayerState.field_0x3[0] = 0;
- DeletePlayerItem(beh, idx);
+ gPlayerState.shield_status = 0;
+ DeleteItemBehavior(this, index);
}
}
-void sub_08076D94(ItemBehavior* beh, u32 idx) {
- if (sub_08077EFC(beh)) {
- gPlayerState.field_0x3[0] |= 1;
- UpdateItemAnim(beh);
+void sub_08076D94(ItemBehavior* this, u32 index) {
+ if (IsItemActive(this)) {
+ gPlayerState.shield_status |= 1;
+ UpdateItemAnim(this);
} else {
- gPlayerState.field_0x3[0] = 0;
- DeletePlayerItem(beh, idx);
+ gPlayerState.shield_status = 0;
+ DeleteItemBehavior(this, index);
}
}
diff --git a/src/item/itemSword.c b/src/item/itemSword.c
index 9dcaba2e..87b1070a 100644
--- a/src/item/itemSword.c
+++ b/src/item/itemSword.c
@@ -1,8 +1,9 @@
-#include "item.h"
#include "functions.h"
-#include "sound.h"
+#include "item.h"
#include "object.h"
+#include "player.h"
#include "playeritem.h"
+#include "sound.h"
void sub_080759B8(ItemBehavior*, u32);
void sub_080754B8(ItemBehavior*, u32);
@@ -16,20 +17,20 @@ void sub_080758B0(ItemBehavior*, u32);
void sub_08075900(ItemBehavior*, u32);
void sub_08075694(ItemBehavior*, u32);
-void ItemSword(ItemBehavior* this, u32 idx) {
+void ItemSword(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075338, sub_080754B8, sub_080755F0, sub_0807564C, sub_08075738,
sub_08075580, sub_08075898, sub_080758B0, sub_08075900,
};
gPlayerState.framestate = PL_STATE_SWORD;
- stateFuncs[this->stateID](this, idx);
+ stateFuncs[this->stateID](this, index);
}
-void sub_08075338(ItemBehavior* this, u32 idx) {
+void sub_08075338(ItemBehavior* this, u32 index) {
u32 temp, temp2;
if (gPlayerState.flags & PL_MINISH) {
- this->field_0x9 |= 0x80;
- sub_08077D38(this, idx);
+ this->priority |= 0x80;
+ sub_08077D38(this, index);
gPlayerState.animation = 0xc00;
SoundReq(SFX_PLY_VO1);
return;
@@ -40,20 +41,20 @@ void sub_08075338(ItemBehavior* this, u32 idx) {
if ((gPlayerState.jump_status & 0x78) == 0 && (u32)gPlayerEntity.zVelocity < Q_16_16(1.5) &&
(gPlayerState.skills & SKILL_DOWN_THRUST) && gPlayerEntity.z.WORD != 0) {
gPlayerState.jump_status |= 0x20;
- gPlayerState.field_0xab = 7;
- gPlayerState.field_0x3[1] |= (8 >> idx) | ((8 >> idx) << 4);
+ gPlayerState.lastSwordMove = SWORD_MOVE_DOWN_THRUST;
+ gPlayerState.attack_status |= (8 >> index) | ((8 >> index) << 4);
sub_08077B98(this);
this->stateID = 6;
- sub_08075898(this, idx);
+ sub_08075898(this, index);
return;
}
}
#ifndef EU
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
return;
} else if (gPlayerEntity.z.WORD) {
#endif
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
return;
}
@@ -67,19 +68,19 @@ void sub_08075338(ItemBehavior* this, u32 idx) {
}
// Do the roll attack.
- sub_08077D38(this, idx);
+ sub_08077D38(this, index);
sub_08077B98(this);
- temp = (8 >> idx);
- gPlayerState.field_0x3[1] |= temp | (temp << 4);
+ temp = (8 >> index);
+ gPlayerState.attack_status |= temp | (temp << 4);
gPlayerState.field_0xa |= temp;
gPlayerState.keepFacing |= temp;
this->stateID = 8;
this->timer = 0x14;
- this->field_0xf = 6;
- this->field_0x9 |= 0x80;
- gPlayerState.field_0xab = 2;
+ this->animPriority = 6;
+ this->priority |= 0x80;
+ gPlayerState.lastSwordMove = SWORD_MOVE_ROLL;
gPlayerState.flags |= PL_SWORD_THRUST;
- sub_08077DF4(this, 0x130);
+ SetItemAnim(this, 0x130);
SoundReq(SFX_PLY_VO3);
return;
}
@@ -96,105 +97,107 @@ void sub_08075338(ItemBehavior* this, u32 idx) {
}
}
- sub_08077D38(this, idx);
+ sub_08077D38(this, index);
sub_08077B98(this);
}
-void sub_080754B8(ItemBehavior* this, u32 idx) {
- u32 iVar1;
+void sub_080754B8(ItemBehavior* this, u32 index) {
+ u32 swordBeam;
if ((gPlayerState.sword_state & 0x80) != 0) {
- sub_08075694(this, idx);
- } else if (gPlayerState.field_0x3[1] != 0) {
+ sub_08075694(this, index);
+ } else if (gPlayerState.attack_status != 0) {
UpdateItemAnim(this);
if (this->playerFrame != 0) {
- this->field_0x9 &= ~0x80;
+ this->priority &= ~0x80;
}
if (gPlayerEntity.frameSpriteSettings & 1) {
- iVar1 = sub_0807B014();
- if (iVar1 && FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_SWORD_BEAM1, 2) == 0) {
+ swordBeam = GetSwordBeam();
+ if (swordBeam && FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_SWORD_BEAM1, 2) == 0) {
CreatePlayerItemWithParent(this, PLAYER_ITEM_SWORD_BEAM1);
- if (iVar1 == 0xf) {
- gPlayerState.field_0xab = 5;
+ if (swordBeam == 0xf) {
+ // SKILL_SWORD_BEAM (full health)
+ gPlayerState.lastSwordMove = SWORD_MOVE_FULL_BEAM;
} else {
- gPlayerState.field_0xab = 8;
+ // SKILL_PERIL_BEAM (low health)
+ gPlayerState.lastSwordMove = SWORD_MOVE_LOW_BEAM;
}
}
}
if ((this->playerFrame & 0x80) != 0) {
if (((gPlayerState.flags & 0x80) != 0) || ((gPlayerState.skills & SKILL_SPIN_ATTACK) == 0)) {
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
} else {
- sub_08075580(this, idx);
+ sub_08075580(this, index);
}
}
} else {
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
}
}
-void sub_08075580(ItemBehavior* this, u32 idx) {
- if ((sub_08077EFC(this) != 0) && (gPlayerState.jump_status == 0)) {
- gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx);
+void sub_08075580(ItemBehavior* this, u32 index) {
+ if ((IsItemActive(this) != 0) && (gPlayerState.jump_status == 0)) {
+ gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
gPlayerState.sword_state = 1;
gPlayerState.item->hurtType = 0xd;
- this->field_0xf = 0;
+ this->animPriority = 0;
this->stateID = 2;
if ((gPlayerState.skills & SKILL_FAST_SPIN) != 0) {
this->timer = 0x28; // TODO spin speed?
} else {
this->timer = 0x50;
}
- sub_08077DF4(this, 0x168);
+ SetItemAnim(this, 0x168);
CreateObject(SWORD_PARTICLE, 0, 0);
return;
}
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
}
-void sub_080755F0(ItemBehavior* this, u32 idx) {
- if (sub_08077EFC(this) != 0) {
+void sub_080755F0(ItemBehavior* this, u32 index) {
+ if (IsItemActive(this) != 0) {
if (sub_08077EC8(this) == 0) {
- if ((gPlayerState.sword_state | gPlayerState.field_0x3[1]) != 0) {
+ if ((gPlayerState.sword_state | gPlayerState.attack_status) != 0) {
if (--this->timer == 0) {
this->stateID = 3;
- this->field_0x9 |= 0x80;
+ this->priority |= 0x80;
gPlayerState.sword_state = gPlayerState.sword_state | 0x20;
}
} else {
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
}
}
} else {
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
}
}
-void sub_0807564C(ItemBehavior* this, u32 idx) {
- if ((gPlayerState.sword_state | gPlayerState.field_0x3[1]) == 0) {
- sub_080759B8(this, idx);
+void sub_0807564C(ItemBehavior* this, u32 index) {
+ if ((gPlayerState.sword_state | gPlayerState.attack_status) == 0) {
+ sub_080759B8(this, index);
} else {
- if ((sub_08077EC8(this) == 0) && ((sub_08077EFC(this) == 0 || ((gPlayerState.sword_state & 0x80) != 0)))) {
- sub_08075694(this, idx);
+ if ((sub_08077EC8(this) == 0) && ((IsItemActive(this) == 0 || ((gPlayerState.sword_state & 0x80) != 0)))) {
+ sub_08075694(this, index);
}
}
}
-void sub_08075694(ItemBehavior* this, u32 idx) {
+void sub_08075694(ItemBehavior* this, u32 index) {
this->timer = 1;
if (gPlayerState.flags & PL_SWORD_THRUST) {
gPlayerState.flags &= ~PL_SWORD_THRUST;
gPlayerState.flags &= ~PL_ROLLING;
- sub_08077DF4(this, 300);
+ SetItemAnim(this, 300);
} else {
- gPlayerState.field_0xab = 1;
- sub_08077DF4(this, 0x124);
+ gPlayerState.lastSwordMove = SWORD_MOVE_SPIN;
+ SetItemAnim(this, 0x124);
}
- gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa;
+ gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
this->stateID = 4;
- this->field_0xf = 6;
+ this->animPriority = 6;
gPlayerEntity.hurtType = 0x1e;
gPlayerState.sword_state |= 0x40;
gPlayerState.sword_state &= 0xdf;
@@ -205,20 +208,20 @@ void sub_08075694(ItemBehavior* this, u32 idx) {
SoundReq(SFX_PLY_VO2);
}
-void sub_08075738(ItemBehavior* this, u32 idx) {
+void sub_08075738(ItemBehavior* this, u32 index) {
u32 bVar6;
- if (gPlayerState.field_0x3[1] == 0) {
- sub_080759B8(this, idx);
+ if (gPlayerState.attack_status == 0) {
+ sub_080759B8(this, index);
} else {
UpdateItemAnim(this);
- if (sub_08077F10(this)) {
+ if (IsItemActivatedThisFrame(this)) {
this->timer = 2;
}
if ((gPlayerState.sword_state & 0x10) != 0) {
- if ((gPlayerState.field_0xd & 0x80) == 0) {
- this->direction = gPlayerState.field_0xd;
+ if ((gPlayerState.direction & 0x80) == 0) {
+ this->direction = gPlayerState.direction;
}
gPlayerEntity.direction = this->direction;
gPlayerEntity.speed = 0x180;
@@ -229,13 +232,13 @@ void sub_08075738(ItemBehavior* this, u32 idx) {
}
if ((bVar6 <= ++this->subtimer) || (--this->timer == 0)) {
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
}
}
} else {
if (((((gPlayerEntity.frameSpriteSettings & 1) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) &&
((gPlayerState.skills & SKILL_FOURSWORD) != 0))) {
- Entity* bombEnt = CreatePlayerItemWithParent(this, PLAYER_ITEM_14);
+ Entity* bombEnt = CreatePlayerItemWithParent(this, PLAYER_ITEM_SPIRAL_BEAM);
if (bombEnt) {
bombEnt->animationState = (gPlayerEntity.animationState & 6) | 0x80;
}
@@ -244,34 +247,34 @@ void sub_08075738(ItemBehavior* this, u32 idx) {
if ((((gPlayerEntity.frameSpriteSettings & 2) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) &&
(((gPlayerState.skills & SKILL_GREAT_SPIN) != 0 && (--this->timer != 0)))) {
gPlayerState.sword_state |= 0x10;
- gPlayerState.field_0xab = 6;
+ gPlayerState.lastSwordMove = SWORD_MOVE_GREAT_SPIN;
this->direction = gPlayerEntity.animationState << 2;
this->timer = 1;
this->subtimer = 1;
- gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx);
- sub_08077DF4(this, 0x128);
+ gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
+ SetItemAnim(this, 0x128);
}
if ((this->playerFrame & 0x80) != 0) {
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
}
}
}
}
-void sub_08075898(ItemBehavior* this, u32 idx) {
- if (gPlayerState.field_0x3[1] == 0) {
- sub_080759B8(this, idx);
+void sub_08075898(ItemBehavior* this, u32 index) {
+ if (gPlayerState.attack_status == 0) {
+ sub_080759B8(this, index);
}
}
-void sub_080758B0(ItemBehavior* this, u32 idx) {
- if (gPlayerState.field_0x3[1] == 0) {
- sub_080759B8(this, idx);
+void sub_080758B0(ItemBehavior* this, u32 index) {
+ if (gPlayerState.attack_status == 0) {
+ sub_080759B8(this, index);
} else {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
- this->field_0xf = 0;
+ this->animPriority = 0;
if ((gPlayerState.sword_state & 0x20) != 0) {
this->stateID = 3;
} else {
@@ -282,20 +285,20 @@ void sub_080758B0(ItemBehavior* this, u32 idx) {
}
}
-void sub_08075900(ItemBehavior* this, u32 idx) {
+void sub_08075900(ItemBehavior* this, u32 index) {
if (gPlayerState.floor_type == SURFACE_SWAMP) {
gPlayerState.flags &= ~PL_ROLLING;
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
} else {
UpdateItemAnim(this);
if ((gPlayerState.sword_state & 0x80) != 0) {
gPlayerState.sword_state = 0xa0;
- sub_0807564C(this, idx);
+ sub_0807564C(this, index);
} else {
if (this->timer != 0) {
if (--this->timer == 0) {
- sub_08077DF4(this, 0x134);
+ SetItemAnim(this, 0x134);
}
gPlayerEntity.direction = (gPlayerEntity.animationState >> 1) << 3;
gPlayerEntity.speed = 0x300;
@@ -306,19 +309,19 @@ void sub_08075900(ItemBehavior* this, u32 idx) {
} else {
if ((this->playerFrame & 0x80) != 0) {
gPlayerState.flags &= ~PL_ROLLING;
- sub_080759B8(this, idx);
+ sub_080759B8(this, index);
}
}
}
}
}
-void sub_080759B8(ItemBehavior* this, u32 idx) {
+void sub_080759B8(ItemBehavior* this, u32 index) {
if ((gPlayerState.flags & PL_MINISH) == 0) {
gPlayerEntity.hurtType = 0;
}
gPlayerState.flags &= ~PL_SWORD_THRUST;
gPlayerState.sword_state = 0;
gPlayerState.item = NULL;
- DeletePlayerItem(this, idx);
+ DeleteItemBehavior(this, index);
}
diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c
index 6de4eb66..8a7b40dc 100644
--- a/src/item/itemTryPickupObject.c
+++ b/src/item/itemTryPickupObject.c
@@ -1,11 +1,12 @@
#include "item.h"
#include "functions.h"
#include "sound.h"
+#include "playeritem.h"
-u32 sub_08077F64(ItemBehavior* arg0, u32 idx);
+u32 sub_08077F64(ItemBehavior* arg0, u32 index);
u32 sub_080789A8(void);
void sub_080762C4(ItemBehavior*, Entity*, u8, u32);
-void sub_08076088(ItemBehavior*, void*, u32);
+void sub_08076088(ItemBehavior*, Entity*, u32);
void ItemPickupCheck(ItemBehavior*, u32);
void sub_080762D8(ItemBehavior*, u32);
void sub_08076488(ItemBehavior*, u32);
@@ -13,24 +14,79 @@ void sub_08076518(ItemBehavior*, u32);
void sub_080765E0(ItemBehavior*, u32);
void sub_0807660C(ItemBehavior*, u32);
-void ItemTryPickupObject(ItemBehavior* this, u32 idx) {
+void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
+ if (param_2 != NULL) {
+ if ((param_2->carryFlags & 1) != 0) {
+ return;
+ }
+ param_2->action = 2;
+ param_2->subAction = param_2->carryFlags & 1;
+ }
+
+ this->field_0x18 = param_2;
+ if ((gPlayerState.flags & PL_NO_CAP)) {
+ SetItemAnim(this, 0x928);
+ } else {
+ SetItemAnim(this, 0x338);
+ }
+ gPlayerState.heldObject = 3;
+ gPlayerState.framestate = 4;
+ this->stateID = 2;
+ this->animPriority = 0xf;
+ if ((gPlayerEntity.field_0x78.HALF.HI & 0x80)) {
+ gPlayerEntity.field_0x78.HALF.HI = 0;
+ COLLISION_ON(&gPlayerEntity);
+ gPlayerState.heldObject = 4;
+ gPlayerState.keepFacing = ~(8 >> param_3) & gPlayerState.keepFacing;
+ gPlayerState.field_0xa = ~(8 >> param_3) & gPlayerState.field_0xa;
+ this->stateID = 3;
+ this->animPriority = 0;
+ } else {
+ gPlayerState.field_0xa |= (8 >> param_3);
+ gPlayerState.keepFacing |= (8 >> param_3);
+ }
+
+ param_2 = CreatePlayerItemWithParent(this, PLAYER_ITEM_HELD_OBJECT);
+ if (param_2 == NULL) {
+ PlayerCancelHoldItem(this, param_3);
+ } else {
+ Entity* playerEnt = &gPlayerEntity;
+ *(Entity**)&playerEnt->field_0x74 = param_2;
+ playerEnt->subtimer = 0;
+ param_2->child = this->field_0x18;
+ param_2->carryFlags = playerEnt->carryFlags;
+ param_2->parent = (Entity*)this;
+ this->field_0x18 = param_2;
+ param_2->type2 = this->field_0x2[1];
+ param_2->timer = this->timer;
+ param_2->subtimer = this->subtimer;
+ if ((this->field_0x18->carryFlags & 0xf0) == 0x10) {
+ this->timer = 8;
+ } else {
+ this->timer = 0;
+ }
+ SoundReq(SFX_PLY_LIFT);
+ }
+}
+
+void ItemTryPickupObject(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
ItemPickupCheck, sub_080762D8, sub_08076488, sub_08076518, sub_080765E0, sub_0807660C,
};
- stateFuncs[this->stateID](this, idx);
+ stateFuncs[this->stateID](this, index);
}
-void ItemPickupCheck(ItemBehavior* this, u32 idx) {
+void ItemPickupCheck(ItemBehavior* this, u32 index) {
Entity* carried;
- if (!(((gPlayerState.field_0x3[1] != 0) ||
- (((gPlayerState.jump_status != 0 && ((gPlayerState.flags & (PL_BUSY | PL_FALLING | PL_IN_MINECART)) == 0)) ||
- (gPlayerState.field_0x0[1] = gPlayerEntity.animationState | 0x80, 8 < gPlayerEntity.iframes)))))) {
+ if (gPlayerState.attack_status == 0 &&
+ (gPlayerState.jump_status == 0 || (gPlayerState.flags & (PL_BUSY | PL_FALLING | PL_IN_MINECART)) != 0) &&
+ (gPlayerState.grab_status = gPlayerEntity.animationState | 0x80, gPlayerEntity.iframes <= 8)) {
switch (sub_080789A8()) {
case 2:
if (((gCarriedEntity.unk_8)->carryFlags & 0xf) == 0) {
- sub_08076088(this, gCarriedEntity.unk_8, idx);
+ sub_08076088(this, gCarriedEntity.unk_8, index);
return;
}
carried = gCarriedEntity.unk_8;
@@ -38,24 +94,24 @@ void ItemPickupCheck(ItemBehavior* this, u32 idx) {
carried->action = 2;
carried->subAction = 5;
gPlayerState.framestate = PL_STATE_THROW;
- sub_080762C4(this, carried, 2, idx);
+ sub_080762C4(this, carried, 2, index);
gUnk_0200AF00.unk_2e = 8;
SoundReq(SFX_102);
break;
case 1:
- sub_080762C4(this, 0, 1, idx);
+ sub_080762C4(this, 0, 1, index);
SoundReq(SFX_102);
break;
case 0:
this->stateID = 5;
this->timer = 0x0f;
- this->field_0xf = 6;
- gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa;
- gPlayerState.keepFacing = (8 >> idx) | gPlayerState.keepFacing;
+ this->animPriority = 6;
+ gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
+ gPlayerState.keepFacing = (8 >> index) | gPlayerState.keepFacing;
if ((gPlayerState.flags & PL_NO_CAP) == 0) {
- sub_08077DF4(this, 0x378);
+ SetItemAnim(this, 0x378);
} else {
- sub_08077DF4(this, 0x948);
+ SetItemAnim(this, 0x948);
}
SoundReq(SFX_88);
break;
@@ -63,7 +119,7 @@ void ItemPickupCheck(ItemBehavior* this, u32 idx) {
break;
}
} else {
- PlayerCancelHoldItem(this, idx);
+ PlayerCancelHoldItem(this, index);
}
}
@@ -73,14 +129,14 @@ void sub_080762C4(ItemBehavior* this, Entity* arg1, u8 arg2, u32 arg3) {
sub_08077D38(this, arg3);
}
-ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080762D8.inc", void sub_080762D8(ItemBehavior* this, u32 idx))
+ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080762D8.inc", void sub_080762D8(ItemBehavior* this, u32 index))
-void sub_08076488(ItemBehavior* this, u32 idx) {
+void sub_08076488(ItemBehavior* this, u32 index) {
u32 bVar1;
s32 iVar2;
if (this->timer == 0) {
- if (PlayerTryDropObject(this, idx) != 0) {
+ if (PlayerTryDropObject(this, index) != 0) {
if ((((this->field_0x18->carryFlags) & 0xf0) == 0x10) && ((gRoomTransition.frameCount & 1U) != 0)) {
return;
}
@@ -88,11 +144,11 @@ void sub_08076488(ItemBehavior* this, u32 idx) {
if ((this->playerFrame & 0x80) != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerState.heldObject = 4;
- bVar1 = ~(8 >> idx);
+ bVar1 = ~(8 >> index);
gPlayerState.keepFacing = bVar1 & gPlayerState.keepFacing;
gPlayerState.field_0xa = bVar1 & gPlayerState.field_0xa;
this->stateID++;
- this->field_0xf = 0;
+ this->animPriority = 0;
}
}
} else {
@@ -108,19 +164,18 @@ void sub_08076518(ItemBehavior* this, u32 index) {
if (gPlayerEntity.knockbackDuration != 0) {
PlayerCancelHoldItem(this, index);
} else {
- if ((gPlayerState.playerInput.field_0x92 & (PLAYER_INPUT_8000 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) !=
- 0) {
+ if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_8000 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0) {
sub_0806F948(&gPlayerEntity);
gPlayerState.heldObject = 5;
this->field_0x18->subAction = 2;
this->field_0x18->direction = (gPlayerEntity.animationState & 0xe) << 2;
this->field_0x18 = NULL;
this->stateID++;
- this->field_0xf = 0x0f;
+ this->animPriority = 0x0f;
if ((gPlayerState.flags & PL_NO_CAP) != 0) {
- sub_08077DF4(this, 0x930);
+ SetItemAnim(this, 0x930);
} else {
- sub_08077DF4(this, 0x344);
+ SetItemAnim(this, 0x344);
}
gPlayerState.field_0xa |= 8 >> index;
gPlayerState.keepFacing |= 8 >> index;
@@ -130,20 +185,20 @@ void sub_08076518(ItemBehavior* this, u32 index) {
}
}
-void sub_080765E0(ItemBehavior* this, u32 idx) {
- if (PlayerTryDropObject(this, idx) != 0) {
+void sub_080765E0(ItemBehavior* this, u32 index) {
+ if (PlayerTryDropObject(this, index) != 0) {
if ((this->playerFrame & 0x80) != 0) {
- PlayerCancelHoldItem(this, idx);
+ PlayerCancelHoldItem(this, index);
} else {
UpdateItemAnim(this);
}
}
}
-void sub_0807660C(ItemBehavior* this, u32 idx) {
+void sub_0807660C(ItemBehavior* this, u32 index) {
UpdateItemAnim(this);
- if ((this->timer-- == 0) || (gPlayerState.field_0x0[1] == 0)) {
- gPlayerState.field_0x0[1] = 0;
- DeletePlayerItem(this, idx);
+ if ((this->timer-- == 0) || (gPlayerState.grab_status == 0)) {
+ gPlayerState.grab_status = 0;
+ DeleteItemBehavior(this, index);
}
}
diff --git a/src/itemDefinitions.c b/src/itemDefinitions.c
new file mode 100644
index 00000000..c6a8567b
--- /dev/null
+++ b/src/itemDefinitions.c
@@ -0,0 +1,43 @@
+#include "item.h"
+#include "playeritem.h"
+#include "structures.h"
+
+const ItemDefinition gItemDefinitions[] = {
+ [ITEM_NONE] = { TRUE, 1, CREATE_ITEM_0, PLAYER_ITEM_NONE, 0, 0, FALSE, FALSE },
+ [ITEM_SMITH_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
+ [ITEM_GREEN_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
+ [ITEM_RED_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
+ [ITEM_BLUE_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
+ [ITEM_UNUSED_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
+ [ITEM_FOURSWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
+ [ITEM_BOMBS] = { TRUE, 3, CREATE_ITEM_4, PLAYER_ITEM_BOMB, 0, 3, FALSE, FALSE },
+ [ITEM_REMOTE_BOMBS] = { TRUE, 3, CREATE_ITEM_4, PLAYER_ITEM_BOMB, 0, 3, FALSE, FALSE },
+ [ITEM_BOW] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOW, 540, 3, FALSE, FALSE },
+ [ITEM_LIGHT_ARROW] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOW, 540, 3, FALSE, FALSE },
+ [ITEM_BOOMERANG] = { TRUE, 5, CREATE_ITEM_3, PLAYER_ITEM_BOOMERANG, 2072, 3, FALSE, FALSE },
+ [ITEM_MAGIC_BOOMERANG] = { TRUE, 5, CREATE_ITEM_3, PLAYER_ITEM_BOOMERANG, 1796, 3, FALSE, FALSE },
+ [ITEM_SHIELD] = { FALSE, 1, CREATE_ITEM_3, PLAYER_ITEM_SHIELD, 344, 2, FALSE, FALSE },
+ [ITEM_MIRROR_SHIELD] = { TRUE, 1, CREATE_ITEM_3, PLAYER_ITEM_SHIELD, 344, 2, FALSE, FALSE },
+#ifdef EU
+ [ITEM_LANTERN_OFF] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 6, FALSE, FALSE },
+ [ITEM_LANTERN_ON] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 6, FALSE, FALSE },
+#else
+ [ITEM_LANTERN_OFF] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 2, FALSE, FALSE },
+ [ITEM_LANTERN_ON] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 2, FALSE, FALSE },
+#endif
+ [ITEM_GUST_JAR] = { TRUE, 6, CREATE_ITEM_3, PLAYER_ITEM_GUST_JAR, 1280, 2, FALSE, FALSE },
+ [ITEM_PACCI_CANE] = { TRUE, 4, CREATE_ITEM_3, PLAYER_ITEM_PACCI_CANE, 1576, 6, TRUE, FALSE },
+ [ITEM_MOLE_MITTS] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NONE2, 0, 2, TRUE, FALSE },
+ [ITEM_ROCS_CAPE] = { TRUE, 1, CREATE_ITEM_1, PLAYER_ITEM_NONE3, 2060, 0, FALSE, FALSE },
+ [ITEM_PEGASUS_BOOTS] = { TRUE, CREATE_ITEM_1, PLAYER_ITEM_SWORD, 12, 260, 6, FALSE, FALSE },
+ [ITEM_FIRE_ROD] = { TRUE, 4, CREATE_ITEM_3, PLAYER_ITEM_CELL_OVERWRITE_SET, 260, 6, FALSE, FALSE },
+ [ITEM_OCARINA] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_NONE, 2273, 6, FALSE, FALSE },
+ [ITEM_ORB_GREEN] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NULLED2, 0, 1, TRUE, TRUE },
+ [ITEM_ORB_BLUE] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NULLED, 0, 1, TRUE, TRUE },
+ [ITEM_ORB_RED] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_CELL_OVERWRITE_SET2, 0, 1, TRUE, TRUE },
+ [ITEM_TRY_PICKUP_OBJECT] = { TRUE, 2, CREATE_ITEM_3, PLAYER_ITEM_HELD_OBJECT, 832, 4, FALSE, TRUE },
+ [ITEM_BOTTLE1] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
+ [ITEM_BOTTLE2] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
+ [ITEM_BOTTLE3] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
+ [ITEM_BOTTLE4] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
+};
diff --git a/src/itemMetaData.c b/src/itemMetaData.c
index c71f9495..ec3e1fe8 100644
--- a/src/itemMetaData.c
+++ b/src/itemMetaData.c
@@ -31,7 +31,7 @@ const ItemMetaData gItemMetaData[] = {
[ITEM_ORB_GREEN] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
[ITEM_ORB_BLUE] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
[ITEM_ORB_RED] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
- [ITEM_TRAP] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
+ [ITEM_TRY_PICKUP_OBJECT] = { 0x63u, 0u, 0u, 0u, 0u, 0u, 0u, 0u },
[ITEM_BOTTLE1] = { MENU_SLOT_BOTTLE0, 0x3u, 0u, 0x1u, 0x20u, TEXT_ITEM_GET, 0x20u, 0x5u },
[ITEM_BOTTLE2] = { MENU_SLOT_BOTTLE1, 0x3u, 0u, 0x1u, 0x20u, TEXT_ITEM_GET, 0x20u, 0x5u },
[ITEM_BOTTLE3] = { MENU_SLOT_BOTTLE2, 0x3u, 0u, 0x1u, 0x20u, TEXT_ITEM_GET, 0x20u, 0x5u },
diff --git a/src/manager/minishPortalManager.c b/src/manager/minishPortalManager.c
index fe312d14..d86549c3 100644
--- a/src/manager/minishPortalManager.c
+++ b/src/manager/minishPortalManager.c
@@ -83,7 +83,7 @@ void CreateMagicSparkles(u32 baseX, u32 baseY, u32 layer) {
}
bool32 PortalReadyForMinish(void) {
- if ((gPlayerState.flags & PL_MINISH) && !gPlayerState.field_0xaa && (gArea.portal_type != 0x6) &&
+ if ((gPlayerState.flags & PL_MINISH) && gPlayerState.attachedBeetleCount == 0 && (gArea.portal_type != 0x6) &&
(gPlayerState.heldObject == 0)) {
switch (gPlayerState.framestate) {
case PL_STATE_IDLE:
diff --git a/src/manager/miscManager.c b/src/manager/miscManager.c
index cca46468..4bd03591 100644
--- a/src/manager/miscManager.c
+++ b/src/manager/miscManager.c
@@ -365,7 +365,7 @@ void MiscManager_TypeB(MiscManager* this) {
bool32 sub_080593CC(MiscManager* this) {
if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 &&
- (gPlayerState.playerInput.field_0x90 & PLAYER_INPUT_ANY_DIRECTION) == PLAYER_INPUT_UP) {
+ (gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) == PLAYER_INPUT_UP) {
return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
}
return FALSE;
diff --git a/src/menu/pause_menu.c b/src/menu/pause_menu.c
index 0d16d8cc..957dc751 100644
--- a/src/menu/pause_menu.c
+++ b/src/menu/pause_menu.c
@@ -75,7 +75,7 @@ void PauseMenu_Variant0(void) {
(u16)gRoomTransition.player_status.overworld_map_y);
gPauseMenuOptions.unk2[4] = ptr->_4;
gPauseMenuOptions.unk2[5] = sub_0801DB94();
- if (IsItemEquipped(ITEM_LANTERN_ON) != 2) {
+ if (IsItemEquipped(ITEM_LANTERN_ON) != EQUIP_SLOT_NONE) {
r1 = 0x10;
} else {
r1 = 0xf;
@@ -399,8 +399,8 @@ void PauseMenu_ItemMenu_Update(void) {
}
case B_BUTTON:
if (gPauseMenu.items[menuSlot] != 0) {
- u32 t = !!(gInput.newKeys ^ 1);
- ForceEquipItem(gPauseMenu.items[menuSlot], t);
+ u32 slot = !!(gInput.newKeys ^ 1);
+ ForceEquipItem(gPauseMenu.items[menuSlot], slot);
SoundReq(SFX_TEXTBOX_SELECT);
}
break;
diff --git a/src/npc.c b/src/npc.c
index 99c07fee..94896d5e 100644
--- a/src/npc.c
+++ b/src/npc.c
@@ -20,7 +20,8 @@ void NPCUpdate(Entity* this) {
if (gNPCFunctions[this->id][1] != NULL)
gNPCFunctions[this->id][1](this);
- if (this->health % 0x80) {
+ if (this->health % 0x80) { // If this NPC was created by DelayedEntityLoadManager_Main, we need to update the
+ // location in gNPCData.
NPCStruct* npc = gNPCData;
npc += (this->health - 1);
npc->x = this->x.HALF.HI - gRoomControls.origin_x;
diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c
index e94a54ff..1497f185 100644
--- a/src/npc/bigGoron.c
+++ b/src/npc/bigGoron.c
@@ -418,12 +418,12 @@ void sub_0806D520(Entity* this, u32 param_2) {
}
void sub_0806D5D4(void) {
- u32 itemSlot;
+ EquipSlot equipSlot;
InitBiggoronTimer();
- itemSlot = IsItemEquipped(ITEM_SHIELD);
- if (itemSlot != 2) {
- gSave.stats.itemButtons[itemSlot] = ITEM_NONE;
+ equipSlot = IsItemEquipped(ITEM_SHIELD);
+ if (equipSlot != EQUIP_SLOT_NONE) {
+ gSave.stats.itemButtons[equipSlot] = ITEM_NONE;
}
SetInventoryValue(ITEM_SHIELD, 0);
}
diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c
index 8e05ed27..7e4f161a 100644
--- a/src/npc/bladeBrothers.c
+++ b/src/npc/bladeBrothers.c
@@ -144,7 +144,7 @@ void BladeBrothers_StartPlayerDemonstration(Entity* this, ScriptExecutionContext
if (BladeBrothers_EquippedItem) {}
if (p = this->timer, BladeBrothers_EquippedItem[p]) {
- ForceEquipItem(BladeBrothers_EquippedItem[this->timer], 0);
+ ForceEquipItem(BladeBrothers_EquippedItem[this->timer], EQUIP_SLOT_A);
}
InitPlayerMacro(BladeBrothers_PlayerMacros[this->timer]);
}
@@ -157,9 +157,10 @@ void sub_08068BB4(Entity* this) {
*(&this->field_0x68.HALF.HI + 1) = item;
}
+// Restore previous equipped items.
void sub_08068BD0(Entity* this) {
- ForceEquipItem(this->field_0x68.HALF.HI, 0);
- ForceEquipItem(*(u8*)(&this->field_0x68.HALF.HI + 1), 1);
+ ForceEquipItem(this->field_0x68.HALF.HI, EQUIP_SLOT_A);
+ ForceEquipItem(*(u8*)(&this->field_0x68.HALF.HI + 1), EQUIP_SLOT_B);
}
static void sub_08068BEC(Entity* this, u32 unused) {
@@ -337,18 +338,18 @@ void sub_08068E78(Entity* this) {
MessageNoOverlap(gUnk_08111714[this->timer], this);
}
-void sub_08068E90(Entity* this) {
+void BladeBrothers_LearnSkill(Entity* this) {
// Learn a skill.
PlayerState* s = &gPlayerState;
*(u16*)&s->skills = (1 << (gUnk_08111740[this->timer] - 1)) | *(u16*)&s->skills;
}
-void sub_08068EB4(void) {
- gPlayerState.field_0xab = 0;
+void BladeBrothers_ResetLastSwordMove(void) {
+ gPlayerState.lastSwordMove = SWORD_MOVE_NONE;
}
-void sub_08068EC4(Entity* this, ScriptExecutionContext* context) {
- if (gUnk_08111740[this->timer] == gPlayerState.field_0xab) {
+void BladeBrothers_CheckLastSwordMove(Entity* this, ScriptExecutionContext* context) {
+ if (gUnk_08111740[this->timer] == gPlayerState.lastSwordMove) {
context->wait = gUnk_0811172A[this->timer];
context->condition = 1;
} else {
diff --git a/src/npc/castleMaid.c b/src/npc/castleMaid.c
index 257bc451..cb327cdc 100644
--- a/src/npc/castleMaid.c
+++ b/src/npc/castleMaid.c
@@ -69,7 +69,7 @@ void sub_08064570(CastleMaidEntity* this) {
if (LoadExtraSpriteData(super, data) == 0) {
return;
}
- super->action += 1;
+ super->action++;
super->timer = 0;
tmp2 = sub_0805ACC0(super);
if (tmp2 == 0) {
@@ -84,7 +84,7 @@ void sub_08064570(CastleMaidEntity* this) {
case 1:
sub_0807DD94(super, NULL);
if (super->interactType != 0) {
- super->action += 1;
+ super->action++;
super->interactType = 0;
InitializeAnimation(super, sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity)));
if (this->dialogFunc != NULL) {
diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c
index 4168d951..d991340e 100644
--- a/src/npc/drLeft.c
+++ b/src/npc/drLeft.c
@@ -7,7 +7,7 @@ void sub_0806BFD8(Entity* this);
void DrLeft(Entity* this) {
if (this->type == 0) {
if (this->action == 0) {
- this->action += 1;
+ this->action++;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0807DD50(this);
}
@@ -17,7 +17,7 @@ void DrLeft(Entity* this) {
sub_0806BFD8(this);
} else {
if (this->action == 0) {
- this->action += 1;
+ this->action++;
this->frameIndex = 0;
SortEntityBelow(this, this);
}
diff --git a/src/npc/epona.c b/src/npc/epona.c
index ce180670..5c5adafa 100644
--- a/src/npc/epona.c
+++ b/src/npc/epona.c
@@ -104,7 +104,7 @@ void sub_08065AA4(Entity* this) {
void Epona_Fusion(Entity* this) {
if (this->action == 0) {
- this->action += 1;
+ this->action++;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 7);
} else {
diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c
index 78661fae..1e833a02 100644
--- a/src/npc/forestMinish.c
+++ b/src/npc/forestMinish.c
@@ -121,7 +121,7 @@ void sub_08060158(Entity* this) {
if (tmp2 & 0x80) {
this->animationState = sub_0806F5B0(index);
}
- tmp2 &= 0x7f;
+ tmp2 &= ~0x80;
this->frame = tmp1;
this->frameIndex = tmp2;
this->frameSpriteSettings = 1;
diff --git a/src/npc/guardWithSpear.c b/src/npc/guardWithSpear.c
index ed298050..f74b97ce 100644
--- a/src/npc/guardWithSpear.c
+++ b/src/npc/guardWithSpear.c
@@ -253,25 +253,25 @@ void sub_08064428(GuardWithSpearEntity* this) {
ShowNPCDialogue(super, pDialog);
}
-void sub_08064470(Entity* this, ScriptExecutionContext* context) {
- if (gPlayerState.field_0xab == 1) {
+void GuardWithSpear_CheckSwordMoveSpin(Entity* this, ScriptExecutionContext* context) {
+ if (gPlayerState.lastSwordMove == SWORD_MOVE_SPIN) {
context->condition = 1;
} else {
context->condition = 0;
}
}
-void sub_08064488(void) {
+void GuardWithSpear_ResetLastSwordMoveIfNotInSwordState(void) {
if (gPlayerState.framestate != PL_STATE_SWORD) {
- gPlayerState.field_0xab = 0;
+ gPlayerState.lastSwordMove = SWORD_MOVE_NONE;
}
}
-void sub_080644A4(void) {
- gPlayerState.field_0xab = 0;
+void GuardWithSpear_ResetLastSwordMove(void) {
+ gPlayerState.lastSwordMove = SWORD_MOVE_NONE;
}
-void sub_080644B4(Entity* this, ScriptExecutionContext* context) {
+void CheckLastSwordMove(Entity* this, ScriptExecutionContext* context) {
context->condition = this->animationState == context->intVariable;
}
diff --git a/src/npc/mama.c b/src/npc/mama.c
index 205c8e5a..ffe8abb6 100644
--- a/src/npc/mama.c
+++ b/src/npc/mama.c
@@ -100,7 +100,7 @@ void sub_0806C4F8(Entity* this) {
void Mama_Fusion(Entity* this) {
if (this->action == 0) {
if (sub_0806C454(this) != 0) {
- this->action += 1;
+ this->action++;
this->spriteSettings.draw = 1;
this->y.HALF.HI -= 4;
InitializeAnimation(this, 2);
diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c
index ea11cd38..91cfcbd1 100644
--- a/src/npc/npc4E.c
+++ b/src/npc/npc4E.c
@@ -180,8 +180,8 @@ void NPC4E_SaveEquippedItems(Entity* this) {
}
void NPC4E_RestoreEquippedItems(Entity* this) {
- ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.LO), 0);
- ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.HI), 1);
+ ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.LO), EQUIP_SLOT_A);
+ ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.HI), EQUIP_SLOT_B);
}
void sub_0806DC7C(void) {
diff --git a/src/npc/npc58.c b/src/npc/npc58.c
index 5a360a9a..5b916583 100644
--- a/src/npc/npc58.c
+++ b/src/npc/npc58.c
@@ -17,7 +17,7 @@ void NPC58(Entity* this) {
if (LoadExtraSpriteData(this, gUnk_081146D0) == 0) {
return;
}
- this->action += 1;
+ this->action++;
this->spriteSettings.draw = 2;
this->spriteRendering.b3 = 0;
this->spritePriority.b0 = 0;
diff --git a/src/npc/pina.c b/src/npc/pina.c
index fecc2bf3..545a4097 100644
--- a/src/npc/pina.c
+++ b/src/npc/pina.c
@@ -29,7 +29,7 @@ void sub_08063A80(Entity* this) {
}
void sub_08063A98(Entity* this) {
- this->action += 1;
+ this->action++;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 4);
sub_08078778(this);
@@ -157,7 +157,7 @@ void sub_08063CAC(Entity* this) {
void Pina_Fusion(Entity* this) {
if (this->action == 0) {
- this->action += 1;
+ this->action++;
this->spriteSettings.draw = 1;
this->y.HALF.HI -= 4;
InitAnimationForceUpdate(this, 2);
diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c
index abf4c69c..10de6135 100644
--- a/src/npc/townMinish.c
+++ b/src/npc/townMinish.c
@@ -320,7 +320,7 @@ void sub_0806AEE4(Entity* this) {
if (tmp2 & 0x80) {
this->animationState = sub_0806F5B0(index);
}
- tmp2 &= 0x7f;
+ tmp2 &= ~0x80;
this->frame = tmp1;
this->frameIndex = tmp2;
this->frameSpriteSettings = 1;
diff --git a/src/object.c b/src/object.c
index d4771b3f..96729ee1 100644
--- a/src/object.c
+++ b/src/object.c
@@ -195,7 +195,7 @@ void (*const gObjectFunctions[])(Entity*) = {
[PINWHEEL] = Pinwheel,
[OBJECT_BF] = ObjectBF,
[ENEMY_ITEM] = EnemyItem,
- [OBJECT_C1] = LinkAnimation,
+ [LINK_ANIMATION] = LinkAnimation,
};
void ObjectInit(Entity*);
diff --git a/src/object/barrelSpiderweb.c b/src/object/barrelSpiderweb.c
index 4c608779..3e555ece 100644
--- a/src/object/barrelSpiderweb.c
+++ b/src/object/barrelSpiderweb.c
@@ -71,7 +71,7 @@ void sub_0808BBE0(BarrelSpiderwebEntity* this) {
ptr = &gUnk_0812144C[diff * 2];
SetAffineInfo(super, ptr[0], ptr[1], 0);
} else {
- super->contactFlags &= 0x7f;
+ super->contactFlags &= ~0x80;
}
}
diff --git a/src/object/bigIceBlock.c b/src/object/bigIceBlock.c
index bb0fb7ca..8814fe63 100644
--- a/src/object/bigIceBlock.c
+++ b/src/object/bigIceBlock.c
@@ -97,7 +97,7 @@ void BigIceBlock_Action2(BigIceBlockEntity* this) {
}
super->action = 3;
super->timer = 60;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
}
void sub_08099880(BigIceBlockEntity* this) {
diff --git a/src/object/bird.c b/src/object/bird.c
index 55f080ad..e6243f22 100644
--- a/src/object/bird.c
+++ b/src/object/bird.c
@@ -238,7 +238,7 @@ void Bird_Type8(Entity* this) {
PutAwayItems();
gPlayerState.swim_state = 0;
gPlayerState.jump_status = 0;
- gPlayerEntity.flags &= 0x7f;
+ gPlayerEntity.flags &= ~0x80;
gPlayerEntity.spriteSettings.draw = 0;
gPriorityHandler.sys_priority = 6;
gPauseMenuOptions.disabled = 1;
diff --git a/src/object/book.c b/src/object/book.c
index 941b5c52..ece50550 100644
--- a/src/object/book.c
+++ b/src/object/book.c
@@ -213,7 +213,7 @@ void Book_Action5(Entity* this) {
u32 sub_0809B688(Entity* this) {
u32 ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12);
- if (ret == 1 && gPlayerState.field_0xd != 16) {
+ if (ret == 1 && gPlayerState.direction != 16) {
ret = 0;
}
diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c
index 0bf59d92..a0fb206d 100644
--- a/src/object/crenelBeanSprout.c
+++ b/src/object/crenelBeanSprout.c
@@ -140,7 +140,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
if (super->parent->action == 2) {
switch (super->parent->subAction) {
case 1:
- if ((gPlayerState.field_0xd & 0x80) != 0) {
+ if ((gPlayerState.direction & 0x80) != 0) {
InitializeAnimation(super, 4);
} else {
GetNextFrame(super);
@@ -163,7 +163,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
} else {
gPlayerState.mobility |= 0x80;
gPlayerState.heldObject = 5;
- if ((gPlayerState.field_0xd & 0x80) != 0) {
+ if ((gPlayerState.direction & 0x80) != 0) {
InitializeAnimation(super, (super->type >> 1) + 3);
} else {
GetNextFrame(super);
@@ -181,7 +181,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
RestorePrevTileEntity(0xdc, super->collisionLayer);
sub_08096A78(this);
}
- if ((gPlayerState.playerInput.field_0x92 & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
+ if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
return;
}
if (gUnk_0200AF00.unk_2f != 3) {
@@ -297,7 +297,7 @@ void CrenelBeanSprout_Action6SubAction1(CrenelBeanSproutEntity* this) {
sub_0807B7D8(gUnk_081231AE[super->type2], COORD_TO_TILE(super), super->collisionLayer);
super->type2++;
if (super->type2 == super->subtimer) {
- gPlayerState.keepFacing &= 0x7f;
+ gPlayerState.keepFacing &= ~0x80;
super->subAction++;
super->timer = 60;
} else {
diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c
index 868902b1..43dde1a2 100644
--- a/src/object/fileScreenObjects.c
+++ b/src/object/fileScreenObjects.c
@@ -9,8 +9,8 @@
#include "main.h"
#include "menu.h"
#include "object.h"
+#include "player.h"
-extern int sub_0807A094(int);
extern u32 sub_080041EC(int, int);
static bool32 sub_0808E950(void);
@@ -104,7 +104,7 @@ void sub_0808E818(Entity* this) {
this->field_0x68.HWORD = CheckGlobalFlag(EZERO_1ST) == 0 ? 0x400 : 0x100;
this->field_0x70.BYTES.byte0 = 4;
this->animationState = 2;
- var1 = gUnk_08133368[sub_0807A094(1) - 22] & 0xFFFFFF;
+ var1 = gUnk_08133368[GetPlayerPalette(TRUE) - 22] & 0xFFFFFF;
LoadPalettes(&gGlobalGfxAndPalettes[var1], 31, 1);
}
diff --git a/src/object/frozenOctorok.c b/src/object/frozenOctorok.c
index 5415125e..85fbb2c0 100644
--- a/src/object/frozenOctorok.c
+++ b/src/object/frozenOctorok.c
@@ -319,7 +319,7 @@ void FrozenOctorok_Action1SubAction6(FrozenOctorokEntity* this) {
super->subAction = 7;
}
if ((gRoomTransition.frameCount & 0xf) == 0) {
- SoundReq(SFX_163);
+ SoundReq(SFX_TOGGLE_DIVING);
}
}
diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c
index 225147a7..332a3ab4 100644
--- a/src/object/houseDoorExterior.c
+++ b/src/object/houseDoorExterior.c
@@ -179,7 +179,7 @@ void sub_0808692C(Entity* this) {
static u8 sub_08086954(Entity* this) {
if (sub_0800445C(this)) {
if (GetAnimationStateInRectRadius(this, 6, 20) >= 0 && gPlayerEntity.animationState == 0 &&
- (u16)gPlayerState.playerInput.field_0x90 == PLAYER_INPUT_UP && gPlayerState.jump_status == 0) {
+ (u16)gPlayerState.playerInput.heldInput == PLAYER_INPUT_UP && gPlayerState.jump_status == 0) {
this->timer--;
}
} else {
diff --git a/src/object/houseDoorInterior.c b/src/object/houseDoorInterior.c
index c8cc5334..50e8a7ba 100644
--- a/src/object/houseDoorInterior.c
+++ b/src/object/houseDoorInterior.c
@@ -92,7 +92,7 @@ void HouseDoorInterior_Action1(HouseDoorInteriorEntity* this) {
if (sub_0800445C(super) && this->unk7d == 0) {
ptr = gUnk_081227CC + super->type2;
if (GetAnimationStateInRectRadius(super, ptr->x, ptr->y) >= 0 &&
- ptr->animationState == gPlayerEntity.animationState && gPlayerState.playerInput.field_0x90 & ptr->unk2) {
+ ptr->animationState == gPlayerEntity.animationState && gPlayerState.playerInput.heldInput & ptr->unk2) {
--super->timer;
}
} else {
diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c
index 283969f8..e4629fa1 100644
--- a/src/object/itemForSale.c
+++ b/src/object/itemForSale.c
@@ -99,7 +99,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) {
super->interactType = 0;
super->subAction = 1;
sub_08078B48();
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.heldObject = 4;
gNewPlayerEntity.unk_74 = super;
gUnk_0200AF00.unk_2f = 2;
@@ -119,9 +119,9 @@ void ItemForSale_Action2(ItemForSaleEntity* this) {
} else {
ptr = sub_080784E4();
if (((*(int*)(ptr + 8) == 0) ||
- ((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.unk_2f = 7, (gPlayerState.playerInput.field_0x92 &
+ ((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.unk_2f = 7, (gPlayerState.playerInput.newInput &
(PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0)))) &&
- ((gPlayerState.playerInput.field_0x92 & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) {
+ ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) {
sub_080819B4(this);
}
}
diff --git a/src/object/lampParticle.c b/src/object/lampParticle.c
index 38f1ed64..85c73532 100644
--- a/src/object/lampParticle.c
+++ b/src/object/lampParticle.c
@@ -28,7 +28,7 @@ void LampParticle_Init(Entity* this) {
}
void LampParticle_Action1(Entity* this) {
- if (1 < IsItemEquipped(ITEM_LANTERN_ON)) {
+ if (IsItemEquipped(ITEM_LANTERN_ON) >= EQUIP_SLOT_NONE) {
DeleteThisEntity();
}
GetNextFrame(this);
diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c
index e03dd38f..88cf601a 100644
--- a/src/object/lilypadLarge.c
+++ b/src/object/lilypadLarge.c
@@ -570,7 +570,7 @@ void sub_08085E74(LilypadLargeEntity* this) {
if (gPlayerState.item != NULL) {
DeleteEntity(gPlayerState.item);
}
- ResetPlayerItem();
+ ResetActiveItems();
}
void sub_08085EFC(LilypadLargeEntity* this) {
diff --git a/src/object/macroPlayer.c b/src/object/macroPlayer.c
index 79921a39..075d749e 100644
--- a/src/object/macroPlayer.c
+++ b/src/object/macroPlayer.c
@@ -10,6 +10,7 @@
#include "functions.h"
#include "object.h"
#include "physics.h"
+#include "player.h"
typedef struct {
Entity base;
@@ -17,8 +18,6 @@ typedef struct {
u16 unk6a;
} MacroPlayerEntity;
-extern int sub_0807A094(int);
-
void MacroPlayer_Type0(MacroPlayerEntity*);
void MacroPlayer_Type1(MacroPlayerEntity*);
void MacroPlayer_Type0_Init(MacroPlayerEntity*);
@@ -118,7 +117,7 @@ void MacroPlayer_Type0_Init(MacroPlayerEntity* this) {
super->spriteRendering.b0 = 3;
SetAffineInfo(super, 4, 4, 0);
gUnk_02018EB0.unk_14 = super;
- ChangeObjPalette(super, sub_0807A094(0));
+ ChangeObjPalette(super, GetPlayerPalette(FALSE));
pEVar1 = CreateObject(PORTAL_FALLING_PLAYER, 1, 0);
if (pEVar1 != NULL) {
pEVar1->parent = super;
diff --git a/src/object/minecart.c b/src/object/minecart.c
index bb839de4..eba55180 100644
--- a/src/object/minecart.c
+++ b/src/object/minecart.c
@@ -12,7 +12,7 @@
typedef struct {
Entity base;
u8 filler[0x1C];
- struct_030010EC* minecartData;
+ MinecartData* minecartData;
} MinecartEntity;
extern void sub_08017744(Entity*);
@@ -39,7 +39,7 @@ void Minecart(Entity* this) {
}
void Minecart_Init(MinecartEntity* this) {
- struct_030010EC* unk = &gRoomTransition.minecart_data[super->timer];
+ MinecartData* unk = &gRoomTransition.minecart_data[super->timer];
this->minecartData = unk;
if ((gRoomControls.room != unk->room) || (gPlayerState.flags & PL_IN_MINECART) != 0) {
@@ -88,7 +88,7 @@ void Minecart_Action1(MinecartEntity* this) {
gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerEntity.speed = 0x100;
gPlayerEntity.flags &= ~PL_MINISH;
- ResetPlayerItem();
+ ResetActiveItems();
DeleteClones();
SoundReq(SFX_PLY_JUMP);
}
@@ -279,7 +279,7 @@ void Minecart_Action5(MinecartEntity* this) {
}
void Minecart_Action6(MinecartEntity* this) {
- struct_030010EC* minecartData;
+ MinecartData* minecartData;
if (gPlayerState.jump_status == 0) {
super->action = 1;
diff --git a/src/object/minishSizedEntrance.c b/src/object/minishSizedEntrance.c
index f8904c9c..c12192c2 100644
--- a/src/object/minishSizedEntrance.c
+++ b/src/object/minishSizedEntrance.c
@@ -46,7 +46,7 @@ void MinishSizedEntrance_Action1(Entity* this) {
}
}
if ((gPlayerState.flags & PL_MINISH) && EntityInRectRadius(this, &gPlayerEntity, 4, 4) &&
- (gPlayerEntity.z.HALF.HI == 0) && (((u16)gPlayerState.playerInput.field_0x90) & gUnk_0812225C[this->type2])) {
+ (gPlayerEntity.z.HALF.HI == 0) && (((u16)gPlayerState.playerInput.heldInput) & gUnk_0812225C[this->type2])) {
DoExitTransition(GetCurrentRoomProperty(this->timer));
}
}
diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c
index ad3afd84..eb1a2f1e 100644
--- a/src/object/octorokBossObject.c
+++ b/src/object/octorokBossObject.c
@@ -166,7 +166,7 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc",
this->child->parent = this->parent;
GET_HELPER(this->child) = GET_HELPER(this);
}
- this->type2 += 1;
+ this->type2++;
}
CopyPosition(GET_HELPER(this)->tailObjects[0], this);
return;
@@ -193,7 +193,7 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc",
this->parent->subAction = 0;
return;
}
- this->timer += 1;
+ this->timer++;
return;
case 2:
if (this->parent->type2 == 3) {
diff --git a/src/object/playerClone.c b/src/object/playerClone.c
index 3dd8b990..e898dcfe 100644
--- a/src/object/playerClone.c
+++ b/src/object/playerClone.c
@@ -169,7 +169,7 @@ void sub_08084B1C(PlayerCloneEntity* this) {
super->collisionFlags = gPlayerEntity.collisionFlags;
super->hurtType = gPlayerEntity.hurtType;
CopyPosition(super, super->child);
- if (gPlayerState.field_0x3[1] != 0) {
+ if (gPlayerState.attack_status != 0) {
super->child->damage = gPlayerState.item->damage;
super->child->frameIndex = gPlayerState.item->frameIndex;
super->child->spriteSettings.flipX = gPlayerState.item->spriteSettings.flipX;
diff --git a/src/object/pot.c b/src/object/pot.c
index 6c62da39..0e024f6f 100644
--- a/src/object/pot.c
+++ b/src/object/pot.c
@@ -121,7 +121,7 @@ void Pot_Action1(Entity* this) {
if (GetTileUnderEntity(this) == 13) {
CreateFx(this, FX_FALL_DOWN, 0);
} else if (tileType == 0x4005) {
- gPlayerState.field_0xab = 4;
+ gPlayerState.lastSwordMove = SWORD_MOVE_BREAK_POT;
SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer);
}
sub_08082850(this, NULL);
diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c
index c03f3444..22982728 100644
--- a/src/object/pullableMushroom.c
+++ b/src/object/pullableMushroom.c
@@ -222,7 +222,7 @@ void sub_0808AEB0(PullableMushroomEntity* this) {
u32 uVar1;
if (super->timer != 0) {
uVar1 = sub_0808B1F0(this, super->child);
- if ((gPlayerState.playerInput.field_0x90 & gUnk_081211E4[super->animationState]) != 0) {
+ if ((gPlayerState.playerInput.heldInput & gUnk_081211E4[super->animationState]) != 0) {
GetNextFrame(super);
if (uVar1 < 0x40) {
sub_080044AE(&gPlayerEntity, 0x40, super->direction);
@@ -247,7 +247,7 @@ void sub_0808AEB0(PullableMushroomEntity* this) {
this->unk_7c = 1;
super->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1);
super->direction = (super->animationState << 3);
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX;
InitializeAnimation(super, super->animationState + 5);
if (sub_0808B21C(this, 0)) {
@@ -291,7 +291,7 @@ void sub_0808B05C(PullableMushroomEntity* this) {
super->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1);
super->direction = super->animationState << 3;
super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
InitializeAnimation(super, super->animationState + 5);
if (sub_0808B21C(this, 1)) {
sub_0808B168((PullableMushroomEntity*)super->child, 1);
diff --git a/src/object/pushableRock.c b/src/object/pushableRock.c
index 56b2e10c..29b3fdd8 100644
--- a/src/object/pushableRock.c
+++ b/src/object/pushableRock.c
@@ -32,7 +32,7 @@ void PushableRock(PushableRockEntity* this) {
void PushableRock_Init(PushableRockEntity* this) {
super->spriteSettings.draw = 1;
- super->action += 1;
+ super->action++;
super->spriteRendering.b3 = 2;
super->spritePriority.b0 = 4;
super->spritePriority.b1 = 3;
diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c
index 54a5bd7e..edd3aac5 100644
--- a/src/object/smallIceBlock.c
+++ b/src/object/smallIceBlock.c
@@ -148,7 +148,7 @@ void SmallIceBlock_Action3(SmallIceBlockEntity* this) {
}
super->action = 4;
super->timer = 60;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
}
void SmallIceBlock_Action4(SmallIceBlockEntity* this) {
diff --git a/src/object/smokeParticle.c b/src/object/smokeParticle.c
index 8cca7eff..de97206b 100644
--- a/src/object/smokeParticle.c
+++ b/src/object/smokeParticle.c
@@ -53,7 +53,7 @@ void SmokeParticle_Action1(Entity* this) {
if (this->frame < 5) {
this->hitbox = (Hitbox*)gUnk_08120A54[this->frame];
} else {
- this->flags &= 0x7f;
+ this->flags &= ~0x80;
}
}
}
diff --git a/src/object/swordParticle.c b/src/object/swordParticle.c
index fbdb0e52..3e197a29 100644
--- a/src/object/swordParticle.c
+++ b/src/object/swordParticle.c
@@ -70,7 +70,7 @@ void SwordParticle_Action1(SwordParticleEntity* this) {
u32 tmp2;
if (super->type2 != 0) {
- if ((gPlayerState.field_0x1f[2] == 0) || ((gPlayerState.field_0x3[1] & 0x80) != 0)) {
+ if ((gPlayerState.field_0x1f[2] == 0) || ((gPlayerState.attack_status & 0x80) != 0)) {
DeleteThisEntity();
}
if (gPlayerState.field_0x1f[2] >= 0x50) {
@@ -85,7 +85,7 @@ void SwordParticle_Action1(SwordParticleEntity* this) {
DeleteThisEntity();
}
} else {
- if (gPlayerState.field_0x3[1] == 0) {
+ if (gPlayerState.attack_status == 0) {
DeleteThisEntity();
}
if ((gPlayerState.sword_state & 1) != 0) {
diff --git a/src/object/thunderbold.c b/src/object/thunderbold.c
index 6128b74d..3b3f7fa3 100644
--- a/src/object/thunderbold.c
+++ b/src/object/thunderbold.c
@@ -42,7 +42,7 @@ void Thunderbold(ThunderboldEntity* this) {
void Thunderbold_Init(ThunderboldEntity* this) {
const struct_08122950* ptr;
super->action = 1;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
super->spriteSettings.draw = 1;
if (super->collisionLayer == 0) {
ResolveCollisionLayer(super);
diff --git a/src/object/unusedSkull.c b/src/object/unusedSkull.c
index 30c6ec1f..c6a2e1f5 100644
--- a/src/object/unusedSkull.c
+++ b/src/object/unusedSkull.c
@@ -53,7 +53,7 @@ void UnusedSkull_Init(UnusedSkullEntity* this) {
void UnusedSkull_Action1(UnusedSkullEntity* this) {
if (super->contactFlags == 0x9c) {
super->action = 2;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
CreateFx(super, FX_ICE, 0);
EnqueueSFX(SFX_10D);
}
diff --git a/src/objectDefinitions.c b/src/objectDefinitions.c
index 4a0186a1..29c5e352 100644
--- a/src/objectDefinitions.c
+++ b/src/objectDefinitions.c
@@ -6,94 +6,94 @@
const Hitbox* const gObjectHitboxes[] = { NULL, &gHitbox_0, &gHitbox_30, &gHitbox_2, &gHitbox_3 };
const ObjectDefinition gObjectDefinition_F[] = {
- { { 1, 0, 0, 0, 59, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_FALL_DOWN
- { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_EXPLOSION
- { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_DEATH
- { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BUSH
- { { 1, 0, 0, 0, 81, 2, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ROCK
- { { 1, 0, 0, 0, 236, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_POT_SHATTER
- { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_6
- { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SPARKLE
- { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_8
- { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_9
- { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_A
- { { 1, 0, 0, 0, 72, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_WATER_SPLASH
- { { 1, 0, 0, 0, 78, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_LAVA_SPLASH
- { { 1, 0, 0, 0, 85, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ICE
- { { 1, 0, 0, 0, 18, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ROCK_HUGE
- { { 1, 0, 0, 0, 81, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ROCK_SMALL
- { { 1, 0, 0, 0, 93, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_REFLECT
- { { 1, 0, 0, 0, 89, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_DASH
- { { 1, 0, 0, 0, 0, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BLUE_SPARKLE
- { { 1, 0, 0, 0, 228, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_RED_BUSH
- { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SPARKLE2
- { { 1, 0, 0, 0, 81, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ROCK2
- { { 1, 0, 0, 0, 176, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_FIRE
- { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT
- { { 1, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }, // FX_18
- { { 1, 0, 0, 0, 0, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SWORD_MAGIC
- { { 1, 0, 0, 0, 64, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_LIGHTNING
- { { 1, 0, 0, 0, 4, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_LIGHTNING_STRIKE
- { { 1, 0, 0, 0, 32, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_STARS
- { { 1, 0, 0, 0, 32, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_STARS_STRIKE
- { { 1, 0, 0, 0, 32, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_STARS_STRIKE2
- { { 1, 0, 0, 0, 28, 0, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_REFLECT2
- { { 1, 0, 0, 0, 20, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_RIPPLE
- { { 1, 0, 0, 0, 30, 0, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_RIPPLE_LARGE
- { { 1, 0, 0, 0, 154, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BROWN_SMOKE
- { { 1, 0, 0, 0, 154, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BROWN_SMOKE_LARGE
- { { 1, 0, 0, 0, 154, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BROWN_SMOKE2
- { { 1, 0, 0, 0, 243, 0, 0 }, { 1, 0, 0, 0, 163, 0, 0 } }, // FX_SWEAT
- { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_26
- { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, 163, 0, 0 } }, // FX_27
- { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SLOW_EXPLOSION
- { { 1, 0, 0, 0, 113, 0, 0 }, { 71, 0, 0, 0, 163, 0, 0 } }, // FX_CONFETTI
- { { 1, 0, 0, 0, 113, 0, 0 }, { 71, 0, 0, 0, 163, 0, 0 } }, // FX_CONFETTI_LARGE
- { { 1, 0, 0, 0, 72, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GREEN_SPLASH2
- { { 1, 0, 0, 0, 93, 2, 0 }, { 1, 0, 0, 0, 163, 0, 0 } }, // FX_REFLECT3
- { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, 163, 0, 0 } }, // FX_SIGN
- { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SLOW_SMOKE2
- { { 1, 0, 0, 0, 89, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SLOW_SMOKE_SMALL
- { { 1, 0, 0, 0, 57, 2, 0 }, { 171, 0, 0, 0, 163, 0, 0 } }, // FX_SPARKLE_SECRET
- { { 1, 0, 0, 0, 205, 2, 0 }, { 3, 0, 0, 0, 163, 0, 0 } }, // FX_MAILBOX_UNUSED
- { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, 163, 0, 0 } }, // FX_32
- { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, 163, 0, 0 } }, // FX_33
- { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, 163, 0, 0 } }, // FX_34
- { { 1, 0, 0, 0, 96, 2, 0 }, { 3, 0, 0, 0, 162, 0, 1 } }, // FX_BIG_EXPLOSION
- { { 1, 0, 0, 0, 78, 2, 0 }, { 0, 0, 0, 0, 163, 0, 1 } }, // FX_LAVA_SPLASH_HUGE
- { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT2
- { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BUSH_CUT2
- { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BUSH_CUT3
- { { 1, 0, 0, 0, 29, 2, 0 }, { 3, 0, 0, 0, 163, 0, 0 } }, // FX_EGG
- { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, 163, 0, 0 } }, // FX_WOOD
- { { 1, 0, 0, 0, 366, 0, 0 }, { 0, 0, 0, 0, 163, 0, 0 } }, // FX_BONE
- { { 1, 0, 0, 0, 379, 0, 0 }, { 4, 0, 0, 0, 163, 0, 1 } }, // FX_STARS2
- { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT3
- { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT4
- { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT5
- { { 1, 0, 0, 0, 28, 0, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_REFLECT4
- { { 1, 0, 0, 0, 372, 0, 0 }, { 0, 0, 0, 0, 163, 0, 1 } }, // FX_STEAM_EFC
- { { 1, 0, 0, 0, 96, 2, 0 }, { 3, 0, 0, 0, 162, 0, 1 } }, // FX_BIG_EXPLOSION2
- { { 1, 0, 0, 0, 446, 0, 0 }, { 184, 0, 0, 0, 163, 0, 1 } }, // FX_WHITE_SPLASH
- { { 1, 0, 0, 0, 85, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_WHITE_ROCK
- { { 1, 0, 0, 0, 452, 0, 0 }, { 0, 0, 0, 0, 163, 0, 1 } }, // FX_GIANT_EXPLOSION
- { { 1, 0, 0, 0, 452, 0, 0 }, { 0, 0, 0, 0, 163, 0, 1 } }, // FX_GIANT_EXPLOSION2
- { { 1, 0, 0, 0, 452, 0, 0 }, { 0, 0, 0, 0, 163, 0, 1 } }, // FX_GIANT_EXPLOSION3
- { { 1, 0, 0, 0, 457, 0, 0 }, { 285, 0, 0, 0, 163, 0, 1 } }, // FX_GREEN_ORB
- { { 1, 0, 0, 0, 458, 0, 0 }, { 285, 0, 0, 0, 163, 0, 1 } }, // FX_GREEN_ORB_SLOW
- { { 1, 0, 0, 0, 459, 0, 0 }, { 3, 0, 0, 0, 163, 0, 1 } }, // FX_WHITE_AURA
- { { 1, 0, 0, 0, 29, 2, 0 }, { 4, 0, 0, 0, 163, 0, 0 } }, // FX_WOOD2
- { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SPARKLE3
- { { 1, 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 163, 0, 1 } }, // FX_MAGIC_STORM
- { { 1, 0, 0, 0, 0, 0, 0 }, { 4, 0, 0, 0, 163, 0, 1 } }, // FX_BLUE_EFC
- { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, 163, 0, 1 } }, // FX_REFLECT5
- { { 1, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 163, 0, 1 } }, // FX_GIANT_EXPLOSION4
- { { 1, 0, 0, 0, 78, 2, 0 }, { 382, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GREEN_SPLASH
- { { 1, 0, 0, 0, 154, 2, 0 }, { 319, 0, 0, 0, 162, 0, 1 } }, // FX_BLUE_PUFF
- { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, 162, 0, 1 } }, // FX_WHITE_PUFF
- { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_AURA_BASE
- { { 1, 0, 0, 0, 217, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_READ_AURA
- { { 1, 0, 0, 0, 217, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_BLUE_AURA
+ { { 1, 0, 0, 0, 59, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_FALL_DOWN
+ { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_EXPLOSION
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_DEATH
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BUSH
+ { { 1, 0, 0, 0, 81, 2, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ROCK
+ { { 1, 0, 0, 0, 236, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_POT_SHATTER
+ { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_6
+ { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SPARKLE
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_8
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_9
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_A
+ { { 1, 0, 0, 0, 72, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_WATER_SPLASH
+ { { 1, 0, 0, 0, 78, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_LAVA_SPLASH
+ { { 1, 0, 0, 0, 85, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ICE
+ { { 1, 0, 0, 0, 18, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ROCK_HUGE
+ { { 1, 0, 0, 0, 81, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ROCK_SMALL
+ { { 1, 0, 0, 0, 93, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_REFLECT
+ { { 1, 0, 0, 0, 89, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_DASH
+ { { 1, 0, 0, 0, 0, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BLUE_SPARKLE
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_RED_BUSH
+ { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SPARKLE2
+ { { 1, 0, 0, 0, 81, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_ROCK2
+ { { 1, 0, 0, 0, 176, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_FIRE
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }, // FX_18
+ { { 1, 0, 0, 0, 0, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SWORD_MAGIC
+ { { 1, 0, 0, 0, 64, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_LIGHTNING
+ { { 1, 0, 0, 0, 4, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_LIGHTNING_STRIKE
+ { { 1, 0, 0, 0, 32, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_STARS
+ { { 1, 0, 0, 0, 32, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_STARS_STRIKE
+ { { 1, 0, 0, 0, 32, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_STARS_STRIKE2
+ { { 1, 0, 0, 0, 28, 0, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_REFLECT2
+ { { 1, 0, 0, 0, 20, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_RIPPLE
+ { { 1, 0, 0, 0, 30, 0, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_RIPPLE_LARGE
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BROWN_SMOKE
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BROWN_SMOKE_LARGE
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BROWN_SMOKE2
+ { { 1, 0, 0, 0, 243, 0, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_SWEAT
+ { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_26
+ { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_27
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SLOW_EXPLOSION
+ { { 1, 0, 0, 0, 113, 0, 0 }, { 71, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_CONFETTI
+ { { 1, 0, 0, 0, 113, 0, 0 }, { 71, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_CONFETTI_LARGE
+ { { 1, 0, 0, 0, 72, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GREEN_SPLASH2
+ { { 1, 0, 0, 0, 93, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_REFLECT3
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_SIGN
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SLOW_SMOKE2
+ { { 1, 0, 0, 0, 89, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SLOW_SMOKE_SMALL
+ { { 1, 0, 0, 0, 57, 2, 0 }, { 171, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_SPARKLE_SECRET
+ { { 1, 0, 0, 0, 205, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_MAILBOX_UNUSED
+ { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_32
+ { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_33
+ { { 1, 0, 0, 0, 96, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_34
+ { { 1, 0, 0, 0, 96, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 1 } }, // FX_BIG_EXPLOSION
+ { { 1, 0, 0, 0, 78, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_LAVA_SPLASH_HUGE
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT2
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BUSH_CUT2
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_BUSH_CUT3
+ { { 1, 0, 0, 0, 29, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_EGG
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_WOOD
+ { { 1, 0, 0, 0, 366, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_BONE
+ { { 1, 0, 0, 0, 379, 0, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_STARS2
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT3
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT4
+ { { 1, 0, 0, 0, 228, 2, 0 }, { 2, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GRASS_CUT5
+ { { 1, 0, 0, 0, 28, 0, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_REFLECT4
+ { { 1, 0, 0, 0, 372, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_STEAM_EFC
+ { { 1, 0, 0, 0, 96, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 1 } }, // FX_BIG_EXPLOSION2
+ { { 1, 0, 0, 0, 446, 0, 0 }, { 184, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_WHITE_SPLASH
+ { { 1, 0, 0, 0, 85, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_WHITE_ROCK
+ { { 1, 0, 0, 0, 452, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_GIANT_EXPLOSION
+ { { 1, 0, 0, 0, 452, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_GIANT_EXPLOSION2
+ { { 1, 0, 0, 0, 452, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_GIANT_EXPLOSION3
+ { { 1, 0, 0, 0, 457, 0, 0 }, { 285, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_GREEN_ORB
+ { { 1, 0, 0, 0, 458, 0, 0 }, { 285, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_GREEN_ORB_SLOW
+ { { 1, 0, 0, 0, 459, 0, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_WHITE_AURA
+ { { 1, 0, 0, 0, 29, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 0 } }, // FX_WOOD2
+ { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_SPARKLE3
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_MAGIC_STORM
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_BLUE_EFC
+ { { 1, 0, 0, 0, 60, 2, 0 }, { 4, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_REFLECT5
+ { { 1, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_GIANT_EXPLOSION4
+ { { 1, 0, 0, 0, 78, 2, 0 }, { 382, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_GREEN_SPLASH
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 319, 0, 0, 0, SPRITE_SPECIALFX, 0, 1 } }, // FX_BLUE_PUFF
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 1 } }, // FX_WHITE_PUFF
+ { { 1, 0, 0, 0, 154, 2, 0 }, { 3, 0, 0, 0, SPRITE_SPECIALFX, 0, 0 } }, // FX_AURA_BASE
+ { { 1, 0, 0, 0, 217, 2, 0 }, { 0, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_READ_AURA
+ { { 1, 0, 0, 0, 217, 2, 0 }, { 1, 0, 0, 0, SPRITE_SPECIALFX_1, 0, 1 } }, // FX_BLUE_AURA
};
#ifdef EU
const ObjectDefinition gObjectDefinition_7[] = {
diff --git a/src/objectUtils.c b/src/objectUtils.c
index 7b748c6d..a3dc0132 100644
--- a/src/objectUtils.c
+++ b/src/objectUtils.c
@@ -13,10 +13,10 @@ extern const ObjectDefinition gObjectDefinitions[];
static Entity* CreateSpeechBubble(Entity*, u32, s32, s32);
-Entity* sub_080A276C(Entity* parent, u32 type, u32 type2) {
+Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) {
Entity* e = CreateItemGetEntity();
if (e != NULL) {
- e->id = OBJECT_C1;
+ e->id = LINK_ANIMATION;
e->kind = OBJECT;
e->type = type;
e->type2 = type2;
diff --git a/src/physics.c b/src/physics.c
index cd09c05b..dcc2eaa3 100644
--- a/src/physics.c
+++ b/src/physics.c
@@ -83,7 +83,7 @@ bool32 sub_0806F3E4(Entity* ent) {
ent->subAction = 3;
gNewPlayerEntity.unk_70 = ent;
gPlayerState.field_0x1c = 7;
- item = CreatePlayerItem(PLAYER_ITEM_11, 0, 0, 0);
+ item = CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0);
if (item != NULL) {
item->child = ent;
ent->parent = item;
@@ -247,10 +247,10 @@ bool32 sub_0806F8DC(Entity* ent) {
u32 sub_0806F948(Entity* ent) {
u32 v1;
- if (gPlayerState.field_0xd == 0xFF)
+ if (gPlayerState.direction == 0xFF)
return ent->animationState;
- v1 = gPlayerState.field_0xd / 4;
+ v1 = gPlayerState.direction / 4;
if ((v1 & 1) && !(((v1 + 1) - ent->animationState) & 4)) {
return ent->animationState;
} else {
diff --git a/src/player.c b/src/player.c
index c5299bc1..242a5322 100644
--- a/src/player.c
+++ b/src/player.c
@@ -5,24 +5,24 @@
* @brief Player entity
*/
-#include "global.h"
-#include "collision.h"
+#include "area.h"
#include "asm.h"
-#include "sound.h"
-#include "entity.h"
-#include "player.h"
-#include "message.h"
+#include "collision.h"
#include "common.h"
-#include "area.h"
-#include "item.h"
-#include "save.h"
-#include "object.h"
+#include "entity.h"
#include "functions.h"
-#include "hitbox.h"
#include "game.h"
-#include "screen.h"
+#include "global.h"
+#include "hitbox.h"
+#include "item.h"
#include "main.h"
+#include "message.h"
+#include "object.h"
+#include "player.h"
#include "playeritem.h"
+#include "save.h"
+#include "screen.h"
+#include "sound.h"
#define GRAVITY_RATE Q_8_8(32)
#define SLOPE_SPEED_MODIFIER 0x50
@@ -340,9 +340,9 @@ void DoPlayerAction(Entity* this) {
}
static void PlayerInit(Entity* this) {
- u32 equip_status;
+ u32 equipSlot;
- gPlayerState.field_0x0[0] = 0xff;
+ gPlayerState.prevAnim = 0xff;
gPlayerState.startPosX = gPlayerEntity.x.HALF.HI;
gPlayerState.startPosY = gPlayerEntity.y.HALF.HI;
COLLISION_ON(this);
@@ -364,9 +364,9 @@ static void PlayerInit(Entity* this) {
ResolveCollisionLayer(this);
}
- equip_status = IsItemEquipped(ITEM_LANTERN_ON);
- if (equip_status != 2) {
- sub_08077728(equip_status);
+ equipSlot = IsItemEquipped(ITEM_LANTERN_ON);
+ if (equipSlot != EQUIP_SLOT_NONE) {
+ CreateItemEquippedAtSlot(equipSlot);
}
DeleteClones();
UpdatePlayerSkills();
@@ -379,7 +379,7 @@ static void PlayerInit(Entity* this) {
gPlayerState.swim_state = 1;
ResolvePlayerAnimation();
gPlayerState.framestate = PL_STATE_SWIM;
- sub_0807ACCC(this);
+ PlayerSwimming(this);
ent = FindEntity(OBJECT, SPECIAL_FX, 0x6, FX_WATER_SPLASH, 0x0);
if (ent != NULL) {
DeleteEntity(ent);
@@ -401,12 +401,11 @@ static void PlayerNormal(Entity* this) {
else
gPlayerState.animation = 604;
sub_0806F948(&gPlayerEntity);
- ResetPlayerItem();
- sub_08077698(this);
+ ResetActiveItems();
+ UpdateActiveItems(this);
return;
}
if (gPlayerState.flags & PL_IN_MINECART) {
- u32 x;
this->hurtType = 30;
gPlayerState.framestate = PL_STATE_C;
sub_08070BEC(this, this->speed == 0 ? 1 : 0);
@@ -422,7 +421,7 @@ static void PlayerNormal(Entity* this) {
return;
}
if (!gPlayerState.swim_state && (gPlayerState.jump_status & 0xC0) == 0) {
- if (gPlayerState.field_0x3[0] || gPlayerState.field_0x1f[2]) {
+ if (gPlayerState.shield_status || gPlayerState.field_0x1f[2]) {
this->speed = SHIELDING_SPEED;
} else {
if (gPlayerState.sword_state) {
@@ -446,7 +445,7 @@ static void PlayerNormal(Entity* this) {
if (gPlayerState.jump_status == 0 && (gPlayerState.flags & PL_BURNING) == 0) {
if (this->knockbackDuration == 0 && sub_080782C0()) {
if (gRoomVars.shopItemType == 0) {
- ResetPlayerItem();
+ ResetActiveItems();
}
if ((gPlayerState.flags & (PL_USE_OCARINA | PL_FLAGS2)) == 0) {
UpdateFloorType();
@@ -456,7 +455,7 @@ static void PlayerNormal(Entity* this) {
}
if (((gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_USE_PORTAL | PL_CAPTURED | PL_FALLING | PL_BURNING |
PL_IN_MINECART | PL_ROLLING)) |
- gPlayerState.field_0xaa) == 0) {
+ gPlayerState.attachedBeetleCount) == 0) {
switch (UpdatePlayerCollision()) {
case 0:
gPlayerState.pushedObject ^= 0x80;
@@ -486,7 +485,7 @@ static void PlayerNormal(Entity* this) {
if (sub_0807AC54(this)) {
return;
}
- sub_08077698(this);
+ UpdateActiveItems(this);
if (CheckQueuedAction())
return;
@@ -511,7 +510,7 @@ static void PlayerNormal(Entity* this) {
}
}
UpdatePlayerMovement();
- if ((this->frame & 2) == 0 && !gPlayerState.field_0x3[1])
+ if ((this->frame & 2) == 0 && !gPlayerState.attack_status)
UpdateAnimationSingleFrame(this);
return;
}
@@ -520,7 +519,7 @@ static void PlayerNormal(Entity* this) {
if (gPlayerState.swim_state) {
gPlayerState.framestate = PL_STATE_SWIM;
- sub_0807ACCC(this);
+ PlayerSwimming(this);
} else {
if ((gPlayerState.flags & PL_CONVEYOR_PUSHED) == 0)
this->spritePriority.b1 = 1;
@@ -536,10 +535,10 @@ static void PlayerNormal(Entity* this) {
}
}
if ((gPlayerState.sword_state & 0x10) == 0) {
- this->direction = gPlayerState.field_0xd;
+ this->direction = gPlayerState.direction;
if (gPlayerState.flags & PL_BURNING) {
this->speed = BURNING_SPEED;
- if ((gPlayerState.field_0xd & 0x80) != 0)
+ if ((gPlayerState.direction & 0x80) != 0)
this->direction = 4 * (this->animationState & 0xE);
DeleteClones();
}
@@ -582,7 +581,7 @@ static void PlayerFall(Entity* this) {
PlayerFallUpdate,
};
- gPlayerState.field_0xd = 0xFF;
+ gPlayerState.direction = 0xFF;
gPlayerState.pushedObject = 0x80;
gPlayerState.framestate = PL_STATE_FALL;
@@ -607,7 +606,7 @@ static void PlayerFallInit(Entity* this) {
this->subAction++;
COLLISION_OFF(this);
this->spritePriority.b1 = 0;
- ResetPlayerItem();
+ ResetActiveItems();
DeleteClones();
SoundReq(SFX_PLY_VO7);
SoundReq(SFX_FALL_HOLE);
@@ -660,7 +659,7 @@ static void PlayerBounceInit(Entity* this) {
gPlayerState.jump_status = 0x80;
SoundReq(SFX_14C);
- ResetPlayerItem();
+ ResetActiveItems();
ResetPlayerVelocity();
}
@@ -798,7 +797,7 @@ static void PlayerItemGetInit(Entity* this) {
}
this->subAction = 1;
- ResetPlayerItem();
+ ResetActiveItems();
ResetPlayerVelocity();
}
@@ -849,7 +848,7 @@ static void PlayerJumpInit(Entity* this) {
if ((gPlayerState.heldObject | gPlayerState.sword_state) == 0) {
if ((gPlayerState.flags & PL_MINISH) == 0) {
- ResetPlayerItem();
+ ResetActiveItems();
if (gPlayerState.flags & PL_NO_CAP) {
gPlayerState.animation = 0x420;
} else {
@@ -970,7 +969,7 @@ static void PlayerDrownInit(Entity* this) {
else
gPlayerState.animation = 0x44c;
}
- ResetPlayerItem();
+ ResetActiveItems();
}
static void sub_080712F0(Entity* this) {
@@ -1073,12 +1072,12 @@ static void PortalStandUpdate(Entity* this) {
break;
}
- if ((gPlayerState.field_0xd & 0x84) == 0) {
- if (this->direction != gPlayerState.field_0xd) {
+ if ((gPlayerState.direction & 0x84) == 0) {
+ if (this->direction != gPlayerState.direction) {
this->timer = 8;
}
if (this->timer-- == 0) {
- this->direction = gPlayerState.field_0xd;
+ this->direction = gPlayerState.direction;
this->animationState = Direction8ToAnimationState(this->direction);
this->zVelocity = Q_16_16(2.0);
this->speed = JUMP_SPEED_FWD;
@@ -1089,7 +1088,7 @@ static void PortalStandUpdate(Entity* this) {
gPlayerState.flags &= ~PL_USE_PORTAL;
return;
}
- this->direction = gPlayerState.field_0xd;
+ this->direction = gPlayerState.direction;
} else {
this->timer = 8;
}
@@ -1100,7 +1099,7 @@ static void PortalStandUpdate(Entity* this) {
return;
}
} else {
- sub_08077698(this);
+ UpdateActiveItems(this);
}
ResolvePlayerAnimation();
}
@@ -1285,8 +1284,8 @@ static void PlayerTalkEzlo(Entity* this) {
}
static void PlayerTalkEzlo_Init(Entity* this) {
- ResetPlayerItem();
- gUnk_03000B80[3].field_0xf = 0;
+ ResetActiveItems();
+ gActiveItems[ACTIVE_ITEM_LANTERN].animPriority = 0;
this->iframes = 0;
gPriorityHandler.sys_priority = PRIO_PLAYER_EVENT;
this->updatePriority = PRIO_PLAYER_EVENT;
@@ -1522,7 +1521,7 @@ static void PlayerMinishDieInit(Entity* this) {
gPlayerState.jump_status = 0;
gPlayerState.pushedObject = 0;
sub_0800451C(this);
- ResetPlayerItem();
+ ResetActiveItems();
SoundReq(SFX_PLY_DIE);
}
@@ -1656,7 +1655,7 @@ static void PlayerEmptyBottle(Entity* this) {
static void PlayerEmptyBottleInit(Entity* this) {
Entity* ent;
- ResetPlayerItem();
+ ResetActiveItems();
ent = CreatePlayerItemWithParent((ItemBehavior*)this, PLAYER_ITEM_BOTTLE);
if (ent != NULL) {
ent->field_0x68.HALF.LO = gPlayerState.field_0x38;
@@ -1755,7 +1754,7 @@ static void sub_08072064(Entity* this) {
COLLISION_OFF(this);
this->timer = gPlayerState.field_0x3a;
gPlayerState.animation = gPlayerState.field_0x38 | (gPlayerState.field_0x39 << 8);
- ResetPlayerItem();
+ ResetActiveItems();
}
static void sub_08072098(Entity* this) {
@@ -1799,7 +1798,7 @@ static void sub_08072100(Entity* this) {
} else {
gPlayerState.animation = 0x104;
}
- ResetPlayerItem();
+ ResetActiveItems();
sub_08072168(this);
}
@@ -1814,7 +1813,7 @@ static void sub_08072168(Entity* this) {
} else {
UpdatePlayerMovement();
}
- gPlayerState.field_0xd = this->direction;
+ gPlayerState.direction = this->direction;
UpdatePlayerCollision();
if (this->timer-- == 0) {
this->knockbackDuration = 0;
@@ -1895,7 +1894,7 @@ static void PlayerLavaInit(Entity* this) {
this->knockbackDuration = 10;
}
gPlayerState.flags |= (PL_BURNING | PL_BUSY);
- ResetPlayerItem();
+ ResetActiveItems();
SoundReq(SFX_124);
SoundReq(SFX_PLY_VO6);
}
@@ -1978,7 +1977,7 @@ static void sub_080724DC(Entity* this) {
DeleteClones();
if (GetTileUnderEntity(this) != 0x29) {
if ((gPlayerState.remainingDiveTime == 0) && (gPlayerState.swim_state != 0)) {
- sub_0807AE20(this);
+ PlayerUpdateSwimming(this);
}
if (gRoomControls.reload_flags == 0) {
this->updatePriority = this->updatePriorityPrev;
@@ -2002,7 +2001,7 @@ static void sub_080724DC(Entity* this) {
static void sub_0807258C(Entity* this) {
if (gRoomControls.reload_flags == 0) {
- if (sub_0807A894(this) == 0x29) {
+ if (GetCollisionTileInFront(this) == 0x29) {
UpdatePlayerMovement();
if (sub_080797C4() != 0) {
gPlayerState.startPosX = gPlayerEntity.x.HALF.HI;
@@ -2020,7 +2019,7 @@ static void sub_0807258C(Entity* this) {
}
}
if ((gPlayerState.remainingDiveTime == 0) && (gPlayerState.swim_state != 0)) {
- sub_0807AE20(this);
+ PlayerUpdateSwimming(this);
}
}
@@ -2043,7 +2042,7 @@ static void PlayerRollInit(Entity* this) {
}
this->subAction = 1;
this->timer = 0;
- ResetPlayerItem();
+ ResetActiveItems();
temp = gPlayerState.flags;
if (gPlayerState.flags & PL_MINISH) {
this->spritePriority.b1 = 0;
@@ -2132,9 +2131,9 @@ static void PlayerRollUpdate(Entity* this) {
this->hurtType = 0;
}
if (this->frame & 0x40) {
- sub_08077698(this);
+ UpdateActiveItems(this);
}
- if ((this->frame & ANIM_DONE) || (gPlayerState.field_0x3[1] != 0)) {
+ if ((this->frame & ANIM_DONE) || (gPlayerState.attack_status != 0)) {
ResetPlayerAnimationAndAction();
}
if (this->frame & ANIM_DONE) {
@@ -2195,7 +2194,7 @@ static void PlayerInHoleInit(Entity* this) {
}
}
SetTile(0x4070, COORD_TO_TILE(this), this->collisionLayer);
- ResetPlayerItem();
+ ResetActiveItems();
PlayerInHoleUpdate(this);
SoundReq(SFX_81);
}
@@ -2223,11 +2222,11 @@ static void PlayerInHoleUpdate(Entity* this) {
}
static void sub_08072ACC(Entity* this) {
- if (gPlayerState.field_0xd == 0xff) {
+ if (gPlayerState.direction == 0xff) {
this->subtimer = 0;
} else if (this->subtimer > 7) {
COLLISION_ON(this);
- this->direction = gPlayerState.field_0xd;
+ this->direction = gPlayerState.direction;
this->zVelocity = JUMP_SPEED_HOLE_Z;
this->speed = JUMP_SPEED_HOLE_FWD;
this->spritePriority.b0 = 4;
@@ -2236,7 +2235,7 @@ static void sub_08072ACC(Entity* this) {
PlayerSetNormalAndCollide();
RestorePrevTileEntity(COORD_TO_TILE(this), this->collisionLayer);
} else {
- this->animationState = Direction8ToAnimationState(gPlayerState.field_0xd);
+ this->animationState = Direction8ToAnimationState(gPlayerState.direction);
this->subtimer++;
}
}
@@ -2335,7 +2334,7 @@ static void sub_08072CFC(Entity* this) {
gPlayerState.animation = 0x810;
this->timer = 5;
this->subtimer = 0;
- ResetPlayerItem();
+ ResetActiveItems();
}
static const u16 sTiles[] = {
@@ -2471,10 +2470,10 @@ static void sub_08072F94(Entity* this) {
case SURFACE_CLIMB_WALL:
case SURFACE_2C:
this->spritePriority.b1 = 0;
- bVar1 = gPlayerState.field_0xd;
- if ((gPlayerState.field_0xd & 0x80) == 0) {
- this->direction = gPlayerState.field_0xd;
- if ((gPlayerState.field_0xd == 8) || (gPlayerState.field_0xd == 0x18)) {
+ bVar1 = gPlayerState.direction;
+ if ((gPlayerState.direction & 0x80) == 0) {
+ this->direction = gPlayerState.direction;
+ if ((gPlayerState.direction == 8) || (gPlayerState.direction == 0x18)) {
if (gPlayerState.floor_type == SURFACE_LADDER) {
return;
}
@@ -2613,7 +2612,7 @@ static void sub_080731D8(Entity* this) {
}
gRoomControls.camera_target = NULL;
DeleteClones();
- ResetPlayerItem();
+ ResetActiveItems();
}
static void sub_080732D0(Entity* this) {
@@ -2714,7 +2713,7 @@ static void sub_08073468(Entity* this) {
gPlayerState.flags |= PL_PARACHUTE;
CreateObjectWithParent(this, EZLO_CAP_FLYING, 0, 0);
}
- ResetPlayerItem();
+ ResetActiveItems();
if (this->zVelocity > 0 || gPlayerState.field_0x38 == 1)
COLLISION_OFF(this);
}
@@ -2749,7 +2748,7 @@ static void sub_08073504(Entity* this) {
static void sub_08073584(Entity* this) {
u32 state, dir, idx;
- if ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_80) || this->iframes > 0 || gPlayerState.field_0x3c ||
+ if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_80) || this->iframes > 0 || gPlayerState.field_0x3c ||
(gPlayerState.flags & PL_PARACHUTE) == 0) {
gPlayerState.jump_status |= 0x40;
PlayerSetNormalAndCollide();
@@ -2771,9 +2770,9 @@ static void sub_08073584(Entity* this) {
else
this->speed = 0x80;
- if ((gPlayerState.field_0xd & 0x80) == 0) {
- if (this->direction != gPlayerState.field_0xd) {
- if (((this->direction - gPlayerState.field_0xd) & 0x1F) < 0x10)
+ if ((gPlayerState.direction & 0x80) == 0) {
+ if (this->direction != gPlayerState.direction) {
+ if (((this->direction - gPlayerState.direction) & 0x1F) < 0x10)
*(u32*)&this->field_0x80 -= 0x20;
else
*(u32*)&this->field_0x80 += 0x20;
@@ -2802,8 +2801,8 @@ static void sub_08073584(Entity* this) {
this->animationState = state;
idx = 0;
- state = gPlayerState.field_0xd >> 2;
- if (!this->field_0x86.HALF.HI || ((gPlayerState.field_0xd & 0x80) == 0 && this->animationState != state)) {
+ state = gPlayerState.direction >> 2;
+ if (!this->field_0x86.HALF.HI || ((gPlayerState.direction & 0x80) == 0 && this->animationState != state)) {
static const u16 sAnims1[] = {
0x0708,
0x071C,
@@ -2811,7 +2810,7 @@ static void sub_08073584(Entity* this) {
0x0714,
};
- if ((gPlayerState.field_0xd & 0x80) == 0) {
+ if ((gPlayerState.direction & 0x80) == 0) {
if (this->animationState != state) {
if (this->animationState == (state ^ 4)) {
idx = 2;
@@ -2947,7 +2946,7 @@ static void DoJump(Entity* this) {
static void sub_08073924(Entity* this) {
if ((gPlayerState.flags & PL_ROLLING) == 0 && (this->z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) {
gPlayerState.jump_status = 0x40;
- gPlayerState.field_0xd = 0xff;
+ gPlayerState.direction = 0xff;
this->direction = 0xff;
PutAwayItems();
sub_08073968(this);
@@ -2956,7 +2955,7 @@ static void sub_08073924(Entity* this) {
static void sub_08073968(Entity* this) {
if ((gPlayerState.jump_status & 0xC0) == 0) {
- this->direction = gPlayerState.field_0xd;
+ this->direction = gPlayerState.direction;
}
CheckPlayerVelocity();
if ((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) {
@@ -2983,7 +2982,7 @@ static void sub_080739EC(Entity* this) {
u32 v;
if ((gPlayerState.jump_status & 0xC0) != 0) {
- gPlayerState.field_0xd = this->direction;
+ gPlayerState.direction = this->direction;
if (gPlayerState.jump_status & 0x80)
this->collisions = COL_NONE;
v = GRAVITY_RATE;
@@ -3037,7 +3036,7 @@ static void sub_08073AD4(Entity* this) {
if (gPlayerState.queued_action != PLAYER_INIT || gPlayerState.swim_state != 0) {
return;
}
- if (gPlayerState.field_0x3[1])
+ if (gPlayerState.attack_status)
sub_08073B60(this);
}
gPlayerState.jump_status = tmp + 1;
@@ -3050,7 +3049,7 @@ static void sub_08073AD4(Entity* this) {
static void sub_08073B60(Entity* this) {
gPlayerState.sword_state = 0;
- gPlayerState.field_0x3[1] = 0;
+ gPlayerState.attack_status = 0;
gPlayerState.jump_status = 0;
ResolvePlayerAnimation();
sub_080085B0(this);
@@ -3060,7 +3059,7 @@ static void sub_08073B60(Entity* this) {
}
void sub_08073B8C(Entity* this) {
- if (!gPlayerState.field_0x3[1]) {
+ if (!gPlayerState.attack_status) {
sub_08073B60(this);
return;
}
@@ -3087,7 +3086,7 @@ void sub_08073B8C(Entity* this) {
}
void sub_08073C30(Entity* this) {
- if (!gPlayerState.field_0x3[1] || this->timer-- == 0) {
+ if (!gPlayerState.attack_status || this->timer-- == 0) {
sub_08073B60(this);
} else {
COLLISION_ON(this);
@@ -3165,18 +3164,18 @@ static void sub_08073D20(Entity* this) {
COLLISION_ON(this);
}
if (!UpdatePlayerCollision()) {
- sub_08077698(this);
+ UpdateActiveItems(this);
if (!GravityUpdate(this, GRAVITY_RATE))
gPlayerState.jump_status = 0;
if ((gPlayerState.field_0x7 & 0x80) == 0 && !gPlayerState.field_0xa) {
if (this->iframes <= 8) {
if (gPlayerState.swim_state) {
gPlayerState.framestate = PL_STATE_SWIM;
- sub_0807ACCC(this);
+ PlayerSwimming(this);
UpdatePlayerMovement();
} else {
- this->direction = gPlayerState.field_0xd;
- if ((gPlayerState.field_0xd & 0x80) == 0) {
+ this->direction = gPlayerState.direction;
+ if ((gPlayerState.direction & 0x80) == 0) {
gPlayerState.framestate = PL_STATE_WALK;
UpdatePlayerMovement();
}
@@ -3211,7 +3210,7 @@ static void sub_08073F04(Entity* this) {
this->zVelocity = Q_16_16(2.5);
this->speed = 0x100;
gPlayerState.flags &= ~PL_MINISH;
- ResetPlayerItem();
+ ResetActiveItems();
}
static void sub_08073F4C(Entity* this) {
@@ -3332,7 +3331,7 @@ void SurfaceAction_DoNothing(Entity* this) {
void SurfaceAction_Pit(Entity* this) {
if (!sub_080741C4() && sub_08079C30(this)) {
if (this->action != PLAYER_FALL) {
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.queued_action = PLAYER_FALL;
}
}
@@ -3355,7 +3354,7 @@ static void sub_08074244(Entity* this, u32 a1, u32 a2) {
if (!sub_080741C4()) {
u32 tmp;
if (gPlayerState.dash_state == 0) {
- tmp = gPlayerState.field_0xd;
+ tmp = gPlayerState.direction;
} else {
tmp = 4 * this->animationState;
}
@@ -3421,7 +3420,7 @@ static void hide(Entity* this) {
this->spriteSettings.draw = 0;
COLLISION_OFF(this);
this->knockbackDuration = 0;
- ResetPlayerItem();
+ ResetActiveItems();
}
void SurfaceAction_14(Entity* this) {
@@ -3519,7 +3518,7 @@ void SurfaceAction_ShallowWater(Entity* this) {
this->spritePriority.b0 = 4;
gPlayerState.swim_state = 0;
}
- if ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_ANY_DIRECTION) ||
+ if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) ||
gPlayerState.surfacePositionSameTimer == 1)
SoundReq(SFX_WATER_WALK);
}
@@ -3563,7 +3562,7 @@ void SurfaceAction_Swamp(Entity* this) {
CreateObjectWithParent(this, OBJECT_70, 0, 0);
CreateFx(this, FX_GREEN_SPLASH, 0);
SoundReq(SFX_161);
- } else if ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_ANY_DIRECTION) != 0) {
+ } else if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) != 0) {
SoundReq(SFX_161);
} else if ((gRoomTransition.frameCount & 0xf) == 0) {
SoundReq(SFX_161);
@@ -3611,11 +3610,11 @@ static void sub_08074808(Entity* this) {
if ((gPlayerState.flags & PL_MINISH) == 0)
CreateFx(this, FX_WATER_SPLASH, 0);
SoundReq(SFX_1A5);
- ResetPlayerItem();
+ ResetActiveItems();
}
if ((gPlayerState.swim_state & 0xF) != 1) {
sub_08079744(this);
- --gPlayerState.swim_state;
+ gPlayerState.swim_state--;
}
gPlayerState.flags &= ~(PL_BURNING | PL_FROZEN);
if ((gPlayerState.flags & PL_DRUGGED) != 0 && this->field_0x7a.HWORD <= 0xEu)
@@ -3668,7 +3667,7 @@ void SurfaceAction_Ladder(Entity* this) {
this->spriteOrientation.flipY = 1;
this->animationState = IdleNorth;
this->collisionLayer = 3;
- ResetPlayerItem();
+ ResetActiveItems();
}
}
@@ -3696,7 +3695,7 @@ void SurfaceAction_AutoLadder(Entity* this) {
gPlayerState.animation = 726;
this->direction = DirectionNorth;
}
- ResetPlayerItem();
+ ResetActiveItems();
}
}
@@ -3719,7 +3718,7 @@ void SurfaceAction_Dust(Entity* this) {
if (!sub_080741C4()) {
gPlayerState.speed_modifier -= 128;
if (gPlayerState.surfacePositionSameTimer == 1 ||
- (gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_ANY_DIRECTION) != 0) {
+ (gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) != 0) {
if (gPlayerState.floor_type == SURFACE_DUST)
CreateObjectWithParent(this, DIRT_PARTICLE, 1, 0);
else
@@ -3732,7 +3731,7 @@ void SurfaceAction_26(Entity* this) {
u32 v1;
if (gPlayerState.dash_state == 0)
- v1 = gPlayerState.field_0xd;
+ v1 = gPlayerState.direction;
else
v1 = 4 * this->animationState;
sub_08074244(this, v1, v1);
@@ -3780,7 +3779,7 @@ void SurfaceAction_ConveyerEast(Entity* this) {
}
static void conveyer_push(Entity* this) {
- ResetPlayerItem();
+ ResetActiveItems();
this->spritePriority.b1 = 0;
this->speed = WALK_SPEED;
gPlayerState.flags |= PL_CONVEYOR_PUSHED;
diff --git a/src/playerItem.c b/src/playerItem.c
index 2c61016e..b5248f8a 100644
--- a/src/playerItem.c
+++ b/src/playerItem.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "functions.h"
#include "player.h"
+#include "playeritem.h"
typedef void(PlayerItemFunc)(Entity*);
@@ -38,31 +39,31 @@ extern const PlayerItemDefinition gPlayerItemDefinitions[];
extern const PlayerItemDefinition* gAdditionalPlayerItemDefinitions[3];
PlayerItemFunc* const gPlayerItemFunctions[] = {
- DeleteEntity,
- PlayerItemSword,
- PlayerItemBomb,
- PlayerItemBoomerang,
- PlayerItemBow,
- PlayerItemShield,
- PlayerItemLantern,
- PlayerItemNulled,
- PlayerItemGustJar,
- PlayerItemPacciCane,
- DeleteEntity,
- DeleteEntity,
- PlayerItemDashSword,
- PlayerItemCellOverwriteSet,
- PlayerItemBottle,
- PlayerItemSwordBeam,
- PlayerItemGust,
- PlayerItemGustBig,
- PlayerItemPacciCaneProjectile,
- PlayerItemHeldObject,
- PlayerItemSpiralBeam,
- PlayerItemFireRodProjectile,
- PlayerItemSwordBeam,
- PlayerItemNulled2,
- PlayerItemCellOverwriteSet,
+ [PLAYER_ITEM_NONE] = DeleteEntity,
+ [PLAYER_ITEM_SWORD] = PlayerItemSword,
+ [PLAYER_ITEM_BOMB] = PlayerItemBomb,
+ [PLAYER_ITEM_BOOMERANG] = PlayerItemBoomerang,
+ [PLAYER_ITEM_BOW] = PlayerItemBow,
+ [PLAYER_ITEM_SHIELD] = PlayerItemShield,
+ [PLAYER_ITEM_LANTERN] = PlayerItemLantern,
+ [PLAYER_ITEM_NULLED] = PlayerItemNulled,
+ [PLAYER_ITEM_GUST_JAR] = PlayerItemGustJar,
+ [PLAYER_ITEM_PACCI_CANE] = PlayerItemPacciCane,
+ [PLAYER_ITEM_NONE2] = DeleteEntity,
+ [PLAYER_ITEM_NONE3] = DeleteEntity,
+ [PLAYER_ITEM_DASH_SWORD] = PlayerItemDashSword,
+ [PLAYER_ITEM_CELL_OVERWRITE_SET] = PlayerItemCellOverwriteSet,
+ [PLAYER_ITEM_BOTTLE] = PlayerItemBottle,
+ [PLAYER_ITEM_SWORD_BEAM1] = PlayerItemSwordBeam,
+ [PLAYER_ITEM_GUST] = PlayerItemGust,
+ [PLAYER_ITEM_GUST_BIG] = PlayerItemGustBig,
+ [PLAYER_ITEM_PACCI_CANE_PROJECTILE] = PlayerItemPacciCaneProjectile,
+ [PLAYER_ITEM_HELD_OBJECT] = PlayerItemHeldObject,
+ [PLAYER_ITEM_SPIRAL_BEAM] = PlayerItemSpiralBeam,
+ [PLAYER_ITEM_FIRE_ROD_PROJECTILE] = PlayerItemFireRodProjectile,
+ [PLAYER_ITEM_SWORD_BEAM2] = PlayerItemSwordBeam,
+ [PLAYER_ITEM_NULLED2] = PlayerItemNulled2,
+ [PLAYER_ITEM_CELL_OVERWRITE_SET2] = PlayerItemCellOverwriteSet,
};
void ItemInit(Entity*);
diff --git a/src/playerItem/playerItemBomb.c b/src/playerItem/playerItemBomb.c
index f6ed0c1c..a1e5e560 100644
--- a/src/playerItem/playerItemBomb.c
+++ b/src/playerItem/playerItemBomb.c
@@ -80,7 +80,7 @@ void sub_0801B250(PlayerItemBombEntity* this) {
super->spriteSettings.draw = 1;
super->action = 1;
super->spritePriority.b1 = 3;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
if (super->type == 0xff) {
super->timer = 60;
} else if (super->type == 0xfe) {
@@ -105,17 +105,17 @@ void sub_0801B2CC(PlayerItemBombEntity* this) {
RegisterCarryEntity(super);
}
switch (IsItemEquipped(ITEM_REMOTE_BOMBS)) {
- case 0:
+ case EQUIP_SLOT_A:
unaff_r5 = PLAYER_INPUT_1;
break;
- case 1:
+ case EQUIP_SLOT_B:
unaff_r5 = PLAYER_INPUT_2;
break;
- case 2:
+ case EQUIP_SLOT_NONE:
unaff_r5 = 0;
break;
}
- if ((gPlayerState.playerInput.field_0x92 & unaff_r5) != 0) {
+ if ((gPlayerState.playerInput.newInput & unaff_r5) != 0) {
super->timer = 0;
super->subtimer = 1;
}
diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c
index 4dc62bca..6557a08c 100644
--- a/src/playerItem/playerItemBoomerang.c
+++ b/src/playerItem/playerItemBoomerang.c
@@ -68,8 +68,8 @@ void PlayerItemBoomerang_Init(Entity* this) {
uVar1 = 30;
}
this->timer = uVar1;
- if (((s8)gPlayerState.field_0xd) >= 0) {
- this->direction = gPlayerState.field_0xd;
+ if (((s8)gPlayerState.direction) >= 0) {
+ this->direction = gPlayerState.direction;
} else {
this->direction = this->animationState << 2;
}
@@ -89,7 +89,7 @@ void sub_0801B584(Entity* this) {
u32 cVar3;
sub_0801B804(this);
- if ((gPlayerState.field_0x3[1] == 0) || (gPlayerState.mobility != 0) || gPlayerState.item != this ||
+ if ((gPlayerState.attack_status == 0) || (gPlayerState.mobility != 0) || gPlayerState.item != this ||
(gPlayerState.item == this && gPlayerEntity.action != PLAYER_NORMAL)) {
if (gPlayerState.item == this) {
gPlayerState.item = NULL;
@@ -124,7 +124,7 @@ void sub_0801B584(Entity* this) {
this->y.HALF.HI += gUnk_080B7826[iVar2 + 1];
InitializeAnimation(this, 0);
gPlayerState.item = NULL;
- gPlayerState.field_0x3[1] |= 0x80;
+ gPlayerState.attack_status |= 0x80;
}
}
@@ -133,8 +133,8 @@ void sub_0801B680(Entity* this) {
u32 uVar6;
sub_0801B804(this);
- if ((this->field_0x68.HALF.LO == 12) && (this->field_0x80.HALF.LO == 0) && ((gPlayerState.field_0xd & 0x80) == 0)) {
- if (((this->field_0x82.HALF.HI - gPlayerState.field_0xd) & 0x1f) > 0x10) {
+ if ((this->field_0x68.HALF.LO == 12) && (this->field_0x80.HALF.LO == 0) && ((gPlayerState.direction & 0x80) == 0)) {
+ if (((this->field_0x82.HALF.HI - gPlayerState.direction) & 0x1f) > 0x10) {
this->field_0x82.HWORD += 0x40;
this->field_0x82.HALF.HI &= 0x1f;
this->direction = this->field_0x82.HALF.HI;
@@ -208,26 +208,26 @@ void sub_0801B7A8(Entity* this) {
}
void sub_0801B804(Entity* this) {
- u32 itemSlot;
+ EquipSlot equipSlot;
u32 uVar1;
- itemSlot = IsItemEquipped(ITEM_MAGIC_BOOMERANG);
- switch (itemSlot) {
- case 0:
+ equipSlot = IsItemEquipped(ITEM_MAGIC_BOOMERANG);
+ switch (equipSlot) {
+ case EQUIP_SLOT_A:
uVar1 = 1;
break;
- case 1:
+ case EQUIP_SLOT_B:
uVar1 = 2;
break;
- case 2:
+ case EQUIP_SLOT_NONE:
uVar1 = 0;
break;
}
- if ((uVar1 & gPlayerState.playerInput.field_0x90) == 0) {
+ if ((uVar1 & gPlayerState.playerInput.heldInput) == 0) {
this->field_0x80.HALF.LO = 1;
- gPlayerState.field_0xa &= 0x7f;
- gPlayerState.keepFacing &= 0x7f;
+ gPlayerState.field_0xa &= ~0x80;
+ gPlayerState.keepFacing &= ~0x80;
} else {
gPlayerState.field_0xa |= 0x80;
gPlayerState.keepFacing |= 0x80;
diff --git a/src/playerItem/playerItemBow.c b/src/playerItem/playerItemBow.c
index 6526b4e8..ee32b950 100644
--- a/src/playerItem/playerItemBow.c
+++ b/src/playerItem/playerItemBow.c
@@ -170,7 +170,7 @@ void sub_0801917C(PlayerItemBowEntity* this) {
InitializeAnimation(super, super->animIndex + 2);
}
sub_08017744(super);
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
super->speed = 0;
tmp3 = super->x.WORD;
if (tmp3 < 0) {
@@ -195,7 +195,7 @@ void sub_0801917C(PlayerItemBowEntity* this) {
super->direction ^= 0x10;
super->speed = 0x100;
super->zVelocity = Q_16_16(0.5);
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
InitializeAnimation(super, 6);
} else {
super->action++;
@@ -230,7 +230,7 @@ void sub_0801917C(PlayerItemBowEntity* this) {
if ((gPlayerEntity.frame & 1) != 0 && arrowCount != 0) {
entity = CreatePlayerItem(PLAYER_ITEM_BOW, 1, super->hurtType, 9);
if (entity != NULL) {
- gPlayerState.field_0x3[1] |= 0x80;
+ gPlayerState.attack_status |= 0x80;
ModArrows(-1);
}
}
diff --git a/src/playerItem/playerItemFireRodProjectile.c b/src/playerItem/playerItemFireRodProjectile.c
index 57e26a75..3c65c353 100644
--- a/src/playerItem/playerItemFireRodProjectile.c
+++ b/src/playerItem/playerItemFireRodProjectile.c
@@ -77,7 +77,7 @@ void sub_080A310C(FireRodProjectileEntity* this) {
if (sub_08008790(super, 0xc)) {
DeleteThisEntity();
}
- super->child = CreatePlayerItem(PLAYER_ITEM_15, 1, 0, this->unk68);
+ super->child = CreatePlayerItem(PLAYER_ITEM_FIRE_ROD_PROJECTILE, 1, 0, this->unk68);
if (super->child != NULL) {
super->child->parent = super;
}
diff --git a/src/playerItem/playerItemGust.c b/src/playerItem/playerItemGust.c
index e3bb729a..8d62b981 100644
--- a/src/playerItem/playerItemGust.c
+++ b/src/playerItem/playerItemGust.c
@@ -221,7 +221,7 @@ static void sub_080ACECC(GustEntity* this) {
Entity* entity;
if (super->type < 3 && super->child == NULL && (s32)this->unk78 >= 0 && gUnk_0812AAE8[super->type] <= this->unk78) {
- entity = CreatePlayerItem(PLAYER_ITEM_10, super->type + 1, 0, 0);
+ entity = CreatePlayerItem(PLAYER_ITEM_GUST, super->type + 1, 0, 0);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
diff --git a/src/playerItem/playerItemHeldObject.c b/src/playerItem/playerItemHeldObject.c
index 8f8c42d2..8421c8fa 100644
--- a/src/playerItem/playerItemHeldObject.c
+++ b/src/playerItem/playerItemHeldObject.c
@@ -34,7 +34,7 @@ void sub_080ACF2C(PlayerItemHeldObjectEntity*);
void sub_080ACFCC(PlayerItemHeldObjectEntity*);
void sub_080AD040(PlayerItemHeldObjectEntity*);
void sub_080AD274(PlayerItemHeldObjectEntity*);
-u32 sub_0806F8DC(Entity*);
+bool32 sub_0806F8DC(Entity*);
void PlayerItemHeldObject(Entity* this) {
static void (*const subActionFuncs[])(PlayerItemHeldObjectEntity*) = {
@@ -91,7 +91,7 @@ void sub_080ACFCC(PlayerItemHeldObjectEntity* this) {
if ((gPlayerState.heldObject == 0) || ((gNewPlayerEntity.unk_79 & 0x7f) != 0)) {
sub_080AD27C(this);
super->subAction++;
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
super->direction = 0xff;
super->zVelocity = 0;
}
@@ -216,7 +216,7 @@ void sub_080AD040(PlayerItemHeldObjectEntity* this) {
return;
}
sub_080AD27C(this);
- super->flags &= 0x7f;
+ super->flags &= ~0x80;
super->direction = 0xff;
super->zVelocity = tmp & 1;
return;
diff --git a/src/playerItem/playerItemLantern.c b/src/playerItem/playerItemLantern.c
index 3158f698..6d22375e 100644
--- a/src/playerItem/playerItemLantern.c
+++ b/src/playerItem/playerItemLantern.c
@@ -56,7 +56,7 @@ void sub_08054AC8(Entity* this) {
this->frame = gPlayerEntity.frame;
this->frameSpriteSettings = gPlayerEntity.frameSpriteSettings;
}
- if (IsItemEquipped(ITEM_LANTERN_ON) < 2) {
+ if (IsItemEquipped(ITEM_LANTERN_ON) < EQUIP_SLOT_NONE) {
if (((this->frameIndex != 0xff) && (gPlayerEntity.spriteSettings.draw != 0)) && (this->timer-- == 0)) {
this->timer = 4;
object = CreateObject(LAMP_PARTICLE, 0, 0x10);
diff --git a/src/playerItem/playerItemShield.c b/src/playerItem/playerItemShield.c
index afe8feb1..0c1a98ee 100644
--- a/src/playerItem/playerItemShield.c
+++ b/src/playerItem/playerItemShield.c
@@ -55,19 +55,19 @@ NONMATCH("asm/non_matching/playerItemShield/sub_080A2E00.inc", void sub_080A2E00
this->iframes = 0;
}
- uVar4 = gPlayerState.field_0x3[0];
+ uVar4 = gPlayerState.shield_status;
if ((uVar4 != 0) && (this == gPlayerState.item)) {
if ((uVar4 & 0x80) != 0) {
this->hitbox = gUnk_08127240[this->animationState >> 1];
this->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x20;
this->flags = this->flags | 0x80;
- gPlayerState.field_0x3[0] = uVar4 & 0x7f;
+ gPlayerState.shield_status = uVar4 & 0x7f;
sub_080176E4(this);
} else {
if ((this->contactFlags & 0x80) != 0) {
if ((((this->contactFlags & 0x7f) == 0x42) && (*(char*)&this->field_0x68 == 0xe)) &&
((uVar4 & 0x40) == 0)) {
- pEVar1 = CreatePlayerItem(PLAYER_ITEM_15, 0, 0, *(char*)&this->field_0x68);
+ pEVar1 = CreatePlayerItem(PLAYER_ITEM_FIRE_ROD_PROJECTILE, 0, 0, *(char*)&this->field_0x68);
this->child = pEVar1;
if (pEVar1 != NULL) {
pEVar1->subtimer = 1;
@@ -77,7 +77,7 @@ NONMATCH("asm/non_matching/playerItemShield/sub_080A2E00.inc", void sub_080A2E00
*(u32*)&this->field_0x78 = gUnk_08127220[1];
*(u32*)&this->field_0x74 = uVar4 & 0x40;
*(u8**)&this->field_0x7c = gUnk_08127220;
- gPlayerState.field_0x3[0] = gPlayerState.field_0x3[0] | 0x40;
+ gPlayerState.shield_status |= 0x40;
}
if (*(int*)&this->field_0x6c == 0) {
SoundReq(0x118);
@@ -86,7 +86,7 @@ NONMATCH("asm/non_matching/playerItemShield/sub_080A2E00.inc", void sub_080A2E00
}
}
} else {
- gPlayerState.field_0x3[0] = 0;
+ gPlayerState.shield_status = 0;
if (gPlayerState.item == this) {
gPlayerState.item = NULL;
}
@@ -109,16 +109,16 @@ NONMATCH("asm/non_matching/playerItemShield/sub_080A2E00.inc", void sub_080A2E00
iVar5 = (*(int*)&this->field_0x74) * 4;
iVar2 = *(u8**)&this->field_0x7c;
if (iVar2[iVar5] == 0xff) {
- if ((gPlayerState.field_0x3[0] & 0x40) != 0) {
+ if ((gPlayerState.shield_status & 0x40) != 0) {
*(u8**)&this->field_0x7c = gUnk_081271DC;
- gPlayerState.field_0x3[0] = gPlayerState.field_0x3[0] & 0xbf;
+ gPlayerState.shield_status = gPlayerState.shield_status & 0xbf;
}
*(u32*)&this->field_0x74 = 0;
iVar2 = *(u8**)&this->field_0x7c;
}
pbVar3 = &iVar2[*(int*)&this->field_0x74 * 4];
*(u32*)&this->field_0x78 = pbVar3[1];
- if ((gPlayerState.field_0x3[0] & 0x40) != 0) {
+ if ((gPlayerState.shield_status & 0x40) != 0) {
u32 temp = (gPlayerEntity.frame & 0x7f) + 8;
sub_080042D0(this, temp + *pbVar3, (u16)this->spriteIndex);
} else {
diff --git a/src/playerItem/playerItemSword.c b/src/playerItem/playerItemSword.c
index 76ae377f..52b9dcbf 100644
--- a/src/playerItem/playerItemSword.c
+++ b/src/playerItem/playerItemSword.c
@@ -46,7 +46,7 @@ void sub_080A758C(PlayerItemSwordEntity* this) {
SFX_PLY_VO4,
SFX_PLY_VO5,
};
- if (((super->type == 0) && (gPlayerState.field_0x3[1] == 0)) && ((gPlayerState.jump_status & 0x20) == 0)) {
+ if (((super->type == 0) && (gPlayerState.attack_status == 0)) && ((gPlayerState.jump_status & 0x20) == 0)) {
DeleteThisEntity();
}
if (AllocMutableHitbox(super) == NULL) {
@@ -157,7 +157,7 @@ void sub_080A76CC(PlayerItemSwordEntity* this) {
if ((PlayerItemSwordEntity*)gPlayerState.item != this) {
DeleteThisEntity();
}
- if (gPlayerState.field_0x3[1] == 0) {
+ if (gPlayerState.attack_status == 0) {
gPlayerState.item = NULL;
gPlayerState.sword_state = 0;
DeleteThisEntity();
@@ -209,7 +209,7 @@ void sub_080A76CC(PlayerItemSwordEntity* this) {
sub_080A78B8(this, &gPlayerEntity);
sub_080A7A84(this);
} else {
- if (!((gPlayerState.field_0x3[1] == 0) || (gPlayerState.item->hurtType == 0))) {
+ if (!((gPlayerState.attack_status == 0) || (gPlayerState.item->hurtType == 0))) {
super->flags |= ENT_COLLIDE;
super->hurtType = gPlayerState.item->hurtType;
sub_080A7A54(this);
@@ -225,7 +225,7 @@ void sub_080A7824(PlayerItemSwordEntity* this) {
if (gPlayerState.item != super) {
DeleteThisEntity();
}
- if (gPlayerState.field_0x3[1] != 0) {
+ if (gPlayerState.attack_status != 0) {
if (gPlayerState.jump_status == 0) {
gPlayerState.item = NULL;
DeleteThisEntity();
@@ -306,7 +306,7 @@ void sub_080A78B8(PlayerItemSwordEntity* this, Entity* param_2) {
default:
if ((gPlayerState.sword_state & 0xc0) == 0) {
gPlayerState.sword_state = 0;
- gPlayerState.field_0x3[1] = 0;
+ gPlayerState.attack_status = 0;
gPlayerState.item = NULL;
DeleteThisEntity();
}
diff --git a/src/playerItem/playerItemSwordBeam.c b/src/playerItem/playerItemSwordBeam.c
index 35f844da..dfd78d5d 100644
--- a/src/playerItem/playerItemSwordBeam.c
+++ b/src/playerItem/playerItemSwordBeam.c
@@ -70,11 +70,11 @@ void sub_08019580(Entity* this) {
if (--*(int*)&this->field_0x6c != -1) {
GetNextFrame(this);
LinearMoveUpdate(this);
- this->timer += 1;
+ this->timer++;
if (this->type2 == 0) {
sub_0800451C(this);
}
- if ((sub_080B1BA4(TILE(this->x.HALF.HI, this->y.HALF.HI), gPlayerEntity.collisionLayer, 0x80) == 0) &&
+ if ((sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) &&
(sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI) != 0)) {
CreateFx(this, FX_SWORD_MAGIC, 0);
DeleteThisEntity();
diff --git a/src/playerItemUtils.c b/src/playerItemUtils.c
index f6a4d67c..b09ed736 100644
--- a/src/playerItemUtils.c
+++ b/src/playerItemUtils.c
@@ -12,13 +12,13 @@
static Entity* GiveItemWithCutscene(u32, u32, u32);
static void InitTileMessage(u32, u32);
-Entity* sub_080A276C(Entity*, u32, u32);
+Entity* CreateLinkAnimation(Entity*, u32, u32);
void SetPlayerItemGetState(Entity*, u32, u32);
void CreateItemEntity(u32 type, u32 type2, u32 delay) {
Entity* e = GiveItemWithCutscene(type, type2, delay);
if (e != NULL) {
- e->parent = sub_080A276C(e, e->type, 0);
+ e->parent = CreateLinkAnimation(e, e->type, 0);
}
}
diff --git a/src/playerUtils.c b/src/playerUtils.c
index 08af08f3..df6022b8 100644
--- a/src/playerUtils.c
+++ b/src/playerUtils.c
@@ -1,26 +1,24 @@
#define NENT_DEPRECATED
-#include "global.h"
#include "area.h"
#include "asm.h"
#include "common.h"
#include "entity.h"
#include "functions.h"
#include "game.h"
+#include "global.h"
+#include "item.h"
#include "kinstone.h"
+#include "manager/diggingCaveEntranceManager.h"
+#include "message.h"
+#include "new_player.h"
#include "object.h"
#include "player.h"
#include "room.h"
#include "save.h"
-#include "new_player.h"
-#include "item.h"
-#include "message.h"
#include "screen.h"
-#include "screen.h"
-#include "manager/diggingCaveEntranceManager.h"
static void sub_08077E54(ItemBehavior* beh);
-extern void sub_080752E8(ItemBehavior* behavior, u32 arg1); // item.c
extern void sub_0800857C(Entity*);
extern void SetDefaultPriorityForKind(Entity*);
extern void sub_0809D738(Entity*);
@@ -31,36 +29,28 @@ extern void sub_08080BC4(void);
void sub_080790E4(Entity* this);
void sub_08079064(Entity*);
-typedef struct {
- u8 unk0[4];
- u16 unk4;
- u8 unk6[6];
-} struct_0811BE48;
-
extern u8 gMapData;
extern const u8 gUnk_020176E0[];
extern const ScreenTransitionData gUnk_0813AD88[];
-bool32 sub_08077758(PlayerEntity*);
-bool32 sub_080777A0();
-void sub_08077880(u32, u32, u32);
-bool32 sub_080778CC();
-ItemBehavior* sub_0807794C(u32);
+bool32 IsAbleToUseItem(PlayerEntity*);
+bool32 IsPreventedFromUsingItem();
+void CreateItemIfInputMatches(Item itemId, PlayerInputState input, bool32 forceCreate);
+bool32 IsTryingToPickupObject(void);
+ItemBehavior* CreateItem(u32);
u32 sub_080789A8(void);
-ItemBehavior* sub_080779EC(u32);
-void DeletePlayerItem(ItemBehavior*, u32);
+ItemBehavior* CreateItem1(u32);
+void DeleteItemBehavior(ItemBehavior*, u32);
bool32 sub_08079E90(u32);
void PlayerMinishSetNormalAndCollide(void);
void sub_08078D60(void);
-void* sub_08077C54(ItemBehavior*);
+void* CreateItemGetPlayerItemWithParent(ItemBehavior*);
u32 sub_08079FD4(Entity*, u32);
void LoadRoomGfx(void);
-u32 sub_0807A094(u32);
SurfaceType GetSurfaceCalcType(Entity*, s32, s32);
void sub_0807AAF8(Entity*, u32);
-extern u32 gUnk_02022830[];
-extern struct_0811BE48 gUnk_0811BE48[];
+extern ItemDefinition gItemDefinitions[];
extern void (*const gUnk_0811C27C[])(Entity*);
extern void (*const gUnk_0811C284[])(PlayerEntity*);
extern void (*const gUnk_0811C298[])(PlayerEntity*);
@@ -69,7 +59,7 @@ extern u8 gUnk_0811C000[];
extern const u8 gUnk_0811C118[];
extern void (*const gUnk_0811C120[])(Entity*);
extern u16 gUnk_0811C268[];
-extern ItemBehavior* (*const gUnk_0811BFC8[])(u32);
+extern ItemBehavior* (*const gCreateItemsFuncs[])(Item);
extern void DeleteLoadedTileEntity(u32, u32);
@@ -90,7 +80,7 @@ struct_03003DF8* sub_080784E4(void);
extern const u16 gUnk_0811C0F8[];
u32 sub_08079778(void);
-u32 sub_0807A500(void);
+u32 GetPlayerTilePos(void);
extern const u16 gUnk_0811C108[];
@@ -126,7 +116,7 @@ bool32 sub_0807B464(u32 param_1, u32 param_2);
extern void CreateRandomWaterTrace(Entity* parent, int range);
void sub_08079520(Entity* this);
-bool32 sub_0807ADB8(Entity*);
+bool32 ToggleDiving(Entity*);
extern const u16* sub_0806FC50(u32 param_1, u32 param_2);
@@ -174,40 +164,36 @@ extern u32 sub_08004202(Entity*, u8*, u32);
extern s8* gUnk_0811C0B0[];
extern u8 gUnk_0811C01C[];
-void sub_08077698(PlayerEntity* this) {
- ItemBehavior* puVar2;
- u32 idx;
-
- gPlayerState.field_0x3[0] &= 0xfe;
- gPlayerState.field_0x3[1] &= 0xf;
- if ((((((gPlayerState.field_0x7 | gPlayerState.jump_status) & 0x80) == 0) &&
- ((gPlayerState.jump_status & 0x40) == 0)) &&
- (gPlayerState.swim_state == 0)) &&
- ((sub_08077758(this) && (sub_080777A0() == 0)))) {
- sub_08077880(gSave.stats.itemButtons[SLOT_A], 1, 0);
- sub_08077880(gSave.stats.itemButtons[SLOT_B], 2, 0);
- sub_080778CC();
- }
- idx = 0;
- puVar2 = gUnk_03000B80;
- do {
- if (puVar2->field_0x9 != 0) {
- sub_080752E8(puVar2, idx);
+extern u32 gUnk_02022830[];
+
+void UpdateActiveItems(PlayerEntity* this) {
+ u32 index;
+
+ gPlayerState.shield_status &= 0xfe;
+ gPlayerState.attack_status &= 0xf;
+ if (((gPlayerState.field_0x7 | gPlayerState.jump_status) & 0x80) == 0 && (gPlayerState.jump_status & 0x40) == 0 &&
+ gPlayerState.swim_state == 0 && IsAbleToUseItem(this) && !IsPreventedFromUsingItem()) {
+ CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_A], PLAYER_INPUT_1, FALSE);
+ CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_B], PLAYER_INPUT_2, FALSE);
+ IsTryingToPickupObject();
+ }
+
+ for (index = 0; index < MAX_ACTIVE_ITEMS; index++) {
+ if (gActiveItems[index].priority != 0) {
+ ExecuteItemFunction(&gActiveItems[index], index);
}
- puVar2++;
- idx++;
- } while (idx < 4);
+ }
}
-void sub_08077728(u32 param_1) {
- if (param_1 == 0) {
- sub_08077880(gSave.stats.itemButtons[SLOT_A], 1, 1);
+void CreateItemEquippedAtSlot(EquipSlot equipSlot) {
+ if (equipSlot == EQUIP_SLOT_A) {
+ CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_A], PLAYER_INPUT_1, TRUE);
} else {
- sub_08077880(gSave.stats.itemButtons[SLOT_B], 2, 1);
+ CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_B], PLAYER_INPUT_2, TRUE);
}
}
-bool32 sub_08077758(PlayerEntity* this) {
+bool32 IsAbleToUseItem(PlayerEntity* this) {
if ((gPlayerState.flags & PL_DRUGGED) == 0) {
if ((gPlayerState.flags & (PL_CAPTURED | PL_HIDDEN | PL_DISABLE_ITEMS | PL_BURNING | PL_FROZEN)) == 0) {
if ((((gPlayerState.dash_state | gPlayerState.mobility) | this->unk_7a) == 0) &&
@@ -221,8 +207,8 @@ bool32 sub_08077758(PlayerEntity* this) {
return FALSE;
}
-bool32 sub_080777A0(void) {
- if ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_80) != 0) {
+bool32 IsPreventedFromUsingItem(void) {
+ if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_80) != 0) {
if ((gPlayerState.flags & PL_CLONING) != 0) {
gPlayerState.chargeState.action = 1;
DeleteClones();
@@ -245,9 +231,9 @@ bool32 sub_080777A0(void) {
default:
if ((((gUnk_0200AF00.unk_2c == 0xc) && (gPlayerState.field_0x1c == 0)) &&
(gPlayerState.floor_type != SURFACE_SWAMP)) &&
- ((((gPlayerState.playerInput.field_0x90 & PLAYER_INPUT_ANY_DIRECTION) != 0 &&
+ ((((gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) != 0 &&
((gPlayerState.flags & (PL_BURNING | PL_ROLLING)) == 0)) &&
- ((gPlayerState.jump_status == 0 && (gPlayerState.field_0x3[1] == 0)))))) {
+ ((gPlayerState.jump_status == 0 && (gPlayerState.attack_status == 0)))))) {
gPlayerState.queued_action = PLAYER_ROLL;
}
return FALSE;
@@ -262,158 +248,150 @@ bool32 sub_080777A0(void) {
}
}
-void sub_08077880(Item itemId, u32 param_2, u32 param_3) {
- ItemBehavior* item;
- u16* puVar2;
-
+void CreateItemIfInputMatches(Item itemId, PlayerInputState input, bool32 forceCreate) {
if (itemId - 1 < 0x1f) {
- struct_0811BE48* ptr = &gUnk_0811BE48[itemId];
- puVar2 = &gPlayerState.playerInput.field_0x90;
- if (ptr->unk0[0] != 0) {
- puVar2 = &gPlayerState.playerInput.field_0x92;
+ ItemDefinition* ptr = &gItemDefinitions[itemId];
+ u16* inputPtr = &gPlayerState.playerInput.heldInput;
+ if (ptr->isOnlyActiveFirstFrame) {
+ inputPtr = &gPlayerState.playerInput.newInput;
}
- if (((*puVar2 & param_2) != 0) || (param_3 != 0)) {
- item = sub_0807794C(itemId);
+ if ((*inputPtr & input) || forceCreate) {
+ ItemBehavior* item = CreateItem(itemId);
if (item != NULL) {
- item->field_0x9 = gUnk_0811BE48[itemId].unk0[1];
- item->behaviorID = itemId;
- item->field_0x2[1] = param_2;
+ item->priority = gItemDefinitions[itemId].priority;
+ item->behaviorId = itemId;
+ item->field_0x2[1] = input;
}
}
}
}
-bool32 sub_080778CC(void) {
+bool32 IsTryingToPickupObject(void) {
ItemBehavior* item;
if (!((((gPlayerState.flags & (PL_USE_PORTAL | PL_MINISH | PL_ROLLING)) == 0) &&
(((gNewPlayerEntity.unk_79 != 0 || (gPlayerState.heldObject != 0)) ||
- ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_8000) != 0)))) &&
- (((sub_080789A8() != 0 || ((gPlayerState.playerInput.field_0x90 &
+ ((gPlayerState.playerInput.newInput & PLAYER_INPUT_8000) != 0)))) &&
+ (((sub_080789A8() != 0 || ((gPlayerState.playerInput.heldInput &
(PLAYER_INPUT_ANY_DIRECTION | PLAYER_INPUT_1 | PLAYER_INPUT_2)) == 0)))))) {
return FALSE;
}
- item = sub_0807794C(ITEM_TRAP);
+ item = CreateItem(ITEM_TRY_PICKUP_OBJECT);
if (item != NULL) {
- item->behaviorID = ITEM_TRAP;
- item->field_0x9 = gUnk_0811BE48[0].unk0[0x145];
+ item->behaviorId = ITEM_TRY_PICKUP_OBJECT;
+ item->priority = gItemDefinitions[ITEM_TRY_PICKUP_OBJECT].priority;
return TRUE;
} else {
return FALSE;
}
}
-ItemBehavior* sub_0807794C(Item itemId) {
- if (((((gPlayerState.queued_action == PLAYER_ROLL) && (itemId != ITEM_TRAP)) ||
+ItemBehavior* CreateItem(Item itemId) {
+ if (((((gPlayerState.queued_action == PLAYER_ROLL) && (itemId != ITEM_TRY_PICKUP_OBJECT)) ||
(((gPlayerState.flags & (PL_ROLLING | PL_CLONING)) != 0 && (ITEM_FOURSWORD < itemId)))) ||
((((gPlayerState.jump_status != 0 || (gPlayerEntity.z.WORD != 0)) && (ITEM_FOURSWORD < itemId)) ||
- (((gPlayerState.flags & PL_MINISH) != 0 && (gUnk_0811BE48[itemId].unk6[2] == 0)))))) ||
+ (((gPlayerState.flags & PL_MINISH) && !gItemDefinitions[itemId].isUseableAsMinish))))) ||
((gPlayerState.floor_type == SURFACE_SWAMP && ((gPlayerState.surfaceTimer != 0 && (1 < itemId - 0x14)))))) {
return NULL;
} else {
- u32 tmp = gUnk_0811BE48[itemId].unk0[2];
- return gUnk_0811BFC8[tmp](itemId);
+ u32 createFunc = gItemDefinitions[itemId].createFunc;
+ return gCreateItemsFuncs[createFunc](itemId);
}
}
-u32 sub_080779E8(void) {
- return 0;
+ItemBehavior* CreateItemNone(Item itemId) {
+ return NULL;
}
-ItemBehavior* sub_080779EC(u32 param_1) {
- if (gUnk_03000B80[1].field_0x9 == 0) {
- return gUnk_03000B80 + 1;
- } else if (gUnk_03000B80[2].field_0x9 == 0) {
- return gUnk_03000B80 + 2;
+ItemBehavior* CreateItem1(Item itemId) {
+ if (gActiveItems[ACTIVE_ITEM_1].priority == 0) {
+ return &gActiveItems[ACTIVE_ITEM_1];
+ } else if (gActiveItems[ACTIVE_ITEM_2].priority == 0) {
+ return &gActiveItems[ACTIVE_ITEM_2];
} else {
return NULL;
}
}
-ItemBehavior* sub_08077A18(u32 param_1) {
- ItemBehavior* pIVar1;
-
- if (((gPlayerState.heldObject == 0) && (param_1 != gUnk_03000B80[1].behaviorID)) &&
- (param_1 != gUnk_03000B80[2].behaviorID)) {
- return sub_080779EC(param_1);
+ItemBehavior* CreateItem2(Item itemId) {
+ if (((gPlayerState.heldObject == 0) && (itemId != gActiveItems[ACTIVE_ITEM_1].behaviorId)) &&
+ (itemId != gActiveItems[ACTIVE_ITEM_2].behaviorId)) {
+ return CreateItem1(itemId);
} else {
return NULL;
}
}
-ItemBehavior* sub_08077A48(s32 param_1) {
+ItemBehavior* CreateItem3(Item itemId) {
if (gPlayerState.heldObject == 0) {
- u32 tmp = gPlayerState.jump_status & 0x20;
- if ((((gPlayerState.jump_status & 0x20) == 0)) &&
- (gUnk_0811BE48[param_1].unk0[1] >= gUnk_03000B80[0].field_0x9)) {
- DeletePlayerItem(gUnk_03000B80, 0);
- gPlayerState.field_0x0[1] = tmp;
- gPlayerState.field_0x1c = tmp;
- gPlayerState.sword_state = tmp;
- return gUnk_03000B80;
+ if ((gPlayerState.jump_status & 0x20) == 0 &&
+ gItemDefinitions[itemId].priority >= gActiveItems[ACTIVE_ITEM_0].priority) {
+ DeleteItemBehavior(&gActiveItems[ACTIVE_ITEM_0], 0);
+ gPlayerState.grab_status = 0;
+ gPlayerState.field_0x1c = 0;
+ gPlayerState.sword_state = 0;
+ return &gActiveItems[ACTIVE_ITEM_0];
}
}
return NULL;
}
-ItemBehavior* sub_08077A98(void) {
- if (!(((gSave.stats.bombCount == 0) || (gPlayerState.heldObject != 0)) || (gUnk_03000B80[0].field_0x9 != 0))) {
- return gUnk_03000B80;
+ItemBehavior* CreateItem4(Item itemId) {
+ if (gSave.stats.bombCount != 0 && gPlayerState.heldObject == 0 && gActiveItems[ACTIVE_ITEM_0].priority == 0) {
+ return &gActiveItems[ACTIVE_ITEM_0];
} else {
return NULL;
}
}
-ItemBehavior* sub_08077AC8(void) {
- ItemBehavior* pIVar1;
+ItemBehavior* CreateItem5(Item itemId) {
+ ItemBehavior* activeItem;
u32 index;
index = 0;
- pIVar1 = gUnk_03000B80;
+ activeItem = gActiveItems;
while (index < 4) {
- if (pIVar1->field_0x9 != 0) {
+ // Lantern can only be active if no other item is active.
+ if (activeItem->priority != 0) {
return NULL;
}
- pIVar1++;
+ activeItem++;
index++;
}
- return gUnk_03000B80 + 3;
+ return &gActiveItems[ACTIVE_ITEM_LANTERN];
}
void ResetLantern(void) {
- u32 slot;
+ EquipSlot slot;
- DeletePlayerItem(gUnk_03000B80 + 3, 3);
+ DeleteItemBehavior(&gActiveItems[ACTIVE_ITEM_LANTERN], ACTIVE_ITEM_LANTERN);
gPlayerState.flags &= ~PL_USE_LANTERN;
slot = IsItemEquipped(ITEM_LANTERN_ON);
- if (slot != 2) {
+ if (slot != EQUIP_SLOT_NONE) {
ForceEquipItem(ITEM_LANTERN_OFF, slot);
}
}
void PutAwayItems(void) {
- ResetPlayerItem();
+ ResetActiveItems();
ResetLantern();
}
-void ResetPlayerItem() {
- u32 index = 0;
- ItemBehavior* ptr = gUnk_03000B80;
- do {
- DeletePlayerItem(ptr, index);
- ptr++;
- index++;
- } while (index <= 2);
+void ResetActiveItems() {
+ u32 index;
+ for (index = 0; index < MAX_ACTIVE_ITEMS - 1; index++) {
+ DeleteItemBehavior(&gActiveItems[index], index);
+ }
gPlayerState.moleMittsState = 0;
gPlayerState.field_0x1c = 0;
gPlayerState.field_0x1f[2] = 0;
- gPlayerState.field_0x0[1] = 0;
- gPlayerState.field_0xe = 0;
+ gPlayerState.grab_status = 0;
+ gPlayerState.itemAnimPriority = 0;
gPlayerState.dash_state = 0;
gPlayerState.sword_state = 0;
- gPlayerState.field_0x3[0] = 0;
+ gPlayerState.shield_status = 0;
gPlayerState.heldObject = 0;
gPlayerState.flags &= ~(PL_ROLLING | PL_SWORD_THRUST);
@@ -434,121 +412,111 @@ void ResetPlayerItem() {
void sub_08077B98(ItemBehavior* unk) {
if ((gPlayerState.item == NULL) || (gPlayerState.item->id != 1)) {
- gPlayerState.item = sub_08077C54(unk);
+ gPlayerState.item = CreateItemGetPlayerItemWithParent(unk);
}
}
void sub_08077BB8(ItemBehavior* beh) {
- Entity* temp = sub_08077C54(beh);
+ Entity* temp = CreateItemGetPlayerItemWithParent(beh);
if (temp != NULL) {
temp->flags = ENT_PERSIST;
}
gPlayerState.item = temp;
}
-Entity* sub_08077BD4(ItemBehavior* beh) {
- if (sub_08077C94(beh, gUnk_0811BE48[beh->behaviorID].unk0[3]) != 0) {
+Entity* CreatePlayerItemForItemIfNotExists(ItemBehavior* this) {
+ if (FindPlayerItemForItem(this, gItemDefinitions[this->behaviorId].playerItemId) != 0) {
return NULL;
} else {
- return CreatePlayerItemWithParent(beh, gUnk_0811BE48[beh->behaviorID].unk0[3]);
+ return CreatePlayerItemWithParent(this, gItemDefinitions[this->behaviorId].playerItemId);
}
}
-Entity* sub_08077C0C(ItemBehavior* beh, u32 arg1) {
- u8 bVar1;
- Entity* pEVar3;
-
- bVar1 = gUnk_0811BE48[arg1].unk0[3];
-
- if (sub_08077C94(beh, bVar1) != 0) {
+Entity* CreatePlayerItemIfNotExists(ItemBehavior* this, u32 index) {
+ u8 id = gItemDefinitions[index].playerItemId;
+ if (FindPlayerItemForItem(this, id) != 0) {
return NULL;
} else {
- return CreatePlayerItemWithParent(beh, bVar1);
+ return CreatePlayerItemWithParent(this, id);
}
}
-Entity* CreatePlayerItemWithParent(ItemBehavior* beh, u32 subtype) {
- Entity* pEVar1;
-
- pEVar1 = CreatePlayerItem(subtype, 0, 0, beh->behaviorID);
- if (pEVar1 != NULL) {
- *(ItemBehavior**)&pEVar1->parent = beh;
+Entity* CreatePlayerItemWithParent(ItemBehavior* this, u32 id) {
+ Entity* playerItem = CreatePlayerItem(id, 0, 0, this->behaviorId);
+ if (playerItem != NULL) {
+ playerItem->parent = (Entity*)this;
}
- return pEVar1;
+ return playerItem;
}
-void* sub_08077C54(ItemBehavior* unk) {
- GenericEntity* item;
-
- item = (GenericEntity*)CreateItemGetEntity();
- if (item != NULL) {
- item->base.id = gUnk_0811BE48[unk->behaviorID].unk0[3];
- item->base.kind = PLAYER_ITEM;
- item->base.flags = 0xa0;
- item->base.parent = (Entity*)unk;
- item->field_0x68.HALF.LO = unk->behaviorID;
- AppendEntityToList(&item->base, 2);
+void* CreateItemGetPlayerItemWithParent(ItemBehavior* this) {
+ GenericEntity* playerItem = (GenericEntity*)CreateItemGetEntity();
+ if (playerItem != NULL) {
+ playerItem->base.id = gItemDefinitions[this->behaviorId].playerItemId;
+ playerItem->base.kind = PLAYER_ITEM;
+ playerItem->base.flags = 0xa0;
+ playerItem->base.parent = (Entity*)this;
+ playerItem->field_0x68.HALF.LO = this->behaviorId;
+ AppendEntityToList(&playerItem->base, 2);
}
- return item;
+ return playerItem;
}
-Entity* sub_08077C94(ItemBehavior* arg0, u32 arg1) {
- Entity* iVar1;
-
- iVar1 = FindEntityByID(PLAYER_ITEM, gUnk_0811BE48[arg1].unk0[3], 2);
- if (iVar1 == NULL) {
+Entity* FindPlayerItemForItem(ItemBehavior* this, u32 index) {
+ Entity* entity = FindEntityByID(PLAYER_ITEM, gItemDefinitions[index].playerItemId, 2);
+ if (entity == NULL) {
return NULL;
}
- return iVar1;
+ return entity;
}
-Entity* CreatePlayerItem(u32 subtype, u32 form, u32 parameter, u32 unk) {
+Entity* CreatePlayerItem(u32 id, u32 type, u32 type2, u32 unk) {
GenericEntity* ent;
ent = (GenericEntity*)GetEmptyEntity();
if (ent != NULL) {
ent->base.flags = ENT_COLLIDE;
ent->base.kind = PLAYER_ITEM;
- ent->base.id = subtype;
- ent->base.type = form;
- ent->base.type2 = parameter;
+ ent->base.id = id;
+ ent->base.type = type;
+ ent->base.type2 = type2;
ent->field_0x68.HALF.LO = unk;
AppendEntityToList(&ent->base, 2);
}
return &ent->base;
}
-Entity* sub_08077CF8(u32 subtype, u32 form, u32 parameter, u32 unk) {
+Entity* sub_08077CF8(u32 id, u32 type, u32 type2, u32 unk) {
GenericEntity* ent;
ent = (GenericEntity*)CreateItemGetEntity();
if (ent != NULL) {
ent->base.flags = ENT_COLLIDE;
ent->base.kind = PLAYER_ITEM;
- ent->base.id = subtype;
- ent->base.type = form;
- ent->base.type2 = parameter;
+ ent->base.id = id;
+ ent->base.type = type;
+ ent->base.type2 = type2;
ent->field_0x68.HALF.LO = unk;
AppendEntityToList(&ent->base, 2);
}
return &ent->base;
}
-void sub_08077D38(ItemBehavior* beh, u32 idx) {
+void sub_08077D38(ItemBehavior* this, u32 index) {
u32 r6;
- struct_0811BE48* ptr;
+ ItemDefinition* ptr;
- gPlayerState.field_0xa |= 8 >> idx;
- gPlayerState.keepFacing |= 8 >> idx;
- beh->playerAnimationState = gPlayerEntity.animationState;
- if (beh->stateID == 0) {
- beh->stateID++;
+ gPlayerState.field_0xa |= 8 >> index;
+ gPlayerState.keepFacing |= 8 >> index;
+ this->playerAnimationState = gPlayerEntity.animationState;
+ if (this->stateID == 0) {
+ this->stateID++;
}
- ptr = &gUnk_0811BE48[beh->behaviorID];
- if (ptr->unk4) {
+ ptr = &gItemDefinitions[this->behaviorId];
+ if (ptr->frameIndex) {
if ((gPlayerState.flags & PL_NO_CAP)) {
- switch (beh->behaviorID) {
+ switch (this->behaviorId) {
case 0x1b:
r6 = 0x948;
break;
@@ -559,15 +527,15 @@ void sub_08077D38(ItemBehavior* beh, u32 idx) {
r6 = 0x40c;
break;
}
- sub_08077DF4(beh, r6);
+ SetItemAnim(this, r6);
} else {
- sub_08077DF4(beh, ptr->unk4);
+ SetItemAnim(this, ptr->frameIndex);
}
}
- beh->field_0xf = ptr->unk6[0];
- if (ptr->unk6[1]) {
- gPlayerState.field_0x3[1] |= (8 >> idx) | ((8 >> idx) << 4);
+ this->animPriority = ptr->animPriority;
+ if (ptr->isChangingAttackStatus) {
+ gPlayerState.attack_status |= (8 >> index) | ((8 >> index) << 4);
}
}
@@ -580,37 +548,37 @@ typedef struct {
u8 unk[16];
} Unk_struct_in_08077EC8;
-void sub_08077DF4(ItemBehavior* beh, u32 animation) {
- beh->field_0x10 = animation;
- if ((animation & 0xff) > 0xb8) {
- animation += beh->playerAnimationState >> 1;
+void SetItemAnim(ItemBehavior* this, u32 animIndex) {
+ this->animIndex = animIndex;
+ if ((animIndex & 0xff) > 0xb8) {
+ animIndex += this->playerAnimationState >> 1;
}
- gPlayerEntity.spriteIndex = (short)(animation >> 8);
- InitAnimationForceUpdate(&gPlayerEntity, (u8)animation);
- sub_08077E54(beh);
+ gPlayerEntity.spriteIndex = (s16)(animIndex >> 8);
+ InitAnimationForceUpdate(&gPlayerEntity, (u8)animIndex);
+ sub_08077E54(this);
}
-void UpdateItemAnim(ItemBehavior* beh) {
+void UpdateItemAnim(ItemBehavior* this) {
UpdateAnimationSingleFrame(&gPlayerEntity);
- sub_08077E54(beh);
+ sub_08077E54(this);
}
-void sub_08077E3C(ItemBehavior* ent, u32 idx) {
- sub_080042BA(&gPlayerEntity, idx);
- sub_08077E54(ent);
+void sub_08077E3C(ItemBehavior* this, u32 index) {
+ sub_080042BA(&gPlayerEntity, index);
+ sub_08077E54(this);
}
-static void sub_08077E54(ItemBehavior* beh) {
- beh->playerAnimIndex = gPlayerEntity.animIndex;
- beh->playerFrameIndex = gPlayerEntity.frameIndex;
- beh->playerFrameDuration = gPlayerEntity.frameDuration;
- beh->playerFrame = gPlayerEntity.frame;
+static void sub_08077E54(ItemBehavior* this) {
+ this->playerAnimIndex = gPlayerEntity.animIndex;
+ this->playerFrameIndex = gPlayerEntity.frameIndex;
+ this->playerFrameDuration = gPlayerEntity.frameDuration;
+ this->playerFrame = gPlayerEntity.frame;
}
-void DeletePlayerItem(ItemBehavior* arg0, u32 idx) {
+void DeleteItemBehavior(ItemBehavior* this, u32 index) {
u32 not ;
- if (idx == 0) {
+ if (index == 0) {
if (gPlayerState.item != NULL) {
((Unk_bitfield*)gPlayerState.item)[0x11].b0 = 6;
gPlayerState.item = NULL;
@@ -619,62 +587,62 @@ void DeletePlayerItem(ItemBehavior* arg0, u32 idx) {
}
}
- not = (8 >> idx);
- gPlayerState.field_0x3[1] &= ~((u8)((8 >> idx) << 4) | not );
+ not = (8 >> index);
+ gPlayerState.attack_status &= ~((u8)((8 >> index) << 4) | not );
not = ~not ;
gPlayerState.field_0xa &= not ;
gPlayerState.keepFacing &= not ;
- MemClear(arg0, sizeof(ItemBehavior));
+ MemClear(this, sizeof(ItemBehavior));
}
-bool32 sub_08077EC8(ItemBehavior* beh) {
+bool32 sub_08077EC8(ItemBehavior* this) {
if ((gPlayerState.sword_state & 8) != 0) {
- sub_08077DF4(beh, 0x170);
- beh->timer = 0x28;
- beh->stateID = 7;
- beh->field_0xf = 6;
+ SetItemAnim(this, 0x170);
+ this->timer = 0x28;
+ this->stateID = 7;
+ this->animPriority = 6;
return TRUE;
} else {
return FALSE;
}
}
-bool32 sub_08077EFC(ItemBehavior* arg0) {
- return sub_08077F24(arg0, (u16)gPlayerState.playerInput.field_0x90);
+bool32 IsItemActive(ItemBehavior* this) {
+ return IsItemActiveByInput(this, gPlayerState.playerInput.heldInput);
}
-bool32 sub_08077F10(ItemBehavior* arg0) {
- return sub_08077F24(arg0, (u16)gPlayerState.playerInput.field_0x92);
+bool32 IsItemActivatedThisFrame(ItemBehavior* this) {
+ return IsItemActiveByInput(this, gPlayerState.playerInput.newInput);
}
-bool32 sub_08077F24(ItemBehavior* beh, u32 arg1) {
+bool32 IsItemActiveByInput(ItemBehavior* this, PlayerInputState input) {
u32 val;
Stats* stats = &gSave.stats;
- u32 id = beh->behaviorID;
+ u32 id = this->behaviorId;
if (stats->itemButtons[SLOT_A] == id) {
- val = 1;
+ val = PLAYER_INPUT_1;
} else if (stats->itemButtons[SLOT_B] == id) {
- val = 2;
+ val = PLAYER_INPUT_2;
} else {
val = 0;
}
- return (val & arg1) ? 1 : 0;
+ return (val & input) ? TRUE : FALSE;
}
-void PlayerCancelHoldItem(ItemBehavior* beh, u32 arg1) {
+void PlayerCancelHoldItem(ItemBehavior* this, u32 index) {
PlayerDropHeldObject();
- DeletePlayerItem(beh, arg1);
+ DeleteItemBehavior(this, index);
}
/**
* Check if player state believes the held item is valid?
* If it's not delete the item?
*/
-bool32 PlayerTryDropObject(ItemBehavior* arg0, u32 unk) {
+bool32 PlayerTryDropObject(ItemBehavior* this, u32 index) {
u32 temp;
if (gPlayerState.heldObject == 0) {
- PlayerCancelHoldItem(arg0, unk);
+ PlayerCancelHoldItem(this, index);
temp = FALSE;
} else {
temp = TRUE;
@@ -682,6 +650,8 @@ bool32 PlayerTryDropObject(ItemBehavior* arg0, u32 unk) {
return temp;
}
+// TODO move above into a itemUtils.c ?
+
void sub_08077F84(void) {
Entity* obj;
@@ -917,7 +887,7 @@ bool32 sub_080782C0(void) {
return FALSE;
}
}
- if (((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_1000) != 0) && ((u8)(gUnk_03003DF0.unk_4[3] - 1) < 100)) {
+ if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && ((u8)(gUnk_03003DF0.unk_4[3] - 1) < 100)) {
sub_0801E738(0);
if (gSave.unk12B[0] != 0) {
gUnk_03003DF0.unk_2 = gUnk_03003DF0.unk_4[3];
@@ -929,7 +899,7 @@ bool32 sub_080782C0(void) {
ForceSetPlayerState(PL_STATE_TALKEZLO);
return TRUE;
}
- if ((gPlayerState.playerInput.field_0x92 & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) {
+ if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) {
return FALSE;
}
switch (gUnk_03003DF0.unk_4[1]) {
@@ -1167,11 +1137,11 @@ void sub_08078B48(void) {
}
void ClearPlayerState(void) {
- gPlayerState.field_0x0[0] = 0;
- gPlayerState.field_0x0[1] = 0;
+ gPlayerState.prevAnim = 0;
+ gPlayerState.grab_status = 0;
gPlayerState.jump_status = 0;
- gPlayerState.field_0x3[0] = 0;
- gPlayerState.field_0x3[1] = 0;
+ gPlayerState.shield_status = 0;
+ gPlayerState.attack_status = 0;
gPlayerState.heldObject = 0;
gPlayerState.pushedObject = 0;
gPlayerState.field_0x7 = 0;
@@ -1181,8 +1151,8 @@ void ClearPlayerState(void) {
gPlayerState.field_0x35 = 0;
gPlayerState.field_0x36 = 0;
gPlayerState.queued_action = PLAYER_INIT;
- gPlayerState.field_0xd = 0;
- gPlayerState.field_0xe = 0;
+ gPlayerState.direction = 0;
+ gPlayerState.itemAnimPriority = 0;
gPlayerState.surfacePositionSameTimer = 0;
gPlayerState.floor_type = SURFACE_NORMAL;
gPlayerState.floor_type_last = SURFACE_NORMAL;
@@ -1273,7 +1243,7 @@ bool32 CheckQueuedAction(void) {
// this doesnt seem to have any real function where its used
void CheckPlayerVelocity(void) {
- u32 angle = gPlayerState.field_0xd;
+ u32 angle = gPlayerState.direction;
if ((angle & 0x80) != 0) {
ResetPlayerVelocity();
} else {
@@ -1345,20 +1315,20 @@ void sub_08078FB0(Entity* this) {
void sub_08079064(Entity* this) {
u32 i;
- u32 bVar4;
- u32 animation;
+ u32 maxAnimPriority;
+ u32 animIndex;
if ((gPlayerState.flags & (PL_IN_HOLE | PL_MINISH)) == 0) {
- bVar4 = 0;
+ maxAnimPriority = 0;
for (i = 0; i < 4; i++) {
- if (gUnk_03000B80[i].field_0xf > bVar4) {
- bVar4 = gUnk_03000B80[i].field_0xf;
- animation = gUnk_03000B80[i].field_0x10;
+ if (gActiveItems[i].animPriority > maxAnimPriority) {
+ maxAnimPriority = gActiveItems[i].animPriority;
+ animIndex = gActiveItems[i].animIndex;
}
}
- if (gPlayerState.field_0xe < bVar4) {
- gPlayerState.animation = animation;
+ if (gPlayerState.itemAnimPriority < maxAnimPriority) {
+ gPlayerState.animation = animIndex;
} else if ((gPlayerState.swim_state & 0x80) != 0) {
gPlayerState.animation = 0x2be;
} else {
@@ -1408,7 +1378,7 @@ void sub_080790E4(Entity* this) {
void PlayerDropHeldObject(void) {
gPlayerState.heldObject = 0;
- gPlayerState.field_0x0[1] = 0;
+ gPlayerState.grab_status = 0;
gNewPlayerEntity.unk_74 = NULL;
}
@@ -1480,9 +1450,9 @@ bool32 sub_080793E4(u32 param_1) {
} else {
tmp = gUnk_0811C0F8[gPlayerEntity.direction >> 2];
}
- if (sub_08079778() && ((gPlayerState.playerInput.field_0x90 & tmp) != 0)) {
+ if (sub_08079778() && ((gPlayerState.playerInput.heldInput & tmp) != 0)) {
if (param_1 != 0) {
- if (!sub_080B1BA4(sub_0807A500(), gPlayerEntity.collisionLayer, param_1)) {
+ if (!sub_080B1BA4(GetPlayerTilePos(), gPlayerEntity.collisionLayer, param_1)) {
return FALSE;
}
}
@@ -1535,9 +1505,9 @@ code_3:
}
void sub_08079520(Entity* this) {
- s32 tmp = gPlayerState.field_0xd;
+ s32 tmp = gPlayerState.direction;
if (tmp < 0x80) {
- this->direction = gPlayerState.field_0xd;
+ this->direction = gPlayerState.direction;
} else {
this->direction = (this->animationState >> 1) << 3;
}
@@ -1545,7 +1515,7 @@ void sub_08079520(Entity* this) {
u32 sub_0807953C(void) {
u32 tmp = PLAYER_INPUT_ANY_DIRECTION | PLAYER_INPUT_20 | PLAYER_INPUT_10 | PLAYER_INPUT_8;
- return gPlayerState.playerInput.field_0x92 & tmp;
+ return gPlayerState.playerInput.newInput & tmp;
}
ASM_FUNC("asm/non_matching/playerUtils/sub_08079550.inc", u32 sub_08079550(void))
@@ -1601,7 +1571,7 @@ ASM_FUNC("asm/non_matching/playerUtils/sub_080797EC.inc", void sub_080797EC())
void ResolvePlayerAnimation(void) {
u32 index;
- u32 tmp;
+ u32 maxAnimPriority;
u32 anim;
if ((gPlayerState.flags & PL_NO_CAP) != 0) {
if (gPlayerState.heldObject != 0) {
@@ -1612,7 +1582,7 @@ void ResolvePlayerAnimation(void) {
}
if ((gPlayerState.flags & PL_CONVEYOR_PUSHED) != 0) {
anim = 0x810;
- } else if (gPlayerState.field_0x3[0] != 0) {
+ } else if (gPlayerState.shield_status != 0) {
anim = 0x414;
} else if (gPlayerState.field_0x1f[2] != 0) {
anim = 0x280;
@@ -1623,7 +1593,7 @@ void ResolvePlayerAnimation(void) {
return;
}
if (gPlayerState.sword_state == 0) {
- if (gPlayerState.field_0x3[1] != 0) {
+ if (gPlayerState.attack_status != 0) {
return;
}
if ((gPlayerState.flags & PL_USE_PORTAL) != 0) {
@@ -1661,7 +1631,7 @@ void ResolvePlayerAnimation(void) {
anim = 0x298;
} else if ((gPlayerState.flags & PL_IN_MINECART) != 0) {
anim = 0x70c;
- } else if (gPlayerState.field_0x3[0] != 0) {
+ } else if (gPlayerState.shield_status != 0) {
anim = 0x164;
} else if (gPlayerState.field_0x1f[2] != 0) {
anim = 0x280;
@@ -1677,11 +1647,11 @@ void ResolvePlayerAnimation(void) {
if (gPlayerState.sword_state != 0) {
anim = 0x168;
} else {
- if (gPlayerState.field_0x3[1] != 0) {
+ if (gPlayerState.attack_status != 0) {
return;
}
- if ((gPlayerState.flags & PL_USE_LANTERN) != 0) {
- if (gUnk_03000B80[3].field_0xf != 0) {
+ if (gPlayerState.flags & PL_USE_LANTERN) {
+ if (gActiveItems[ACTIVE_ITEM_LANTERN].animPriority != 0) {
return;
}
anim = 0x604;
@@ -1696,20 +1666,20 @@ void ResolvePlayerAnimation(void) {
gPlayerState.animation = anim;
if (gPlayerState.heldObject == 0) {
- tmp = 0;
+ maxAnimPriority = 0;
for (index = 0; index < 4; index++) {
- if (gUnk_03000B80[index].field_0xf > tmp) {
- tmp = gUnk_03000B80[index].field_0xf;
+ if (gActiveItems[index].animPriority > maxAnimPriority) {
+ maxAnimPriority = gActiveItems[index].animPriority;
}
}
- if (gPlayerState.field_0xe < tmp) {
+ if (gPlayerState.itemAnimPriority < maxAnimPriority) {
return;
}
- if ((u8)anim == gPlayerState.field_0x0[0]) {
+ if ((u8)anim == gPlayerState.prevAnim) {
UpdateAnimationSingleFrame(&gPlayerEntity);
}
}
- gPlayerState.field_0x0[0] = anim;
+ gPlayerState.prevAnim = anim;
}
bool32 sub_08079B24(void) {
@@ -1728,7 +1698,7 @@ bool32 sub_08079B24(void) {
if ((gPlayerState.jump_status & 0x41) == 0) {
gPlayerState.jump_status = 0x41;
gPlayerEntity.direction = 0xff;
- gPlayerState.field_0xd = 0xff;
+ gPlayerState.direction = 0xff;
return TRUE;
} else {
return TRUE;
@@ -1934,49 +1904,49 @@ u32 sub_08079FD4(Entity* this, u32 param_2) {
return index;
}
-void sub_0807A050(void) {
+void UpdatePlayerPalette(void) {
u32 palette;
if ((gPlayerState.hurtBlinkSpeed != 0) && ((gMessage.doTextBox & 0x7f) == 0)) {
gPlayerState.hurtBlinkSpeed--;
}
- palette = sub_0807A094(0);
+ palette = GetPlayerPalette(FALSE);
if (palette != gPlayerState.playerPalette) {
gPlayerState.playerPalette = palette;
ChangeObjPalette(&gPlayerEntity, palette);
}
}
-u32 sub_0807A094(u32 param_1) {
+u32 GetPlayerPalette(bool32 affectedBy) {
bool32 condition;
- u32 result = 0x16;
+ u32 palette = 0x16;
if (gPlayerState.hurtBlinkSpeed != 0) {
- result = 0x1b;
- if (0x78 < gPlayerState.hurtBlinkSpeed) {
- result = 0x1a;
+ palette = 0x1b;
+ if (gPlayerState.hurtBlinkSpeed > 0x78) {
+ palette = 0x1a;
}
} else {
if (gSave.stats.charm != 0) {
condition = TRUE;
- if (((param_1 == 0) && (gSave.stats.charmTimer < 0xb4)) && ((gSave.stats.charmTimer & 8) != 0)) {
+ if (!affectedBy && (gSave.stats.charmTimer < 0xb4) && ((gSave.stats.charmTimer & 8) != 0)) {
condition = FALSE;
}
if (condition) {
switch (gSave.stats.charm) {
- case 0x2f:
- result = 0x18;
+ case BOTTLE_CHARM_NAYRU:
+ palette = 0x18;
break;
- case 0x31:
- result = 0x17;
+ case BOTTLE_CHARM_DIN:
+ palette = 0x17;
break;
- case 0x30:
+ case BOTTLE_CHARM_FARORE:
default:
- result = 0x19;
+ palette = 0x19;
break;
}
}
}
}
- return result;
+ return palette;
}
void DeleteClones(void) {
@@ -2052,7 +2022,7 @@ bool32 sub_0807A2B8(void) {
ASM_FUNC("asm/non_matching/playerUtils/sub_0807A2F8.inc", u32 sub_0807A2F8(u32 a1))
-u32 sub_0807A500(void) {
+u32 GetPlayerTilePos(void) {
switch (gPlayerEntity.animationState >> 1) {
case 0:
return TILE(gPlayerEntity.x.HALF.HI,
@@ -2074,7 +2044,7 @@ ASM_FUNC("asm/non_matching/playerUtils/sub_0807A5B8.inc", void sub_0807A5B8(u32
ASM_FUNC("asm/non_matching/playerUtils/sub_0807A750.inc", void sub_0807A750())
-u32 sub_0807A894(Entity* this) {
+u32 GetCollisionTileInFront(Entity* this) {
s32 x;
s32 y;
switch (this->direction) {
@@ -2217,7 +2187,7 @@ bool32 sub_0807AC54(Entity* this) {
}
}
-void sub_0807ACCC(Entity* this) {
+void PlayerSwimming(Entity* this) {
s32 speed;
this->spritePriority.b1 = 0;
this->knockbackDuration = 0;
@@ -2226,9 +2196,9 @@ void sub_0807ACCC(Entity* this) {
} else {
speed = 0xc0;
}
- if (speed > *(s16*)&this->speed) {
+ if (speed > this->speed) {
this->speed = speed;
- this->direction = gPlayerState.field_0xd;
+ this->direction = gPlayerState.direction;
if ((gPlayerState.swim_state & 0xf) != 1) {
return;
}
@@ -2236,17 +2206,18 @@ void sub_0807ACCC(Entity* this) {
this->speed -= 4;
}
if (gPlayerState.remainingDiveTime == 0) {
- if (!sub_0807ADB8(this)) {
- sub_0807AE20(this);
+ if (!ToggleDiving(this)) {
+ PlayerUpdateSwimming(this);
}
} else {
gPlayerState.remainingDiveTime--;
if (gPlayerState.remainingDiveTime != 0) {
- sub_0807ADB8(this);
+ ToggleDiving(this);
} else {
- gPlayerState.swim_state &= 0x7f;
+ // End diving.
+ gPlayerState.swim_state &= ~0x80;
this->spritePriority.b0 = 4;
- SoundReq(SFX_163);
+ SoundReq(SFX_TOGGLE_DIVING);
}
}
if ((gPlayerState.swim_state & 0x80) != 0) {
@@ -2257,27 +2228,25 @@ void sub_0807ACCC(Entity* this) {
}
}
-bool32 sub_0807ADB8(Entity* this) {
- u8 tmp;
- if ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_10) != 0) {
+bool32 ToggleDiving(Entity* this) {
+ if (gPlayerState.playerInput.newInput & PLAYER_INPUT_10) {
gPlayerState.swim_state ^= 0x80;
- tmp = (gPlayerState.swim_state & 0x80);
- if (tmp != 0) {
+ if (gPlayerState.swim_state & 0x80) {
gPlayerState.remainingDiveTime = 0x78;
} else {
this->spritePriority.b0 = 4;
- gPlayerState.remainingDiveTime = tmp;
+ gPlayerState.remainingDiveTime = 0;
}
- SoundReq(SFX_163);
+ SoundReq(SFX_TOGGLE_DIVING);
return TRUE;
} else {
return FALSE;
}
}
-void sub_0807AE20(Entity* this) {
+void PlayerUpdateSwimming(Entity* this) {
if ((((this->action != 0x17) || (gPlayerState.field_0xa == 0)) && (gRoomControls.reload_flags == 0)) &&
- ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_8) != 0)) {
+ ((gPlayerState.playerInput.newInput & PLAYER_INPUT_8) != 0)) {
if (GetInventoryValue(ITEM_SWIM_BUTTERFLY) == 1) {
this->speed = 0x1c0;
} else {
@@ -2344,7 +2313,7 @@ void UpdatePlayerSkills(void) {
}
}
-void sub_0807AFE8(void) {
+void PlayerShrinkByRay(void) {
Entity* effect;
PutAwayItems();
effect = CreateFx(&gPlayerEntity, FX_BIG_EXPLOSION2, 0);
@@ -2355,11 +2324,11 @@ void sub_0807AFE8(void) {
}
/** Returns which kind of sword projectile is created. */
-u32 sub_0807B014(void) {
- if (((gPlayerState.skills & SKILL_SWORD_BEAM) != 0) && gSave.stats.health == gSave.stats.maxHealth) {
+u32 GetSwordBeam(void) {
+ if ((gPlayerState.skills & SKILL_SWORD_BEAM) && gSave.stats.health == gSave.stats.maxHealth) {
return 0xf;
} else {
- if ((gPlayerState.skills & SKILL_PERIL_BEAM) != SKILL_NONE && gSave.stats.health <= 8) {
+ if ((gPlayerState.skills & SKILL_PERIL_BEAM) && gSave.stats.health <= 8) {
return 0x16;
} else {
return 0;
@@ -2368,7 +2337,7 @@ u32 sub_0807B014(void) {
}
void sub_0807B068(Entity* entity) {
- if ((gPlayerState.dash_state | gPlayerState.field_0x3[1]) == 0) {
+ if ((gPlayerState.dash_state | gPlayerState.attack_status) == 0) {
if (gPlayerState.swim_state != 0) {
if ((gPlayerState.swim_state & 0x80) != 0) {
gPlayerState.animation = 0xc1c;
@@ -2376,7 +2345,7 @@ void sub_0807B068(Entity* entity) {
gPlayerState.animation = 0xc0c;
}
} else {
- if ((gPlayerState.field_0xd & 0x80) != 0) {
+ if ((gPlayerState.direction & 0x80) != 0) {
if (gPlayerState.animation != 0xc18) {
gPlayerState.animation = 0xc18;
}
diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c
index d6c4b568..6bf78af5 100644
--- a/src/projectile/v1DarkMagicProjectile.c
+++ b/src/projectile/v1DarkMagicProjectile.c
@@ -35,7 +35,7 @@ void sub_080AAC44(Entity* this) {
} else {
SortEntityAbove(this->parent, this);
}
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
}
@@ -215,7 +215,7 @@ void sub_080AAF74(Entity* this) {
gPlayerState.mobility = 0;
this->health = 0;
} else {
- ResetPlayerItem();
+ ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
CopyPosition(&gPlayerEntity, this);
diff --git a/src/scroll.c b/src/scroll.c
index 37af7af7..e6a0fa6d 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -297,7 +297,7 @@ void sub_0807FF6C(RoomControls* controls) {
gScreen.controls.windowOutsideControl = (gScreen.controls.windowOutsideControl & 0xff00) | 7;
gScreen.controls.window1HorizontalDimensions = 0xf0;
gScreen.controls.window1VerticalDimensions = 0xf0;
- ResetPlayerItem();
+ ResetActiveItems();
ResetPlayerAnimationAndAction();
if (gDiggingCaveEntranceTransition.isDiggingCave) {
gPlayerEntity.animationState = 4;
diff --git a/src/sound.c b/src/sound.c
index 532d964f..f888af22 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -549,7 +549,7 @@ extern const SongHeader sfx15F;
extern const SongHeader sfx160;
extern const SongHeader sfx161;
extern const SongHeader sfx162;
-extern const SongHeader sfx163;
+extern const SongHeader sfxToggleDiving;
extern const SongHeader sfx164;
extern const SongHeader sfx165;
extern const SongHeader sfx166;
@@ -1181,7 +1181,7 @@ const Song gSongTable[] = {
[SFX_160] = { &sfx160, MUSIC_PLAYER_04, MUSIC_PLAYER_04 },
[SFX_161] = { &sfx161, MUSIC_PLAYER_1D, MUSIC_PLAYER_1D },
[SFX_162] = { &sfx162, MUSIC_PLAYER_1C, MUSIC_PLAYER_1C },
- [SFX_163] = { &sfx163, MUSIC_PLAYER_1B, MUSIC_PLAYER_1B },
+ [SFX_TOGGLE_DIVING] = { &sfxToggleDiving, MUSIC_PLAYER_1B, MUSIC_PLAYER_1B },
[SFX_164] = { &sfx164, MUSIC_PLAYER_1A, MUSIC_PLAYER_1A },
[SFX_165] = { &sfx165, MUSIC_PLAYER_19, MUSIC_PLAYER_19 },
[SFX_166] = { &sfx166, MUSIC_PLAYER_18, MUSIC_PLAYER_18 },