2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2021-11-16 23:04:31 +00:00
|
|
|
#include "z64elf_message.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-30 20:29:51 +00:00
|
|
|
ElfMessage sChildSariaMsgs[] = {
|
2021-11-16 23:04:31 +00:00
|
|
|
ELF_MSG_STRENGTH_UPG(SKIP, 3, false, 0),
|
2022-04-29 18:19:48 +00:00
|
|
|
ELF_MSG_FLAG(CHECK, 0x61, false, EVENTCHKINF_37),
|
2021-11-16 23:04:31 +00:00
|
|
|
ELF_MSG_END(0x64),
|
2022-04-29 18:19:48 +00:00
|
|
|
ELF_MSG_FLAG(CHECK, 0x62, false, EVENTCHKINF_25),
|
|
|
|
ELF_MSG_FLAG(CHECK, 0x63, false, EVENTCHKINF_37),
|
|
|
|
ELF_MSG_FLAG(CHECK, 0x65, false, EVENTCHKINF_43),
|
2021-11-16 23:04:31 +00:00
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x66, false, ITEM_MEDALLION_FOREST),
|
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x66, false, ITEM_MEDALLION_FIRE),
|
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x66, false, ITEM_MEDALLION_WATER),
|
|
|
|
ELF_MSG_SONG(CHECK, 0x67, false, ITEM_SONG_STORMS),
|
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x68, false, ITEM_MEDALLION_SPIRIT),
|
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x68, false, ITEM_MEDALLION_SHADOW),
|
|
|
|
ELF_MSG_END(0x69),
|
2020-03-30 20:29:51 +00:00
|
|
|
};
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-30 20:29:51 +00:00
|
|
|
ElfMessage sAdultSariaMsgs[] = {
|
2021-11-16 23:04:31 +00:00
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x6A, false, ITEM_MEDALLION_FOREST),
|
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x6B, false, ITEM_MEDALLION_FIRE),
|
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x6B, false, ITEM_MEDALLION_WATER),
|
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x6C, false, ITEM_MEDALLION_SPIRIT),
|
|
|
|
ELF_MSG_MEDALLION(CHECK, 0x6C, false, ITEM_MEDALLION_SHADOW),
|
|
|
|
ELF_MSG_END(0x6D),
|
2020-03-30 20:29:51 +00:00
|
|
|
};
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-30 20:29:51 +00:00
|
|
|
u32 ElfMessage_CheckCondition(ElfMessage* msg) {
|
2020-08-30 16:51:46 +00:00
|
|
|
s32 type = msg->byte0 & 0x1E;
|
|
|
|
u16 flag;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-30 16:51:46 +00:00
|
|
|
switch (type) {
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_FLAG << 1):
|
2020-08-30 16:51:46 +00:00
|
|
|
flag = 1 << (msg->byte1 & 0x0F);
|
|
|
|
return ((msg->byte0 & 1) == 1) == ((flag & gSaveContext.eventChkInf[(msg->byte1 & 0xF0) >> 4]) != 0);
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_DUNGEON_ITEM << 1):
|
2020-12-03 21:55:01 +00:00
|
|
|
return ((msg->byte0 & 1) == 1) ==
|
|
|
|
(CHECK_DUNGEON_ITEM(msg->byte1 - ITEM_KEY_BOSS, gSaveContext.mapIndex) != 0);
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_ITEM << 1):
|
2020-03-30 20:29:51 +00:00
|
|
|
return ((msg->byte0 & 1) == 1) == (msg->byte3 == INV_CONTENT(msg->byte1));
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_OTHER << 1):
|
2020-03-30 20:29:51 +00:00
|
|
|
switch (msg->byte1 & 0xF0) {
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_STRENGTH_UPG << 4):
|
2020-03-30 20:29:51 +00:00
|
|
|
return ((msg->byte0 & 1) == 1) == ((msg->byte1 & 0x0F) == CUR_UPG_VALUE(UPG_STRENGTH));
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_BOOTS << 4):
|
2020-03-30 20:29:51 +00:00
|
|
|
return ((msg->byte0 & 1) == 1) ==
|
2022-04-30 16:18:56 +00:00
|
|
|
(CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS,
|
|
|
|
msg->byte3 - ITEM_BOOTS_KOKIRI + EQUIP_INV_BOOTS_KOKIRI) != 0);
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_SONG << 4):
|
2020-03-30 20:29:51 +00:00
|
|
|
return ((msg->byte0 & 1) == 1) ==
|
2021-08-21 23:12:57 +00:00
|
|
|
(CHECK_QUEST_ITEM(msg->byte3 - ITEM_SONG_MINUET + QUEST_SONG_MINUET) != 0);
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_MEDALLION << 4):
|
2020-03-30 20:29:51 +00:00
|
|
|
return ((msg->byte0 & 1) == 1) ==
|
2021-08-21 23:12:57 +00:00
|
|
|
(CHECK_QUEST_ITEM(msg->byte3 - ITEM_MEDALLION_FOREST + QUEST_MEDALLION_FOREST) != 0);
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_CONDITION_MAGIC << 4):
|
2020-08-30 16:51:46 +00:00
|
|
|
return ((msg->byte0 & 1) == 1) == (((void)0, gSaveContext.magicAcquired) != 0);
|
2020-03-30 20:29:51 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2021-09-04 13:33:19 +00:00
|
|
|
LOG_STRING("企画外 条件", "../z_elf_message.c", 156); // "Unplanned conditions"
|
2021-04-29 18:39:46 +00:00
|
|
|
ASSERT(0, "0", "../z_elf_message.c", 157);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-30 20:29:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 func_8006BE88(ElfMessage** msgp) {
|
|
|
|
u32 temp = true;
|
|
|
|
|
2021-11-16 23:04:31 +00:00
|
|
|
while (((*msgp)->byte0 & 0xE0) == (ELF_MSG_TYPE_UNK_1 << 5)) {
|
2020-03-30 20:29:51 +00:00
|
|
|
if (!ElfMessage_CheckCondition(*msgp)) {
|
|
|
|
temp = false;
|
|
|
|
}
|
|
|
|
*msgp += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (temp) {
|
|
|
|
return ElfMessage_CheckCondition(*msgp);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 func_8006BF1C(ElfMessage** msgp) {
|
2021-02-14 00:49:40 +00:00
|
|
|
ElfMessage* msg = *msgp;
|
2020-03-30 20:29:51 +00:00
|
|
|
u32 sp44[10];
|
2021-02-14 00:49:40 +00:00
|
|
|
s32 temp1 = 0;
|
|
|
|
s32 temp2 = 0;
|
2020-03-30 20:29:51 +00:00
|
|
|
s32 temp3;
|
|
|
|
|
|
|
|
do {
|
|
|
|
sp44[temp2] = ElfMessage_CheckCondition(msg);
|
|
|
|
temp1 += sp44[temp2];
|
|
|
|
temp2++;
|
|
|
|
msg++;
|
2021-11-16 23:04:31 +00:00
|
|
|
} while ((msg->byte0 & 0xE0) == (ELF_MSG_TYPE_UNK_2 << 5));
|
2020-03-30 20:29:51 +00:00
|
|
|
|
|
|
|
if (temp1 == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-12-26 10:44:53 +00:00
|
|
|
temp3 = Rand_ZeroFloat(temp1);
|
2020-03-30 20:29:51 +00:00
|
|
|
for (temp1 = 0; temp1 < temp2; temp1++) {
|
|
|
|
if (sp44[temp1]) {
|
|
|
|
if (temp3 > 0) {
|
|
|
|
temp3--;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*msgp += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 ElfMessage_GetTextFromMsgs(ElfMessage* msg) {
|
|
|
|
while (true) {
|
|
|
|
switch (msg->byte0 & 0xE0) {
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_TYPE_CHECK << 5):
|
2020-03-30 20:29:51 +00:00
|
|
|
if (ElfMessage_CheckCondition(msg)) {
|
|
|
|
return msg->byte2 | 0x100;
|
|
|
|
}
|
|
|
|
break;
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_TYPE_UNK_1 << 5):
|
2020-03-30 20:29:51 +00:00
|
|
|
if (func_8006BE88(&msg)) {
|
|
|
|
return msg->byte2 | 0x100;
|
|
|
|
}
|
|
|
|
break;
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_TYPE_UNK_2 << 5):
|
2020-03-30 20:29:51 +00:00
|
|
|
if (func_8006BF1C(&msg)) {
|
|
|
|
return msg->byte2 | 0x100;
|
|
|
|
}
|
|
|
|
break;
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_TYPE_SKIP << 5):
|
2020-03-30 20:29:51 +00:00
|
|
|
if (ElfMessage_CheckCondition(msg)) {
|
|
|
|
msg += msg->byte2;
|
|
|
|
msg--;
|
|
|
|
}
|
|
|
|
break;
|
2021-11-16 23:04:31 +00:00
|
|
|
case (ELF_MSG_TYPE_END << 5):
|
2020-03-30 20:29:51 +00:00
|
|
|
return msg->byte2 | 0x100;
|
|
|
|
default:
|
2021-09-04 13:33:19 +00:00
|
|
|
LOG_STRING("企画外 条件", "../z_elf_message.c", 281); // "Unplanned conditions"
|
2021-04-29 18:39:46 +00:00
|
|
|
ASSERT(0, "0", "../z_elf_message.c", 282);
|
2020-03-30 20:29:51 +00:00
|
|
|
}
|
|
|
|
msg++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
u16 ElfMessage_GetSariaText(PlayState* play) {
|
|
|
|
Player* player = GET_PLAYER(play);
|
2020-03-30 20:29:51 +00:00
|
|
|
ElfMessage* msgs;
|
|
|
|
|
2021-08-21 23:12:57 +00:00
|
|
|
if (!LINK_IS_ADULT) {
|
2022-05-21 18:23:43 +00:00
|
|
|
if (Actor_FindNearby(play, &player->actor, ACTOR_EN_SA, 4, 800.0f) == NULL) {
|
2020-03-30 20:29:51 +00:00
|
|
|
msgs = sChildSariaMsgs;
|
|
|
|
} else {
|
|
|
|
return 0x0160; // Special text about Saria preferring to talk to you face-to-face
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
msgs = sAdultSariaMsgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ElfMessage_GetTextFromMsgs(msgs);
|
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
u16 ElfMessage_GetCUpText(PlayState* play) {
|
|
|
|
if (play->cUpElfMsgs == NULL) {
|
2020-03-30 20:29:51 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
2022-05-21 18:23:43 +00:00
|
|
|
return ElfMessage_GetTextFromMsgs(play->cUpElfMsgs);
|
2020-03-30 20:29:51 +00:00
|
|
|
}
|
|
|
|
}
|