Name some more functions in common.c

This commit is contained in:
Catobat 2023-01-08 15:01:18 +01:00
parent 1d2d1cd786
commit 4ab73f8eb7
17 changed files with 36 additions and 36 deletions

View File

@ -792,8 +792,8 @@ gUnk_0800232E:: @ 0800232E
gUnk_08002342:: @ 08002342 gUnk_08002342:: @ 08002342
.incbin "code_080011C4/gUnk_08002342.bin" .incbin "code_080011C4/gUnk_08002342.bin"
non_word_aligned_thumb_func_start sub_08002632 non_word_aligned_thumb_func_start GetFuserId
sub_08002632: @ 0x08002632 GetFuserId: @ 0x08002632
push {r4, r5, r6, r7, lr} push {r4, r5, r6, r7, lr}
ldr r4, _0800269C @ =gUnk_0800232E ldr r4, _0800269C @ =gUnk_0800232E
ldrb r3, [r0, #8] ldrb r3, [r0, #8]

View File

@ -17,7 +17,7 @@ extern void LoadResourceAsync(const void*, u32, u32);
extern void GenericConfused(struct Entity_*); extern void GenericConfused(struct Entity_*);
extern void sub_08001290(struct Entity_*, u32); extern void sub_08001290(struct Entity_*, u32);
extern void GenericKnockback(struct Entity_*); 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 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY);
extern u32 GravityUpdate(struct Entity_*, u32); extern u32 GravityUpdate(struct Entity_*, u32);
extern u32 CheckOnScreen(struct Entity_*); extern u32 CheckOnScreen(struct Entity_*);

View File

@ -122,9 +122,9 @@ void sub_0801E1B8(u32, u32);
void AddKinstoneToBag(u32); void AddKinstoneToBag(u32);
void sub_0801DFB4(struct Entity_*, u32, u32, u32); void sub_0801DFB4(struct Entity_*, u32, u32, u32);
u32 sub_0801E00C(void); u32 sub_0801E00C(void);
bool32 sub_0801E810(u32); bool32 CheckFusionMapMarkerDisabled(u32);
u32 sub_0801DB94(void); u32 sub_0801DB94(void);
u32 sub_0801EA74(u8*); u32 GetRandomSharedFusion(u8*);
typedef struct { typedef struct {
u8 unk_0; u8 unk_0;

View File

@ -64,7 +64,8 @@ typedef struct {
/*0x141*/ u8 fuserProgress[128]; // indexed by fuser id, incremented after fusion /*0x141*/ u8 fuserProgress[128]; // indexed by fuser id, incremented after fusion
/*0x1C1*/ u8 fuserOffers[128]; // available kinstone fusion for each fuser /*0x1C1*/ u8 fuserOffers[128]; // available kinstone fusion for each fuser
/*0x241*/ u8 fusedKinstones[13]; /**< Bitfield for fused kinstones. @see CheckKinstoneFused */ /*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. */ /*0x25C*/ u8 flags[0x200]; /**< Flags. */
/*0x45C*/ u8 dungeonKeys[0x10]; // TODO Indexed by dungeon id, keys per dungeon /*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 /*0x46C*/ u8 dungeonItems[0x10]; // TODO items in the dungeon. 4: compass, 2: big key, 1: small key

View File

@ -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 tmp;
u32 index; u32 index;
if (kinstoneId - 1 < 100) { if (kinstoneId - 1 < 100) {
@ -755,7 +755,7 @@ void sub_0801E6C8(u32 kinstoneId) {
gSave.fuserOffers[index] = 0xf1; gSave.fuserOffers[index] = 0xf1;
} }
} }
tmp = sub_08002632(gFuseInfo.ent); tmp = GetFuserId(gFuseInfo.ent);
if ((tmp - 1 < 0x7f) && (gSave.fuserOffers[tmp] == 0xf1)) { if ((tmp - 1 < 0x7f) && (gSave.fuserOffers[tmp] == 0xf1)) {
gSave.fuserOffers[tmp] = 0xf2; gSave.fuserOffers[tmp] = 0xf2;
} }
@ -818,11 +818,11 @@ u32 CheckKinstoneFused(u32 kinstoneId) {
return ReadBit(&gSave.fusedKinstones, kinstoneId); return ReadBit(&gSave.fusedKinstones, kinstoneId);
} }
bool32 sub_0801E810(u32 kinstoneId) { bool32 CheckFusionMapMarkerDisabled(u32 kinstoneId) {
if (kinstoneId > 100 || kinstoneId < 1) { if (kinstoneId > 100 || kinstoneId < 1) {
return FALSE; return FALSE;
} }
return ReadBit(&gSave.unk24E, kinstoneId); return ReadBit(&gSave.fusionUnmarked, kinstoneId);
} }
void SortKinstoneBag(void) { void SortKinstoneBag(void) {
@ -903,7 +903,7 @@ s32 GetIndexInKinstoneBag(u32 kinstoneId) {
void sub_0801E8D4(void) { void sub_0801E8D4(void) {
u32 kinstoneId; u32 kinstoneId;
for (kinstoneId = 10; kinstoneId <= 100; ++kinstoneId) { for (kinstoneId = 10; kinstoneId <= 100; ++kinstoneId) {
if (CheckKinstoneFused(kinstoneId) && !sub_0801E810(kinstoneId)) { if (CheckKinstoneFused(kinstoneId) && !CheckFusionMapMarkerDisabled(kinstoneId)) {
u32 worldEventId = gKinstoneWorldEvents[kinstoneId].worldEventId; u32 worldEventId = gKinstoneWorldEvents[kinstoneId].worldEventId;
const WorldEvent* s = &gWorldEvents[worldEventId]; const WorldEvent* s = &gWorldEvents[worldEventId];
#if !defined EU && !defined JP #if !defined EU && !defined JP
@ -961,7 +961,7 @@ void sub_0801E8D4(void) {
#else #else
if (sub_0807CB24(tmp, s->flag)) { if (sub_0807CB24(tmp, s->flag)) {
#endif #endif
WriteBit(&gSave.unk24E, kinstoneId); WriteBit(&gSave.fusionUnmarked, kinstoneId);
} }
} }
} }
@ -977,7 +977,7 @@ u32 sub_0801E99C(Entity* entity) {
u8* fuserFusionData; u8* fuserFusionData;
s32 randomMood; s32 randomMood;
u32 fuserStability; u32 fuserStability;
fuserId = sub_08002632(entity); fuserId = GetFuserId(entity);
fuserData = gUnk_08001DCC[fuserId]; fuserData = gUnk_08001DCC[fuserId];
if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0 || fuserData[0] > gSave.global_progress) { if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0 || fuserData[0] > gSave.global_progress) {
return 0; return 0;
@ -999,7 +999,7 @@ u32 sub_0801E99C(Entity* entity) {
offeredFusion = fuserFusionData[5]; offeredFusion = fuserFusionData[5];
} }
if (offeredFusion == 0xFF) { // random shared fusion if (offeredFusion == 0xFF) { // random shared fusion
offeredFusion = sub_0801EA74(fuserData); offeredFusion = GetRandomSharedFusion(fuserData);
} }
if (offeredFusion == 0x00) { // end of fusion list if (offeredFusion == 0x00) { // end of fusion list
offeredFusion = 0xF3; // mark this fuser as done 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 }; 150560, 151584, 152608, 153632, 154656, 155680, 156704, 157728, 158752, 159776, 160800 };
#endif #endif
// TODO maybe KinstoneFlag? const u8 SharedFusions[] = {
const u8 gUnk_080CA11C[] = { 0x18, 0x2D, 0x35, 0x36, 0x37, 0x39, 0x3C, 0x44, 0x46, 0x47, 0x4E, 0x50, 0x53, 0x55, 0x56, 0x58, 0x5F, 0x60, 0, 0,
24, 45, 53, 54, 55, 57, 60, 68, 70, 71, 78, 80, 83, 85, 86, 88, 95, 96, 0, 0,
}; };
// Get a random kinstone // Get a random kinstone
u32 sub_0801EA74(u8* fuserData) { u32 GetRandomSharedFusion(u8* fuserData) {
s32 r = (s32)Random() % 18; s32 r = (s32)Random() % 18;
u32 i; u32 i;
for (i = 0; i < 18; ++i) { for (i = 0; i < 18; ++i) {
u32 kinstoneId = gUnk_080CA11C[r]; u32 kinstoneId = SharedFusions[r];
if (!CheckKinstoneFused(kinstoneId)) if (!CheckKinstoneFused(kinstoneId))
return kinstoneId; return kinstoneId;
r = (r + 1) % 18; r = (r + 1) % 18;

View File

@ -27,7 +27,7 @@ extern u32 sub_08000E44(u32);
extern void sub_080A3B74(void); extern void sub_080A3B74(void);
extern u32 sub_080A3B48(void); extern u32 sub_080A3B48(void);
extern void sub_0805ECEC(u32, u32, u32, u32); extern void sub_0805ECEC(u32, u32, u32, u32);
extern void sub_0801E6C8(u32); extern void NotifyFusersOnFusionDone(u32);
extern void RemoveKinstoneFromBag(u32); extern void RemoveKinstoneFromBag(u32);
extern WStruct* sub_0805F2C8(void); extern WStruct* sub_0805F2C8(void);
extern void sub_0805F300(WStruct*); extern void sub_0805F300(WStruct*);
@ -608,7 +608,7 @@ u32 sub_080A4418(u32 param_1, u32 param_2) {
void KinstoneMenu_080A4468(void) { void KinstoneMenu_080A4468(void) {
gUnk_03003DF0.unk_2 = 0; gUnk_03003DF0.unk_2 = 0;
gUnk_03003DF0.unk_4[3] = 0; gUnk_03003DF0.unk_4[3] = 0;
sub_0801E6C8(gFuseInfo.kinstoneId); NotifyFusersOnFusionDone(gFuseInfo.kinstoneId);
RemoveKinstoneFromBag(gKinstoneMenu.unk2a); RemoveKinstoneFromBag(gKinstoneMenu.unk2a);
} }
@ -625,9 +625,9 @@ u32 KinstoneMenu_080A4494(void) {
psVar1->unk1 = 0; psVar1->unk1 = 0;
sub_080A44E0(psVar1, gSave.name, 0x80); sub_080A44E0(psVar1, gSave.name, 0x80);
#if NON_MATCHING #if NON_MATCHING
ret = sub_080A44E0(psVar1, sub_08002632(gFuseInfo.ent) >> 0x20, 0xa0); ret = sub_080A44E0(psVar1, GetFuserId(gFuseInfo.ent) >> 0x20, 0xa0);
#else #else
sub_08002632(gFuseInfo.ent); GetFuserId(gFuseInfo.ent);
asm("" : "=r"(r1)); asm("" : "=r"(r1));
ret = sub_080A44E0(psVar1, r1, 0xa0); ret = sub_080A44E0(psVar1, r1, 0xa0);
#endif #endif

View File

@ -205,7 +205,7 @@ void sub_080A68D4(void) {
} }
for (i = 10; i <= 100; i++) { for (i = 10; i <= 100; i++) {
if (CheckKinstoneFused(i) && !sub_0801E810(i)) { if (CheckKinstoneFused(i) && !CheckFusionMapMarkerDisabled(i)) {
uVar4 = gKinstoneWorldEvents[i].unk7; uVar4 = gKinstoneWorldEvents[i].unk7;
ptr = &gWorldEvents[gKinstoneWorldEvents[i].worldEventId]; ptr = &gWorldEvents[gKinstoneWorldEvents[i].worldEventId];
sub_080A698C(ptr->_c, ptr->_e, DRAW_DIRECT_SPRITE_INDEX, uVar4 + 100); sub_080A698C(ptr->_c, ptr->_e, DRAW_DIRECT_SPRITE_INDEX, uVar4 + 100);

View File

@ -112,7 +112,7 @@ void sub_0806E65C(Entity* this) {
void Cucco_ShowMessage(Entity* this) { void Cucco_ShowMessage(Entity* this) {
u32 val = 0; u32 val = 0;
u32 index = sub_08002632(this); u32 index = GetFuserId(this);
if (gSave.fuserOffers[index] == 0xf3) { if (gSave.fuserOffers[index] == 0xf3) {
val = 1; val = 1;
} }

View File

@ -31,7 +31,7 @@ void Din(Entity* this) {
void sub_08064828(Entity* this) { void sub_08064828(Entity* this) {
u32 tmp = sub_0801E99C(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; tmp = 0;
} }
sub_08078784(this, tmp); sub_08078784(this, tmp);

View File

@ -31,7 +31,7 @@ void Farore(Entity* this) {
void sub_08064A28(Entity* this) { void sub_08064A28(Entity* this) {
u32 tmp = sub_0801E99C(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; tmp = 0;
} }
sub_08078784(this, tmp); sub_08078784(this, tmp);

View File

@ -26,7 +26,7 @@ void HurdyGurdyMan(Entity* this) {
this->interactType = 0; this->interactType = 0;
this->field_0x68.HALF.HI = this->animIndex; this->field_0x68.HALF.HI = this->animIndex;
InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
index = sub_08002632(this); index = GetFuserId(this);
pointerToArray = gUnk_08001A7C[index]; pointerToArray = gUnk_08001A7C[index];
if (this->field_0x68.HALF.LO == 0x32) { if (this->field_0x68.HALF.LO == 0x32) {
pointerToArray = pointerToArray + 3; pointerToArray = pointerToArray + 3;

View File

@ -31,7 +31,7 @@ void Nayru(Entity* this) {
void sub_08064928(Entity* this) { void sub_08064928(Entity* this) {
u32 tmp = sub_0801E99C(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; tmp = 0;
} }
sub_08078784(this, tmp); sub_08078784(this, tmp);

View File

@ -71,7 +71,7 @@ void sub_0806B41C(Entity* this) {
this->action = 2; this->action = 2;
this->interactType = 0; this->interactType = 0;
InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4); InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4);
idx = sub_08002632(this); idx = GetFuserId(this);
tmp = gUnk_08001A7C[idx]; tmp = gUnk_08001A7C[idx];
if (this->field_0x68.HALF.LO == 33) if (this->field_0x68.HALF.LO == 33)
tmp += 3; tmp += 3;

View File

@ -134,7 +134,7 @@ void sub_08064F28(Entity* this, ScriptExecutionContext* context) {
context->condition = 0; context->condition = 0;
roomFlag = gUnk_0810FC50[this->type]; roomFlag = gUnk_0810FC50[this->type];
if (CheckRoomFlag(roomFlag) == 0) { if (CheckRoomFlag(roomFlag) == 0) {
bVar2 = gSave.fuserProgress[sub_08002632(this)]; bVar2 = gSave.fuserProgress[GetFuserId(this)];
if (bVar2 >= 2) { if (bVar2 >= 2) {
uVar5 = 3; uVar5 = 3;
} else { } else {

View File

@ -327,7 +327,7 @@ void CollideFollowers(void) {
} }
void sub_0806F118(Entity* ent) { void sub_0806F118(Entity* ent) {
u32 idx = sub_08002632(ent); u32 idx = GetFuserId(ent);
NPCData* data = gUnk_08001A7C[idx]; NPCData* data = gUnk_08001A7C[idx];
sub_0801DFB4(ent, data->textIndex, data->_2, data->_4); sub_0801DFB4(ent, data->textIndex, data->_2, data->_4);
gPlayerState.controlMode = CONTROL_DISABLED; gPlayerState.controlMode = CONTROL_DISABLED;
@ -353,7 +353,7 @@ u32 UpdateFuseInteraction(Entity* ent) {
} }
void sub_0806F188(Entity* ent) { void sub_0806F188(Entity* ent) {
u32 idx = sub_08002632(ent); u32 idx = GetFuserId(ent);
if (idx != 0) if (idx != 0)
gSave.fuserOffers[idx] = 0xF3; gSave.fuserOffers[idx] = 0xF3;
} }

View File

@ -44,14 +44,14 @@ void Object37_Init(Object37Entity* this) {
void Object37_Action1(Object37Entity* this) { void Object37_Action1(Object37Entity* this) {
Entity* item; 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); item = CreateGroundItem(super, ITEM_RUPEE100, 0);
if (item != 0) { if (item != 0) {
item->direction = gPlayerEntity.animationState << 2; item->direction = gPlayerEntity.animationState << 2;
item->speed = 0x80; item->speed = 0x80;
item->zVelocity = Q_16_16(2.0); item->zVelocity = Q_16_16(2.0);
} }
gSave.unk24E[0] = 1; gSave.fusionUnmarked[0] = 1;
DeleteThisEntity(); DeleteThisEntity();
} }
} }

View File

@ -1822,7 +1822,7 @@ void sub_0807F634(Entity* entity, ScriptExecutionContext* context) {
} }
void sub_0807F650(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]); sub_0801DFB4(entity, gUnk_08001A7C[p][0], gUnk_08001A7C[p][1], gUnk_08001A7C[p][2]);
gPlayerState.controlMode = CONTROL_DISABLED; gPlayerState.controlMode = CONTROL_DISABLED;
} }