From 6b0f125be056b9fe3976fc49e9edf96723112bdb Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Tue, 11 Jan 2022 16:01:04 +0200 Subject: [PATCH 1/2] Match sub_0806D5D4 --- include/player.h | 6 ++++-- src/npc/bigGoron.c | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/player.h b/include/player.h index 583d882b..6ff4018b 100644 --- a/include/player.h +++ b/include/player.h @@ -247,8 +247,7 @@ typedef struct { /*0x08*/ u8 filler[2]; /*0x0a*/ u8 charm; /*0x0b*/ u8 unkB; - /*0x0c*/ u8 itemOnA; - /*0x0d*/ u8 itemOnB; + /*0x0c*/ u8 itemButtons[2]; /*0x0e*/ u8 bottles[4]; /*0x12*/ u8 effect; /*0x13*/ u8 filler3[5]; @@ -260,6 +259,9 @@ typedef struct { /*0x22*/ u8 filler4[4]; } Stats; +#define itemOnA itemButtons[0] +#define itemOnB itemButtons[1] + typedef struct { /*0x0*/ u8 field_0x0; /*0x1*/ u8 behaviorID; diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 7f45152e..7bb9f3e3 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -298,18 +298,16 @@ void sub_0806D514(Entity* this) { ASM_FUNC("asm/non_matching/bigGoron/sub_0806D520.inc", void sub_0806D520(Entity* this, u32 param)) -// TODO itemOnA and itemOnB would need to be in array? -NONMATCH("asm/non_matching/bigGoron/sub_0806D5D4.inc", void sub_0806D5D4(void)) { +void sub_0806D5D4(void) { u32 itemSlot; InitBiggoronTimer(); itemSlot = IsItemEquipped(0xd); if (itemSlot != 2) { - ((u8*)&gSave.stats.itemOnA)[itemSlot] = 0; + gSave.stats.itemButtons[itemSlot] = 0; } sub_0807CAA0(0xd, 0); } -END_NONMATCH void sub_0806D600(Entity* this, ScriptExecutionContext* context) { context->condition = gSave.timers[2] == 0; From 5476829893eb610c84af2a31f39cade246d44cb5 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Wed, 12 Jan 2022 06:23:06 +0200 Subject: [PATCH 2/2] Rename itemOnA and itemOnA, fix jp demo --- include/player.h | 4 ++-- src/code_0805436C.c | 12 ++++++------ src/enemy/likeLike.c | 8 ++++---- src/npc/bladeBrothers.c | 4 ++-- src/npc/npc4E.c | 4 ++-- src/player.c | 6 +++--- src/title.c | 3 +-- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/player.h b/include/player.h index 6ff4018b..09483161 100644 --- a/include/player.h +++ b/include/player.h @@ -259,8 +259,8 @@ typedef struct { /*0x22*/ u8 filler4[4]; } Stats; -#define itemOnA itemButtons[0] -#define itemOnB itemButtons[1] +#define SLOT_A 0 +#define SLOT_B 1 typedef struct { /*0x0*/ u8 field_0x0; diff --git a/src/code_0805436C.c b/src/code_0805436C.c index 729460d7..72da2bf9 100644 --- a/src/code_0805436C.c +++ b/src/code_0805436C.c @@ -37,9 +37,9 @@ extern u8 gUnk_080FE1DD[]; u32 IsItemEquipped(u32 itemID) { u32 itemSlot; - if (itemID == gSave.stats.itemOnA) + if (itemID == gSave.stats.itemButtons[SLOT_A]) itemSlot = 0; - else if (itemID == gSave.stats.itemOnB) + else if (itemID == gSave.stats.itemButtons[SLOT_B]) itemSlot = 1; else itemSlot = 2; @@ -54,17 +54,17 @@ void PutItemOnSlot(u32 itemID) { } if (itemID2 - 1 < 0x1f) { itemSlot = 2; - if (gSave.stats.itemOnA == 0) { + if (gSave.stats.itemButtons[SLOT_A] == 0) { itemSlot = 0; - } else if (gSave.stats.itemOnB == 0) { + } else if (gSave.stats.itemButtons[SLOT_B] == 0) { itemSlot = 1; } if (itemSlot == 2) { u8 temp = gUnk_080FD5B4[itemID2].unk; - if (temp == gUnk_080FD5B4[gSave.stats.itemOnA].unk) { + if (temp == gUnk_080FD5B4[gSave.stats.itemButtons[SLOT_A]].unk) { itemSlot = 0; } else { - if (temp == gUnk_080FD5B4[gSave.stats.itemOnB].unk) { + if (temp == gUnk_080FD5B4[gSave.stats.itemButtons[SLOT_B]].unk) { itemSlot = 1; } } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index df692772..ca5f59e0 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -247,12 +247,12 @@ void sub_080281A0(Entity* this) { bool32 sub_080281E0(u32 param_1) { bool32 ret = FALSE; if (GetInventoryValue(param_1) == 1) { - if (ItemIsShield(gSave.stats.itemOnA)) { - gSave.stats.itemOnA = 0; + if (ItemIsShield(gSave.stats.itemButtons[SLOT_A])) { + gSave.stats.itemButtons[SLOT_A] = 0; } - if (ItemIsShield(gSave.stats.itemOnB)) { - gSave.stats.itemOnB = 0; + if (ItemIsShield(gSave.stats.itemButtons[SLOT_B])) { + gSave.stats.itemButtons[SLOT_B] = 0; } sub_0807CAA0(param_1, 0); diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 8b313f98..0b7de9f5 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -149,10 +149,10 @@ void sub_08068B84(Entity* this) { } void sub_08068BB4(Entity* this) { - u32 item = gSave.stats.itemOnA; + u32 item = gSave.stats.itemButtons[SLOT_A]; this->field_0x68.HALF.HI = item; - item = gSave.stats.itemOnB; + item = gSave.stats.itemButtons[SLOT_B]; *(&this->field_0x68.HALF.HI + 1) = item; } diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index 19c7b63a..2d59b83e 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -176,8 +176,8 @@ u32 sub_0806DBF4(u32 param_1) { } void sub_0806DC3C(Entity* this) { - this->field_0x68.HALF.LO = gSave.stats.itemOnA; - this->field_0x68.HALF.HI = gSave.stats.itemOnB; + this->field_0x68.HALF.LO = gSave.stats.itemButtons[SLOT_A]; + this->field_0x68.HALF.HI = gSave.stats.itemButtons[SLOT_B]; } void sub_0806DC58(Entity* this) { diff --git a/src/player.c b/src/player.c index a76b4013..a9a5ee22 100644 --- a/src/player.c +++ b/src/player.c @@ -3424,10 +3424,10 @@ void SurfaceAction_14(Entity* this) { void SurfaceAction_CloneTile(Entity* this) { if (gPlayerState.field_0xa0[0] == 4) { u32 item, n, i; - if (ItemIsSword(gSave.stats.itemOnA)) { - item = gSave.stats.itemOnA; + if (ItemIsSword(gSave.stats.itemButtons[SLOT_A])) { + item = gSave.stats.itemButtons[SLOT_A]; } else { - item = gSave.stats.itemOnB; + item = gSave.stats.itemButtons[SLOT_B]; } switch (item) { case 1: diff --git a/src/title.c b/src/title.c index fcc6e7c6..e878d784 100644 --- a/src/title.c +++ b/src/title.c @@ -88,8 +88,7 @@ static const SaveFile gDemoSave = { .stats = { .health = 40, .maxHealth = 40, - .itemOnA = ITEM_SHIELD, - .itemOnB = ITEM_SMITH_SWORD, + .itemButtons = { ITEM_SHIELD, ITEM_SMITH_SWORD }, .rupees = 5, }, .fillerD0 = {