summaryrefslogtreecommitdiff
path: root/src/d/d_message.cpp
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-05-12 21:35:03 +0200
committerrobojumper <robojumper@gmail.com>2025-05-15 19:05:48 +0200
commit33efdfeec9be71687d07c3a4ab460703c2b7e93a (patch)
tree6e15a79e73cc00e0b7af06e9011b08a845525c89 /src/d/d_message.cpp
parentc241dbe301f94839175504f24d70615d67bac8d7 (diff)
More docs
Diffstat (limited to 'src/d/d_message.cpp')
-rw-r--r--src/d/d_message.cpp142
1 files changed, 84 insertions, 58 deletions
diff --git a/src/d/d_message.cpp b/src/d/d_message.cpp
index b500ef92..83add314 100644
--- a/src/d/d_message.cpp
+++ b/src/d/d_message.cpp
@@ -58,9 +58,9 @@ dFlow_c::dFlow_c() {
field_0x3C = 0;
field_0x40 = -1;
field_0x44 = -1;
- field_0x46 = -1;
+ mNextFiFlow = -1;
mDelayTimer = 0;
- field_0x5C = -1;
+ mFiSpeechArgument = -1;
}
dFlow_c::~dFlow_c() {}
@@ -265,30 +265,32 @@ bool dFlow_c::handleEventInternal(const MsbFlowInfo *element) {
}
mDelayTimer = 0;
break;
- case EVENT_07:
+ case EVENT_LOAD_FI_FLOW:
if (params1n2 == -1) {
s32 hi, lo;
s32 selectedOption = dLytMsgWindow_c::getInstance()->getTextOptionSelection();
mFiInfo0 = FiContext::getGlobalFiInfo0(selectedOption);
switch (mFiInfo0) {
- case 0: {
+ case FiContext::KEN8_Summary: {
hi = 6;
lo = 1;
- field_0x5C = FiContext::getNaviTableProgressSummary();
+ mFiSpeechArgument = FiContext::getNaviTableProgressSummary();
break;
}
case 11:
+ // TODO: Is this one actually used? It completely duplicates
+ // KEN8_Hint (case 1) down below...
hi = 6;
lo = 100;
- field_0x5C = FiContext::getFiAdviceHintEntry();
+ mFiSpeechArgument = FiContext::getFiAdviceHintEntry();
break;
- case 2: {
+ case FiContext::KEN8_Objective: {
hi = 6;
lo = 200;
- field_0x5C = FiContext::getObjective();
+ mFiSpeechArgument = FiContext::getObjective();
break;
}
- case 3: {
+ case FiContext::KEN8_Analysis: {
FiAnalysisHandle handle = FiContext::getNaviTableEquipmentCheckEntry();
if (handle.isValid()) {
hi = 6;
@@ -297,30 +299,30 @@ bool dFlow_c::handleEventInternal(const MsbFlowInfo *element) {
hi = 6;
lo = 301;
}
- field_0x5C = 5;
+ mFiSpeechArgument = 5;
break;
}
- case 4:
+ case FiContext::KEN8_PlayTime:
hi = 6;
lo = 800;
break;
- case 9:
+ case FiContext::KEN8_Advice:
hi = 6;
lo = 802;
break;
- case 1: {
+ case FiContext::KEN8_Hint: {
hi = 6;
lo = 100;
- field_0x5C = FiContext::getFiAdviceHintEntry();
+ mFiSpeechArgument = FiContext::getFiAdviceHintEntry();
break;
}
- case 5:
+ case FiContext::KEN8_Rumors:
hi = 6;
lo = 900;
break;
}
FiContext::do_setAdviceOptions(FiContext::getGlobalFiInfo0(selectedOption));
- field_0x46 = lo + hi * 1000;
+ mNextFiFlow = lo + hi * 1000;
} else {
triggerEntryPoint((params1n2 >> 16) & 0xFFFF, params1n2 & 0xFFFF);
field_0x0F = 1;
@@ -441,6 +443,7 @@ bool dFlow_c::handleEventInternal(const MsbFlowInfo *element) {
break;
}
case EVENT_LIGHT_PILLAR_34: {
+ // TODO what do these modes do?
if (params1n2 == 1) {
if (!dLytControlGame_c::getInstance()->isNotInStateMap()) {
dLytControlGame_c::getInstance()->fn_802CCD40(true);
@@ -551,24 +554,24 @@ bool dFlow_c::handleMessage() {
if (mCurrentTextLabelName == "KEN0_08") {
// "After winning the race in the Wing Ceremony..."
// Current objective - use value from FiContext::getObjective?
- if (field_0x5C < 0) {
- field_0x5C = 8;
+ if (mFiSpeechArgument < 0) {
+ mFiSpeechArgument = 8;
}
- mCurrentTextLabelName.sprintf("KEN0_%02d", field_0x5C);
+ mCurrentTextLabelName.sprintf("KEN0_%02d", mFiSpeechArgument);
} else if (mCurrentTextLabelName == "KEN1_000") {
// "This is Skyloft..."
// Area analysis - use value from FiContext::???
- if (field_0x5C < 0) {
- field_0x5C = 0;
+ if (mFiSpeechArgument < 0) {
+ mFiSpeechArgument = 0;
}
- mCurrentTextLabelName.sprintf("KEN1_%03d", field_0x5C);
+ mCurrentTextLabelName.sprintf("KEN1_%03d", mFiSpeechArgument);
} else if (mCurrentTextLabelName == "KEN2_000") {
// "To search for Zelda..."
// Hint - use value from FiContext::getFiAdviceHintEntry?
- if (field_0x5C < 0) {
- field_0x5C = 2;
+ if (mFiSpeechArgument < 0) {
+ mFiSpeechArgument = 2;
}
- mCurrentTextLabelName.sprintf("KEN2_%03d", field_0x5C);
+ mCurrentTextLabelName.sprintf("KEN2_%03d", mFiSpeechArgument);
} else if (mCurrentTextLabelName == "KEN3_500") {
// "Master, your current selection of pouch items is..."
// Equipment focus
@@ -730,18 +733,18 @@ bool dFlow_c::handleMessage() {
u16 dFlow_c::getSwitchChoice(const MsbFlowInfo *element, u16 param) const {
u16 result = 0;
- if (param < 14 || param > 16) {
+ if (param < BRANCH_14 || param > BRANCH_16) {
result = (this->*(sBranchHandlers[param]))(element);
}
return result;
}
-inline void setTagProcessorFiArgument(s32 argIdx, s32 btnIdx) {
+inline void syncFiButtonText(s32 argIdx, s32 btnIdx) {
dTagProcessor_c *p = dLytMsgWindow_c::getInstance()->getTagProcessor();
p->setStringArg(FiContext::getMessageForFiInfo(argIdx), btnIdx);
}
-inline void setTagProcessorArgument(s32 textLabel, s32 btnIdx) {
+inline void setFiButtonTextDirectly(s32 textLabel, s32 btnIdx) {
dTagProcessor_c *p = dLytMsgWindow_c::getInstance()->getTagProcessor();
p->setStringArg(FiContext::getButtonText(textLabel), btnIdx);
}
@@ -755,14 +758,18 @@ u16 dFlow_c::branchHandler01(const MsbFlowInfo *element) const {
}
u16 dFlow_c::branchHandler02(const MsbFlowInfo *element) const {
- if (FiContext::getDoSpecialFiMenuHandlingChecked()) {
- if (dLytMsgWindow_c::getInstance()->getTextOptionSelection() == 0 && FiContext::getGlobalFiInfo0(0) == 9) {
+ if (FiContext::getIsInFiMainMenuChecked()) {
+ if (dLytMsgWindow_c::getInstance()->getTextOptionSelection() == 0 &&
+ FiContext::getGlobalFiInfo0(0) == FiContext::KEN8_Advice) {
+ // HACK (?): If the user presses "Advice" on the Fi main menu,
+ // which is known to be button 0, update Fi's buttons since that
+ // menu isn't entirely integrated into the flow
FiContext::do_resetAdviceOptions();
- setTagProcessorFiArgument(0, 0);
- setTagProcessorFiArgument(1, 1);
- setTagProcessorFiArgument(2, 2);
+ syncFiButtonText(0, 0);
+ syncFiButtonText(1, 1);
+ syncFiButtonText(2, 2);
} else {
- FiContext::setDoSpecialFiMenuHandling(false);
+ FiContext::setIsInFiMainMenu(false);
}
}
return dLytMsgWindow_c::getInstance()->getTextOptionSelection();
@@ -938,12 +945,29 @@ u16 dFlow_c::branchHandler22(const MsbFlowInfo *element) const {
}
dFlow_c::BranchHandler dFlow_c::sBranchHandlers[] = {
- &dFlow_c::branchHandler00, &dFlow_c::branchHandler01, &dFlow_c::branchHandler02, &dFlow_c::branchHandler03,
- &dFlow_c::branchHandler04, &dFlow_c::branchHandler05, &dFlow_c::branchHandler06, &dFlow_c::branchHandler07,
- &dFlow_c::branchHandler08, &dFlow_c::branchHandler09, &dFlow_c::branchHandler10, &dFlow_c::branchHandler11,
- &dFlow_c::branchHandler12, &dFlow_c::branchHandler13, &dFlow_c::branchHandler14, &dFlow_c::branchHandler15,
- &dFlow_c::branchHandler16, &dFlow_c::branchHandler17, &dFlow_c::branchHandler18, &dFlow_c::branchHandler19,
- &dFlow_c::branchHandler20, &dFlow_c::branchHandler21, &dFlow_c::branchHandler22,
+ &dFlow_c::branchHandler00, // BRANCH_SELECTED_OPTION_0
+ &dFlow_c::branchHandler01, // BRANCH_SELECTED_OPTION_1
+ &dFlow_c::branchHandler02, // BRANCH_SELECTED_OPTION_FI
+ &dFlow_c::branchHandler03, // BRANCH_STORYFLAG
+ &dFlow_c::branchHandler04, // BRANCH_NONE
+ &dFlow_c::branchHandler05, // BRANCH_ZONEFLAG
+ &dFlow_c::branchHandler06, // BRANCH_SCENEFLAG
+ &dFlow_c::branchHandler07, // BRANCH_EVENT_COUNTER_THRESHOLD_1
+ &dFlow_c::branchHandler08, // BRANCH_EVENT_COUNTER_THRESHOLD_2
+ &dFlow_c::branchHandler09, // BRANCH_TEMPFLAG
+ &dFlow_c::branchHandler10, // BRANCH_CURRENT_RUPEES
+ &dFlow_c::branchHandler11, // BRANCH_RAND_2
+ &dFlow_c::branchHandler12, // BRANCH_RAND_3
+ &dFlow_c::branchHandler13, // BRANCH_RAND_4
+ &dFlow_c::branchHandler14, // BRANCH_14
+ &dFlow_c::branchHandler15, // BRANCH_15
+ &dFlow_c::branchHandler16, // BRANCH_16
+ &dFlow_c::branchHandler17, // BRANCH_FREE_SPACE_IN_POUCH
+ &dFlow_c::branchHandler18, // BRANCH_18
+ &dFlow_c::branchHandler19, // BRANCH_19
+ &dFlow_c::branchHandler20, // BRANCH_FREE_SPACE_IN_ITEM_CHECK
+ &dFlow_c::branchHandler21, // BRANCH_TARGET_ACTOR_HAS_KILL_COUNT
+ &dFlow_c::branchHandler22, // BRANCH_22
};
bool dFlow_c::handleBranch() {
@@ -997,19 +1021,19 @@ void dFlow_c::triggerEntryPoint(s32 labelPart1, s32 labelPart2) {
if (labelPart1 == 6 && labelPart2 == 801) {
// "You called for me, Master?"
FiContext::do_prepareFiCallOptions();
- FiContext::setDoSpecialFiMenuHandling(true);
+ FiContext::setIsInFiMainMenu(true);
FiContext::do_fn_8016CB40();
- setTagProcessorFiArgument(0, 0);
- setTagProcessorFiArgument(1, 1);
- setTagProcessorFiArgument(2, 2);
- setTagProcessorArgument(FiContext::KEN8_Nevermind, 3);
+ syncFiButtonText(0, 0);
+ syncFiButtonText(1, 1);
+ syncFiButtonText(2, 2);
+ setFiButtonTextDirectly(FiContext::KEN8_Nevermind, 3);
} else if (labelPart1 == 6 && labelPart2 == 802) {
// Doesn't seem to exist in the files
- FiContext::setDoSpecialFiMenuHandling(true);
- setTagProcessorFiArgument(0, 0);
- setTagProcessorFiArgument(1, 1);
- setTagProcessorFiArgument(2, 2);
- setTagProcessorArgument(FiContext::KEN8_Nevermind, 3);
+ FiContext::setIsInFiMainMenu(true);
+ syncFiButtonText(0, 0);
+ syncFiButtonText(1, 1);
+ syncFiButtonText(2, 2);
+ setFiButtonTextDirectly(FiContext::KEN8_Nevermind, 3);
}
u16 entry = findEntryPoint(labelPart1, labelPart2);
start(entry);
@@ -1024,8 +1048,8 @@ u16 dFlow_c::getField_0x44() const {
return field_0x44;
}
-u16 dFlow_c::getField_0x46() const {
- return field_0x46;
+u16 dFlow_c::getNextFiFlow() const {
+ return mNextFiFlow;
}
bool dFlow_c::triggerEntryPointChecked(s32 labelPart1, s32 labelPart2) {
@@ -1053,7 +1077,7 @@ void dFlow_c::start(u16 entry) {
field_0x3C = 0;
field_0x40 = -1;
field_0x44 = -1;
- field_0x46 = -1;
+ mNextFiFlow = -1;
mDelayTimer = 0;
std::memset(&mFlowInfo, 0, sizeof(MsbFlowInfo));
CURRENT_ACTOR_EVENT_FLOW_MANAGER = this;
@@ -1087,18 +1111,20 @@ bool dFlow_c::advanceUntil(s32 searchType, s32 searchParam3, s32 *pOutParams1n2)
keepGoing = true;
break;
case FLOW_BRANCH:
- if (element->param3 <= 2) {
+ if (element->param3 <= BRANCH_SELECTED_OPTION_FI) {
+ // Skip evaluating if next branch depends on user input
keepGoing = false;
} else {
+ // Otherwise
keepGoing = handleBranch();
}
break;
case FLOW_EVENT:
switch (element->param3) {
- case 7:
- case 23:
- case 27: keepGoing = handleEvent(); continue;
- case 34:
+ case EVENT_LOAD_FI_FLOW:
+ case EVENT_COUNTER_THRESHOLD:
+ case 27: keepGoing = handleEvent(); continue;
+ case EVENT_LIGHT_PILLAR_34:
if (element->params1n2 == 2) {
keepGoing = false;
continue;