summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCatobat <69204835+Catobat@users.noreply.github.com>2023-04-29 02:56:08 +0200
committerCatobat <69204835+Catobat@users.noreply.github.com>2023-04-29 02:56:08 +0200
commitfcfbd73dd26284d6b89bec62483502a9e13aecdc (patch)
treee14abf47a47c4d376ce2a3a0b528de4f89d25dcd /src
parenta82ad2951a2d78533fb18bf08203cb4b3256a2f1 (diff)
Name the special values used with Kinstone Fusions
Diffstat (limited to 'src')
-rw-r--r--src/common.c56
-rw-r--r--src/enemy/businessScrub.c3
-rw-r--r--src/menu/kinstoneMenu.c6
-rw-r--r--src/menu/pauseMenu.c3
-rw-r--r--src/npc/cucco.c3
-rw-r--r--src/npc/din.c7
-rw-r--r--src/npc/farore.c7
-rw-r--r--src/npc/nayru.c7
-rw-r--r--src/npc/npc4E.c4
-rw-r--r--src/npcUtils.c2
-rw-r--r--src/playerUtils.c6
11 files changed, 54 insertions, 50 deletions
diff --git a/src/common.c b/src/common.c
index 24dba48d..e3f962b4 100644
--- a/src/common.c
+++ b/src/common.c
@@ -831,28 +831,28 @@ void sub_0801E64C(s32 param_1, s32 param_2, s32 param_3, s32 param_4, s32 param_
}
}
-void NotifyFusersOnFusionDone(u32 kinstoneId) {
+void NotifyFusersOnFusionDone(KinstoneId kinstoneId) {
u32 tmp;
u32 index;
if (kinstoneId - 1 < 100) {
for (index = 0; index < 0x80; index++) {
if (kinstoneId == gSave.fuserOffers[index]) {
- gSave.fuserOffers[index] = 0xf1;
+ gSave.fuserOffers[index] = KINSTONE_NEEDS_REPLACEMENT;
}
}
tmp = GetFuserId(gFuseInfo.ent);
- if ((tmp - 1 < 0x7f) && (gSave.fuserOffers[tmp] == 0xf1)) {
- gSave.fuserOffers[tmp] = 0xf2;
+ if ((tmp - 1 < 0x7f) && (gSave.fuserOffers[tmp] == KINSTONE_NEEDS_REPLACEMENT)) {
+ gSave.fuserOffers[tmp] = KINSTONE_JUST_FUSED;
}
for (index = 0; index < 0x20; index++) {
if (kinstoneId == gPossibleInteraction.candidates[index].kinstoneId) {
- gPossibleInteraction.candidates[index].kinstoneId = 0xf1;
+ gPossibleInteraction.candidates[index].kinstoneId = KINSTONE_NEEDS_REPLACEMENT;
}
}
}
}
-void AddKinstoneToBag(u32 kinstoneId) {
+void AddKinstoneToBag(KinstoneId kinstoneId) {
s32 index;
s32 tmp;
@@ -861,7 +861,7 @@ void AddKinstoneToBag(u32 kinstoneId) {
index = GetIndexInKinstoneBag(kinstoneId);
if (index < 0) {
index = 0;
- while (gSave.kinstoneTypes[index] != 0) {
+ while (gSave.kinstoneTypes[index] != KINSTONE_NONE) {
index++;
}
}
@@ -876,19 +876,19 @@ void AddKinstoneToBag(u32 kinstoneId) {
}
}
-void RemoveKinstoneFromBag(u32 kinstoneId) {
+void RemoveKinstoneFromBag(KinstoneId kinstoneId) {
s32 idx = GetIndexInKinstoneBag(kinstoneId);
if (idx >= 0) {
s32 next = gSave.kinstoneAmounts[idx] - 1;
if (next <= 0) {
- gSave.kinstoneTypes[idx] = 0;
+ gSave.kinstoneTypes[idx] = KINSTONE_NONE;
next = 0;
}
gSave.kinstoneAmounts[idx] = next;
}
}
-u32 GetAmountInKinstoneBag(u32 kinstoneId) {
+u32 GetAmountInKinstoneBag(KinstoneId kinstoneId) {
s32 index = GetIndexInKinstoneBag(kinstoneId);
if (index < 0) {
return 0;
@@ -896,15 +896,15 @@ u32 GetAmountInKinstoneBag(u32 kinstoneId) {
return gSave.kinstoneAmounts[index];
}
-u32 CheckKinstoneFused(u32 kinstoneId) {
- if (kinstoneId > 100 || kinstoneId < 1) {
+u32 CheckKinstoneFused(KinstoneId kinstoneId) {
+ if (kinstoneId - 1 >= 100) {
return 0;
}
return ReadBit(&gSave.fusedKinstones, kinstoneId);
}
-bool32 CheckFusionMapMarkerDisabled(u32 kinstoneId) {
- if (kinstoneId > 100 || kinstoneId < 1) {
+bool32 CheckFusionMapMarkerDisabled(KinstoneId kinstoneId) {
+ if (kinstoneId - 1 >= 100) {
return FALSE;
}
return ReadBit(&gSave.fusionUnmarked, kinstoneId);
@@ -974,7 +974,7 @@ code0_2:
#endif
}
-s32 GetIndexInKinstoneBag(u32 kinstoneId) {
+s32 GetIndexInKinstoneBag(KinstoneId kinstoneId) {
u32 i;
for (i = 0; i < 0x12; ++i) {
@@ -1054,7 +1054,7 @@ void UpdateVisibleFusionMapMarkers(void) {
extern u8* gUnk_08001DCC[];
-u32 GetFusionToOffer(Entity* entity) {
+KinstoneId GetFusionToOffer(Entity* entity) {
u8* fuserData;
u32 fuserId;
u32 offeredFusion;
@@ -1065,20 +1065,20 @@ u32 GetFusionToOffer(Entity* entity) {
fuserId = GetFuserId(entity);
fuserData = gUnk_08001DCC[fuserId];
if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0 || fuserData[0] > gSave.global_progress) {
- return 0;
+ return KINSTONE_NONE;
}
offeredFusion = gSave.fuserOffers[fuserId];
fuserProgress = gSave.fuserProgress[fuserId];
fuserFusionData = (u8*)(fuserProgress + (u32)fuserData);
while (TRUE) { // loop through fusions for this fuser
switch (offeredFusion) {
- case 0xF1: // offered fusion completed with someone else
- case 0x00: // no fusion offered yet
+ case KINSTONE_NEEDS_REPLACEMENT: // offered fusion completed with someone else
+ case KINSTONE_NONE: // no fusion offered yet
offeredFusion = fuserFusionData[5];
- if (offeredFusion == 0x00 || offeredFusion == 0xFF || CheckKinstoneFused(offeredFusion) == 0) {
+ if (offeredFusion == KINSTONE_NONE || offeredFusion == 0xFF || CheckKinstoneFused(offeredFusion) == 0) {
break;
}
- case 0xF2: // previous fusion completed
+ case KINSTONE_JUST_FUSED: // previous fusion completed
fuserFusionData++;
fuserProgress++;
offeredFusion = fuserFusionData[5];
@@ -1086,27 +1086,27 @@ u32 GetFusionToOffer(Entity* entity) {
if (offeredFusion == 0xFF) { // random shared fusion
offeredFusion = GetRandomSharedFusion(fuserData);
}
- if (offeredFusion == 0x00) { // end of fusion list
- offeredFusion = 0xF3; // mark this fuser as done
+ if (offeredFusion == KINSTONE_NONE) { // end of fusion list
+ offeredFusion = KINSTONE_FUSER_DONE; // mark this fuser as done
break;
}
- if (offeredFusion == 0xF2) { // previous fusion completed
+ if (offeredFusion == KINSTONE_JUST_FUSED) { // previous fusion completed
continue;
}
if (CheckKinstoneFused(offeredFusion) == 0) {
break;
}
- offeredFusion = 0xF1; // already completed, try next fusion in the list
+ offeredFusion = KINSTONE_NEEDS_REPLACEMENT; // already completed, try next fusion in the list
}
gSave.fuserOffers[fuserId] = offeredFusion;
gSave.fuserProgress[fuserId] = fuserProgress;
randomMood = Random();
fuserStability = fuserData[1];
if (fuserStability <= randomMood % 100) {
- return 0; // fickleness
+ return KINSTONE_NONE; // fickleness
}
if (offeredFusion - 1 > 99) {
- offeredFusion = 0;
+ offeredFusion = KINSTONE_NONE;
}
return offeredFusion;
}
@@ -1286,5 +1286,5 @@ u32 GetRandomSharedFusion(u8* fuserData) {
return kinstoneId;
r = (r + 1) % 18;
}
- return 0xF2;
+ return KINSTONE_JUST_FUSED;
}
diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c
index 97f67813..aa1001a5 100644
--- a/src/enemy/businessScrub.c
+++ b/src/enemy/businessScrub.c
@@ -13,6 +13,7 @@
#include "functions.h"
#include "game.h"
#include "item.h"
+#include "kinstone.h"
void sub_08028E9C(Entity*);
void sub_08028EDC(Entity*);
@@ -257,7 +258,7 @@ void sub_08028CE8(Entity* this) {
switch (offer->field_0x0 >> 2) {
case 0:
subtype = offer->field_0x9;
- if (subtype == 0xff) {
+ if (subtype == KINSTONE_RANDOM) {
subtype = kinstoneTypes[Random() & 7];
}
diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c
index 97d49044..77b55818 100644
--- a/src/menu/kinstoneMenu.c
+++ b/src/menu/kinstoneMenu.c
@@ -151,7 +151,7 @@ void KinstoneMenu_Type0(void) {
gScreen.bg3.updated = 1;
KinstoneMenu_080A4528();
sub_080A4398();
- AddKinstoneToBag(0);
+ AddKinstoneToBag(KINSTONE_NONE);
sub_080A70AC((void*)gUnk_081280DC);
SetMenuType(1);
SetFade(FADE_BLACK_WHITE | FADE_INSTANT, 8);
@@ -606,8 +606,8 @@ u32 sub_080A4418(u32 param_1, u32 param_2) {
}
void KinstoneMenu_080A4468(void) {
- gPossibleInteraction.kinstoneId = 0;
- gPossibleInteraction.currentObject->kinstoneId = 0;
+ gPossibleInteraction.kinstoneId = KINSTONE_NONE;
+ gPossibleInteraction.currentObject->kinstoneId = KINSTONE_NONE;
NotifyFusersOnFusionDone(gFuseInfo.kinstoneId);
RemoveKinstoneFromBag(gKinstoneMenu.unk2a);
}
diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c
index c36dbb9a..29c4f3ab 100644
--- a/src/menu/pauseMenu.c
+++ b/src/menu/pauseMenu.c
@@ -11,6 +11,7 @@
#include "game.h"
#include "item.h"
#include "itemMetaData.h"
+#include "kinstone.h"
#include "main.h"
#include "menu.h"
#include "message.h"
@@ -1281,7 +1282,7 @@ void PauseMenu_Screen_7(void) {
void sub_080A6024(void) {
sub_080A70AC((KeyButtonLayout*)&gUnk_08128D60);
- AddKinstoneToBag(0);
+ AddKinstoneToBag(KINSTONE_NONE);
sub_080A4398();
SetMenuType(1);
}
diff --git a/src/npc/cucco.c b/src/npc/cucco.c
index 7f1ad66a..62926b8f 100644
--- a/src/npc/cucco.c
+++ b/src/npc/cucco.c
@@ -1,5 +1,6 @@
#include "npc.h"
#include "functions.h"
+#include "kinstone.h"
void (*const Cucco_Actions[])(Entity*);
const u16 Cucco_Sounds[];
@@ -113,7 +114,7 @@ void sub_0806E65C(Entity* this) {
void Cucco_ShowMessage(Entity* this) {
u32 val = 0;
u32 index = GetFuserId(this);
- if (gSave.fuserOffers[index] == 0xf3) {
+ if (gSave.fuserOffers[index] == KINSTONE_FUSER_DONE) {
val = 1;
}
diff --git a/src/npc/din.c b/src/npc/din.c
index 735f4282..c5608c7e 100644
--- a/src/npc/din.c
+++ b/src/npc/din.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "entity.h"
#include "npc.h"
+#include "kinstone.h"
void Din(Entity* this) {
switch (this->action) {
@@ -30,11 +31,11 @@ void Din(Entity* this) {
}
void Din_MakeInteractable(Entity* this) {
- u32 tmp = GetFusionToOffer(this);
+ u32 kinstoneId = GetFusionToOffer(this);
if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) {
- tmp = 0;
+ kinstoneId = KINSTONE_NONE;
}
- AddInteractableWhenBigFuser(this, tmp);
+ AddInteractableWhenBigFuser(this, kinstoneId);
}
void Din_Fusion(Entity* this) {
diff --git a/src/npc/farore.c b/src/npc/farore.c
index fc68d782..c802bf6f 100644
--- a/src/npc/farore.c
+++ b/src/npc/farore.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "entity.h"
#include "npc.h"
+#include "kinstone.h"
void Farore(Entity* this) {
switch (this->action) {
@@ -30,11 +31,11 @@ void Farore(Entity* this) {
}
void Farore_MakeInteractable(Entity* this) {
- u32 tmp = GetFusionToOffer(this);
+ u32 kinstoneId = GetFusionToOffer(this);
if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) {
- tmp = 0;
+ kinstoneId = KINSTONE_NONE;
}
- AddInteractableWhenBigFuser(this, tmp);
+ AddInteractableWhenBigFuser(this, kinstoneId);
}
void Farore_Fusion(Entity* this) {
diff --git a/src/npc/nayru.c b/src/npc/nayru.c
index f0949f24..b9ea0df4 100644
--- a/src/npc/nayru.c
+++ b/src/npc/nayru.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "entity.h"
#include "npc.h"
+#include "kinstone.h"
void Nayru(Entity* this) {
switch (this->action) {
@@ -30,11 +31,11 @@ void Nayru(Entity* this) {
}
void Nayru_MakeInteractable(Entity* this) {
- u32 tmp = GetFusionToOffer(this);
+ u32 kinstoneId = GetFusionToOffer(this);
if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) {
- tmp = 0;
+ kinstoneId = KINSTONE_NONE;
}
- AddInteractableWhenBigFuser(this, tmp);
+ AddInteractableWhenBigFuser(this, kinstoneId);
}
void Nayru_Fusion(Entity* this) {
diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c
index b4967940..8da17db8 100644
--- a/src/npc/npc4E.c
+++ b/src/npc/npc4E.c
@@ -58,7 +58,7 @@ u8 NPC4E_GetKinstoneId(Entity* this) {
switch (this->type) {
default:
- result = KINSTONE_0;
+ result = KINSTONE_NONE;
break;
case 1:
result = KINSTONE_MYSTERIOUS_CLOUD_TOP_RIGHT;
@@ -89,13 +89,11 @@ u8 NPC4E_GetKinstoneId(Entity* this) {
return result;
}
-// Check whether a kinstone fusion is possible and store the result somewhere in param_2?
void NPC4E_IsKinstoneFused(Entity* this, ScriptExecutionContext* context) {
context->condition = CheckKinstoneFused(NPC4E_GetKinstoneId(this));
gActiveScriptInfo.flags |= 1;
}
-// maybe actually execute the kinstone fusion?
void NPC4E_MakeFuserInteractable(Entity* this) {
AddInteractableFuser(this, NPC4E_GetKinstoneId(this));
}
diff --git a/src/npcUtils.c b/src/npcUtils.c
index cea167ae..b5963d94 100644
--- a/src/npcUtils.c
+++ b/src/npcUtils.c
@@ -355,7 +355,7 @@ u32 UpdateFuseInteraction(Entity* ent) {
void sub_0806F188(Entity* ent) {
u32 idx = GetFuserId(ent);
if (idx != 0)
- gSave.fuserOffers[idx] = 0xF3;
+ gSave.fuserOffers[idx] = KINSTONE_FUSER_DONE;
}
void ShowNPCDialogue(Entity* ent, const Dialog* dia) {
diff --git a/src/playerUtils.c b/src/playerUtils.c
index 705cd02e..b078f080 100644
--- a/src/playerUtils.c
+++ b/src/playerUtils.c
@@ -1092,7 +1092,7 @@ bool32 sub_080782C0(void) {
}
}
if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && ((u8)(gPossibleInteraction.currentObject->kinstoneId - 1) < 100)) {
- AddKinstoneToBag(0);
+ AddKinstoneToBag(KINSTONE_NONE);
if (gSave.kinstoneAmounts[0] != 0) {
gPossibleInteraction.kinstoneId = gPossibleInteraction.currentObject->kinstoneId;
gPossibleInteraction.currentObject->entity->interactType = 2;
@@ -1120,7 +1120,7 @@ bool32 sub_080782C0(void) {
case INTERACTION_USE_SMALL_KEY:
case INTERACTION_TALK_MINISH:
entity->interactType = 1;
- gPossibleInteraction.kinstoneId = 0;
+ gPossibleInteraction.kinstoneId = KINSTONE_NONE;
return TRUE;
case INTERACTION_LIFT_SHOP_ITEM:
if (gRoomVars.shopItemType == 0) {
@@ -1229,7 +1229,7 @@ s32 AddInteractableObject(Entity* entity, InteractionType type, KinstoneId kinst
gPossibleInteraction.candidates[index].type = type;
gPossibleInteraction.candidates[index].kinstoneId = kinstoneId;
}
- if (kinstoneId != 0) {
+ if (kinstoneId != KINSTONE_NONE) {
Entity* entity = FindEntityByID(OBJECT, CAMERA_TARGET, 6);
if (entity == NULL) {
CreateObject(CAMERA_TARGET, 0, 0);