diff --git a/include/asm.h b/include/asm.h index 34d77cc6..f14e6f01 100644 --- a/include/asm.h +++ b/include/asm.h @@ -21,7 +21,7 @@ extern u32 sub_08002632(struct Entity_*); extern u32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY); extern u32 GravityUpdate(struct Entity_*, u32); extern u32 CheckOnScreen(struct Entity_*); -extern u32 EntityInRectRadius(struct Entity_*, struct Entity_*, u32, u32); +extern bool32 EntityInRectRadius(struct Entity_*, struct Entity_*, u32, u32); extern void UpdateAnimationVariableFrames(struct Entity_*, u32); extern u32 sub_080043E8(struct Entity_*); extern void sub_08004484(struct Entity_*, struct Entity_*); diff --git a/include/player.h b/include/player.h index 94ec3435..ad55ec05 100644 --- a/include/player.h +++ b/include/player.h @@ -154,7 +154,7 @@ enum PlayerItemId { PL_ITEM_CELL_OVERWRITE_SET2, }; -enum SurfaceType { +typedef enum { SURFACE_NORMAL, SURFACE_PIT, SURFACE_2, @@ -200,7 +200,7 @@ enum SurfaceType { SURFACE_AUTO_LADDER, SURFACE_CLIMB_WALL, SURFACE_2C, -}; +} SurfaceType; typedef enum { SKILL_NONE = 0, @@ -255,7 +255,8 @@ typedef struct { /*0x1d*/ u8 gustJarSpeed; /*0x1e*/ u8 dash_state; /*0x1f*/ u8 field_0x1f[3]; - /*0x22*/ u16 field_0x22[2]; + /*0x22*/ u16 tilePosition; + /*0x24*/ u16 tileType; /*0x26*/ u8 swim_state; /*0x27*/ u8 field_0x27[5]; /*0x2c*/ Entity* item; @@ -376,7 +377,7 @@ void sub_08077728(u32); void PutAwayItems(void); void sub_08079E58(s32 speed, u32 direction); void RespawnPlayer(void); -u32 GetSurfaceCalcType(Entity*, s32, s32); +SurfaceType GetSurfaceCalcType(Entity*, s32, s32); void UpdatePlayerMovement(void); void EnablePlayerDraw(Entity*); void sub_080797EC(void); diff --git a/src/code_0805EC04.c b/src/code_0805EC04.c index e8197e14..dbcf312f 100644 --- a/src/code_0805EC04.c +++ b/src/code_0805EC04.c @@ -67,7 +67,12 @@ void InitPlayerMacro(u32 param_1) { ASM_FUNC("asm/non_matching/code_0805EC04/UpdatePlayerInput.inc", void UpdatePlayerInput()) u32 ConvInputToState(u32 keys) { - u32 result = (s32) - (keys & 0x200) >> 0x1f & 0x1000; + u32 result; + if (keys & L_BUTTON) { + result = 0x1000; + } else { + result = 0; + } if (keys & R_BUTTON) { result |= 0x20; result |= 0x8000; diff --git a/src/enemy/bowMoblin.c b/src/enemy/bowMoblin.c index 831477de..fd7e73bd 100644 --- a/src/enemy/bowMoblin.c +++ b/src/enemy/bowMoblin.c @@ -31,7 +31,7 @@ void sub_0803C624(BowMoblinEntity*); void sub_0803C6DC(BowMoblinEntity*); void sub_0803C714(BowMoblinEntity*); void sub_0803C634(BowMoblinEntity*); -u32 sub_0803C6F8(BowMoblinEntity*); +bool32 sub_0803C6F8(BowMoblinEntity*); bool32 sub_0803C568(BowMoblinEntity*); void sub_0803C664(BowMoblinEntity*); @@ -111,7 +111,7 @@ void sub_0803C234(BowMoblinEntity* this) { sub_0803C4B0(this); } - } else if (sub_0803C6F8(this) != 0) { + } else if (sub_0803C6F8(this)) { sub_0800417E(super, super->collisions); super->animationState = ((super->direction + 4) & 0x18) >> 2; this->unk_0x83++; @@ -369,10 +369,8 @@ void sub_0803C6DC(BowMoblinEntity* this) { GetNextFrame(super); } -u32 sub_0803C6F8(BowMoblinEntity* this) { - u32 tmp = (super->collisions & gUnk_080CFFBC[(super->animationState ^ 1) / 2]); - u32 tmp2 = -tmp; - return (tmp2 | tmp) >> 0x1f; +bool32 sub_0803C6F8(BowMoblinEntity* this) { + return (super->collisions & gUnk_080CFFBC[(super->animationState ^ 1) / 2]) != 0; } void sub_0803C714(BowMoblinEntity* this) { diff --git a/src/enemy/eyegore.c b/src/enemy/eyegore.c index a3e189ba..7e308ab8 100644 --- a/src/enemy/eyegore.c +++ b/src/enemy/eyegore.c @@ -370,7 +370,7 @@ void sub_08031024(EyegoreEntity* this) { gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI); } else { this->unk_79 = 1; - this->unk_78 = (boolresult >> 0x1f); + this->unk_78 = boolresult != 0; super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_74, this->unk_76); } } else { diff --git a/src/npc/cat.c b/src/npc/cat.c index 92154bbb..cb8e1c99 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -342,7 +342,12 @@ void sub_08067C44(Entity* this) { s32 iVar4; u32 uVar5; - uVar5 = -((s32) - (gPlayerState.flags & PL_MINISH) >> 0x1f); + if ((gPlayerState.flags & PL_MINISH) != 0) { + uVar5 = TRUE; + } else { + uVar5 = FALSE; + } + if (uVar5 != this->field_0x68.HALF.HI) { if (uVar5 == 0) { sub_08078778(this); diff --git a/src/npc/cow.c b/src/npc/cow.c index 99f5514a..e418ecd9 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -200,8 +200,12 @@ void Cow_ShowDialogue(Entity* ent) { } void sub_0806920C(Entity* ent) { - u32 var0 = gPlayerState.flags & PL_MINISH; - u32 var1 = -var0 >> 0x1F; + u32 var1; + if ((gPlayerState.flags & PL_MINISH) != 0) { + var1 = TRUE; + } else { + var1 = FALSE; + } if (var1 != ent->field_0x6c.HALF.HI) { if (var1 == 0) { diff --git a/src/npc/dog.c b/src/npc/dog.c index af62571a..82bd62d2 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -9,7 +9,7 @@ void sub_08069FE8(Entity*); u32 sub_08069EF0(Entity*); extern u8 gUnk_08111DA8[]; -u32 sub_08069F90(Entity*); +bool32 sub_08069F90(Entity*); void sub_08069F6C(Entity*); void sub_08069D00(Entity*); void sub_08069CB8(Entity*); @@ -24,9 +24,9 @@ extern u8 gUnk_08111E30[]; void sub_0806A080(Entity*); -extern Dialog gUnk_08111E34[]; +extern Dialog gUnk_08111E34[][10]; -extern u16 gUnk_08111F74[]; +extern u16 gUnk_08111F74[][5]; extern u16 gUnk_08111FD8[]; @@ -71,11 +71,7 @@ void sub_08069B44(Entity* this) { (GetInventoryValue(ITEM_QST_DOGFOOD) != 2)) { this->action = 4; } -#if defined(JP) || defined(EU) || defined(DEMO_JP) - if ((this->type == 2) && (CheckLocalFlag(0xcc) == 0)) { -#else - if ((this->type == 2) && (CheckLocalFlag(0xcf) == 0)) { -#endif + if ((this->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) { SetTile(0x4072, TILE(this->x.HALF.HI, this->y.HALF.HI - 8), this->collisionLayer); } } @@ -83,7 +79,7 @@ void sub_08069B44(Entity* this) { void sub_08069C40(Entity* this) { UpdateAnimationSingleFrame(this); - if (sub_08069F90(this) != 0) { + if (sub_08069F90(this)) { if ((gPlayerState.flags & PL_MINISH) != 0) { sub_08069CB8(this); } else { @@ -135,7 +131,7 @@ void sub_08069D00(Entity* this) { void sub_08069D54(Entity* this) { u16 collisions; - if (sub_08069F90(this) == 0) { + if (!sub_08069F90(this)) { this->timer -= 1; if (this->timer != 0) { UpdateAnimationSingleFrame(this); @@ -161,7 +157,7 @@ void sub_08069D54(Entity* this) { return; } } - if (sub_08069F90(this) != 0) { + if (sub_08069F90(this)) { this->action = 1; } else { this->action = 3; @@ -171,7 +167,7 @@ void sub_08069D54(Entity* this) { void sub_08069DF8(Entity* this) { UpdateAnimationSingleFrame(this); - if (sub_08069F90(this) != 0) { + if (sub_08069F90(this)) { this->action = 1; } else { this->timer -= 1; @@ -211,8 +207,8 @@ void sub_08069E50(Entity* this) { this->action = 7; InitAnimationForceUpdate(this, 0x29); sub_080788E0(this); - EnqueueSFX(0xd1); - EnqueueSFX(0xcd); + EnqueueSFX(SFX_VO_DOG); + EnqueueSFX(SFX_TASK_COMPLETE); } } @@ -249,9 +245,9 @@ u32 sub_08069EF0(Entity* this) { void Dog_Head(Entity* this) { u32 frame; - frame = this->frame & 0xffffff7f; + frame = this->frame & ~ANIM_DONE; if (frame != 0) { - frame = frame + this->field_0x68.HWORD; + frame += this->field_0x68.HWORD; } SetExtraSpriteFrame(this, 0, frame - 1); SetExtraSpriteFrame(this, 1, this->frameIndex); @@ -266,9 +262,9 @@ void sub_08069F6C(Entity* this) { } } -u32 sub_08069F90(Entity* this) { +bool32 sub_08069F90(Entity* this) { if ((this->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) { - return 1; + return TRUE; } else { return EntityInRectRadius(this, &gPlayerEntity, 0x14, 0x14); } @@ -282,7 +278,13 @@ void sub_08069FBC(Entity* this) { } void sub_08069FE8(Entity* this) { - u32 tmp = -((s32) - (gPlayerState.flags & PL_MINISH) >> 0x1f); + u32 tmp; + if ((gPlayerState.flags & PL_MINISH) != 0) { + tmp = TRUE; + } else { + tmp = FALSE; + } + if (tmp != this->field_0x6a.HALF.LO) { if (tmp == 0) { sub_08078778(this); @@ -313,7 +315,7 @@ void sub_0806A028(Entity* this) { } void sub_0806A080(Entity* this) { - ShowNPCDialogue(this, (Dialog*)&gUnk_08111E34 + this->type2 * 10 + gSave.global_progress); + ShowNPCDialogue(this, &(gUnk_08111E34[this->type2][gSave.global_progress])); } void sub_0806A0A4(Entity* this) { @@ -336,7 +338,7 @@ void sub_0806A0A4(Entity* this) { } } } - MessageNoOverlap(gUnk_08111F74[(u32)gSave.global_progress * 5 + dialog], this); + MessageNoOverlap(gUnk_08111F74[gSave.global_progress][dialog], this); } void sub_0806A144(Entity* this) { diff --git a/src/npc/epona.c b/src/npc/epona.c index 5ac95ddb..ce180670 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -65,7 +65,12 @@ void sub_08065A50(Entity* this) { void sub_08065A64(Entity* this) { u32 uVar2; - uVar2 = -(gPlayerState.flags & PL_MINISH) >> 0x1f; + if ((gPlayerState.flags & PL_MINISH) != 0) { + uVar2 = TRUE; + } else { + uVar2 = FALSE; + } + if (uVar2 != this->field_0x68.HALF.HI) { if (uVar2 == 0) { sub_08078778(this); diff --git a/src/npc/postman.c b/src/npc/postman.c index fd33d519..d80f92c4 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -148,7 +148,7 @@ void sub_08060528(Entity* this) { this->zVelocity = Q_16_16(2.0); this->field_0x6c.HALF.HI = 1; sub_080788E0(this); - EnqueueSFX(0x7c); + EnqueueSFX(SFX_PLY_JUMP); } else { this->field_0x6a.HWORD -= 1; } diff --git a/src/npc/tingleSiblings.c b/src/npc/tingleSiblings.c index 3b00da9d..6c998270 100644 --- a/src/npc/tingleSiblings.c +++ b/src/npc/tingleSiblings.c @@ -141,7 +141,11 @@ void sub_08064F28(Entity* this, ScriptExecutionContext* context) { iVar3 = GetInventoryValue(ITEM_MAGIC_BOOMERANG); uVar5 = 2; if (iVar3 == 0) { - uVar5 = (-bVar2 | bVar2) >> 0x1f; + if (bVar2) { + uVar5 = 1; + } else { + uVar5 = 0; + } } } iVar4 = 0xffffffff; diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index 1c8527e1..04ca7420 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -307,7 +307,14 @@ void sub_080842D8(ChestSpawnerEntity* this) { gUnk_0811F880, gUnk_0811F88A, }; - s32 index = -(-(super->x.HALF.HI & 8) >> 0x1f); + s32 index; + + if ((super->x.HALF.HI & 8) != 0) { + index = 1; + } else { + index = 0; + } + if ((super->y.HALF.HI & 8) != 0) { index += 2; } diff --git a/src/object/object64.c b/src/object/object64.c index d1d6f62e..e0f20c1e 100644 --- a/src/object/object64.c +++ b/src/object/object64.c @@ -20,7 +20,7 @@ void sub_08093ED0(Object64Entity*); void sub_08093EF0(Object64Entity*); typedef struct { - u16 unk_0; + u16 sfx; u8 unk_2; u8 unk_3; } struct_08122950; @@ -40,7 +40,7 @@ void Object64(Object64Entity* this) { } void sub_08093E3C(Object64Entity* this) { - const u16* ptr; + const struct_08122950* ptr; super->action = 1; super->flags &= 0x7f; super->spriteSettings.draw = 1; @@ -48,9 +48,9 @@ void sub_08093E3C(Object64Entity* this) { ResolveCollisionLayer(super); } InitializeAnimation(super, super->type); - ptr = &gUnk_08122950[super->type].unk_0; - if ((ptr[0] != 0) && ((super->type2 & 0x40) == 0)) { - EnqueueSFX(ptr[0]); + ptr = &gUnk_08122950[super->type]; + if ((ptr->sfx != SFX_NONE) && ((super->type2 & 0x40) == 0)) { + EnqueueSFX(ptr->sfx); } if ((super->type2 & 0x20) != 0) { super->spriteRendering.b3 = 1; diff --git a/src/object/specialFx.c b/src/object/specialFx.c index a278428e..f0ec7d46 100644 --- a/src/object/specialFx.c +++ b/src/object/specialFx.c @@ -14,104 +14,104 @@ typedef struct { u8 unk_00 : 4; u8 unk_00_4 : 4; u8 unk_01; - u16 unk_02; + u16 sfx; } struct_0811F960; // way more legible like this than if clang-format were to put multiple elements on each line // clang-format off const struct_0811F960 gUnk_0811F960[] = { - {0x1, 0x0, 0x00, 0x12D}, - {0x0, 0x0, 0x00, 0x0FD}, - {0x0, 0x0, 0x00, 0x124}, - {0x0, 0x1, 0x11, 0x123}, - {0x0, 0x1, 0x12, 0x164}, - {0x0, 0x1, 0x13, 0x10D}, - {0x0, 0x0, 0x00, 0x0FF}, - {0x5, 0x1, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x000}, - {0x2, 0x1, 0x00, 0x084}, - {0x2, 0x1, 0x00, 0x084}, - {0x0, 0x0, 0x00, 0x195}, - {0x0, 0x0, 0x00, 0x164}, - {0x0, 0x0, 0x00, 0x10D}, - {0x0, 0x1, 0x00, 0x074}, - {0x0, 0x0, 0x00, 0x10C}, - {0x5, 0x0, 0x00, 0x000}, - {0x0, 0x0, 0x10, 0x123}, - {0x5, 0x1, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x164}, - {0x0, 0x1, 0x14, 0x1A8}, - {0x0, 0x1, 0x10, 0x088}, - {0x0, 0x0, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x000}, - {0x3, 0x0, 0x00, 0x197}, - {0x3, 0x0, 0x00, 0x000}, - {0x6, 0x1, 0x00, 0x074}, - {0x3, 0x0, 0x00, 0x074}, - {0x0, 0x0, 0x00, 0x074}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x000}, - {0x7, 0x0, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x000}, - {0x3, 0x1, 0x00, 0x000}, - {0x8, 0x1, 0x00, 0x000}, - {0x9, 0x1, 0x00, 0x15F}, - {0x0, 0x0, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x2, 0x1, 0x00, 0x084}, - {0x0, 0x0, 0x00, 0x074}, - {0x0, 0x0, 0x00, 0x164}, - {0xA, 0x1, 0x00, 0x000}, - {0xA, 0x1, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x9, 0x1, 0x00, 0x15F}, - {0x9, 0x1, 0x00, 0x15F}, - {0x9, 0x1, 0x00, 0x15F}, - {0x0, 0x0, 0x00, 0x000}, - {0x2, 0x0, 0x00, 0x17F}, - {0x0, 0x1, 0x11, 0x123}, - {0x0, 0x1, 0x11, 0x123}, - {0x0, 0x1, 0x11, 0x123}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x1B4}, - {0x0, 0x1, 0x13, 0x164}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x10, 0x088}, - {0x0, 0x1, 0x10, 0x088}, - {0x0, 0x1, 0x10, 0x088}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x11D}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x0, 0x00, 0x164}, - {0x0, 0x0, 0x00, 0x0FD}, - {0x0, 0x0, 0x00, 0x0FD}, - {0x0, 0x0, 0x00, 0x0FD}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0xB, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x000}, - {0x0, 0x1, 0x00, 0x0FD}, - {0x2, 0x1, 0x00, 0x084}, + {0x1, 0x0, 0x00, SFX_12D}, + {0x0, 0x0, 0x00, SFX_ITEM_BOMB_EXPLODE}, + {0x0, 0x0, 0x00, SFX_124}, + {0x0, 0x1, 0x11, SFX_123}, + {0x0, 0x1, 0x12, SFX_164}, + {0x0, 0x1, 0x13, SFX_10D}, + {0x0, 0x0, 0x00, SFX_FF}, + {0x5, 0x1, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x2, 0x1, 0x00, SFX_WATER_SPLASH}, + {0x2, 0x1, 0x00, SFX_WATER_SPLASH}, + {0x0, 0x0, 0x00, SFX_195}, + {0x0, 0x0, 0x00, SFX_164}, + {0x0, 0x0, 0x00, SFX_10D}, + {0x0, 0x1, 0x00, SFX_METAL_CLINK}, + {0x0, 0x0, 0x00, SFX_BUTTON_PRESS}, + {0x5, 0x0, 0x00, SFX_NONE}, + {0x0, 0x0, 0x10, SFX_123}, + {0x5, 0x1, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_164}, + {0x0, 0x1, 0x14, SFX_1A8}, + {0x0, 0x1, 0x10, SFX_88}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x3, 0x0, 0x00, SFX_197}, + {0x3, 0x0, 0x00, SFX_NONE}, + {0x6, 0x1, 0x00, SFX_METAL_CLINK}, + {0x3, 0x0, 0x00, SFX_METAL_CLINK}, + {0x0, 0x0, 0x00, SFX_METAL_CLINK}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x7, 0x0, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x3, 0x1, 0x00, SFX_NONE}, + {0x8, 0x1, 0x00, SFX_NONE}, + {0x9, 0x1, 0x00, SFX_15F}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x2, 0x1, 0x00, SFX_WATER_SPLASH}, + {0x0, 0x0, 0x00, SFX_METAL_CLINK}, + {0x0, 0x0, 0x00, SFX_164}, + {0xA, 0x1, 0x00, SFX_NONE}, + {0xA, 0x1, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x9, 0x1, 0x00, SFX_15F}, + {0x9, 0x1, 0x00, SFX_15F}, + {0x9, 0x1, 0x00, SFX_15F}, + {0x0, 0x0, 0x00, SFX_NONE}, + {0x2, 0x0, 0x00, SFX_LAVA_TILE_LAND}, + {0x0, 0x1, 0x11, SFX_123}, + {0x0, 0x1, 0x11, SFX_123}, + {0x0, 0x1, 0x11, SFX_123}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_1B4}, + {0x0, 0x1, 0x13, SFX_164}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x10, SFX_88}, + {0x0, 0x1, 0x10, SFX_88}, + {0x0, 0x1, 0x10, SFX_88}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_11D}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x0, 0x00, SFX_164}, + {0x0, 0x0, 0x00, SFX_ITEM_BOMB_EXPLODE}, + {0x0, 0x0, 0x00, SFX_ITEM_BOMB_EXPLODE}, + {0x0, 0x0, 0x00, SFX_ITEM_BOMB_EXPLODE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0xB, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_NONE}, + {0x0, 0x1, 0x00, SFX_ITEM_BOMB_EXPLODE}, + {0x2, 0x1, 0x00, SFX_WATER_SPLASH}, #ifndef EU - {0x0, 0x0, 0x18, 0x124}, + {0x0, 0x0, 0x18, SFX_124}, #else - {0x0, 0x0, 0x16, 0x124}, + {0x0, 0x0, 0x16, SFX_124}, #endif - {0xC, 0x0, 0x00, 0x124}, - {0x0, 0x0, 0x00, 0x0FD}, - {0xD, 0x1, 0x00, 0x000}, - {0xD, 0x1, 0x00, 0x000}, + {0xC, 0x0, 0x00, SFX_124}, + {0x0, 0x0, 0x00, SFX_ITEM_BOMB_EXPLODE}, + {0xD, 0x1, 0x00, SFX_NONE}, + {0xD, 0x1, 0x00, SFX_NONE}, }; // clang-format on @@ -166,8 +166,8 @@ void sub_080844E0(SpecialFxObject* this) { if (ptr->unk_00 == 6) { super->speed = 0x40; } - if (ptr->unk_02 && !(super->type2 & 0x40)) { - EnqueueSFX(ptr->unk_02); + if (ptr->sfx != SFX_NONE && !(super->type2 & 0x40)) { + EnqueueSFX(ptr->sfx); } if (super->type2 & 0x80) { CreateRandomItemDrop(super, ptr->unk_01); diff --git a/src/player.c b/src/player.c index 92452736..e509c7de 100644 --- a/src/player.c +++ b/src/player.c @@ -3705,7 +3705,7 @@ void SurfaceAction_20(Entity* this) { if (e != NULL) { e->timer = 1; UpdateSpriteForCollisionLayer(e); - CloneTile(57, gPlayerState.field_0x22[0], this->collisionLayer); + CloneTile(57, gPlayerState.tilePosition, this->collisionLayer); } } SurfaceAction_Water(this); diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c index 5f8d95ce..1c9fa0f6 100644 --- a/src/playerItem/playerItemBoomerang.c +++ b/src/playerItem/playerItemBoomerang.c @@ -149,7 +149,11 @@ void sub_0801B680(Entity* this) { if (sub_0801B864(this)) { uvar1 = this->field_0x68.HALF.LO; uvar1 ^= 0xc; - uVar6 = ((u32)(-uvar1 | uvar1)) >> 0x1f; + if (uvar1) { + uVar6 = TRUE; + } else { + uVar6 = FALSE; + } } if (sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) { diff --git a/src/playerItem/playerItemSword.c b/src/playerItem/playerItemSword.c index 680ea92f..76ae377f 100644 --- a/src/playerItem/playerItemSword.c +++ b/src/playerItem/playerItemSword.c @@ -356,8 +356,8 @@ NONMATCH("asm/non_matching/playerItemSword/sub_080A7A84.inc", void sub_080A7A84( if (super->type != 0) { sub_08008796(super, 0, super->x.HALF.HI + uVar3, super->y.HALF.HI + uVar4); } else { - if ((((super->z.WORD == 0) && (sub_08008796(super, ((u32) - (gPlayerState.skills & 8)) >> 0x1f, - super->x.HALF.HI + uVar3, super->y.HALF.HI + uVar4) == NULL)) && + if ((((super->z.WORD == 0) && (sub_08008796(super, (gPlayerState.skills & 8) != 0, super->x.HALF.HI + uVar3, + super->y.HALF.HI + uVar4) == NULL)) && (gPlayerState.sword_state != 0)) && ((gPlayerState.sword_state & 0xc0) == 0)) { if (GetRelativeCollisionTile(super, uVar3, uVar4) == 0x2e) { diff --git a/src/playerUtils.c b/src/playerUtils.c index 8e8388c6..b3734e1c 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -56,7 +56,7 @@ void* sub_08077C54(ItemBehavior*); u32 sub_08079FD4(Entity*, u32); void LoadRoomGfx(void); u32 sub_0807A094(u32); -u32 GetSurfaceCalcType(Entity*, s32, s32); +SurfaceType GetSurfaceCalcType(Entity*, s32, s32); void sub_0807AAF8(Entity*, u32); extern struct_0811BE48 gUnk_0811BE48[]; @@ -243,7 +243,7 @@ bool32 sub_080777A0(void) { return FALSE; default: if ((((gUnk_0200AF00.unk_2c == 0xc) && (gPlayerState.field_0x1c == 0)) && - (gPlayerState.floor_type != 0x11)) && + (gPlayerState.floor_type != SURFACE_SWAMP)) && ((((gPlayerState.field_0x90 & 0xf00) != 0 && ((gPlayerState.flags & (PL_BURNING | PL_ROLLING)) == 0)) && ((gPlayerState.jump_status == 0 && (gPlayerState.field_0x3[1] == 0)))))) { @@ -1192,8 +1192,8 @@ void ClearPlayerState(void) { gPlayerState.field_0x1f[0] = 0; gPlayerState.field_0x1f[1] = 0; gPlayerState.field_0x1f[2] = 0; - gPlayerState.field_0x22[0] = 0; - gPlayerState.field_0x22[1] = 0; + gPlayerState.tilePosition = 0; + gPlayerState.tileType = 0; gPlayerState.swim_state = 0; gPlayerState.item = NULL; gPlayerState.speed_modifier = 0; @@ -1863,15 +1863,15 @@ void UpdateFloorType(void) { gUnk_0811C120[gPlayerState.floor_type](&gPlayerEntity); } -u32 GetSurfaceCalcType(Entity* param_1, s32 x, s32 y) { +SurfaceType GetSurfaceCalcType(Entity* param_1, s32 x, s32 y) { u32 position = TILE(param_1->x.HALF.HI + (u32)x, param_1->y.HALF.HI + y); u32 tileType = GetTileTypeByPos(param_1->x.HALF.HI + x, param_1->y.HALF.HI + y, gPlayerEntity.collisionLayer); - if (tileType != gPlayerState.field_0x22[1]) { + if (tileType != gPlayerState.tileType) { gPlayerState.field_0x37 = 0; } - if ((tileType != gPlayerState.field_0x22[1]) || (position != gPlayerState.field_0x22[0])) { - gPlayerState.field_0x22[0] = position; - gPlayerState.field_0x22[1] = tileType; + if ((tileType != gPlayerState.tileType) || (position != gPlayerState.tilePosition)) { + gPlayerState.tilePosition = position; + gPlayerState.tileType = tileType; gPlayerState.field_0x11 = 0; } diff --git a/src/text.c b/src/text.c index 277b0a65..c4cc0c10 100644 --- a/src/text.c +++ b/src/text.c @@ -201,8 +201,11 @@ u32 GetCharacter(Token* token) { case 0x14: case 0x15: code = 0xb; - // This is a comparison to 0 but couldn't make it do the bit trick - uVar6 = (-(uVar6 ^ 0x14) | (uVar6 ^ 0x14)) >> 0x1f; + if ((uVar6 ^ 0x14) != 0) { + uVar6 = 1; + } else { + uVar6 = 0; + } } token->param = (u16)uVar6; break;