From 1cb62deadddf29f7d6d5e22bf2e92cdb1b16794e Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sat, 7 Jan 2023 20:51:24 +0100 Subject: [PATCH 01/14] Fix Kinstone constant names --- include/item.h | 4 ++-- src/gameData.c | 6 +++--- src/itemUtils.c | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/item.h b/include/item.h index 97fa95a8..20087141 100644 --- a/include/item.h +++ b/include/item.h @@ -147,9 +147,9 @@ typedef enum { ITEM_SKILL_LONG_SPIN, // these are not actually item ids but special values used by item drops for example - ITEM_KINSTONE_GREEN = 0xfc, + ITEM_KINSTONE_RED = 0xfc, ITEM_KINSTONE_BLUE, - ITEM_KINSTONE_RED, + ITEM_KINSTONE_GREEN, ITEM_ENEMY_BEETLE } Item; diff --git a/src/gameData.c b/src/gameData.c index 26462587..12407475 100644 --- a/src/gameData.c +++ b/src/gameData.c @@ -10,9 +10,9 @@ // extern const u8 gUnk_080FE1B4[]; // const u8 gUnk_080FE1B4[] = {0, 84, 85, 86, 95, 96, 93, 94, 63, 252, 253, 254, 255, 0, 0, 0,0,}; const u8 gUnk_080FE1B4[] = { - ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY, - ITEM_BOMBS5, ITEM_ARROWS5, ITEM_SHELLS, ITEM_KINSTONE_GREEN, ITEM_KINSTONE_BLUE, ITEM_KINSTONE_RED, - ITEM_ENEMY_BEETLE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY, + ITEM_BOMBS5, ITEM_ARROWS5, ITEM_SHELLS, ITEM_KINSTONE_RED, ITEM_KINSTONE_BLUE, ITEM_KINSTONE_GREEN, + ITEM_ENEMY_BEETLE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, }; const u8 gUnk_080FE1C6[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 10, 10, 11, 12, 13, 14, 15, 8, 15, 1, 8, diff --git a/src/itemUtils.c b/src/itemUtils.c index 97201c9c..dc53d28c 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -408,9 +408,9 @@ extern u32 sub_08000F2C(s16*, const s16*, const s16*, const s16*); 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, - ITEM_BOMBS5, ITEM_ARROWS5, ITEM_SHELLS, ITEM_KINSTONE_GREEN, ITEM_KINSTONE_BLUE, ITEM_KINSTONE_RED, - ITEM_ENEMY_BEETLE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY, + ITEM_BOMBS5, ITEM_ARROWS5, ITEM_SHELLS, ITEM_KINSTONE_RED, ITEM_KINSTONE_BLUE, ITEM_KINSTONE_GREEN, + ITEM_ENEMY_BEETLE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, }*/; int r0, r1, rand, summOdds, item; @@ -539,7 +539,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) { break; } case ITEM_KINSTONE: - case ITEM_KINSTONE_GREEN ... ITEM_KINSTONE_RED: { + case ITEM_KINSTONE_RED ... ITEM_KINSTONE_GREEN: { u32 rand; if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0) { @@ -550,7 +550,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) { } if (itemId != ITEM_KINSTONE) { - adjustedParam = itemId - ITEM_KINSTONE_GREEN; + adjustedParam = itemId - ITEM_KINSTONE_RED; rand = (Random() & 0x3f); adjustedParam = gUnk_080FE1DD[(rand + adjustedParam * 0x40)]; if (adjustedParam == 0) { From fba95b9ff778a83706806b15924e63862937d214 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sat, 7 Jan 2023 21:48:05 +0100 Subject: [PATCH 02/14] Make gUnk_080FE1DD a 2D array --- src/gameData.c | 24 ++++++++++++++---------- src/itemUtils.c | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/gameData.c b/src/gameData.c index 12407475..3009474c 100644 --- a/src/gameData.c +++ b/src/gameData.c @@ -17,17 +17,21 @@ const u8 gUnk_080FE1B4[] = { const u8 gUnk_080FE1C6[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 10, 10, 11, 12, 13, 14, 15, 8, 15, 1, 8, }; -const u8 gUnk_080FE1DD[] = { - 110, 111, 112, 112, 110, 111, 111, 112, 110, 110, 112, 111, 112, 111, 110, 110, 110, 111, 112, 112, 110, 111, - 111, 112, 110, 110, 112, 111, 112, 111, 110, 111, 110, 111, 112, 112, 110, 111, 111, 112, 110, 110, 112, 111, - 112, 111, 110, 112, 110, 111, 112, 112, 110, 111, 111, 112, 110, 110, 112, 111, 112, 111, 110, 0, 113, 114, - 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, - 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, - 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 115, 116, 117, 117, - 115, 116, 116, 117, 115, 115, 117, 116, 117, 116, 115, 115, 115, 116, 117, 117, 115, 116, 116, 117, 115, 115, - 117, 116, 117, 116, 115, 116, 115, 116, 117, 117, 115, 116, 116, 117, 115, 115, 117, 116, 117, 116, 115, 117, - 115, 116, 117, 117, 115, 116, 116, 117, 115, 115, 117, 116, 117, 116, 115, 0, 0, 0, 0, +const u8 gUnk_080FE1DD[3][0x40] = { + { 0x6E, 0x6F, 0x70, 0x70, 0x6E, 0x6F, 0x6F, 0x70, 0x6E, 0x6E, 0x70, 0x6F, 0x70, 0x6F, 0x6E, 0x6E, + 0x6E, 0x6F, 0x70, 0x70, 0x6E, 0x6F, 0x6F, 0x70, 0x6E, 0x6E, 0x70, 0x6F, 0x70, 0x6F, 0x6E, 0x6F, + 0x6E, 0x6F, 0x70, 0x70, 0x6E, 0x6F, 0x6F, 0x70, 0x6E, 0x6E, 0x70, 0x6F, 0x70, 0x6F, 0x6E, 0x70, + 0x6E, 0x6F, 0x70, 0x70, 0x6E, 0x6F, 0x6F, 0x70, 0x6E, 0x6E, 0x70, 0x6F, 0x70, 0x6F, 0x6E, 0x00 }, + { 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, + 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, + 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, + 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72 }, + { 0x73, 0x74, 0x75, 0x75, 0x73, 0x74, 0x74, 0x75, 0x73, 0x73, 0x75, 0x74, 0x75, 0x74, 0x73, 0x73, + 0x73, 0x74, 0x75, 0x75, 0x73, 0x74, 0x74, 0x75, 0x73, 0x73, 0x75, 0x74, 0x75, 0x74, 0x73, 0x74, + 0x73, 0x74, 0x75, 0x75, 0x73, 0x74, 0x74, 0x75, 0x73, 0x73, 0x75, 0x74, 0x75, 0x74, 0x73, 0x75, + 0x73, 0x74, 0x75, 0x75, 0x73, 0x74, 0x74, 0x75, 0x73, 0x73, 0x75, 0x74, 0x75, 0x74, 0x73, 0x00 }, }; +const u8 gPadding[3] = { 0, 0, 0 }; void Subtask_WorldEvent_Init(void); void Subtask_WorldEvent_Update(void); diff --git a/src/itemUtils.c b/src/itemUtils.c index dc53d28c..57857c4f 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -508,7 +508,7 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) { return ITEM_NONE; } -extern u8 gUnk_080FE1DD[]; +extern u8 gUnk_080FE1DD[3][0x40]; u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) { u32 adjustedParam = itemParameter; Entity* itemEntity; @@ -552,7 +552,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) { if (itemId != ITEM_KINSTONE) { adjustedParam = itemId - ITEM_KINSTONE_RED; rand = (Random() & 0x3f); - adjustedParam = gUnk_080FE1DD[(rand + adjustedParam * 0x40)]; + adjustedParam = gUnk_080FE1DD[adjustedParam][rand]; if (adjustedParam == 0) { itemId = ITEM_NONE; } else { From fbdd0078cd92dc914fe29ea6ac71778ca814bbcc Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sat, 7 Jan 2023 22:54:36 +0100 Subject: [PATCH 03/14] Give unk141 and unk1C1 in SaveFile names --- include/save.h | 4 ++-- src/common.c | 16 ++++++++-------- src/npc/cucco.c | 2 +- src/npc/din.c | 2 +- src/npc/farore.c | 2 +- src/npc/nayru.c | 2 +- src/npc/tingleSiblings.c | 2 +- src/npcUtils.c | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/save.h b/include/save.h index 5fe9c04b..4d5e6d06 100644 --- a/include/save.h +++ b/include/save.h @@ -60,8 +60,8 @@ typedef struct { /*0x117*/ u8 fusedKinstoneCount; /*0x118*/ u8 unk118[0x13]; // TODO also related to kinstones /*0x12B*/ u8 unk12B[0x16]; // TODO also related to kinstones - /*0x141*/ u8 unk141[128]; // TODO sub_08064F28 and also the goddesses, indexed by sub_08002632 - /*0x1C1*/ u8 unk1C1[128]; // TODO also related to kinstones, see sub_0801E6C8 0x80 available kinstone fusions? + /*0x141*/ u8 fuserProgress[128]; // indexed by fuser id, incremented after fusion + /*0x1C1*/ u8 fuserOffers[128]; // available kinstone fusion for each fuser /*0x241*/ u8 fusedKinstones[13]; /**< Bitfield for fused kinstones. @see CheckKinstoneFused */ /*0x24E*/ u8 unk24E[14]; // TODO something else with kinstones @see sub_0801E810 /*0x25C*/ u8 flags[0x200]; /**< Flags. */ diff --git a/src/common.c b/src/common.c index 909dd944..f92ea874 100644 --- a/src/common.c +++ b/src/common.c @@ -751,13 +751,13 @@ void sub_0801E6C8(u32 kinstoneId) { u32 index; if (kinstoneId - 1 < 100) { for (index = 0; index < 0x80; index++) { - if (kinstoneId == gSave.unk1C1[index]) { - gSave.unk1C1[index] = 0xf1; + if (kinstoneId == gSave.fuserOffers[index]) { + gSave.fuserOffers[index] = 0xf1; } } tmp = sub_08002632(gFuseInfo.ent); - if ((tmp - 1 < 0x7f) && (gSave.unk1C1[tmp] == 0xf1)) { - gSave.unk1C1[tmp] = 0xf2; + if ((tmp - 1 < 0x7f) && (gSave.fuserOffers[tmp] == 0xf1)) { + gSave.fuserOffers[tmp] = 0xf2; } for (index = 0; index < 0x20; index++) { if (kinstoneId == gUnk_03003DF0.array[index].unk_3) { @@ -982,8 +982,8 @@ u32 sub_0801E99C(Entity* entity) { if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0 || fuserData[0] > gSave.global_progress) { return 0; } - offeredFusion = gSave.unk1C1[fuserId]; - fuserProgress = gSave.unk141[fuserId]; + offeredFusion = gSave.fuserOffers[fuserId]; + fuserProgress = gSave.fuserProgress[fuserId]; fuserFusionData = (u8*)(fuserProgress + (u32)fuserData); while (TRUE) { // loop through fusions for this fuser switch (offeredFusion) { @@ -1013,8 +1013,8 @@ u32 sub_0801E99C(Entity* entity) { } offeredFusion = 0xF1; // already completed, try next fusion in the list } - gSave.unk1C1[fuserId] = offeredFusion; - gSave.unk141[fuserId] = fuserProgress; + gSave.fuserOffers[fuserId] = offeredFusion; + gSave.fuserProgress[fuserId] = fuserProgress; randomMood = Random(); fuserStability = fuserData[1]; if (fuserStability <= randomMood % 100) { diff --git a/src/npc/cucco.c b/src/npc/cucco.c index c79084a8..9944978e 100644 --- a/src/npc/cucco.c +++ b/src/npc/cucco.c @@ -113,7 +113,7 @@ void sub_0806E65C(Entity* this) { void Cucco_ShowMessage(Entity* this) { u32 val = 0; u32 index = sub_08002632(this); - if (gSave.unk1C1[index] == 0xf3) { + if (gSave.fuserOffers[index] == 0xf3) { val = 1; } diff --git a/src/npc/din.c b/src/npc/din.c index 894edab4..19f23540 100644 --- a/src/npc/din.c +++ b/src/npc/din.c @@ -31,7 +31,7 @@ void Din(Entity* this) { void sub_08064828(Entity* this) { u32 tmp = sub_0801E99C(this); - if ((gSave.unk141[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { + if ((gSave.fuserProgress[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } sub_08078784(this, tmp); diff --git a/src/npc/farore.c b/src/npc/farore.c index 32f6e6ee..cbd09a5a 100644 --- a/src/npc/farore.c +++ b/src/npc/farore.c @@ -31,7 +31,7 @@ void Farore(Entity* this) { void sub_08064A28(Entity* this) { u32 tmp = sub_0801E99C(this); - if ((gSave.unk141[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { + if ((gSave.fuserProgress[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } sub_08078784(this, tmp); diff --git a/src/npc/nayru.c b/src/npc/nayru.c index 262b251c..23ab5de6 100644 --- a/src/npc/nayru.c +++ b/src/npc/nayru.c @@ -31,7 +31,7 @@ void Nayru(Entity* this) { void sub_08064928(Entity* this) { u32 tmp = sub_0801E99C(this); - if ((gSave.unk141[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { + if ((gSave.fuserProgress[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } sub_08078784(this, tmp); diff --git a/src/npc/tingleSiblings.c b/src/npc/tingleSiblings.c index 7ca9c778..36819425 100644 --- a/src/npc/tingleSiblings.c +++ b/src/npc/tingleSiblings.c @@ -134,7 +134,7 @@ void sub_08064F28(Entity* this, ScriptExecutionContext* context) { context->condition = 0; roomFlag = gUnk_0810FC50[this->type]; if (CheckRoomFlag(roomFlag) == 0) { - bVar2 = gSave.unk141[sub_08002632(this)]; + bVar2 = gSave.fuserProgress[sub_08002632(this)]; if (bVar2 >= 2) { uVar5 = 3; } else { diff --git a/src/npcUtils.c b/src/npcUtils.c index 190c9338..c66537f3 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -355,7 +355,7 @@ u32 UpdateFuseInteraction(Entity* ent) { void sub_0806F188(Entity* ent) { u32 idx = sub_08002632(ent); if (idx != 0) - gSave.unk1C1[idx] = 0xF3; + gSave.fuserOffers[idx] = 0xF3; } void ShowNPCDialogue(Entity* ent, const Dialog* dia) { From c8d37f73c87f29e2aba1c5970d5f8ee38d8617d2 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sat, 7 Jan 2023 23:19:07 +0100 Subject: [PATCH 04/14] Give unk118 and unk12B in SaveFile names --- include/save.h | 5 +++-- src/common.c | 34 +++++++++++++++++----------------- src/menu/kinstoneMenu.c | 8 ++++---- src/menu/pauseMenu.c | 8 ++++---- src/playerUtils.c | 2 +- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/save.h b/include/save.h index 4d5e6d06..ef5ec931 100644 --- a/include/save.h +++ b/include/save.h @@ -58,8 +58,9 @@ typedef struct { /*0x0F2*/ u8 inventory[36]; /*0x116*/ u8 didAllFusions; /*0x117*/ u8 fusedKinstoneCount; - /*0x118*/ u8 unk118[0x13]; // TODO also related to kinstones - /*0x12B*/ u8 unk12B[0x16]; // TODO also related to kinstones + /*0x118*/ u8 kinstoneTypes[0x13]; // 0x65-0x75 for each kinstone type present in kinstone bag + /*0x12B*/ u8 kinstoneAmounts[0x13]; // amount of each kinstone type above + /*0x13E*/ u8 filler13E[3]; /*0x141*/ u8 fuserProgress[128]; // indexed by fuser id, incremented after fusion /*0x1C1*/ u8 fuserOffers[128]; // available kinstone fusion for each fuser /*0x241*/ u8 fusedKinstones[13]; /**< Bitfield for fused kinstones. @see CheckKinstoneFused */ diff --git a/src/common.c b/src/common.c index f92ea874..8a2e3058 100644 --- a/src/common.c +++ b/src/common.c @@ -776,17 +776,17 @@ void sub_0801E738(u32 param_1) { index = sub_0801E8B0(param_1); if (index < 0) { index = 0; - while (gSave.unk118[index] != 0) { + while (gSave.kinstoneTypes[index] != 0) { index++; } } if ((u32)index < 0x12) { - gSave.unk118[index] = param_1; - tmp = gSave.unk12B[index] + 1; + gSave.kinstoneTypes[index] = param_1; + tmp = gSave.kinstoneAmounts[index] + 1; if (tmp > 99) { tmp = 99; } - gSave.unk12B[index] = tmp; + gSave.kinstoneAmounts[index] = tmp; } } } @@ -794,12 +794,12 @@ void sub_0801E738(u32 param_1) { void sub_0801E798(u32 a1) { s32 idx = sub_0801E8B0(a1); if (idx >= 0) { - s32 next = gSave.unk12B[idx] - 1; + s32 next = gSave.kinstoneAmounts[idx] - 1; if (next <= 0) { - gSave.unk118[idx] = 0; + gSave.kinstoneTypes[idx] = 0; next = 0; } - gSave.unk12B[idx] = next; + gSave.kinstoneAmounts[idx] = next; } } @@ -808,7 +808,7 @@ u32 sub_0801E7D0(u32 a1) { if (tmp < 0) { return 0; } - return gSave.unk12B[tmp]; + return gSave.kinstoneAmounts[tmp]; } u32 CheckKinstoneFused(u32 kinstoneId) { @@ -830,18 +830,18 @@ void sub_0801E82C(void) { u32 r5; for (r5 = 0; r5 < 0x13; r5++) { - if (gSave.unk12B[r5] == 0) { - gSave.unk118[r5] = gSave.unk12B[r5]; + if (gSave.kinstoneAmounts[r5] == 0) { + gSave.kinstoneTypes[r5] = gSave.kinstoneAmounts[r5]; } } - gSave.unk118[0x12] = 0; - gSave.unk12B[0x12] = 0; + gSave.kinstoneTypes[0x12] = 0; + gSave.kinstoneAmounts[0x12] = 0; for (r5 = 0; r5 < 0x12; r5++) { - if ((gSave.unk118[r5] - 0x65) > 0x10) { - MemCopy(&gSave.unk118[r5 + 1], &gSave.unk118[r5], 0x12 - r5); - MemCopy(&gSave.unk12B[r5 + 1], &gSave.unk12B[r5], 0x12 - r5); + if ((gSave.kinstoneTypes[r5] - 0x65) > 0x10) { + MemCopy(&gSave.kinstoneTypes[r5 + 1], &gSave.kinstoneTypes[r5], 0x12 - r5); + MemCopy(&gSave.kinstoneAmounts[r5 + 1], &gSave.kinstoneAmounts[r5], 0x12 - r5); } } #else @@ -852,7 +852,7 @@ void sub_0801E82C(void) { new_var = 4; r1 = &gSave.inventory[34]; r5 = 0; - r2 = gSave.unk118; + r2 = gSave.kinstoneTypes; code0_0: r0 = r2[0x13]; r3 = &r1[4]; @@ -893,7 +893,7 @@ s32 sub_0801E8B0(u32 idx) { u32 i; for (i = 0; i < 18; ++i) { - if (idx == gSave.unk118[i]) + if (idx == gSave.kinstoneTypes[i]) return i; } return -1; diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index e9aaad8e..11673e00 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -86,7 +86,7 @@ const ScreenTransitionData gUnk_08128024[] = { u32 sub_080A3B48(void) { u32 index; for (index = 0; index <= 0x12; index++) { - if (gSave.unk12B[index] == 0) { + if (gSave.kinstoneAmounts[index] == 0) { break; } } @@ -206,7 +206,7 @@ void KinstoneMenu_Type1(void) { case A_BUTTON: if (gMenu.column_idx == 2) { tmp3 = gGenericMenu.unk10.i / 0x10000; - gGenericMenu.unk2a = gSave.unk118[tmp3]; + gGenericMenu.unk2a = gSave.kinstoneTypes[tmp3]; SetMenuType(3); } break; @@ -448,7 +448,7 @@ NONMATCH("asm/non_matching/menu/kinstone_menu/KinstoneMenu_080A414C.inc", void K gOamCmd.x = ((gSineTable[(uVar1 + 0x40) & 0xff] * 0x42) / 0x100) - 0x10; iVar2 = gKinstoneMenu.unk10.WORD / 0x10000 + i; if (iVar2 >= 0) { - uVar3 = gSave.unk12B[iVar2]; + uVar3 = gSave.kinstoneAmounts[iVar2]; if (i == 0) { switch (gMenu.column_idx) { case 3: @@ -460,7 +460,7 @@ NONMATCH("asm/non_matching/menu/kinstone_menu/KinstoneMenu_080A414C.inc", void K } } if (0 < uVar3) { - sub_080A42E0(gSave.unk118[iVar2], uVar3); + sub_080A42E0(gSave.kinstoneTypes[iVar2], uVar3); } } } diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index 63f22f28..cb76bee0 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -665,7 +665,7 @@ void sub_080A5594(void) { iVar5 = 0; if (GetInventoryValue(ITEM_KINSTONE_BAG) != 0) { for (i = 0; i < 0x13; i++) { - iVar5 += gSave.unk12B[i]; + iVar5 += gSave.kinstoneAmounts[i]; } if (iVar5 >= 0x50) { @@ -1299,11 +1299,11 @@ void sub_080A6044(void) { gOamCmd._6 = 0; uVar4 = 0; uVar2 = 0; - uVar1 = gSave.unk118[0]; + uVar1 = gSave.kinstoneTypes[0]; while (uVar1 != 0) { gOamCmd.x = (uVar4 & 3) * 0x30 + 0x2b; gOamCmd.y = (uVar4 >> 2) * 0x24 + 0x34; - uVar3 = gSave.unk12B[uVar2]; + uVar3 = gSave.kinstoneAmounts[uVar2]; gMenu.column_idx = 0; sub_080A42E0(uVar1, uVar3); uVar4++; @@ -1314,7 +1314,7 @@ void sub_080A6044(void) { if (0x11 < uVar2) { return; } - uVar1 = gSave.unk118[uVar2]; + uVar1 = gSave.kinstoneTypes[uVar2]; } } } diff --git a/src/playerUtils.c b/src/playerUtils.c index 5b71aebe..47ed9c10 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -1090,7 +1090,7 @@ bool32 sub_080782C0(void) { } if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && ((u8)(gUnk_03003DF0.unk_4[3] - 1) < 100)) { sub_0801E738(0); - if (gSave.unk12B[0] != 0) { + if (gSave.kinstoneAmounts[0] != 0) { gUnk_03003DF0.unk_2 = gUnk_03003DF0.unk_4[3]; *(u8*)(*(int*)(gUnk_03003DF0.unk_4 + 8) + 0x39) = 2; gPlayerState.queued_action = PLAYER_08070E9C; From 1d2d1cd786915571c93f4ac2426729584550f8f9 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sun, 8 Jan 2023 00:13:19 +0100 Subject: [PATCH 05/14] Name some functions in common.c --- include/common.h | 2 +- src/common.c | 34 +++++++++++++++++----------------- src/itemUtils.c | 4 ++-- src/menu/kinstoneMenu.c | 6 +++--- src/menu/pauseMenu.c | 2 +- src/npc/goronMerchant.c | 4 ++-- src/playerUtils.c | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/common.h b/include/common.h index 4fcf2be6..ff4e027a 100644 --- a/include/common.h +++ b/include/common.h @@ -119,7 +119,7 @@ u32 CheckKinstoneFused(u32); void sub_0801E1EC(u32, u32, u32); void sub_0801DD58(u32, u32); void sub_0801E1B8(u32, u32); -void sub_0801E738(u32); +void AddKinstoneToBag(u32); void sub_0801DFB4(struct Entity_*, u32, u32, u32); u32 sub_0801E00C(void); bool32 sub_0801E810(u32); diff --git a/src/common.c b/src/common.c index 8a2e3058..45a413e1 100644 --- a/src/common.c +++ b/src/common.c @@ -36,7 +36,7 @@ void ResetScreenRegs(void); void MessageFromFusionTarget(u32); void sub_0801E24C(s32, s32); void sub_0801E290(u32, u32, u32); -s32 sub_0801E8B0(u32); +s32 GetIndexInKinstoneBag(u32); extern u32 sub_0807CB24(u32, u32); @@ -71,7 +71,7 @@ extern const GfxItem* gGfxGroups[]; extern const u32 gUnk_080C9460[]; -void sub_0801E82C(void); +void SortKinstoneBag(void); extern void* GetRoomProperty(u32, u32, u32); @@ -767,13 +767,13 @@ void sub_0801E6C8(u32 kinstoneId) { } } -void sub_0801E738(u32 param_1) { +void AddKinstoneToBag(u32 kinstoneId) { s32 index; s32 tmp; - sub_0801E82C(); - if (param_1 - 0x65 < 0x11) { - index = sub_0801E8B0(param_1); + SortKinstoneBag(); // sometimes called just for this function + if (kinstoneId - 0x65 < 0x11) { + index = GetIndexInKinstoneBag(kinstoneId); if (index < 0) { index = 0; while (gSave.kinstoneTypes[index] != 0) { @@ -781,7 +781,7 @@ void sub_0801E738(u32 param_1) { } } if ((u32)index < 0x12) { - gSave.kinstoneTypes[index] = param_1; + gSave.kinstoneTypes[index] = kinstoneId; tmp = gSave.kinstoneAmounts[index] + 1; if (tmp > 99) { tmp = 99; @@ -791,8 +791,8 @@ void sub_0801E738(u32 param_1) { } } -void sub_0801E798(u32 a1) { - s32 idx = sub_0801E8B0(a1); +void RemoveKinstoneFromBag(u32 kinstoneId) { + s32 idx = GetIndexInKinstoneBag(kinstoneId); if (idx >= 0) { s32 next = gSave.kinstoneAmounts[idx] - 1; if (next <= 0) { @@ -803,12 +803,12 @@ void sub_0801E798(u32 a1) { } } -u32 sub_0801E7D0(u32 a1) { - s32 tmp = sub_0801E8B0(a1); - if (tmp < 0) { +u32 GetAmountInKinstoneBag(u32 kinstoneId) { + s32 index = GetIndexInKinstoneBag(kinstoneId); + if (index < 0) { return 0; } - return gSave.kinstoneAmounts[tmp]; + return gSave.kinstoneAmounts[index]; } u32 CheckKinstoneFused(u32 kinstoneId) { @@ -825,7 +825,7 @@ bool32 sub_0801E810(u32 kinstoneId) { return ReadBit(&gSave.unk24E, kinstoneId); } -void sub_0801E82C(void) { +void SortKinstoneBag(void) { #ifdef NON_MATCHING u32 r5; @@ -889,11 +889,11 @@ code0_2: #endif } -s32 sub_0801E8B0(u32 idx) { +s32 GetIndexInKinstoneBag(u32 kinstoneId) { u32 i; - for (i = 0; i < 18; ++i) { - if (idx == gSave.kinstoneTypes[i]) + for (i = 0; i < 0x12; ++i) { + if (kinstoneId == gSave.kinstoneTypes[i]) return i; } return -1; diff --git a/src/itemUtils.c b/src/itemUtils.c index 57857c4f..72cd7608 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -114,7 +114,7 @@ u32 GiveItem(Item item, u32 param_2) { gSave.dungeonItems[gArea.dungeon_idx] |= metaData->unk2; break; case 0xd: - sub_0801E738(0x72); + AddKinstoneToBag(0x72); break; case 0x12: if (item == ITEM_BOOMERANG) { @@ -174,7 +174,7 @@ u32 GiveItem(Item item, u32 param_2) { SoundReq(SFX_103); break; case 0x0f: - sub_0801E738(param_2); + AddKinstoneToBag(param_2); break; case 0x10: gSave.stats.walletType++; diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index 11673e00..e30c3adf 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -28,7 +28,7 @@ extern void sub_080A3B74(void); extern u32 sub_080A3B48(void); extern void sub_0805ECEC(u32, u32, u32, u32); extern void sub_0801E6C8(u32); -extern void sub_0801E798(u32); +extern void RemoveKinstoneFromBag(u32); extern WStruct* sub_0805F2C8(void); extern void sub_0805F300(WStruct*); extern u32 sub_0805F76C(u8*, WStruct*); @@ -151,7 +151,7 @@ void KinstoneMenu_Type0(void) { gScreen.bg3.updated = 1; KinstoneMenu_080A4528(); sub_080A4398(); - sub_0801E738(0); + AddKinstoneToBag(0); sub_080A70AC((void*)gUnk_081280DC); SetMenuType(1); SetFade(FADE_BLACK_WHITE | FADE_INSTANT, 8); @@ -609,7 +609,7 @@ void KinstoneMenu_080A4468(void) { gUnk_03003DF0.unk_2 = 0; gUnk_03003DF0.unk_4[3] = 0; sub_0801E6C8(gFuseInfo.kinstoneId); - sub_0801E798(gKinstoneMenu.unk2a); + RemoveKinstoneFromBag(gKinstoneMenu.unk2a); } u32 KinstoneMenu_080A4494(void) { diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index cb76bee0..3af4f5eb 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -1281,7 +1281,7 @@ void PauseMenu_Screen_7(void) { void sub_080A6024(void) { sub_080A70AC((KeyButtonLayout*)&gUnk_08128D60); - sub_0801E738(0); + AddKinstoneToBag(0); sub_080A4398(); SetMenuType(1); } diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 37f9ef3f..f3f9b323 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -13,7 +13,7 @@ extern void (*const gUnk_08111B98[])(Entity*); static const u16 sKinstonePrices[]; -extern u32 sub_0801E7D0(u32); +extern u32 GetAmountInKinstoneBag(u32); void GoronMerchant(Entity* this) { if ((this->flags & ENT_SCRIPTED) != 0) { @@ -132,7 +132,7 @@ static u32 GoronMerchant_GetSalePrice(Entity* this) { void GoronMerchant_TryToBuyKinstone(Entity* this, ScriptExecutionContext* context) { s32 salePrice = GoronMerchant_GetSalePrice(this); if (salePrice <= gSave.stats.rupees) { - if (sub_0801E7D0(gRoomVars.shopItemType2) < 99) { + if (GetAmountInKinstoneBag(gRoomVars.shopItemType2) < 99) { ModRupees(-salePrice); InitItemGetSequence(0x5c, gRoomVars.shopItemType2, 0); gRoomVars.shopItemType = 0; diff --git a/src/playerUtils.c b/src/playerUtils.c index 47ed9c10..30d37295 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -1089,7 +1089,7 @@ bool32 sub_080782C0(void) { } } if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && ((u8)(gUnk_03003DF0.unk_4[3] - 1) < 100)) { - sub_0801E738(0); + AddKinstoneToBag(0); if (gSave.kinstoneAmounts[0] != 0) { gUnk_03003DF0.unk_2 = gUnk_03003DF0.unk_4[3]; *(u8*)(*(int*)(gUnk_03003DF0.unk_4 + 8) + 0x39) = 2; From 4ab73f8eb752722a682d5a610e2e8d2836e4bf38 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sun, 8 Jan 2023 15:01:18 +0100 Subject: [PATCH 06/14] Name some more functions in common.c --- asm/src/code_08001A7C.s | 4 ++-- include/asm.h | 2 +- include/common.h | 4 ++-- include/save.h | 3 ++- src/common.c | 25 ++++++++++++------------- src/menu/kinstoneMenu.c | 8 ++++---- src/menu/pauseMenuScreen6.c | 2 +- src/npc/cucco.c | 2 +- src/npc/din.c | 2 +- src/npc/farore.c | 2 +- src/npc/hurdyGurdyMan.c | 2 +- src/npc/nayru.c | 2 +- src/npc/percy.c | 2 +- src/npc/tingleSiblings.c | 2 +- src/npcUtils.c | 4 ++-- src/object/object37.c | 4 ++-- src/script.c | 2 +- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/asm/src/code_08001A7C.s b/asm/src/code_08001A7C.s index f857963e..a3b5224d 100644 --- a/asm/src/code_08001A7C.s +++ b/asm/src/code_08001A7C.s @@ -792,8 +792,8 @@ gUnk_0800232E:: @ 0800232E gUnk_08002342:: @ 08002342 .incbin "code_080011C4/gUnk_08002342.bin" - non_word_aligned_thumb_func_start sub_08002632 -sub_08002632: @ 0x08002632 + non_word_aligned_thumb_func_start GetFuserId +GetFuserId: @ 0x08002632 push {r4, r5, r6, r7, lr} ldr r4, _0800269C @ =gUnk_0800232E ldrb r3, [r0, #8] diff --git a/include/asm.h b/include/asm.h index 837cebca..1f15a0ea 100644 --- a/include/asm.h +++ b/include/asm.h @@ -17,7 +17,7 @@ extern void LoadResourceAsync(const void*, u32, u32); extern void GenericConfused(struct Entity_*); extern void sub_08001290(struct Entity_*, u32); extern void GenericKnockback(struct Entity_*); -extern u32 sub_08002632(struct Entity_*); +extern u32 GetFuserId(struct Entity_*); extern u32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY); extern u32 GravityUpdate(struct Entity_*, u32); extern u32 CheckOnScreen(struct Entity_*); diff --git a/include/common.h b/include/common.h index ff4e027a..011e5a8a 100644 --- a/include/common.h +++ b/include/common.h @@ -122,9 +122,9 @@ void sub_0801E1B8(u32, u32); void AddKinstoneToBag(u32); void sub_0801DFB4(struct Entity_*, u32, u32, u32); u32 sub_0801E00C(void); -bool32 sub_0801E810(u32); +bool32 CheckFusionMapMarkerDisabled(u32); u32 sub_0801DB94(void); -u32 sub_0801EA74(u8*); +u32 GetRandomSharedFusion(u8*); typedef struct { u8 unk_0; diff --git a/include/save.h b/include/save.h index ef5ec931..5193e692 100644 --- a/include/save.h +++ b/include/save.h @@ -64,7 +64,8 @@ typedef struct { /*0x141*/ u8 fuserProgress[128]; // indexed by fuser id, incremented after fusion /*0x1C1*/ u8 fuserOffers[128]; // available kinstone fusion for each fuser /*0x241*/ u8 fusedKinstones[13]; /**< Bitfield for fused kinstones. @see CheckKinstoneFused */ - /*0x24E*/ u8 unk24E[14]; // TODO something else with kinstones @see sub_0801E810 + /*0x24E*/ u8 fusionUnmarked[13]; /**< Bitfield for disabled fusion map markers. @see CheckFusionMapMarkerDisabled */ + /*0x25B*/ u8 filler25B; /*0x25C*/ u8 flags[0x200]; /**< Flags. */ /*0x45C*/ u8 dungeonKeys[0x10]; // TODO Indexed by dungeon id, keys per dungeon /*0x46C*/ u8 dungeonItems[0x10]; // TODO items in the dungeon. 4: compass, 2: big key, 1: small key diff --git a/src/common.c b/src/common.c index 45a413e1..a205833b 100644 --- a/src/common.c +++ b/src/common.c @@ -746,7 +746,7 @@ void sub_0801E64C(s32 param_1, s32 param_2, s32 param_3, s32 param_4, s32 param_ } } -void sub_0801E6C8(u32 kinstoneId) { +void NotifyFusersOnFusionDone(u32 kinstoneId) { u32 tmp; u32 index; if (kinstoneId - 1 < 100) { @@ -755,7 +755,7 @@ void sub_0801E6C8(u32 kinstoneId) { gSave.fuserOffers[index] = 0xf1; } } - tmp = sub_08002632(gFuseInfo.ent); + tmp = GetFuserId(gFuseInfo.ent); if ((tmp - 1 < 0x7f) && (gSave.fuserOffers[tmp] == 0xf1)) { gSave.fuserOffers[tmp] = 0xf2; } @@ -818,11 +818,11 @@ u32 CheckKinstoneFused(u32 kinstoneId) { return ReadBit(&gSave.fusedKinstones, kinstoneId); } -bool32 sub_0801E810(u32 kinstoneId) { +bool32 CheckFusionMapMarkerDisabled(u32 kinstoneId) { if (kinstoneId > 100 || kinstoneId < 1) { return FALSE; } - return ReadBit(&gSave.unk24E, kinstoneId); + return ReadBit(&gSave.fusionUnmarked, kinstoneId); } void SortKinstoneBag(void) { @@ -903,7 +903,7 @@ s32 GetIndexInKinstoneBag(u32 kinstoneId) { void sub_0801E8D4(void) { u32 kinstoneId; for (kinstoneId = 10; kinstoneId <= 100; ++kinstoneId) { - if (CheckKinstoneFused(kinstoneId) && !sub_0801E810(kinstoneId)) { + if (CheckKinstoneFused(kinstoneId) && !CheckFusionMapMarkerDisabled(kinstoneId)) { u32 worldEventId = gKinstoneWorldEvents[kinstoneId].worldEventId; const WorldEvent* s = &gWorldEvents[worldEventId]; #if !defined EU && !defined JP @@ -961,7 +961,7 @@ void sub_0801E8D4(void) { #else if (sub_0807CB24(tmp, s->flag)) { #endif - WriteBit(&gSave.unk24E, kinstoneId); + WriteBit(&gSave.fusionUnmarked, kinstoneId); } } } @@ -977,7 +977,7 @@ u32 sub_0801E99C(Entity* entity) { u8* fuserFusionData; s32 randomMood; u32 fuserStability; - fuserId = sub_08002632(entity); + fuserId = GetFuserId(entity); fuserData = gUnk_08001DCC[fuserId]; if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0 || fuserData[0] > gSave.global_progress) { return 0; @@ -999,7 +999,7 @@ u32 sub_0801E99C(Entity* entity) { offeredFusion = fuserFusionData[5]; } if (offeredFusion == 0xFF) { // random shared fusion - offeredFusion = sub_0801EA74(fuserData); + offeredFusion = GetRandomSharedFusion(fuserData); } if (offeredFusion == 0x00) { // end of fusion list offeredFusion = 0xF3; // mark this fuser as done @@ -1187,17 +1187,16 @@ const u32 gUnk_080CA06C[] = { 139808, 139808, 140320, 140832, 141344, 141856, 14 150560, 151584, 152608, 153632, 154656, 155680, 156704, 157728, 158752, 159776, 160800 }; #endif -// TODO maybe KinstoneFlag? -const u8 gUnk_080CA11C[] = { - 24, 45, 53, 54, 55, 57, 60, 68, 70, 71, 78, 80, 83, 85, 86, 88, 95, 96, 0, 0, +const u8 SharedFusions[] = { + 0x18, 0x2D, 0x35, 0x36, 0x37, 0x39, 0x3C, 0x44, 0x46, 0x47, 0x4E, 0x50, 0x53, 0x55, 0x56, 0x58, 0x5F, 0x60, 0, 0, }; // Get a random kinstone -u32 sub_0801EA74(u8* fuserData) { +u32 GetRandomSharedFusion(u8* fuserData) { s32 r = (s32)Random() % 18; u32 i; for (i = 0; i < 18; ++i) { - u32 kinstoneId = gUnk_080CA11C[r]; + u32 kinstoneId = SharedFusions[r]; if (!CheckKinstoneFused(kinstoneId)) return kinstoneId; r = (r + 1) % 18; diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index e30c3adf..d81e9573 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -27,7 +27,7 @@ extern u32 sub_08000E44(u32); extern void sub_080A3B74(void); extern u32 sub_080A3B48(void); extern void sub_0805ECEC(u32, u32, u32, u32); -extern void sub_0801E6C8(u32); +extern void NotifyFusersOnFusionDone(u32); extern void RemoveKinstoneFromBag(u32); extern WStruct* sub_0805F2C8(void); extern void sub_0805F300(WStruct*); @@ -608,7 +608,7 @@ u32 sub_080A4418(u32 param_1, u32 param_2) { void KinstoneMenu_080A4468(void) { gUnk_03003DF0.unk_2 = 0; gUnk_03003DF0.unk_4[3] = 0; - sub_0801E6C8(gFuseInfo.kinstoneId); + NotifyFusersOnFusionDone(gFuseInfo.kinstoneId); RemoveKinstoneFromBag(gKinstoneMenu.unk2a); } @@ -625,9 +625,9 @@ u32 KinstoneMenu_080A4494(void) { psVar1->unk1 = 0; sub_080A44E0(psVar1, gSave.name, 0x80); #if NON_MATCHING - ret = sub_080A44E0(psVar1, sub_08002632(gFuseInfo.ent) >> 0x20, 0xa0); + ret = sub_080A44E0(psVar1, GetFuserId(gFuseInfo.ent) >> 0x20, 0xa0); #else - sub_08002632(gFuseInfo.ent); + GetFuserId(gFuseInfo.ent); asm("" : "=r"(r1)); ret = sub_080A44E0(psVar1, r1, 0xa0); #endif diff --git a/src/menu/pauseMenuScreen6.c b/src/menu/pauseMenuScreen6.c index 4bfcd17a..a7fa969c 100644 --- a/src/menu/pauseMenuScreen6.c +++ b/src/menu/pauseMenuScreen6.c @@ -205,7 +205,7 @@ void sub_080A68D4(void) { } for (i = 10; i <= 100; i++) { - if (CheckKinstoneFused(i) && !sub_0801E810(i)) { + if (CheckKinstoneFused(i) && !CheckFusionMapMarkerDisabled(i)) { uVar4 = gKinstoneWorldEvents[i].unk7; ptr = &gWorldEvents[gKinstoneWorldEvents[i].worldEventId]; sub_080A698C(ptr->_c, ptr->_e, DRAW_DIRECT_SPRITE_INDEX, uVar4 + 100); diff --git a/src/npc/cucco.c b/src/npc/cucco.c index 9944978e..de157e63 100644 --- a/src/npc/cucco.c +++ b/src/npc/cucco.c @@ -112,7 +112,7 @@ void sub_0806E65C(Entity* this) { void Cucco_ShowMessage(Entity* this) { u32 val = 0; - u32 index = sub_08002632(this); + u32 index = GetFuserId(this); if (gSave.fuserOffers[index] == 0xf3) { val = 1; } diff --git a/src/npc/din.c b/src/npc/din.c index 19f23540..ab9d6940 100644 --- a/src/npc/din.c +++ b/src/npc/din.c @@ -31,7 +31,7 @@ void Din(Entity* this) { void sub_08064828(Entity* this) { u32 tmp = sub_0801E99C(this); - if ((gSave.fuserProgress[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { + if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } sub_08078784(this, tmp); diff --git a/src/npc/farore.c b/src/npc/farore.c index cbd09a5a..f45aeb17 100644 --- a/src/npc/farore.c +++ b/src/npc/farore.c @@ -31,7 +31,7 @@ void Farore(Entity* this) { void sub_08064A28(Entity* this) { u32 tmp = sub_0801E99C(this); - if ((gSave.fuserProgress[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { + if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } sub_08078784(this, tmp); diff --git a/src/npc/hurdyGurdyMan.c b/src/npc/hurdyGurdyMan.c index 4decaced..04c91d9d 100644 --- a/src/npc/hurdyGurdyMan.c +++ b/src/npc/hurdyGurdyMan.c @@ -26,7 +26,7 @@ void HurdyGurdyMan(Entity* this) { this->interactType = 0; this->field_0x68.HALF.HI = this->animIndex; InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); - index = sub_08002632(this); + index = GetFuserId(this); pointerToArray = gUnk_08001A7C[index]; if (this->field_0x68.HALF.LO == 0x32) { pointerToArray = pointerToArray + 3; diff --git a/src/npc/nayru.c b/src/npc/nayru.c index 23ab5de6..89d8bbac 100644 --- a/src/npc/nayru.c +++ b/src/npc/nayru.c @@ -31,7 +31,7 @@ void Nayru(Entity* this) { void sub_08064928(Entity* this) { u32 tmp = sub_0801E99C(this); - if ((gSave.fuserProgress[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { + if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } sub_08078784(this, tmp); diff --git a/src/npc/percy.c b/src/npc/percy.c index acb65a57..d04f61d5 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -71,7 +71,7 @@ void sub_0806B41C(Entity* this) { this->action = 2; this->interactType = 0; InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4); - idx = sub_08002632(this); + idx = GetFuserId(this); tmp = gUnk_08001A7C[idx]; if (this->field_0x68.HALF.LO == 33) tmp += 3; diff --git a/src/npc/tingleSiblings.c b/src/npc/tingleSiblings.c index 36819425..0bf334c9 100644 --- a/src/npc/tingleSiblings.c +++ b/src/npc/tingleSiblings.c @@ -134,7 +134,7 @@ void sub_08064F28(Entity* this, ScriptExecutionContext* context) { context->condition = 0; roomFlag = gUnk_0810FC50[this->type]; if (CheckRoomFlag(roomFlag) == 0) { - bVar2 = gSave.fuserProgress[sub_08002632(this)]; + bVar2 = gSave.fuserProgress[GetFuserId(this)]; if (bVar2 >= 2) { uVar5 = 3; } else { diff --git a/src/npcUtils.c b/src/npcUtils.c index c66537f3..cea167ae 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -327,7 +327,7 @@ void CollideFollowers(void) { } void sub_0806F118(Entity* ent) { - u32 idx = sub_08002632(ent); + u32 idx = GetFuserId(ent); NPCData* data = gUnk_08001A7C[idx]; sub_0801DFB4(ent, data->textIndex, data->_2, data->_4); gPlayerState.controlMode = CONTROL_DISABLED; @@ -353,7 +353,7 @@ u32 UpdateFuseInteraction(Entity* ent) { } void sub_0806F188(Entity* ent) { - u32 idx = sub_08002632(ent); + u32 idx = GetFuserId(ent); if (idx != 0) gSave.fuserOffers[idx] = 0xF3; } diff --git a/src/object/object37.c b/src/object/object37.c index 11f54176..800f0fa0 100644 --- a/src/object/object37.c +++ b/src/object/object37.c @@ -44,14 +44,14 @@ void Object37_Init(Object37Entity* this) { void Object37_Action1(Object37Entity* this) { Entity* item; - if ((gSave.unk24E[0] != 0) && (this->unk70 != *this->unk78)) { + if ((gSave.fusionUnmarked[0] != 0) && (this->unk70 != *this->unk78)) { item = CreateGroundItem(super, ITEM_RUPEE100, 0); if (item != 0) { item->direction = gPlayerEntity.animationState << 2; item->speed = 0x80; item->zVelocity = Q_16_16(2.0); } - gSave.unk24E[0] = 1; + gSave.fusionUnmarked[0] = 1; DeleteThisEntity(); } } diff --git a/src/script.c b/src/script.c index 27bea866..1f14de5f 100644 --- a/src/script.c +++ b/src/script.c @@ -1822,7 +1822,7 @@ void sub_0807F634(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F650(Entity* entity, ScriptExecutionContext* context) { - u32 p = sub_08002632(entity); + u32 p = GetFuserId(entity); sub_0801DFB4(entity, gUnk_08001A7C[p][0], gUnk_08001A7C[p][1], gUnk_08001A7C[p][2]); gPlayerState.controlMode = CONTROL_DISABLED; } From 8515634fa98120084c54de11d0d5eeeb8053ce5c Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sun, 8 Jan 2023 16:46:07 +0100 Subject: [PATCH 07/14] Name more functions --- include/kinstone.h | 2 +- include/npc.h | 2 +- src/common.c | 6 +++--- src/enemy/businessScrub.c | 2 +- src/menu/pauseMenu.c | 4 ++-- src/npc/anju.c | 2 +- src/npc/bladeBrothers.c | 2 +- src/npc/brocco.c | 2 +- src/npc/carpenter.c | 2 +- src/npc/cat.c | 2 +- src/npc/cow.c | 2 +- src/npc/cucco.c | 2 +- src/npc/cuccoChick.c | 2 +- src/npc/dampe.c | 2 +- src/npc/din.c | 2 +- src/npc/dog.c | 2 +- src/npc/epona.c | 2 +- src/npc/farmers.c | 2 +- src/npc/farore.c | 2 +- src/npc/festari.c | 2 +- src/npc/forestMinish.c | 2 +- src/npc/gentari.c | 2 +- src/npc/ghostBrothers.c | 2 +- src/npc/gina.c | 2 +- src/npc/goron.c | 2 +- src/npc/gregal.c | 2 +- src/npc/hurdyGurdyMan.c | 2 +- src/npc/kid.c | 2 +- src/npc/kingDaltus.c | 4 ++-- src/npc/librari.c | 2 +- src/npc/malon.c | 2 +- src/npc/mama.c | 2 +- src/npc/mayorHagen.c | 4 ++-- src/npc/melari.c | 2 +- src/npc/ministerPotho.c | 4 ++-- src/npc/mountainMinish.c | 2 +- src/npc/mutoh.c | 2 +- src/npc/nayru.c | 2 +- src/npc/npc4E.c | 2 +- src/npc/percy.c | 2 +- src/npc/pina.c | 2 +- src/npc/postman.c | 4 ++-- src/npc/sittingPerson.c | 2 +- src/npc/smith.c | 4 ++-- src/npc/sturgeon.c | 2 +- src/npc/talon.c | 2 +- src/npc/teachers.c | 2 +- src/npc/tingleSiblings.c | 4 ++-- src/npc/townMinish.c | 2 +- src/npc/townsperson.c | 2 +- src/npc/windTribespeople.c | 2 +- 51 files changed, 60 insertions(+), 60 deletions(-) diff --git a/include/kinstone.h b/include/kinstone.h index 486b4ca9..0b889f13 100644 --- a/include/kinstone.h +++ b/include/kinstone.h @@ -209,7 +209,7 @@ typedef struct { u16 y; /**< Y position of the actual event. */ u16 _c; // see sub_080A6A80, related to _0 and _2 of gUnk_08127F94 u16 _e; // see sub_080A6A80, related to _1 and _3 of gUnk_08127F94 - u8 condition; // TODO some sort of flag determining what type the bank&flag are? see sub_0801E8D4 + u8 condition; // TODO some sort of flag determining what type the bank&flag are? see UpdateVisibleFusionMapMarkers u8 bank; /**< @see LocalBanks */ u16 flag; } WorldEvent; diff --git a/include/npc.h b/include/npc.h index 6f719154..6588f1d4 100644 --- a/include/npc.h +++ b/include/npc.h @@ -86,7 +86,7 @@ void CollideFollowers(void); // TODO move? void sub_08078784(Entity* ent, u32 arg1); u32 sub_0806F5A4(u32); -u32 sub_0801E99C(Entity*); +u32 GetFusionToOffer(Entity*); void sub_08078778(Entity*); void sub_0807000C(Entity*); void sub_080787A8(Entity*, u32); diff --git a/src/common.c b/src/common.c index a205833b..3a0e2618 100644 --- a/src/common.c +++ b/src/common.c @@ -899,8 +899,8 @@ s32 GetIndexInKinstoneBag(u32 kinstoneId) { return -1; } -// Check conditions, something with kinstones -void sub_0801E8D4(void) { +// For example if a chest from a fusion is opened, hide the chest marker +void UpdateVisibleFusionMapMarkers(void) { u32 kinstoneId; for (kinstoneId = 10; kinstoneId <= 100; ++kinstoneId) { if (CheckKinstoneFused(kinstoneId) && !CheckFusionMapMarkerDisabled(kinstoneId)) { @@ -969,7 +969,7 @@ void sub_0801E8D4(void) { extern u8* gUnk_08001DCC[]; -u32 sub_0801E99C(Entity* entity) { +u32 GetFusionToOffer(Entity* entity) { u8* fuserData; u32 fuserId; u32 offeredFusion; diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 9084508b..643b63e6 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -547,7 +547,7 @@ void sub_0802922C(Entity* this) { } void sub_0802925C(Entity* this) { - sub_08078784(this, sub_0801E99C(this)); + sub_08078784(this, GetFusionToOffer(this)); } void sub_08029270(Entity* this) { diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index 3af4f5eb..0b76815b 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -59,14 +59,14 @@ void Subtask_PauseMenu(void) { struct_08127F94* sub_080A6A80(u32, u32); extern u8 gUnk_02034492[]; -void sub_0801E8D4(void); +void UpdateVisibleFusionMapMarkers(void); s32 sub_080A50A0(s32); void PauseMenu_Variant0(void) { struct_08127F94* ptr; int r0, r1; - sub_0801E8D4(); + UpdateVisibleFusionMapMarkers(); sub_080A4D34(); r1 = 4; do { diff --git a/src/npc/anju.c b/src/npc/anju.c index 224978a9..59fa7ce1 100644 --- a/src/npc/anju.c +++ b/src/npc/anju.c @@ -29,7 +29,7 @@ void Anju(Entity* this) { } void sub_0806C354(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index fb31384a..93dbfccc 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -291,7 +291,7 @@ void sub_08068ADC(Entity* this) { void sub_08068AFC(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); sub_0807DD50(this); } diff --git a/src/npc/brocco.c b/src/npc/brocco.c index 5a860d69..28edb9a2 100644 --- a/src/npc/brocco.c +++ b/src/npc/brocco.c @@ -115,7 +115,7 @@ void sub_080636D8(Entity* this) { } void sub_080636F4(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c index a4da0fff..e7781a50 100644 --- a/src/npc/carpenter.c +++ b/src/npc/carpenter.c @@ -92,7 +92,7 @@ void sub_08067304(Entity* this) { } void sub_08067314(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/cat.c b/src/npc/cat.c index 11c85fd3..7eebb148 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -129,7 +129,7 @@ void sub_080677EC(Entity* this) { this->spriteSettings.flipX = 0; } - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); this->hitbox = (Hitbox*)&gUnk_08110EF0; uVar2 = sub_0805ACC0(this); if (uVar2 == 0) { diff --git a/src/npc/cow.c b/src/npc/cow.c index e418ecd9..7c99efb9 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -50,7 +50,7 @@ void sub_08068FC0(Entity* ent) { *(u16*)&ent->field_0x68 = var1; ent->field_0x6a.HWORD = r2; } - ent->field_0x6c.HALF.LO = sub_0801E99C(ent); + ent->field_0x6c.HALF.LO = GetFusionToOffer(ent); InitAnimationForceUpdate(ent, ent->animationState + 4); } diff --git a/src/npc/cucco.c b/src/npc/cucco.c index de157e63..5710d40a 100644 --- a/src/npc/cucco.c +++ b/src/npc/cucco.c @@ -15,7 +15,7 @@ void Cucco(Entity* this) { void Cucco_Init(Entity* this) { this->action++; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_080787A8(this, this->field_0x68.HALF.LO); SetDefaultPriority(this, PRIO_MESSAGE); this->subAction = 0; diff --git a/src/npc/cuccoChick.c b/src/npc/cuccoChick.c index e73045ca..22d29486 100644 --- a/src/npc/cuccoChick.c +++ b/src/npc/cuccoChick.c @@ -23,7 +23,7 @@ void CuccoChick(Entity* this) { void CuccoChick_Init(Entity* this) { this->action++; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_080787A8(this, this->field_0x68.HALF.LO); SetDefaultPriority(this, PRIO_MESSAGE); this->subAction = 0; diff --git a/src/npc/dampe.c b/src/npc/dampe.c index dbdff1e9..6c587232 100644 --- a/src/npc/dampe.c +++ b/src/npc/dampe.c @@ -34,7 +34,7 @@ void Dampe(Entity* this) { } void sub_0806BE3C(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/din.c b/src/npc/din.c index ab9d6940..b803d9a2 100644 --- a/src/npc/din.c +++ b/src/npc/din.c @@ -30,7 +30,7 @@ void Din(Entity* this) { } void sub_08064828(Entity* this) { - u32 tmp = sub_0801E99C(this); + u32 tmp = GetFusionToOffer(this); if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } diff --git a/src/npc/dog.c b/src/npc/dog.c index fef5cd27..e3c287d9 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -206,7 +206,7 @@ void sub_08069B44(Entity* this) { this->timer = 30; this->animationState = 2; this->field_0x6a.HALF.LO = 0xff; - this->field_0x74.HALF.LO = sub_0801E99C(this); + this->field_0x74.HALF.LO = GetFusionToOffer(this); SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 10); if ((this->flags & ENT_SCRIPTED) != 0) { diff --git a/src/npc/epona.c b/src/npc/epona.c index 5c5adafa..544a749d 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -27,7 +27,7 @@ void sub_080659B8(Entity* this) { this->spriteSettings.draw = 1; this->animationState = 6; this->field_0x68.HALF.HI = -1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); InitAnimationForceUpdate(this, this->animationState / 2); } diff --git a/src/npc/farmers.c b/src/npc/farmers.c index 59de6957..1fa4357c 100644 --- a/src/npc/farmers.c +++ b/src/npc/farmers.c @@ -60,7 +60,7 @@ void sub_0806BCC0(Entity* this) { } void sub_0806BCD4(Entity* this) { - sub_08078784(this, sub_0801E99C(this)); + sub_08078784(this, GetFusionToOffer(this)); } void sub_0806BCE8(Entity* this) { diff --git a/src/npc/farore.c b/src/npc/farore.c index f45aeb17..fa5f25c3 100644 --- a/src/npc/farore.c +++ b/src/npc/farore.c @@ -30,7 +30,7 @@ void Farore(Entity* this) { } void sub_08064A28(Entity* this) { - u32 tmp = sub_0801E99C(this); + u32 tmp = GetFusionToOffer(this); if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } diff --git a/src/npc/festari.c b/src/npc/festari.c index 5d698d36..781cc9cf 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -21,7 +21,7 @@ void sub_0805FE10(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; SetDefaultPriority(this, PRIO_MESSAGE); - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); sub_0807DD50(this); } diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index 7f3625f0..9a898c67 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -535,7 +535,7 @@ void ForestMinish(Entity* this) { } void sub_08060090(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/gentari.c b/src/npc/gentari.c index bf7818c1..3ba91821 100644 --- a/src/npc/gentari.c +++ b/src/npc/gentari.c @@ -8,7 +8,7 @@ void Gentari(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; SetDefaultPriority(this, PRIO_MESSAGE); - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); sub_0807DD50(this); break; diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c index e427c01e..afcb7f2b 100644 --- a/src/npc/ghostBrothers.c +++ b/src/npc/ghostBrothers.c @@ -111,7 +111,7 @@ void sub_08065CCC(Entity* this) { } void sub_08065D00(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/gina.c b/src/npc/gina.c index 4a729d2e..0bb49f92 100644 --- a/src/npc/gina.c +++ b/src/npc/gina.c @@ -9,7 +9,7 @@ void Gina(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); sub_0807DD50(this); break; diff --git a/src/npc/goron.c b/src/npc/goron.c index e046f7c9..8056bf52 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -105,7 +105,7 @@ void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65) { } u32 sub_08069480(Entity* this) { - return (u8)sub_0801E99C(this); + return (u8)GetFusionToOffer(this); } void sub_0806948C(Entity* this, ScriptExecutionContext* context) { diff --git a/src/npc/gregal.c b/src/npc/gregal.c index 87333383..7d867bf0 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -155,7 +155,7 @@ void sub_0806CD4C(Entity* this) { } void sub_0806CD58(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/hurdyGurdyMan.c b/src/npc/hurdyGurdyMan.c index 04c91d9d..46ee55f0 100644 --- a/src/npc/hurdyGurdyMan.c +++ b/src/npc/hurdyGurdyMan.c @@ -101,7 +101,7 @@ void sub_0806E418(Entity* this) { } void sub_0806E440(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/kid.c b/src/npc/kid.c index 59e1e87f..7aacefff 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -555,7 +555,7 @@ void sub_08062948(Entity* this, ScriptExecutionContext* context) { } void sub_08062A48(Entity* this, ScriptExecutionContext* context) { - this->field_0x6a.HALF.LO = sub_0801E99C(this); + this->field_0x6a.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x6a.HALF.LO); } diff --git a/src/npc/kingDaltus.c b/src/npc/kingDaltus.c index bc22daa4..2d9c2989 100644 --- a/src/npc/kingDaltus.c +++ b/src/npc/kingDaltus.c @@ -39,7 +39,7 @@ void KingDaltus(Entity* this) { void sub_08066654(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); InitAnimationForceUpdate(this, 2); } @@ -72,7 +72,7 @@ void sub_080666DC(Entity* this) { void sub_080666E4(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); } diff --git a/src/npc/librari.c b/src/npc/librari.c index 5f0b6786..819b5a61 100644 --- a/src/npc/librari.c +++ b/src/npc/librari.c @@ -9,7 +9,7 @@ void Librari(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; this->animationState = this->timer; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); diff --git a/src/npc/malon.c b/src/npc/malon.c index d38be5aa..0270006d 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -43,7 +43,7 @@ void sub_08065888(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; this->animationState = 4; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); sub_0807DD50(this); } diff --git a/src/npc/mama.c b/src/npc/mama.c index 0cbda85b..95758b1c 100644 --- a/src/npc/mama.c +++ b/src/npc/mama.c @@ -93,7 +93,7 @@ void sub_0806C4DC(Entity* this) { } void sub_0806C4F8(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index 5550feb6..1cef31bc 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -11,7 +11,7 @@ void MayorHagen(Entity* this) { case 0: this->action = 1; this->field_0x68.HALF.HI = 0; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); break; @@ -44,7 +44,7 @@ void sub_0806CE5C(Entity* this) { 8, 16, }; - sub_08078784(this, sub_0801E99C(this)); + sub_08078784(this, GetFusionToOffer(this)); sub_08078850(this, 1, 0, gUnk_08113F44); } diff --git a/src/npc/melari.c b/src/npc/melari.c index 7e20dbed..5c72230b 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -101,7 +101,7 @@ void sub_08068780(Entity* this) { } void sub_08068884(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/ministerPotho.c b/src/npc/ministerPotho.c index 72323ed3..9ee87713 100644 --- a/src/npc/ministerPotho.c +++ b/src/npc/ministerPotho.c @@ -60,7 +60,7 @@ void sub_08066864(Entity* this) { case 0: this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); break; case 1: @@ -82,7 +82,7 @@ void sub_08066864(Entity* this) { } void sub_080668F0(Entity* this) { - sub_08078784(this, sub_0801E99C(this)); + sub_08078784(this, GetFusionToOffer(this)); } void sub_08066904(Entity* this) { diff --git a/src/npc/mountainMinish.c b/src/npc/mountainMinish.c index 647b550a..ca0d3574 100644 --- a/src/npc/mountainMinish.c +++ b/src/npc/mountainMinish.c @@ -180,7 +180,7 @@ void sub_08067EF0(Entity* this) { } void sub_08068104(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index d1d5a00a..5cb1691e 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -83,7 +83,7 @@ void sub_080670E4(Entity* this) { } void sub_08067100(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/nayru.c b/src/npc/nayru.c index 89d8bbac..35176f0b 100644 --- a/src/npc/nayru.c +++ b/src/npc/nayru.c @@ -30,7 +30,7 @@ void Nayru(Entity* this) { } void sub_08064928(Entity* this) { - u32 tmp = sub_0801E99C(this); + u32 tmp = GetFusionToOffer(this); if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { tmp = 0; } diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index 3e4bc3c7..42c3b02d 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -83,7 +83,7 @@ u8 sub_0806DA3C(Entity* this) { case 8: case 9: case 10: - result = sub_0801E99C(this); + result = GetFusionToOffer(this); break; } return result; diff --git a/src/npc/percy.c b/src/npc/percy.c index d04f61d5..22753a85 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -162,7 +162,7 @@ void sub_0806B540(Entity* this) { } void sub_0806B60C(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/pina.c b/src/npc/pina.c index 545a4097..00d73a13 100644 --- a/src/npc/pina.c +++ b/src/npc/pina.c @@ -151,7 +151,7 @@ void sub_08063C90(Entity* this) { } void sub_08063CAC(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/postman.c b/src/npc/postman.c index 2bdeedd2..06fa095c 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -234,7 +234,7 @@ void sub_08060528(Entity* this) { this->field_0x68.HALF.HI = 0; this->field_0x6a.HWORD = 0; this->field_0x6c.HALF.HI = 0; - this->field_0x6c.HALF.LO = sub_0801E99C(this); + this->field_0x6c.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); break; case 1: @@ -293,7 +293,7 @@ void sub_08060528(Entity* this) { } void sub_080606C0(Entity* this) { - this->field_0x6c.HALF.LO = sub_0801E99C(this); + this->field_0x6c.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x6c.HALF.LO); } diff --git a/src/npc/sittingPerson.c b/src/npc/sittingPerson.c index 6fc0ec00..b7f7af0c 100644 --- a/src/npc/sittingPerson.c +++ b/src/npc/sittingPerson.c @@ -236,7 +236,7 @@ void SittingPerson_Head(Entity* this) { } void sub_080639D0(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/smith.c b/src/npc/smith.c index e6663737..08013aa7 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -73,7 +73,7 @@ void Smith_Head(Entity* this) { void sub_080660EC(Entity* this) { if (LoadExtraSpriteData(this, gUnk_08110354)) { this->action = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); InitAnimationForceUpdate(this, 2); } } @@ -109,7 +109,7 @@ void sub_08066178(Entity* this) { if (LoadExtraSpriteData(this, gUnk_08110354)) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); } } diff --git a/src/npc/sturgeon.c b/src/npc/sturgeon.c index 7ee3e4bc..d4902142 100644 --- a/src/npc/sturgeon.c +++ b/src/npc/sturgeon.c @@ -141,7 +141,7 @@ void sub_08064C9C(Entity* this) { } void sub_08064CC0(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/talon.c b/src/npc/talon.c index 8de3c789..b2d99ca8 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -78,7 +78,7 @@ void sub_08065608(Entity* this) { if (LoadExtraSpriteData(this, gUnk_0810FEB0)) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); sub_0807DD50(this); } diff --git a/src/npc/teachers.c b/src/npc/teachers.c index 4ff317ad..763bf448 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -43,7 +43,7 @@ void Teachers(Entity* this) { } void sub_0806C674(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_08078784(this, this->field_0x68.HALF.LO); } diff --git a/src/npc/tingleSiblings.c b/src/npc/tingleSiblings.c index 0bf334c9..cb22cf1d 100644 --- a/src/npc/tingleSiblings.c +++ b/src/npc/tingleSiblings.c @@ -68,7 +68,7 @@ void sub_08064DE4(Entity* this) { case 2: if (UpdateFuseInteraction(this)) { this->action = 1; - sub_0801E99C(this); + GetFusionToOffer(this); } break; } @@ -84,7 +84,7 @@ void sub_08064DE4(Entity* this) { } void sub_08064EA4(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); switch (this->type) { case 0: if ((CheckKinstoneFused(KINSTONE_59) != 0) && (GetInventoryValue(ITEM_MAGIC_BOOMERANG) == 0)) { diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 85630b7c..69f729d7 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -208,7 +208,7 @@ void sub_0806ACC4(Entity* this) { this->animationState = delay * 2; this->timer = 0; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); InitializeAnimation(this, (this->animationState / 2) + 8); break; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 4def0fca..862e00f5 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -104,7 +104,7 @@ void sub_08061CEC(Entity* this) { this->field_0x6a.HWORD = (uVar2 >> 0x10); } *(u16*)&this->field_0x6c = uVar2; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD64(this); sub_08061D64(this); } diff --git a/src/npc/windTribespeople.c b/src/npc/windTribespeople.c index 2018581f..d60e0b37 100644 --- a/src/npc/windTribespeople.c +++ b/src/npc/windTribespeople.c @@ -81,7 +81,7 @@ void sub_0806C85C(Entity* this) { void sub_0806C870(Entity* this) { u8 bVar1; - bVar1 = sub_0801E99C(this); + bVar1 = GetFusionToOffer(this); this->field_0x68.HALF.LO = bVar1; sub_08078784(this, this->field_0x68.HALF.LO); } From c88f5cf280c290da3f33a280011fc200ae86dbcf Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sun, 8 Jan 2023 17:47:29 +0100 Subject: [PATCH 08/14] Names in KinstoneWorldEvent struct --- include/kinstone.h | 10 +++++----- src/menu/kinstoneMenu.c | 8 ++++---- src/menu/pauseMenuScreen6.c | 2 +- src/object/cameraTarget.c | 2 +- src/subtask/subtaskLocalMapHint.c | 2 +- src/subtask/subtaskWorldEvent.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/kinstone.h b/include/kinstone.h index 0b889f13..a5c20d44 100644 --- a/include/kinstone.h +++ b/include/kinstone.h @@ -23,13 +23,13 @@ extern FuseInfo gFuseInfo; typedef struct { u8 objPalette; - u8 unk1; - u8 unk2; + u8 gfxOffsetPiece; + u8 gfxOffsetFull; u8 subtask; // SUBTASK_WORLDEVENT or 0 u8 worldEventId; - u8 unk5; - u8 unk6; - u8 unk7; // TODO flag if it shows a map hint? + u8 shape; + u8 bubbleIcon; + u8 mapMarkerIcon; // 0 for no map marker } KinstoneWorldEvent; // Indexed by kinstoneId extern const KinstoneWorldEvent gKinstoneWorldEvents[]; diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index d81e9573..62621f7e 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -265,8 +265,8 @@ void KinstoneMenu_Type3_Overlay0(void) { } void KinstoneMenu_Type3_Overlay1(void) { - u32 temp = gKinstoneWorldEvents[gKinstoneMenu.unk2a].unk5; - if (temp != gKinstoneWorldEvents[gFuseInfo.kinstoneId].unk5) { + u32 temp = gKinstoneWorldEvents[gKinstoneMenu.unk2a].shape; + if (temp != gKinstoneWorldEvents[gFuseInfo.kinstoneId].shape) { SoundReq(SFX_ITEM_SHIELD_BOUNCE); SetMenuType(4); } else { @@ -517,9 +517,9 @@ void sub_080A42E0(u32 kinstoneId, u32 param_2) { const KinstoneWorldEvent* ptr = &gKinstoneWorldEvents[kinstoneId]; if (param_2 == 0xff) { - uVar1 = ptr->unk2; + uVar1 = ptr->gfxOffsetFull; } else { - uVar1 = ptr->unk1; + uVar1 = ptr->gfxOffsetPiece; } iVar4 = sub_080A43A8(uVar1); if ((param_2 != 0) && (param_2 != 0xff)) { diff --git a/src/menu/pauseMenuScreen6.c b/src/menu/pauseMenuScreen6.c index a7fa969c..c9a085c9 100644 --- a/src/menu/pauseMenuScreen6.c +++ b/src/menu/pauseMenuScreen6.c @@ -206,7 +206,7 @@ void sub_080A68D4(void) { for (i = 10; i <= 100; i++) { if (CheckKinstoneFused(i) && !CheckFusionMapMarkerDisabled(i)) { - uVar4 = gKinstoneWorldEvents[i].unk7; + uVar4 = gKinstoneWorldEvents[i].mapMarkerIcon; ptr = &gWorldEvents[gKinstoneWorldEvents[i].worldEventId]; sub_080A698C(ptr->_c, ptr->_e, DRAW_DIRECT_SPRITE_INDEX, uVar4 + 100); } diff --git a/src/object/cameraTarget.c b/src/object/cameraTarget.c index 79b56190..86321cbb 100644 --- a/src/object/cameraTarget.c +++ b/src/object/cameraTarget.c @@ -133,7 +133,7 @@ void CameraTarget_Action2(Entity* this) { bVar2 = this->type2; } ptr = gKinstoneWorldEvents + bVar2; - bVar1 = ptr->unk6; + bVar1 = ptr->bubbleIcon; bVar3 = bVar1 & 1; this->palette.b.b0 = bVar3; temp = gUnk_0811F744[bVar1] < 0; diff --git a/src/subtask/subtaskLocalMapHint.c b/src/subtask/subtaskLocalMapHint.c index 8f9bb133..7a86d5e4 100644 --- a/src/subtask/subtaskLocalMapHint.c +++ b/src/subtask/subtaskLocalMapHint.c @@ -38,7 +38,7 @@ void sub_080A6B04(void) { sub_080A4DB8(6); ptr = &gKinstoneWorldEvents[gFuseInfo.kinstoneId]; ptr2 = &gWorldEvents[ptr->worldEventId]; - bVar1 = ptr->unk7; + bVar1 = ptr->mapMarkerIcon; uVar3 = ptr2->_c; uVar4 = ptr2->_e; uVar2 = sub_080A6A80(uVar3, uVar4)->_4; diff --git a/src/subtask/subtaskWorldEvent.c b/src/subtask/subtaskWorldEvent.c index bae3e921..0c7c5b5b 100644 --- a/src/subtask/subtaskWorldEvent.c +++ b/src/subtask/subtaskWorldEvent.c @@ -58,7 +58,7 @@ void Subtask_WorldEvent_Update(void) { void Subtask_WorldEvent_End(void) { MessageInitialize(); sub_0806F38C(); - if (gKinstoneWorldEvents[gFuseInfo.kinstoneId].unk7 != 0) { + if (gKinstoneWorldEvents[gFuseInfo.kinstoneId].mapMarkerIcon != 0) { // Show the map hint. MenuFadeIn(SUBTASK_LOCALMAPHINT, gUI.field_0x3); } else { From c9e3f39e56214eb14bdd1b26334c94e10e57ee52 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sun, 8 Jan 2023 18:07:37 +0100 Subject: [PATCH 09/14] Goron Merchant adjustments --- src/manager/goronMerchantShopManager.c | 9 +++++---- src/npc/goronMerchant.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/manager/goronMerchantShopManager.c b/src/manager/goronMerchantShopManager.c index 3f6ed6b5..feb2f7c0 100644 --- a/src/manager/goronMerchantShopManager.c +++ b/src/manager/goronMerchantShopManager.c @@ -8,16 +8,17 @@ #include "asm.h" #include "flags.h" #include "object.h" +#include "item.h" typedef struct { u16 minType; - u16 maxType; + u16 numTypes; u16 x; u16 y; } GoronShopSpawnData; void GoronMerchantShopManager_Main(GoronMerchantShopManager* this) { - static const GoronShopSpawnData gUnk_08108D5C[3] = { { 0x6e, 0x3, 0x210, 0x210 }, + static const GoronShopSpawnData shopSpawnData[3] = { { 0x6e, 0x3, 0x210, 0x210 }, { 0x71, 0x2, 0x220, 0x210 }, { 0x73, 0x3, 0x230, 0x210 } }; s32 uVar2; @@ -54,12 +55,12 @@ void GoronMerchantShopManager_Main(GoronMerchantShopManager* this) { this->itemActive[2] = 0; this->itemActive[1] = 0; this->itemActive[0] = 0; - spawnData = gUnk_08108D5C; + spawnData = shopSpawnData; count = 0; for (count = 0; count < 3;) { if (CheckGlobalFlag(GORON_KAKERA_L + count) == 0) { Entity* object = - CreateObject(SHOP_ITEM, 0x5c, ((s32)Random() % spawnData->maxType) + spawnData->minType); + CreateObject(SHOP_ITEM, ITEM_KINSTONE, ((s32)Random() % spawnData->numTypes) + spawnData->minType); if (object != NULL) { object->timer = 1; object->subtimer = count; diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index f3f9b323..a26eb4b1 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -5,6 +5,7 @@ #include "flags.h" #include "save.h" #include "npc.h" +#include "item.h" static u32 GoronMerchant_GetSalePrice(Entity*); @@ -134,7 +135,7 @@ void GoronMerchant_TryToBuyKinstone(Entity* this, ScriptExecutionContext* contex if (salePrice <= gSave.stats.rupees) { if (GetAmountInKinstoneBag(gRoomVars.shopItemType2) < 99) { ModRupees(-salePrice); - InitItemGetSequence(0x5c, gRoomVars.shopItemType2, 0); + InitItemGetSequence(ITEM_KINSTONE, gRoomVars.shopItemType2, 0); gRoomVars.shopItemType = 0; gRoomVars.shopItemType2 = 0; context->condition = 1; From 529c1ef8b9c441df0f4b6574b351b286e3c1cb40 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sun, 8 Jan 2023 18:14:47 +0100 Subject: [PATCH 10/14] Bakery Kinstone stuff --- src/npc/pita.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/npc/pita.c b/src/npc/pita.c index a55c4012..8414accc 100644 --- a/src/npc/pita.c +++ b/src/npc/pita.c @@ -41,10 +41,10 @@ void RemoveAllBakedGoods(void) { bool32 sub_08062EDC(Entity* this, ScriptExecutionContext* context) { u32 tmp; - u32 tmp2; + u32 kinstoneId; static const u8 chanceForPrize[] = { 0x20, 0x40, 0x60, 0x80, 0xFF }; - static const u8 gUnk_0810C435[] = { 0x10, 0x10, 0x10, 0x20, 0x20, 0x30, 0x30, 0x30 }; - static const u8 gUnk_0810C43D[] = { 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 }; + static const u8 chancesPerType[] = { 0x10, 0x10, 0x10, 0x20, 0x20, 0x30, 0x30, 0x30 }; + static const u8 kinstoneTypes[] = { 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 }; //! @bug: tmp is uninitialized, in practice player must have an item here if (GetInventoryValue(ITEM_BRIOCHE) != 0) { @@ -67,9 +67,9 @@ bool32 sub_08062EDC(Entity* this, ScriptExecutionContext* context) { context->condition = FALSE; return FALSE; } else { - tmp = GetRandomByWeight(gUnk_0810C435); - tmp2 = gUnk_0810C43D[tmp]; - InitItemGetSequence(ITEM_KINSTONE, tmp2, 1); + tmp = GetRandomByWeight(chancesPerType); + kinstoneId = kinstoneTypes[tmp]; + InitItemGetSequence(ITEM_KINSTONE, kinstoneId, 1); MessageNoOverlap(TEXT_INDEX(TEXT_BAKERY, 0x5), this); context->condition = TRUE; return TRUE; From 3073318124bbede2bc62102775c7dc5d622a968c Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Sun, 8 Jan 2023 18:20:37 +0100 Subject: [PATCH 11/14] Business Scrub Kinstone stuff --- src/enemy/businessScrub.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 643b63e6..d1333784 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -28,7 +28,7 @@ void sub_0802922C(Entity*); void sub_0802925C(Entity*); extern const struct SalesOffering gUnk_080CC954[]; -extern const u8 gUnk_080CC9C0[]; +extern const u8 kinstoneTypes[]; extern void (*const BusinessScrub_Functions[])(Entity*); extern void (*const gUnk_080CC9E0[])(Entity*); extern const u8 gUnk_080CCA04[]; @@ -258,7 +258,7 @@ void sub_08028CE8(Entity* this) { case 0: subtype = offer->field_0x9; if (subtype == 0xff) { - subtype = gUnk_080CC9C0[Random() & 7]; + subtype = kinstoneTypes[Random() & 7]; } CreateItemEntity(offer->offeredItem, subtype, 0); @@ -577,17 +577,7 @@ const struct SalesOffering gUnk_080CC954[] = { #endif }; -const u8 gUnk_080CC9C0[] = { - 0x6e, - 0x6f, - 0x70, - 0x71, - 0x72, - 0x73, - 0x74, - 0x75, - -}; +const u8 kinstoneTypes[] = { 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 }; void (*const BusinessScrub_Functions[])(Entity*) = { BusinessScrub_OnTick, From 3dd2ccc2110c9131df5c4ef24078f2d281fb34bd Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Mon, 9 Jan 2023 01:16:36 +0100 Subject: [PATCH 12/14] Name and organize Cucco Minigame stuff --- data/scripts/hyruleTown/script_Anju.inc | 12 +- src/object/cuccoMinigame.c | 161 +++++++++++++----------- 2 files changed, 96 insertions(+), 77 deletions(-) diff --git a/data/scripts/hyruleTown/script_Anju.inc b/data/scripts/hyruleTown/script_Anju.inc index adfccdb4..09bf74c8 100644 --- a/data/scripts/hyruleTown/script_Anju.inc +++ b/data/scripts/hyruleTown/script_Anju.inc @@ -16,7 +16,7 @@ script_0801015A: WaitUntilTextboxCloses CheckTextboxResult JumpIfNot script_080101A6 - Call sub_080A1608 + Call CuccoMinigame_TellObjective WaitUntilTextboxCloses EnablePlayerControl CallWithArg CuccoMinigame_Init, script_080101AC @@ -25,7 +25,7 @@ script_0801015A: SetRoomFlag 0x0001 Jump script_0801015A script_0801019E: - Call sub_080A1608 + Call CuccoMinigame_TellObjective WaitUntilTextboxCloses script_080101A6: EnablePlayerControl @@ -60,14 +60,14 @@ script_080101AC: SetFade4 WaitForFadeFinish PlayBGM - Call sub_080A13B4 + Call CuccoMinigame_Results WaitUntilTextboxCloses JumpIfNot script_08010240 - Call sub_080A13E8 + Call CuccoMinigame_WinItem WaitPlayerGetItem - Call sub_080A1460 + Call CuccoMinigame_WinRupees WaitUntilTextboxCloses - Call sub_080A14A8 + Call CuccoMinigame_AdvanceLevel script_08010240: Call EnablePauseMenu EnablePlayerControl diff --git a/src/object/cuccoMinigame.c b/src/object/cuccoMinigame.c index 1d87a6d0..4f3a1489 100644 --- a/src/object/cuccoMinigame.c +++ b/src/object/cuccoMinigame.c @@ -13,23 +13,28 @@ #include "npc.h" #include "object.h" #include "script.h" +#include "item.h" typedef struct { Entity base; - s16 unk68; - s16 unk6a; - s16 unk6c; + s16 timer; + s16 currentCuccos; + s16 targetCuccos; u16 unk6e; - u8 unk70[0x18]; + u8 returnedCuccoTypes[0x18]; } CuccoMinigameEntity; typedef Entity* CuccoMinigameHeap[10]; -u32 sub_080A1514(); +u32 CuccoMinigame_GetLevel(); -const u16 gUnk_08124C20[] = { - 25, 0x2, 25, 0x3, 30, 0x4, 45, 0x5, 50, 0x5, 45, 0x5, 50, 0x6, 60, 0x7, 55, 0x2, 55, 0x3, -}; +typedef struct { + u16 time; + u16 numCuccos; +} CuccoMinigameGoal; + +const CuccoMinigameGoal goalData[10] = { { 25, 2}, { 25, 3}, { 30, 4}, { 45, 5}, { 50, 5}, + { 45, 5}, { 50, 6}, { 60, 7}, { 55, 2}, { 55, 3} }; static const u16 pCuccoMinigame_MinigameCuccoDefs[][30] = { { 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001, @@ -66,9 +71,23 @@ static const u16 pCuccoMinigame_MinigameCuccoDefs[][30] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 } }; -static const u8 gUnk_08124EA0[] = { 0x3F, 0x0A, 0x01, 0x00, 0x3F, 0x0A, 0x01, 0x00, 0x3F, 0x14, 0x01, 0x00, 0x3F, 0x14, - 0x01, 0x00, 0x3F, 0x1E, 0x01, 0x00, 0x3F, 0x1E, 0x01, 0x00, 0x5C, 0x6E, 0x01, 0x00, - 0x5C, 0x6F, 0x01, 0x00, 0x5C, 0x70, 0x01, 0x00, 0x63, 0x00, 0x01, 0x00 }; +typedef struct { + u8 item; + u8 subtype; + u8 unk2; + u8 unk3; +} CuccoMinigamePrizeData; + +static const CuccoMinigamePrizeData prizeData[10] = { { ITEM_SHELLS, 10, 1, 0 }, + { ITEM_SHELLS, 10, 1, 0 }, + { ITEM_SHELLS, 20, 1, 0 }, + { ITEM_SHELLS, 20, 1, 0 }, + { ITEM_SHELLS, 30, 1, 0 }, + { ITEM_SHELLS, 30, 1, 0 }, + { ITEM_KINSTONE, 0x6E, 1, 0 }, + { ITEM_KINSTONE, 0x6F, 1, 0 }, + { ITEM_KINSTONE, 0x70, 1, 0 }, + { ITEM_HEART_PIECE, 0, 1, 0 } }; static const u16 CuccoMinigame_Sounds[] = { SFX_VO_CUCCO5, SFX_VO_CUCCO_CALL }; @@ -78,17 +97,17 @@ void CuccoMinigame(CuccoMinigameEntity* this) { int index; u32 val; u8* puVar2; - const u16* ptr; + const CuccoMinigameGoal* ptr; if (super->action == 0) { super->action++; - ptr = gUnk_08124C20 + sub_080A1514() * 2; - this->unk68 = ptr[0] * 0x3c; - this->unk6a = 0; - this->unk6c = ptr[1]; + ptr = &goalData[CuccoMinigame_GetLevel()]; + this->timer = ptr->time * 60; + this->currentCuccos = 0; + this->targetCuccos = ptr->numCuccos; this->unk6e = 1; - for (puVar2 = this->unk70, val = 0, index = 9; index >= 0; index--) { + for (puVar2 = this->returnedCuccoTypes, val = 0, index = 9; index >= 0; index--) { *puVar2++ = val; } sub_0807DD64(super); @@ -110,7 +129,7 @@ NONMATCH("asm/non_matching/objectB9/sub_080A1270.inc", void sub_080A1270(CuccoMi sVar6 = 0; entArray = ((Entity**)super->myHeap); - ptr = this->unk70; + ptr = this->returnedCuccoTypes; iVar1 = (gRoomControls.origin_x + 0x360); iVar4 = (gRoomControls.origin_y + 0x350); iVar1 = (iVar1 << 16) >> 16; @@ -147,9 +166,9 @@ NONMATCH("asm/non_matching/objectB9/sub_080A1270.inc", void sub_080A1270(CuccoMi } } - this->unk6a = sVar6; + this->currentCuccos = sVar6; gPlayerState.field_0x27[0] = 0xff; - if (--this->unk68 < 1) { + if (--this->timer < 1) { SoundReq(SFX_CUCCO_MINIGAME_BELL); sub_08050384(); } else { @@ -163,7 +182,7 @@ void CuccoMinigame_Cleanup(CuccoMinigameEntity* this) { s8* pcVar2; int index; - pcVar2 = this->unk70; + pcVar2 = this->returnedCuccoTypes; puVar1 = super->myHeap; for (index = 9; index >= 0; index--, pcVar2++, puVar1++) { @@ -174,8 +193,8 @@ void CuccoMinigame_Cleanup(CuccoMinigameEntity* this) { } } -void sub_080A13B4(CuccoMinigameEntity* this, ScriptExecutionContext* context) { - if (this->unk6a >= this->unk6c) { +void CuccoMinigame_Results(CuccoMinigameEntity* this, ScriptExecutionContext* context) { + if (this->currentCuccos >= this->targetCuccos) { MessageFromTarget(TEXT_INDEX(TEXT_ANJU, 0xc)); context->condition = 1; } else { @@ -184,115 +203,115 @@ void sub_080A13B4(CuccoMinigameEntity* this, ScriptExecutionContext* context) { } } -void sub_080A13E8(CuccoMinigameEntity* this) { - bool32 bVar2; - const u8* ptr = &gUnk_08124EA0[sub_080A1514() * 4]; +void CuccoMinigame_WinItem(CuccoMinigameEntity* this) { + bool32 skipItem; + const CuccoMinigamePrizeData* prize = &prizeData[CuccoMinigame_GetLevel()]; - bVar2 = 0; - switch (ptr[0]) { - case 0x3f: + skipItem = 0; + switch (prize->item) { + case ITEM_SHELLS: if (gSave.stats.hasAllFigurines) { - bVar2 = 1; + skipItem = 1; } break; - case 0x5c: + case ITEM_KINSTONE: if (gSave.didAllFusions) { - bVar2 = 1; + skipItem = 1; } break; - case 0x63: + case ITEM_HEART_PIECE: if (!CheckGlobalFlag(ANJU_HEART)) { SetGlobalFlag(ANJU_HEART); break; } - bVar2 = 1; + skipItem = 1; break; } - if (!bVar2) { - InitItemGetSequence(ptr[0], ptr[1], 0); + if (!skipItem) { + InitItemGetSequence(prize->item, prize->subtype, 0); } else { this->unk6e = 2; } } -void sub_080A1460(CuccoMinigameEntity* this) { - s8* pcVar1; - int iVar2; +void CuccoMinigame_WinRupees(CuccoMinigameEntity* this) { + s8* cuccoTypes; + int index; s32 rupees; - const u8* ptr; + const u8* rupeeValues; - sub_080A1514(); - pcVar1 = this->unk70; + CuccoMinigame_GetLevel(); // Rupees previously dependent on level? + cuccoTypes = this->returnedCuccoTypes; rupees = 0; - ptr = CuccoMinigameRupees; + rupeeValues = CuccoMinigameRupees; - for (iVar2 = 9; iVar2 >= 0; iVar2--) { + for (index = 9; index >= 0; index--) { // Only first 10 count? // Weird register addition - // ptr[*pcVar1] translates to add r0,r3,r0 but should be add r0,r3 - u32 temp = *pcVar1; - temp += (int)ptr; + // rupeeValues[*cuccoTypes] translates to add r0,r3,r0 but should be add r0,r3 + u32 temp = *cuccoTypes; + temp += (int)rupeeValues; rupees += *(u8*)temp; - pcVar1++; + cuccoTypes++; } ModRupees(rupees); MessageNoOverlap(TEXT_INDEX(TEXT_ANJU, 0x7), super); gMessage.rupees = (u16)rupees; } -void sub_080A14A8(void) { - int iVar1; +void CuccoMinigame_AdvanceLevel(void) { + int level; - iVar1 = sub_080A1514(); - iVar1++; - if (iVar1 > 9) { - iVar1 = 9; + level = CuccoMinigame_GetLevel(); + level++; + if (level > 9) { + level = 9; } - if (iVar1 & 1) { + if (level & 1) { SetGlobalFlag(ANJU_LV_BIT0); } else { ClearGlobalFlag(ANJU_LV_BIT0); } - if (iVar1 & 2) { + if (level & 2) { SetGlobalFlag(ANJU_LV_BIT1); } else { ClearGlobalFlag(ANJU_LV_BIT1); } - if (iVar1 & 4) { + if (level & 4) { SetGlobalFlag(ANJU_LV_BIT2); } else { ClearGlobalFlag(ANJU_LV_BIT2); } - if (iVar1 & 8) { + if (level & 8) { SetGlobalFlag(ANJU_LV_BIT3); } else { ClearGlobalFlag(ANJU_LV_BIT3); } } -u32 sub_080A1514(void) { - u32 rv = 0; +u32 CuccoMinigame_GetLevel(void) { + u32 level = 0; if (CheckGlobalFlag(ANJU_LV_BIT0)) { - rv = 1; + level = 1; } if (CheckGlobalFlag(ANJU_LV_BIT1)) { - rv |= 2; + level |= 2; } if (CheckGlobalFlag(ANJU_LV_BIT2)) { - rv |= 4; + level |= 4; } if (CheckGlobalFlag(ANJU_LV_BIT3)) { - rv |= 8; + level |= 8; } - return rv; + return level; } void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) { @@ -311,7 +330,7 @@ void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) { } else { *(ScriptExecutionContext**)&((GenericEntity*)pEnt)->cutsceneBeh = (ScriptExecutionContext*)StartCutscene(pEnt, (u16*)context->intVariable); - pCuccoMinigameDef = pCuccoMinigame_MinigameCuccoDefs[sub_080A1514()]; + pCuccoMinigameDef = pCuccoMinigame_MinigameCuccoDefs[CuccoMinigame_GetLevel()]; ppEVar5 = (Entity**)pEnt->myHeap; room = &gRoomControls; for (index = 9; index >= 0; index--, pCuccoMinigameDef += 3) { @@ -332,9 +351,9 @@ void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) { } } -void sub_080A1608(void) { +void CuccoMinigame_TellObjective(void) { u16 messageIndex; - const u16* ptr; + const CuccoMinigameGoal* ptr; messageIndex = TEXT_INDEX(TEXT_ANJU, 0x2); if (CheckRoomFlag(1)) { @@ -343,9 +362,9 @@ void sub_080A1608(void) { MessageFromTarget(messageIndex); gMessage.textWindowPosX = 1; gMessage.textWindowPosY = 0; - ptr = &gUnk_08124C20[sub_080A1514() * 2]; - gMessage.rupees = ptr[0]; - gMessage.field_0x14 = ptr[1]; + ptr = &goalData[CuccoMinigame_GetLevel()]; + gMessage.rupees = ptr->time; + gMessage.field_0x14 = ptr->numCuccos; } void sub_080A1648(void) { From c5a8bcc6a1b1d7abd2ef1c6a8722906e11308485 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Mon, 9 Jan 2023 01:50:55 +0100 Subject: [PATCH 13/14] Formatting --- src/object/cuccoMinigame.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/object/cuccoMinigame.c b/src/object/cuccoMinigame.c index 4f3a1489..6b5b13ad 100644 --- a/src/object/cuccoMinigame.c +++ b/src/object/cuccoMinigame.c @@ -33,8 +33,8 @@ typedef struct { u16 numCuccos; } CuccoMinigameGoal; -const CuccoMinigameGoal goalData[10] = { { 25, 2}, { 25, 3}, { 30, 4}, { 45, 5}, { 50, 5}, - { 45, 5}, { 50, 6}, { 60, 7}, { 55, 2}, { 55, 3} }; +const CuccoMinigameGoal goalData[10] = { { 25, 2 }, { 25, 3 }, { 30, 4 }, { 45, 5 }, { 50, 5 }, + { 45, 5 }, { 50, 6 }, { 60, 7 }, { 55, 2 }, { 55, 3 } }; static const u16 pCuccoMinigame_MinigameCuccoDefs[][30] = { { 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001, @@ -78,16 +78,11 @@ typedef struct { u8 unk3; } CuccoMinigamePrizeData; -static const CuccoMinigamePrizeData prizeData[10] = { { ITEM_SHELLS, 10, 1, 0 }, - { ITEM_SHELLS, 10, 1, 0 }, - { ITEM_SHELLS, 20, 1, 0 }, - { ITEM_SHELLS, 20, 1, 0 }, - { ITEM_SHELLS, 30, 1, 0 }, - { ITEM_SHELLS, 30, 1, 0 }, - { ITEM_KINSTONE, 0x6E, 1, 0 }, - { ITEM_KINSTONE, 0x6F, 1, 0 }, - { ITEM_KINSTONE, 0x70, 1, 0 }, - { ITEM_HEART_PIECE, 0, 1, 0 } }; +static const CuccoMinigamePrizeData prizeData[10] = { { ITEM_SHELLS, 10, 1, 0 }, { ITEM_SHELLS, 10, 1, 0 }, + { ITEM_SHELLS, 20, 1, 0 }, { ITEM_SHELLS, 20, 1, 0 }, + { ITEM_SHELLS, 30, 1, 0 }, { ITEM_SHELLS, 30, 1, 0 }, + { ITEM_KINSTONE, 0x6E, 1, 0 }, { ITEM_KINSTONE, 0x6F, 1, 0 }, + { ITEM_KINSTONE, 0x70, 1, 0 }, { ITEM_HEART_PIECE, 0, 1, 0 } }; static const u16 CuccoMinigame_Sounds[] = { SFX_VO_CUCCO5, SFX_VO_CUCCO_CALL }; From ae16a42a0b197f8b733b70c77f94d6da187f9709 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Mon, 9 Jan 2023 01:53:52 +0100 Subject: [PATCH 14/14] Formatting, but why? --- src/object/cuccoMinigame.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/object/cuccoMinigame.c b/src/object/cuccoMinigame.c index 6b5b13ad..f6b02dd1 100644 --- a/src/object/cuccoMinigame.c +++ b/src/object/cuccoMinigame.c @@ -78,11 +78,11 @@ typedef struct { u8 unk3; } CuccoMinigamePrizeData; -static const CuccoMinigamePrizeData prizeData[10] = { { ITEM_SHELLS, 10, 1, 0 }, { ITEM_SHELLS, 10, 1, 0 }, - { ITEM_SHELLS, 20, 1, 0 }, { ITEM_SHELLS, 20, 1, 0 }, - { ITEM_SHELLS, 30, 1, 0 }, { ITEM_SHELLS, 30, 1, 0 }, - { ITEM_KINSTONE, 0x6E, 1, 0 }, { ITEM_KINSTONE, 0x6F, 1, 0 }, - { ITEM_KINSTONE, 0x70, 1, 0 }, { ITEM_HEART_PIECE, 0, 1, 0 } }; +static const CuccoMinigamePrizeData prizeData[10] = { { ITEM_SHELLS, 10, 1, 0 }, { ITEM_SHELLS, 10, 1, 0 }, + { ITEM_SHELLS, 20, 1, 0 }, { ITEM_SHELLS, 20, 1, 0 }, + { ITEM_SHELLS, 30, 1, 0 }, { ITEM_SHELLS, 30, 1, 0 }, + { ITEM_KINSTONE, 0x6E, 1, 0 }, { ITEM_KINSTONE, 0x6F, 1, 0 }, + { ITEM_KINSTONE, 0x70, 1, 0 }, { ITEM_HEART_PIECE, 0, 1, 0 } }; static const u16 CuccoMinigame_Sounds[] = { SFX_VO_CUCCO5, SFX_VO_CUCCO_CALL };