summaryrefslogtreecommitdiff
path: root/src/quest_log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/quest_log.c')
-rw-r--r--src/quest_log.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/src/quest_log.c b/src/quest_log.c
index 7de7463a4..a41459dc9 100644
--- a/src/quest_log.c
+++ b/src/quest_log.c
@@ -106,7 +106,7 @@ EWRAM_DATA u8 gQuestLogState = 0;
static EWRAM_DATA u16 gUnknown_203ADFC = 0;
static EWRAM_DATA u8 sQuestLogHeaderWindowIds[3] = {0};
static EWRAM_DATA u16 *gUnknown_203AE04 = NULL;
-static EWRAM_DATA u16 *gUnknown_203AE08 = NULL;
+static EWRAM_DATA u16 *sEventRecordingPointer = NULL;
static EWRAM_DATA u16 *gUnknown_203AE0C[32] = {NULL};
static EWRAM_DATA void (* sQuestLogCB)(void) = NULL;
static EWRAM_DATA u16 *gUnknown_203AE90 = NULL;
@@ -129,7 +129,7 @@ static void sub_8110A00(void);
static void sub_8110A3C(void);
static void SetPlayerInitialCoordsAtScene(u8);
static void SetNPCInitialCoordsAtScene(u8);
-static void sub_8110E3C(void);
+static void TryRecordEvent39_GoToNextScene(void);
static void BackUpTrainerRematchesToVars(void);
static void BackUpMapLayoutToVar(void);
static void SetGameStateAtScene(u8);
@@ -182,7 +182,7 @@ static bool8 sub_81137E4(u16, const u16 *);
static u16 *sub_8113828(u16, const u16 *);
static bool8 TrySetLinkQuestLogEvent(u16, const u16 *);
static bool8 TrySetTrainerBattleQuestLogEvent(u16, const u16 *);
-static void sub_8113A1C(u16);
+static void TryRecordEvent41_IncCursor(u16);
static void sub_811381C(void);
static bool8 IsQuestLogEventWithSpecialEncounterSpecies(u16, const u16 *);
static u16 *QuestLog_SkipCommand(u16 *, u16 **);
@@ -192,9 +192,9 @@ static bool8 sub_8113B44(const u16 *);
static void sub_8113B88(void);
static void sub_8113B94(u16);
static void sub_8113BD8(void);
-static u16 *sub_8113BF4(u16 *);
+static u16 *TryRecordEvent39_NoParams(u16 *);
static u16 *sub_8113C20(u16 *, struct QuestLogEntry *);
-static u16 *sub_8113C5C(u16 *, u16);
+static u16 *TryRecordEvent41(u16 *, u16);
static u16 *sub_8113C8C(u16 *, struct QuestLogEntry *);
static u16 *sub_8113CC8(u16 *, struct QuestLogEntry *);
static u16 *sub_8113D08(u16 *, struct QuestLogEntry *);
@@ -300,8 +300,8 @@ void sub_8110840(void * oldPointer)
gUnknown_203AE04 = (void *)gUnknown_203AE04 + offset;
if (gQuestLogState != 0)
{
- if (gUnknown_203AE08)
- gUnknown_203AE08 = (void *)gUnknown_203AE08 + offset;
+ if (sEventRecordingPointer)
+ sEventRecordingPointer = (void *)sEventRecordingPointer + offset;
if (gQuestLogState == QL_STATE_2)
{
int r3;
@@ -318,7 +318,7 @@ void ResetQuestLog(void)
sCurrentSceneNum = 0;
gQuestLogState = 0;
sQuestLogCB = NULL;
- gUnknown_203AE08 = NULL;
+ sEventRecordingPointer = NULL;
gUnknown_203AE04 = NULL;
sub_8113BD8();
sub_81138F8();
@@ -351,12 +351,12 @@ bool8 sub_8110944(const void * a0, size_t cmdSize)
return TRUE;
}
-bool8 sub_8110988(u16 *a0, size_t a1)
+static bool8 WillCommandOfSizeFitInSav1Record(u16 *cursor, size_t size)
{
- void * r2 = gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_568;
- void * r0 = gSaveBlock1Ptr->questLog[sCurrentSceneNum].end;
- r0 -= a1;
- if ((void *)a0 < r2 || (void *)a0 > r0)
+ void * start = gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_568;
+ void * end = gSaveBlock1Ptr->questLog[sCurrentSceneNum].end;
+ end -= size;
+ if ((void *)cursor < start || (void *)cursor > end)
return FALSE;
return TRUE;
}
@@ -375,7 +375,7 @@ static void sub_8110A00(void)
if (TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer) != 1)
{
gUnknown_3005E88 = 0;
- sub_8110E3C();
+ TryRecordEvent39_GoToNextScene();
gQuestLogState = 0;
sQuestLogCB = NULL;
}
@@ -416,7 +416,7 @@ static void StartRecordingQuestLogEntry(u16 eventId)
DestroySav1QuestLogEntry(sCurrentSceneNum);
sub_8113B88();
- gUnknown_203AE08 = gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_568;
+ sEventRecordingPointer = gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_568;
if (IS_LINK_QL_EVENT(eventId) || eventId == QL_EVENT_DEPARTED)
gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000 = 2;
else
@@ -509,9 +509,9 @@ static void BackUpMapLayoutToVar(void)
VarSet(VAR_QLBAK_MAP_LAYOUT, gSaveBlock1Ptr->mapLayoutId);
}
-static void sub_8110E3C(void)
+static void TryRecordEvent39_GoToNextScene(void)
{
- sub_8113BF4(gUnknown_203AE08);
+ TryRecordEvent39_NoParams(sEventRecordingPointer);
if (++sCurrentSceneNum >= QUEST_LOG_SCENE_COUNT)
sCurrentSceneNum = 0;
}
@@ -522,19 +522,19 @@ static bool8 TryRecordQuestLogEntrySequence(struct QuestLogEntry * entry)
for (i = gUnknown_203ADFC; i < sQuestLogCursor; i++)
{
- if (gUnknown_203AE08 == NULL)
+ if (sEventRecordingPointer == NULL)
return FALSE;
switch (entry[i].unk_6)
{
case 0:
case 1:
- gUnknown_203AE08 = sub_8113D48(gUnknown_203AE08, &entry[i]);
+ sEventRecordingPointer = sub_8113D48(sEventRecordingPointer, &entry[i]);
break;
default:
- gUnknown_203AE08 = sub_8113CC8(gUnknown_203AE08, &entry[i]);
+ sEventRecordingPointer = sub_8113CC8(sEventRecordingPointer, &entry[i]);
break;
}
- if (gUnknown_203AE08 == NULL)
+ if (sEventRecordingPointer == NULL)
{
gUnknown_3005E88 = 0;
return FALSE;
@@ -543,7 +543,7 @@ static bool8 TryRecordQuestLogEntrySequence(struct QuestLogEntry * entry)
if (gUnknown_3005E88 == 0)
{
- gUnknown_203AE08 = sub_8113BF4(gUnknown_203AE08);
+ sEventRecordingPointer = TryRecordEvent39_NoParams(sEventRecordingPointer);
return FALSE;
}
gUnknown_203ADFC = sQuestLogCursor;
@@ -966,7 +966,7 @@ bool8 QuestLog_SchedulePlaybackCB(void (*callback)(void))
switch (gQuestLogState)
{
case 1:
- sub_8112364();
+ QuestLog_OnInteractionWithSpecialNpc();
break;
case 2:
gUnknown_3005E88 = 3;
@@ -1228,7 +1228,7 @@ static void sub_8111F8C(u8 taskId)
{
FreezeObjectEvents();
sub_805C270();
- sub_805C780();
+ StopPlayerAvatar();
ScriptContext2_Enable();
task->func = Task_QuestLogScene_SavedGame;
}
@@ -1364,28 +1364,28 @@ void sub_811231C(void)
if (gQuestLogState == QL_STATE_1)
{
TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer);
- sub_8110E3C();
+ TryRecordEvent39_GoToNextScene();
gQuestLogState = 0;
sQuestLogCB = NULL;
gUnknown_203AE04 = NULL;
- gUnknown_203AE08 = NULL;
+ sEventRecordingPointer = NULL;
gUnknown_3005E88 = 0;
}
}
-void sub_8112364(void)
+void QuestLog_OnInteractionWithSpecialNpc(void)
{
if (gUnknown_3005E88 && gQuestLogState == QL_STATE_1)
{
TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer);
- sub_8113A1C(1);
- sub_8110E3C();
+ TryRecordEvent41_IncCursor(1);
+ TryRecordEvent39_GoToNextScene();
gUnknown_3005E88 = 0;
gQuestLogState = 0;
sQuestLogCB = NULL;
}
gUnknown_203AE04 = NULL;
- gUnknown_203AE08 = NULL;
+ sEventRecordingPointer = NULL;
}
void sub_81123BC(void)
@@ -1414,7 +1414,7 @@ void sub_8112450(void)
{
if (MenuHelpers_LinkSomething() != TRUE)
{
- sub_8112364();
+ QuestLog_OnInteractionWithSpecialNpc();
sub_81123BC();
}
}
@@ -2442,7 +2442,7 @@ void SetQuestLogEvent(u16 eventId, const u16 *eventData)
{
if (gUnknown_203AE04 == NULL)
{
- gUnknown_203AE04 = gUnknown_203AE08;
+ gUnknown_203AE04 = sEventRecordingPointer;
r1 = sQuestLogStorageCBs[eventId](gUnknown_203AE04, eventData);
}
else
@@ -2454,7 +2454,7 @@ void SetQuestLogEvent(u16 eventId, const u16 *eventData)
else
{
gUnknown_203AE04 = NULL;
- r1 = sQuestLogStorageCBs[eventId](gUnknown_203AE08, eventData);
+ r1 = sQuestLogStorageCBs[eventId](sEventRecordingPointer, eventData);
}
if (r1 == NULL)
@@ -2465,7 +2465,7 @@ void SetQuestLogEvent(u16 eventId, const u16 *eventData)
return;
}
- gUnknown_203AE08 = r1;
+ sEventRecordingPointer = r1;
if (gUnknown_203B048 == 0)
return;
sub_811231C();
@@ -2517,7 +2517,7 @@ bool8 sub_8113748(void)
return TRUE;
if (gQuestLogState == QL_STATE_1)
- sub_8112364();
+ QuestLog_OnInteractionWithSpecialNpc();
return FALSE;
}
@@ -2583,11 +2583,11 @@ static u16 *sub_8113828(u16 eventId, const u16 *eventData)
sub_8113B94(eventId);
if (eventId == QL_EVENT_DEFEATED_WILD_MON)
- gUnknown_203AE04 = gUnknown_203AE08;
+ gUnknown_203AE04 = sEventRecordingPointer;
else
gUnknown_203AE04 = NULL;
- return sQuestLogStorageCBs[eventId](gUnknown_203AE08, eventData);
+ return sQuestLogStorageCBs[eventId](sEventRecordingPointer, eventData);
}
static bool8 TrySetLinkQuestLogEvent(u16 eventId, const u16 *eventData)
@@ -2613,15 +2613,15 @@ void sub_81138F8(void)
gUnknown_203B024 = (struct UnkStruct_203B024){};
}
-void sub_811390C(void)
+void QuestLog_StartRecordingInputsAfterDeferredEvent(void)
{
if (gUnknown_203B024.unk_00 != QL_EVENT_0)
{
u16 *resp;
gUnknown_203B04A = 0;
StartRecordingQuestLogEntry(gUnknown_203B024.unk_00);
- resp = sQuestLogStorageCBs[gUnknown_203B024.unk_00](gUnknown_203AE08, gUnknown_203B024.unk_04);
- gUnknown_203AE08 = resp;
+ resp = sQuestLogStorageCBs[gUnknown_203B024.unk_00](sEventRecordingPointer, gUnknown_203B024.unk_04);
+ sEventRecordingPointer = resp;
sub_81138F8();
}
}
@@ -2654,17 +2654,17 @@ void sub_81139BC(void)
StartRecordingQuestLogEntry(gUnknown_203B024.unk_00);
}
sub_8113B94(gUnknown_203B024.unk_00);
- resp = sQuestLogStorageCBs[gUnknown_203B024.unk_00](gUnknown_203AE08, gUnknown_203B024.unk_04);
- gUnknown_203AE08 = resp;
- sub_8113A1C(1);
+ resp = sQuestLogStorageCBs[gUnknown_203B024.unk_00](sEventRecordingPointer, gUnknown_203B024.unk_04);
+ sEventRecordingPointer = resp;
+ TryRecordEvent41_IncCursor(1);
sub_81138F8();
sub_811231C();
}
}
-static void sub_8113A1C(u16 a0)
+static void TryRecordEvent41_IncCursor(u16 a0)
{
- gUnknown_203AE08 = sub_8113C5C(gUnknown_203AE08, a0);
+ sEventRecordingPointer = TryRecordEvent41(sEventRecordingPointer, a0);
sQuestLogCursor++;
}
@@ -2853,9 +2853,9 @@ static void sub_8113BD8(void)
gUnknown_203B04B = FALSE;
}
-static u16 *sub_8113BF4(u16 *a0)
+static u16 *TryRecordEvent39_NoParams(u16 *a0)
{
- if (!sub_8110988(a0, sQuestLogEventCmdSizes[QL_EVENT_39]))
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_39]))
return NULL;
a0[0] = QL_EVENT_39;
return a0 + 1;
@@ -2863,7 +2863,7 @@ static u16 *sub_8113BF4(u16 *a0)
static u16 *sub_8113C20(u16 *a0, struct QuestLogEntry * a1)
{
- if (!sub_8110988(a0, sQuestLogEventCmdSizes[QL_EVENT_39]))
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_39]))
return NULL;
a1->unk_6 = 0xFF;
a1->unk_4 = 0;
@@ -2874,9 +2874,9 @@ static u16 *sub_8113C20(u16 *a0, struct QuestLogEntry * a1)
return a0 + 1;
}
-static u16 *sub_8113C5C(u16 *a0, u16 a1)
+static u16 *TryRecordEvent41(u16 *a0, u16 a1)
{
- if (!sub_8110988(a0, sQuestLogEventCmdSizes[QL_EVENT_41]))
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_41]))
return NULL;
a0[0] = QL_EVENT_41;
a0[1] = a1;
@@ -2885,7 +2885,7 @@ static u16 *sub_8113C5C(u16 *a0, u16 a1)
static u16 *sub_8113C8C(u16 *a0, struct QuestLogEntry * a1)
{
- if (!sub_8110988(a0, sQuestLogEventCmdSizes[QL_EVENT_41]))
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_41]))
return NULL;
a1->unk_6 = 0xFE;
a1->unk_4 = a0[1];
@@ -2900,7 +2900,7 @@ static u16 *sub_8113CC8(u16 *a0, struct QuestLogEntry * a1)
{
u8 *r6 = (u8 *)a0 + 4;
- if (!sub_8110988(a0, sQuestLogEventCmdSizes[QL_EVENT_0]))
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_0]))
return NULL;
a0[0] = 0;
a0[1] = a1->unk_4;
@@ -2915,7 +2915,7 @@ static u16 *sub_8113D08(u16 *a0, struct QuestLogEntry * a1)
{
u8 *r6 = (u8 *)a0 + 4;
- if (!sub_8110988(a0, sQuestLogEventCmdSizes[QL_EVENT_0]))
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_0]))
return NULL;
a1->unk_6 = 2;
a1->unk_4 = a0[1];
@@ -2931,7 +2931,7 @@ static u16 *sub_8113D48(u16 *a0, struct QuestLogEntry * a1)
u16 *r4 = a0;
u8 *r6 = (u8 *)a0 + 4;
- if (!sub_8110988(r4, sQuestLogEventCmdSizes[QL_EVENT_2]))
+ if (!WillCommandOfSizeFitInSav1Record(r4, sQuestLogEventCmdSizes[QL_EVENT_2]))
return NULL;
if (a1->unk_6 == 0)
r4[0] = 2;
@@ -2950,7 +2950,7 @@ static u16 *sub_8113D94(u16 *a0, struct QuestLogEntry * a1)
u16 *r5 = a0;
u8 *r6 = (u8 *)a0 + 4;
- if (!sub_8110988(r5, sQuestLogEventCmdSizes[QL_EVENT_2]))
+ if (!WillCommandOfSizeFitInSav1Record(r5, sQuestLogEventCmdSizes[QL_EVENT_2]))
return NULL;
if (r5[0] == 2)
a1->unk_6 = 0;