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] 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; }