summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/overworld.s8
-rw-r--r--common_syms/field_control_avatar.txt3
-rw-r--r--common_syms/scrcmd.txt1
-rw-r--r--data/event_scripts.s4
-rw-r--r--data/maps/PalletTown/scripts.inc2
-rw-r--r--data/scripts/flavor_text.inc16
-rw-r--r--data/specials.inc4
-rw-r--r--data/text/flavor_text.inc8
-rw-r--r--include/constants/quest_log.h12
-rw-r--r--include/constants/vars.h7
-rw-r--r--include/event_scripts.h10
-rw-r--r--include/field_control_avatar.h4
-rw-r--r--include/script.h26
-rw-r--r--include/script_menu.h2
-rw-r--r--src/field_control_avatar.c180
-rw-r--r--src/field_specials.c6
-rw-r--r--src/scrcmd.c71
-rw-r--r--src/script.c76
-rw-r--r--src/script_menu.c2
19 files changed, 232 insertions, 210 deletions
diff --git a/asm/overworld.s b/asm/overworld.s
index 03051d691..c6dad9fa7 100644
--- a/asm/overworld.s
+++ b/asm/overworld.s
@@ -3265,7 +3265,7 @@ sub_805644C: @ 805644C
adds r2, r4, 0
bl FieldGetPlayerInput
mov r0, sp
- bl sub_806CD30
+ bl FieldInput_HandleCancelSignpost
bl ScriptContext2_IsEnabled
lsls r0, 24
cmp r0, 0
@@ -3278,7 +3278,7 @@ sub_805644C: @ 805644C
ldrb r0, [r0]
cmp r0, 0x2
bne _0805649E
- ldr r0, _080564AC @ =gUnknown_3005078
+ ldr r0, _080564AC @ =gInputToStoreInQuestLogMaybe
bl sub_81127F8
_0805649E:
bl ScriptContext2_Enable
@@ -3286,7 +3286,7 @@ _0805649E:
b _080564BA
.align 2, 0
_080564A8: .4byte gUnknown_3005E88
-_080564AC: .4byte gUnknown_3005078
+_080564AC: .4byte gInputToStoreInQuestLogMaybe
_080564B0:
ldrb r0, [r6, 0x2]
adds r1, r5, 0
@@ -3313,7 +3313,7 @@ sub_80564C8: @ 80564C8
ldr r0, [r0]
str r0, [sp]
mov r0, sp
- bl sub_806CD30
+ bl FieldInput_HandleCancelSignpost
bl ScriptContext2_IsEnabled
lsls r0, 24
cmp r0, 0
diff --git a/common_syms/field_control_avatar.txt b/common_syms/field_control_avatar.txt
index a9912f983..0b9b08091 100644
--- a/common_syms/field_control_avatar.txt
+++ b/common_syms/field_control_avatar.txt
@@ -1,2 +1 @@
-gSelectedObjectEvent
-gUnknown_3005078
+gInputToStoreInQuestLogMaybe
diff --git a/common_syms/scrcmd.txt b/common_syms/scrcmd.txt
index 7fb0245af..684b63705 100644
--- a/common_syms/scrcmd.txt
+++ b/common_syms/scrcmd.txt
@@ -1 +1,2 @@
gUnknown_3005070
+gSelectedObjectEvent
diff --git a/data/event_scripts.s b/data/event_scripts.s
index 0940cf955..a4dbd9854 100644
--- a/data/event_scripts.s
+++ b/data/event_scripts.s
@@ -1161,8 +1161,8 @@ EventScript_GetElevatorFloor:: @ 81A7AB9
.include "data/scripts/aide.inc"
-gUnknown_81A7ADB:: @ 81A7ADB
- special sub_80CADC4
+EventScript_CancelMessageBox:: @ 81A7ADB
+ special DoPicboxCancel
release
end
diff --git a/data/maps/PalletTown/scripts.inc b/data/maps/PalletTown/scripts.inc
index 43a56496e..b165ae6b9 100644
--- a/data/maps/PalletTown/scripts.inc
+++ b/data/maps/PalletTown/scripts.inc
@@ -450,7 +450,7 @@ PalletTown_EventScript_SignLadyShowSign:: @ 8165894
setflag FLAG_OPENED_START_MENU
setvar VAR_MAP_SCENE_PALLET_TOWN_SIGN_LADY, 1
setvar SIGN_LADY_READY, FALSE
- special sub_80699E0
+ special SetWalkingIntoSignVars
special sub_80699BC
signmsg
msgbox PalletTown_Text_PressStartToOpenMenuCopy
diff --git a/data/scripts/flavor_text.inc b/data/scripts/flavor_text.inc
index 7ea879b04..29ea87a46 100644
--- a/data/scripts/flavor_text.inc
+++ b/data/scripts/flavor_text.inc
@@ -96,18 +96,18 @@ gUnknown_81A76D5:: @ 81A76D5
msgbox gUnknown_81C124B, MSGBOX_SIGN
end
-gUnknown_81A76DE:: @ 81A76DE
- msgbox gUnknown_81C0ECB, MSGBOX_SIGN
+EventScript_PokemartSign:: @ 81A76DE
+ msgbox Text_PokemartSign, MSGBOX_SIGN
end
-gUnknown_81A76E7:: @ 81A76E7
- msgbox gUnknown_81C0EF7, MSGBOX_SIGN
+EventScript_PokecenterSign:: @ 81A76E7
+ msgbox Text_PokecenterSign, MSGBOX_SIGN
end
-gUnknown_81A76F0:: @ 81A76F0
- msgbox gUnknown_81C0F19, MSGBOX_SIGN
+EventScript_Indigo_UltimateGoal:: @ 81A76F0
+ msgbox Text_Indigo_UltimateGoal, MSGBOX_SIGN
end
-gUnknown_81A76F9:: @ 81A76F9
- msgbox gUnknown_81C0F59, MSGBOX_SIGN
+EventScript_Indigo_HighestAuthority:: @ 81A76F9
+ msgbox Text_Indigo_HighestAuthority, MSGBOX_SIGN
end
diff --git a/data/specials.inc b/data/specials.inc
index dbe9deebc..ab7309c32 100644
--- a/data/specials.inc
+++ b/data/specials.inc
@@ -354,7 +354,7 @@ gSpecials:: @ 815FD60
def_special ForcePlayerOntoBike
def_special ListMenu
def_special ReturnToListMenu
- def_special sub_80CADC4
+ def_special DoPicboxCancel
def_special SetVermilionTrashCans
def_special sub_805D1A8
def_special SampleResortGorgeousMonAndReward
@@ -376,7 +376,7 @@ gSpecials:: @ 815FD60
def_special UnionRoomSpecial
def_special ShowWirelessCommunicationScreen
def_special EnableNationalPokedex
- def_special sub_80699E0
+ def_special SetWalkingIntoSignVars
def_special sub_80699BC
def_special sub_810C3A4
def_special SetFlavorTextFlagFromSpecialVars
diff --git a/data/text/flavor_text.inc b/data/text/flavor_text.inc
index a3e46e8d8..993da0ecb 100644
--- a/data/text/flavor_text.inc
+++ b/data/text/flavor_text.inc
@@ -30,20 +30,20 @@ gUnknown_81C0E73:: @ 81C0E73
gUnknown_81C0EAC:: @ 81C0EAC
.string "There's a pile of snacks here.$"
-gUnknown_81C0ECB:: @ 81C0ECB
+Text_PokemartSign:: @ 81C0ECB
.string "All your item needs fulfilled!\n"
.string "POKéMON MART$"
-gUnknown_81C0EF7:: @ 81C0EF7
+Text_PokecenterSign:: @ 81C0EF7
.string "Heal Your POKéMON!\n"
.string "POKéMON CENTER$"
-gUnknown_81C0F19:: @ 81C0F19
+Text_Indigo_UltimateGoal:: @ 81C0F19
.string "INDIGO PLATEAU\p"
.string "The ultimate goal of TRAINERS!\n"
.string "POKéMON LEAGUE HQ$"
-gUnknown_81C0F59:: @ 81C0F59
+Text_Indigo_HighestAuthority:: @ 81C0F59
.string "INDIGO PLATEAU\p"
.string "The highest POKéMON authority!\n"
.string "POKéMON LEAGUE HQ$"
diff --git a/include/constants/quest_log.h b/include/constants/quest_log.h
index c1eaf3f07..b5494e7b9 100644
--- a/include/constants/quest_log.h
+++ b/include/constants/quest_log.h
@@ -118,6 +118,18 @@
#define QL_DEPARTED_MISC_BUILDING_1 8
#define QL_DEPARTED_MISC_BUILDING_2 9
+#define QL_INPUT_OFF 0
+#define QL_INPUT_UP 1
+#define QL_INPUT_DOWN 2
+#define QL_INPUT_LEFT 3
+#define QL_INPUT_RIGHT 4
+#define QL_INPUT_L 5
+#define QL_INPUT_R 6
+#define QL_INPUT_START 7
+#define QL_INPUT_SELECT 8
+#define QL_INPUT_A 9
+#define QL_INPUT_B 10
+
#define FANCLUB_MEMBER1 0
#define FANCLUB_MEMBER2 1
diff --git a/include/constants/vars.h b/include/constants/vars.h
index 6e0553931..4a64eb095 100644
--- a/include/constants/vars.h
+++ b/include/constants/vars.h
@@ -51,7 +51,12 @@
// every party poke gets a slight boost.
#define VAR_HAPPINESS_STEP_COUNTER 0x4021
-// Maybe unused?
+// Counts up every step while a party Pokemon is
+// poisoned. Wraps around at 5. When wraparound
+// occurs, every party Pokemon with the PSN status
+// takes 1 point of damage.
+// This is a deviation from the typical rate in
+// the series, which is 1 damage every 4 steps.
#define VAR_POISON_STEP_COUNTER 0x4022
// Step counter. Caps at 1500. If you enter a map with
diff --git a/include/event_scripts.h b/include/event_scripts.h
index afc509909..9b78854fa 100644
--- a/include/event_scripts.h
+++ b/include/event_scripts.h
@@ -1213,7 +1213,7 @@ extern const u8 CableClub_Text_PleaseWaitBCancel[];
extern const u8 EventScript_FldEffFlash[];
// field_control_avatar
-extern const u8 gUnknown_81A7ADB[];
+extern const u8 EventScript_CancelMessageBox[];
extern const u8 PalletTown_PlayersHouse_2F_EventScript_PC[];
extern const u8 EventScript_HiddenItemScript[];
extern const u8 EventScript_PC[];
@@ -1246,10 +1246,10 @@ extern const u8 gUnknown_81A76D5[];
extern const u8 CableClub_EventScript_81BBFD8[];
extern const u8 EventScript_Questionnaire[];
extern const u8 CableClub_EventScript_ShowBattleRecords[];
-extern const u8 gUnknown_81A76F0[];
-extern const u8 gUnknown_81A76F9[];
-extern const u8 gUnknown_81A76DE[];
-extern const u8 gUnknown_81A76E7[];
+extern const u8 EventScript_Indigo_UltimateGoal[];
+extern const u8 EventScript_Indigo_HighestAuthority[];
+extern const u8 EventScript_PokemartSign[];
+extern const u8 EventScript_PokecenterSign[];
extern const u8 EventScript_CurrentTooFast[];
extern const u8 EventScript_UseSurf[];
extern const u8 EventScript_Waterfall[];
diff --git a/include/field_control_avatar.h b/include/field_control_avatar.h
index 969c605cb..335076a9d 100644
--- a/include/field_control_avatar.h
+++ b/include/field_control_avatar.h
@@ -21,7 +21,7 @@ struct FieldInput
u8 dpadDirection;
};
-extern struct FieldInput gUnknown_3005078;
+extern struct FieldInput gInputToStoreInQuestLogMaybe;
void RestartWildEncounterImmunitySteps(void);
void ClearPoisonStepCounter(void);
@@ -33,7 +33,7 @@ const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatil
const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position);
void FieldClearPlayerInput(struct FieldInput *input);
int ProcessPlayerFieldInput(struct FieldInput *input);
-void sub_806CD30(struct FieldInput * input);
+void FieldInput_HandleCancelSignpost(struct FieldInput * input);
void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys);
#endif //GUARD_FIELD_CONTROL_AVATAR_H
diff --git a/include/script.h b/include/script.h
index 46746ddd8..3dd91ca59 100644
--- a/include/script.h
+++ b/include/script.h
@@ -65,22 +65,22 @@ void sub_80992A0(u8 *script, u16 scriptSize);
bool32 ValidateRamScript(void);
void MEventSetRamScript(u8 * script, u16 scriptSize);
u8 * sub_8069E48(void);
-void sub_8069998(u8 var);
-void sub_80699F8(void);
-void sub_8069964(void);
-void sub_80699A4(void);
-void sub_8069970(void);
-void sub_8069A20(void);
-void sub_8069A2C(void);
+void RegisterQuestLogInput(u8 var);
+void ClearMsgBoxCancelableState(void);
+void SetQuestLogInputIsDpadFlag(void);
+void ClearQuestLogInput(void);
+void ClearQuestLogInputIsDpadFlag(void);
+void MsgSetSignPost(void);
+void MsgSetNotSignPost(void);
bool8 IsMsgSignPost(void);
-bool8 sub_806997C(void);
-u8 sub_80699B0(void);
-void sub_8069A54(void);
-bool8 sub_8069A04(void);
-void sub_80699E0(void);
+bool8 IsQuestLogInputDpad(void);
+u8 GetRegisteredQuestLogInput(void);
+void ResetFacingNpcOrSignPostVars(void);
+bool8 CanWalkAwayToCancelMsgBox(void);
+void SetWalkingIntoSignVars(void);
bool8 sub_80699D4(void);
extern const u8 *gRAMScriptPtr;
-extern u8 gUnknown_20370A0;
+extern u8 gWalkAwayFromSignInhibitTimer;
#endif // GUARD_SCRIPT_H
diff --git a/include/script_menu.h b/include/script_menu.h
index 0e166e7c7..006ce5578 100644
--- a/include/script_menu.h
+++ b/include/script_menu.h
@@ -15,6 +15,6 @@ void ScriptMenu_DisplayPCStartupPrompt(void);
bool8 (*ScriptMenu_GetPicboxWaitFunc(void))(void);
void QLPlaybackCB_DestroyScriptMenuMonPicSprites(void);
-void sub_809D424(void);
+void PicboxCancel(void);
#endif //GUARD_SCRIPT_MENU_H
diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c
index e8ed7e89e..281da9697 100644
--- a/src/field_control_avatar.c
+++ b/src/field_control_avatar.c
@@ -31,8 +31,15 @@
#include "constants/maps.h"
#include "constants/metatile_behaviors.h"
-static void sub_806CA4C(struct FieldInput *input, u16 *newKeys, u16 *heldKeys);
-static void sub_806CDF8(u8 taskId);
+#define SIGNPOST_POKECENTER 0
+#define SIGNPOST_POKEMART 1
+#define SIGNPOST_INDIGO_1 2
+#define SIGNPOST_INDIGO_2 3
+#define SIGNPOST_SCRIPTED 240
+#define SIGNPOST_NA 255
+
+static void QuestLogOverrideJoyVars(struct FieldInput *input, u16 *newKeys, u16 *heldKeys);
+static void Task_QuestLogPlayback_OpenStartMenu(u8 taskId);
static void GetPlayerPosition(struct MapPosition * position);
static void GetInFrontOfPlayerPosition(struct MapPosition * position);
static u16 GetPlayerCurMetatileBehavior(void);
@@ -50,10 +57,10 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior);
static void UpdateHappinessStepCounter(void);
static bool8 UpdatePoisonStepCounter(void);
static bool8 CheckStandardWildEncounter(u32 encounter);
-static bool8 sub_806D804(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
-static void sub_806D908(const u8 *script, u8 playerDirection);
-static u8 sub_806D898(u16 metatileBehvaior, u8 direction);
-static const u8 *sub_806D928(struct MapPosition * position);
+static bool8 TrySetUpWalkIntoSignpostScript(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
+static void SetUpWalkIntoSignScript(const u8 *script, u8 playerDirection);
+static u8 GetFacingSignpostType(u16 metatileBehvaior, u8 direction);
+static const u8 *GetSignpostScriptAtMapPosition(struct MapPosition * position);
static bool8 TryArrowWarp(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
static bool8 TryStartWarpEventScript(struct MapPosition * position, u16 metatileBehavior);
static bool8 IsWarpMetatileBehavior(u16 metatileBehavior);
@@ -64,8 +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);
-u8 gSelectedObjectEvent;
-struct FieldInput gUnknown_3005078;
+struct FieldInput gInputToStoreInQuestLogMaybe;
void FieldClearPlayerInput(struct FieldInput *input)
{
@@ -91,9 +97,9 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
u8 tileTransitionState = gPlayerAvatar.tileTransitionState;
bool8 forcedMove = MetatileBehavior_IsForcedMovementTile(GetPlayerCurMetatileBehavior());
- if (!ScriptContext1_IsScriptSetUp() && sub_806997C() == TRUE)
+ if (!ScriptContext1_IsScriptSetUp() && IsQuestLogInputDpad() == TRUE)
{
- sub_806CA4C(input, &newKeys, &heldKeys);
+ QuestLogOverrideJoyVars(input, &newKeys, &heldKeys);
}
if ((tileTransitionState == T_TILE_CENTER && forcedMove == FALSE) || tileTransitionState == T_NOT_MOVING)
{
@@ -149,39 +155,39 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
}
}
-static void sub_806CA4C(struct FieldInput *input, u16 *newKeys, u16 *heldKeys)
+static void QuestLogOverrideJoyVars(struct FieldInput *input, u16 *newKeys, u16 *heldKeys)
{
- switch (sub_80699B0())
+ switch (GetRegisteredQuestLogInput())
{
- case 0:
+ case QL_INPUT_OFF:
break;
- case 1:
+ case QL_INPUT_UP:
*heldKeys = *newKeys = DPAD_UP;
break;
- case 2:
+ case QL_INPUT_DOWN:
*heldKeys = *newKeys = DPAD_DOWN;
break;
- case 3:
+ case QL_INPUT_LEFT:
*heldKeys = *newKeys = DPAD_LEFT;
break;
- case 4:
+ case QL_INPUT_RIGHT:
*heldKeys = *newKeys = DPAD_RIGHT;
break;
- case 5:
+ case QL_INPUT_L:
*heldKeys = *newKeys = L_BUTTON;
break;
- case 6:
+ case QL_INPUT_R:
*heldKeys = *newKeys = R_BUTTON;
break;
- case 7:
+ case QL_INPUT_START:
*heldKeys = *newKeys = START_BUTTON;
break;
- case 8:
+ case QL_INPUT_SELECT:
*heldKeys = *newKeys = SELECT_BUTTON;
break;
}
- sub_8069970();
- sub_80699A4();
+ ClearQuestLogInputIsDpadFlag();
+ ClearQuestLogInput();
}
int ProcessPlayerFieldInput(struct FieldInput *input)
@@ -191,14 +197,14 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
u16 metatileBehavior;
u32 r8;
- sub_8069A54();
+ ResetFacingNpcOrSignPostVars();
playerDirection = GetPlayerFacingDirection();
GetPlayerPosition(&position);
r8 = MapGridGetMetatileAttributeAt(position.x, position.y, 0xFF);
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
- FieldClearPlayerInput(&gUnknown_3005078);
- gUnknown_3005078.dpadDirection = input->dpadDirection;
+ FieldClearPlayerInput(&gInputToStoreInQuestLogMaybe);
+ gInputToStoreInQuestLogMaybe.dpadDirection = input->dpadDirection;
if (CheckForTrainersWantingBattle() == TRUE)
return TRUE;
@@ -216,7 +222,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
IncrementBirthIslandRockStepCount();
if (TryStartStepBasedScript(&position, metatileBehavior, playerDirection) == TRUE)
{
- gUnknown_3005078.tookStep = TRUE;
+ gInputToStoreInQuestLogMaybe.tookStep = TRUE;
return TRUE;
}
}
@@ -226,9 +232,9 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
{
GetInFrontOfPlayerPosition(&position);
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
- if (sub_806D804(&position, metatileBehavior, playerDirection) == TRUE)
+ if (TrySetUpWalkIntoSignpostScript(&position, metatileBehavior, playerDirection) == TRUE)
{
- gUnknown_3005078.checkStandardWildEncounter = TRUE;
+ gInputToStoreInQuestLogMaybe.checkStandardWildEncounter = TRUE;
return TRUE;
}
GetPlayerPosition(&position);
@@ -237,14 +243,14 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
}
if (input->checkStandardWildEncounter && CheckStandardWildEncounter(r8) == TRUE)
{
- gUnknown_3005078.checkStandardWildEncounter = TRUE;
+ gInputToStoreInQuestLogMaybe.checkStandardWildEncounter = TRUE;
return TRUE;
}
if (input->heldDirection && input->dpadDirection == playerDirection)
{
if (TryArrowWarp(&position, metatileBehavior, playerDirection) == TRUE)
{
- gUnknown_3005078.heldDirection = TRUE;
+ gInputToStoreInQuestLogMaybe.heldDirection = TRUE;
return TRUE;
}
}
@@ -253,16 +259,16 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
if (input->heldDirection && input->dpadDirection == playerDirection)
{
- if (sub_806D804(&position, metatileBehavior, playerDirection) == TRUE)
+ if (TrySetUpWalkIntoSignpostScript(&position, metatileBehavior, playerDirection) == TRUE)
{
- gUnknown_3005078.heldDirection = TRUE;
+ gInputToStoreInQuestLogMaybe.heldDirection = TRUE;
return TRUE;
}
}
if (input->pressedAButton && TryStartInteractionScript(&position, metatileBehavior, playerDirection) == TRUE)
{
- gUnknown_3005078.pressedAButton = TRUE;
+ gInputToStoreInQuestLogMaybe.pressedAButton = TRUE;
return TRUE;
}
@@ -270,14 +276,14 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
{
if (TryDoorWarp(&position, metatileBehavior, playerDirection) == TRUE)
{
- gUnknown_3005078.heldDirection2 = TRUE;
+ gInputToStoreInQuestLogMaybe.heldDirection2 = TRUE;
return TRUE;
}
}
if (input->pressedStartButton)
{
- gUnknown_3005078.pressedStartButton = TRUE;
+ gInputToStoreInQuestLogMaybe.pressedStartButton = TRUE;
FlagSet(FLAG_OPENED_START_MENU);
PlaySE(SE_WIN_OPEN);
ShowStartMenu();
@@ -285,48 +291,48 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
}
if (input->pressedSelectButton && UseRegisteredKeyItemOnField() == TRUE)
{
- gUnknown_3005078.pressedSelectButton = TRUE;
+ gInputToStoreInQuestLogMaybe.pressedSelectButton = TRUE;
return TRUE;
}
return FALSE;
}
-void sub_806CD30(struct FieldInput * input)
+void FieldInput_HandleCancelSignpost(struct FieldInput * input)
{
if (ScriptContext1_IsScriptSetUp() == TRUE)
{
- if (gUnknown_20370A0 != 0)
- gUnknown_20370A0--;
- else if (sub_8069A04() == TRUE)
+ if (gWalkAwayFromSignInhibitTimer != 0)
+ gWalkAwayFromSignInhibitTimer--;
+ else if (CanWalkAwayToCancelMsgBox() == TRUE)
{
if (input->dpadDirection != 0 && GetPlayerFacingDirection() != input->dpadDirection)
{
if (sub_80699D4() == TRUE)
return;
if (input->dpadDirection == DIR_NORTH)
- sub_8069998(1);
+ RegisterQuestLogInput(QL_INPUT_UP);
else if (input->dpadDirection == DIR_SOUTH)
- sub_8069998(2);
+ RegisterQuestLogInput(QL_INPUT_DOWN);
else if (input->dpadDirection == DIR_WEST)
- sub_8069998(3);
+ RegisterQuestLogInput(QL_INPUT_LEFT);
else if (input->dpadDirection == DIR_EAST)
- sub_8069998(4);
- ScriptContext1_SetupScript(gUnknown_81A7ADB);
+ RegisterQuestLogInput(QL_INPUT_RIGHT);
+ ScriptContext1_SetupScript(EventScript_CancelMessageBox);
ScriptContext2_Enable();
}
else if (input->pressedStartButton)
{
- ScriptContext1_SetupScript(gUnknown_81A7ADB);
+ ScriptContext1_SetupScript(EventScript_CancelMessageBox);
ScriptContext2_Enable();
- if (!FuncIsActiveTask(sub_806CDF8))
- CreateTask(sub_806CDF8, 8);
+ if (!FuncIsActiveTask(Task_QuestLogPlayback_OpenStartMenu))
+ CreateTask(Task_QuestLogPlayback_OpenStartMenu, 8);
}
}
}
}
-static void sub_806CDF8(u8 taskId)
+static void Task_QuestLogPlayback_OpenStartMenu(u8 taskId)
{
if (!ScriptContext2_IsEnabled())
{
@@ -411,7 +417,7 @@ const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatil
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
return NULL;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
if (gLinkPlayerObjectEvents[i].active == TRUE && gLinkPlayerObjectEvents[i].objEventId == objectEventId)
return NULL;
@@ -455,7 +461,7 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8
static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
{
- u8 r2;
+ u8 signpostType;
const struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
if (bgEvent == NULL)
@@ -463,7 +469,7 @@ static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position
if (bgEvent->bgUnion.script == NULL)
return EventScript_TestSignpostMsg;
- r2 = sub_806D898(metatileBehavior, direction);
+ signpostType = GetFacingSignpostType(metatileBehavior, direction);
switch (bgEvent->kind)
{
@@ -500,8 +506,8 @@ static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position
return EventScript_HiddenItemScript;
}
- if (r2 != 0xFF)
- sub_8069A20();
+ if (signpostType != SIGNPOST_NA)
+ MsgSetSignPost();
gSpecialVar_Facing = direction;
return bgEvent->bgUnion.script;
}
@@ -571,23 +577,23 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me
return CableClub_EventScript_ShowBattleRecords;
if (MetatileBehavior_IsIndigoPlateauMark(metatileBehavior) == TRUE)
{
- sub_8069A20();
- return gUnknown_81A76F0;
+ MsgSetSignPost();
+ return EventScript_Indigo_UltimateGoal;
}
if (MetatileBehavior_IsIndigoPlateauMark2(metatileBehavior) == TRUE)
{
- sub_8069A20();
- return gUnknown_81A76F9;
+ MsgSetSignPost();
+ return EventScript_Indigo_HighestAuthority;
}
if (MetatileBehavior_IsPlayerFacingPokeMartSign(metatileBehavior, direction) == TRUE)
{
- sub_8069A20();
- return gUnknown_81A76DE;
+ MsgSetSignPost();
+ return EventScript_PokemartSign;
}
if (MetatileBehavior_IsPlayerFacingPokemonCenterSign(metatileBehavior, direction) == TRUE)
{
- sub_8069A20();
- return gUnknown_81A76E7;
+ MsgSetSignPost();
+ return EventScript_PokecenterSign;
}
return NULL;
}
@@ -736,7 +742,7 @@ static bool8 CheckStandardWildEncounter(u32 encounter)
return TryStandardWildEncounter(encounter);
}
-static bool8 sub_806D804(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection)
+static bool8 TrySetUpWalkIntoSignpostScript(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection)
{
u8 r4;
const u8 * script;
@@ -745,68 +751,68 @@ static bool8 sub_806D804(struct MapPosition * position, u16 metatileBehavior, u8
if (playerDirection == DIR_EAST || playerDirection == DIR_WEST)
return FALSE;
- r4 = sub_806D898(metatileBehavior, playerDirection);
- if (r4 == 0)
+ r4 = GetFacingSignpostType(metatileBehavior, playerDirection);
+ if (r4 == SIGNPOST_POKECENTER)
{
- sub_806D908(gUnknown_81A76E7, playerDirection);
+ SetUpWalkIntoSignScript(EventScript_PokecenterSign, playerDirection);
return TRUE;
}
- else if (r4 == 1)
+ else if (r4 == SIGNPOST_POKEMART)
{
- sub_806D908(gUnknown_81A76DE, playerDirection);
+ SetUpWalkIntoSignScript(EventScript_PokemartSign, playerDirection);
return TRUE;
}
- else if (r4 == 2)
+ else if (r4 == SIGNPOST_INDIGO_1)
{
- sub_806D908(gUnknown_81A76F0, playerDirection);
+ SetUpWalkIntoSignScript(EventScript_Indigo_UltimateGoal, playerDirection);
return TRUE;
}
- else if (r4 == 3)
+ else if (r4 == SIGNPOST_INDIGO_2)
{
- sub_806D908(gUnknown_81A76F9, playerDirection);
+ SetUpWalkIntoSignScript(EventScript_Indigo_HighestAuthority, playerDirection);
return TRUE;
}
else
{
- script = sub_806D928(position);
+ script = GetSignpostScriptAtMapPosition(position);
if (script == NULL)
return FALSE;
- if (r4 != 0xF0)
+ if (r4 != SIGNPOST_SCRIPTED)
return FALSE;
- sub_806D908(script, playerDirection);
+ SetUpWalkIntoSignScript(script, playerDirection);
return TRUE;
}
}
-static u8 sub_806D898(u16 metatileBehavior, u8 playerDirection)
+static u8 GetFacingSignpostType(u16 metatileBehavior, u8 playerDirection)
{
if (MetatileBehavior_IsPlayerFacingPokemonCenterSign(metatileBehavior, playerDirection) == TRUE)
- return 0;
+ return SIGNPOST_POKECENTER;
if (MetatileBehavior_IsPlayerFacingPokeMartSign(metatileBehavior, playerDirection) == TRUE)
- return 1;
+ return SIGNPOST_POKEMART;
if (MetatileBehavior_IsIndigoPlateauMark(metatileBehavior) == TRUE)
- return 2;
+ return SIGNPOST_INDIGO_1;
if (MetatileBehavior_IsIndigoPlateauMark2(metatileBehavior) == TRUE)
- return 3;
+ return SIGNPOST_INDIGO_2;
if (MetatileBehavior_IsSignpost(metatileBehavior) == TRUE)
- return 0xF0;
+ return SIGNPOST_SCRIPTED;
- return 0xFF;
+ return SIGNPOST_NA;
}
-static void sub_806D908(const u8 *script, u8 playerDirection)
+static void SetUpWalkIntoSignScript(const u8 *script, u8 playerDirection)
{
gSpecialVar_Facing = playerDirection;
ScriptContext1_SetupScript(script);
- sub_80699E0();
- sub_8069A20();
+ SetWalkingIntoSignVars();
+ MsgSetSignPost();
}
-static const u8 *sub_806D928(struct MapPosition * position)
+static const u8 *GetSignpostScriptAtMapPosition(struct MapPosition * position)
{
const struct BgEvent * event = GetBackgroundEventAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
if (event == NULL)
diff --git a/src/field_specials.c b/src/field_specials.c
index 86ae03ddb..59c026b78 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -547,11 +547,11 @@ void NullFieldSpecial(void)
}
-void sub_80CADC4(void)
+void DoPicboxCancel(void)
{
u8 t = EOS;
AddTextPrinterParameterized(0, 2, &t, 0, 1, 0, NULL);
- sub_809D424();
+ PicboxCancel();
}
void SetVermilionTrashCans(void)
@@ -1545,7 +1545,7 @@ void SetSeenMon(void)
GetSetPokedexFlag(SpeciesToNationalPokedexNum(gSpecialVar_0x8004), 2);
}
-void sub_80CBDE8(void)
+void ResetContextNpcTextColor(void)
{
gSelectedObjectEvent = 0;
gSpecialVar_TextColor = 0xFF;
diff --git a/src/scrcmd.c b/src/scrcmd.c
index f58c5b220..2b5137f9a 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -55,8 +55,7 @@ static EWRAM_DATA u16 sMovingNpcMapId = 0;
static EWRAM_DATA u16 sFieldEffectScriptId = 0;
struct ScriptContext * gUnknown_3005070;
-
-extern u8 gSelectedObjectEvent;
+u8 gSelectedObjectEvent;
// This is defined in here so the optimizer can't see its value when compiling
// script.c.
@@ -1315,32 +1314,32 @@ bool8 ScrCmd_closemessage(struct ScriptContext * ctx)
static bool8 WaitForAorBPress(void)
{
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
return TRUE;
- if (gMain.newKeys & B_BUTTON)
+ if (JOY_NEW(B_BUTTON))
return TRUE;
if (sub_806B93C(gUnknown_3005070) == TRUE)
{
u8 r4 = sub_806B96C(gUnknown_3005070);
- sub_8069998(r4);
- if (r4)
+ RegisterQuestLogInput(r4);
+ if (r4 != QL_INPUT_OFF)
{
- if (gQuestLogState != 2)
+ if (gQuestLogState != QL_STATE_2)
{
- sub_80699F8();
- if (r4 < 9 || r4 > 10)
- sub_8069964();
+ ClearMsgBoxCancelableState();
+ if (r4 != QL_INPUT_A && r4 != QL_INPUT_B)
+ SetQuestLogInputIsDpadFlag();
else
{
- sub_80699A4();
- sub_8069970();
+ ClearQuestLogInput();
+ ClearQuestLogInputIsDpadFlag();
}
return TRUE;
}
}
}
- if (sub_8112CAC() == 1 || gQuestLogState == 2)
+ if (sub_8112CAC() == 1 || gQuestLogState == QL_STATE_2)
{
if (gUnknown_20370AC == 120)
return TRUE;
@@ -1368,37 +1367,37 @@ static bool8 sub_806B93C(struct ScriptContext * ctx)
static u8 sub_806B96C(struct ScriptContext * ctx)
{
- if (gMain.heldKeys & DPAD_UP && gSpecialVar_Facing != 2)
- return 1;
+ if (JOY_HELD(DPAD_UP) && gSpecialVar_Facing != DIR_NORTH)
+ return QL_INPUT_UP;
- if (gMain.heldKeys & DPAD_DOWN && gSpecialVar_Facing != 1)
- return 2;
+ if (JOY_HELD(DPAD_DOWN) && gSpecialVar_Facing != DIR_SOUTH)
+ return QL_INPUT_DOWN;
- if (gMain.heldKeys & DPAD_LEFT && gSpecialVar_Facing != 3)
- return 3;
+ if (JOY_HELD(DPAD_LEFT) && gSpecialVar_Facing != DIR_WEST)
+ return QL_INPUT_LEFT;
- if (gMain.heldKeys & DPAD_RIGHT && gSpecialVar_Facing != 4)
- return 4;
+ if (JOY_HELD(DPAD_RIGHT) && gSpecialVar_Facing != DIR_EAST)
+ return QL_INPUT_RIGHT;
- if (gMain.newKeys & L_BUTTON)
- return 5;
+ if (JOY_NEW(L_BUTTON))
+ return QL_INPUT_L;
- if (gMain.heldKeys & R_BUTTON)
- return 6;
+ if (JOY_HELD(R_BUTTON))
+ return QL_INPUT_R;
- if (gMain.heldKeys & START_BUTTON)
- return 7;
+ if (JOY_HELD(START_BUTTON))
+ return QL_INPUT_START;
- if (gMain.heldKeys & SELECT_BUTTON)
- return 8;
+ if (JOY_HELD(SELECT_BUTTON))
+ return QL_INPUT_SELECT;
- if (gMain.newKeys & A_BUTTON)
- return 9;
+ if (JOY_NEW(A_BUTTON))
+ return QL_INPUT_A;
- if (gMain.newKeys & B_BUTTON)
- return 10;
+ if (JOY_NEW(B_BUTTON))
+ return QL_INPUT_B;
- return 0;
+ return QL_INPUT_OFF;
}
bool8 ScrCmd_waitbuttonpress(struct ScriptContext * ctx)
@@ -2224,13 +2223,13 @@ bool8 ScrCmd_removecoins(struct ScriptContext * ctx)
bool8 ScrCmd_signmsg(struct ScriptContext * ctx)
{
- sub_8069A20();
+ MsgSetSignPost();
return FALSE;
}
bool8 ScrCmd_normalmsg(struct ScriptContext * ctx)
{
- sub_8069A2C();
+ MsgSetNotSignPost();
return FALSE;
}
diff --git a/src/script.c b/src/script.c
index 7c7c3b970..ff74b40bc 100644
--- a/src/script.c
+++ b/src/script.c
@@ -7,7 +7,7 @@
#define SCRIPT_STACK_SIZE 20
-extern void sub_80CBDE8(void); // field_specials
+extern void ResetContextNpcTextColor(void); // field_specials
extern u16 CalcCRC16WithTable(u8 *data, int length); // util
extern bool32 ValidateReceivedWonderCard(void); // mevent
@@ -18,7 +18,7 @@ enum
SCRIPT_MODE_NATIVE,
};
-EWRAM_DATA u8 gUnknown_20370A0 = 0;
+EWRAM_DATA u8 gWalkAwayFromSignInhibitTimer = 0;
EWRAM_DATA const u8 *gRAMScriptPtr = NULL;
// iwram bss
@@ -29,10 +29,10 @@ static u32 sUnusedVariable2;
static struct ScriptContext sScriptContext2;
static bool8 sScriptContext2Enabled;
static u8 gUnknown_3000F9D;
-static u8 gUnknown_3000F9E;
-static u8 gUnknown_3000F9F;
-static u8 gUnknown_3000FA0;
-static u8 gUnknown_3000FA1;
+static u8 sMsgBoxIsCancelable;
+static u8 sQuestLogInput;
+static u8 sQuestLogInputIsDpad;
+static u8 sMsgIsSignPost;
extern ScrCmdFunc gScriptCmdTable[];
extern ScrCmdFunc gScriptCmdTableEnd[];
@@ -202,95 +202,95 @@ bool8 ScriptContext2_IsEnabled(void)
return sScriptContext2Enabled;
}
-void sub_8069964(void)
+void SetQuestLogInputIsDpadFlag(void)
{
- gUnknown_3000FA0 = 1;
+ sQuestLogInputIsDpad = TRUE;
}
-void sub_8069970(void)
+void ClearQuestLogInputIsDpadFlag(void)
{
- gUnknown_3000FA0 = 0;
+ sQuestLogInputIsDpad = FALSE;
}
-bool8 sub_806997C(void)
+bool8 IsQuestLogInputDpad(void)
{
- if(gUnknown_3000FA0 == TRUE)
+ if(sQuestLogInputIsDpad == TRUE)
return TRUE;
else
return FALSE;
}
-void sub_8069998(u8 var)
+void RegisterQuestLogInput(u8 var)
{
- gUnknown_3000F9F = var;
+ sQuestLogInput = var;
}
-void sub_80699A4(void)
+void ClearQuestLogInput(void)
{
- gUnknown_3000F9F = 0;
+ sQuestLogInput = 0;
}
-u8 sub_80699B0(void)
+u8 GetRegisteredQuestLogInput(void)
{
- return gUnknown_3000F9F;
+ return sQuestLogInput;
}
void sub_80699BC(void)
{
- gUnknown_3000F9D = 1;
+ gUnknown_3000F9D = TRUE;
}
void sub_80699C8(void)
{
- gUnknown_3000F9D = 0;
+ gUnknown_3000F9D = FALSE;
}
-u8 sub_80699D4(void)
+bool8 sub_80699D4(void)
{
return gUnknown_3000F9D;
}
-void sub_80699E0(void)
+void SetWalkingIntoSignVars(void)
{
- gUnknown_20370A0 = 6;
- gUnknown_3000F9E = 1;
+ gWalkAwayFromSignInhibitTimer = 6;
+ sMsgBoxIsCancelable = TRUE;
}
-void sub_80699F8(void)
+void ClearMsgBoxCancelableState(void)
{
- gUnknown_3000F9E = 0;
+ sMsgBoxIsCancelable = FALSE;
}
-bool8 sub_8069A04(void)
+bool8 CanWalkAwayToCancelMsgBox(void)
{
- if(gUnknown_3000F9E == TRUE)
+ if(sMsgBoxIsCancelable == TRUE)
return TRUE;
else
return FALSE;
}
-void sub_8069A20(void)
+void MsgSetSignPost(void)
{
- gUnknown_3000FA1 = 1;
+ sMsgIsSignPost = TRUE;
}
-void sub_8069A2C(void)
+void MsgSetNotSignPost(void)
{
- gUnknown_3000FA1 = 0;
+ sMsgIsSignPost = FALSE;
}
bool8 IsMsgSignPost(void)
{
- if(gUnknown_3000FA1 == TRUE)
+ if(sMsgIsSignPost == TRUE)
return TRUE;
else
return FALSE;
}
-void sub_8069A54(void)
+void ResetFacingNpcOrSignPostVars(void)
{
- sub_80CBDE8();
- sub_8069A2C();
+ ResetContextNpcTextColor();
+ MsgSetNotSignPost();
}
bool8 ScriptContext1_IsScriptSetUp(void)
@@ -329,9 +329,9 @@ bool8 ScriptContext2_RunScript(void)
void ScriptContext1_SetupScript(const u8 *ptr)
{
- sub_80699F8();
+ ClearMsgBoxCancelableState();
sub_80699C8();
- sub_8069970();
+ ClearQuestLogInputIsDpadFlag();
InitScriptContext(&sScriptContext1, gScriptCmdTable, gScriptCmdTableEnd);
SetupBytecodeScript(&sScriptContext1, ptr);
ScriptContext2_Enable();
diff --git a/src/script_menu.c b/src/script_menu.c
index a4745ee10..94aaf528d 100644
--- a/src/script_menu.c
+++ b/src/script_menu.c
@@ -1070,7 +1070,7 @@ static bool8 PicboxWait(void)
return FALSE;
}
-void sub_809D424(void)
+void PicboxCancel(void)
{
u8 taskId = FindTaskIdByFunc(Task_ScriptShowMonPic);
struct Task * task;