diff --git a/asm/src/code_08000E44.s b/asm/src/code_08000E44.s index cfaf1f47..aab9b4ae 100644 --- a/asm/src/code_08000E44.s +++ b/asm/src/code_08000E44.s @@ -17,7 +17,7 @@ _08000E4E: thumb_func_start Random Random: @ 0x08000E50 - ldr r2, _08000EBC @ =gRand + ldr r2, =gRand ldr r0, [r2] lsls r1, r0, #1 adds r0, r0, r1 @@ -30,22 +30,22 @@ Random: @ 0x08000E50 non_word_aligned_thumb_func_start sub_08000E62 sub_08000E62: @ 0x08000E62 lsrs r1, r0, #1 - ldr r2, _08000EC0 @ =0x55555555 + ldr r2, =0x55555555 ands r0, r2 ands r1, r2 adds r0, r0, r1 lsrs r1, r0, #2 - ldr r2, _08000EC4 @ =0x33333333 + ldr r2, =0x33333333 ands r0, r2 ands r1, r2 adds r0, r0, r1 lsrs r1, r0, #4 - ldr r2, _08000EC8 @ =0x0F0F0F0F + ldr r2, =0x0F0F0F0F ands r0, r2 ands r1, r2 adds r0, r0, r1 lsrs r1, r0, #8 - ldr r2, _08000ECC @ =0x00FF00FF + ldr r2, =0x00FF00FF ands r0, r2 ands r1, r2 adds r0, r0, r1 @@ -64,7 +64,7 @@ LoadResourceAsync: @ 0x08000E96 movs r3, #0 _08000E98: push {r4, r5} - ldr r5, _08000ED0 @ =gUnk_03003DE0 + ldr r5, =gUnk_03003DE0 ldrb r4, [r5] cmp r4, #0x28 bhs _08000EB6 @@ -72,7 +72,7 @@ _08000E98: strb r4, [r5] movs r5, #0xc muls r4, r5, r4 - ldr r5, _08000ED4 @ =gUnk_03000C24 + ldr r5, =gUnk_03000C24 adds r4, r4, r5 strb r3, [r4] strh r2, [r4, #2] @@ -82,10 +82,3 @@ _08000EB6: pop {r4, r5} bx lr .align 2, 0 -_08000EBC: .4byte gRand -_08000EC0: .4byte 0x55555555 -_08000EC4: .4byte 0x33333333 -_08000EC8: .4byte 0x0F0F0F0F -_08000ECC: .4byte 0x00FF00FF -_08000ED0: .4byte gUnk_03003DE0 -_08000ED4: .4byte gUnk_03000C24 diff --git a/include/item.h b/include/item.h index 5aa1913c..8d3cb920 100644 --- a/include/item.h +++ b/include/item.h @@ -5,7 +5,6 @@ #include "entity.h" #include "player.h" -extern u32 GiveItem(u32, u32); extern u32 CreateRandomItemDrop(Entity*, u32); extern void DisableRandomDrops(); extern void EnableRandomDrops(void); @@ -175,4 +174,6 @@ typedef enum { CREATE_ITEM_5, } CreateItemFunc; +extern u32 GiveItem(Item, u32); + #endif // ITEM_H diff --git a/include/object/itemOnGround.h b/include/object/itemOnGround.h index 151dcc28..65a6fc70 100644 --- a/include/object/itemOnGround.h +++ b/include/object/itemOnGround.h @@ -3,14 +3,28 @@ #include "entity.h" +typedef enum { + ITEM_ON_GROUND_KIND_0, + ITEM_ON_GROUND_KIND_1, + ITEM_ON_GROUND_KIND_2, + ITEM_ON_GROUND_KIND_3, + ITEM_ON_GROUND_KIND_4, + ITEM_ON_GROUND_KIND_5, + ITEM_ON_GROUND_KIND_6, + ITEM_ON_GROUND_BURRIED, + ITEM_ON_GROUND_SUNKEN, + ITEM_ON_GROUND_KIND_9, + ITEM_ON_GROUND_KIND_10, +} ItemOnGroundKind; + typedef struct { /*0x00*/ Entity base; /*0x68*/ u8 unk_68; - /*0x69*/ u8 unk_69; + /*0x69*/ ItemOnGroundKind kind : 8; /*0x6a*/ u8 unk_6a; /*0x6b*/ u8 unused1[1]; /*0x6c*/ u16 unk_6c; - /*0x6e*/ u16 unk_6e; + /*0x6e*/ u16 originalTile; /*0x70*/ u8 unused2[22]; /*0x86*/ u16 flag; } ItemOnGroundEntity; diff --git a/include/room.h b/include/room.h index 1802a934..c391bea5 100644 --- a/include/room.h +++ b/include/room.h @@ -158,7 +158,7 @@ typedef struct { /* 0x2e */ u8 location; /* 0x2f */ u8 field2f; /* 0x30 */ u8 field30; - /* 0x31 */ u8 field31; + /* 0x31 */ u8 ezlo_startup_hint; /* 0x32 */ u8 field32; /* 0x33 */ u8 field33; #if defined(JP) || defined(EU) diff --git a/src/collision.c b/src/collision.c index 8f063d14..aea865bf 100644 --- a/src/collision.c +++ b/src/collision.c @@ -41,7 +41,7 @@ typedef struct { extern ColSettings gCollisionMtx[173 * 34]; extern void ram_CollideAll(void); -u32 sub_08081420(Entity*); +u32 ItemOnGround_PickUp(Entity*); extern void SoundReqClipped(Entity*, u32); void sub_08079D84(void); void sub_080180BC(Entity*, Entity*); @@ -374,7 +374,7 @@ CollisionResult CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettin CollisionResult CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { COLLISION_OFF(tgt); tgt->contactFlags = org->hurtType | CONTACT_NOW; - if ((tgt->type == 0x5F || tgt->type == 0x60) && sub_08081420(tgt)) + if ((tgt->type == 0x5F || tgt->type == 0x60) && ItemOnGround_PickUp(tgt)) tgt->health = 0; return RESULT_COLLISION_WITHOUT_SET; } diff --git a/src/game.c b/src/game.c index 7a7fc11d..b92c88b9 100644 --- a/src/game.c +++ b/src/game.c @@ -217,7 +217,7 @@ static void GameMain_ChangeRoom(void) { sub_0801855C(); } #elif defined(DEMO_JP) - if (gRoomTransition.field31) + if (gRoomTransition.ezlo_startup_hint) CheckAreaDiscovery(); if (gArea.unk28.textBaseIndex != 0xff) { sub_0801855C(); diff --git a/src/gameUtils.c b/src/gameUtils.c index 92a9db0b..f83ba232 100644 --- a/src/gameUtils.c +++ b/src/gameUtils.c @@ -463,9 +463,9 @@ void DisplayEzloMessage(void) { void CreateMiscManager(void) { Entity* e = NULL; - if (gRoomTransition.field31) + if (gRoomTransition.ezlo_startup_hint) return; - gRoomTransition.field31 = 1; + gRoomTransition.ezlo_startup_hint = TRUE; #ifndef DEMO_JP gRoomTransition.location = gArea.locationIndex; #endif diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index 860f52a4..0f077c2b 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -21,7 +21,7 @@ #include "sound.h" #include "tiles.h" -void sub_08081150(ItemOnGroundEntity* this); +void ItemOnGround_Kind2_Init(ItemOnGroundEntity* this); u8 sub_0808147C(u32); void sub_080814A4(ItemOnGroundEntity* this); u32 sub_080814C0(ItemOnGroundEntity* this); @@ -29,28 +29,28 @@ void sub_08081500(ItemOnGroundEntity* this); void sub_0808153C(ItemOnGroundEntity* this); void sub_08081598(ItemOnGroundEntity* this); void sub_080813BC(ItemOnGroundEntity* this); -void sub_080810FC(ItemOnGroundEntity* this); +void ItemOnGround_Kind1_Init(ItemOnGroundEntity* this); void ItemOnGround_Init(ItemOnGroundEntity* this); void ItemOnGround_Action1(ItemOnGroundEntity* this); void ItemOnGround_Action2(ItemOnGroundEntity* this); void ItemOnGround_Action3(ItemOnGroundEntity* this); void ItemOnGround_Action4(ItemOnGroundEntity* this); -void sub_080810A8(ItemOnGroundEntity* this); -void sub_080810FC(ItemOnGroundEntity* this); -void sub_08081150(ItemOnGroundEntity* this); -void sub_08081134(ItemOnGroundEntity* this); -void sub_08081188(ItemOnGroundEntity* this); -void sub_080811AC(ItemOnGroundEntity* this); -void sub_080811C8(ItemOnGroundEntity* this); -void sub_080811D8(ItemOnGroundEntity* this); -void sub_08081248(ItemOnGroundEntity* this); -void sub_0808126C(ItemOnGroundEntity* this); -void sub_0808127C(ItemOnGroundEntity* this); -void nullsub_113(ItemOnGroundEntity* this); -void sub_080812A0(ItemOnGroundEntity* this); -void sub_080812A8(ItemOnGroundEntity* this); -void sub_080812E8(ItemOnGroundEntity* this); -void nullsub_510(ItemOnGroundEntity* this); +void ItemOnGround_Kindx_Init(ItemOnGroundEntity* this); +void ItemOnGround_Kind1_Init(ItemOnGroundEntity* this); +void ItemOnGround_Kind2_Init(ItemOnGroundEntity* this); +void ItemOnGround_Kind3_Init(ItemOnGroundEntity* this); +void ItemOnGround_Kind4_Init(ItemOnGroundEntity* this); +void ItemOnGround_Burried_Init(ItemOnGroundEntity* this); +void ItemOnGround_Sunken_Init(ItemOnGroundEntity* this); +void ItemOnGround_Kind9_Init(ItemOnGroundEntity* this); +void ItemOnGround_Kindx_Action2(ItemOnGroundEntity* this); +void ItemOnGround_Kind2_Action2(ItemOnGroundEntity* this); +void ItemOnGround_Kind3_Action2(ItemOnGroundEntity* this); +void ItemOnGround_Kind4_Action2(ItemOnGroundEntity* this); +void ItemOnGround_Kind5_Action2(ItemOnGroundEntity* this); +void ItemOnGround_Burried_Action2(ItemOnGroundEntity* this); +void ItemOnGround_Sunken_Action2(ItemOnGroundEntity* this); +void ItemOnGround_Kind9_Action2(ItemOnGroundEntity* this); void sub_080813D4(ItemOnGroundEntity* this); void sub_080813E8(ItemOnGroundEntity* this); void sub_080813F0(ItemOnGroundEntity* this); @@ -99,7 +99,7 @@ void ItemOnGround(ItemOnGroundEntity* this) { ItemOnGround_Actions[super->action](this); } - if (super->type == 0x5C) { + if (super->type == ITEM_KINSTONE) { gRoomVars.numKinstoneDrops++; } @@ -107,9 +107,10 @@ void ItemOnGround(ItemOnGroundEntity* this) { } void ItemOnGround_Init(ItemOnGroundEntity* this) { - static void (*const gUnk_0811E7E8[])(ItemOnGroundEntity*) = { - sub_080810A8, sub_080810FC, sub_08081150, sub_08081134, sub_08081188, sub_080810A8, - sub_080810A8, sub_080811AC, sub_080811C8, sub_080811D8, sub_080810A8, + static void (*const sItemOnGround_Init_Kinds[])(ItemOnGroundEntity*) = { + ItemOnGround_Kindx_Init, ItemOnGround_Kind1_Init, ItemOnGround_Kind2_Init, ItemOnGround_Kind3_Init, + ItemOnGround_Kind4_Init, ItemOnGround_Kindx_Init, ItemOnGround_Kindx_Init, ItemOnGround_Burried_Init, + ItemOnGround_Sunken_Init, ItemOnGround_Kind9_Init, ItemOnGround_Kindx_Init, }; if (this->flag && CheckFlags(this->flag)) { DeleteThisEntity(); @@ -142,14 +143,14 @@ void ItemOnGround_Init(ItemOnGroundEntity* this) { break; } - this->unk_69 = super->timer; + this->kind = super->timer; this->unk_6a = 0; this->unk_6c = 0; this->unk_68 = 0; super->timer = 0; SetEntityPriority(super, PRIO_NO_BLOCK); super->gustJarFlags = sub_0808147C(super->type); - gUnk_0811E7E8[this->unk_69](this); + sItemOnGround_Init_Kinds[this->kind](this); } else { Entity* entity = CreateObject(FAIRY, 0x60, 0); if (entity != NULL) { @@ -163,7 +164,7 @@ void ItemOnGround_Init(ItemOnGroundEntity* this) { } } -void sub_080810A8(ItemOnGroundEntity* this) { +void ItemOnGround_Kindx_Init(ItemOnGroundEntity* this) { super->action = 1; sub_080814A4(this); if (super->direction & 0x80) { @@ -184,7 +185,7 @@ void sub_080810A8(ItemOnGroundEntity* this) { } } -void sub_080810FC(ItemOnGroundEntity* this) { +void ItemOnGround_Kind1_Init(ItemOnGroundEntity* this) { if (super->type != ITEM_HEART) { sub_08081598(this); } else { @@ -196,13 +197,13 @@ void sub_080810FC(ItemOnGroundEntity* this) { } } -void sub_08081134(ItemOnGroundEntity* this) { +void ItemOnGround_Kind3_Init(ItemOnGroundEntity* this) { sub_080814A4(this); this->unk_6c += 80; - sub_08081150(this); + ItemOnGround_Kind2_Init(this); } -void sub_08081150(ItemOnGroundEntity* this) { +void ItemOnGround_Kind2_Init(ItemOnGroundEntity* this) { super->action = 2; COLLISION_ON(super); super->z.HALF.HI = -0x80; @@ -211,7 +212,7 @@ void sub_08081150(ItemOnGroundEntity* this) { SoundReq(SFX_12D); } -void sub_08081188(ItemOnGroundEntity* this) { +void ItemOnGround_Kind4_Init(ItemOnGroundEntity* this) { super->action = 2; COLLISION_ON(super); if (super->collisionLayer == 2) { @@ -219,24 +220,24 @@ void sub_08081188(ItemOnGroundEntity* this) { } } -void sub_080811AC(ItemOnGroundEntity* this) { +void ItemOnGround_Burried_Init(ItemOnGroundEntity* this) { super->action = 2; super->spriteSettings.draw = 0; - this->unk_6e = GetTileTypeAtEntity(super); + this->originalTile = GetTileTypeAtEntity(super); } -void sub_080811C8(ItemOnGroundEntity* this) { +void ItemOnGround_Sunken_Init(ItemOnGroundEntity* this) { super->action = 2; super->spriteSettings.draw = 0; } -void sub_080811D8(ItemOnGroundEntity* this) { - sub_08081188(this); +void ItemOnGround_Kind9_Init(ItemOnGroundEntity* this) { + ItemOnGround_Kind4_Init(this); SoundReq(SFX_215); } void ItemOnGround_Action1(ItemOnGroundEntity* this) { - if (this->unk_69 != 6) { + if (this->kind != ITEM_ON_GROUND_KIND_6) { ProcessMovement2(super); } else { LinearMoveUpdate(super); @@ -252,13 +253,15 @@ void ItemOnGround_Action1(ItemOnGroundEntity* this) { void ItemOnGround_Action2(ItemOnGroundEntity* this) { static void (*const gUnk_0811E814[])(ItemOnGroundEntity*) = { - sub_08081248, sub_08081248, sub_0808126C, sub_0808127C, nullsub_113, sub_080812A0, - sub_08081248, sub_080812A8, sub_080812E8, nullsub_510, sub_08081248, + ItemOnGround_Kindx_Action2, ItemOnGround_Kindx_Action2, ItemOnGround_Kind2_Action2, + ItemOnGround_Kind3_Action2, ItemOnGround_Kind4_Action2, ItemOnGround_Kind5_Action2, + ItemOnGround_Kindx_Action2, ItemOnGround_Burried_Action2, ItemOnGround_Sunken_Action2, + ItemOnGround_Kind9_Action2, ItemOnGround_Kindx_Action2, }; - gUnk_0811E814[this->unk_69](this); + gUnk_0811E814[this->kind](this); } -void sub_08081248(ItemOnGroundEntity* this) { +void ItemOnGround_Kindx_Action2(ItemOnGroundEntity* this) { sub_08081500(this); if (sub_080814C0(this)) { ItemOnGround_SetFlagAndDelete(this, FALSE); @@ -267,12 +270,12 @@ void sub_08081248(ItemOnGroundEntity* this) { } } -void sub_0808126C(ItemOnGroundEntity* this) { +void ItemOnGround_Kind2_Action2(ItemOnGroundEntity* this) { UpdateAnimationSingleFrame(super); sub_0808153C(this); } -void sub_0808127C(ItemOnGroundEntity* this) { +void ItemOnGround_Kind3_Action2(ItemOnGroundEntity* this) { if (sub_080814C0(this)) { ItemOnGround_SetFlagAndDelete(this, FALSE); } else { @@ -280,24 +283,24 @@ void sub_0808127C(ItemOnGroundEntity* this) { } } -void nullsub_113(ItemOnGroundEntity* this) { +void ItemOnGround_Kind4_Action2(ItemOnGroundEntity* this) { } -void sub_080812A0(ItemOnGroundEntity* this) { +void ItemOnGround_Kind5_Action2(ItemOnGroundEntity* this) { sub_08081500(this); } -void sub_080812A8(ItemOnGroundEntity* this) { - if (GetCollisionDataAtEntity(super) != COLLISION_DATA_15 && this->unk_6e != GetTileTypeAtEntity(super)) { +void ItemOnGround_Burried_Action2(ItemOnGroundEntity* this) { + if (GetCollisionDataAtEntity(super) != COLLISION_DATA_15 && this->originalTile != GetTileTypeAtEntity(super)) { super->direction = 0; super->speed = 0; super->spriteSettings.draw = 1; - this->unk_69 = 0; - sub_080810A8(this); + this->kind = ITEM_ON_GROUND_KIND_0; + ItemOnGround_Kindx_Init(this); } } -void sub_080812E8(ItemOnGroundEntity* this) { +void ItemOnGround_Sunken_Action2(ItemOnGroundEntity* this) { PlayerState* playerState = &gPlayerState; #ifdef EU if ((playerState->swim_state & 0x80) && IsColliding(super, &gPlayerEntity.base)) { @@ -305,11 +308,11 @@ void sub_080812E8(ItemOnGroundEntity* this) { if ((playerState->swim_state & 0x80) && (playerState->flags & PL_MINISH) == 0 && IsColliding(super, &gPlayerEntity.base)) { #endif - sub_080810FC(this); + ItemOnGround_Kind1_Init(this); } } -void nullsub_510(ItemOnGroundEntity* this) { +void ItemOnGround_Kind9_Action2(ItemOnGroundEntity* this) { } void ItemOnGround_Action3(ItemOnGroundEntity* this) { @@ -321,7 +324,7 @@ void ItemOnGround_Action3(ItemOnGroundEntity* this) { super->z.HALF.HI--; other = &gPlayerEntity.base; if (IsColliding(super, other)) { - sub_080810FC(this); + ItemOnGround_Kind1_Init(this); } } } @@ -360,7 +363,7 @@ void sub_080813E8(ItemOnGroundEntity* this) { void sub_080813F0(ItemOnGroundEntity* this) { if (sub_0806F3E4(super)) { - sub_080810FC(this); + ItemOnGround_Kind1_Init(this); } } @@ -372,7 +375,7 @@ void ItemOnGround_SetFlagAndDelete(ItemOnGroundEntity* this, bool32 doSetFlag) { DeleteThisEntity(); } -bool32 sub_08081420(ItemOnGroundEntity* this) { +bool32 ItemOnGround_PickUp(ItemOnGroundEntity* this) { if (CheckShouldPlayItemGetCutscene(this)) { SetEntityPriority(super, PRIO_PLAYER_EVENT); CreateItemEntity(super->type, super->type2, 0); @@ -418,7 +421,7 @@ void sub_0808148C(u32 arg0) { } void sub_080814A4(ItemOnGroundEntity* this) { - if (this->unk_69 == 10) { + if (this->kind == ITEM_ON_GROUND_KIND_10) { this->unk_6c = 120; } else { this->unk_6c = 600; @@ -489,7 +492,7 @@ void sub_08081598(ItemOnGroundEntity* this) { super->child = &gPlayerEntity.base; CopyPosition(super->child, super); super->z.HALF.HI -= 4; - if (super->type != 0x5F && sub_08081420(this)) { + if (super->type != ITEM_HEART && ItemOnGround_PickUp(this)) { ItemOnGround_SetFlagAndDelete(this, 1); } }