Quest log doc cleanup
This commit is contained in:
+6
-6
@@ -192,15 +192,15 @@ u16 *GetVarPointer(u16 idx)
|
||||
{
|
||||
switch (gQuestLogPlaybackState)
|
||||
{
|
||||
case QL_PLAYBACK_STATE_0:
|
||||
case QL_PLAYBACK_STATE_STOPPED:
|
||||
default:
|
||||
break;
|
||||
case QL_PLAYBACK_STATE_1:
|
||||
case QL_PLAYBACK_STATE_RUNNING:
|
||||
ptr = QuestLogGetFlagOrVarPtr(FALSE, idx);
|
||||
if (ptr != NULL)
|
||||
gSaveBlock1Ptr->vars[idx - VARS_START] = *ptr;
|
||||
break;
|
||||
case QL_PLAYBACK_STATE_2:
|
||||
case QL_PLAYBACK_STATE_RECORDING:
|
||||
if (IsFlagOrVarStoredInQuestLog(idx - VARS_START, TRUE) == TRUE)
|
||||
{
|
||||
gLastQuestLogStoredFlagOrVarIdx = idx - VARS_START;
|
||||
@@ -263,15 +263,15 @@ u8 *GetFlagAddr(u16 idx)
|
||||
{
|
||||
switch (gQuestLogPlaybackState)
|
||||
{
|
||||
case QL_PLAYBACK_STATE_0:
|
||||
case QL_PLAYBACK_STATE_STOPPED:
|
||||
default:
|
||||
break;
|
||||
case QL_PLAYBACK_STATE_1:
|
||||
case QL_PLAYBACK_STATE_RUNNING:
|
||||
ptr = QuestLogGetFlagOrVarPtr(TRUE, idx);
|
||||
if (ptr != NULL)
|
||||
gSaveBlock1Ptr->flags[idx / 8] = *ptr;
|
||||
break;
|
||||
case QL_PLAYBACK_STATE_2:
|
||||
case QL_PLAYBACK_STATE_RECORDING:
|
||||
if (IsFlagOrVarStoredInQuestLog(idx, FALSE) == TRUE)
|
||||
{
|
||||
gLastQuestLogStoredFlagOrVarIdx = idx;
|
||||
|
||||
@@ -1677,8 +1677,8 @@ void CopyObjectGraphicsInfoToSpriteTemplate(u16 graphicsId, void (*callback)(str
|
||||
|
||||
do
|
||||
{
|
||||
if (ScriptContext_IsEnabled() != TRUE && sub_8112CAC() == 1)
|
||||
spriteTemplate->callback = sub_811246C;
|
||||
if (ScriptContext_IsEnabled() != TRUE && QL_GetPlaybackState() == QL_PLAYBACK_STATE_RUNNING)
|
||||
spriteTemplate->callback = QL_UpdateObject;
|
||||
else
|
||||
spriteTemplate->callback = callback;
|
||||
} while (0);
|
||||
@@ -5046,7 +5046,7 @@ bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *objectEvent)
|
||||
|
||||
bool8 ObjectEventSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementActionId)
|
||||
{
|
||||
if(sub_8112CAC() == TRUE)
|
||||
if (QL_GetPlaybackState() == QL_PLAYBACK_STATE_RUNNING)
|
||||
ObjectEventClearHeldMovementIfActive(objectEvent);
|
||||
else if (ObjectEventIsMovementOverridden(objectEvent))
|
||||
return TRUE;
|
||||
@@ -5122,7 +5122,7 @@ void UpdateObjectEventCurrentMovement(struct ObjectEvent *objectEvent, struct Sp
|
||||
ObjectEventUpdateSubpriority(objectEvent, sprite);
|
||||
}
|
||||
|
||||
void UpdateQuestLogObjectEventCurrentMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
void QL_UpdateObjectEventCurrentMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
DoGroundEffects_OnSpawn(objectEvent, sprite);
|
||||
TryEnableObjectEventAnim(objectEvent, sprite);
|
||||
@@ -5267,7 +5267,7 @@ static void ObjectEventSetSingleMovement(struct ObjectEvent *objectEvent, struct
|
||||
objectEvent->movementActionId = movementActionId;
|
||||
sprite->data[2] = 0;
|
||||
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_2)
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_RECORDING)
|
||||
QuestLogRecordNPCStep(objectEvent->localId, objectEvent->mapNum, objectEvent->mapGroup, movementActionId);
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -71,7 +71,7 @@ static bool8 TryDoorWarp(struct MapPosition * position, u16 metatileBehavior, u8
|
||||
static s8 GetWarpEventAtPosition(struct MapHeader * mapHeader, u16 x, u16 y, u8 z);
|
||||
static const u8 *GetCoordEventScriptAtPosition(struct MapHeader * mapHeader, u16 x, u16 y, u8 z);
|
||||
|
||||
struct FieldInput gInputToStoreInQuestLogMaybe;
|
||||
struct FieldInput gFieldInputRecord;
|
||||
|
||||
void FieldClearPlayerInput(struct FieldInput *input)
|
||||
{
|
||||
@@ -203,8 +203,8 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
metatileAttributes = MapGridGetMetatileAttributeAt(position.x, position.y, METATILE_ATTRIBUTES_ALL);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
|
||||
FieldClearPlayerInput(&gInputToStoreInQuestLogMaybe);
|
||||
gInputToStoreInQuestLogMaybe.dpadDirection = input->dpadDirection;
|
||||
FieldClearPlayerInput(&gFieldInputRecord);
|
||||
gFieldInputRecord.dpadDirection = input->dpadDirection;
|
||||
|
||||
if (CheckForTrainersWantingBattle() == TRUE)
|
||||
return TRUE;
|
||||
@@ -222,7 +222,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
IncrementBirthIslandRockStepCount();
|
||||
if (TryStartStepBasedScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.tookStep = TRUE;
|
||||
gFieldInputRecord.tookStep = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -234,7 +234,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
if (TrySetUpWalkIntoSignpostScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.checkStandardWildEncounter = TRUE;
|
||||
gFieldInputRecord.checkStandardWildEncounter = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
GetPlayerPosition(&position);
|
||||
@@ -243,14 +243,14 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
}
|
||||
if (input->checkStandardWildEncounter && CheckStandardWildEncounter(metatileAttributes) == TRUE)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.checkStandardWildEncounter = TRUE;
|
||||
gFieldInputRecord.checkStandardWildEncounter = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
if (input->heldDirection && input->dpadDirection == playerDirection)
|
||||
{
|
||||
if (TryArrowWarp(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.heldDirection = TRUE;
|
||||
gFieldInputRecord.heldDirection = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -261,14 +261,14 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
{
|
||||
if (TrySetUpWalkIntoSignpostScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.heldDirection = TRUE;
|
||||
gFieldInputRecord.heldDirection = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (input->pressedAButton && TryStartInteractionScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.pressedAButton = TRUE;
|
||||
gFieldInputRecord.pressedAButton = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -276,14 +276,14 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
{
|
||||
if (TryDoorWarp(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.heldDirection2 = TRUE;
|
||||
gFieldInputRecord.heldDirection2 = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (input->pressedStartButton)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.pressedStartButton = TRUE;
|
||||
gFieldInputRecord.pressedStartButton = TRUE;
|
||||
FlagSet(FLAG_OPENED_START_MENU);
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
@@ -291,7 +291,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
}
|
||||
if (input->pressedSelectButton && UseRegisteredKeyItemOnField() == TRUE)
|
||||
{
|
||||
gInputToStoreInQuestLogMaybe.pressedSelectButton = TRUE;
|
||||
gFieldInputRecord.pressedSelectButton = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1602,11 +1602,11 @@ void CreateStopSurfingTask_NoMusicChange(u8 direction)
|
||||
|
||||
void SeafoamIslandsB4F_CurrentDumpsPlayerOnLand(void)
|
||||
{
|
||||
if (gQuestLogPlaybackState != QL_PLAYBACK_STATE_1 && gQuestLogPlaybackState != QL_PLAYBACK_STATE_3)
|
||||
{
|
||||
QuestLogRecordPlayerAvatarGfxTransitionWithDuration(sQuestLogSurfDismountActionIds[DIR_NORTH], 16);
|
||||
CreateStopSurfingTask(DIR_NORTH);
|
||||
}
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_RUNNING || gQuestLogPlaybackState == QL_PLAYBACK_STATE_ACTION_END)
|
||||
return;
|
||||
|
||||
QuestLogRecordPlayerAvatarGfxTransitionWithDuration(sQuestLogSurfDismountActionIds[DIR_NORTH], 16);
|
||||
CreateStopSurfingTask(DIR_NORTH);
|
||||
}
|
||||
|
||||
static void Task_StopSurfingInit(u8 taskId)
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ void SetSaveBlocksPointers(void)
|
||||
gPokemonStoragePtr = (void *)(&gPokemonStorage) + offset;
|
||||
|
||||
SetBagPocketsPointers();
|
||||
SetQuestLogRecordAndPlaybackPointers(oldSave);
|
||||
QL_AddASLROffset(oldSave);
|
||||
}
|
||||
|
||||
void MoveSaveBlocks_ResetHeap(void)
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ static void InitMainCallbacks(void)
|
||||
gSaveBlock2Ptr = &gSaveBlock2;
|
||||
gSaveBlock1Ptr = &gSaveBlock1;
|
||||
gSaveBlock2.encryptionKey = 0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
}
|
||||
|
||||
static void CallCallbacks(void)
|
||||
|
||||
+13
-13
@@ -772,7 +772,7 @@ void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum)
|
||||
InitSecondaryTilesetAnimation();
|
||||
UpdateLocationHistoryForRoamer();
|
||||
RoamerMove();
|
||||
sub_8110920();
|
||||
QL_ResetDefeatedWildMonRecord();
|
||||
DoCurrentWeather();
|
||||
ResetFieldTasksArgs();
|
||||
RunOnResumeMapScript();
|
||||
@@ -803,7 +803,7 @@ static void LoadMapFromWarp(bool32 unused)
|
||||
TryRegenerateRenewableHiddenItems();
|
||||
UpdateLocationHistoryForRoamer();
|
||||
RoamerMoveToOtherLocationSet();
|
||||
sub_8110920();
|
||||
QL_ResetDefeatedWildMonRecord();
|
||||
InitMap();
|
||||
}
|
||||
|
||||
@@ -818,7 +818,7 @@ static void QL_LoadMapNormal(void)
|
||||
SetSavedWeatherFromCurrMapHeader();
|
||||
ChooseAmbientCrySpecies();
|
||||
SetDefaultFlashLevel();
|
||||
sub_8110920();
|
||||
QL_ResetDefeatedWildMonRecord();
|
||||
QL_RestoreMapLayoutId();
|
||||
LoadSaveblockMapHeader();
|
||||
InitMap();
|
||||
@@ -1390,7 +1390,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
|
||||
{
|
||||
struct FieldInput fieldInput;
|
||||
|
||||
sub_8112B3C();
|
||||
QL_TryRunActions();
|
||||
UpdatePlayerAvatarTransitionState();
|
||||
FieldClearPlayerInput(&fieldInput);
|
||||
FieldGetPlayerInput(&fieldInput, newKeys, heldKeys);
|
||||
@@ -1399,8 +1399,8 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
|
||||
{
|
||||
if (ProcessPlayerFieldInput(&fieldInput) == TRUE)
|
||||
{
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_2)
|
||||
sub_81127F8(&gInputToStoreInQuestLogMaybe);
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_RECORDING)
|
||||
QL_RecordFieldInput(&gFieldInputRecord);
|
||||
LockPlayerFieldControls();
|
||||
DismissMapNamePopup();
|
||||
}
|
||||
@@ -1416,9 +1416,9 @@ static void DoCB1_Overworld_QuestLogPlayback(void)
|
||||
{
|
||||
struct FieldInput fieldInput;
|
||||
|
||||
sub_8112B3C();
|
||||
QL_TryRunActions();
|
||||
UpdatePlayerAvatarTransitionState();
|
||||
HandleQuestLogInput();
|
||||
QL_HandleInput();
|
||||
FieldClearPlayerInput(&fieldInput);
|
||||
fieldInput = gQuestLogFieldInput;
|
||||
FieldInput_HandleCancelSignpost(&fieldInput);
|
||||
@@ -1445,7 +1445,7 @@ void CB1_Overworld(void)
|
||||
{
|
||||
if (gMain.callback2 == CB2_Overworld)
|
||||
{
|
||||
if (sub_8112CAC() == 1 || gQuestLogState == QL_STATE_PLAYBACK)
|
||||
if (QL_GetPlaybackState() == QL_PLAYBACK_STATE_RUNNING || gQuestLogState == QL_STATE_PLAYBACK)
|
||||
DoCB1_Overworld_QuestLogPlayback();
|
||||
else
|
||||
DoCB1_Overworld(gMain.newKeys, gMain.heldKeys);
|
||||
@@ -2239,8 +2239,8 @@ static bool32 LoadMap_QLPlayback(u8 *state)
|
||||
InitOverworldBgs();
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
QuestLog_InitPalettesBackup();
|
||||
sub_81113E4();
|
||||
sub_8111438();
|
||||
QL_CopySaveState();
|
||||
QL_ResetPartyAndPC();
|
||||
if (GetQuestLogStartType() == QL_START_WARP)
|
||||
{
|
||||
gExitStairsMovementDisabled = FALSE;
|
||||
@@ -2254,7 +2254,7 @@ static bool32 LoadMap_QLPlayback(u8 *state)
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_8110FCC();
|
||||
QL_InitSceneObjectsAndActions();
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
@@ -2296,7 +2296,7 @@ static bool32 LoadMap_QLPlayback(u8 *state)
|
||||
break;
|
||||
case 10:
|
||||
InitTilesetAnimations();
|
||||
sub_815A540();
|
||||
QL_TryStopSurfing();
|
||||
(*state)++;
|
||||
break;
|
||||
default:
|
||||
|
||||
+176
-190
@@ -30,32 +30,6 @@
|
||||
#include "constants/field_weather.h"
|
||||
#include "constants/event_object_movement.h"
|
||||
|
||||
/*
|
||||
QUEST LOG
|
||||
|
||||
## What is the Quest Log?
|
||||
|
||||
When the player resumes playing a saved game a black-and-white sequence will play recounting some
|
||||
significant events that happened leading up to the last time the player saved.
|
||||
The name comes from the text displayed at the top of these scenes: "Previously on your quest..."
|
||||
|
||||
## Quest Log Terminology
|
||||
|
||||
- "Scene": This is the name for each sequence that plays during the quest log. There are QUEST_LOG_SCENE_COUNT (4)
|
||||
of these scenes that play, after which a final screen shows where the game was saved before the game resumes.
|
||||
All the data stored for each scene is in 'struct QuestLogScene', defined in include/global.h.
|
||||
The entirety of the Quest Log's save data is represented by an array of these scenes in SaveBlock1.
|
||||
|
||||
- "Action": TODO: Copy from quest_log.h
|
||||
|
||||
- "Event":
|
||||
|
||||
- "Command":
|
||||
|
||||
- "Script":
|
||||
|
||||
*/
|
||||
|
||||
enum {
|
||||
WIN_TOP_BAR, // Contains the "Previously on..." text
|
||||
WIN_BOTTOM_BAR, // Empty, only briefly visible at the end or when the description window isn't covering it.
|
||||
@@ -65,6 +39,7 @@ enum {
|
||||
|
||||
#define DESC_WIN_WIDTH (DISPLAY_WIDTH / 8)
|
||||
#define DESC_WIN_HEIGHT 6
|
||||
#define DESC_WIN_SIZE (DESC_WIN_WIDTH * DESC_WIN_HEIGHT * TILE_SIZE_4BPP)
|
||||
|
||||
// sQuestLogActionRecordBuffer should be large enough to fill a scene's script with the maximum number of actions
|
||||
#define SCRIPT_BUFFER_SIZE (sizeof(gSaveBlock1Ptr->questLog[0].script) / sizeof(struct QuestLogAction))
|
||||
@@ -92,7 +67,6 @@ struct FlagOrVarRecord
|
||||
u16 value;
|
||||
};
|
||||
|
||||
|
||||
u8 gQuestLogPlaybackState;
|
||||
u16 sMaxActionsInScene;
|
||||
struct FieldInput gQuestLogFieldInput;
|
||||
@@ -106,9 +80,9 @@ static EWRAM_DATA u8 sNumScenes = 0;
|
||||
EWRAM_DATA u8 gQuestLogState = 0;
|
||||
static EWRAM_DATA u16 sRecordSequenceStartIdx = 0;
|
||||
static EWRAM_DATA u8 sWindowIds[WIN_COUNT] = {0};
|
||||
EWRAM_DATA u16 *gUnknown_203AE04 = NULL;
|
||||
EWRAM_DATA u16 *gQuestLogDefeatedWildMonRecord = NULL;
|
||||
EWRAM_DATA u16 *gQuestLogRecordingPointer = NULL;
|
||||
static EWRAM_DATA u16 *sUnknown_203AE0C[32] = {NULL};
|
||||
static EWRAM_DATA u16 *sEventData[32] = {NULL};
|
||||
static EWRAM_DATA void (* sQuestLogCB)(void) = NULL;
|
||||
static EWRAM_DATA u16 *sPalettesBackup = NULL;
|
||||
static EWRAM_DATA struct PlaybackControl sPlaybackControl = {0};
|
||||
@@ -129,7 +103,7 @@ static void BackUpMapLayout(void);
|
||||
static void SetGameStateAtScene(u8);
|
||||
static u8 TryRecordActionSequence(struct QuestLogAction *);
|
||||
static void Task_BeginQuestLogPlayback(u8);
|
||||
static void QuestLogPlaybackSetObjectEventTemplates(u8);
|
||||
static void QL_LoadObjectsAndTemplates(u8);
|
||||
static void QLPlayback_InitOverworldState(void);
|
||||
static void SetPokemonCounts(void);
|
||||
static u16 QuestLog_GetPartyCount(void);
|
||||
@@ -153,10 +127,10 @@ static void Task_FinalScene_WaitFade(u8);
|
||||
static void Task_QuestLogScene_SavedGame(u8);
|
||||
static void Task_WaitAtEndOfQuestLog(u8);
|
||||
static void Task_EndQuestLog(u8);
|
||||
static bool8 sub_81121D8(u8);
|
||||
static bool8 RestoreScreenAfterPlayback(u8);
|
||||
static void QL_SlightlyDarkenSomePals(void);
|
||||
static void TogglePlaybackStateForOverworldLock(u8);
|
||||
static void SetUpQuestLogAction(u8, struct QuestLogAction *, u16);
|
||||
static void ResetActions(u8, struct QuestLogAction *, u16);
|
||||
static bool8 RecordHeadAtEndOfEntryOrScriptContext2Enabled(void);
|
||||
static bool8 RecordHeadAtEndOfEntry(void);
|
||||
static bool8 InQuestLogDisabledLocation(void);
|
||||
@@ -199,22 +173,27 @@ static const u16 sDescriptionWindow_Gfx[] = INCBIN_U16("graphics/quest_log/descr
|
||||
|
||||
static const u8 sQuestLogTextLineYCoords[] = {17, 10, 3};
|
||||
|
||||
void SetQuestLogRecordAndPlaybackPointers(void *oldPointer)
|
||||
void QL_AddASLROffset(void *oldSaveBlockPtr)
|
||||
{
|
||||
ptrdiff_t offset = (void *)gSaveBlock1Ptr - oldPointer;
|
||||
if (gUnknown_203AE04)
|
||||
gUnknown_203AE04 = (void *)gUnknown_203AE04 + offset;
|
||||
if (gQuestLogState != 0)
|
||||
// For some reason the caller passes the original pointer and the
|
||||
// amount the save moved is recalculated, instead of just passing
|
||||
// the offset to begin with.
|
||||
ptrdiff_t offset = (void *)gSaveBlock1Ptr - oldSaveBlockPtr;
|
||||
if (gQuestLogDefeatedWildMonRecord)
|
||||
gQuestLogDefeatedWildMonRecord = (void *)gQuestLogDefeatedWildMonRecord + offset;
|
||||
|
||||
if (gQuestLogState == 0)
|
||||
return;
|
||||
|
||||
if (gQuestLogRecordingPointer)
|
||||
gQuestLogRecordingPointer = (void *)gQuestLogRecordingPointer + offset;
|
||||
|
||||
if (gQuestLogState == QL_STATE_PLAYBACK)
|
||||
{
|
||||
if (gQuestLogRecordingPointer)
|
||||
gQuestLogRecordingPointer = (void *)gQuestLogRecordingPointer + offset;
|
||||
if (gQuestLogState == QL_STATE_PLAYBACK)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)ARRAY_COUNT(sUnknown_203AE0C); i++)
|
||||
if (sUnknown_203AE0C[i])
|
||||
sUnknown_203AE0C[i] = (void *)sUnknown_203AE0C[i] + offset;
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < (int)ARRAY_COUNT(sEventData); i++)
|
||||
if (sEventData[i])
|
||||
sEventData[i] = (void *)sEventData[i] + offset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,20 +204,20 @@ void ResetQuestLog(void)
|
||||
gQuestLogState = 0;
|
||||
sQuestLogCB = NULL;
|
||||
gQuestLogRecordingPointer = NULL;
|
||||
gUnknown_203AE04 = NULL;
|
||||
sub_8113BD8();
|
||||
gQuestLogDefeatedWildMonRecord = NULL;
|
||||
QL_ResetEventStates();
|
||||
ResetDeferredLinkEvent();
|
||||
}
|
||||
|
||||
static void ClearSavedScene(u8 sceneNum)
|
||||
{
|
||||
memset(&gSaveBlock1Ptr->questLog[sceneNum], 0, sizeof(gSaveBlock1Ptr->questLog[sceneNum]));
|
||||
gUnknown_203AE04 = NULL;
|
||||
gQuestLogDefeatedWildMonRecord = NULL;
|
||||
}
|
||||
|
||||
void sub_8110920(void)
|
||||
void QL_ResetDefeatedWildMonRecord(void)
|
||||
{
|
||||
gUnknown_203AE04 = NULL;
|
||||
gQuestLogDefeatedWildMonRecord = NULL;
|
||||
}
|
||||
|
||||
void RunQuestLogCB(void)
|
||||
@@ -281,7 +260,7 @@ static void QLogCB_Recording(void)
|
||||
{
|
||||
if (TryRecordActionSequence(sQuestLogActionRecordBuffer) != 1)
|
||||
{
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
RecordSceneEnd();
|
||||
gQuestLogState = 0;
|
||||
sQuestLogCB = NULL;
|
||||
@@ -295,10 +274,10 @@ static void QLogCB_Playback(void)
|
||||
|
||||
if (sPlaybackControl.endMode == END_MODE_NONE)
|
||||
{
|
||||
if (gQuestLogPlaybackState != QL_PLAYBACK_STATE_0
|
||||
if (gQuestLogPlaybackState != QL_PLAYBACK_STATE_STOPPED
|
||||
|| sPlaybackControl.state == 1
|
||||
|| (sPlaybackControl.cursor < ARRAY_COUNT(sUnknown_203AE0C)
|
||||
&& sUnknown_203AE0C[sPlaybackControl.cursor] != NULL))
|
||||
|| (sPlaybackControl.cursor < ARRAY_COUNT(sEventData)
|
||||
&& sEventData[sPlaybackControl.cursor] != NULL))
|
||||
QuestLog_PlayCurrentEvent();
|
||||
else
|
||||
{
|
||||
@@ -319,13 +298,13 @@ u8 GetQuestLogStartType(void)
|
||||
return gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType;
|
||||
}
|
||||
|
||||
void StartRecordingQuestLogAction(u16 eventId)
|
||||
void QL_StartRecordingAction(u16 eventId)
|
||||
{
|
||||
if (sCurrentSceneNum >= QUEST_LOG_SCENE_COUNT)
|
||||
sCurrentSceneNum = 0;
|
||||
|
||||
ClearSavedScene(sCurrentSceneNum);
|
||||
ResetUnk203B044();
|
||||
QL_ResetRepeatEventTracker();
|
||||
gQuestLogRecordingPointer = gSaveBlock1Ptr->questLog[sCurrentSceneNum].script;
|
||||
if (IS_LINK_QL_EVENT(eventId) || eventId == QL_EVENT_DEPARTED)
|
||||
gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType = QL_START_WARP;
|
||||
@@ -338,7 +317,7 @@ void StartRecordingQuestLogAction(u16 eventId)
|
||||
BackUpMapLayout();
|
||||
SetGameStateAtScene(sCurrentSceneNum);
|
||||
sRecordSequenceStartIdx = 0;
|
||||
SetUpQuestLogAction(2, sQuestLogActionRecordBuffer, sizeof(sQuestLogActionRecordBuffer));
|
||||
ResetActions(QL_PLAYBACK_STATE_RECORDING, sQuestLogActionRecordBuffer, sizeof(sQuestLogActionRecordBuffer));
|
||||
TryRecordActionSequence(sQuestLogActionRecordBuffer);
|
||||
SetQuestLogState(QL_STATE_RECORDING);
|
||||
}
|
||||
@@ -452,12 +431,12 @@ static bool8 TryRecordActionSequence(struct QuestLogAction * actions)
|
||||
}
|
||||
if (gQuestLogRecordingPointer == NULL)
|
||||
{
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_0)
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_STOPPED)
|
||||
{
|
||||
gQuestLogRecordingPointer = QL_RecordAction_SceneEnd(gQuestLogRecordingPointer);
|
||||
return FALSE;
|
||||
@@ -502,12 +481,12 @@ static void Task_BeginQuestLogPlayback(u8 taskId)
|
||||
QLPlayback_InitOverworldState();
|
||||
}
|
||||
|
||||
void sub_8110FCC(void)
|
||||
void QL_InitSceneObjectsAndActions(void)
|
||||
{
|
||||
ReadQuestLogScriptFromSav1(sCurrentSceneNum, sQuestLogActionRecordBuffer);
|
||||
ResetUnk203B044();
|
||||
SetUpQuestLogAction(1, sQuestLogActionRecordBuffer, sizeof(sQuestLogActionRecordBuffer));
|
||||
QuestLogPlaybackSetObjectEventTemplates(sCurrentSceneNum);
|
||||
QL_ResetRepeatEventTracker();
|
||||
ResetActions(QL_PLAYBACK_STATE_RUNNING, sQuestLogActionRecordBuffer, sizeof(sQuestLogActionRecordBuffer));
|
||||
QL_LoadObjectsAndTemplates(sCurrentSceneNum);
|
||||
}
|
||||
|
||||
static bool8 FieldCB2_QuestLogStartPlaybackWithWarpExit(void)
|
||||
@@ -563,7 +542,7 @@ void CommitQuestLogWindow1(void)
|
||||
CopyWindowToVram(sWindowIds[WIN_BOTTOM_BAR], COPYWIN_MAP);
|
||||
}
|
||||
|
||||
static void QuestLogPlaybackSetObjectEventTemplates(u8 sceneNum)
|
||||
static void QL_LoadObjectsAndTemplates(u8 sceneNum)
|
||||
{
|
||||
struct QuestLogScene *questLog = &gSaveBlock1Ptr->questLog[sceneNum];
|
||||
u16 i;
|
||||
@@ -587,8 +566,6 @@ static void QuestLogPlaybackSetObjectEventTemplates(u8 sceneNum)
|
||||
|
||||
static void QLPlayback_SetInitialPlayerPosition(u8 sceneNum, bool8 isWarp)
|
||||
{
|
||||
struct WarpData sp0;
|
||||
|
||||
if (!isWarp)
|
||||
{
|
||||
gSaveBlock1Ptr->location.mapGroup = gSaveBlock1Ptr->questLog[sceneNum].mapGroup;
|
||||
@@ -599,12 +576,13 @@ static void QLPlayback_SetInitialPlayerPosition(u8 sceneNum, bool8 isWarp)
|
||||
}
|
||||
else
|
||||
{
|
||||
sp0.mapGroup = gSaveBlock1Ptr->questLog[sceneNum].mapGroup;
|
||||
sp0.mapNum = gSaveBlock1Ptr->questLog[sceneNum].mapNum;
|
||||
sp0.warpId = gSaveBlock1Ptr->questLog[sceneNum].warpId;
|
||||
sp0.x = gSaveBlock1Ptr->questLog[sceneNum].x;
|
||||
sp0.y = gSaveBlock1Ptr->questLog[sceneNum].y;
|
||||
Overworld_SetWarpDestinationFromWarp(&sp0);
|
||||
struct WarpData warp;
|
||||
warp.mapGroup = gSaveBlock1Ptr->questLog[sceneNum].mapGroup;
|
||||
warp.mapNum = gSaveBlock1Ptr->questLog[sceneNum].mapNum;
|
||||
warp.warpId = gSaveBlock1Ptr->questLog[sceneNum].warpId;
|
||||
warp.x = gSaveBlock1Ptr->questLog[sceneNum].x;
|
||||
warp.y = gSaveBlock1Ptr->questLog[sceneNum].y;
|
||||
Overworld_SetWarpDestinationFromWarp(&warp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,7 +607,7 @@ static void QLPlayback_InitOverworldState(void)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81113E4(void)
|
||||
void QL_CopySaveState(void)
|
||||
{
|
||||
struct QuestLogScene * questLog = &gSaveBlock1Ptr->questLog[sCurrentSceneNum];
|
||||
|
||||
@@ -638,22 +616,22 @@ void sub_81113E4(void)
|
||||
RestoreTrainerRematches();
|
||||
}
|
||||
|
||||
struct PokemonAndSomethingElse
|
||||
{
|
||||
struct Pokemon mon;
|
||||
u16 partyCount;
|
||||
u16 boxMonCount;
|
||||
};
|
||||
// The number of bits allocated to store the number of pokemon in the PC
|
||||
#define NUM_PC_COUNT_BITS 12
|
||||
|
||||
void sub_8111438(void)
|
||||
void QL_ResetPartyAndPC(void)
|
||||
{
|
||||
struct PokemonAndSomethingElse *prev = AllocZeroed(sizeof(struct PokemonAndSomethingElse));
|
||||
struct {
|
||||
struct Pokemon mon;
|
||||
u16 partyCount;
|
||||
u16 boxMonCount;
|
||||
} *prev = AllocZeroed(sizeof(*prev));
|
||||
u16 packedCounts, i, count, j;
|
||||
|
||||
CreateMon(&prev->mon, SPECIES_RATTATA, 1, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0);
|
||||
packedCounts = VarGet(VAR_QUEST_LOG_MON_COUNTS);
|
||||
prev->partyCount = packedCounts >> 12;
|
||||
prev->boxMonCount = packedCounts % 0x1000;
|
||||
prev->partyCount = packedCounts >> NUM_PC_COUNT_BITS;
|
||||
prev->boxMonCount = packedCounts % (1 << NUM_PC_COUNT_BITS);
|
||||
|
||||
count = QuestLog_GetPartyCount();
|
||||
if (count > prev->partyCount)
|
||||
@@ -663,9 +641,11 @@ void sub_8111438(void)
|
||||
}
|
||||
else if (count < prev->partyCount)
|
||||
{
|
||||
// Clear 5 slots in the PC?
|
||||
for (i = 0; i < PARTY_SIZE - 1; i++)
|
||||
ZeroBoxMonAt(0, i);
|
||||
|
||||
// Replace the additional slots with placeholder Pokémon.
|
||||
for (i = count; i < prev->partyCount; i++)
|
||||
CopyMon(&gPlayerParty[i], &prev->mon, sizeof(struct Pokemon));
|
||||
}
|
||||
@@ -697,6 +677,7 @@ void sub_8111438(void)
|
||||
struct BoxPokemon * boxMon = GetBoxedMonPtr(i, j);
|
||||
if (!GetBoxMonData(boxMon, MON_DATA_SANITY_HAS_SPECIES))
|
||||
{
|
||||
// Replace the additional slots with placeholder Pokémon.
|
||||
CopyMon(boxMon, &prev->mon.box, sizeof(struct BoxPokemon));
|
||||
if (++count == prev->boxMonCount)
|
||||
break;
|
||||
@@ -713,7 +694,7 @@ static void SetPokemonCounts(void)
|
||||
{
|
||||
u16 partyCount = QuestLog_GetPartyCount();
|
||||
u16 boxesCount = QuestLog_GetBoxMonCount();
|
||||
VarSet(VAR_QUEST_LOG_MON_COUNTS, (partyCount << 12) + boxesCount);
|
||||
VarSet(VAR_QUEST_LOG_MON_COUNTS, (partyCount << NUM_PC_COUNT_BITS) + boxesCount);
|
||||
}
|
||||
|
||||
static u16 QuestLog_GetPartyCount(void)
|
||||
@@ -780,44 +761,44 @@ void QL_RestoreMapLayoutId(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void ReadQuestLogScriptFromSav1(u8 sceneNum, struct QuestLogAction * a1)
|
||||
static void ReadQuestLogScriptFromSav1(u8 sceneNum, struct QuestLogAction * actions)
|
||||
{
|
||||
u16 i;
|
||||
u16 *script;
|
||||
u16 r6 = 0;
|
||||
u16 r9 = 0;
|
||||
u16 actionNum = 0;
|
||||
u16 eventNum = 0;
|
||||
|
||||
memset(a1, 0, 32 * sizeof(struct QuestLogAction));
|
||||
for (i = 0; i < ARRAY_COUNT(sUnknown_203AE0C); i++)
|
||||
sUnknown_203AE0C[i] = NULL;
|
||||
memset(actions, 0, ARRAY_COUNT(sEventData) * sizeof(struct QuestLogAction));
|
||||
for (i = 0; i < ARRAY_COUNT(sEventData); i++)
|
||||
sEventData[i] = NULL;
|
||||
|
||||
script = gSaveBlock1Ptr->questLog[sceneNum].script;
|
||||
for (i = 0; i < 32; i++)
|
||||
for (i = 0; i < ARRAY_COUNT(sEventData); i++)
|
||||
{
|
||||
switch (script[0] & QL_CMD_EVENT_MASK)
|
||||
{
|
||||
case QL_EVENT_INPUT:
|
||||
script = QL_LoadAction_Input(script, &a1[r6]);
|
||||
r6++;
|
||||
script = QL_LoadAction_Input(script, &actions[actionNum]);
|
||||
actionNum++;
|
||||
break;
|
||||
case QL_EVENT_GFX_CHANGE:
|
||||
case QL_EVENT_MOVEMENT:
|
||||
script = QL_LoadAction_MovementOrGfxChange(script, &a1[r6]);
|
||||
r6++;
|
||||
script = QL_LoadAction_MovementOrGfxChange(script, &actions[actionNum]);
|
||||
actionNum++;
|
||||
break;
|
||||
case QL_EVENT_SCENE_END:
|
||||
script = QL_LoadAction_SceneEnd(script, &a1[r6]);
|
||||
r6++;
|
||||
script = QL_LoadAction_SceneEnd(script, &actions[actionNum]);
|
||||
actionNum++;
|
||||
break;
|
||||
case QL_EVENT_WAIT:
|
||||
script = QL_LoadAction_Wait(script, &a1[r6]);
|
||||
r6++;
|
||||
script = QL_LoadAction_Wait(script, &actions[actionNum]);
|
||||
actionNum++;
|
||||
break;
|
||||
default: // Normal event
|
||||
script = QuestLog_SkipCommand(script, &sUnknown_203AE0C[r9]);
|
||||
if (r9 == 0)
|
||||
sub_8113ABC(sUnknown_203AE0C[0]);
|
||||
r9++;
|
||||
script = QL_SkipCommand(script, &sEventData[eventNum]);
|
||||
if (eventNum == 0)
|
||||
QL_UpdateLastDepartedLocation(sEventData[0]);
|
||||
eventNum++;
|
||||
break;
|
||||
}
|
||||
if (script == NULL)
|
||||
@@ -844,7 +825,7 @@ static void QuestLog_AdvancePlayhead(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
QuestLog_StartFinalScene();
|
||||
}
|
||||
}
|
||||
@@ -886,7 +867,7 @@ bool8 QL_AvoidDisplay(void (*callback)(void))
|
||||
QuestLog_CutRecording();
|
||||
break;
|
||||
case QL_STATE_PLAYBACK:
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_3;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_ACTION_END;
|
||||
taskId = CreateTask(Task_AvoidDisplay, 80);
|
||||
gTasks[taskId].tTimer = 0;
|
||||
gTasks[taskId].tState = 0;
|
||||
@@ -915,7 +896,7 @@ static void Task_AvoidDisplay(u8 taskId)
|
||||
case 1:
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
|
||||
// Call the provided function (if any). In practice this is always QL_DestroyAbortedDisplay
|
||||
routine = (void (*)(void)) GetWordTaskArg(taskId, DATA_IDX_CALLBACK);
|
||||
@@ -939,24 +920,24 @@ static void QuestLog_PlayCurrentEvent(void)
|
||||
if (--sPlaybackControl.timer != 0)
|
||||
return;
|
||||
sPlaybackControl.state = 0;
|
||||
sPlaybackControl.playingEvent = 1;
|
||||
sPlaybackControl.playingEvent = TRUE;
|
||||
TogglePlaybackStateForOverworldLock(2);
|
||||
}
|
||||
|
||||
if (sPlaybackControl.playingEvent == 1)
|
||||
if (sPlaybackControl.playingEvent == TRUE)
|
||||
{
|
||||
if (++sPlaybackControl.overlapTimer > 15)
|
||||
{
|
||||
QuestLog_CloseTextWindow();
|
||||
sPlaybackControl.playingEvent = 0;
|
||||
sPlaybackControl.playingEvent = FALSE;
|
||||
sPlaybackControl.overlapTimer = 0;
|
||||
}
|
||||
}
|
||||
if (sPlaybackControl.cursor < ARRAY_COUNT(sUnknown_203AE0C))
|
||||
if (sPlaybackControl.cursor < ARRAY_COUNT(sEventData))
|
||||
{
|
||||
if (sub_8113B44(sUnknown_203AE0C[sPlaybackControl.cursor]) == 1)
|
||||
if (QL_TryRepeatEvent(sEventData[sPlaybackControl.cursor]) == TRUE)
|
||||
HandleShowQuestLogMessage();
|
||||
else if (sub_8113AE8(sUnknown_203AE0C[sPlaybackControl.cursor]) == 1)
|
||||
else if (QL_LoadEvent(sEventData[sPlaybackControl.cursor]) == TRUE)
|
||||
HandleShowQuestLogMessage();
|
||||
}
|
||||
}
|
||||
@@ -966,12 +947,12 @@ static void HandleShowQuestLogMessage(void)
|
||||
if (sPlaybackControl.state == 0)
|
||||
{
|
||||
sPlaybackControl.state = 1;
|
||||
sPlaybackControl.playingEvent = 0;
|
||||
sPlaybackControl.playingEvent = FALSE;
|
||||
sPlaybackControl.overlapTimer = 0;
|
||||
sPlaybackControl.timer = GetQuestLogTextDisplayDuration();
|
||||
if (gUnknown_203B044.unk_2 == 0)
|
||||
if (gQuestLogRepeatEventTracker.counter == 0)
|
||||
sPlaybackControl.cursor++;
|
||||
if (sPlaybackControl.cursor > 32)
|
||||
if (sPlaybackControl.cursor > ARRAY_COUNT(sEventData))
|
||||
return;
|
||||
DrawSceneDescription();
|
||||
}
|
||||
@@ -998,16 +979,16 @@ static u8 GetQuestLogTextDisplayDuration(void)
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
bool8 sub_8111C2C(void)
|
||||
bool8 QL_IsTrainerSightDisabled(void)
|
||||
{
|
||||
if (gQuestLogState != QL_STATE_PLAYBACK)
|
||||
return FALSE;
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_0 || sPlaybackControl.state == 1 || sPlaybackControl.state == 2)
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_STOPPED || sPlaybackControl.state == 1 || sPlaybackControl.state == 2)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void HandleQuestLogInput(void)
|
||||
void QL_HandleInput(void)
|
||||
{
|
||||
// Ignore input if we're currently ending a scene/playback
|
||||
if (sPlaybackControl.endMode != END_MODE_NONE)
|
||||
@@ -1017,14 +998,14 @@ void HandleQuestLogInput(void)
|
||||
{
|
||||
// Pressed A, skip to next scene
|
||||
sPlaybackControl.endMode = END_MODE_SCENE;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
DoSceneEndTransition(-3);
|
||||
}
|
||||
else if (JOY_NEW(B_BUTTON))
|
||||
{
|
||||
// Pressed B, end playback
|
||||
sPlaybackControl.endMode = END_MODE_FINISH;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
DoSkipToEndTransition(-3);
|
||||
}
|
||||
}
|
||||
@@ -1062,7 +1043,7 @@ static void DrawSceneDescription(void)
|
||||
static void CopyDescriptionWindowTiles(u8 windowId)
|
||||
{
|
||||
const u16 *src = sDescriptionWindow_Gfx;
|
||||
u16 *buffer = Alloc(DESC_WIN_WIDTH * DESC_WIN_HEIGHT * 32);
|
||||
u16 *buffer = Alloc(DESC_WIN_SIZE);
|
||||
u8 i, j, y;
|
||||
|
||||
if (buffer)
|
||||
@@ -1086,10 +1067,10 @@ static void CopyDescriptionWindowTiles(u8 windowId)
|
||||
}
|
||||
|
||||
for (j = 0; j < DESC_WIN_WIDTH; j++)
|
||||
CpuCopy32(src + 16 * y, buffer + 16 * (2 * (15 * i) + j), 32);
|
||||
CpuCopy32(src + 16 * y, buffer + 16 * (2 * (15 * i) + j), TILE_SIZE_4BPP);
|
||||
}
|
||||
|
||||
CopyToWindowPixelBuffer(windowId, (const u8 *)buffer, DESC_WIN_WIDTH * DESC_WIN_HEIGHT * 32, 0);
|
||||
CopyToWindowPixelBuffer(windowId, (const u8 *)buffer, DESC_WIN_SIZE, 0);
|
||||
Free(buffer);
|
||||
}
|
||||
}
|
||||
@@ -1120,7 +1101,7 @@ static void QuestLog_WaitFadeAndCancelPlayback(void)
|
||||
break;
|
||||
ReadQuestLogScriptFromSav1(sCurrentSceneNum, sQuestLogActionRecordBuffer);
|
||||
}
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
QuestLog_StartFinalScene();
|
||||
}
|
||||
}
|
||||
@@ -1219,7 +1200,7 @@ static void Task_EndQuestLog(u8 taskId)
|
||||
tState++;
|
||||
break;
|
||||
case 1:
|
||||
if (sub_81121D8(taskId))
|
||||
if (RestoreScreenAfterPlayback(taskId))
|
||||
{
|
||||
for (i = 0; i < WIN_COUNT; i++)
|
||||
{
|
||||
@@ -1257,18 +1238,21 @@ static void Task_EndQuestLog(u8 taskId)
|
||||
#undef tState
|
||||
#undef tTimer
|
||||
|
||||
static bool8 sub_81121D8(u8 taskId)
|
||||
#define tTimer data[1]
|
||||
|
||||
// Scroll the top and bottom windows offscreen and restore the screen tint to the original color.
|
||||
static bool8 RestoreScreenAfterPlayback(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (data[1] > 15)
|
||||
if (tTimer > 15)
|
||||
return TRUE;
|
||||
|
||||
CopyPaletteInvertedTint(&gPlttBufferUnfaded[BG_PLTT_ID(0) + 1], &gPlttBufferFaded[BG_PLTT_ID(0) + 1], 0xDF, 0x0F - data[1]);
|
||||
CopyPaletteInvertedTint(&gPlttBufferUnfaded[OBJ_PLTT_ID(0)], &gPlttBufferFaded[OBJ_PLTT_ID(0)], 0x100, 0x0F - data[1]);
|
||||
CopyPaletteInvertedTint(&gPlttBufferUnfaded[BG_PLTT_ID(0) + 1], &gPlttBufferFaded[BG_PLTT_ID(0) + 1], 0xDF, 15 - tTimer);
|
||||
CopyPaletteInvertedTint(&gPlttBufferUnfaded[OBJ_PLTT_ID(0)], &gPlttBufferFaded[OBJ_PLTT_ID(0)], 0x100, 15 - tTimer);
|
||||
FillWindowPixelRect(sWindowIds[WIN_TOP_BAR],
|
||||
0x00, 0,
|
||||
sWindowTemplates[WIN_TOP_BAR].height * 8 - 1 - data[1],
|
||||
sWindowTemplates[WIN_TOP_BAR].height * 8 - 1 - tTimer,
|
||||
sWindowTemplates[WIN_TOP_BAR].width * 8, 1);
|
||||
FillWindowPixelRect(sWindowIds[WIN_BOTTOM_BAR],
|
||||
0x00, 0,
|
||||
@@ -1276,7 +1260,7 @@ static bool8 sub_81121D8(u8 taskId)
|
||||
sWindowTemplates[WIN_BOTTOM_BAR].width * 8, 1);
|
||||
CopyWindowToVram(sWindowIds[WIN_TOP_BAR], COPYWIN_GFX);
|
||||
CopyWindowToVram(sWindowIds[WIN_BOTTOM_BAR], COPYWIN_GFX);
|
||||
data[1]++;
|
||||
tTimer++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1301,24 +1285,24 @@ void QL_FinishRecordingScene(void)
|
||||
RecordSceneEnd();
|
||||
gQuestLogState = 0;
|
||||
sQuestLogCB = NULL;
|
||||
gUnknown_203AE04 = NULL;
|
||||
gQuestLogDefeatedWildMonRecord = NULL;
|
||||
gQuestLogRecordingPointer = NULL;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
}
|
||||
}
|
||||
|
||||
void QuestLog_CutRecording(void)
|
||||
{
|
||||
if (gQuestLogPlaybackState != QL_PLAYBACK_STATE_0 && gQuestLogState == QL_STATE_RECORDING)
|
||||
if (gQuestLogPlaybackState != QL_PLAYBACK_STATE_STOPPED && gQuestLogState == QL_STATE_RECORDING)
|
||||
{
|
||||
TryRecordActionSequence(sQuestLogActionRecordBuffer);
|
||||
QL_RecordWait(1);
|
||||
RecordSceneEnd();
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
gQuestLogState = 0;
|
||||
sQuestLogCB = NULL;
|
||||
}
|
||||
gUnknown_203AE04 = NULL;
|
||||
gQuestLogDefeatedWildMonRecord = NULL;
|
||||
gQuestLogRecordingPointer = NULL;
|
||||
}
|
||||
|
||||
@@ -1353,7 +1337,7 @@ void SaveQuestLogData(void)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_811246C(struct Sprite *sprite)
|
||||
void QL_UpdateObject(struct Sprite *sprite)
|
||||
{
|
||||
struct ObjectEvent *objectEvent = &gObjectEvents[sprite->data[0]];
|
||||
if (objectEvent->localId == OBJ_EVENT_ID_PLAYER)
|
||||
@@ -1368,7 +1352,7 @@ void sub_811246C(struct Sprite *sprite)
|
||||
QuestLogUpdatePlayerSprite(sMovementScripts[0][1]);
|
||||
sMovementScripts[0][1] = QL_PLAYER_GFX_NONE;
|
||||
}
|
||||
UpdateQuestLogObjectEventCurrentMovement(objectEvent, sprite);
|
||||
QL_UpdateObjectEventCurrentMovement(objectEvent, sprite);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1377,7 +1361,7 @@ void sub_811246C(struct Sprite *sprite)
|
||||
ObjectEventSetHeldMovement(objectEvent, sMovementScripts[objectEvent->localId][0]);
|
||||
sMovementScripts[objectEvent->localId][0] = MOVEMENT_ACTION_NONE;
|
||||
}
|
||||
UpdateQuestLogObjectEventCurrentMovement(objectEvent, sprite);
|
||||
QL_UpdateObjectEventCurrentMovement(objectEvent, sprite);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1468,7 +1452,7 @@ void QuestLogRecordPlayerAvatarGfxTransitionWithDuration(u8 gfxState, u8 duratio
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81127F8(struct FieldInput * a0)
|
||||
void QL_RecordFieldInput(struct FieldInput * fieldInput)
|
||||
{
|
||||
if (gQuestLogCurActionIdx < sMaxActionsInScene)
|
||||
{
|
||||
@@ -1480,13 +1464,13 @@ void sub_81127F8(struct FieldInput * a0)
|
||||
// - tookStep
|
||||
// - pressedBButton
|
||||
// - dpadDirection
|
||||
u32 r2 = *(u32 *)a0 & 0x00FF00F3;
|
||||
u32 data = *(u32 *)fieldInput & 0x00FF00F3;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].duration = sNextActionDelay;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].type = QL_ACTION_INPUT;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[0] = r2;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[1] = r2 >> 8; // always 0
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[2] = r2 >> 16;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[3] = r2 >> 24; // always 0
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[0] = data;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[1] = data >> 8; // always 0
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[2] = data >> 16;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[3] = data >> 24; // always 0
|
||||
gQuestLogCurActionIdx++;
|
||||
if (ArePlayerFieldControlsLocked())
|
||||
sNextActionDelay = 1;
|
||||
@@ -1500,53 +1484,53 @@ static void TogglePlaybackStateForOverworldLock(u8 a0)
|
||||
switch (a0)
|
||||
{
|
||||
case 1:
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_1)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_3; // Message visible, overworld locked
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_RUNNING)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_ACTION_END; // Message visible, overworld locked
|
||||
break;
|
||||
case 2:
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_3)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_1; // Overworld unlocked
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_ACTION_END)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_RUNNING; // Overworld unlocked
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QuestLog_OnEscalatorWarp(u8 direction)
|
||||
{
|
||||
u8 r1 = sub_8112CAC();
|
||||
u8 state = QL_GetPlaybackState();
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case QL_ESCALATOR_OUT: // warp out
|
||||
if (r1 == 1)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_3;
|
||||
else if (r1 == 2)
|
||||
if (state == QL_PLAYBACK_STATE_RUNNING)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_ACTION_END;
|
||||
else if (state == QL_PLAYBACK_STATE_RECORDING)
|
||||
{
|
||||
sCurSceneActions[gQuestLogCurActionIdx].duration = sNextActionDelay;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].type = QL_ACTION_3;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].type = QL_ACTION_EMPTY;
|
||||
gQuestLogCurActionIdx++;
|
||||
sNextActionDelay = 0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_4;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_RECORDING_NO_DELAY;
|
||||
}
|
||||
break;
|
||||
case QL_ESCALATOR_IN: // warp in
|
||||
if (r1 == 1)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_1;
|
||||
else if (r1 == 2)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_2;
|
||||
if (state == QL_PLAYBACK_STATE_RUNNING)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_RUNNING;
|
||||
else if (state == QL_PLAYBACK_STATE_RECORDING)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_RECORDING;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SetUpQuestLogAction(u8 kind, struct QuestLogAction *actions, u16 size)
|
||||
static void ResetActions(u8 kind, struct QuestLogAction *actions, u16 size)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
default:
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
break;
|
||||
case 1:
|
||||
case QL_PLAYBACK_STATE_RUNNING:
|
||||
sCurSceneActions = actions;
|
||||
sMaxActionsInScene = size / sizeof(*sCurSceneActions);
|
||||
for (i = 0; i < (s32)ARRAY_COUNT(sMovementScripts); i++)
|
||||
@@ -1560,9 +1544,9 @@ static void SetUpQuestLogAction(u8 kind, struct QuestLogAction *actions, u16 siz
|
||||
sNextActionDelay = sCurSceneActions[gQuestLogCurActionIdx].duration;
|
||||
sMovementScripts[0][0] = sCurSceneActions[gQuestLogCurActionIdx].data.a.movementActionId;
|
||||
sMovementScripts[0][1] = QL_PLAYER_GFX_NONE;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_1;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_RUNNING;
|
||||
break;
|
||||
case 2:
|
||||
case QL_PLAYBACK_STATE_RECORDING:
|
||||
sCurSceneActions = actions;
|
||||
sMaxActionsInScene = size / sizeof(*sCurSceneActions);
|
||||
for (i = 0; i < sMaxActionsInScene; i++)
|
||||
@@ -1602,20 +1586,20 @@ static void SetUpQuestLogAction(u8 kind, struct QuestLogAction *actions, u16 siz
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[2] = 0;
|
||||
sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[3] = 0;
|
||||
gQuestLogCurActionIdx++;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_2;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_RECORDING;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8112B3C(void)
|
||||
void QL_TryRunActions(void)
|
||||
{
|
||||
switch (gQuestLogPlaybackState)
|
||||
{
|
||||
case QL_PLAYBACK_STATE_0:
|
||||
case QL_PLAYBACK_STATE_3:
|
||||
case QL_PLAYBACK_STATE_4:
|
||||
case QL_PLAYBACK_STATE_STOPPED:
|
||||
case QL_PLAYBACK_STATE_ACTION_END:
|
||||
case QL_PLAYBACK_STATE_RECORDING_NO_DELAY:
|
||||
break;
|
||||
case QL_PLAYBACK_STATE_1:
|
||||
case QL_PLAYBACK_STATE_RUNNING:
|
||||
if (!RecordHeadAtEndOfEntryOrScriptContext2Enabled())
|
||||
{
|
||||
if (sNextActionDelay != 0)
|
||||
@@ -1643,42 +1627,42 @@ void sub_8112B3C(void)
|
||||
| (sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[1] << 8)
|
||||
| (sCurSceneActions[gQuestLogCurActionIdx].data.fieldInput[0] << 0));
|
||||
break;
|
||||
case QL_ACTION_3:
|
||||
case QL_ACTION_EMPTY:
|
||||
// End
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_3;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_ACTION_END;
|
||||
break;
|
||||
case QL_ACTION_WAIT:
|
||||
// Nothing. The wait action uses sNextActionDelay to add a pause to playback.
|
||||
// When the counter is finished and this is reached there's nothing else that needs to be done.
|
||||
break;
|
||||
case QL_ACTION_SCENE_END:
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_0)
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_STOPPED)
|
||||
break;
|
||||
if (++gQuestLogCurActionIdx >= sMaxActionsInScene)
|
||||
{
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
break;
|
||||
}
|
||||
sNextActionDelay = sCurSceneActions[gQuestLogCurActionIdx].duration;
|
||||
|
||||
} while (gQuestLogPlaybackState != QL_PLAYBACK_STATE_3 && (sNextActionDelay == 0 || sNextActionDelay == 0xFFFF));
|
||||
} while (gQuestLogPlaybackState != QL_PLAYBACK_STATE_ACTION_END && (sNextActionDelay == 0 || sNextActionDelay == 0xFFFF));
|
||||
}
|
||||
}
|
||||
else if (gQuestLogCurActionIdx >= sMaxActionsInScene)
|
||||
{
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
}
|
||||
break;
|
||||
case QL_PLAYBACK_STATE_2:
|
||||
case QL_PLAYBACK_STATE_RECORDING:
|
||||
if (ArePlayerFieldControlsLocked() != TRUE)
|
||||
{
|
||||
sNextActionDelay++;
|
||||
if (gQuestLogCurActionIdx >= sMaxActionsInScene)
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1689,19 +1673,21 @@ void QL_AfterRecordFishActionSuccessful(void)
|
||||
sNextActionDelay++;
|
||||
}
|
||||
|
||||
u8 sub_8112CAC(void)
|
||||
u8 QL_GetPlaybackState(void)
|
||||
{
|
||||
switch (gQuestLogPlaybackState)
|
||||
{
|
||||
case QL_PLAYBACK_STATE_0:
|
||||
case QL_PLAYBACK_STATE_STOPPED:
|
||||
default:
|
||||
return 0;
|
||||
case QL_PLAYBACK_STATE_1:
|
||||
case QL_PLAYBACK_STATE_3:
|
||||
return 1;
|
||||
case QL_PLAYBACK_STATE_2:
|
||||
case QL_PLAYBACK_STATE_4:
|
||||
return 2;
|
||||
return QL_PLAYBACK_STATE_STOPPED;
|
||||
|
||||
case QL_PLAYBACK_STATE_RUNNING:
|
||||
case QL_PLAYBACK_STATE_ACTION_END:
|
||||
return QL_PLAYBACK_STATE_RUNNING;
|
||||
|
||||
case QL_PLAYBACK_STATE_RECORDING:
|
||||
case QL_PLAYBACK_STATE_RECORDING_NO_DELAY:
|
||||
return QL_PLAYBACK_STATE_RECORDING;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1765,7 +1751,7 @@ static void QuestLogResetFlagsOrVars(u8 state, struct FlagOrVarRecord * records,
|
||||
|
||||
if (state == 0 || state > QL_STATE_PLAYBACK)
|
||||
{
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_0;
|
||||
gQuestLogPlaybackState = QL_PLAYBACK_STATE_STOPPED;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+13
-13
@@ -7,7 +7,7 @@
|
||||
#include "quest_log.h"
|
||||
#include "constants/trainers.h"
|
||||
|
||||
static void sub_812C334(s32 *, s32 *);
|
||||
static void GetLinkMultiBattlePlayerIndexes(s32 *, s32 *);
|
||||
|
||||
void TrySetQuestLogBattleEvent(void)
|
||||
{
|
||||
@@ -93,8 +93,8 @@ void TrySetQuestLogBattleEvent(void)
|
||||
|
||||
void TrySetQuestLogLinkBattleEvent(void)
|
||||
{
|
||||
s32 sp0;
|
||||
s32 sp4[2];
|
||||
s32 partnerIdx;
|
||||
s32 opponentIdxs[2];
|
||||
u16 eventId;
|
||||
s32 i;
|
||||
bool32 inUnionRoom;
|
||||
@@ -106,12 +106,12 @@ void TrySetQuestLogLinkBattleEvent(void)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
{
|
||||
eventId = QL_EVENT_LINK_BATTLED_MULTI;
|
||||
sub_812C334(&sp0, sp4);
|
||||
GetLinkMultiBattlePlayerIndexes(&partnerIdx, opponentIdxs);
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
||||
{
|
||||
data->playerNames[0][i] = gLinkPlayers[sp0].name[i];
|
||||
data->playerNames[1][i] = gLinkPlayers[sp4[0]].name[i];
|
||||
data->playerNames[2][i] = gLinkPlayers[sp4[1]].name[i];
|
||||
data->playerNames[0][i] = gLinkPlayers[partnerIdx].name[i];
|
||||
data->playerNames[1][i] = gLinkPlayers[opponentIdxs[0]].name[i];
|
||||
data->playerNames[2][i] = gLinkPlayers[opponentIdxs[1]].name[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -135,16 +135,16 @@ void TrySetQuestLogLinkBattleEvent(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_812C334(s32 * a0, s32 * a1)
|
||||
static void GetLinkMultiBattlePlayerIndexes(s32 * partnerIdx, s32 * opponentIdxs)
|
||||
{
|
||||
s32 i;
|
||||
s32 _optimized_out = 0;
|
||||
u8 r2 = gLinkPlayers[gBattleStruct->multiplayerId].id ^ 2;
|
||||
s32 numOpponentsFound = 0;
|
||||
u8 partnerId = gLinkPlayers[gBattleStruct->multiplayerId].id ^ 2;
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
if (r2 == gLinkPlayers[i].id)
|
||||
a0[0] = i;
|
||||
if (partnerId == gLinkPlayers[i].id)
|
||||
*partnerIdx = i;
|
||||
else if (i != gBattleStruct->multiplayerId)
|
||||
a1[_optimized_out++] = i;
|
||||
opponentIdxs[numOpponentsFound++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
+135
-126
@@ -19,9 +19,9 @@
|
||||
#include "constants/region_map_sections.h"
|
||||
|
||||
enum {
|
||||
STEP_RECORDING_MODE_0,
|
||||
STEP_RECORDING_MODE_1,
|
||||
STEP_RECORDING_MODE_2,
|
||||
STEP_RECORDING_MODE_ENABLED,
|
||||
STEP_RECORDING_MODE_DISABLED,
|
||||
STEP_RECORDING_MODE_DISABLED_UNTIL_DEPART,
|
||||
};
|
||||
|
||||
struct DeferredLinkEvent
|
||||
@@ -30,9 +30,12 @@ struct DeferredLinkEvent
|
||||
u16 ALIGNED(4) data[14];
|
||||
};
|
||||
|
||||
#define CMD_HEADER_SIZE 4
|
||||
#define MAX_CMD_REPEAT 4
|
||||
|
||||
static EWRAM_DATA struct DeferredLinkEvent sDeferredEvent = {0};
|
||||
EWRAM_DATA struct UnkStruct_203B044 gUnknown_203B044 = {0};
|
||||
static EWRAM_DATA u8 sEventShouldNotRecordSteps = 0;
|
||||
EWRAM_DATA struct QuestLogRepeatEventTracker gQuestLogRepeatEventTracker = {0};
|
||||
static EWRAM_DATA u8 sStepRecordingMode = 0;
|
||||
static EWRAM_DATA bool8 sNewlyEnteredMap = FALSE;
|
||||
static EWRAM_DATA u8 sLastDepartedLocation = 0;
|
||||
static EWRAM_DATA bool8 sPlayedTheSlots = FALSE;
|
||||
@@ -44,7 +47,7 @@ static u16 *ShouldRegisterEvent(u16, const u16 *);
|
||||
static bool8 TryDeferLinkEvent(u16, const u16 *);
|
||||
static bool8 TryDeferTrainerBattleEvent(u16, const u16 *);
|
||||
static bool8 IsEventWithSpecialEncounterSpecies(u16, const u16 *);
|
||||
static void SetQuestLogEventToActive(u16);
|
||||
static void UpdateRepeatEventCounter(u16);
|
||||
static u16 *QL_RecordAction_Wait(u16 *, u16);
|
||||
static u16 *RecordEvent_SwitchedPartyOrder(u16 *, const struct QuestLogEvent_SwitchedPartyOrder *);
|
||||
static u16 *RecordEvent_UsedItem(u16 *, const struct QuestLogEvent_Item *);
|
||||
@@ -222,49 +225,49 @@ static const u16 *(*const sLoadEventFuncs[])(const u16 *) = {
|
||||
};
|
||||
|
||||
static const u8 sQuestLogEventCmdSizes[] = {
|
||||
[QL_EVENT_INPUT] = 8,
|
||||
[QL_EVENT_GFX_CHANGE] = 8,
|
||||
[QL_EVENT_MOVEMENT] = 8,
|
||||
[QL_EVENT_SWITCHED_PARTY_ORDER] = 8,
|
||||
[QL_EVENT_USED_ITEM] = 10,
|
||||
[QL_EVENT_GAVE_HELD_ITEM] = 8,
|
||||
[QL_EVENT_GAVE_HELD_ITEM_BAG] = 8,
|
||||
[QL_EVENT_GAVE_HELD_ITEM_PC] = 8,
|
||||
[QL_EVENT_TOOK_HELD_ITEM] = 8,
|
||||
[QL_EVENT_SWAPPED_HELD_ITEM] = 10,
|
||||
[QL_EVENT_SWAPPED_HELD_ITEM_PC] = 10,
|
||||
[QL_EVENT_USED_PKMN_CENTER] = 4,
|
||||
[QL_EVENT_LINK_TRADED] = 16,
|
||||
[QL_EVENT_LINK_BATTLED_SINGLE] = 12,
|
||||
[QL_EVENT_LINK_BATTLED_DOUBLE] = 12,
|
||||
[QL_EVENT_LINK_BATTLED_MULTI] = 26,
|
||||
[QL_EVENT_USED_UNION_ROOM] = 4,
|
||||
[QL_EVENT_USED_UNION_ROOM_CHAT] = 4,
|
||||
[QL_EVENT_LINK_TRADED_UNION] = 16,
|
||||
[QL_EVENT_LINK_BATTLED_UNION] = 12,
|
||||
[QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES] = 10,
|
||||
[QL_EVENT_SWITCHED_MONS_WITHIN_BOX] = 10,
|
||||
[QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON] = 10,
|
||||
[QL_EVENT_MOVED_MON_BETWEEN_BOXES] = 8,
|
||||
[QL_EVENT_MOVED_MON_WITHIN_BOX] = 8,
|
||||
[QL_EVENT_WITHDREW_MON_PC] = 8,
|
||||
[QL_EVENT_DEPOSITED_MON_PC] = 8,
|
||||
[QL_EVENT_SWITCHED_MULTIPLE_MONS] = 6,
|
||||
[QL_EVENT_DEPOSITED_ITEM_PC] = 6,
|
||||
[QL_EVENT_WITHDREW_ITEM_PC] = 6,
|
||||
[QL_EVENT_DEFEATED_GYM_LEADER] = 12,
|
||||
[QL_EVENT_DEFEATED_WILD_MON] = 12,
|
||||
[QL_EVENT_DEFEATED_E4_MEMBER] = 12,
|
||||
[QL_EVENT_DEFEATED_CHAMPION] = 10,
|
||||
[QL_EVENT_DEFEATED_TRAINER] = 12,
|
||||
[QL_EVENT_DEPARTED] = 6,
|
||||
[QL_EVENT_USED_FIELD_MOVE] = 8,
|
||||
[QL_EVENT_BOUGHT_ITEM] = 14,
|
||||
[QL_EVENT_SOLD_ITEM] = 14,
|
||||
[QL_EVENT_SCENE_END] = 2,
|
||||
[QL_EVENT_OBTAINED_STORY_ITEM] = 8,
|
||||
[QL_EVENT_WAIT] = 4,
|
||||
[QL_EVENT_ARRIVED] = 6
|
||||
[QL_EVENT_INPUT] = 8,
|
||||
[QL_EVENT_GFX_CHANGE] = 8,
|
||||
[QL_EVENT_MOVEMENT] = 8,
|
||||
[QL_EVENT_SWITCHED_PARTY_ORDER] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_USED_ITEM] = CMD_HEADER_SIZE + 6,
|
||||
[QL_EVENT_GAVE_HELD_ITEM] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_GAVE_HELD_ITEM_BAG] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_GAVE_HELD_ITEM_PC] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_TOOK_HELD_ITEM] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_SWAPPED_HELD_ITEM] = CMD_HEADER_SIZE + 6,
|
||||
[QL_EVENT_SWAPPED_HELD_ITEM_PC] = CMD_HEADER_SIZE + 6,
|
||||
[QL_EVENT_USED_PKMN_CENTER] = CMD_HEADER_SIZE + 0,
|
||||
[QL_EVENT_LINK_TRADED] = CMD_HEADER_SIZE + 12,
|
||||
[QL_EVENT_LINK_BATTLED_SINGLE] = CMD_HEADER_SIZE + 8,
|
||||
[QL_EVENT_LINK_BATTLED_DOUBLE] = CMD_HEADER_SIZE + 8,
|
||||
[QL_EVENT_LINK_BATTLED_MULTI] = CMD_HEADER_SIZE + 22,
|
||||
[QL_EVENT_USED_UNION_ROOM] = CMD_HEADER_SIZE + 0,
|
||||
[QL_EVENT_USED_UNION_ROOM_CHAT] = CMD_HEADER_SIZE + 0,
|
||||
[QL_EVENT_LINK_TRADED_UNION] = CMD_HEADER_SIZE + 12,
|
||||
[QL_EVENT_LINK_BATTLED_UNION] = CMD_HEADER_SIZE + 8,
|
||||
[QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES] = CMD_HEADER_SIZE + 6,
|
||||
[QL_EVENT_SWITCHED_MONS_WITHIN_BOX] = CMD_HEADER_SIZE + 6,
|
||||
[QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON] = CMD_HEADER_SIZE + 6,
|
||||
[QL_EVENT_MOVED_MON_BETWEEN_BOXES] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_MOVED_MON_WITHIN_BOX] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_WITHDREW_MON_PC] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_DEPOSITED_MON_PC] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_SWITCHED_MULTIPLE_MONS] = CMD_HEADER_SIZE + 2,
|
||||
[QL_EVENT_DEPOSITED_ITEM_PC] = CMD_HEADER_SIZE + 2,
|
||||
[QL_EVENT_WITHDREW_ITEM_PC] = CMD_HEADER_SIZE + 2,
|
||||
[QL_EVENT_DEFEATED_GYM_LEADER] = CMD_HEADER_SIZE + 8,
|
||||
[QL_EVENT_DEFEATED_WILD_MON] = CMD_HEADER_SIZE + 8,
|
||||
[QL_EVENT_DEFEATED_E4_MEMBER] = CMD_HEADER_SIZE + 8,
|
||||
[QL_EVENT_DEFEATED_CHAMPION] = CMD_HEADER_SIZE + 6,
|
||||
[QL_EVENT_DEFEATED_TRAINER] = CMD_HEADER_SIZE + 8,
|
||||
[QL_EVENT_DEPARTED] = CMD_HEADER_SIZE + 2,
|
||||
[QL_EVENT_USED_FIELD_MOVE] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_BOUGHT_ITEM] = CMD_HEADER_SIZE + 10,
|
||||
[QL_EVENT_SOLD_ITEM] = CMD_HEADER_SIZE + 10,
|
||||
[QL_EVENT_SCENE_END] = 2,
|
||||
[QL_EVENT_OBTAINED_STORY_ITEM] = CMD_HEADER_SIZE + 4,
|
||||
[QL_EVENT_WAIT] = 4,
|
||||
[QL_EVENT_ARRIVED] = CMD_HEADER_SIZE + 2
|
||||
};
|
||||
|
||||
static const u8 *const sDefeatedOpponentFlavorTexts[] = {
|
||||
@@ -461,7 +464,7 @@ void SetQuestLogEvent(u16 eventId, const u16 * data)
|
||||
{
|
||||
u16 *r1;
|
||||
|
||||
if (eventId == QL_EVENT_DEPARTED && sEventShouldNotRecordSteps == STEP_RECORDING_MODE_2)
|
||||
if (eventId == QL_EVENT_DEPARTED && sStepRecordingMode == STEP_RECORDING_MODE_DISABLED_UNTIL_DEPART)
|
||||
{
|
||||
QL_EnableRecordingSteps();
|
||||
return;
|
||||
@@ -496,38 +499,38 @@ void SetQuestLogEvent(u16 eventId, const u16 * data)
|
||||
if (ShouldRegisterEvent_DepartedGameCorner(eventId, data) == FALSE)
|
||||
return;
|
||||
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_0)
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_STOPPED)
|
||||
{
|
||||
if (ShouldRegisterEvent_HandlePartyActions(eventId, data) == TRUE)
|
||||
return;
|
||||
|
||||
if (eventId != QL_EVENT_DEFEATED_WILD_MON || gUnknown_203AE04 == NULL)
|
||||
if (eventId != QL_EVENT_DEFEATED_WILD_MON || gQuestLogDefeatedWildMonRecord == NULL)
|
||||
{
|
||||
if (ShouldRegisterEvent_HandleDeparted(eventId, data) == FALSE)
|
||||
return;
|
||||
StartRecordingQuestLogAction(eventId);
|
||||
QL_StartRecordingAction(eventId);
|
||||
}
|
||||
}
|
||||
else if (eventId == QL_EVENT_OBTAINED_STORY_ITEM)
|
||||
return;
|
||||
|
||||
SetQuestLogEventToActive(eventId);
|
||||
UpdateRepeatEventCounter(eventId);
|
||||
if (eventId == QL_EVENT_DEFEATED_WILD_MON)
|
||||
{
|
||||
if (gUnknown_203AE04 == NULL)
|
||||
if (gQuestLogDefeatedWildMonRecord == NULL)
|
||||
{
|
||||
gUnknown_203AE04 = gQuestLogRecordingPointer;
|
||||
r1 = sRecordEventFuncs[eventId](gUnknown_203AE04, data);
|
||||
gQuestLogDefeatedWildMonRecord = gQuestLogRecordingPointer;
|
||||
r1 = sRecordEventFuncs[eventId](gQuestLogDefeatedWildMonRecord, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
sRecordEventFuncs[eventId](gUnknown_203AE04, data);
|
||||
sRecordEventFuncs[eventId](gQuestLogDefeatedWildMonRecord, data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gUnknown_203AE04 = NULL;
|
||||
gQuestLogDefeatedWildMonRecord = NULL;
|
||||
r1 = sRecordEventFuncs[eventId](gQuestLogRecordingPointer, data);
|
||||
}
|
||||
|
||||
@@ -540,7 +543,7 @@ void SetQuestLogEvent(u16 eventId, const u16 * data)
|
||||
}
|
||||
|
||||
gQuestLogRecordingPointer = r1;
|
||||
if (sEventShouldNotRecordSteps == STEP_RECORDING_MODE_0)
|
||||
if (sStepRecordingMode == STEP_RECORDING_MODE_ENABLED)
|
||||
return;
|
||||
QL_FinishRecordingScene();
|
||||
}
|
||||
@@ -646,7 +649,7 @@ static bool8 ShouldRegisterEvent_HandleBeatStoryTrainer(u16 eventId, const u16 *
|
||||
|
||||
void QL_EnableRecordingSteps(void)
|
||||
{
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_0;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_ENABLED;
|
||||
}
|
||||
|
||||
static u16 *ShouldRegisterEvent(u16 eventId, const u16 * data)
|
||||
@@ -657,13 +660,13 @@ static u16 *ShouldRegisterEvent(u16 eventId, const u16 * data)
|
||||
if (ShouldRegisterEvent_HandleDeparted(eventId, data) == FALSE)
|
||||
return NULL;
|
||||
|
||||
StartRecordingQuestLogAction(eventId);
|
||||
SetQuestLogEventToActive(eventId);
|
||||
QL_StartRecordingAction(eventId);
|
||||
UpdateRepeatEventCounter(eventId);
|
||||
|
||||
if (eventId == QL_EVENT_DEFEATED_WILD_MON)
|
||||
gUnknown_203AE04 = gQuestLogRecordingPointer;
|
||||
gQuestLogDefeatedWildMonRecord = gQuestLogRecordingPointer;
|
||||
else
|
||||
gUnknown_203AE04 = NULL;
|
||||
gQuestLogDefeatedWildMonRecord = NULL;
|
||||
|
||||
return sRecordEventFuncs[eventId](gQuestLogRecordingPointer, data);
|
||||
}
|
||||
@@ -698,7 +701,7 @@ void QuestLog_StartRecordingInputsAfterDeferredEvent(void)
|
||||
{
|
||||
u16 *resp;
|
||||
sLastDepartedLocation = 0;
|
||||
StartRecordingQuestLogAction(sDeferredEvent.id);
|
||||
QL_StartRecordingAction(sDeferredEvent.id);
|
||||
resp = sRecordEventFuncs[sDeferredEvent.id](gQuestLogRecordingPointer, sDeferredEvent.data);
|
||||
gQuestLogRecordingPointer = resp;
|
||||
ResetDeferredLinkEvent();
|
||||
@@ -714,7 +717,7 @@ static bool8 TryDeferTrainerBattleEvent(u16 eventId, const u16 * data)
|
||||
return FALSE;
|
||||
|
||||
ResetDeferredLinkEvent();
|
||||
if (gQuestLogPlaybackState != QL_PLAYBACK_STATE_0 || FlagGet(FLAG_SYS_GAME_CLEAR) || ShouldRegisterEvent_HandleBeatStoryTrainer(eventId, data) != TRUE)
|
||||
if (gQuestLogPlaybackState != QL_PLAYBACK_STATE_STOPPED || FlagGet(FLAG_SYS_GAME_CLEAR) || ShouldRegisterEvent_HandleBeatStoryTrainer(eventId, data) != TRUE)
|
||||
{
|
||||
sDeferredEvent.id = eventId;
|
||||
memcpy(sDeferredEvent.data, data, sizeof(struct QuestLogEvent_TrainerBattle));
|
||||
@@ -727,12 +730,12 @@ void QuestLogEvents_HandleEndTrainerBattle(void)
|
||||
if (sDeferredEvent.id != 0)
|
||||
{
|
||||
u16 *resp;
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_0)
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_STOPPED)
|
||||
{
|
||||
sLastDepartedLocation = 0;
|
||||
StartRecordingQuestLogAction(sDeferredEvent.id);
|
||||
QL_StartRecordingAction(sDeferredEvent.id);
|
||||
}
|
||||
SetQuestLogEventToActive(sDeferredEvent.id);
|
||||
UpdateRepeatEventCounter(sDeferredEvent.id);
|
||||
resp = sRecordEventFuncs[sDeferredEvent.id](gQuestLogRecordingPointer, sDeferredEvent.data);
|
||||
gQuestLogRecordingPointer = resp;
|
||||
QL_RecordWait(1);
|
||||
@@ -765,22 +768,22 @@ static bool8 IsEventWithSpecialEncounterSpecies(u16 eventId, const u16 * generic
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u16 *QuestLog_SkipCommand(u16 *curPtr, u16 **prevPtr_p)
|
||||
u16 *QL_SkipCommand(u16 *curPtr, u16 **prevPtr_p)
|
||||
{
|
||||
u16 eventId = curPtr[0] & QL_CMD_EVENT_MASK;
|
||||
u16 cnt = curPtr[0] >> QL_CMD_UNK_SHIFT;
|
||||
u16 count = curPtr[0] >> QL_CMD_COUNT_SHIFT;
|
||||
|
||||
if (eventId == QL_EVENT_DEFEATED_CHAMPION)
|
||||
cnt = 0;
|
||||
count = 0;
|
||||
|
||||
if (!IS_VALID_QL_EVENT(eventId))
|
||||
return NULL;
|
||||
|
||||
*prevPtr_p = curPtr;
|
||||
return sQuestLogEventCmdSizes[eventId] + (sQuestLogEventCmdSizes[eventId] - 4) * cnt + (void *)curPtr;
|
||||
return sQuestLogEventCmdSizes[eventId] + (sQuestLogEventCmdSizes[eventId] - CMD_HEADER_SIZE) * count + (void *)curPtr;
|
||||
}
|
||||
|
||||
void sub_8113ABC(const u16 *a0)
|
||||
void QL_UpdateLastDepartedLocation(const u16 *a0)
|
||||
{
|
||||
const u8 *r2 = (const u8 *)(a0 + 2);
|
||||
if ((a0[0] & QL_CMD_EVENT_MASK) != QL_EVENT_DEPARTED)
|
||||
@@ -789,53 +792,57 @@ void sub_8113ABC(const u16 *a0)
|
||||
sLastDepartedLocation = r2[1] + 1;
|
||||
}
|
||||
|
||||
bool8 sub_8113AE8(const u16 *a0)
|
||||
bool8 QL_LoadEvent(const u16 *eventData)
|
||||
{
|
||||
const u16 *r0 = a0;
|
||||
const u16 *r0 = eventData;
|
||||
|
||||
if (a0 == NULL)
|
||||
if (eventData == NULL)
|
||||
return FALSE;
|
||||
if (r0[1] > gQuestLogCurActionIdx)
|
||||
return FALSE;
|
||||
|
||||
sLoadEventFuncs[(r0[0] & QL_CMD_EVENT_MASK)](a0);
|
||||
gUnknown_203B044.id = r0[0];
|
||||
gUnknown_203B044.unk_1 = (r0[0] & QL_CMD_UNK_MASK) >> QL_CMD_UNK_SHIFT;
|
||||
if (gUnknown_203B044.unk_1 != 0)
|
||||
gUnknown_203B044.unk_2 = 1;
|
||||
sLoadEventFuncs[(r0[0] & QL_CMD_EVENT_MASK)](eventData);
|
||||
gQuestLogRepeatEventTracker.id = r0[0];
|
||||
gQuestLogRepeatEventTracker.numRepeats = (r0[0] & QL_CMD_COUNT_MASK) >> QL_CMD_COUNT_SHIFT;
|
||||
if (gQuestLogRepeatEventTracker.numRepeats != 0)
|
||||
gQuestLogRepeatEventTracker.counter = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_8113B44(const u16 *a0)
|
||||
bool8 QL_TryRepeatEvent(const u16 *eventData)
|
||||
{
|
||||
if (gUnknown_203B044.unk_2 == 0)
|
||||
// This is the first for a new event, do nothing. Counter may be changed later by QL_LoadEvent.
|
||||
if (gQuestLogRepeatEventTracker.counter == 0)
|
||||
return FALSE;
|
||||
|
||||
sLoadEventFuncs[gUnknown_203B044.id](a0);
|
||||
gUnknown_203B044.unk_2++;
|
||||
if (gUnknown_203B044.unk_2 > gUnknown_203B044.unk_1)
|
||||
ResetUnk203B044();
|
||||
// Repeat event
|
||||
sLoadEventFuncs[gQuestLogRepeatEventTracker.id](eventData);
|
||||
if (++gQuestLogRepeatEventTracker.counter > gQuestLogRepeatEventTracker.numRepeats)
|
||||
QL_ResetRepeatEventTracker();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ResetUnk203B044(void)
|
||||
void QL_ResetRepeatEventTracker(void)
|
||||
{
|
||||
gUnknown_203B044 = (struct UnkStruct_203B044){};
|
||||
gQuestLogRepeatEventTracker = (struct QuestLogRepeatEventTracker){};
|
||||
}
|
||||
|
||||
static void SetQuestLogEventToActive(u16 eventId)
|
||||
static void UpdateRepeatEventCounter(u16 eventId)
|
||||
{
|
||||
if (gUnknown_203B044.id != (u8)eventId || gUnknown_203B044.unk_2 != gQuestLogCurActionIdx)
|
||||
if (gQuestLogRepeatEventTracker.id != (u8)eventId || gQuestLogRepeatEventTracker.counter != gQuestLogCurActionIdx)
|
||||
{
|
||||
gUnknown_203B044.id = eventId;
|
||||
gUnknown_203B044.unk_1 = 0;
|
||||
gUnknown_203B044.unk_2 = gQuestLogCurActionIdx;
|
||||
gQuestLogRepeatEventTracker.id = eventId;
|
||||
gQuestLogRepeatEventTracker.numRepeats = 0;
|
||||
gQuestLogRepeatEventTracker.counter = gQuestLogCurActionIdx;
|
||||
}
|
||||
// Allow 1 over the max. It will be recorded temporarily, ultimately replacing the oldest record.
|
||||
else if (gQuestLogRepeatEventTracker.numRepeats < MAX_CMD_REPEAT + 1)
|
||||
{
|
||||
gQuestLogRepeatEventTracker.numRepeats++;
|
||||
}
|
||||
else if (gUnknown_203B044.unk_1 < 5)
|
||||
gUnknown_203B044.unk_1++;
|
||||
}
|
||||
|
||||
void sub_8113BD8(void)
|
||||
void QL_ResetEventStates(void)
|
||||
{
|
||||
sNewlyEnteredMap = FALSE;
|
||||
sLastDepartedLocation = 0;
|
||||
@@ -958,45 +965,49 @@ static u16 *RecordEventHeader(u16 eventId, u16 *dest)
|
||||
u8 cmdSize;
|
||||
u16 *record;
|
||||
u8 i;
|
||||
u8 r1;
|
||||
u8 count;
|
||||
|
||||
if (gUnknown_203B044.unk_1 == 0)
|
||||
if (gQuestLogRepeatEventTracker.numRepeats == 0)
|
||||
cmdSize = sQuestLogEventCmdSizes[eventId];
|
||||
else
|
||||
cmdSize = sQuestLogEventCmdSizes[eventId] - 4;
|
||||
cmdSize = sQuestLogEventCmdSizes[eventId] - CMD_HEADER_SIZE; // First will already have the header
|
||||
|
||||
if (!QL_IsRoomToSaveEvent(dest, cmdSize))
|
||||
return NULL;
|
||||
|
||||
record = (void *)dest;
|
||||
|
||||
if (gUnknown_203B044.unk_1 != 0)
|
||||
record = (void *)record - (gUnknown_203B044.unk_1 * cmdSize + 4);
|
||||
if (gQuestLogRepeatEventTracker.numRepeats != 0)
|
||||
record = (void *)record - (gQuestLogRepeatEventTracker.numRepeats * cmdSize + CMD_HEADER_SIZE);
|
||||
|
||||
if (gUnknown_203B044.unk_1 == 5)
|
||||
if (gQuestLogRepeatEventTracker.numRepeats == MAX_CMD_REPEAT + 1)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
// Shift back one, replacing oldest
|
||||
for (i = 0; i < MAX_CMD_REPEAT; i++)
|
||||
{
|
||||
memcpy(
|
||||
(void *)record + ((i + 0) * cmdSize + 4),
|
||||
(void *)record + ((i + 1) * cmdSize + 4),
|
||||
(void *)record + ((i + 0) * cmdSize + CMD_HEADER_SIZE),
|
||||
(void *)record + ((i + 1) * cmdSize + CMD_HEADER_SIZE),
|
||||
cmdSize
|
||||
);
|
||||
}
|
||||
r1 = 4;
|
||||
count = MAX_CMD_REPEAT;
|
||||
}
|
||||
else
|
||||
r1 = gUnknown_203B044.unk_1;
|
||||
count = gQuestLogRepeatEventTracker.numRepeats;
|
||||
|
||||
record[0] = eventId + (r1 << QL_CMD_UNK_SHIFT);
|
||||
// Set header data (CMD_HEADER_SIZE)
|
||||
record[0] = eventId + (count << QL_CMD_COUNT_SHIFT);
|
||||
record[1] = gQuestLogCurActionIdx;
|
||||
record = (void *)record + (r1 * cmdSize + 4);
|
||||
|
||||
// Move past header and event data
|
||||
record = (void *)record + (count * cmdSize + CMD_HEADER_SIZE);
|
||||
return record;
|
||||
}
|
||||
|
||||
static const u16 *LoadEvent(u16 eventId, const u16 *eventData)
|
||||
{
|
||||
eventData = (const void *)eventData + (gUnknown_203B044.unk_2 * (sQuestLogEventCmdSizes[eventId] - 4) + 4);
|
||||
eventData = (const void *)eventData + (gQuestLogRepeatEventTracker.counter * (sQuestLogEventCmdSizes[eventId] - CMD_HEADER_SIZE) + CMD_HEADER_SIZE);
|
||||
return eventData;
|
||||
}
|
||||
|
||||
@@ -1053,7 +1064,7 @@ static u16 *RecordEvent_UsedItem(u16 *dest, const struct QuestLogEvent_Item * da
|
||||
rItemParam = data->itemParam;
|
||||
|
||||
if (data->itemId == ITEM_ESCAPE_ROPE)
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_2;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_DISABLED_UNTIL_DEPART;
|
||||
|
||||
return record + 3;
|
||||
}
|
||||
@@ -1237,7 +1248,7 @@ static const u16 *LoadEvent_SwappedHeldItemFromPC(const u16 *eventData)
|
||||
static u16 *RecordEvent_UsedPkmnCenter(u16 *dest, const u16 * data)
|
||||
{
|
||||
u16 *record = dest;
|
||||
if (gUnknown_203B044.id == QL_EVENT_USED_PKMN_CENTER && gUnknown_203B044.unk_1 != 0)
|
||||
if (gQuestLogRepeatEventTracker.id == QL_EVENT_USED_PKMN_CENTER && gQuestLogRepeatEventTracker.numRepeats != 0)
|
||||
return record;
|
||||
|
||||
if (!QL_IsRoomToSaveEvent(dest, sQuestLogEventCmdSizes[QL_EVENT_USED_PKMN_CENTER]))
|
||||
@@ -1471,7 +1482,6 @@ static u16 *RecordEvent_SwitchedMonsBetweenBoxes(u16 *dest, const struct QuestLo
|
||||
return record + 3;
|
||||
}
|
||||
|
||||
// TODO
|
||||
static const u16 *LoadEvent_SwitchedMonsBetweenBoxes(const u16 *eventData)
|
||||
{
|
||||
const u8 *boxIdxs;
|
||||
@@ -1730,11 +1740,10 @@ static u16 *RecordEvent_DefeatedTrainer(u16 eventId, u16 *dest, const struct Que
|
||||
|
||||
static u16 *RecordEvent_DefeatedGymLeader(u16 *dest, const struct QuestLogEvent_TrainerBattle * data)
|
||||
{
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_1;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_DISABLED;
|
||||
return RecordEvent_DefeatedTrainer(QL_EVENT_DEFEATED_GYM_LEADER, dest, data);
|
||||
}
|
||||
|
||||
// TODO
|
||||
static const u16 *LoadEvent_DefeatedGymLeader(const u16 *eventData)
|
||||
{
|
||||
const u8 *r6;
|
||||
@@ -1841,7 +1850,7 @@ static bool8 IsSpeciesFromSpecialEncounter(u16 species)
|
||||
|
||||
static u16 *RecordEvent_DefeatedEliteFourMember(u16 *dest, const struct QuestLogEvent_TrainerBattle * data)
|
||||
{
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_1;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_DISABLED;
|
||||
return RecordEvent_DefeatedTrainer(QL_EVENT_DEFEATED_E4_MEMBER, dest, data);
|
||||
}
|
||||
|
||||
@@ -1863,12 +1872,12 @@ static u16 *RecordEvent_DefeatedChampion(u16 *dest, const struct QuestLogEvent_T
|
||||
{
|
||||
if (!QL_IsRoomToSaveEvent(dest, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_CHAMPION]))
|
||||
return NULL;
|
||||
dest[0] = QL_EVENT_DEFEATED_CHAMPION | (2 << QL_CMD_UNK_SHIFT);
|
||||
dest[0] = QL_EVENT_DEFEATED_CHAMPION | (2 << QL_CMD_COUNT_SHIFT); // Event will run two additional times, for each state in LoadEvent_DefeatedChampion
|
||||
dest[1] = gQuestLogCurActionIdx;
|
||||
dest[2] = data->speciesOpponent;
|
||||
dest[3] = data->speciesPlayer;
|
||||
*((u8 *)dest + 8) = data->hpFractionId;
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_1;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_DISABLED;
|
||||
return dest + 5;
|
||||
}
|
||||
|
||||
@@ -1881,7 +1890,7 @@ static const u16 *LoadEvent_DefeatedChampion(const u16 *a0)
|
||||
r5 = (const u8 *)a0 + 8;
|
||||
DynamicPlaceholderTextUtil_Reset();
|
||||
|
||||
switch (gUnknown_203B044.unk_2)
|
||||
switch (gQuestLogRepeatEventTracker.counter)
|
||||
{
|
||||
case 0:
|
||||
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName);
|
||||
@@ -1905,7 +1914,7 @@ static const u16 *LoadEvent_DefeatedChampion(const u16 *a0)
|
||||
|
||||
static u16 *RecordEvent_DefeatedNormalTrainer(u16 *dest, const struct QuestLogEvent_TrainerBattle * data)
|
||||
{
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_1;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_DISABLED;
|
||||
return RecordEvent_DefeatedTrainer(QL_EVENT_DEFEATED_TRAINER, dest, data);
|
||||
}
|
||||
|
||||
@@ -1949,7 +1958,7 @@ static u16 *RecordEvent_DepartedLocation(u16 *dest, const struct QuestLogEvent_D
|
||||
rMapSec = data->mapSec;
|
||||
rLocationId = data->locationId;
|
||||
if (rLocationId == QL_LOCATION_SAFARI_ZONE)
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_1;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_DISABLED;
|
||||
|
||||
return (u16 *)(record + 2);
|
||||
}
|
||||
@@ -2036,9 +2045,9 @@ static u16 *RecordEvent_UsedFieldMove(u16 *dest, const struct QuestLogEvent_Fiel
|
||||
record[0] = data->fieldMove;
|
||||
record[1] = data->mapSec;
|
||||
if (record[0] == FIELD_MOVE_TELEPORT || record[0] == FIELD_MOVE_DIG)
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_2;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_DISABLED_UNTIL_DEPART;
|
||||
else
|
||||
sEventShouldNotRecordSteps = STEP_RECORDING_MODE_1;
|
||||
sStepRecordingMode = STEP_RECORDING_MODE_DISABLED;
|
||||
return (u16 *)(record + 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ void QL_LoadObjects(const struct QuestLogScene * questLog, const struct ObjectEv
|
||||
CpuCopy16(gObjectEvents, gSaveBlock1Ptr->objectEvents, sizeof(gObjectEvents));
|
||||
}
|
||||
|
||||
void sub_815A540(void)
|
||||
void QL_TryStopSurfing(void)
|
||||
{
|
||||
if (gQuestLogState == QL_STATE_PLAYBACK)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ void QuestLogUpdatePlayerSprite(u8 state)
|
||||
|
||||
bool32 QuestLogTryRecordPlayerAvatarGfxTransition(u8 state)
|
||||
{
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_2)
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_RECORDING)
|
||||
{
|
||||
QuestLogRecordPlayerAvatarGfxTransition(state);
|
||||
return TRUE;
|
||||
@@ -77,7 +77,7 @@ static void QL_GfxTransition_Fish(void)
|
||||
struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
|
||||
struct Sprite *sprite = &gSprites[objectEvent->spriteId];
|
||||
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_1 || gQuestLogPlaybackState == QL_PLAYBACK_STATE_3)
|
||||
if (gQuestLogPlaybackState == QL_PLAYBACK_STATE_RUNNING || gQuestLogPlaybackState == QL_PLAYBACK_STATE_ACTION_END)
|
||||
{
|
||||
u8 taskId;
|
||||
LockPlayerFieldControls();
|
||||
|
||||
+2
-2
@@ -1336,7 +1336,7 @@ static bool8 WaitForAorBPress(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sub_8112CAC() == 1 || gQuestLogState == QL_STATE_PLAYBACK)
|
||||
if (QL_GetPlaybackState() == QL_PLAYBACK_STATE_RUNNING || gQuestLogState == QL_STATE_PLAYBACK)
|
||||
{
|
||||
if (sQuestLogWaitButtonPressTimer == 120)
|
||||
return TRUE;
|
||||
@@ -1401,7 +1401,7 @@ bool8 ScrCmd_waitbuttonpress(struct ScriptContext * ctx)
|
||||
{
|
||||
sQuestLogScriptContextPtr = ctx;
|
||||
|
||||
if (sub_8112CAC() == 1 || gQuestLogState == QL_STATE_PLAYBACK)
|
||||
if (QL_GetPlaybackState() == QL_PLAYBACK_STATE_RUNNING || gQuestLogState == QL_STATE_PLAYBACK)
|
||||
sQuestLogWaitButtonPressTimer = 0;
|
||||
SetupNativeScript(ctx, WaitForAorBPress);
|
||||
return TRUE;
|
||||
|
||||
+1
-1
@@ -1056,7 +1056,7 @@ static void DebugFunc_PrintShopMenuHistoryBeforeClearMaybe(void)
|
||||
}
|
||||
|
||||
// Records a transaction during a single shopping session.
|
||||
// This is for the Quest Log to save infomration about the player's purchases/sales when they finish.
|
||||
// This is for the Quest Log to save information about the player's purchases/sales when they finish.
|
||||
void RecordItemTransaction(u16 itemId, u16 quantity, u8 logEventId)
|
||||
{
|
||||
struct QuestLogEvent_Shop *history;
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ static const TrainerSeeFunc sTrainerSeeFuncList2[] = {
|
||||
bool8 CheckForTrainersWantingBattle(void)
|
||||
{
|
||||
u8 i;
|
||||
if (sub_8111C2C() == TRUE)
|
||||
if (QL_IsTrainerSightDisabled() == TRUE)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
||||
|
||||
Reference in New Issue
Block a user