summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2020-04-10 12:48:58 -0400
committerGitHub <noreply@github.com>2020-04-10 12:48:58 -0400
commit2880cf2a51ea36fa36f00d9ecf07177e5955c882 (patch)
tree331837d61614da6f73e983a7230796ace13c9ea6 /src
parenta81edaba1d5e0f84336fd8a57a48b2a970171ba4 (diff)
parent5f7ed93363db01da8667aadf47d78cb6515bb450 (diff)
Merge pull request #323 from PikalaxALT/various_documentation
Document various parts of the source tree
Diffstat (limited to 'src')
-rw-r--r--src/battle_anim.c4
-rw-r--r--src/battle_anim_mons.c2
-rw-r--r--src/battle_anim_special.c20
-rw-r--r--src/battle_controller_safari.c2
-rw-r--r--src/battle_controllers.c2
-rw-r--r--src/battle_main.c6
-rw-r--r--src/battle_message.c748
-rw-r--r--src/battle_setup.c13
-rw-r--r--src/cable_club.c8
-rw-r--r--src/cereader_tool.c2
-rw-r--r--src/coins.c2
-rw-r--r--src/credits.c7
-rw-r--r--src/dark.c3
-rw-r--r--src/data.c2
-rw-r--r--src/decompress.c2
-rw-r--r--src/digit_obj_util.c3
-rw-r--r--src/diploma.c15
-rw-r--r--src/dynamic_placeholder_text_util.c3
-rw-r--r--src/easy_chat.c3
-rw-r--r--src/event_data.c4
-rw-r--r--src/event_object_lock.c27
-rw-r--r--src/event_object_movement.c9
-rw-r--r--src/evolution_graphics.c3
-rw-r--r--src/evolution_scene.c11
-rw-r--r--src/fame_checker.c11
-rw-r--r--src/field_control_avatar.c33
-rw-r--r--src/field_effect.c12
-rw-r--r--src/field_effect_helpers.c3
-rw-r--r--src/field_fadetransition.c88
-rw-r--r--src/field_message_box.c2
-rw-r--r--src/field_player_avatar.c16
-rw-r--r--src/field_poison.c2
-rw-r--r--src/field_screen_effect.c4
-rw-r--r--src/field_specials.c159
-rw-r--r--src/field_tasks.c4
-rw-r--r--src/field_weather_effects.c1
-rw-r--r--src/fieldmap.c3
-rw-r--r--src/fighting.c2
-rw-r--r--src/fldeff_cut.c2
-rw-r--r--src/fldeff_poison.c3
-rw-r--r--src/fldeff_rocksmash.c3
-rw-r--r--src/fldeff_softboiled.c3
-rw-r--r--src/fldeff_sweetscent.c4
-rw-r--r--src/flying.c2
-rw-r--r--src/ghost.c6
-rw-r--r--src/gpu_regs.c1
-rw-r--r--src/graphics.c4
-rw-r--r--src/hall_of_fame.c8
-rw-r--r--src/help_message.c196
-rw-r--r--src/help_system.c7
-rw-r--r--src/help_system_812B1E0.c4
-rw-r--r--src/hof_pc.c4
-rw-r--r--src/ice.c5
-rw-r--r--src/isagbprn.c1
-rw-r--r--src/item.c3
-rw-r--r--src/item_menu.c2
-rw-r--r--src/item_menu_icons.c2
-rw-r--r--src/item_pc.c8
-rw-r--r--src/item_use.c80
-rw-r--r--src/itemfinder.c6
-rw-r--r--src/learn_move.c8
-rw-r--r--src/librfu_intr.c1
-rw-r--r--src/link.c17
-rw-r--r--src/link_rfu_2.c36
-rw-r--r--src/link_rfu_3.c4
-rw-r--r--src/list_menu.c5
-rw-r--r--src/load_save.c5
-rw-r--r--src/mail.c6
-rw-r--r--src/mail_data.c2
-rw-r--r--src/mailbox_pc.c5
-rw-r--r--src/main.c10
-rw-r--r--src/main_menu.c9
-rw-r--r--src/map_name_popup.c9
-rw-r--r--src/map_preview_screen.c8
-rw-r--r--src/menu.c5
-rw-r--r--src/menu2.c5
-rw-r--r--src/menu_helpers.c7
-rw-r--r--src/menu_indicators.c4
-rw-r--r--src/metatile_behavior.c26
-rw-r--r--src/mevent.c5
-rw-r--r--src/mevent_client.c2
-rw-r--r--src/mevent_server.c2
-rw-r--r--src/mevent_show_card.c5
-rw-r--r--src/minigame_countdown.c2
-rw-r--r--src/mon_markings.c3
-rw-r--r--src/money.c3
-rw-r--r--src/mystery_event_script.c4
-rw-r--r--src/mystery_gift_menu.c11
-rw-r--r--src/new_game.c3
-rw-r--r--src/new_menu_helpers.c21
-rw-r--r--src/normal.c2
-rw-r--r--src/oak_speech.c11
-rw-r--r--src/option_menu.c11
-rw-r--r--src/overworld.c66
-rw-r--r--src/palette.c3
-rw-r--r--src/party_menu.c1
-rw-r--r--src/party_menu_specials.c4
-rw-r--r--src/pc_screen_effect.c3
-rw-r--r--src/player_pc.c4
-rw-r--r--src/pokeball.c5
-rw-r--r--src/pokedex_area_markers.c5
-rw-r--r--src/pokedex_screen.c10
-rw-r--r--src/pokemon.c6
-rw-r--r--src/pokemon_icon.c2
-rw-r--r--src/pokemon_jump_4.c2
-rw-r--r--src/pokemon_size_record.c3
-rw-r--r--src/psychic.c4
-rw-r--r--src/quest_log.c3197
-rw-r--r--src/quest_log_battle.c2
-rw-r--r--src/quest_log_events.c2155
-rw-r--r--src/quest_log_objects.c4
-rw-r--r--src/quest_log_player.c4
-rw-r--r--src/region_map.c7
-rw-r--r--src/reset_save_heap.c4
-rw-r--r--src/reshow_battle_screen.c7
-rw-r--r--src/rock.c4
-rw-r--r--src/roulette_util.c2
-rw-r--r--src/safari_zone.c2
-rw-r--r--src/save.c1
-rw-r--r--src/save_failed_screen.c4
-rw-r--r--src/save_menu_util.c3
-rw-r--r--src/scrcmd.c65
-rw-r--r--src/script.c2
-rw-r--r--src/script_menu.c6
-rw-r--r--src/script_pokemon_util.c2
-rw-r--r--src/seagallop.c7
-rw-r--r--src/shop.c10
-rw-r--r--src/slot_machine.c1735
-rw-r--r--src/sound.c9
-rw-r--r--src/ss_anne.c2
-rw-r--r--src/start_menu.c9
-rw-r--r--src/string_util.c3
-rw-r--r--src/strings.c6
-rw-r--r--src/teachy_tv.c10
-rw-r--r--src/text.c10
-rw-r--r--src/text_window.c6
-rw-r--r--src/title_screen.c7
-rw-r--r--src/tm_case.c8
-rw-r--r--src/trade.c787
-rw-r--r--src/trade_scene.c9
-rw-r--r--src/trainer_card.c10
-rw-r--r--src/trainer_fan_club.c359
-rw-r--r--src/trainer_pokemon_sprites.c6
-rw-r--r--src/trainer_tower.c8
-rw-r--r--src/union_room.c4
-rw-r--r--src/union_room_battle.c6
-rw-r--r--src/vs_seeker.c168
-rw-r--r--src/wild_encounter.c2
-rw-r--r--src/window.c5
-rw-r--r--src/window_8bpp.c5
-rw-r--r--src/wireless_communication_status_screen.c9
151 files changed, 5235 insertions, 5406 deletions
diff --git a/src/battle_anim.c b/src/battle_anim.c
index 1132b5725..af387bb08 100644
--- a/src/battle_anim.c
+++ b/src/battle_anim.c
@@ -1382,7 +1382,7 @@ const struct CompressedSpriteSheet gBattleAnimPicTable[] =
{gBattleAnimSpriteGfx_GreenSpike, 0x0080, ANIM_TAG_GREEN_SPIKE},
{gBattleAnimSpriteGfx_CircleOfLight, 0x0800, ANIM_TAG_WHITE_CIRCLE_OF_LIGHT},
{gBattleAnimSpriteGfx_GlowyRedOrb, 0x0020, ANIM_TAG_GLOWY_BLUE_ORB},
- {gBattleAnimSpriteGfx_Pokeblock, 0x0080, ANIM_TAG_POKEBLOCK},
+ {gBattleAnimSpriteGfx_SafariBait, 0x0080, ANIM_TAG_SAFARI_BAIT},
{gBattleAnimSpriteGfx_WhiteFeather, 0x0400, ANIM_TAG_WHITE_FEATHER},
{gBattleAnimSpriteGfx_Sparkle6, 0x0080, ANIM_TAG_SPARKLE_6},
{gBattleAnimSpriteGfx_Splash, 0x0800, ANIM_TAG_SPLASH},
@@ -1675,7 +1675,7 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] =
{gBattleAnimSpritePal_GreenSpike, ANIM_TAG_GREEN_SPIKE},
{gBattleAnimSpritePal_WhiteCircleOfLight, ANIM_TAG_WHITE_CIRCLE_OF_LIGHT},
{gBattleAnimSpritePal_GlowyBlueOrb, ANIM_TAG_GLOWY_BLUE_ORB},
- {gBattleAnimSpritePal_Pokeblock, ANIM_TAG_POKEBLOCK},
+ {gBattleAnimSpritePal_SafariBait, ANIM_TAG_SAFARI_BAIT},
{gBattleAnimSpritePal_WhiteFeather, ANIM_TAG_WHITE_FEATHER},
{gBattleAnimSpritePal_Sparkle6, ANIM_TAG_SPARKLE_6},
{gBattleAnimSpritePal_Splash, ANIM_TAG_SPLASH},
diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c
index 8cc6c9a00..741fdf312 100644
--- a/src/battle_anim_mons.c
+++ b/src/battle_anim_mons.c
@@ -898,7 +898,7 @@ void sub_8075458(bool8 arg0)
}
}
-void sub_8075490(struct Sprite *sprite)
+void StartSpriteLinearTranslationFromCurrentPos(struct Sprite *sprite)
{
sprite->data[1] = sprite->pos1.x;
sprite->data[3] = sprite->pos1.y;
diff --git a/src/battle_anim_special.c b/src/battle_anim_special.c
index 621ee9039..296e670bd 100644
--- a/src/battle_anim_special.c
+++ b/src/battle_anim_special.c
@@ -375,10 +375,10 @@ static const u16 sBallOpenFadeColors[] =
RGB(4, 0, 0),
};
-const struct SpriteTemplate gPokeblockSpriteTemplate =
+const struct SpriteTemplate gSafariBaitSpriteTemplate =
{
- .tileTag = ANIM_TAG_POKEBLOCK,
- .paletteTag = ANIM_TAG_POKEBLOCK,
+ .tileTag = ANIM_TAG_SAFARI_BAIT,
+ .paletteTag = ANIM_TAG_SAFARI_BAIT,
.oam = &gOamData_AffineOff_ObjNormal_16x16,
.anims = gDummySpriteAnimTable,
.images = NULL,
@@ -2205,20 +2205,20 @@ static void sub_80F1A80(struct Sprite *sprite)
}
}
-void AnimTask_LoadPokeblockGfx(u8 taskId)
+void AnimTask_LoadBaitGfx(u8 taskId)
{
u8 paletteIndex;
- LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[ANIM_TAG_POKEBLOCK - ANIM_SPRITES_START]);
- LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[ANIM_TAG_POKEBLOCK - ANIM_SPRITES_START]);
- paletteIndex = IndexOfSpritePaletteTag(ANIM_TAG_POKEBLOCK);
+ LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[ANIM_TAG_SAFARI_BAIT - ANIM_SPRITES_START]);
+ LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[ANIM_TAG_SAFARI_BAIT - ANIM_SPRITES_START]);
+ paletteIndex = IndexOfSpritePaletteTag(ANIM_TAG_SAFARI_BAIT);
DestroyAnimVisualTask(taskId);
}
-void AnimTask_FreePokeblockGfx(u8 taskId)
+void AnimTask_FreeBaitGfx(u8 taskId)
{
- FreeSpriteTilesByTag(ANIM_TAG_POKEBLOCK);
- FreeSpritePaletteByTag(ANIM_TAG_POKEBLOCK);
+ FreeSpriteTilesByTag(ANIM_TAG_SAFARI_BAIT);
+ FreeSpritePaletteByTag(ANIM_TAG_SAFARI_BAIT);
DestroyAnimVisualTask(taskId);
}
diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c
index e15d76deb..d2f8a1377 100644
--- a/src/battle_controller_safari.c
+++ b/src/battle_controller_safari.c
@@ -171,7 +171,7 @@ static void HandleInputChooseAction(void)
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_BALL, 0);
break;
case 1:
- BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_POKEBLOCK, 0);
+ BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_BAIT, 0);
break;
case 2:
BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_GO_NEAR, 0);
diff --git a/src/battle_controllers.c b/src/battle_controllers.c
index d06d09012..b7737090a 100644
--- a/src/battle_controllers.c
+++ b/src/battle_controllers.c
@@ -37,7 +37,7 @@ void HandleLinkBattleSetup(void)
SetWirelessCommType1();
if (!gReceivedRemoteLinkPlayers)
OpenLink();
- CreateTask(sub_8081A90, 0);
+ CreateTask(Task_WaitForReceivedRemoteLinkPlayers5SecondTimeout, 0);
CreateTasksForSendRecvLinkBuffers();
}
}
diff --git a/src/battle_main.c b/src/battle_main.c
index 841985c48..f91386e6e 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -569,7 +569,7 @@ static void (*const sTurnActionsFuncsTable[])(void) =
[B_ACTION_RUN] = HandleAction_Run,
[B_ACTION_SAFARI_WATCH_CAREFULLY] = HandleAction_WatchesCarefully,
[B_ACTION_SAFARI_BALL] = HandleAction_SafariZoneBallThrow,
- [B_ACTION_SAFARI_POKEBLOCK] = HandleAction_ThrowBait,
+ [B_ACTION_SAFARI_BAIT] = HandleAction_ThrowBait,
[B_ACTION_SAFARI_GO_NEAR] = HandleAction_ThrowRock,
[B_ACTION_SAFARI_RUN] = HandleAction_SafariZoneRun,
[B_ACTION_OLDMAN_THROW] = HandleAction_OldManBallThrow,
@@ -3260,7 +3260,7 @@ static void HandleTurnActionSelectionState(void)
case B_ACTION_SAFARI_BALL:
++gBattleCommunication[gActiveBattler];
break;
- case B_ACTION_SAFARI_POKEBLOCK:
+ case B_ACTION_SAFARI_BAIT:
case B_ACTION_SAFARI_GO_NEAR:
++gBattleCommunication[gActiveBattler];
break;
@@ -3771,7 +3771,7 @@ static void HandleEndTurn_FinishBattle(void)
}
TrySetQuestLogBattleEvent();
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
- sub_810CB90();
+ ClearRematchStateByTrainerId();
BeginFastPaletteFade(3);
FadeOutMapMusic(5);
gBattleMainFunc = FreeResetData_ReturnToOvOrDoEvolutions;
diff --git a/src/battle_message.c b/src/battle_message.c
index e17d3241b..55667de7d 100644
--- a/src/battle_message.c
+++ b/src/battle_message.c
@@ -514,380 +514,380 @@ const u8 gUnknown_83FDD64[] = _("OAK: Hm! Excellent!\pIf you win, you earn prize
const u8 gUnknown_83FDDEB[] = _("OAK: Hm…\nHow disappointing…\pIf you win, you earn prize money,\nand your POKéMON grow.\pBut if you lose, {B_PLAYER_NAME}, you end\nup paying prize money…\pHowever, since you had no warning\nthis time, I'll pay for you.\pBut things won't be this way once\nyou step outside these doors.\pThat's why you must strengthen your\nPOKéMON by battling wild POKéMON.\p");
const u8 *const gBattleStringsTable[] = {
- gUnknown_83FB219,
- gUnknown_83FB265,
- gUnknown_83FB28E,
- gUnknown_83FB2A4,
- gUnknown_83FB2B6,
- gUnknown_83FB2D1,
- gUnknown_83FB2FC,
- gUnknown_83FB31F,
- gUnknown_83FB32E,
- gUnknown_83FB343,
- gUnknown_83FD1B8,
- gUnknown_83FB36B,
- gUnknown_83FB37F,
- gUnknown_83FCBA5,
- gUnknown_83FB394,
- gUnknown_83FB3EA,
- gUnknown_83FB400,
- gUnknown_83FB40D,
- gUnknown_83FB41A,
- gUnknown_83FB433,
- gUnknown_83FB451,
- gUnknown_83FB508,
- gUnknown_83FB545,
- gUnknown_83FB555,
- gUnknown_83FB565,
- gUnknown_83FB57C,
- gUnknown_83FB592,
- gUnknown_83FB5A8,
- gUnknown_83FB5BC,
- gUnknown_83FB5CD,
- gUnknown_83FB5E2,
- gUnknown_83FB5F8,
- gUnknown_83FB610,
- gUnknown_83FB626,
- gUnknown_83FB641,
- gUnknown_83FB650,
- gUnknown_83FB663,
- gUnknown_83FB692,
- gUnknown_83FB6A7,
- gUnknown_83FB6BF,
- gUnknown_83FB6D3,
- gUnknown_83FB6E5,
- gUnknown_83FB6F7,
- gUnknown_83FB70F,
- gUnknown_83FB73A,
- gUnknown_83FB76A,
- gUnknown_83FB78A,
- gUnknown_83FB7A3,
- gUnknown_83FB7BF,
- gUnknown_83FB7D5,
- gUnknown_83FB7EE,
- gUnknown_83FB806,
- gUnknown_83FB826,
- gUnknown_83FB844,
- gUnknown_83FB854,
- gUnknown_83FB871,
- gUnknown_83FB885,
- gUnknown_83FB89D,
- gUnknown_83FB8AE,
- gUnknown_83FB8C5,
- gUnknown_83FB8E0,
- gUnknown_83FB8F3,
- gUnknown_83FB914,
- gUnknown_83FB921,
- gUnknown_83FB935,
- gUnknown_83FB946,
- gUnknown_83FB97F,
- gUnknown_83FB9B8,
- gUnknown_83FB9D9,
- gUnknown_83FB9FF,
- gUnknown_83FBA2F,
- gUnknown_83FBA41,
- gUnknown_83FBA5E,
- gUnknown_83FBA79,
- gUnknown_83FBA8E,
- gUnknown_83FBAA3,
- gUnknown_83FBAB2,
- gUnknown_83FBAC3,
- gUnknown_83FBAF3,
- gUnknown_83FBB11,
- gUnknown_83FBB4C,
- gUnknown_83FBB62,
- gUnknown_83FBB71,
- gUnknown_83FBB83,
- gUnknown_83FBB99,
- gBattleText_MistShroud,
- gUnknown_83FBBD0,
- gBattleText_GetPumped,
- gUnknown_83FBBFF,
- gUnknown_83FBC16,
- gUnknown_83FBC2B,
- gUnknown_83FBC4C,
- gUnknown_83FBC74,
- gUnknown_83FBC83,
- gUnknown_83FBC99,
- gUnknown_83FBCBE,
- gUnknown_83FBCD1,
- gUnknown_83FBCDD,
- gUnknown_83FBCFC,
- gUnknown_83FBD16,
- gUnknown_83FBD2B,
- gUnknown_83FBD43,
- gUnknown_83FBD53,
- gUnknown_83FBD74,
- gUnknown_83FBD86,
- gUnknown_83FBDA3,
- gUnknown_83FBDC4,
- gUnknown_83FBDE2,
- gUnknown_83FBE00,
- gUnknown_83FBE16,
- gUnknown_83FBE2B,
- gUnknown_83FBE4E,
- gUnknown_83FBE61,
- gUnknown_83FBE73,
- gUnknown_83FBE8B,
- gUnknown_83FBEA1,
- gUnknown_83FBEBE,
- gUnknown_83FBEE2,
- gUnknown_83FBEFA,
- gUnknown_83FBF0C,
- gUnknown_83FBF23,
- gUnknown_83FC687,
- gUnknown_83FBF39,
- gUnknown_83FBF51,
- gUnknown_83FBF63,
- gUnknown_83FBF76,
- gUnknown_83FBF89,
- gUnknown_83FBF99,
- gUnknown_83FBFBF,
- gUnknown_83FBFD3,
- gUnknown_83FBFEA,
- gUnknown_83FBFFC,
- gUnknown_83FC011,
- gUnknown_83FC02B,
- gUnknown_83FC048,
- gUnknown_83FC072,
- gUnknown_83FC090,
- gUnknown_83FC0C6,
- gUnknown_83FC0DC,
- gUnknown_83FC0EE,
- gUnknown_83FC10C,
- gUnknown_83FC11E,
- gUnknown_83FC132,
- gUnknown_83FC140,
- gUnknown_83FC168,
- gUnknown_83FC185,
- gUnknown_83FC19D,
- gUnknown_83FC1B1,
- gUnknown_83FC1C6,
- gUnknown_83FC1DB,
- gUnknown_83FC1F1,
- gUnknown_83FC224,
- gUnknown_83FC231,
- gUnknown_83FC254,
- gUnknown_83FC26D,
- gUnknown_83FC28A,
- gUnknown_83FC670,
- gUnknown_83FC2AA,
- gUnknown_83FC69D,
- gUnknown_83FC2C7,
- gUnknown_83FC2E3,
- gUnknown_83FC6D6,
- gUnknown_83FC2FA,
- gUnknown_83FC312,
- gUnknown_83FC377,
- gUnknown_83FC38A,
- gUnknown_83FC39A,
- gUnknown_83FC3AF,
- gUnknown_83FC3C5,
- gUnknown_83FC3EB,
- gUnknown_83FC40E,
- gUnknown_83FC421,
- gUnknown_83FC439,
- gUnknown_83FC461,
- gUnknown_83FC6F8,
- gUnknown_83FC483,
- gUnknown_83FC4AB,
- gUnknown_83FC4D6,
- gUnknown_83FC4F0,
- gUnknown_83FC518,
- gUnknown_83FC53D,
- gUnknown_83FC715,
- gUnknown_83FC72B,
- gUnknown_83FC745,
- gUnknown_83FC75D,
- gUnknown_83FC780,
- gUnknown_83FC7B6,
- gUnknown_83FC7D3,
- gUnknown_83FC7EF,
- gUnknown_83FC809,
- gUnknown_83FC825,
- gUnknown_83FC841,
- gUnknown_83FC860,
- gUnknown_83FC87B,
- gUnknown_83FC895,
- gUnknown_83FC8B1,
- gUnknown_83FC8C2,
- gUnknown_83FCB41,
- gBattleText_Rose,
- gUnknown_83FCB50,
- gUnknown_83FCB59,
- gUnknown_83FCB5F,
- gBattleText_UnknownString3,
- gUnknown_83FCB8F,
- gUnknown_83FCB9A,
- gUnknown_83FCBE4,
- gUnknown_83FCBF4,
- gUnknown_83FCC07,
- gUnknown_83FCC33,
- gUnknown_83FCC5B,
- gUnknown_83FCC74,
- sText_GotAwaySafely,
- gUnknown_83FCCD2,
- gUnknown_83FCDB3,
- gUnknown_83FCDE2,
- gUnknown_83FCDF1,
- gUnknown_83FCDF2,
- gUnknown_83FCE08,
- gUnknown_83FCE17,
- gUnknown_83FCE38,
- gUnknown_83FCE50,
- gUnknown_83FCE64,
- gUnknown_83FCE78,
- gUnknown_83FCE90,
- gUnknown_83FCEA8,
- gUnknown_83FCEBA,
- gUnknown_83FCECE,
- gUnknown_83FCEE3,
- gUnknown_83FCEFB,
- gUnknown_83FCF14,
- gUnknown_83FCF2C,
- gUnknown_83FCF40,
- gUnknown_83FCF54,
- gUnknown_83FCF6C,
- gUnknown_83FCF7E,
- gUnknown_83FCFA0,
- gUnknown_83FCFC2,
- gUnknown_83FCFE4,
- gUnknown_83FD006,
- gUnknown_83FD022,
- gUnknown_83FD048,
- gUnknown_83FD068,
- gUnknown_83FD077,
- gUnknown_83FD0A7,
- gUnknown_83FD0CA,
- sText_PlayerUsedItem,
- sText_OldManUsedItem,
- sText_TrainerBlockedBall,
- sText_DontBeAThief,
- sText_ItDodgedBall,
- sText_YouMissedPkmn,
- sText_PkmnBrokeFree,
- sText_ItAppearedCaught,
- sText_AarghAlmostHadIt,
- sText_ShootSoClose,
- sText_GotchaPkmnCaught,
- sText_GotchaPkmnCaught2,
- sText_GiveNicknameCaptured,
- sText_PkmnSentToPC,
- gUnknown_83FD82B,
- gUnknown_83FD850,
- gUnknown_83FD85F,
- gUnknown_83FB525,
- gUnknown_83FD0F1,
- gUnknown_83FD111,
- gUnknown_83FD124,
- gUnknown_83FD135,
- gUnknown_83FD14B,
- gUnknown_83FD15A,
- gUnknown_83FD16A,
- gUnknown_83FD186,
- gUnknown_83FD1DF,
- gUnknown_83FD1FA,
- gUnknown_83FD218,
- gUnknown_83FD232,
- gUnknown_83FD23F,
- gUnknown_83FB218,
- gUnknown_83FB218,
- gUnknown_83FD24D,
- gUnknown_83FD8B9,
- gUnknown_83FD8D2,
- gUnknown_83FD8E8,
- gUnknown_83FD901,
- gUnknown_83FD917,
- gUnknown_83FD937,
- gUnknown_83FD95C,
- gUnknown_83FD999,
- gUnknown_83FD9B2,
- gUnknown_83FD9CC,
- gUnknown_83FD9E9,
- gUnknown_83FDA0B,
- gUnknown_83FDA33,
- gUnknown_83FDA4C,
- gUnknown_83FC8D5,
- gUnknown_83FC8ED,
- gUnknown_83FC913,
- gUnknown_83FC935,
- gUnknown_83FC979,
- gUnknown_83FC993,
- gUnknown_83FC9AA,
- gUnknown_83FC9C7,
- gUnknown_83FC9E5,
- gUnknown_83FCA03,
- gUnknown_83FC554,
- gUnknown_83FC576,
- gUnknown_83FBAD2,
- gUnknown_83FBAE5,
- gUnknown_83FCC39,
- gUnknown_83FC591,
- sText_PlayerDefeatedLinkTrainerTrainer1,
- gUnknown_83FC5A2,
- gUnknown_83FC5CC,
- gUnknown_83FC5E8,
- gUnknown_83FCB75,
- gUnknown_83FC5F6,
- gUnknown_83FC79D,
- gUnknown_83FBB2F,
- gUnknown_83FB282,
- gUnknown_83FB283,
- gUnknown_83FC955,
- gUnknown_83FB3AF,
- gUnknown_83FDAB1,
- gUnknown_83FCA13,
- gUnknown_83FC208,
- gUnknown_83FC60C,
- gUnknown_83FB359,
- gUnknown_83FCCA0,
- gUnknown_83FCCBB,
- gUnknown_83FC631,
- gUnknown_83FCA49,
- gUnknown_83FD97A,
- sText_Trainer1UsedItem,
- gUnknown_83FD876,
- gUnknown_83FB3D3,
- gUnknown_83FCA71,
- gUnknown_83FCA8E,
- gUnknown_83FB67B,
- gUnknown_83FCBC5,
- gUnknown_83FC900,
- gUnknown_83FBC62,
- gUnknown_83FB997,
- gUnknown_83FB95E,
- gUnknown_83FC646,
- gUnknown_83FCAAA,
- gUnknown_83FCAD1,
- gUnknown_83FB534,
- gUnknown_83FC337,
- gUnknown_83FC347,
- gUnknown_83FC357,
- gUnknown_83FC65A,
- gUnknown_83FCAEF,
- gUnknown_83FDD64,
- gUnknown_83FDDEB,
- gUnknown_83FB484,
- gUnknown_83FB4BE,
- Text_MonSentToBoxInSomeonesPC,
- Text_MonSentToBoxInBillsPC,
- Text_MonSentToBoxSomeonesBoxFull,
- Text_MonSentToBoxBillsBoxFull,
- sText_PokedudeUsedItem,
- gUnknown_83FDA4D,
- gUnknown_83FDA7A,
- gUnknown_83FDA8C,
- gUnknown_83FB21C,
- gUnknown_83FB262,
- gUnknown_83FB4F7,
- gUnknown_83FCB0C,
- gUnknown_83FCB26,
- gUnknown_83FD322,
- gUnknown_83FD34D,
- gUnknown_83FB21F,
- gUnknown_83FB232,
- gUnknown_83FB235,
- gUnknown_83FB248
+ [STRINGID_TRAINER1LOSETEXT - 12] = gUnknown_83FB219,
+ [STRINGID_PKMNGAINEDEXP - 12] = gUnknown_83FB265,
+ [STRINGID_PKMNGREWTOLV - 12] = gUnknown_83FB28E,
+ [STRINGID_PKMNLEARNEDMOVE - 12] = gUnknown_83FB2A4,
+ [STRINGID_TRYTOLEARNMOVE1 - 12] = gUnknown_83FB2B6,
+ [STRINGID_TRYTOLEARNMOVE2 - 12] = gUnknown_83FB2D1,
+ [STRINGID_TRYTOLEARNMOVE3 - 12] = gUnknown_83FB2FC,
+ [STRINGID_PKMNFORGOTMOVE - 12] = gUnknown_83FB31F,
+ [STRINGID_STOPLEARNINGMOVE - 12] = gUnknown_83FB32E,
+ [STRINGID_DIDNOTLEARNMOVE - 12] = gUnknown_83FB343,
+ [STRINGID_PKMNLEARNEDMOVE2 - 12] = gUnknown_83FD1B8,
+ [STRINGID_ATTACKMISSED - 12] = gUnknown_83FB36B,
+ [STRINGID_PKMNPROTECTEDITSELF - 12] = gUnknown_83FB37F,
+ [STRINGID_STATSWONTINCREASE2 - 12] = gUnknown_83FCBA5,
+ [STRINGID_AVOIDEDDAMAGE - 12] = gUnknown_83FB394,
+ [STRINGID_ITDOESNTAFFECT - 12] = gUnknown_83FB3EA,
+ [STRINGID_ATTACKERFAINTED - 12] = gUnknown_83FB400,
+ [STRINGID_TARGETFAINTED - 12] = gUnknown_83FB40D,
+ [STRINGID_PLAYERGOTMONEY - 12] = gUnknown_83FB41A,
+ [STRINGID_PLAYERWHITEOUT - 12] = gUnknown_83FB433,
+ [STRINGID_PLAYERWHITEOUT2 - 12] = gUnknown_83FB451,
+ [STRINGID_PREVENTSESCAPE - 12] = gUnknown_83FB508,
+ [STRINGID_HITXTIMES - 12] = gUnknown_83FB545,
+ [STRINGID_PKMNFELLASLEEP - 12] = gUnknown_83FB555,
+ [STRINGID_PKMNMADESLEEP - 12] = gUnknown_83FB565,
+ [STRINGID_PKMNALREADYASLEEP - 12] = gUnknown_83FB57C,
+ [STRINGID_PKMNALREADYASLEEP2 - 12] = gUnknown_83FB592,
+ [STRINGID_PKMNWASNTAFFECTED - 12] = gUnknown_83FB5A8,
+ [STRINGID_PKMNWASPOISONED - 12] = gUnknown_83FB5BC,
+ [STRINGID_PKMNPOISONEDBY - 12] = gUnknown_83FB5CD,
+ [STRINGID_PKMNHURTBYPOISON - 12] = gUnknown_83FB5E2,
+ [STRINGID_PKMNALREADYPOISONED - 12] = gUnknown_83FB5F8,
+ [STRINGID_PKMNBADLYPOISONED - 12] = gUnknown_83FB610,
+ [STRINGID_PKMNENERGYDRAINED - 12] = gUnknown_83FB626,
+ [STRINGID_PKMNWASBURNED - 12] = gUnknown_83FB641,
+ [STRINGID_PKMNBURNEDBY - 12] = gUnknown_83FB650,
+ [STRINGID_PKMNHURTBYBURN - 12] = gUnknown_83FB663,
+ [STRINGID_PKMNWASFROZEN - 12] = gUnknown_83FB692,
+ [STRINGID_PKMNFROZENBY - 12] = gUnknown_83FB6A7,
+ [STRINGID_PKMNISFROZEN - 12] = gUnknown_83FB6BF,
+ [STRINGID_PKMNWASDEFROSTED - 12] = gUnknown_83FB6D3,
+ [STRINGID_PKMNWASDEFROSTED2 - 12] = gUnknown_83FB6E5,
+ [STRINGID_PKMNWASDEFROSTEDBY - 12] = gUnknown_83FB6F7,
+ [STRINGID_PKMNWASPARALYZED - 12] = gUnknown_83FB70F,
+ [STRINGID_PKMNWASPARALYZEDBY - 12] = gUnknown_83FB73A,
+ [STRINGID_PKMNISPARALYZED - 12] = gUnknown_83FB76A,
+ [STRINGID_PKMNISALREADYPARALYZED - 12] = gUnknown_83FB78A,
+ [STRINGID_PKMNHEALEDPARALYSIS - 12] = gUnknown_83FB7A3,
+ [STRINGID_PKMNDREAMEATEN - 12] = gUnknown_83FB7BF,
+ [STRINGID_STATSWONTINCREASE - 12] = gUnknown_83FB7D5,
+ [STRINGID_STATSWONTDECREASE - 12] = gUnknown_83FB7EE,
+ [STRINGID_TEAMSTOPPEDWORKING - 12] = gUnknown_83FB806,
+ [STRINGID_FOESTOPPEDWORKING - 12] = gUnknown_83FB826,
+ [STRINGID_PKMNISCONFUSED - 12] = gUnknown_83FB844,
+ [STRINGID_PKMNHEALEDCONFUSION - 12] = gUnknown_83FB854,
+ [STRINGID_PKMNWASCONFUSED - 12] = gUnknown_83FB871,
+ [STRINGID_PKMNALREADYCONFUSED - 12] = gUnknown_83FB885,
+ [STRINGID_PKMNFELLINLOVE - 12] = gUnknown_83FB89D,
+ [STRINGID_PKMNINLOVE - 12] = gUnknown_83FB8AE,
+ [STRINGID_PKMNIMMOBILIZEDBYLOVE - 12] = gUnknown_83FB8C5,
+ [STRINGID_PKMNBLOWNAWAY - 12] = gUnknown_83FB8E0,
+ [STRINGID_PKMNCHANGEDTYPE - 12] = gUnknown_83FB8F3,
+ [STRINGID_PKMNFLINCHED - 12] = gUnknown_83FB914,
+ [STRINGID_PKMNREGAINEDHEALTH - 12] = gUnknown_83FB921,
+ [STRINGID_PKMNHPFULL - 12] = gUnknown_83FB935,
+ [STRINGID_PKMNRAISEDSPDEF - 12] = gUnknown_83FB946,
+ [STRINGID_PKMNRAISEDDEF - 12] = gUnknown_83FB97F,
+ [STRINGID_PKMNCOVEREDBYVEIL - 12] = gUnknown_83FB9B8,
+ [STRINGID_PKMNUSEDSAFEGUARD - 12] = gUnknown_83FB9D9,
+ [STRINGID_PKMNSAFEGUARDEXPIRED - 12] = gUnknown_83FB9FF,
+ [STRINGID_PKMNWENTTOSLEEP - 12] = gUnknown_83FBA2F,
+ [STRINGID_PKMNSLEPTHEALTHY - 12] = gUnknown_83FBA41,
+ [STRINGID_PKMNWHIPPEDWHIRLWIND - 12] = gUnknown_83FBA5E,
+ [STRINGID_PKMNTOOKSUNLIGHT - 12] = gUnknown_83FBA79,
+ [STRINGID_PKMNLOWEREDHEAD - 12] = gUnknown_83FBA8E,
+ [STRINGID_PKMNISGLOWING - 12] = gUnknown_83FBAA3,
+ [STRINGID_PKMNFLEWHIGH - 12] = gUnknown_83FBAB2,
+ [STRINGID_PKMNDUGHOLE - 12] = gUnknown_83FBAC3,
+ [STRINGID_PKMNSQUEEZEDBYBIND - 12] = gUnknown_83FBAF3,
+ [STRINGID_PKMNTRAPPEDINVORTEX - 12] = gUnknown_83FBB11,
+ [STRINGID_PKMNWRAPPEDBY - 12] = gUnknown_83FBB4C,
+ [STRINGID_PKMNCLAMPED - 12] = gUnknown_83FBB62,
+ [STRINGID_PKMNHURTBY - 12] = gUnknown_83FBB71,
+ [STRINGID_PKMNFREEDFROM - 12] = gUnknown_83FBB83,
+ [STRINGID_PKMNCRASHED - 12] = gUnknown_83FBB99,
+ [STRINGID_PKMNSHROUDEDINMIST - 12] = gBattleText_MistShroud,
+ [STRINGID_PKMNPROTECTEDBYMIST - 12] = gUnknown_83FBBD0,
+ [STRINGID_PKMNGETTINGPUMPED - 12] = gBattleText_GetPumped,
+ [STRINGID_PKMNHITWITHRECOIL - 12] = gUnknown_83FBBFF,
+ [STRINGID_PKMNPROTECTEDITSELF2 - 12] = gUnknown_83FBC16,
+ [STRINGID_PKMNBUFFETEDBYSANDSTORM - 12] = gUnknown_83FBC2B,
+ [STRINGID_PKMNPELTEDBYHAIL - 12] = gUnknown_83FBC4C,
+ [STRINGID_PKMNSEEDED - 12] = gUnknown_83FBC74,
+ [STRINGID_PKMNEVADEDATTACK - 12] = gUnknown_83FBC83,
+ [STRINGID_PKMNSAPPEDBYLEECHSEED - 12] = gUnknown_83FBC99,
+ [STRINGID_PKMNFASTASLEEP - 12] = gUnknown_83FBCBE,
+ [STRINGID_PKMNWOKEUP - 12] = gUnknown_83FBCD1,
+ [STRINGID_PKMNUPROARKEPTAWAKE - 12] = gUnknown_83FBCDD,
+ [STRINGID_PKMNWOKEUPINUPROAR - 12] = gUnknown_83FBCFC,
+ [STRINGID_PKMNCAUSEDUPROAR - 12] = gUnknown_83FBD16,
+ [STRINGID_PKMNMAKINGUPROAR - 12] = gUnknown_83FBD2B,
+ [STRINGID_PKMNCALMEDDOWN - 12] = gUnknown_83FBD43,
+ [STRINGID_PKMNCANTSLEEPINUPROAR - 12] = gUnknown_83FBD53,
+ [STRINGID_PKMNSTOCKPILED - 12] = gUnknown_83FBD74,
+ [STRINGID_PKMNCANTSTOCKPILE - 12] = gUnknown_83FBD86,
+ [STRINGID_PKMNCANTSLEEPINUPROAR2 - 12] = gUnknown_83FBDA3,
+ [STRINGID_UPROARKEPTPKMNAWAKE - 12] = gUnknown_83FBDC4,
+ [STRINGID_PKMNSTAYEDAWAKEUSING - 12] = gUnknown_83FBDE2,
+ [STRINGID_PKMNSTORINGENERGY - 12] = gUnknown_83FBE00,
+ [STRINGID_PKMNUNLEASHEDENERGY - 12] = gUnknown_83FBE16,
+ [STRINGID_PKMNFATIGUECONFUSION - 12] = gUnknown_83FBE2B,
+ [STRINGID_PKMNPICKEDUPITEM - 12] = gUnknown_83FBE4E,
+ [STRINGID_PKMNUNAFFECTED - 12] = gUnknown_83FBE61,
+ [STRINGID_PKMNTRANSFORMEDINTO - 12] = gUnknown_83FBE73,
+ [STRINGID_PKMNMADESUBSTITUTE - 12] = gUnknown_83FBE8B,
+ [STRINGID_PKMNHASSUBSTITUTE - 12] = gUnknown_83FBEA1,
+ [STRINGID_SUBSTITUTEDAMAGED - 12] = gUnknown_83FBEBE,
+ [STRINGID_PKMNSUBSTITUTEFADED - 12] = gUnknown_83FBEE2,
+ [STRINGID_PKMNMUSTRECHARGE - 12] = gUnknown_83FBEFA,
+ [STRINGID_PKMNRAGEBUILDING - 12] = gUnknown_83FBF0C,
+ [STRINGID_PKMNMOVEWASDISABLED - 12] = gUnknown_83FBF23,
+ [STRINGID_PKMNMOVEISDISABLED - 12] = gUnknown_83FC687,
+ [STRINGID_PKMNMOVEDISABLEDNOMORE - 12] = gUnknown_83FBF39,
+ [STRINGID_PKMNGOTENCORE - 12] = gUnknown_83FBF51,
+ [STRINGID_PKMNENCOREENDED - 12] = gUnknown_83FBF63,
+ [STRINGID_PKMNTOOKAIM - 12] = gUnknown_83FBF76,
+ [STRINGID_PKMNSKETCHEDMOVE - 12] = gUnknown_83FBF89,
+ [STRINGID_PKMNTRYINGTOTAKEFOE - 12] = gUnknown_83FBF99,
+ [STRINGID_PKMNTOOKFOE - 12] = gUnknown_83FBFBF,
+ [STRINGID_PKMNREDUCEDPP - 12] = gUnknown_83FBFD3,
+ [STRINGID_PKMNSTOLEITEM - 12] = gUnknown_83FBFEA,
+ [STRINGID_TARGETCANTESCAPENOW - 12] = gUnknown_83FBFFC,
+ [STRINGID_PKMNFELLINTONIGHTMARE - 12] = gUnknown_83FC011,
+ [STRINGID_PKMNLOCKEDINNIGHTMARE - 12] = gUnknown_83FC02B,
+ [STRINGID_PKMNLAIDCURSE - 12] = gUnknown_83FC048,
+ [STRINGID_PKMNAFFLICTEDBYCURSE - 12] = gUnknown_83FC072,
+ [STRINGID_SPIKESSCATTERED - 12] = gUnknown_83FC090,
+ [STRINGID_PKMNHURTBYSPIKES - 12] = gUnknown_83FC0C6,
+ [STRINGID_PKMNIDENTIFIED - 12] = gUnknown_83FC0DC,
+ [STRINGID_PKMNPERISHCOUNTFELL - 12] = gUnknown_83FC0EE,
+ [STRINGID_PKMNBRACEDITSELF - 12] = gUnknown_83FC10C,
+ [STRINGID_PKMNENDUREDHIT - 12] = gUnknown_83FC11E,
+ [STRINGID_MAGNITUDESTRENGTH - 12] = gUnknown_83FC132,
+ [STRINGID_PKMNCUTHPMAXEDATTACK - 12] = gUnknown_83FC140,
+ [STRINGID_PKMNCOPIEDSTATCHANGES - 12] = gUnknown_83FC168,
+ [STRINGID_PKMNGOTFREE - 12] = gUnknown_83FC185,
+ [STRINGID_PKMNSHEDLEECHSEED - 12] = gUnknown_83FC19D,
+ [STRINGID_PKMNBLEWAWAYSPIKES - 12] = gUnknown_83FC1B1,
+ [STRINGID_PKMNFLEDFROMBATTLE - 12] = gUnknown_83FC1C6,
+ [STRINGID_PKMNFORESAWATTACK - 12] = gUnknown_83FC1DB,
+ [STRINGID_PKMNTOOKATTACK - 12] = gUnknown_83FC1F1,
+ [STRINGID_PKMNATTACK - 12] = gUnknown_83FC224,
+ [STRINGID_PKMNCENTERATTENTION - 12] = gUnknown_83FC231,
+ [STRINGID_PKMNCHARGINGPOWER - 12] = gUnknown_83FC254,
+ [STRINGID_NATUREPOWERTURNEDINTO - 12] = gUnknown_83FC26D,
+ [STRINGID_PKMNSTATUSNORMAL - 12] = gUnknown_83FC28A,
+ [STRINGID_PKMNHASNOMOVESLEFT - 12] = gUnknown_83FC670,
+ [STRINGID_PKMNSUBJECTEDTOTORMENT - 12] = gUnknown_83FC2AA,
+ [STRINGID_PKMNCANTUSEMOVETORMENT - 12] = gUnknown_83FC69D,
+ [STRINGID_PKMNTIGHTENINGFOCUS - 12] = gUnknown_83FC2C7,
+ [STRINGID_PKMNFELLFORTAUNT - 12] = gUnknown_83FC2E3,
+ [STRINGID_PKMNCANTUSEMOVETAUNT - 12] = gUnknown_83FC6D6,
+ [STRINGID_PKMNREADYTOHELP - 12] = gUnknown_83FC2FA,
+ [STRINGID_PKMNSWITCHEDITEMS - 12] = gUnknown_83FC312,
+ [STRINGID_PKMNCOPIEDFOE - 12] = gUnknown_83FC377,
+ [STRINGID_PKMNMADEWISH - 12] = gUnknown_83FC38A,
+ [STRINGID_PKMNWISHCAMETRUE - 12] = gUnknown_83FC39A,
+ [STRINGID_PKMNPLANTEDROOTS - 12] = gUnknown_83FC3AF,
+ [STRINGID_PKMNABSORBEDNUTRIENTS - 12] = gUnknown_83FC3C5,
+ [STRINGID_PKMNANCHOREDITSELF - 12] = gUnknown_83FC3EB,
+ [STRINGID_PKMNWASMADEDROWSY - 12] = gUnknown_83FC40E,
+ [STRINGID_PKMNKNOCKEDOFF - 12] = gUnknown_83FC421,
+ [STRINGID_PKMNSWAPPEDABILITIES - 12] = gUnknown_83FC439,
+ [STRINGID_PKMNSEALEDOPPONENTMOVE - 12] = gUnknown_83FC461,
+ [STRINGID_PKMNCANTUSEMOVESEALED - 12] = gUnknown_83FC6F8,
+ [STRINGID_PKMNWANTSGRUDGE - 12] = gUnknown_83FC483,
+ [STRINGID_PKMNLOSTPPGRUDGE - 12] = gUnknown_83FC4AB,
+ [STRINGID_PKMNSHROUDEDITSELF - 12] = gUnknown_83FC4D6,
+ [STRINGID_PKMNMOVEBOUNCED - 12] = gUnknown_83FC4F0,
+ [STRINGID_PKMNWAITSFORTARGET - 12] = gUnknown_83FC518,
+ [STRINGID_PKMNSNATCHEDMOVE - 12] = gUnknown_83FC53D,
+ [STRINGID_PKMNMADEITRAIN - 12] = gUnknown_83FC715,
+ [STRINGID_PKMNRAISEDSPEED - 12] = gUnknown_83FC72B,
+ [STRINGID_PKMNPROTECTEDBY - 12] = gUnknown_83FC745,
+ [STRINGID_PKMNPREVENTSUSAGE - 12] = gUnknown_83FC75D,
+ [STRINGID_PKMNRESTOREDHPUSING - 12] = gUnknown_83FC780,
+ [STRINGID_PKMNCHANGEDTYPEWITH - 12] = gUnknown_83FC7B6,
+ [STRINGID_PKMNPREVENTSPARALYSISWITH - 12] = gUnknown_83FC7D3,
+ [STRINGID_PKMNPREVENTSROMANCEWITH - 12] = gUnknown_83FC7EF,
+ [STRINGID_PKMNPREVENTSPOISONINGWITH - 12] = gUnknown_83FC809,
+ [STRINGID_PKMNPREVENTSCONFUSIONWITH - 12] = gUnknown_83FC825,
+ [STRINGID_PKMNRAISEDFIREPOWERWITH - 12] = gUnknown_83FC841,
+ [STRINGID_PKMNANCHORSITSELFWITH - 12] = gUnknown_83FC860,
+ [STRINGID_PKMNCUTSATTACKWITH - 12] = gUnknown_83FC87B,
+ [STRINGID_PKMNPREVENTSSTATLOSSWITH - 12] = gUnknown_83FC895,
+ [STRINGID_PKMNHURTSWITH - 12] = gUnknown_83FC8B1,
+ [STRINGID_PKMNTRACED - 12] = gUnknown_83FC8C2,
+ [STRINGID_STATSHARPLY - 12] = gUnknown_83FCB41,
+ [STRINGID_STATROSE - 12] = gBattleText_Rose,
+ [STRINGID_STATHARSHLY - 12] = gUnknown_83FCB50,
+ [STRINGID_STATFELL - 12] = gUnknown_83FCB59,
+ [STRINGID_PKMNSSTATCHANGED - 12] = gUnknown_83FCB5F,
+ [STRINGID_PKMNSSTATCHANGED2 - 12] = gBattleText_UnknownString3,
+ [STRINGID_PKMNSSTATCHANGED3 - 12] = gUnknown_83FCB8F,
+ [STRINGID_PKMNSSTATCHANGED4 - 12] = gUnknown_83FCB9A,
+ [STRINGID_CRITICALHIT - 12] = gUnknown_83FCBE4,
+ [STRINGID_ONEHITKO - 12] = gUnknown_83FCBF4,
+ [STRINGID_123POOF - 12] = gUnknown_83FCC07,
+ [STRINGID_ANDELLIPSIS - 12] = gUnknown_83FCC33,
+ [STRINGID_NOTVERYEFFECTIVE - 12] = gUnknown_83FCC5B,
+ [STRINGID_SUPEREFFECTIVE - 12] = gUnknown_83FCC74,
+ [STRINGID_GOTAWAYSAFELY - 12] = sText_GotAwaySafely,
+ [STRINGID_WILDPKMNFLED - 12] = gUnknown_83FCCD2,
+ [STRINGID_NORUNNINGFROMTRAINERS - 12] = gUnknown_83FCDB3,
+ [STRINGID_CANTESCAPE - 12] = gUnknown_83FCDE2,
+ [STRINGID_DONTLEAVEBIRCH - 12] = gUnknown_83FCDF1,
+ [STRINGID_BUTNOTHINGHAPPENED - 12] = gUnknown_83FCDF2,
+ [STRINGID_BUTITFAILED - 12] = gUnknown_83FCE08,
+ [STRINGID_ITHURTCONFUSION - 12] = gUnknown_83FCE17,
+ [STRINGID_MIRRORMOVEFAILED - 12] = gUnknown_83FCE38,
+ [STRINGID_STARTEDTORAIN - 12] = gUnknown_83FCE50,
+ [STRINGID_DOWNPOURSTARTED - 12] = gUnknown_83FCE64,
+ [STRINGID_RAINCONTINUES - 12] = gUnknown_83FCE78,
+ [STRINGID_DOWNPOURCONTINUES - 12] = gUnknown_83FCE90,
+ [STRINGID_RAINSTOPPED - 12] = gUnknown_83FCEA8,
+ [STRINGID_SANDSTORMBREWED - 12] = gUnknown_83FCEBA,
+ [STRINGID_SANDSTORMRAGES - 12] = gUnknown_83FCECE,
+ [STRINGID_SANDSTORMSUBSIDED - 12] = gUnknown_83FCEE3,
+ [STRINGID_SUNLIGHTGOTBRIGHT - 12] = gUnknown_83FCEFB,
+ [STRINGID_SUNLIGHTSTRONG - 12] = gUnknown_83FCF14,
+ [STRINGID_SUNLIGHTFADED - 12] = gUnknown_83FCF2C,
+ [STRINGID_STARTEDHAIL - 12] = gUnknown_83FCF40,
+ [STRINGID_HAILCONTINUES - 12] = gUnknown_83FCF54,
+ [STRINGID_HAILSTOPPED - 12] = gUnknown_83FCF6C,
+ [STRINGID_FAILEDTOSPITUP - 12] = gUnknown_83FCF7E,
+ [STRINGID_FAILEDTOSWALLOW - 12] = gUnknown_83FCFA0,
+ [STRINGID_WINDBECAMEHEATWAVE - 12] = gUnknown_83FCFC2,
+ [STRINGID_STATCHANGESGONE - 12] = gUnknown_83FCFE4,
+ [STRINGID_COINSSCATTERED - 12] = gUnknown_83FD006,
+ [STRINGID_TOOWEAKFORSUBSTITUTE - 12] = gUnknown_83FD022,
+ [STRINGID_SHAREDPAIN - 12] = gUnknown_83FD048,
+ [STRINGID_BELLCHIMED - 12] = gUnknown_83FD068,
+ [STRINGID_FAINTINTHREE - 12] = gUnknown_83FD077,
+ [STRINGID_NOPPLEFT - 12] = gUnknown_83FD0A7,
+ [STRINGID_BUTNOPPLEFT - 12] = gUnknown_83FD0CA,
+ [STRINGID_PLAYERUSEDITEM - 12] = sText_PlayerUsedItem,
+ [STRINGID_OLDMANUSEDITEM - 12] = sText_OldManUsedItem,
+ [STRINGID_TRAINERBLOCKEDBALL - 12] = sText_TrainerBlockedBall,
+ [STRINGID_DONTBEATHIEF - 12] = sText_DontBeAThief,
+ [STRINGID_ITDODGEDBALL - 12] = sText_ItDodgedBall,
+ [STRINGID_YOUMISSEDPKMN - 12] = sText_YouMissedPkmn,
+ [STRINGID_PKMNBROKEFREE - 12] = sText_PkmnBrokeFree,
+ [STRINGID_ITAPPEAREDCAUGHT - 12] = sText_ItAppearedCaught,
+ [STRINGID_AARGHALMOSTHADIT - 12] = sText_AarghAlmostHadIt,
+ [STRINGID_SHOOTSOCLOSE - 12] = sText_ShootSoClose,
+ [STRINGID_GOTCHAPKMNCAUGHT - 12] = sText_GotchaPkmnCaught,
+ [STRINGID_GOTCHAPKMNCAUGHT2 - 12] = sText_GotchaPkmnCaught2,
+ [STRINGID_GIVENICKNAMECAPTURED - 12] = sText_GiveNicknameCaptured,
+ [STRINGID_PKMNSENTTOPC - 12] = sText_PkmnSentToPC,
+ [STRINGID_PKMNDATAADDEDTODEX - 12] = gUnknown_83FD82B,
+ [STRINGID_ITISRAINING - 12] = gUnknown_83FD850,
+ [STRINGID_SANDSTORMISRAGING - 12] = gUnknown_83FD85F,
+ [STRINGID_CANTESCAPE2 - 12] = gUnknown_83FB525,
+ [STRINGID_PKMNIGNORESASLEEP - 12] = gUnknown_83FD0F1,
+ [STRINGID_PKMNIGNOREDORDERS - 12] = gUnknown_83FD111,
+ [STRINGID_PKMNBEGANTONAP - 12] = gUnknown_83FD124,
+ [STRINGID_PKMNLOAFING - 12] = gUnknown_83FD135,
+ [STRINGID_PKMNWONTOBEY - 12] = gUnknown_83FD14B,
+ [STRINGID_PKMNTURNEDAWAY - 12] = gUnknown_83FD15A,
+ [STRINGID_PKMNPRETENDNOTNOTICE - 12] = gUnknown_83FD16A,
+ [STRINGID_ENEMYABOUTTOSWITCHPKMN - 12] = gUnknown_83FD186,
+ [STRINGID_THREWROCK - 12] = gUnknown_83FD1DF,
+ [STRINGID_THREWBAIT - 12] = gUnknown_83FD1FA,
+ [STRINGID_PKMNWATCHINGCAREFULLY - 12] = gUnknown_83FD218,
+ [STRINGID_PKMNANGRY - 12] = gUnknown_83FD232,
+ [STRINGID_PKMNEATING - 12] = gUnknown_83FD23F,
+ [STRINGID_DUMMY288 - 12] = gUnknown_83FB218,
+ [STRINGID_DUMMY289 - 12] = gUnknown_83FB218,
+ [STRINGID_OUTOFSAFARIBALLS - 12] = gUnknown_83FD24D,
+ [STRINGID_PKMNSITEMCUREDPARALYSIS - 12] = gUnknown_83FD8B9,
+ [STRINGID_PKMNSITEMCUREDPOISON - 12] = gUnknown_83FD8D2,
+ [STRINGID_PKMNSITEMHEALEDBURN - 12] = gUnknown_83FD8E8,
+ [STRINGID_PKMNSITEMDEFROSTEDIT - 12] = gUnknown_83FD901,
+ [STRINGID_PKMNSITEMWOKEIT - 12] = gUnknown_83FD917,
+ [STRINGID_PKMNSITEMSNAPPEDOUT - 12] = gUnknown_83FD937,
+ [STRINGID_PKMNSITEMCUREDPROBLEM - 12] = gUnknown_83FD95C,
+ [STRINGID_PKMNSITEMRESTOREDHEALTH - 12] = gUnknown_83FD999,
+ [STRINGID_PKMNSITEMRESTOREDPP - 12] = gUnknown_83FD9B2,
+ [STRINGID_PKMNSITEMRESTOREDSTATUS - 12] = gUnknown_83FD9CC,
+ [STRINGID_PKMNSITEMRESTOREDHPALITTLE - 12] = gUnknown_83FD9E9,
+ [STRINGID_ITEMALLOWSONLYYMOVE - 12] = gUnknown_83FDA0B,
+ [STRINGID_PKMNHUNGONWITHX - 12] = gUnknown_83FDA33,
+ [STRINGID_EMPTYSTRING3 - 12] = gUnknown_83FDA4C,
+ [STRINGID_PKMNSXPREVENTSBURNS - 12] = gUnknown_83FC8D5,
+ [STRINGID_PKMNSXBLOCKSY - 12] = gUnknown_83FC8ED,
+ [STRINGID_PKMNSXRESTOREDHPALITTLE2 - 12] = gUnknown_83FC913,
+ [STRINGID_PKMNSXWHIPPEDUPSANDSTORM - 12] = gUnknown_83FC935,
+ [STRINGID_PKMNSXPREVENTSYLOSS - 12] = gUnknown_83FC979,
+ [STRINGID_PKMNSXINFATUATEDY - 12] = gUnknown_83FC993,
+ [STRINGID_PKMNSXMADEYINEFFECTIVE - 12] = gUnknown_83FC9AA,
+ [STRINGID_PKMNSXCUREDYPROBLEM - 12] = gUnknown_83FC9C7,
+ [STRINGID_ITSUCKEDLIQUIDOOZE - 12] = gUnknown_83FC9E5,
+ [STRINGID_PKMNTRANSFORMED - 12] = gUnknown_83FCA03,
+ [STRINGID_ELECTRICITYWEAKENED - 12] = gUnknown_83FC554,
+ [STRINGID_FIREWEAKENED - 12] = gUnknown_83FC576,
+ [STRINGID_PKMNHIDUNDERWATER - 12] = gUnknown_83FBAD2,
+ [STRINGID_PKMNSPRANGUP - 12] = gUnknown_83FBAE5,
+ [STRINGID_HMMOVESCANTBEFORGOTTEN - 12] = gUnknown_83FCC39,
+ [STRINGID_XFOUNDONEY - 12] = gUnknown_83FC591,
+ [STRINGID_PLAYERDEFEATEDTRAINER1 - 12] = sText_PlayerDefeatedLinkTrainerTrainer1,
+ [STRINGID_SOOTHINGAROMA - 12] = gUnknown_83FC5A2,
+ [STRINGID_ITEMSCANTBEUSEDNOW - 12] = gUnknown_83FC5CC,
+ [STRINGID_FORXCOMMAYZ - 12] = gUnknown_83FC5E8,
+ [STRINGID_USINGXTHEYOFZN - 12] = gUnknown_83FCB75,
+ [STRINGID_PKMNUSEDXTOGETPUMPED - 12] = gUnknown_83FC5F6,
+ [STRINGID_PKMNSXMADEYUSELESS - 12] = gUnknown_83FC79D,
+ [STRINGID_PKMNTRAPPEDBYSANDTOMB - 12] = gUnknown_83FBB2F,
+ [STRINGID_EMPTYSTRING4 - 12] = gUnknown_83FB282,
+ [STRINGID_ABOOSTED - 12] = gUnknown_83FB283,
+ [STRINGID_PKMNSXINTENSIFIEDSUN - 12] = gUnknown_83FC955,
+ [STRINGID_PKMNMAKESGROUNDMISS - 12] = gUnknown_83FB3AF,
+ [STRINGID_YOUTHROWABALLNOWRIGHT - 12] = gUnknown_83FDAB1,
+ [STRINGID_PKMNSXTOOKATTACK - 12] = gUnknown_83FCA13,
+ [STRINGID_PKMNCHOSEXASDESTINY - 12] = gUnknown_83FC208,
+ [STRINGID_PKMNLOSTFOCUS - 12] = gUnknown_83FC60C,
+ [STRINGID_USENEXTPKMN - 12] = gUnknown_83FB359,
+ [STRINGID_PKMNFLEDUSINGITS - 12] = gUnknown_83FCCA0,
+ [STRINGID_PKMNFLEDUSING - 12] = gUnknown_83FCCBB,
+ [STRINGID_PKMNWASDRAGGEDOUT - 12] = gUnknown_83FC631,
+ [STRINGID_PREVENTEDFROMWORKING - 12] = gUnknown_83FCA49,
+ [STRINGID_PKMNSITEMNORMALIZEDSTATUS - 12] = gUnknown_83FD97A,
+ [STRINGID_TRAINER1USEDITEM - 12] = sText_Trainer1UsedItem,
+ [STRINGID_BOXISFULL - 12] = gUnknown_83FD876,
+ [STRINGID_PKMNAVOIDEDATTACK - 12] = gUnknown_83FB3D3,
+ [STRINGID_PKMNSXMADEITINEFFECTIVE - 12] = gUnknown_83FCA71,
+ [STRINGID_PKMNSXPREVENTSFLINCHING - 12] = gUnknown_83FCA8E,
+ [STRINGID_PKMNALREADYHASBURN - 12] = gUnknown_83FB67B,
+ [STRINGID_STATSWONTDECREASE2 - 12] = gUnknown_83FCBC5,
+ [STRINGID_PKMNSXBLOCKSY2 - 12] = gUnknown_83FC900,
+ [STRINGID_PKMNSXWOREOFF - 12] = gUnknown_83FBC62,
+ [STRINGID_PKMNRAISEDDEFALITTLE - 12] = gUnknown_83FB997,
+ [STRINGID_PKMNRAISEDSPDEFALITTLE - 12] = gUnknown_83FB95E,
+ [STRINGID_THEWALLSHATTERED - 12] = gUnknown_83FC646,
+ [STRINGID_PKMNSXPREVENTSYSZ - 12] = gUnknown_83FCAAA,
+ [STRINGID_PKMNSXCUREDITSYPROBLEM - 12] = gUnknown_83FCAD1,
+ [STRINGID_ATTACKERCANTESCAPE - 12] = gUnknown_83FB534,
+ [STRINGID_PKMNOBTAINEDX - 12] = gUnknown_83FC337,
+ [STRINGID_PKMNOBTAINEDX2 - 12] = gUnknown_83FC347,
+ [STRINGID_PKMNOBTAINEDXYOBTAINEDZ - 12] = gUnknown_83FC357,
+ [STRINGID_BUTNOEFFECT - 12] = gUnknown_83FC65A,
+ [STRINGID_PKMNSXHADNOEFFECTONY - 12] = gUnknown_83FCAEF,
+ [STRINGID_OAKPLAYERWON - 12] = gUnknown_83FDD64,
+ [STRINGID_OAKPLAYERLOST - 12] = gUnknown_83FDDEB,
+ [STRINGID_PLAYERLOSTAGAINSTENEMYTRAINER - 12] = gUnknown_83FB484,
+ [STRINGID_PLAYERPAIDPRIZEMONEY - 12] = gUnknown_83FB4BE,
+ [STRINGID_PKMNTRANSFERREDSOMEONESPC - 12] = Text_MonSentToBoxInSomeonesPC,
+ [STRINGID_PKMNTRANSFERREDBILLSPC - 12] = Text_MonSentToBoxInBillsPC,
+ [STRINGID_PKMNBOXSOMEONESPCFULL - 12] = Text_MonSentToBoxSomeonesBoxFull,
+ [STRINGID_PKMNBOXBILLSPCFULL - 12] = Text_MonSentToBoxBillsBoxFull,
+ [STRINGID_POKEDUDEUSED - 12] = sText_PokedudeUsedItem,
+ [STRINGID_POKEFLUTECATCHY - 12] = gUnknown_83FDA4D,
+ [STRINGID_POKEFLUTE - 12] = gUnknown_83FDA7A,
+ [STRINGID_MONHEARINGFLUTEAWOKE - 12] = gUnknown_83FDA8C,
+ [STRINGID_TRAINER2CLASS - 12] = gUnknown_83FB21C,
+ [STRINGID_TRAINER2NAME - 12] = gUnknown_83FB262,
+ [STRINGID_PLAYERWHITEDOUT - 12] = gUnknown_83FB4F7,
+ [STRINGID_MONTOOSCAREDTOMOVE - 12] = gUnknown_83FCB0C,
+ [STRINGID_GHOSTGETOUTGETOUT - 12] = gUnknown_83FCB26,
+ [STRINGID_SILPHSCOPEUNVEILED - 12] = gUnknown_83FD322,
+ [STRINGID_GHOSTWASMAROWAK - 12] = gUnknown_83FD34D,
+ [STRINGID_TRAINER1MON1COMEBACK - 12] = gUnknown_83FB21F,
+ [STRINGID_TRAINER1WINTEXT - 12] = gUnknown_83FB232,
+ [STRINGID_TRAINER1MON2COMEBACK - 12] = gUnknown_83FB235,
+ [STRINGID_TRAINER1MON1AND2COMEBACK - 12] = gUnknown_83FB248
};
const u16 gMissStringIds[] = {
diff --git a/src/battle_setup.c b/src/battle_setup.c
index ee923d6c7..b54696247 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -417,7 +417,7 @@ static void CB2_EndWildBattle(void)
else
{
SetMainCallback2(CB2_ReturnToField);
- gFieldCallback = sub_807E3EC;
+ gFieldCallback = FieldCB_SafariZoneRanOutOfBalls;
}
}
@@ -794,13 +794,13 @@ const u8 *BattleSetup_ConfigureTrainerBattle(const u8 *data)
SetMapVarsToTrainer();
return EventScript_TryDoDoubleTrainerBattle;
case TRAINER_BATTLE_REMATCH_DOUBLE:
- sub_811231C();
+ FinishRecordingQuestLogScene();
TrainerBattleLoadArgs(sDoubleBattleParams, data);
SetMapVarsToTrainer();
gTrainerBattleOpponent_A = GetRematchTrainerId(gTrainerBattleOpponent_A);
return EventScript_TryDoDoubleRematchBattle;
case TRAINER_BATTLE_REMATCH:
- sub_811231C();
+ FinishRecordingQuestLogScene();
TrainerBattleLoadArgs(sOrdinaryBattleParams, data);
SetMapVarsToTrainer();
gTrainerBattleOpponent_A = GetRematchTrainerId(gTrainerBattleOpponent_A);
@@ -951,8 +951,8 @@ static void CB2_EndRematchBattle(void)
{
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
SetBattledTrainerFlag();
- sub_810CDE8();
- sub_81138F8();
+ ClearRematchStateOfLastTalked();
+ ResetDeferredLinkEvent();
}
}
@@ -994,8 +994,7 @@ void PlayTrainerEncounterMusic(void)
{
u16 music;
- if (gQuestLogState != 2
- && gQuestLogState != 3
+ if (!QL_IS_PLAYBACK_STATE
&& sTrainerBattleMode != TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC
&& sTrainerBattleMode != TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC)
{
diff --git a/src/cable_club.c b/src/cable_club.c
index 52856e3a3..73fa82d42 100644
--- a/src/cable_club.c
+++ b/src/cable_club.c
@@ -173,7 +173,7 @@ static void sub_80809C4(u8 taskId)
gTasks[taskId].data[0]++;
if (gTasks[taskId].data[0] == 10)
{
- sub_800A474(2);
+ Link_PrepareCmd0xCCCC_Rfu0xA100(2);
DestroyTask(taskId);
}
}
@@ -369,7 +369,7 @@ static void Task_LinkupMaster_6(u8 taskId)
sub_800A900(gFieldLinkPlayerCount);
TrainerCard_GenerateCardForLinkPlayer((void*)gBlockSendBuffer);
gTasks[taskId].func = Task_Linkup_6a;
- sub_800A474(2);
+ Link_PrepareCmd0xCCCC_Rfu0xA100(2);
}
}
}
@@ -532,7 +532,7 @@ static void Task_ReestablishLinkInCableClubRoom_0(u8 taskId)
{
OpenLink();
ResetLinkPlayers();
- CreateTask(sub_8081A90, 80);
+ CreateTask(Task_WaitForReceivedRemoteLinkPlayers5SecondTimeout, 80);
}
else if (data[0] > 9)
gTasks[taskId].func = Task_ReestablishLinkInCableClubRoom_1;
@@ -934,7 +934,7 @@ bool32 GetSeeingLinkPlayerCardMsg(u8 who)
return TRUE;
}
-void sub_8081A90(u8 taskId)
+void Task_WaitForReceivedRemoteLinkPlayers5SecondTimeout(u8 taskId)
{
struct Task * task = &gTasks[taskId];
task->data[0]++;
diff --git a/src/cereader_tool.c b/src/cereader_tool.c
index c6e0c9a99..cb8c48f7a 100644
--- a/src/cereader_tool.c
+++ b/src/cereader_tool.c
@@ -1,7 +1,7 @@
#include "global.h"
+#include "gflib.h"
#include "util.h"
#include "save.h"
-#include "malloc.h"
#include "cereader_tool.h"
u8 sub_815D654(void)
diff --git a/src/coins.c b/src/coins.c
index fd5000fbd..1b9c610c5 100644
--- a/src/coins.c
+++ b/src/coins.c
@@ -1,6 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "string_util.h"
-#include "text.h"
#include "menu.h"
#include "text_window.h"
#include "strings.h"
diff --git a/src/credits.c b/src/credits.c
index dfcdfb418..3be5c8fa5 100644
--- a/src/credits.c
+++ b/src/credits.c
@@ -1,19 +1,14 @@
#include "global.h"
-#include "malloc.h"
-#include "bg.h"
+#include "gflib.h"
#include "credits.h"
-#include "palette.h"
-#include "gpu_regs.h"
#include "task.h"
#include "overworld.h"
#include "event_data.h"
-#include "window.h"
#include "new_menu_helpers.h"
#include "decompress.h"
#include "graphics.h"
#include "strings.h"
#include "trainer_pokemon_sprites.h"
-#include "sound.h"
#include "constants/species.h"
#include "constants/maps.h"
#include "constants/field_weather.h"
diff --git a/src/dark.c b/src/dark.c
index e13227316..d2e0996bd 100644
--- a/src/dark.c
+++ b/src/dark.c
@@ -1,8 +1,7 @@
#include "global.h"
+#include "gflib.h"
#include "battle_anim.h"
-#include "gpu_regs.h"
#include "graphics.h"
-#include "palette.h"
#include "scanline_effect.h"
#include "trig.h"
#include "util.h"
diff --git a/src/data.c b/src/data.c
index 891c9f94f..54c67c875 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "battle.h"
#include "data.h"
#include "graphics.h"
diff --git a/src/decompress.c b/src/decompress.c
index 3f0c82bce..3e32f00eb 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "decompress.h"
#include "pokemon.h"
#include "constants/species.h"
diff --git a/src/digit_obj_util.c b/src/digit_obj_util.c
index 82af5dcab..852c386ac 100644
--- a/src/digit_obj_util.c
+++ b/src/digit_obj_util.c
@@ -1,8 +1,7 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "decompress.h"
#include "digit_obj_util.h"
-#include "main.h"
struct DigitPrinterAlloc
{
diff --git a/src/diploma.c b/src/diploma.c
index 5c653d071..c43eff105 100644
--- a/src/diploma.c
+++ b/src/diploma.c
@@ -1,23 +1,14 @@
#include "global.h"
-#include "bg.h"
-#include "constants/fanfares.h"
+#include "gflib.h"
#include "dynamic_placeholder_text_util.h"
-#include "gba/macro.h"
-#include "gpu_regs.h"
-#include "main.h"
-#include "malloc.h"
#include "menu.h"
#include "new_menu_helpers.h"
#include "overworld.h"
-#include "palette.h"
#include "pokedex.h"
#include "scanline_effect.h"
-#include "sound.h"
-#include "sprite.h"
#include "strings.h"
#include "task.h"
-#include "text.h"
-#include "window.h"
+#include "constants/fanfares.h"
struct Diploma
{
@@ -193,7 +184,7 @@ static void Task_DiplomaReturnToOverworld(u8 taskId)
DestroyTask(taskId);
FreeAllWindowBuffers();
FREE_AND_SET_NULL(gDiploma);
- SetMainCallback2(sub_80568FC);
+ SetMainCallback2(CB2_ReturnToFieldFromDiploma);
}
static void DiplomaBgInit(void)
diff --git a/src/dynamic_placeholder_text_util.c b/src/dynamic_placeholder_text_util.c
index 174a1c5d5..eede1ae48 100644
--- a/src/dynamic_placeholder_text_util.c
+++ b/src/dynamic_placeholder_text_util.c
@@ -1,6 +1,5 @@
#include "global.h"
-#include "text.h"
-#include "string_util.h"
+#include "gflib.h"
#include "constants/event_objects.h"
static EWRAM_DATA const u8 *sStringPointers[8] = {0};
diff --git a/src/easy_chat.c b/src/easy_chat.c
index 657d178d7..c34ace10d 100644
--- a/src/easy_chat.c
+++ b/src/easy_chat.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "data.h"
#include "easy_chat.h"
#include "event_data.h"
@@ -9,7 +9,6 @@
#include "mail.h"
#include "pokedex.h"
#include "random.h"
-#include "string_util.h"
#include "strings.h"
#include "constants/easy_chat.h"
#include "constants/flags.h"
diff --git a/src/event_data.c b/src/event_data.c
index c012a4a59..6cd6f277b 100644
--- a/src/event_data.c
+++ b/src/event_data.c
@@ -179,7 +179,7 @@ u16 *GetVarPointer(u16 idx)
return NULL;
if (idx < SPECIAL_VARS_START)
{
- switch (gUnknown_3005E88)
+ switch (gQuestLogPlaybackState)
{
case 0:
default:
@@ -250,7 +250,7 @@ u8 *GetFlagAddr(u16 idx)
return NULL;
if (idx < SPECIAL_FLAGS_START)
{
- switch (gUnknown_3005E88)
+ switch (gQuestLogPlaybackState)
{
case 0:
default:
diff --git a/src/event_object_lock.c b/src/event_object_lock.c
index aa9a99895..c578905f3 100644
--- a/src/event_object_lock.c
+++ b/src/event_object_lock.c
@@ -4,6 +4,7 @@
#include "event_object_movement.h"
#include "script_movement.h"
#include "event_data.h"
+#include "constants/event_objects.h"
bool8 walkrun_is_standing_still(void)
{
@@ -13,18 +14,18 @@ bool8 walkrun_is_standing_still(void)
return TRUE;
}
-void sub_8069570(u8 taskId)
+void Task_WaitPlayerStopMoving(u8 taskId)
{
if (walkrun_is_standing_still())
{
- sub_805C270();
+ HandleEnforcedLookDirectionOnPlayerStopMoving();
DestroyTask(taskId);
}
}
-bool8 sub_8069590(void)
+bool8 NativeScript_WaitPlayerStopMoving(void)
{
- if (FuncIsActiveTask(sub_8069570))
+ if (FuncIsActiveTask(Task_WaitPlayerStopMoving))
return FALSE;
else
{
@@ -36,16 +37,16 @@ bool8 sub_8069590(void)
void ScriptFreezeObjectEvents(void)
{
FreezeObjectEvents();
- CreateTask(sub_8069570, 80);
+ CreateTask(Task_WaitPlayerStopMoving, 80);
}
-void sub_80695CC(u8 taskId)
+void Task_WaitPlayerAndTargetNPCStopMoving(u8 taskId)
{
struct Task * task = &gTasks[taskId];
if (task->data[0] == 0 && walkrun_is_standing_still() == TRUE)
{
- sub_805C270();
+ HandleEnforcedLookDirectionOnPlayerStopMoving();
task->data[0] = 1;
}
@@ -59,9 +60,9 @@ void sub_80695CC(u8 taskId)
DestroyTask(taskId);
}
-bool8 sub_8069648(void)
+bool8 NativeScript_WaitPlayerAndTargetNPCStopMoving(void)
{
- if (FuncIsActiveTask(sub_80695CC))
+ if (FuncIsActiveTask(Task_WaitPlayerAndTargetNPCStopMoving))
return FALSE;
else
{
@@ -75,7 +76,7 @@ void LockSelectedObjectEvent(void)
u8 taskId;
FreezeObjectEventsExceptOne(gSelectedObjectEvent);
- taskId = CreateTask(sub_80695CC, 80);
+ taskId = CreateTask(Task_WaitPlayerAndTargetNPCStopMoving, 80);
if (!gObjectEvents[gSelectedObjectEvent].singleMovementActive)
{
FreezeObjectEvent(&gObjectEvents[gSelectedObjectEvent]);
@@ -83,9 +84,9 @@ void LockSelectedObjectEvent(void)
}
}
-void sub_80696C0(void)
+void ClearPlayerHeldMovementAndUnfreezeObjectEvents(void)
{
- u8 objectEventId = GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0);
+ u8 objectEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[objectEventId]);
ScriptMovement_UnfreezeObjectEvents();
UnfreezeObjectEvents();
@@ -96,7 +97,7 @@ void UnionRoom_UnlockPlayerAndChatPartner(void)
u8 objectEventId;
if (gObjectEvents[gSelectedObjectEvent].active)
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[gSelectedObjectEvent]);
- objectEventId = GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0);
+ objectEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[objectEventId]);
ScriptMovement_UnfreezeObjectEvents();
UnfreezeObjectEvents();
diff --git a/src/event_object_movement.c b/src/event_object_movement.c
index 5361d05dc..72ce58bb5 100644
--- a/src/event_object_movement.c
+++ b/src/event_object_movement.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "event_data.h"
#include "event_object_movement.h"
#include "field_camera.h"
@@ -10,7 +10,6 @@
#include "fieldmap.h"
#include "metatile_behavior.h"
#include "overworld.h"
-#include "palette.h"
#include "quest_log.h"
#include "random.h"
#include "script.h"
@@ -2805,7 +2804,7 @@ u8 sub_805FC9C(u8 localId, u8 mapNum, u8 mapGroup)
return gObjectEvents[objectEventId].trainerType;
}
-u16 sub_805FCD8(u8 localId, u8 mapNum, u8 mapGroup)
+u16 GetObjectEventFlagByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
{
return GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->trainerType;
}
@@ -5530,7 +5529,7 @@ static void sub_8064544(struct ObjectEvent *objectEvent, struct Sprite *sprite)
{
objectEvent->heldMovementFinished = TRUE;
if (objectEvent->graphicsId == 0x61)
- sub_806DE28(objectEvent);
+ HandleBoulderFallThroughHole(objectEvent);
}
}
@@ -5550,7 +5549,7 @@ static void ObjectEventSetSingleMovement(struct ObjectEvent *objectEvent, struct
objectEvent->movementActionId = animId;
sprite->data[2] = 0;
- if (gUnknown_3005E88 == 2)
+ if (gQuestLogPlaybackState == 2)
{
sub_81124EC(objectEvent->localId, objectEvent->mapNum, objectEvent->mapGroup, animId);
}
diff --git a/src/evolution_graphics.c b/src/evolution_graphics.c
index 622b26f8f..d9c9317bd 100644
--- a/src/evolution_graphics.c
+++ b/src/evolution_graphics.c
@@ -1,9 +1,8 @@
#include "global.h"
+#include "gflib.h"
#include "trig.h"
#include "random.h"
#include "decompress.h"
-#include "palette.h"
-#include "sound.h"
#include "task.h"
#include "evolution_scene.h"
#include "evolution_graphics.h"
diff --git a/src/evolution_scene.c b/src/evolution_scene.c
index 71eb3fc36..caa19a7a5 100644
--- a/src/evolution_scene.c
+++ b/src/evolution_scene.c
@@ -1,34 +1,25 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "battle.h"
#include "battle_message.h"
-#include "bg.h"
#include "data.h"
#include "decompress.h"
#include "help_system.h"
#include "evolution_scene.h"
#include "evolution_graphics.h"
-#include "gpu_regs.h"
#include "link.h"
#include "link_rfu.h"
#include "m4a.h"
#include "event_data.h"
#include "trade_scene.h"
-#include "main.h"
#include "new_menu_helpers.h"
#include "menu.h"
#include "overworld.h"
-#include "palette.h"
#include "pokedex.h"
-#include "pokemon.h"
#include "pokemon_summary_screen.h"
#include "scanline_effect.h"
-#include "sound.h"
-#include "sprite.h"
-#include "string_util.h"
#include "strings.h"
#include "task.h"
-#include "text.h"
#include "text_window.h"
#include "trig.h"
#include "battle_string_ids.h"
diff --git a/src/fame_checker.c b/src/fame_checker.c
index dbdb47da8..cccdbf604 100644
--- a/src/fame_checker.c
+++ b/src/fame_checker.c
@@ -1,7 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "constants/songs.h"
-#include "sprite.h"
-#include "bg.h"
#include "event_data.h"
#include "event_scripts.h"
#include "graphics.h"
@@ -13,15 +12,7 @@
#include "new_menu_helpers.h"
#include "item_menu.h"
#include "list_menu.h"
-#include "gpu_regs.h"
-#include "palette.h"
#include "task.h"
-#include "malloc.h"
-#include "main.h"
-#include "sound.h"
-#include "text.h"
-#include "window.h"
-#include "string_util.h"
#include "event_object_movement.h"
#include "menu_indicators.h"
#include "text_window.h"
diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c
index 286f7519a..694ef0392 100644
--- a/src/field_control_avatar.c
+++ b/src/field_control_avatar.c
@@ -107,7 +107,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
{
if ((newKeys & START_BUTTON) && !(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FISHING))
input->pressedStartButton = TRUE;
- if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3)
+ if (!QL_IS_PLAYBACK_STATE)
{
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FISHING))
{
@@ -123,7 +123,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
}
}
- if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3)
+ if (!QL_IS_PLAYBACK_STATE)
{
if (heldKeys & (DPAD_UP | DPAD_DOWN | DPAD_LEFT | DPAD_RIGHT))
{
@@ -142,7 +142,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
input->checkStandardWildEncounter = TRUE;
}
- if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3)
+ if (!QL_IS_PLAYBACK_STATE)
{
if (heldKeys & DPAD_UP)
input->dpadDirection = DIR_NORTH;
@@ -650,7 +650,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
{
if (InUnionRoom() == TRUE)
return FALSE;
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
return FALSE;
UpdateHappinessStepCounter();
@@ -836,17 +836,17 @@ static bool8 TryArrowWarp(struct MapPosition *position, u16 metatileBehavior, u8
DoWarp();
return TRUE;
}
- else if (sub_806DB84(metatileBehavior, direction) == TRUE)
+ else if (IsDirectionalStairWarpMetatileBehavior(metatileBehavior, direction) == TRUE)
{
delay = 0;
if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
{
- SetPlayerAvatarTransitionFlags(1);
+ SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
delay = 12;
}
StoreInitialPlayerAvatarState();
SetupWarp(&gMapHeader, warpEventId, position);
- sub_807E4A0(metatileBehavior, delay);
+ DoStairWarp(metatileBehavior, delay);
return TRUE;
}
}
@@ -921,20 +921,20 @@ static bool8 IsWarpMetatileBehavior(u16 metatileBehavior)
return FALSE;
}
-bool8 sub_806DB84(u16 metatileBehavior, u8 playerDirection)
+bool8 IsDirectionalStairWarpMetatileBehavior(u16 metatileBehavior, u8 playerDirection)
{
switch (playerDirection)
{
case DIR_WEST:
- if (MetatileBehavior_IsUnknownWarp6D(metatileBehavior))
+ if (MetatileBehavior_IsDirectionalUpLeftStairWarp(metatileBehavior))
return TRUE;
- if (MetatileBehavior_IsUnknownWarp6F(metatileBehavior))
+ if (MetatileBehavior_IsDirectionalDownLeftStairWarp(metatileBehavior))
return TRUE;
break;
case DIR_EAST:
- if (MetatileBehavior_IsUnknownWarp6C(metatileBehavior))
+ if (MetatileBehavior_IsDirectionalUpRightStairWarp(metatileBehavior))
return TRUE;
- if (MetatileBehavior_IsUnknownWarp6E(metatileBehavior))
+ if (MetatileBehavior_IsDirectionalDownRightStairWarp(metatileBehavior))
return TRUE;
break;
}
@@ -1063,18 +1063,17 @@ static const u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16
return NULL;
}
-void sub_806DE28(struct ObjectEvent * object)
+void HandleBoulderFallThroughHole(struct ObjectEvent * object)
{
if (MapGridGetMetatileBehaviorAt(object->currentCoords.x, object->currentCoords.y) == MB_FALL_WARP)
{
PlaySE(SE_RU_HYUU);
- // w-why?!
RemoveObjectEventByLocalIdAndMap(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
- FlagClear(sub_805FCD8(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup));
+ FlagClear(GetObjectEventFlagByLocalIdAndMap(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup));
}
}
-void sub_806DE70(u16 x, u16 y)
+void HandleBoulderActivateVictoryRoadSwitch(u16 x, u16 y)
{
int i;
const struct CoordEvent * events = gMapHeader.events->coordEvents;
@@ -1086,7 +1085,7 @@ void sub_806DE70(u16 x, u16 y)
{
if (events[i].x + 7 == x && events[i].y + 7 == y)
{
- QuestLog_OnInteractionWithSpecialNpc();
+ QuestLog_CutRecording();
ScriptContext1_SetupScript(events[i].script);
ScriptContext2_Enable();
}
diff --git a/src/field_effect.c b/src/field_effect.c
index b8269ae46..b89e9c116 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -1105,7 +1105,7 @@ void FieldCB_FallWarpExit(void)
{
Overworld_PlaySpecialMapMusic();
WarpFadeInScreen();
- sub_8111CF0();
+ QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
ScriptContext2_Enable();
FreezeObjectEvents();
CreateTask(Task_FallWarpFieldEffect, 0);
@@ -1409,7 +1409,7 @@ static void FieldCB_EscalatorWarpIn(void)
{
Overworld_PlaySpecialMapMusic();
WarpFadeInScreen();
- sub_8111CF0();
+ QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
ScriptContext2_Enable();
FreezeObjectEvents();
CreateTask(Task_EscalatorWarpInFieldEffect, 0);
@@ -1819,7 +1819,7 @@ static void FieldCB_LavaridgeGymB1FWarpExit(void)
{
Overworld_PlaySpecialMapMusic();
WarpFadeInScreen();
- sub_8111CF0();
+ QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
ScriptContext2_Enable();
gFieldCallback = NULL;
CreateTask(Task_LavaridgeGymB1FWarpExit, 0);
@@ -2186,7 +2186,7 @@ static void FieldCallback_EscapeRopeExit(void)
{
Overworld_PlaySpecialMapMusic();
WarpFadeInScreen();
- sub_8111CF0();
+ QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
ScriptContext2_Enable();
FreezeObjectEvents();
gFieldCallback = NULL;
@@ -2350,7 +2350,7 @@ static void FieldCallback_TeleportIn(void)
{
Overworld_PlaySpecialMapMusic();
WarpFadeInScreen();
- sub_8111CF0();
+ QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
ScriptContext2_Enable();
FreezeObjectEvents();
gFieldCallback = NULL;
@@ -2984,7 +2984,7 @@ static void (*const sUseVsSeekerEffectFuncs[])(struct Task * task) = {
u32 FldEff_UseVsSeeker(void)
{
- if (gQuestLogState == QL_STATE_1)
+ if (gQuestLogState == QL_STATE_RECORDING)
sub_811278C(8, 89);
CreateTask(Task_FldEffUseVsSeeker, 0xFF);
return 0;
diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c
index 06d48fce0..d259775ef 100644
--- a/src/field_effect_helpers.c
+++ b/src/field_effect_helpers.c
@@ -1,12 +1,11 @@
#include "global.h"
+#include "gflib.h"
#include "event_object_movement.h"
#include "field_camera.h"
#include "field_effect.h"
#include "field_weather.h"
#include "fieldmap.h"
#include "metatile_behavior.h"
-#include "sound.h"
-#include "sprite.h"
#include "constants/field_effects.h"
#include "constants/songs.h"
diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c
index bf5ab0ab3..478c89bad 100644
--- a/src/field_fadetransition.c
+++ b/src/field_fadetransition.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "palette.h"
+#include "gflib.h"
#include "field_fadetransition.h"
#include "overworld.h"
#include "fldeff.h"
@@ -14,7 +14,6 @@
#include "quest_log.h"
#include "link.h"
#include "event_object_movement.h"
-#include "sound.h"
#include "field_door.h"
#include "field_effect.h"
#include "field_screen_effect.h"
@@ -23,6 +22,7 @@
#include "start_menu.h"
#include "constants/songs.h"
#include "constants/event_object_movement.h"
+#include "constants/event_objects.h"
#include "constants/field_weather.h"
static void sub_807DF4C(u8 a0);
@@ -30,10 +30,10 @@ static void sub_807DFBC(u8 taskId);
static void task_map_chg_seq_0807E20C(u8 taskId);
static void task_map_chg_seq_0807E2CC(u8 taskId);
static void Task_TeleportWarpIn(u8 taskId);
-static void sub_807E718(u8 taskId);
+static void Task_Teleport2Warp(u8 taskId);
static void Task_TeleportWarp(u8 taskId);
-static void sub_807E80C(u8 taskId);
-static void sub_807E980(u8 taskId);
+static void Task_DoorWarp(u8 taskId);
+static void Task_StairWarp(u8 taskId);
static void sub_807EB64(u16, s16*, s16*);
static void sub_807EBBC(u8 a0, s16 *a1, s16 *a2);
static void sub_807EAC4(s16, s16, s16*, s16*, s16*);
@@ -262,7 +262,7 @@ static void sub_807DE78(bool8 a0)
sub_807DF4C(a0);
if (MetatileBehavior_IsNonAnimDoor(behavior) == TRUE)
func = task_map_chg_seq_0807E20C;
- else if (MetatileBehavior_IsUnknownWarp6C_to_6F(behavior) == TRUE)
+ else if (MetatileBehavior_IsDirectionalStairWarp(behavior) == TRUE)
{
u8 tmp = gUnknown_2031DE0;
func = task_map_chg_seq_0807E2CC;
@@ -287,7 +287,7 @@ static void sub_807DF4C(bool8 a0)
void FieldCB_DefaultWarpExit(void)
{
Overworld_PlaySpecialMapMusic();
- sub_8111CF0();
+ QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
sub_807DE78(FALSE);
ScriptContext2_Enable();
}
@@ -295,7 +295,7 @@ void FieldCB_DefaultWarpExit(void)
void FieldCB_WarpExitFadeFromBlack(void)
{
Overworld_PlaySpecialMapMusic();
- sub_8111CF0();
+ QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
sub_807DE78(TRUE);
ScriptContext2_Enable();
}
@@ -304,7 +304,7 @@ static void FieldCB_TeleportWarpIn(void)
{
Overworld_PlaySpecialMapMusic();
WarpFadeInScreen();
- sub_8111CF0();
+ QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
PlaySE(SE_TK_WARPOUT);
CreateTask(Task_TeleportWarpIn, 10);
ScriptContext2_Enable();
@@ -350,7 +350,7 @@ static void sub_807DFBC(u8 taskId)
{
PlayerGetDestCoords(&task->data[12], &task->data[13]);
sub_807DCB0(TRUE);
- ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)], MOVEMENT_ACTION_WALK_NORMAL_DOWN);
+ ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0)], MOVEMENT_ACTION_WALK_NORMAL_DOWN);
task->data[0] = 8;
}
break;
@@ -365,7 +365,7 @@ static void sub_807DFBC(u8 taskId)
case 9:
if (FieldFadeTransitionBackgroundEffectIsFinished() && walkrun_is_standing_still() && !FieldIsDoorAnimationRunning() && !FuncIsActiveTask(Task_BarnDoorWipe))
{
- ObjectEventClearHeldMovementIfFinished(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)]);
+ ObjectEventClearHeldMovementIfFinished(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0)]);
task->data[0] = 4;
}
break;
@@ -374,7 +374,7 @@ static void sub_807DFBC(u8 taskId)
if (FieldFadeTransitionBackgroundEffectIsFinished())
{
sub_807DCB0(TRUE);
- ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)], MOVEMENT_ACTION_WALK_NORMAL_DOWN);
+ ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0)], MOVEMENT_ACTION_WALK_NORMAL_DOWN);
task->data[0] = 2;
}
break;
@@ -382,7 +382,7 @@ static void sub_807DFBC(u8 taskId)
if (walkrun_is_standing_still())
{
task->data[1] = FieldAnimateDoorClose(*x, *y);
- ObjectEventClearHeldMovementIfFinished(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)]);
+ ObjectEventClearHeldMovementIfFinished(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0)]);
task->data[0] = 3;
}
break;
@@ -416,7 +416,7 @@ static void task_map_chg_seq_0807E20C(u8 taskId)
if (FieldFadeTransitionBackgroundEffectIsFinished())
{
sub_807DCB0(TRUE);
- ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)], GetWalkNormalMovementAction(GetPlayerFacingDirection()));
+ ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0)], GetWalkNormalMovementAction(GetPlayerFacingDirection()));
task->data[0] = 2;
}
break;
@@ -497,22 +497,22 @@ bool8 FieldCB_ReturnToFieldOpenStartMenu(void)
return FALSE;
}
-static void task_mpl_807E3C8(u8 taskId)
+static void Task_SafariZoneRanOutOfBalls(u8 taskId)
{
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
{
ScriptContext2_Disable();
DestroyTask(taskId);
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
}
}
-void sub_807E3EC(void)
+void FieldCB_SafariZoneRanOutOfBalls(void)
{
ScriptContext2_Enable();
Overworld_PlaySpecialMapMusic();
FadeInFromBlack();
- CreateTask(task_mpl_807E3C8, 10);
+ CreateTask(Task_SafariZoneRanOutOfBalls, 10);
}
static bool32 WaitWarpFadeOutScreen(void)
@@ -536,7 +536,7 @@ void DoWarp(void)
PlayRainStoppingSoundEffect();
PlaySE(SE_KAIDAN);
gFieldCallback = FieldCB_DefaultWarpExit;
- CreateTask(sub_807E718, 10);
+ CreateTask(Task_Teleport2Warp, 10);
}
void DoDiveWarp(void)
@@ -546,28 +546,28 @@ void DoDiveWarp(void)
WarpFadeOutScreen();
PlayRainStoppingSoundEffect();
gFieldCallback = FieldCB_DefaultWarpExit;
- CreateTask(sub_807E718, 10);
+ CreateTask(Task_Teleport2Warp, 10);
}
-void sub_807E4A0(u16 metatileBehavior, u16 delay)
+void DoStairWarp(u16 metatileBehavior, u16 delay)
{
- u8 taskId = CreateTask(sub_807E980, 10);
+ u8 taskId = CreateTask(Task_StairWarp, 10);
gTasks[taskId].data[1] = metatileBehavior;
gTasks[taskId].data[15] = delay;
- sub_807E980(taskId);
+ Task_StairWarp(taskId);
}
void DoDoorWarp(void)
{
ScriptContext2_Enable();
gFieldCallback = FieldCB_DefaultWarpExit;
- CreateTask(sub_807E80C, 10);
+ CreateTask(Task_DoorWarp, 10);
}
-void sub_807E500(void)
+void DoTeleport2Warp(void)
{
ScriptContext2_Enable();
- CreateTask(sub_807E718, 10);
+ CreateTask(Task_Teleport2Warp, 10);
gFieldCallback = FieldCB_TeleportWarpIn;
}
@@ -614,11 +614,11 @@ void sub_807E5C4(void)
{
ScriptContext2_Enable();
WarpFadeOutScreen();
- CreateTask(sub_807E718, 10);
+ CreateTask(Task_Teleport2Warp, 10);
gFieldCallback = nullsub_60;
}
-static void sub_807E5EC(u8 taskId)
+static void Task_CableClubWarp(u8 taskId)
{
struct Task * task = &gTasks[taskId];
switch (task->data[0])
@@ -645,10 +645,10 @@ void DoCableClubWarp(void)
TryFadeOutOldMapMusic();
WarpFadeOutScreen();
PlaySE(SE_KAIDAN);
- CreateTask(sub_807E5EC, 10);
+ CreateTask(Task_CableClubWarp, 10);
}
-static void sub_807E678(u8 taskId)
+static void Task_ReturnFromLinkRoomWarp(u8 taskId)
{
s16 * data = gTasks[taskId].data;
switch (data[0])
@@ -680,10 +680,10 @@ static void sub_807E678(u8 taskId)
void ReturnFromLinkRoom(void)
{
- CreateTask(sub_807E678, 10);
+ CreateTask(Task_ReturnFromLinkRoomWarp, 10);
}
-static void sub_807E718(u8 taskId)
+static void Task_Teleport2Warp(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
@@ -736,7 +736,7 @@ static void Task_TeleportWarp(u8 taskId)
}
}
-static void sub_807E80C(u8 taskId)
+static void Task_DoorWarp(u8 taskId)
{
struct Task *task = &gTasks[taskId];
s16 * xp = &task->data[2];
@@ -753,8 +753,8 @@ static void sub_807E80C(u8 taskId)
case 1:
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
{
- ObjectEventClearHeldMovementIfActive(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)]);
- ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)], MOVEMENT_ACTION_WALK_NORMAL_UP);
+ ObjectEventClearHeldMovementIfActive(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0)]);
+ ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0)], MOVEMENT_ACTION_WALK_NORMAL_UP);
task->data[0] = 2;
}
break;
@@ -762,7 +762,7 @@ static void sub_807E80C(u8 taskId)
if (walkrun_is_standing_still())
{
task->data[1] = FieldAnimateDoorClose(*xp, *yp - 1);
- ObjectEventClearHeldMovementIfFinished(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)]);
+ ObjectEventClearHeldMovementIfFinished(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0)]);
sub_807DCB0(FALSE);
task->data[0] = 3;
}
@@ -778,18 +778,18 @@ static void sub_807E80C(u8 taskId)
WarpFadeOutScreen();
PlayRainStoppingSoundEffect();
task->data[0] = 0;
- task->func = sub_807E718;
+ task->func = Task_Teleport2Warp;
break;
case 5:
TryFadeOutOldMapMusic();
PlayRainStoppingSoundEffect();
task->data[0] = 0;
- task->func = sub_807E718;
+ task->func = Task_Teleport2Warp;
break;
}
}
-static void sub_807E980(u8 taskId)
+static void Task_StairWarp(u8 taskId)
{
s16 * data = gTasks[taskId].data;
struct ObjectEvent *playerObj = &gObjectEvents[gPlayerAvatar.objectEventId];
@@ -865,22 +865,22 @@ static void sub_807EB64(u16 a0, s16 *a1, s16 *a2)
static void sub_807EBBC(u8 a0, s16 *a1, s16 *a2)
{
- if (MetatileBehavior_IsUnknownWarp6C(a0))
+ if (MetatileBehavior_IsDirectionalUpRightStairWarp(a0))
{
*a1 = 16;
*a2 = -10;
}
- else if (MetatileBehavior_IsUnknownWarp6D(a0))
+ else if (MetatileBehavior_IsDirectionalUpLeftStairWarp(a0))
{
*a1 = -17;
*a2 = -10;
}
- else if (MetatileBehavior_IsUnknownWarp6E(a0))
+ else if (MetatileBehavior_IsDirectionalDownRightStairWarp(a0))
{
*a1 = 17;
*a2 = 3;
}
- else if (MetatileBehavior_IsUnknownWarp6F(a0))
+ else if (MetatileBehavior_IsDirectionalDownLeftStairWarp(a0))
{
*a1 = -17;
*a2 = 3;
@@ -927,7 +927,7 @@ static void sub_807ECBC(s16 *a0, s16 *a1, s16 *a2, s16 *a3, s16 *a4)
struct Sprite *sprite;
PlayerGetDestCoords(&x, &y);
behavior = MapGridGetMetatileBehaviorAt(x, y);
- if (MetatileBehavior_IsUnknownWarp6E(behavior) || MetatileBehavior_IsUnknownWarp6C(behavior))
+ if (MetatileBehavior_IsDirectionalDownRightStairWarp(behavior) || MetatileBehavior_IsDirectionalUpRightStairWarp(behavior))
r1 = 3;
else
r1 = 4;
diff --git a/src/field_message_box.c b/src/field_message_box.c
index 1909fd398..bee44f331 100644
--- a/src/field_message_box.c
+++ b/src/field_message_box.c
@@ -24,7 +24,7 @@ static void Task_RunFieldMessageBoxPrinter(u8 taskId)
switch (task->data[0])
{
case 0:
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
{
gTextFlags.autoScroll = TRUE;
TextWindow_LoadTilesStdFrame1(0, 0x200);
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index 7e3ba59fe..5a8a3e98a 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -556,7 +556,7 @@ static u8 CheckForPlayerAvatarCollision(u8 direction)
x = playerObjEvent->currentCoords.x;
y = playerObjEvent->currentCoords.y;
- if (sub_806DB84(MapGridGetMetatileBehaviorAt(x, y), direction))
+ if (IsDirectionalStairWarpMetatileBehavior(MapGridGetMetatileBehaviorAt(x, y), direction))
return 8;
MoveCoords(direction, &x, &y);
return CheckForObjectEventCollision(playerObjEvent, x, y, direction, MapGridGetMetatileBehaviorAt(x, y));
@@ -673,7 +673,7 @@ static void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collis
}
}
-void SetPlayerAvatarTransitionFlags(bool16 flags)
+void SetPlayerAvatarTransitionFlags(u16 flags)
{
gPlayerAvatar.transitionFlags |= flags;
DoPlayerAvatarTransition();
@@ -910,7 +910,7 @@ void sub_805C260(void)
PlayerSetAnimId(MOVEMENT_ACTION_0x9F, 0);
}
-void sub_805C270(void)
+void HandleEnforcedLookDirectionOnPlayerStopMoving(void)
{
if (gPlayerAvatar.tileTransitionState == T_TILE_CENTER || gPlayerAvatar.tileTransitionState == T_NOT_MOVING)
{
@@ -1006,12 +1006,12 @@ static void PlayCollisionSoundIfNotFacingWarp(u8 direction)
{
if (direction == DIR_WEST)
{
- if (MetatileBehavior_IsUnknownWarp6D(metatileBehavior) || MetatileBehavior_IsUnknownWarp6F(metatileBehavior))
+ if (MetatileBehavior_IsDirectionalUpLeftStairWarp(metatileBehavior) || MetatileBehavior_IsDirectionalDownLeftStairWarp(metatileBehavior))
return;
}
if (direction == DIR_EAST)
{
- if (MetatileBehavior_IsUnknownWarp6C(metatileBehavior) || MetatileBehavior_IsUnknownWarp6E(metatileBehavior))
+ if (MetatileBehavior_IsDirectionalUpRightStairWarp(metatileBehavior) || MetatileBehavior_IsDirectionalDownRightStairWarp(metatileBehavior))
return;
}
if (direction == DIR_NORTH)
@@ -1445,8 +1445,8 @@ static bool8 sub_805CE20(struct Task *task, struct ObjectEvent *playerObject, st
{
ObjectEventClearHeldMovementIfFinished(playerObject);
ObjectEventClearHeldMovementIfFinished(strengthObject);
- sub_806DE28(strengthObject);
- sub_806DE70(strengthObject->currentCoords.x, strengthObject->currentCoords.y);
+ HandleBoulderFallThroughHole(strengthObject);
+ HandleBoulderActivateVictoryRoadSwitch(strengthObject->currentCoords.x, strengthObject->currentCoords.y);
gPlayerAvatar.preventStep = FALSE;
ScriptContext2_Disable();
DestroyTask(FindTaskIdByFunc(Task_BumpBoulder));
@@ -1598,7 +1598,7 @@ void CreateStopSurfingTask_NoMusicChange(u8 direction)
void SeafoamIslandsB4F_CurrentDumpsPlayerOnLand(void)
{
- if (gUnknown_3005E88 != 1 && gUnknown_3005E88 != 3)
+ if (gQuestLogPlaybackState != 1 && gQuestLogPlaybackState != 3)
{
sub_811278C(gUnknown_835B820[DIR_NORTH], 16);
CreateStopSurfingTask(DIR_NORTH);
diff --git a/src/field_poison.c b/src/field_poison.c
index aa77375a5..ed2a9360d 100644
--- a/src/field_poison.c
+++ b/src/field_poison.c
@@ -1,9 +1,9 @@
#include "global.h"
+#include "gflib.h"
#include "strings.h"
#include "task.h"
#include "field_message_box.h"
#include "script.h"
-#include "string_util.h"
#include "event_data.h"
#include "fldeff.h"
#include "party_menu.h"
diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c
index 22043ed2d..a926e5937 100644
--- a/src/field_screen_effect.c
+++ b/src/field_screen_effect.c
@@ -1,13 +1,11 @@
#include "global.h"
+#include "gflib.h"
#include "field_screen_effect.h"
-#include "gpu_regs.h"
#include "overworld.h"
#include "scanline_effect.h"
#include "script.h"
#include "task.h"
-#include "window.h"
#include "strings.h"
-#include "string_util.h"
#include "menu.h"
#include "heal_location.h"
#include "new_menu_helpers.h"
diff --git a/src/field_specials.c b/src/field_specials.c
index 425528d50..26a1d75e6 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -1,6 +1,5 @@
#include "global.h"
-#include "malloc.h"
-#include "palette.h"
+#include "gflib.h"
#include "quest_log.h"
#include "list_menu.h"
#include "diploma.h"
@@ -9,7 +8,6 @@
#include "overworld.h"
#include "field_message_box.h"
#include "event_data.h"
-#include "string_util.h"
#include "strings.h"
#include "battle.h"
#include "fieldmap.h"
@@ -24,13 +22,10 @@
#include "random.h"
#include "mail_data.h"
#include "help_system.h"
-#include "sound.h"
-#include "text.h"
#include "pokemon_storage_system.h"
#include "script_menu.h"
#include "data.h"
#include "pokedex.h"
-#include "window.h"
#include "text_window.h"
#include "menu.h"
#include "mevent.h"
@@ -95,15 +90,15 @@ static u8 *const sStringVarPtrs[] = {
void ShowDiploma(void)
{
- QuestLog_OnInteractionWithSpecialNpc();
+ QuestLog_CutRecording();
SetMainCallback2(CB2_ShowDiploma);
ScriptContext2_Enable();
}
void ForcePlayerOntoBike(void)
{
- if (gPlayerAvatar.flags & 1)
- SetPlayerAvatarTransitionFlags(2);
+ if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ON_FOOT)
+ SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_MACH_BIKE);
Overworld_SetSavedMusic(MUS_CYCLING);
Overworld_ChangeMusicTo(MUS_CYCLING);
}
@@ -187,7 +182,7 @@ u8 GetLeadMonFriendship(void)
void ShowTownMap(void)
{
- QuestLog_OnInteractionWithSpecialNpc();
+ QuestLog_CutRecording();
InitRegionMapWithExitCB(REGIONMAP_TYPE_WALL, CB2_ReturnToFieldContinueScriptPlayMapMusic);
}
@@ -1519,7 +1514,7 @@ static void Task_ListMenuRemoveScrollIndicatorArrowPair(u8 taskId)
void ForcePlayerToStartSurfing(void)
{
SetHelpContext(HELPCONTEXT_SURFING);
- SetPlayerAvatarTransitionFlags(8);
+ SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_SURFING);
}
static const u16 sStarterSpecies[] = {
@@ -1775,18 +1770,18 @@ bool8 DoesPlayerPartyContainSpecies(void)
}
static const u8 sMartMaps[][3] = {
- {MAP_GROUP(VIRIDIAN_CITY_MART), MAP_NUM(VIRIDIAN_CITY_MART), 1},
- {MAP_GROUP(PEWTER_CITY_MART), MAP_NUM(PEWTER_CITY_MART), 3},
- {MAP_GROUP(CERULEAN_CITY_MART), MAP_NUM(CERULEAN_CITY_MART), 1},
- {MAP_GROUP(LAVENDER_TOWN_MART), MAP_NUM(LAVENDER_TOWN_MART), 1},
- {MAP_GROUP(VERMILION_CITY_MART), MAP_NUM(VERMILION_CITY_MART), 1},
- {MAP_GROUP(FUCHSIA_CITY_MART), MAP_NUM(FUCHSIA_CITY_MART), 1},
- {MAP_GROUP(CINNABAR_ISLAND_MART), MAP_NUM(CINNABAR_ISLAND_MART), 1},
- {MAP_GROUP(SAFFRON_CITY_MART), MAP_NUM(SAFFRON_CITY_MART), 1},
- {MAP_GROUP(THREE_ISLAND_MART), MAP_NUM(THREE_ISLAND_MART), 1},
- {MAP_GROUP(FOUR_ISLAND_MART), MAP_NUM(FOUR_ISLAND_MART), 1},
- {MAP_GROUP(SEVEN_ISLAND_MART), MAP_NUM(SEVEN_ISLAND_MART), 1},
- {MAP_GROUP(SIX_ISLAND_MART), MAP_NUM(SIX_ISLAND_MART), 1}
+ {MAP(VIRIDIAN_CITY_MART), 1},
+ {MAP(PEWTER_CITY_MART), 3},
+ {MAP(CERULEAN_CITY_MART), 1},
+ {MAP(LAVENDER_TOWN_MART), 1},
+ {MAP(VERMILION_CITY_MART), 1},
+ {MAP(FUCHSIA_CITY_MART), 1},
+ {MAP(CINNABAR_ISLAND_MART), 1},
+ {MAP(SAFFRON_CITY_MART), 1},
+ {MAP(THREE_ISLAND_MART), 1},
+ {MAP(FOUR_ISLAND_MART), 1},
+ {MAP(SEVEN_ISLAND_MART), 1},
+ {MAP(SIX_ISLAND_MART), 1}
};
u8 GetMartClerkObjectId(void)
@@ -1811,57 +1806,57 @@ static const struct {
u16 grp2;
u16 num2;
} sInsideOutsidePairs[51] = {
- {MAP_GROUP(PALLET_TOWN_PLAYERS_HOUSE_1F), MAP_NUM(PALLET_TOWN_PLAYERS_HOUSE_1F), MAP_GROUP(PALLET_TOWN), MAP_NUM(PALLET_TOWN)},
- {MAP_GROUP(PALLET_TOWN_PROFESSOR_OAKS_LAB), MAP_NUM(PALLET_TOWN_PROFESSOR_OAKS_LAB), MAP_GROUP(PALLET_TOWN), MAP_NUM(PALLET_TOWN)},
- {MAP_GROUP(VIRIDIAN_CITY_GYM), MAP_NUM(VIRIDIAN_CITY_GYM), MAP_GROUP(VIRIDIAN_CITY), MAP_NUM(VIRIDIAN_CITY)},
- {MAP_GROUP(ROUTE22_NORTH_ENTRANCE), MAP_NUM(ROUTE22_NORTH_ENTRANCE), MAP_GROUP(ROUTE22), MAP_NUM(ROUTE22)},
- {MAP_GROUP(ROUTE22_NORTH_ENTRANCE), MAP_NUM(ROUTE22_NORTH_ENTRANCE), MAP_GROUP(ROUTE23), MAP_NUM(ROUTE23)},
- {MAP_GROUP(VIRIDIAN_FOREST), MAP_NUM(VIRIDIAN_FOREST), MAP_GROUP(ROUTE2_VIRIDIAN_FOREST_SOUTH_ENTRANCE), MAP_NUM(ROUTE2_VIRIDIAN_FOREST_SOUTH_ENTRANCE)},
- {MAP_GROUP(VIRIDIAN_FOREST), MAP_NUM(VIRIDIAN_FOREST), MAP_GROUP(ROUTE2_VIRIDIAN_FOREST_NORTH_ENTRANCE), MAP_NUM(ROUTE2_VIRIDIAN_FOREST_NORTH_ENTRANCE)},
- {MAP_GROUP(PEWTER_CITY_MUSEUM_1F), MAP_NUM(PEWTER_CITY_MUSEUM_1F), MAP_GROUP(PEWTER_CITY), MAP_NUM(PEWTER_CITY)},
- {MAP_GROUP(PEWTER_CITY_GYM), MAP_NUM(PEWTER_CITY_GYM), MAP_GROUP(PEWTER_CITY), MAP_NUM(PEWTER_CITY)},
- {MAP_GROUP(MT_MOON_1F), MAP_NUM(MT_MOON_1F), MAP_GROUP(ROUTE4), MAP_NUM(ROUTE4)},
- {MAP_GROUP(MT_MOON_B1F), MAP_NUM(MT_MOON_B1F), MAP_GROUP(ROUTE4), MAP_NUM(ROUTE4)},
- {MAP_GROUP(CERULEAN_CITY_GYM), MAP_NUM(CERULEAN_CITY_GYM), MAP_GROUP(CERULEAN_CITY), MAP_NUM(CERULEAN_CITY)},
- {MAP_GROUP(CERULEAN_CITY_BIKE_SHOP), MAP_NUM(CERULEAN_CITY_BIKE_SHOP), MAP_GROUP(CERULEAN_CITY), MAP_NUM(CERULEAN_CITY)},
- {MAP_GROUP(ROUTE25_SEA_COTTAGE), MAP_NUM(ROUTE25_SEA_COTTAGE), MAP_GROUP(ROUTE25), MAP_NUM(ROUTE25)},
- {MAP_GROUP(ROUTE5_POKEMON_DAY_CARE), MAP_NUM(ROUTE5_POKEMON_DAY_CARE), MAP_GROUP(ROUTE5), MAP_NUM(ROUTE5)},
- {MAP_GROUP(UNDERGROUND_PATH_NORTH_ENTRANCE), MAP_NUM(UNDERGROUND_PATH_NORTH_ENTRANCE), MAP_GROUP(ROUTE5), MAP_NUM(ROUTE5)},
- {MAP_GROUP(UNDERGROUND_PATH_SOUTH_ENTRANCE), MAP_NUM(UNDERGROUND_PATH_SOUTH_ENTRANCE), MAP_GROUP(ROUTE6), MAP_NUM(ROUTE6)},
- {MAP_GROUP(VERMILION_CITY_POKEMON_FAN_CLUB), MAP_NUM(VERMILION_CITY_POKEMON_FAN_CLUB), MAP_GROUP(VERMILION_CITY), MAP_NUM(VERMILION_CITY)},
- {MAP_GROUP(VERMILION_CITY_GYM), MAP_NUM(VERMILION_CITY_GYM), MAP_GROUP(VERMILION_CITY), MAP_NUM(VERMILION_CITY)},
- {MAP_GROUP(SSANNE_1F_CORRIDOR), MAP_NUM(SSANNE_1F_CORRIDOR), MAP_GROUP(VERMILION_CITY), MAP_NUM(VERMILION_CITY)},
- {MAP_GROUP(DIGLETTS_CAVE_NORTH_ENTRANCE), MAP_NUM(DIGLETTS_CAVE_NORTH_ENTRANCE), MAP_GROUP(ROUTE2), MAP_NUM(ROUTE2)},
- {MAP_GROUP(DIGLETTS_CAVE_SOUTH_ENTRANCE), MAP_NUM(DIGLETTS_CAVE_SOUTH_ENTRANCE), MAP_GROUP(ROUTE11), MAP_NUM(ROUTE11)},
- {MAP_GROUP(ROCK_TUNNEL_1F), MAP_NUM(ROCK_TUNNEL_1F), MAP_GROUP(ROUTE10), MAP_NUM(ROUTE10)},
- {MAP_GROUP(ROCK_TUNNEL_1F), MAP_NUM(ROCK_TUNNEL_1F), MAP_GROUP(ROUTE10), MAP_NUM(ROUTE10)},
- {MAP_GROUP(POWER_PLANT), MAP_NUM(POWER_PLANT), MAP_GROUP(ROUTE10), MAP_NUM(ROUTE10)},
- {MAP_GROUP(POKEMON_TOWER_1F), MAP_NUM(POKEMON_TOWER_1F), MAP_GROUP(LAVENDER_TOWN), MAP_NUM(LAVENDER_TOWN)},
- {MAP_GROUP(LAVENDER_TOWN_VOLUNTEER_POKEMON_HOUSE), MAP_NUM(LAVENDER_TOWN_VOLUNTEER_POKEMON_HOUSE), MAP_GROUP(LAVENDER_TOWN), MAP_NUM(LAVENDER_TOWN)},
- {MAP_GROUP(LAVENDER_TOWN_HOUSE2), MAP_NUM(LAVENDER_TOWN_HOUSE2), MAP_GROUP(LAVENDER_TOWN), MAP_NUM(LAVENDER_TOWN)},
- {MAP_GROUP(UNDERGROUND_PATH_EAST_ENTRANCE), MAP_NUM(UNDERGROUND_PATH_EAST_ENTRANCE), MAP_GROUP(ROUTE8), MAP_NUM(ROUTE8)},
- {MAP_GROUP(UNDERGROUND_PATH_WEST_ENTRANCE), MAP_NUM(UNDERGROUND_PATH_WEST_ENTRANCE), MAP_GROUP(ROUTE7), MAP_NUM(ROUTE7)},
- {MAP_GROUP(CELADON_CITY_DEPARTMENT_STORE_1F), MAP_NUM(CELADON_CITY_DEPARTMENT_STORE_1F), MAP_GROUP(CELADON_CITY), MAP_NUM(CELADON_CITY)},
- {MAP_GROUP(CELADON_CITY_CONDOMINIUMS_1F), MAP_NUM(CELADON_CITY_CONDOMINIUMS_1F), MAP_GROUP(CELADON_CITY), MAP_NUM(CELADON_CITY)},
- {MAP_GROUP(CELADON_CITY_GAME_CORNER), MAP_NUM(CELADON_CITY_GAME_CORNER), MAP_GROUP(CELADON_CITY), MAP_NUM(CELADON_CITY)},
- {MAP_GROUP(CELADON_CITY_GYM), MAP_NUM(CELADON_CITY_GYM), MAP_GROUP(CELADON_CITY), MAP_NUM(CELADON_CITY)},
- {MAP_GROUP(CELADON_CITY_RESTAURANT), MAP_NUM(CELADON_CITY_RESTAURANT), MAP_GROUP(CELADON_CITY), MAP_NUM(CELADON_CITY)},
- {MAP_GROUP(ROCKET_HIDEOUT_B1F), MAP_NUM(ROCKET_HIDEOUT_B1F), MAP_GROUP(CELADON_CITY_GAME_CORNER), MAP_NUM(CELADON_CITY_GAME_CORNER)},
- {MAP_GROUP(SAFARI_ZONE_CENTER), MAP_NUM(SAFARI_ZONE_CENTER), MAP_GROUP(FUCHSIA_CITY_SAFARI_ZONE_ENTRANCE), MAP_NUM(FUCHSIA_CITY_SAFARI_ZONE_ENTRANCE)},
- {MAP_GROUP(FUCHSIA_CITY_GYM), MAP_NUM(FUCHSIA_CITY_GYM), MAP_GROUP(FUCHSIA_CITY), MAP_NUM(FUCHSIA_CITY)},
- {MAP_GROUP(FUCHSIA_CITY_WARDENS_HOUSE), MAP_NUM(FUCHSIA_CITY_WARDENS_HOUSE), MAP_GROUP(FUCHSIA_CITY), MAP_NUM(FUCHSIA_CITY)},
- {MAP_GROUP(SAFFRON_CITY_DOJO), MAP_NUM(SAFFRON_CITY_DOJO), MAP_GROUP(SAFFRON_CITY), MAP_NUM(SAFFRON_CITY)},
- {MAP_GROUP(SAFFRON_CITY_GYM), MAP_NUM(SAFFRON_CITY_GYM), MAP_GROUP(SAFFRON_CITY), MAP_NUM(SAFFRON_CITY)},
- {MAP_GROUP(SILPH_CO_1F), MAP_NUM(SILPH_CO_1F), MAP_GROUP(SAFFRON_CITY), MAP_NUM(SAFFRON_CITY)},
- {MAP_GROUP(SEAFOAM_ISLANDS_1F), MAP_NUM(SEAFOAM_ISLANDS_1F), MAP_GROUP(ROUTE20), MAP_NUM(ROUTE20)},
- {MAP_GROUP(SEAFOAM_ISLANDS_1F), MAP_NUM(SEAFOAM_ISLANDS_1F), MAP_GROUP(ROUTE20), MAP_NUM(ROUTE20)},
- {MAP_GROUP(POKEMON_MANSION_1F), MAP_NUM(POKEMON_MANSION_1F), MAP_GROUP(CINNABAR_ISLAND), MAP_NUM(CINNABAR_ISLAND)},
- {MAP_GROUP(CINNABAR_ISLAND_GYM), MAP_NUM(CINNABAR_ISLAND_GYM), MAP_GROUP(CINNABAR_ISLAND), MAP_NUM(CINNABAR_ISLAND)},
- {MAP_GROUP(CINNABAR_ISLAND_POKEMON_LAB_ENTRANCE), MAP_NUM(CINNABAR_ISLAND_POKEMON_LAB_ENTRANCE), MAP_GROUP(CINNABAR_ISLAND), MAP_NUM(CINNABAR_ISLAND)},
- {MAP_GROUP(VICTORY_ROAD_1F), MAP_NUM(VICTORY_ROAD_1F), MAP_GROUP(ROUTE23), MAP_NUM(ROUTE23)},
- {MAP_GROUP(VICTORY_ROAD_2F), MAP_NUM(VICTORY_ROAD_2F), MAP_GROUP(ROUTE23), MAP_NUM(ROUTE23)},
- {MAP_GROUP(INDIGO_PLATEAU_POKEMON_CENTER_1F), MAP_NUM(INDIGO_PLATEAU_POKEMON_CENTER_1F), MAP_GROUP(INDIGO_PLATEAU_EXTERIOR), MAP_NUM(INDIGO_PLATEAU_EXTERIOR)},
- {MAP_GROUP(CERULEAN_CAVE_1F), MAP_NUM(CERULEAN_CAVE_1F), MAP_GROUP(CERULEAN_CITY), MAP_NUM(CERULEAN_CITY)}
+ [QL_LOCATION_HOME] = {MAP(PALLET_TOWN_PLAYERS_HOUSE_1F), MAP(PALLET_TOWN)},
+ [QL_LOCATION_OAKS_LAB] = {MAP(PALLET_TOWN_PROFESSOR_OAKS_LAB), MAP(PALLET_TOWN)},
+ [QL_LOCATION_VIRIDIAN_GYM] = {MAP(VIRIDIAN_CITY_GYM), MAP(VIRIDIAN_CITY)},
+ [QL_LOCATION_LEAGUE_GATE_1] = {MAP(ROUTE22_NORTH_ENTRANCE), MAP(ROUTE22)},
+ [QL_LOCATION_LEAGUE_GATE_2] = {MAP(ROUTE22_NORTH_ENTRANCE), MAP(ROUTE23)},
+ [QL_LOCATION_VIRIDIAN_FOREST_1] = {MAP(VIRIDIAN_FOREST), MAP(ROUTE2_VIRIDIAN_FOREST_SOUTH_ENTRANCE)},
+ [QL_LOCATION_VIRIDIAN_FOREST_2] = {MAP(VIRIDIAN_FOREST), MAP(ROUTE2_VIRIDIAN_FOREST_NORTH_ENTRANCE)},
+ [QL_LOCATION_PEWTER_MUSEUM] = {MAP(PEWTER_CITY_MUSEUM_1F), MAP(PEWTER_CITY)},
+ [QL_LOCATION_PEWTER_GYM] = {MAP(PEWTER_CITY_GYM), MAP(PEWTER_CITY)},
+ [QL_LOCATION_MT_MOON_1] = {MAP(MT_MOON_1F), MAP(ROUTE4)},
+ [QL_LOCATION_MT_MOON_2] = {MAP(MT_MOON_B1F), MAP(ROUTE4)},
+ [QL_LOCATION_CERULEAN_GYM] = {MAP(CERULEAN_CITY_GYM), MAP(CERULEAN_CITY)},
+ [QL_LOCATION_BIKE_SHOP] = {MAP(CERULEAN_CITY_BIKE_SHOP), MAP(CERULEAN_CITY)},
+ [QL_LOCATION_BILLS_HOUSE] = {MAP(ROUTE25_SEA_COTTAGE), MAP(ROUTE25)},
+ [QL_LOCATION_DAY_CARE] = {MAP(ROUTE5_POKEMON_DAY_CARE), MAP(ROUTE5)},
+ [QL_LOCATION_UNDERGROUND_PATH_1] = {MAP(UNDERGROUND_PATH_NORTH_ENTRANCE), MAP(ROUTE5)},
+ [QL_LOCATION_UNDERGROUND_PATH_2] = {MAP(UNDERGROUND_PATH_SOUTH_ENTRANCE), MAP(ROUTE6)},
+ [QL_LOCATION_PKMN_FAN_CLUB] = {MAP(VERMILION_CITY_POKEMON_FAN_CLUB), MAP(VERMILION_CITY)},
+ [QL_LOCATION_VERMILION_GYM] = {MAP(VERMILION_CITY_GYM), MAP(VERMILION_CITY)},
+ [QL_LOCATION_SS_ANNE] = {MAP(SSANNE_1F_CORRIDOR), MAP(VERMILION_CITY)},
+ [QL_LOCATION_DIGLETTS_CAVE_1] = {MAP(DIGLETTS_CAVE_NORTH_ENTRANCE), MAP(ROUTE2)},
+ [QL_LOCATION_DIGLETTS_CAVE_2] = {MAP(DIGLETTS_CAVE_SOUTH_ENTRANCE), MAP(ROUTE11)},
+ [QL_LOCATION_ROCK_TUNNEL_1] = {MAP(ROCK_TUNNEL_1F), MAP(ROUTE10)},
+ [QL_LOCATION_ROCK_TUNNEL_2] = {MAP(ROCK_TUNNEL_1F), MAP(ROUTE10)},
+ [QL_LOCATION_POWER_PLANT] = {MAP(POWER_PLANT), MAP(ROUTE10)},
+ [QL_LOCATION_PKMN_TOWER] = {MAP(POKEMON_TOWER_1F), MAP(LAVENDER_TOWN)},
+ [QL_LOCATION_VOLUNTEER_HOUSE] = {MAP(LAVENDER_TOWN_VOLUNTEER_POKEMON_HOUSE), MAP(LAVENDER_TOWN)},
+ [QL_LOCATION_NAME_RATERS_HOUSE] = {MAP(LAVENDER_TOWN_HOUSE2), MAP(LAVENDER_TOWN)},
+ [QL_LOCATION_UNDERGROUND_PATH_3] = {MAP(UNDERGROUND_PATH_EAST_ENTRANCE), MAP(ROUTE8)},
+ [QL_LOCATION_UNDERGROUND_PATH_4] = {MAP(UNDERGROUND_PATH_WEST_ENTRANCE), MAP(ROUTE7)},
+ [QL_LOCATION_CELADON_DEPT_STORE] = {MAP(CELADON_CITY_DEPARTMENT_STORE_1F), MAP(CELADON_CITY)},
+ [QL_LOCATION_CELADON_MANSION] = {MAP(CELADON_CITY_CONDOMINIUMS_1F), MAP(CELADON_CITY)},
+ [QL_LOCATION_GAME_CORNER] = {MAP(CELADON_CITY_GAME_CORNER), MAP(CELADON_CITY)},
+ [QL_LOCATION_CELADON_GYM] = {MAP(CELADON_CITY_GYM), MAP(CELADON_CITY)},
+ [QL_LOCATION_CELADON_RESTAURANT] = {MAP(CELADON_CITY_RESTAURANT), MAP(CELADON_CITY)},
+ [QL_LOCATION_ROCKET_HIDEOUT] = {MAP(ROCKET_HIDEOUT_B1F), MAP(CELADON_CITY_GAME_CORNER)},
+ [QL_LOCATION_SAFARI_ZONE] = {MAP(SAFARI_ZONE_CENTER), MAP(FUCHSIA_CITY_SAFARI_ZONE_ENTRANCE)},
+ [QL_LOCATION_FUCHSIA_GYM] = {MAP(FUCHSIA_CITY_GYM), MAP(FUCHSIA_CITY)},
+ [QL_LOCATION_WARDENS_HOME] = {MAP(FUCHSIA_CITY_WARDENS_HOUSE), MAP(FUCHSIA_CITY)},
+ [QL_LOCATION_FIGHTING_DOJO] = {MAP(SAFFRON_CITY_DOJO), MAP(SAFFRON_CITY)},
+ [QL_LOCATION_SAFFRON_GYM] = {MAP(SAFFRON_CITY_GYM), MAP(SAFFRON_CITY)},
+ [QL_LOCATION_SILPH_CO] = {MAP(SILPH_CO_1F), MAP(SAFFRON_CITY)},
+ [QL_LOCATION_SEAFOAM_ISLANDS_1] = {MAP(SEAFOAM_ISLANDS_1F), MAP(ROUTE20)},
+ [QL_LOCATION_SEAFOAM_ISLANDS_2] = {MAP(SEAFOAM_ISLANDS_1F), MAP(ROUTE20)},
+ [QL_LOCATION_PKMN_MANSION] = {MAP(POKEMON_MANSION_1F), MAP(CINNABAR_ISLAND)},
+ [QL_LOCATION_CINNABAR_GYM] = {MAP(CINNABAR_ISLAND_GYM), MAP(CINNABAR_ISLAND)},
+ [QL_LOCATION_CINNABAR_LAB] = {MAP(CINNABAR_ISLAND_POKEMON_LAB_ENTRANCE), MAP(CINNABAR_ISLAND)},
+ [QL_LOCATION_VICTORY_ROAD_1] = {MAP(VICTORY_ROAD_1F), MAP(ROUTE23)},
+ [QL_LOCATION_VICTORY_ROAD_2] = {MAP(VICTORY_ROAD_2F), MAP(ROUTE23)},
+ [QL_LOCATION_PKMN_LEAGUE] = {MAP(INDIGO_PLATEAU_POKEMON_CENTER_1F), MAP(INDIGO_PLATEAU_EXTERIOR)},
+ [QL_LOCATION_CERULEAN_CAVE] = {MAP(CERULEAN_CAVE_1F), MAP(CERULEAN_CITY)}
};
void sub_80CC534(void)
@@ -1871,7 +1866,7 @@ void sub_80CC534(void)
{
if (gSaveBlock1Ptr->location.mapGroup == sInsideOutsidePairs[i].grp && gSaveBlock1Ptr->location.mapNum == sInsideOutsidePairs[i].num)
{
- if (VarGet(VAR_0x404D) != 35 || i != 32)
+ if (VarGet(VAR_0x404D) != QL_LOCATION_ROCKET_HIDEOUT || i != QL_LOCATION_GAME_CORNER)
{
VarSet(VAR_0x404D, i);
FlagSet(FLAG_0x808);
@@ -1893,7 +1888,7 @@ void sub_80CC59C(void)
sp0.unk1 = 0;
if (FlagGet(FLAG_0x808))
{
- if (r5 == 5)
+ if (r5 == QL_LOCATION_VIRIDIAN_FOREST_1)
{
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROUTE2_VIRIDIAN_FOREST_SOUTH_ENTRANCE) && (gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE2_VIRIDIAN_FOREST_SOUTH_ENTRANCE) || gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE2_VIRIDIAN_FOREST_NORTH_ENTRANCE)))
{
@@ -1907,7 +1902,7 @@ void sub_80CC59C(void)
return;
}
}
- else if (r5 == 3)
+ else if (r5 == QL_LOCATION_LEAGUE_GATE_1)
{
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROUTE22) && (gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE22) || gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE23)))
{
@@ -1925,13 +1920,13 @@ void sub_80CC59C(void)
{
sp0.unk0 = Overworld_GetMapHeaderByGroupAndId(sInsideOutsidePairs[r5].grp, sInsideOutsidePairs[r5].num)->regionMapSectionId;
sp0.unk1 = r5;
- if (r5 == 22)
+ if (r5 == QL_LOCATION_ROCK_TUNNEL_1)
{
PlayerGetDestCoords(&x, &y);
if (x != 15 || y != 26)
sp0.unk1++;
}
- else if (r5 == 42)
+ else if (r5 == QL_LOCATION_SEAFOAM_ISLANDS_1)
{
PlayerGetDestCoords(&x, &y);
if (x != 67 || y != 15)
@@ -1939,9 +1934,9 @@ void sub_80CC59C(void)
}
SetQuestLogEvent(QL_EVENT_DEPARTED, (void *)&sp0);
FlagClear(FLAG_0x808);
- if (r5 == 35)
+ if (r5 == QL_LOCATION_ROCKET_HIDEOUT)
{
- VarSet(VAR_0x404D, 32);
+ VarSet(VAR_0x404D, QL_LOCATION_GAME_CORNER);
FlagSet(FLAG_0x808);
}
}
@@ -2481,7 +2476,7 @@ void BrailleCursorToggle(void)
// 8005 = y
// 8006 = action (0 = create, 1 = delete)
u16 x;
- if (gQuestLogState != 2)
+ if (gQuestLogState != QL_STATE_PLAYBACK)
{
x = gSpecialVar_0x8004 + 27;
if (gSpecialVar_0x8006 == 0)
diff --git a/src/field_tasks.c b/src/field_tasks.c
index 4c7b93f20..0eb3045e0 100644
--- a/src/field_tasks.c
+++ b/src/field_tasks.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "gflib.h"
#include "bike.h"
#include "event_data.h"
#include "field_camera.h"
@@ -9,7 +10,6 @@
#include "overworld.h"
#include "quest_log.h"
#include "script.h"
-#include "sound.h"
#include "task.h"
#include "constants/field_tasks.h"
#include "constants/flags.h"
@@ -61,7 +61,7 @@ static void Task_RunTimeBasedEvents(u8 taskId)
if (!ScriptContext2_IsEnabled())
{
- if (gQuestLogState != 2 && gQuestLogState != 3)
+ if (!QL_IS_PLAYBACK_STATE)
{
UpdateAmbientCry(&data[1], &data[2]);
}
diff --git a/src/field_weather_effects.c b/src/field_weather_effects.c
index e6f4bfacf..2acf19a5f 100644
--- a/src/field_weather_effects.c
+++ b/src/field_weather_effects.c
@@ -4,7 +4,6 @@
#include "event_object_movement.h"
#include "field_weather.h"
#include "field_weather_effects.h"
-#include "overworld.h"
#include "random.h"
#include "script.h"
#include "constants/weather.h"
diff --git a/src/fieldmap.c b/src/fieldmap.c
index 60c6f3dae..53110396d 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -1,6 +1,5 @@
#include "global.h"
-#include "bg.h"
-#include "palette.h"
+#include "gflib.h"
#include "overworld.h"
#include "script.h"
#include "new_menu_helpers.h"
diff --git a/src/fighting.c b/src/fighting.c
index 7b826594d..fcfee5c54 100644
--- a/src/fighting.c
+++ b/src/fighting.c
@@ -1,6 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "battle_anim.h"
-#include "gpu_regs.h"
#include "random.h"
#include "task.h"
#include "trig.h"
diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c
index bd7abc4e4..6a2d1659f 100644
--- a/src/fldeff_cut.c
+++ b/src/fldeff_cut.c
@@ -287,7 +287,7 @@ static void SpriteCallback_CutGrass_Cleanup(struct Sprite * sprite)
}
FieldEffectStop(&gSprites[sCutGrassSpriteArrayPtr[0]], FLDEFF_CUT_GRASS);
Free(sCutGrassSpriteArrayPtr);
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
}
diff --git a/src/fldeff_poison.c b/src/fldeff_poison.c
index d117e0c9b..c88ec6502 100644
--- a/src/fldeff_poison.c
+++ b/src/fldeff_poison.c
@@ -1,7 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "task.h"
-#include "bg.h"
-#include "sound.h"
#include "constants/songs.h"
static void Task_FieldPoisonEffect(u8 taskId)
diff --git a/src/fldeff_rocksmash.c b/src/fldeff_rocksmash.c
index dc372ce18..12377f345 100644
--- a/src/fldeff_rocksmash.c
+++ b/src/fldeff_rocksmash.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "global.fieldmap.h"
+#include "gflib.h"
#include "field_player_avatar.h"
#include "field_effect.h"
#include "party_menu.h"
@@ -7,7 +7,6 @@
#include "script.h"
#include "fldeff.h"
#include "event_scripts.h"
-#include "sound.h"
#include "overworld.h"
#include "event_object_movement.h"
#include "constants/songs.h"
diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c
index 966a7934c..2854653e5 100644
--- a/src/fldeff_softboiled.c
+++ b/src/fldeff_softboiled.c
@@ -1,7 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "party_menu.h"
-#include "sound.h"
-#include "string_util.h"
#include "menu.h"
#include "new_menu_helpers.h"
#include "constants/songs.h"
diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c
index d827aff4d..3d1dce193 100644
--- a/src/fldeff_sweetscent.c
+++ b/src/fldeff_sweetscent.c
@@ -1,14 +1,12 @@
#include "global.h"
+#include "gflib.h"
#include "field_player_avatar.h"
#include "field_effect.h"
#include "party_menu.h"
-#include "malloc.h"
#include "script.h"
#include "fldeff.h"
#include "event_scripts.h"
#include "field_weather.h"
-#include "sound.h"
-#include "palette.h"
#include "wild_encounter.h"
#include "constants/songs.h"
diff --git a/src/flying.c b/src/flying.c
index 4ecfa2899..83c8e1f0e 100644
--- a/src/flying.c
+++ b/src/flying.c
@@ -1,6 +1,6 @@
#include "global.h"
#include "battle_anim.h"
-#include "palette.h"
+#include "gflib.h"
#include "trig.h"
#include "constants/battle_anim.h"
#include "random.h"
diff --git a/src/ghost.c b/src/ghost.c
index 35dcd267b..9a77999de 100644
--- a/src/ghost.c
+++ b/src/ghost.c
@@ -1,12 +1,8 @@
#include "global.h"
+#include "gflib.h"
#include "battle_anim.h"
-#include "bg.h"
-#include "gpu_regs.h"
-#include "palette.h"
#include "scanline_effect.h"
-#include "malloc.h"
#include "graphics.h"
-#include "sound.h"
#include "trig.h"
#include "util.h"
#include "decompress.h"
diff --git a/src/gpu_regs.c b/src/gpu_regs.c
index c1909ff32..2f52c5be3 100644
--- a/src/gpu_regs.c
+++ b/src/gpu_regs.c
@@ -1,5 +1,4 @@
#include "global.h"
-#include "gpu_regs.h"
#define GPU_REG_BUF_SIZE 0x60
diff --git a/src/graphics.c b/src/graphics.c
index 14c20496a..7eee42bf0 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1003,8 +1003,8 @@ const u32 gBattleAnimSpritePal_Splash[] = INCBIN_U32("graphics/battle_anims/spri
const u32 gBattleAnimSpriteGfx_SweatBead[] = INCBIN_U32("graphics/battle_anims/sprites/sweat_bead.4bpp.lz");
-const u32 gBattleAnimSpriteGfx_Pokeblock[] = INCBIN_U32("graphics/battle_anims/sprites/pokeblock.4bpp.lz");
-const u32 gBattleAnimSpritePal_Pokeblock[] = INCBIN_U32("graphics/battle_anims/sprites/pokeblock.gbapal.lz");
+const u32 gBattleAnimSpriteGfx_SafariBait[] = INCBIN_U32("graphics/battle_anims/sprites/safari_bait.4bpp.lz");
+const u32 gBattleAnimSpritePal_SafariBait[] = INCBIN_U32("graphics/battle_anims/sprites/safari_bait.gbapal.lz");
const u32 gBattleAnimSpriteGfx_Gem1[] = INCBIN_U32("graphics/battle_anims/sprites/gem_1.4bpp.lz");
const u32 gBattleAnimSpriteGfx_Gem2[] = INCBIN_U32("graphics/battle_anims/sprites/gem_2.4bpp.lz");
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index 14f399f24..1652538a3 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -1,14 +1,8 @@
#include "global.h"
-#include "palette.h"
-#include "malloc.h"
+#include "gflib.h"
#include "decompress.h"
-#include "bg.h"
#include "scanline_effect.h"
-#include "gpu_regs.h"
#include "task.h"
-#include "text.h"
-#include "main.h"
-#include "sound.h"
#include "save.h"
#include "data.h"
#include "m4a.h"
diff --git a/src/help_message.c b/src/help_message.c
new file mode 100644
index 000000000..2fd76e432
--- /dev/null
+++ b/src/help_message.c
@@ -0,0 +1,196 @@
+#include "global.h"
+#include "menu.h"
+
+static EWRAM_DATA u8 sHelpMessageWindowId = 0;
+
+const u16 gUnknown_84566A8[] = INCBIN_U16("graphics/unknown/unknown_84566a8.bin");
+
+static const struct WindowTemplate sHelpMessageWindowTemplate = {
+ .bg = 0,
+ .tilemapLeft = 0,
+ .tilemapTop = 15,
+ .width = 30,
+ .height = 5,
+ .paletteNum = 15,
+ .baseBlock = 0x08F
+};
+
+void MapNamePopupWindowIdSetDummy(void)
+{
+ sHelpMessageWindowId = 0xFF;
+}
+
+u8 CreateHelpMessageWindow(void)
+{
+ if (sHelpMessageWindowId == 0xFF)
+ {
+ sHelpMessageWindowId = AddWindow(&sHelpMessageWindowTemplate);
+ PutWindowTilemap(sHelpMessageWindowId);
+ }
+ return sHelpMessageWindowId;
+}
+
+void DestroyHelpMessageWindow(u8 a0)
+{
+ if (sHelpMessageWindowId != 0xFF)
+ {
+ FillWindowPixelBuffer(sHelpMessageWindowId, PIXEL_FILL(0));
+ ClearWindowTilemap(sHelpMessageWindowId);
+
+ if (a0)
+ CopyWindowToVram(sHelpMessageWindowId, a0);
+
+ RemoveWindow(sHelpMessageWindowId);
+ sHelpMessageWindowId = 0xFF;
+ }
+}
+
+#ifdef NONMATCHING
+void sub_8112F18(u8 windowId)
+{
+ u8 width = GetWindowAttribute(windowId, WINDOW_WIDTH);
+ u8 height = GetWindowAttribute(windowId, WINDOW_HEIGHT);
+ u8 *buffer = Alloc(32 * width * height);
+ u8 i, j;
+ u8 k;
+
+ if (buffer != NULL)
+ {
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ if (i == 0)
+ k = 0;
+ else if (i == height - 1)
+ k = 14;
+ else
+ k = 5;
+ CpuCopy32(
+ (void *)gUnknown_84566A8 + 32 * k, // operand swap on "add" instruction
+ buffer + 32 * (i * width + j),
+ 32
+ );
+ }
+ }
+ CopyToWindowPixelBuffer(windowId, buffer, width * height * 32, 0);
+ Free(buffer);
+ }
+}
+#else
+NAKED
+void sub_8112F18(u8 windowId)
+{
+ asm_unified("\tpush {r4-r7,lr}\n"
+ "\tmov r7, r10\n"
+ "\tmov r6, r9\n"
+ "\tmov r5, r8\n"
+ "\tpush {r5-r7}\n"
+ "\tsub sp, 0x8\n"
+ "\tlsls r0, 24\n"
+ "\tlsrs r0, 24\n"
+ "\tmov r10, r0\n"
+ "\tmovs r1, 0x3\n"
+ "\tbl GetWindowAttribute\n"
+ "\tlsls r0, 24\n"
+ "\tlsrs r6, r0, 24\n"
+ "\tmov r0, r10\n"
+ "\tmovs r1, 0x4\n"
+ "\tbl GetWindowAttribute\n"
+ "\tlsls r0, 24\n"
+ "\tlsrs r7, r0, 24\n"
+ "\tlsls r0, r7, 5\n"
+ "\tmuls r0, r6\n"
+ "\tbl Alloc\n"
+ "\tmov r8, r0\n"
+ "\tcmp r0, 0\n"
+ "\tbeq _08112FB8\n"
+ "\tmovs r5, 0\n"
+ "\tadds r0, r6, 0\n"
+ "\tmuls r0, r7\n"
+ "\tstr r0, [sp]\n"
+ "\tcmp r5, r7\n"
+ "\tbcs _08112FA2\n"
+ "_08112F5A:\n"
+ "\tmovs r4, 0\n"
+ "\tadds r1, r5, 0x1\n"
+ "\tmov r9, r1\n"
+ "\tcmp r4, r6\n"
+ "\tbcs _08112F98\n"
+ "\tsubs r3, r7, 0x1\n"
+ "_08112F66:\n"
+ "\tmovs r0, 0\n"
+ "\tcmp r5, 0\n"
+ "\tbeq _08112F74\n"
+ "\tmovs r0, 0x5\n"
+ "\tcmp r5, r3\n"
+ "\tbne _08112F74\n"
+ "\tmovs r0, 0xE\n"
+ "_08112F74:\n"
+ "\tlsls r0, 5\n"
+ "\tldr r1, _08112FC8 @ =gUnknown_84566A8\n"
+ "\tadds r0, r1, r0\n"
+ "\tadds r1, r5, 0\n"
+ "\tmuls r1, r6\n"
+ "\tadds r1, r4\n"
+ "\tlsls r1, 5\n"
+ "\tadd r1, r8\n"
+ "\tldr r2, _08112FCC @ =0x04000008\n"
+ "\tstr r3, [sp, 0x4]\n"
+ "\tbl CpuSet\n"
+ "\tadds r0, r4, 0x1\n"
+ "\tlsls r0, 24\n"
+ "\tlsrs r4, r0, 24\n"
+ "\tldr r3, [sp, 0x4]\n"
+ "\tcmp r4, r6\n"
+ "\tbcc _08112F66\n"
+ "_08112F98:\n"
+ "\tmov r1, r9\n"
+ "\tlsls r0, r1, 24\n"
+ "\tlsrs r5, r0, 24\n"
+ "\tcmp r5, r7\n"
+ "\tbcc _08112F5A\n"
+ "_08112FA2:\n"
+ "\tldr r0, [sp]\n"
+ "\tlsls r2, r0, 21\n"
+ "\tlsrs r2, 16\n"
+ "\tmov r0, r10\n"
+ "\tmov r1, r8\n"
+ "\tmovs r3, 0\n"
+ "\tbl CopyToWindowPixelBuffer\n"
+ "\tmov r0, r8\n"
+ "\tbl Free\n"
+ "_08112FB8:\n"
+ "\tadd sp, 0x8\n"
+ "\tpop {r3-r5}\n"
+ "\tmov r8, r3\n"
+ "\tmov r9, r4\n"
+ "\tmov r10, r5\n"
+ "\tpop {r4-r7}\n"
+ "\tpop {r0}\n"
+ "\tbx r0\n"
+ "\t.align 2, 0\n"
+ "_08112FC8: .4byte gUnknown_84566A8\n"
+ "_08112FCC: .4byte 0x04000008");
+}
+#endif
+
+static void sub_8112FD0(void)
+{
+ sub_8112F18(sHelpMessageWindowId);
+}
+
+static const u8 sHelpMessageTextColors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_DYNAMIC_COLOR_1, TEXT_COLOR_DARK_GREY};
+
+static void PrintHelpMessageText(const u8 *text)
+{
+ AddTextPrinterParameterized4(sHelpMessageWindowId, 2, 2, 5, 1, 1, sHelpMessageTextColors, -1, text);
+}
+
+void PrintTextOnHelpMessageWindow(const u8 *text, u8 mode)
+{
+ sub_8112FD0();
+ PrintHelpMessageText(text);
+ if (mode)
+ CopyWindowToVram(sHelpMessageWindowId, mode);
+}
diff --git a/src/help_system.c b/src/help_system.c
index 8eabd4e1d..eeeb0a65f 100644
--- a/src/help_system.c
+++ b/src/help_system.c
@@ -1,15 +1,10 @@
#include "global.h"
+#include "gflib.h"
#include "decompress.h"
-#include "gpu_regs.h"
-#include "main.h"
#include "m4a.h"
-#include "dma3.h"
#include "help_system.h"
#include "list_menu.h"
-#include "sound.h"
#include "strings.h"
-#include "text.h"
-#include "blit.h"
#include "constants/songs.h"
extern u8 gGlyphInfo[];
diff --git a/src/help_system_812B1E0.c b/src/help_system_812B1E0.c
index ee26c6de5..f3ec0ba85 100644
--- a/src/help_system_812B1E0.c
+++ b/src/help_system_812B1E0.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "gflib.h"
#include "event_data.h"
#include "event_scripts.h"
#include "field_player_avatar.h"
@@ -10,7 +11,6 @@
#include "quest_log.h"
#include "save.h"
#include "save_location.h"
-#include "sound.h"
#include "strings.h"
#include "constants/items.h"
#include "constants/maps.h"
@@ -1892,7 +1892,7 @@ void HelpSystem_Disable(void)
void HelpSystem_Enable(void)
{
- if (gQuestLogState != 2 && gQuestLogState != 3)
+ if (!QL_IS_PLAYBACK_STATE)
{
gHelpSystemEnabled = TRUE;
HelpSystem_EnableToggleWithRButton();
diff --git a/src/hof_pc.c b/src/hof_pc.c
index 173625774..6f21d3c32 100644
--- a/src/hof_pc.c
+++ b/src/hof_pc.c
@@ -1,12 +1,10 @@
#include "global.h"
+#include "gflib.h"
#include "hall_of_fame.h"
-#include "palette.h"
#include "overworld.h"
#include "script.h"
#include "script_menu.h"
#include "task.h"
-#include "bg.h"
-#include "window.h"
static void ReshowPCMenuAfterHallOfFamePC(void);
static void Task_WaitForPaletteFade(u8 taskId);
diff --git a/src/ice.c b/src/ice.c
index 8b4269a95..c00358357 100644
--- a/src/ice.c
+++ b/src/ice.c
@@ -1,11 +1,8 @@
#include "global.h"
+#include "gflib.h"
#include "battle_anim.h"
-#include "bg.h"
-#include "gpu_regs.h"
#include "graphics.h"
-#include "palette.h"
#include "random.h"
-#include "sprite.h"
#include "task.h"
#include "trig.h"
#include "constants/battle_anim.h"
diff --git a/src/isagbprn.c b/src/isagbprn.c
index 3fd5e9142..d6f547c1f 100644
--- a/src/isagbprn.c
+++ b/src/isagbprn.c
@@ -1,6 +1,5 @@
#include <stdarg.h>
#include <stdio.h>
-#include "global.h"
#include "config.h"
#include "gba/gba.h"
diff --git a/src/item.c b/src/item.c
index 296ba8ec7..ab082c315 100644
--- a/src/item.c
+++ b/src/item.c
@@ -1,12 +1,11 @@
#include "global.h"
+#include "gflib.h"
#include "berry.h"
#include "event_data.h"
#include "item.h"
#include "item_use.h"
#include "load_save.h"
-#include "malloc.h"
#include "quest_log.h"
-#include "string_util.h"
#include "strings.h"
#include "constants/hold_effects.h"
#include "constants/items.h"
diff --git a/src/item_menu.c b/src/item_menu.c
index ebad0640d..ff59f0985 100644
--- a/src/item_menu.c
+++ b/src/item_menu.c
@@ -2035,7 +2035,7 @@ bool8 UseRegisteredKeyItemOnField(void)
{
ScriptContext2_Enable();
FreezeObjectEvents();
- sub_805C270();
+ HandleEnforcedLookDirectionOnPlayerStopMoving();
StopPlayerAvatar();
gSpecialVar_ItemId = gSaveBlock1Ptr->registeredItem;
taskId = CreateTask(ItemId_GetFieldFunc(gSaveBlock1Ptr->registeredItem), 8);
diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c
index d389c7781..6e7e8b80b 100644
--- a/src/item_menu_icons.c
+++ b/src/item_menu_icons.c
@@ -1,8 +1,8 @@
#include "global.h"
+#include "gflib.h"
#include "decompress.h"
#include "graphics.h"
#include "item_menu_icons.h"
-#include "malloc.h"
#include "constants/items.h"
static EWRAM_DATA u8 sItemMenuIconSpriteIds[12] = {0};
diff --git a/src/item_pc.c b/src/item_pc.c
index 1fda50d6f..dce96d59d 100644
--- a/src/item_pc.c
+++ b/src/item_pc.c
@@ -1,8 +1,7 @@
#include "global.h"
-#include "bg.h"
+#include "gflib.h"
#include "data.h"
#include "decompress.h"
-#include "gpu_regs.h"
#include "graphics.h"
#include "help_system.h"
#include "item.h"
@@ -11,18 +10,13 @@
#include "list_menu.h"
#include "item_pc.h"
#include "item_use.h"
-#include "main.h"
-#include "malloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "menu_indicators.h"
#include "new_menu_helpers.h"
-#include "palette.h"
#include "party_menu.h"
#include "pc_screen_effect.h"
#include "scanline_effect.h"
-#include "sound.h"
-#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "text_window.h"
diff --git a/src/item_use.c b/src/item_use.c
index 5682392a1..086f9d0c4 100644
--- a/src/item_use.c
+++ b/src/item_use.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "gflib.h"
#include "battle.h"
#include "berry_pouch.h"
#include "berry_powder.h"
@@ -17,19 +18,14 @@
#include "item_use.h"
#include "itemfinder.h"
#include "mail.h"
-#include "main.h"
-#include "malloc.h"
#include "event_object_lock.h"
#include "metatile_behavior.h"
#include "new_menu_helpers.h"
#include "overworld.h"
-#include "palette.h"
#include "party_menu.h"
#include "quest_log.h"
#include "region_map.h"
#include "script.h"
-#include "sound.h"
-#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "teachy_tv.h"
@@ -45,9 +41,9 @@
static EWRAM_DATA void (*sItemUseOnFieldCB)(u8 taskId) = NULL;
-static void sub_80A1084(void);
-static void sub_80A109C(u8 taskId);
-static void sub_80A112C(u8 taskId);
+static void FieldCB_FadeInFromBlack(void);
+static void Task_WaitFadeIn_CallItemUseOnFieldCB(u8 taskId);
+static void Task_ItemUse_CloseMessageBoxAndReturnToField(u8 taskId);
static void sub_80A11C0(u8 taskId);
static bool8 sub_80A1194(void);
static void sub_80A1208(void);
@@ -130,14 +126,14 @@ static const u8 sUnref_83E27B4[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
-static void (*const gUnknown_83E2954[])(void) = {
+static void (*const sExitCallbackByItemType[])(void) = {
CB2_ShowPartyMenuForItemUse,
CB2_ReturnToField,
NULL,
NULL
};
-static void sub_80A0FBC(u8 taskId)
+static void Task_FadeOuFromBackToField(u8 taskId)
{
u8 itemType;
if (gSpecialVar_ItemId == ITEM_ENIGMA_BERRY)
@@ -146,12 +142,12 @@ static void sub_80A0FBC(u8 taskId)
itemType = ItemId_GetType(gSpecialVar_ItemId) - 1;
if (GetPocketByItemId(gSpecialVar_ItemId) == POCKET_BERRY_POUCH)
{
- BerryPouch_SetExitCallback(gUnknown_83E2954[itemType]);
+ BerryPouch_SetExitCallback(sExitCallbackByItemType[itemType]);
BerryPouch_StartFadeToExitCallback(taskId);
}
else
{
- ItemMenu_SetExitCallback(gUnknown_83E2954[itemType]);
+ ItemMenu_SetExitCallback(sExitCallbackByItemType[itemType]);
if (itemType == 1)
Bag_BeginCloseWin0Animation();
ItemMenu_StartFadeToExitCallback(taskId);
@@ -162,20 +158,20 @@ static void sub_80A103C(u8 taskId)
{
if (gTasks[taskId].data[3] != 1)
{
- gFieldCallback = sub_80A1084;
- sub_80A0FBC(taskId);
+ gFieldCallback = FieldCB_FadeInFromBlack;
+ Task_FadeOuFromBackToField(taskId);
}
else
sItemUseOnFieldCB(taskId);
}
-static void sub_80A1084(void)
+static void FieldCB_FadeInFromBlack(void)
{
FadeInFromBlack();
- CreateTask(sub_80A109C, 8);
+ CreateTask(Task_WaitFadeIn_CallItemUseOnFieldCB, 8);
}
-static void sub_80A109C(u8 taskId)
+static void Task_WaitFadeIn_CallItemUseOnFieldCB(u8 taskId)
{
if (IsWeatherNotFadingIn() == TRUE)
{
@@ -183,25 +179,25 @@ static void sub_80A109C(u8 taskId)
}
}
-static void sub_80A10C4(u8 taskId, bool8 a1, u8 a2, const u8 * str)
+static void DisplayItemMessageInCurrentContext(u8 taskId, bool8 inField, u8 textSpeed, const u8 * str)
{
StringExpandPlaceholders(gStringVar4, str);
- if (a1 == FALSE)
- DisplayItemMessageInBag(taskId, a2, gStringVar4, Task_ReturnToBagFromContextMenu);
+ if (inField == FALSE)
+ DisplayItemMessageInBag(taskId, textSpeed, gStringVar4, Task_ReturnToBagFromContextMenu);
else
- DisplayItemMessageOnField(taskId, a2, gStringVar4, sub_80A112C);
+ DisplayItemMessageOnField(taskId, textSpeed, gStringVar4, Task_ItemUse_CloseMessageBoxAndReturnToField);
}
-static void sub_80A1110(u8 taskId, bool8 a1)
+static void PrintNotTheTimeToUseThat(u8 taskId, bool8 inField)
{
- sub_80A10C4(taskId, a1, 4, gUnknown_8416425);
+ DisplayItemMessageInCurrentContext(taskId, inField, 4, gText_OakForbidsUseOfItemHere);
}
-static void sub_80A112C(u8 taskId)
+static void Task_ItemUse_CloseMessageBoxAndReturnToField(u8 taskId)
{
ClearDialogWindowAndFrame(0, 1);
DestroyTask(taskId);
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
}
@@ -267,14 +263,14 @@ void FieldUseFunc_MachBike(u8 taskId)
|| MetatileBehavior_IsHorizontalRail(behavior) == TRUE
|| MetatileBehavior_IsIsolatedVerticalRail(behavior) == TRUE
|| MetatileBehavior_IsIsolatedHorizontalRail(behavior) == TRUE)
- sub_80A10C4(taskId, gTasks[taskId].data[3], 2, gUnknown_8416451);
+ DisplayItemMessageInCurrentContext(taskId, gTasks[taskId].data[3], 2, gUnknown_8416451);
else if (Overworld_IsBikingAllowed() == TRUE && !MetatileAtPlayerPositionForbidsBiking())
{
sItemUseOnFieldCB = ItemUseOnFieldCB_Bicycle;
sub_80A103C(taskId);
}
else
- sub_80A1110(taskId, gTasks[taskId].data[3]);
+ PrintNotTheTimeToUseThat(taskId, gTasks[taskId].data[3]);
}
static void ItemUseOnFieldCB_Bicycle(u8 taskId)
@@ -282,7 +278,7 @@ static void ItemUseOnFieldCB_Bicycle(u8 taskId)
if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
PlaySE(SE_JITENSYA);
StartTransitionToFlipBikeState(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE);
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
DestroyTask(taskId);
}
@@ -295,7 +291,7 @@ void FieldUseFunc_OldRod(u8 taskId)
sub_80A103C(taskId);
}
else
- sub_80A1110(taskId, gTasks[taskId].data[3]);
+ PrintNotTheTimeToUseThat(taskId, gTasks[taskId].data[3]);
}
static bool8 ItemUseCheckFunc_Rod(void)
@@ -346,7 +342,7 @@ void FieldUseFunc_CoinCase(u8 taskId)
if (gTasks[taskId].data[3] == 0)
DisplayItemMessageInBag(taskId, 2, gStringVar4, Task_ReturnToBagFromContextMenu);
else
- DisplayItemMessageOnField(taskId, 2, gStringVar4, sub_80A112C);
+ DisplayItemMessageOnField(taskId, 2, gStringVar4, Task_ItemUse_CloseMessageBoxAndReturnToField);
}
void FieldUseFunc_PowderJar(u8 taskId)
@@ -357,7 +353,7 @@ void FieldUseFunc_PowderJar(u8 taskId)
if (gTasks[taskId].data[3] == 0)
DisplayItemMessageInBag(taskId, 2, gStringVar4, Task_ReturnToBagFromContextMenu);
else
- DisplayItemMessageOnField(taskId, 2, gStringVar4, sub_80A112C);
+ DisplayItemMessageOnField(taskId, 2, gStringVar4, Task_ItemUse_CloseMessageBoxAndReturnToField);
}
void FieldUseFunc_PokeFlute(u8 taskId)
@@ -385,7 +381,7 @@ void FieldUseFunc_PokeFlute(u8 taskId)
if (gTasks[taskId].data[3] == 0)
DisplayItemMessageInBag(taskId, 2, gUnknown_841665C, Task_ReturnToBagFromContextMenu);
else
- DisplayItemMessageOnField(taskId, 2, gUnknown_841665C, sub_80A112C);
+ DisplayItemMessageOnField(taskId, 2, gUnknown_841665C, Task_ItemUse_CloseMessageBoxAndReturnToField);
}
}
@@ -402,13 +398,13 @@ static void sub_80A1674(u8 taskId)
if (gTasks[taskId].data[3] == 0)
DisplayItemMessageInBag(taskId, 2, gUnknown_84166A7, Task_ReturnToBagFromContextMenu);
else
- DisplayItemMessageOnField(taskId, 2, gUnknown_84166A7, sub_80A112C);
+ DisplayItemMessageOnField(taskId, 2, gUnknown_84166A7, Task_ItemUse_CloseMessageBoxAndReturnToField);
}
}
static void sub_80A16D0(u8 taskId)
{
- sub_80A0FBC(taskId);
+ Task_FadeOuFromBackToField(taskId);
}
void FieldUseFunc_Medicine(u8 taskId)
@@ -444,7 +440,7 @@ void FieldUseFunc_EvoItem(u8 taskId)
void FieldUseFunc_SacredAsh(u8 taskId)
{
gItemUseCB = ItemUseCB_SacredAsh;
- sub_80A0FBC(taskId);
+ Task_FadeOuFromBackToField(taskId);
}
void FieldUseFunc_TmCase(u8 taskId)
@@ -633,7 +629,7 @@ void ItemUseOutOfBattle_EscapeRope(u8 taskId)
sub_80A103C(taskId);
}
else
- sub_80A1110(taskId, gTasks[taskId].data[3]);
+ PrintNotTheTimeToUseThat(taskId, gTasks[taskId].data[3]);
}
static void sub_80A1C08(u8 taskId)
@@ -725,7 +721,7 @@ void FieldUseFunc_VsSeeker(u8 taskId)
|| gSaveBlock1Ptr->location.mapNum == MAP_NUM(THREE_ISLAND_BERRY_FOREST)
|| gSaveBlock1Ptr->location.mapNum == MAP_NUM(SIX_ISLAND_PATTERN_BUSH))))
{
- sub_80A1110(taskId, gTasks[taskId].data[3]);
+ PrintNotTheTimeToUseThat(taskId, gTasks[taskId].data[3]);
}
else
{
@@ -734,9 +730,9 @@ void FieldUseFunc_VsSeeker(u8 taskId)
}
}
-void sub_80A1E0C(u8 taskId)
+void Task_ItemUse_CloseMessageBoxAndReturnToField_VsSeeker(u8 taskId)
{
- sub_80A112C(taskId);
+ Task_ItemUse_CloseMessageBoxAndReturnToField(taskId);
}
void BattleUseFunc_PokeBallEtc(u8 taskId)
@@ -835,7 +831,7 @@ void BattleUseFunc_PokeDoll(u8 taskId)
DisplayItemMessageInBag(taskId, 2, gStringVar4, ItemMenu_StartFadeToExitCallback);
}
else
- sub_80A1110(taskId, 0);
+ PrintNotTheTimeToUseThat(taskId, 0);
}
void ItemUseOutOfBattle_EnigmaBerry(u8 taskId)
@@ -911,11 +907,11 @@ void FieldUseFunc_OakStopsYou(u8 taskId)
{
if (GetPocketByItemId(gSpecialVar_ItemId) == POCKET_BERRY_POUCH)
{
- StringExpandPlaceholders(gStringVar4, gUnknown_8416425);
+ StringExpandPlaceholders(gStringVar4, gText_OakForbidsUseOfItemHere);
DisplayItemMessageInBerryPouch(taskId, 4, gStringVar4, Task_BerryPouch_DestroyDialogueWindowAndRefreshListMenu);
}
else
- sub_80A1110(taskId, gTasks[taskId].data[3]);
+ PrintNotTheTimeToUseThat(taskId, gTasks[taskId].data[3]);
}
void ItemUse_SetQuestLogEvent(u8 eventId, struct Pokemon * pokemon, u16 itemId, u16 param)
diff --git a/src/itemfinder.c b/src/itemfinder.c
index 19d58b471..ab455d240 100644
--- a/src/itemfinder.c
+++ b/src/itemfinder.c
@@ -1,11 +1,11 @@
#include "global.h"
+#include "gflib.h"
#include "task.h"
#include "new_menu_helpers.h"
#include "strings.h"
#include "event_scripts.h"
#include "event_object_lock.h"
#include "script.h"
-#include "sound.h"
#include "event_data.h"
#include "field_player_avatar.h"
#include "field_specials.h"
@@ -150,7 +150,7 @@ void ItemUseOnFieldCB_Itemfinder(u8 taskId)
static void Task_NoResponse_CleanUp(u8 taskId)
{
ClearDialogWindowAndFrame(0, TRUE);
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
DestroyTask(taskId);
}
@@ -486,7 +486,7 @@ static void Task_ItemfinderResponseCleanUp(u8 taskId)
{
DestroyArrowAndStarTiles();
ClearDialogWindowAndFrame(0, TRUE);
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
DestroyTask(taskId);
}
diff --git a/src/learn_move.c b/src/learn_move.c
index 8cf10cffa..d444b5d40 100644
--- a/src/learn_move.c
+++ b/src/learn_move.c
@@ -1,13 +1,9 @@
#include "global.h"
-#include "bg.h"
-#include "malloc.h"
-#include "gpu_regs.h"
-#include "palette.h"
+#include "gflib.h"
#include "script.h"
#include "task.h"
#include "data.h"
#include "trig.h"
-#include "window.h"
#include "field_fadetransition.h"
#include "overworld.h"
#include "new_menu_helpers.h"
@@ -15,10 +11,8 @@
#include "list_menu.h"
#include "event_data.h"
#include "text_window.h"
-#include "string_util.h"
#include "pokemon_summary_screen.h"
#include "graphics.h"
-#include "sound.h"
#include "strings.h"
#include "constants/songs.h"
#include "constants/moves.h"
diff --git a/src/librfu_intr.c b/src/librfu_intr.c
index 23962a937..44160acbb 100644
--- a/src/librfu_intr.c
+++ b/src/librfu_intr.c
@@ -1,4 +1,3 @@
-#include "global.h"
#include "librfu.h"
static void sio32intr_clock_master(void);
diff --git a/src/link.c b/src/link.c
index cb46a50ff..e11ba4f29 100644
--- a/src/link.c
+++ b/src/link.c
@@ -1,12 +1,9 @@
#include "global.h"
-#include "palette.h"
-#include "bg.h"
+#include "gflib.h"
#include "m4a.h"
#include "scanline_effect.h"
#include "bg_regs.h"
-#include "gpu_regs.h"
#include "decompress.h"
-#include "malloc.h"
#include "save.h"
#include "battle.h"
#include "quest_log.h"
@@ -15,16 +12,12 @@
#include "random.h"
#include "task.h"
#include "event_data.h"
-#include "string_util.h"
#include "item_menu.h"
#include "trade.h"
-#include "text.h"
-#include "sound.h"
#include "menu.h"
#include "overworld.h"
#include "new_menu_helpers.h"
#include "link.h"
-#include "window.h"
#include "graphics.h"
#include "strings.h"
#include "help_system.h"
@@ -229,7 +222,7 @@ static const u8 sLinkErrorTextColor[] = { 0x00, 0x01, 0x02 };
bool8 IsWirelessAdapterConnected(void)
{
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return FALSE;
SetWirelessCommType1();
@@ -816,7 +809,7 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper)
{
if (gLinkPlayers[0].linkType == 0x1133)
{
- switch (sub_804FB34())
+ switch (Trade_CalcLinkPlayerCompatibilityParam())
{
case 0:
sPlayerDataExchangeStatus = EXCHANGE_COMPLETE;
@@ -1006,11 +999,11 @@ bool8 SendBlock(u8 unused, const void *src, u16 size)
return InitBlockSend(src, size);
}
-bool8 sub_800A474(u8 blockRequestType)
+bool8 Link_PrepareCmd0xCCCC_Rfu0xA100(u8 blockRequestType)
{
if (gWirelessCommType == 1)
{
- return sub_80FA0F8(blockRequestType);
+ return LinkRfu_PrepareCmd0xA100(blockRequestType);
}
if (gLinkCallback == NULL)
{
diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c
index 15ffb4813..f3e7ce274 100644
--- a/src/link_rfu_2.c
+++ b/src/link_rfu_2.c
@@ -1,15 +1,13 @@
#include "global.h"
-#include "battle.h"
-#include "gpu_regs.h"
+#include "gflib.h"
#include "librfu.h"
+#include "battle.h"
#include "link.h"
#include "link_rfu.h"
#include "mystery_gift_menu.h"
#include "overworld.h"
-#include "palette.h"
#include "quest_log.h"
#include "random.h"
-#include "string_util.h"
#include "task.h"
#include "constants/species.h"
#include "constants/union_room.h"
@@ -499,7 +497,7 @@ void LinkRfu_Shutdown(void)
{
u8 i;
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return;
rfu_LMAN_powerDownRFU();
@@ -538,7 +536,7 @@ void LinkRfu_Shutdown(void)
static void CreateTask_LinkLeaderSearchForChildren(void)
{
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return;
Rfu.unk_67 = CreateTask(Task_LinkLeaderSearchForChildren, 1);
}
@@ -564,7 +562,7 @@ static bool32 IsParentSuccessfullyReconnected(void)
static void CreateTask_JoinGroupSearchForParent(void)
{
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return;
Rfu.unk_67 = CreateTask(Task_JoinGroupSearchForParent, 1);
}
@@ -1147,7 +1145,7 @@ static void RfuPrepareSendBuffer(u16 command)
break;
case RFU_COMMAND_0xa100:
if (Cmd8000recvIsFinished())
- gSendCmd[1] = Rfu.unk_5a;
+ gSendCmd[1] = Rfu.cmdA100_blockRequestType;
break;
case RFU_COMMAND_0x7700:
case RFU_COMMAND_0x7800:
@@ -1274,9 +1272,9 @@ static void RfuFunc_SendLastBlock(void)
Rfu.RfuFunc = NULL;
}
-bool8 sub_80FA0F8(u8 a0)
+bool8 LinkRfu_PrepareCmd0xA100(u8 blockRequestType)
{
- Rfu.unk_5a = a0;
+ Rfu.cmdA100_blockRequestType = blockRequestType;
RfuPrepareSendBuffer(RFU_COMMAND_0xa100);
return TRUE;
}
@@ -1286,7 +1284,7 @@ static void RfuFunc_End5F00_PowerDownRfu(void)
rfu_clearAllSlot();
rfu_LMAN_powerDownRFU();
gReceivedRemoteLinkPlayers = 0;
- Rfu.unk_ef = 1;
+ Rfu.isShuttingDown = TRUE;
Rfu.RfuFunc = NULL;
}
@@ -1454,7 +1452,7 @@ bool32 RfuSerialNumberIsValid(u32 serialNo)
return TRUE;
}
-u8 sub_80FA484(bool32 a0)
+u8 ToggleLMANlinkRecovery(bool32 a0)
{
if (!a0)
return rfu_LMAN_setLinkRecovery(0, 0);
@@ -1662,7 +1660,7 @@ static void sub_80FA834(u8 taskId)
{
if (Cmd8000recvIsFinished())
{
- Rfu.unk_5a = 0;
+ Rfu.cmdA100_blockRequestType = 0;
RfuPrepareSendBuffer(RFU_COMMAND_0xa100);
gTasks[taskId].data[0]++;
}
@@ -1881,7 +1879,7 @@ bool32 LinkRfuMain1(void)
bool32 retval = FALSE;
Rfu.parentId = 0;
rfu_LMAN_manager_entity(Random());
- if (Rfu.unk_ef == 0)
+ if (!Rfu.isShuttingDown)
{
switch (Rfu.parent_child)
{
@@ -1902,7 +1900,7 @@ bool32 LinkRfuMain1(void)
bool32 LinkRfuMain2(void)
{
bool32 retval = FALSE;
- if (Rfu.unk_ef == 0)
+ if (!Rfu.isShuttingDown)
{
if (Rfu.parent_child == MODE_PARENT)
retval = sub_80F9204();
@@ -2093,7 +2091,7 @@ static void LmanCallback_Parent2(u8 msg, u8 param_count)
case LMAN_MSG_LMAN_API_ERROR_RETURN:
RfuSetErrorStatus(1, msg);
GetLinkmanErrorParams(msg);
- Rfu.unk_ef = 1;
+ Rfu.isShuttingDown = TRUE;
break;
case LMAN_MSG_REQ_API_ERROR:
case LMAN_MSG_WATCH_DOG_TIMER_ERROR:
@@ -2166,7 +2164,7 @@ static void LmanCallback_Child(u8 msg, u8 param_count)
case LMAN_MSG_LMAN_API_ERROR_RETURN:
RfuSetErrorStatus(1, msg);
GetLinkmanErrorParams(msg);
- Rfu.unk_ef = 1;
+ Rfu.isShuttingDown = TRUE;
break;
case LMAN_MSG_REQ_API_ERROR:
case LMAN_MSG_WATCH_DOG_TIMER_ERROR:
@@ -2343,7 +2341,7 @@ static void LmanCallback_Parent(u8 msg, u8 param_count)
case LMAN_MSG_LMAN_API_ERROR_RETURN:
RfuSetErrorStatus(1, msg);
GetLinkmanErrorParams(msg);
- Rfu.unk_ef = 1;
+ Rfu.isShuttingDown = TRUE;
break;
case LMAN_MSG_REQ_API_ERROR:
case LMAN_MSG_WATCH_DOG_TIMER_ERROR:
@@ -2481,7 +2479,7 @@ void InitializeRfuLinkManager_JoinGroup(void)
void InitializeRfuLinkManager_EnterUnionRoom(void)
{
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return;
Rfu.parent_child = 2;
CopyPlayerNameToUnameBuffer();
diff --git a/src/link_rfu_3.c b/src/link_rfu_3.c
index 8382f1dab..8d34bc4e8 100644
--- a/src/link_rfu_3.c
+++ b/src/link_rfu_3.c
@@ -1,12 +1,10 @@
#include "global.h"
+#include "gflib.h"
#include "decompress.h"
#include "event_data.h"
#include "link.h"
#include "link_rfu.h"
-#include "malloc.h"
#include "random.h"
-#include "string_util.h"
-#include "text.h"
#include "constants/flags.h"
static EWRAM_DATA u8 gWirelessStatusIndicatorSpriteId = 0;
diff --git a/src/list_menu.c b/src/list_menu.c
index 9439d712c..5232708f3 100644
--- a/src/list_menu.c
+++ b/src/list_menu.c
@@ -1,16 +1,13 @@
#include "global.h"
+#include "gflib.h"
#include "menu.h"
#include "list_menu.h"
#include "menu_indicators.h"
#include "new_menu_helpers.h"
-#include "window.h"
#include "text_window.h"
-#include "main.h"
#include "task.h"
#include "graphics.h"
-#include "palette.h"
#include "strings.h"
-#include "sound.h"
#include "pokemon_icon.h"
#include "constants/songs.h"
diff --git a/src/load_save.c b/src/load_save.c
index 9dff59928..f17d31f37 100644
--- a/src/load_save.c
+++ b/src/load_save.c
@@ -1,10 +1,9 @@
#include "global.h"
+#include "gflib.h"
#include "gba/flash_internal.h"
#include "load_save.h"
-#include "main.h"
#include "pokemon.h"
#include "random.h"
-#include "malloc.h"
#include "item.h"
#include "save_location.h"
#include "berry_powder.h"
@@ -78,7 +77,7 @@ void SetSaveBlocksPointers(void)
gPokemonStoragePtr = (void*)(&gPokemonStorage) + offset;
SetBagPocketsPointers();
- sub_8110840(oldSave);
+ SetQuestLogRecordAndPlaybackPointers(oldSave);
}
void MoveSaveBlocks_ResetHeap(void)
diff --git a/src/mail.c b/src/mail.c
index 9a28fae41..0e9a8db41 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -1,12 +1,8 @@
#include "global.h"
-#include "malloc.h"
-#include "bg.h"
+#include "gflib.h"
#include "scanline_effect.h"
#include "palette.h"
-#include "gpu_regs.h"
-#include "window.h"
#include "text_window.h"
-#include "main.h"
#include "easy_chat.h"
#include "mail.h"
#include "task.h"
diff --git a/src/mail_data.c b/src/mail_data.c
index 43ca1d0e6..a032cdd95 100644
--- a/src/mail_data.c
+++ b/src/mail_data.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "text.h"
+#include "gflib.h"
#include "mail.h"
#include "mail_data.h"
#include "constants/species.h"
diff --git a/src/mailbox_pc.c b/src/mailbox_pc.c
index 5489c4c4e..ffa7ed073 100644
--- a/src/mailbox_pc.c
+++ b/src/mailbox_pc.c
@@ -1,14 +1,11 @@
#include "global.h"
-#include "malloc.h"
-#include "window.h"
+#include "gflib.h"
#include "menu.h"
-#include "string_util.h"
#include "new_menu_helpers.h"
#include "list_menu.h"
#include "player_pc.h"
#include "strings.h"
#include "menu_indicators.h"
-#include "sound.h"
#include "constants/songs.h"
static EWRAM_DATA u8 sWindowIds[3] = {};
diff --git a/src/main.c b/src/main.c
index 77f668e6f..be025c79f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,20 +1,14 @@
#include "global.h"
-#include "bg.h"
-#include "gpu_regs.h"
+#include "gflib.h"
#include "link.h"
#include "link_rfu.h"
#include "load_save.h"
-#include "main.h"
#include "m4a.h"
#include "random.h"
-#include "dma3.h"
#include "gba/flash_internal.h"
#include "help_system.h"
-#include "sound.h"
#include "new_menu_helpers.h"
-#include "malloc.h"
#include "overworld.h"
-#include "sprite.h"
#include "play_time.h"
#include "intro.h"
#include "battle_controllers.h"
@@ -176,7 +170,7 @@ static void InitMainCallbacks(void)
gSaveBlock2Ptr = &gSaveBlock2;
gSaveBlock1Ptr = &gSaveBlock1;
gSaveBlock2.encryptionKey = 0;
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
}
static void CallCallbacks(void)
diff --git a/src/main_menu.c b/src/main_menu.c
index 899119654..00ecd0fe3 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -1,14 +1,9 @@
#include "global.h"
-#include "palette.h"
-#include "gpu_regs.h"
+#include "gflib.h"
#include "scanline_effect.h"
-#include "bg.h"
-#include "dma3.h"
#include "task.h"
-#include "text.h"
#include "save.h"
#include "event_data.h"
-#include "window.h"
#include "menu.h"
#include "link.h"
#include "oak_speech.h"
@@ -16,10 +11,8 @@
#include "quest_log.h"
#include "mystery_gift_menu.h"
#include "strings.h"
-#include "sound.h"
#include "title_screen.h"
#include "help_system.h"
-#include "string_util.h"
#include "pokedex.h"
#include "text_window.h"
#include "text_window_graphics.h"
diff --git a/src/map_name_popup.c b/src/map_name_popup.c
index 6f7fa5d3c..b490722a5 100644
--- a/src/map_name_popup.c
+++ b/src/map_name_popup.c
@@ -1,16 +1,11 @@
#include "global.h"
-#include "bg.h"
-#include "gpu_regs.h"
-#include "window.h"
-#include "palette.h"
+#include "gflib.h"
#include "task.h"
#include "event_data.h"
#include "text_window.h"
#include "quest_log.h"
#include "region_map.h"
-#include "text.h"
#include "strings.h"
-#include "string_util.h"
#include "constants/flags.h"
static void Task_MapNamePopup(u8 taskId);
@@ -31,7 +26,7 @@ static u8 *MapNamePopupAppendFloorNum(u8 *dest, s8 flags);
void ShowMapNamePopup(bool32 palIntoFadedBuffer)
{
u8 taskId;
- if (FlagGet(FLAG_DONT_SHOW_MAP_NAME_POPUP) != TRUE && !(gQuestLogState == QL_STATE_2 || gQuestLogState == QL_STATE_3))
+ if (FlagGet(FLAG_DONT_SHOW_MAP_NAME_POPUP) != TRUE && !QL_IS_PLAYBACK_STATE)
{
taskId = FindTaskIdByFunc(Task_MapNamePopup);
if (taskId == 0xFF)
diff --git a/src/map_preview_screen.c b/src/map_preview_screen.c
index f3cff7882..33e69a8a0 100644
--- a/src/map_preview_screen.c
+++ b/src/map_preview_screen.c
@@ -1,11 +1,7 @@
#include "global.h"
-#include "gpu_regs.h"
-#include "bg.h"
-#include "palette.h"
-#include "malloc.h"
+#include "gflib.h"
#include "quest_log.h"
#include "new_menu_helpers.h"
-#include "window.h"
#include "region_map.h"
#include "menu.h"
#include "field_fadetransition.h"
@@ -366,7 +362,7 @@ bool8 MapHasPreviewScreen(u8 mapsec, u8 type)
bool32 MapHasPreviewScreen_HandleQLState2(u8 mapsec, u8 type)
{
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
{
return FALSE;
}
diff --git a/src/menu.c b/src/menu.c
index b7c3f54eb..03cdaed09 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1,12 +1,9 @@
#include "global.h"
-#include "bg.h"
+#include "gflib.h"
#include "menu.h"
#include "menu_helpers.h"
#include "strings.h"
#include "text_window.h"
-#include "window.h"
-#include "sound.h"
-#include "palette.h"
#include "constants/songs.h"
struct Menu
diff --git a/src/menu2.c b/src/menu2.c
index 116bf7b52..cc596dba4 100644
--- a/src/menu2.c
+++ b/src/menu2.c
@@ -1,10 +1,7 @@
#include "global.h"
-#include "text.h"
-#include "blit.h"
-#include "gpu_regs.h"
+#include "gflib.h"
#include "task.h"
#include "wild_encounter.h"
-#include "string_util.h"
#include "constants/species.h"
static void Task_SmoothBlendLayers(u8 taskId);
diff --git a/src/menu_helpers.c b/src/menu_helpers.c
index 8e63ea99d..a4794e1af 100644
--- a/src/menu_helpers.c
+++ b/src/menu_helpers.c
@@ -1,14 +1,9 @@
#include "global.h"
+#include "gflib.h"
#include "task.h"
-#include "bg.h"
-#include "gpu_regs.h"
-#include "window.h"
#include "menu.h"
#include "menu_helpers.h"
#include "new_menu_helpers.h"
-#include "string_util.h"
-#include "text.h"
-#include "sound.h"
#include "link.h"
#include "overworld.h"
#include "mail_data.h"
diff --git a/src/menu_indicators.c b/src/menu_indicators.c
index 3044fb8b4..890a5fcfa 100644
--- a/src/menu_indicators.c
+++ b/src/menu_indicators.c
@@ -1,9 +1,7 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "task.h"
#include "decompress.h"
-#include "palette.h"
-#include "sprite.h"
#include "trig.h"
#include "list_menu.h"
#include "menu_indicators.h"
diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c
index 77c839b89..4539c884b 100644
--- a/src/metatile_behavior.c
+++ b/src/metatile_behavior.c
@@ -131,51 +131,51 @@ bool8 MetatileBehavior_IsEscalator(u8 metatileBehavior)
return FALSE;
}
-bool8 MetatileBehavior_IsUnknownWarp6C(u8 metatileBehavior)
+bool8 MetatileBehavior_IsDirectionalUpRightStairWarp(u8 metatileBehavior)
{
u8 result = FALSE;
- if(metatileBehavior == MB_UNKNOWN_WARP_6C)
+ if(metatileBehavior == MB_UP_RIGHT_STAIR_WARP)
result = TRUE;
return result;
}
-bool8 MetatileBehavior_IsUnknownWarp6D(u8 metatileBehavior)
+bool8 MetatileBehavior_IsDirectionalUpLeftStairWarp(u8 metatileBehavior)
{
u8 result = FALSE;
- if(metatileBehavior == MB_UNKNOWN_WARP_6D)
+ if(metatileBehavior == MB_UP_LEFT_STAIR_WARP)
result = TRUE;
return result;
}
-bool8 MetatileBehavior_IsUnknownWarp6E(u8 metatileBehavior)
+bool8 MetatileBehavior_IsDirectionalDownRightStairWarp(u8 metatileBehavior)
{
u8 result = FALSE;
- if(metatileBehavior == MB_UNKNOWN_WARP_6E)
+ if(metatileBehavior == MB_DOWN_RIGHT_STAIR_WARP)
result = TRUE;
return result;
}
-bool8 MetatileBehavior_IsUnknownWarp6F(u8 metatileBehavior)
+bool8 MetatileBehavior_IsDirectionalDownLeftStairWarp(u8 metatileBehavior)
{
u8 result = FALSE;
- if(metatileBehavior == MB_UNKNOWN_WARP_6F)
+ if(metatileBehavior == MB_DOWN_LEFT_STAIR_WARP)
result = TRUE;
return result;
}
-bool8 MetatileBehavior_IsUnknownWarp6C_to_6F(u8 metatileBehavior)
+bool8 MetatileBehavior_IsDirectionalStairWarp(u8 metatileBehavior)
{
bool8 result = FALSE;
- if(metatileBehavior >= MB_UNKNOWN_WARP_6C && metatileBehavior <= MB_UNKNOWN_WARP_6F)
+ if(metatileBehavior >= MB_UP_RIGHT_STAIR_WARP && metatileBehavior <= MB_DOWN_LEFT_STAIR_WARP)
result = TRUE;
else
result = FALSE;
@@ -484,7 +484,7 @@ bool8 MetatileBehavior_IsDiveable(u8 metatileBehavior)
bool8 MetatileBehavior_IsUnableToEmerge(u8 metatileBehavior)
{
- if(metatileBehavior == MB_19)
+ if(metatileBehavior == MB_UNDERWATER_BLOCKED_ABOVE)
return TRUE;
else
return FALSE;
@@ -622,7 +622,7 @@ bool8 MetatileBehavior_IsLavaridgeB1FWarp(u8 metatileBehavior) { return FALSE; }
bool8 MetatileBehavior_IsLavaridge1FWarp(u8 metatileBehavior)
{
- if(metatileBehavior == MB_68)
+ if(metatileBehavior == MB_LAVARIDGE_1F_WARP)
return TRUE;
else
return FALSE;
@@ -685,7 +685,7 @@ bool8 MetatileBehavior_IsHorizontalRail(u8 metatileBehavior) { return FALSE; }
bool8 MetatileBehavior_IsSeaweed(u8 metatileBehavior)
{
- if(metatileBehavior == MB_22)
+ if(metatileBehavior == MB_SEAWEED)
return TRUE;
else
return FALSE;
diff --git a/src/mevent.c b/src/mevent.c
index 9eabcad61..469019fa6 100644
--- a/src/mevent.c
+++ b/src/mevent.c
@@ -1,10 +1,8 @@
#include "global.h"
+#include "gflib.h"
#include "constants/songs.h"
#include "constants/species.h"
-#include "malloc.h"
-#include "sound.h"
#include "easy_chat.h"
-#include "main.h"
#include "task.h"
#include "decompress.h"
#include "link.h"
@@ -15,7 +13,6 @@
#include "event_data.h"
#include "battle_tower.h"
#include "new_game.h"
-#include "string_util.h"
#include "menews_jisan.h"
#include "cereader_tool.h"
#include "mystery_gift_menu.h"
diff --git a/src/mevent_client.c b/src/mevent_client.c
index d7eff1ec6..5346a4e82 100644
--- a/src/mevent_client.c
+++ b/src/mevent_client.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "decompress.h"
#include "overworld.h"
#include "script.h"
diff --git a/src/mevent_server.c b/src/mevent_server.c
index f1505fcbc..4a6e6a19c 100644
--- a/src/mevent_server.c
+++ b/src/mevent_server.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "script.h"
#include "mevent.h"
#include "mevent_server.h"
diff --git a/src/mevent_show_card.c b/src/mevent_show_card.c
index 5f92a36bf..0452c60b9 100644
--- a/src/mevent_show_card.c
+++ b/src/mevent_show_card.c
@@ -1,14 +1,11 @@
#include "global.h"
+#include "gflib.h"
#include "constants/species.h"
-#include "bg.h"
-#include "palette.h"
#include "decompress.h"
-#include "malloc.h"
#include "menu.h"
#include "new_menu_helpers.h"
#include "pokemon_icon.h"
#include "mystery_gift_menu.h"
-#include "string_util.h"
#include "mevent.h"
#include "battle_anim.h"
diff --git a/src/minigame_countdown.c b/src/minigame_countdown.c
index 81d1cb7df..874fb2377 100644
--- a/src/minigame_countdown.c
+++ b/src/minigame_countdown.c
@@ -1,6 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "decompress.h"
-#include "sound.h"
#include "task.h"
#include "trig.h"
#include "constants/songs.h"
diff --git a/src/mon_markings.c b/src/mon_markings.c
index dfef23821..feb8a255a 100644
--- a/src/mon_markings.c
+++ b/src/mon_markings.c
@@ -1,7 +1,6 @@
#include "global.h"
-#include "dma3.h"
+#include "gflib.h"
#include "text_window_graphics.h"
-#include "sound.h"
#include "mon_markings.h"
#include "graphics.h"
#include "constants/songs.h"
diff --git a/src/money.c b/src/money.c
index 323b2e5f6..3fa52bb8c 100644
--- a/src/money.c
+++ b/src/money.c
@@ -1,7 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "event_data.h"
-#include "text.h"
-#include "string_util.h"
#include "menu.h"
#include "text_window.h"
#include "strings.h"
diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c
index 5a105bae9..1fea39b60 100644
--- a/src/mystery_event_script.c
+++ b/src/mystery_event_script.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "gflib.h"
#include "berry.h"
#include "battle_tower.h"
#include "easy_chat.h"
@@ -6,13 +7,10 @@
#include "mail_data.h"
#include "mystery_event_script.h"
#include "pokedex.h"
-#include "pokemon.h"
#include "pokemon_size_record.h"
#include "script.h"
#include "constants/species.h"
#include "strings.h"
-#include "string_util.h"
-#include "text.h"
#include "util.h"
#include "mystery_event_msg.h"
#include "pokemon_storage_system.h"
diff --git a/src/mystery_gift_menu.c b/src/mystery_gift_menu.c
index cdfd62624..a207cee96 100644
--- a/src/mystery_gift_menu.c
+++ b/src/mystery_gift_menu.c
@@ -1,21 +1,14 @@
#include "global.h"
-#include "palette.h"
-#include "gpu_regs.h"
-#include "bg.h"
+#include "gflib.h"
#include "task.h"
#include "scanline_effect.h"
-#include "malloc.h"
-#include "text.h"
-#include "window.h"
#include "text_window.h"
#include "menu.h"
#include "new_menu_helpers.h"
-#include "sound.h"
#include "mystery_gift_menu.h"
#include "title_screen.h"
#include "list_menu.h"
#include "link_rfu.h"
-#include "string_util.h"
#include "mevent.h"
#include "save.h"
#include "link.h"
@@ -398,7 +391,7 @@ bool32 HandleMysteryGiftOrEReaderSetup(s32 mg_or_ereader)
SetBgTilemapBuffer(0, Alloc(0x800));
LoadUserWindowBorderGfx(0, 10, 0xE0);
- sub_814FDA0(0, 1, 0xF0);
+ DrawWindowBorderWithStdpal3(0, 1, 0xF0);
DecompressAndLoadBgGfxUsingHeap(3, gUnkTextboxBorderGfx, 0x100, 0, 0);
InitWindows(sMainWindows);
DeactivateAllTextPrinters();
diff --git a/src/new_game.c b/src/new_game.c
index d03e83b34..bc7763fd9 100644
--- a/src/new_game.c
+++ b/src/new_game.c
@@ -1,6 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "random.h"
-#include "main.h"
#include "overworld.h"
#include "constants/maps.h"
#include "load_save.h"
@@ -10,7 +10,6 @@
#include "quest_log.h"
#include "wild_encounter.h"
#include "event_data.h"
-#include "string_util.h"
#include "mail_data.h"
#include "play_time.h"
#include "money.h"
diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c
index 78bc6b7a4..9da0dea80 100644
--- a/src/new_menu_helpers.c
+++ b/src/new_menu_helpers.c
@@ -1,18 +1,13 @@
#include "global.h"
-#include "malloc.h"
-#include "dma3.h"
-#include "task.h"
-#include "bg.h"
-#include "window.h"
+#include "gflib.h"
+#include "help_message.h"
#include "menu.h"
#include "menu_helpers.h"
#include "new_menu_helpers.h"
#include "quest_log.h"
-#include "text.h"
#include "field_specials.h"
#include "text_window.h"
#include "script.h"
-#include "palette.h"
#define DLG_WINDOW_PALETTE_NUM 15
#define DLG_WINDOW_BASE_TILE_NUM 0x200
@@ -457,7 +452,7 @@ void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonP
void LoadStdWindowFrameGfx(void)
{
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
{
gTextFlags.autoScroll = 1;
TextWindow_LoadTilesStdFrame1(0, DLG_WINDOW_BASE_TILE_NUM);
@@ -495,7 +490,7 @@ void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram)
ClearWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
CommitQuestLogWindow1();
}
@@ -527,7 +522,7 @@ static void WindowFunc_DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u
static void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
- if (!IsMsgSignPost() || gQuestLogState == QL_STATE_2)
+ if (!IsMsgSignPost() || gQuestLogState == QL_STATE_PLAYBACK)
{
FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 0, tilemapLeft - 2, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM);
FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 1, tilemapLeft - 1, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM);
@@ -611,7 +606,7 @@ void SetStdWindowBorderStyle(u8 windowId, bool8 copyToVram)
void sub_80F7768(u8 windowId, bool8 copyToVram)
{
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
{
gTextFlags.autoScroll = 1;
TextWindow_LoadTilesStdFrame1(0, DLG_WINDOW_BASE_TILE_NUM);
@@ -645,10 +640,10 @@ static u16 GetStdPalColor(u8 colorNum)
return gTMCaseMainWindowPalette[colorNum];
}
-void DisplayItemMessageOnField(u8 taskId, u8 bgId, const u8 *string, TaskFunc callback)
+void DisplayItemMessageOnField(u8 taskId, u8 textSpeed, const u8 *string, TaskFunc callback)
{
LoadStdWindowFrameGfx();
- DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, bgId, GetTextSpeedSetting(), string, callback);
+ DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, textSpeed, GetTextSpeedSetting(), string, callback);
CopyWindowToVram(0, 3);
}
diff --git a/src/normal.c b/src/normal.c
index 366219c72..5a4d98907 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -1,6 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "battle_anim.h"
-#include "palette.h"
#include "random.h"
#include "task.h"
#include "trig.h"
diff --git a/src/oak_speech.c b/src/oak_speech.c
index 91fe117f1..3d0c656d7 100644
--- a/src/oak_speech.c
+++ b/src/oak_speech.c
@@ -1,23 +1,14 @@
#include "global.h"
-#include "main.h"
+#include "gflib.h"
#include "decompress.h"
#include "task.h"
-#include "malloc.h"
-#include "gpu_regs.h"
-#include "palette.h"
#include "blend_palette.h"
-#include "text.h"
-#include "window.h"
#include "text_window.h"
-#include "bg.h"
#include "menu.h"
#include "help_system.h"
#include "new_menu_helpers.h"
-#include "pokemon.h"
-#include "sound.h"
#include "event_scripts.h"
#include "scanline_effect.h"
-#include "string_util.h"
#include "pokeball.h"
#include "naming_screen.h"
#include "math_util.h"
diff --git a/src/option_menu.c b/src/option_menu.c
index 54cca0501..5a7bc42e4 100644
--- a/src/option_menu.c
+++ b/src/option_menu.c
@@ -1,20 +1,13 @@
#include "global.h"
-#include "gpu_regs.h"
+#include "gflib.h"
#include "scanline_effect.h"
#include "text_window_graphics.h"
#include "menu.h"
#include "menu_helpers.h"
#include "task.h"
-#include "palette.h"
#include "overworld.h"
-#include "malloc.h"
#include "help_system.h"
-#include "main.h"
-#include "bg.h"
-#include "window.h"
-#include "text.h"
#include "text_window.h"
-#include "string_util.h"
#include "strings.h"
#include "field_fadetransition.h"
#include "gba/m4a_internal.h"
@@ -352,7 +345,7 @@ static bool8 LoadOptionMenuPalette(void)
LoadPalette(stdpal_get(2), 0xF0, 0x20);
break;
case 3:
- sub_814FDA0(1, 0x1B3, 0x30);
+ DrawWindowBorderWithStdpal3(1, 0x1B3, 0x30);
break;
default:
return TRUE;
diff --git a/src/overworld.c b/src/overworld.c
index a4a6213e6..f36429dde 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -160,9 +160,9 @@ static void SetCameraToTrackGuestPlayer_2(void);
static void sub_8057178(void);
static void sub_80571A8(void);
static void CreateLinkPlayerSprites(void);
-static void sub_80572D8(void);
-static void sub_8057300(u8 *state);
-static bool32 sub_8057314(u8 *state);
+static void CB2_LoadMapForQLPlayback(void);
+static void DoLoadMap_QLPlayback(u8 *state);
+static bool32 LoadMap_QLPlayback(u8 *state);
static bool32 SetUpScrollSceneForCredits(u8 *state, u8 unused);
static bool8 MapLdr_Credits(void);
static void CameraCB_CreditsPan(struct CameraObject * camera);
@@ -340,7 +340,7 @@ static void Overworld_ResetStateAfterWhitingOut(void)
VarSet(VAR_0x404D, 0);
}
-static void sub_8054E40(void)
+static void Overworld_ResetStateOnContinue(void)
{
FlagClear(FLAG_SYS_SAFARI_MODE);
VarSet(VAR_MAP_SCENE_FUCHSIA_CITY_SAFARI_ZONE_ENTRANCE, 0);
@@ -763,7 +763,7 @@ void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum)
ClearTempFieldEventData();
ResetCyclingRoadChallengeData();
RestartWildEncounterImmunitySteps();
- TryUpdateRandomTrainerRematches(mapGroup, mapNum);
+ MapResetTrainerRematches(mapGroup, mapNum);
SetSav1WeatherFromCurrMapHeader();
ChooseAmbientCrySpecies();
SetDefaultFlashLevel();
@@ -798,7 +798,7 @@ static void mli0_load_map(bool32 a1)
ClearTempFieldEventData();
ResetCyclingRoadChallengeData();
RestartWildEncounterImmunitySteps();
- TryUpdateRandomTrainerRematches(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
+ MapResetTrainerRematches(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
SetSav1WeatherFromCurrMapHeader();
ChooseAmbientCrySpecies();
if (isOutdoors)
@@ -921,9 +921,9 @@ static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStr
return DIR_EAST;
else if (MetatileBehavior_IsEastArrowWarp(metatileBehavior) == TRUE)
return DIR_WEST;
- else if (MetatileBehavior_IsUnknownWarp6C(metatileBehavior) == TRUE || MetatileBehavior_IsUnknownWarp6E(metatileBehavior) == TRUE)
+ else if (MetatileBehavior_IsDirectionalUpRightStairWarp(metatileBehavior) == TRUE || MetatileBehavior_IsDirectionalDownRightStairWarp(metatileBehavior) == TRUE)
return DIR_WEST;
- else if (MetatileBehavior_IsUnknownWarp6D(metatileBehavior) == TRUE || MetatileBehavior_IsUnknownWarp6F(metatileBehavior) == TRUE)
+ else if (MetatileBehavior_IsDirectionalUpLeftStairWarp(metatileBehavior) == TRUE || MetatileBehavior_IsDirectionalDownLeftStairWarp(metatileBehavior) == TRUE)
return DIR_EAST;
else if ((playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER && transitionFlags == PLAYER_AVATAR_FLAG_SURFING)
|| (playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_SURFING && transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER ))
@@ -979,7 +979,7 @@ void SetCurrentMapLayout(u16 mapLayoutId)
gMapHeader.mapLayout = GetMapLayout();
}
-void sub_8055D5C(struct WarpData * warp)
+void Overworld_SetWarpDestinationFromWarp(struct WarpData * warp)
{
sWarpDestination = *warp;
}
@@ -1406,7 +1406,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
{
if (ProcessPlayerFieldInput(&fieldInput) == TRUE)
{
- if (gUnknown_3005E88 == 2)
+ if (gQuestLogPlaybackState == 2)
sub_81127F8(&gInputToStoreInQuestLogMaybe);
ScriptContext2_Enable();
DismissMapNamePopup();
@@ -1441,7 +1441,7 @@ static void DoCB1_Overworld_QuestLogPlayback(void)
RunQuestLogCB();
}
}
- else if (sub_8111CD0() == TRUE)
+ else if (QuestLogScenePlaybackIsEnding() == TRUE)
{
RunQuestLogCB();
}
@@ -1452,7 +1452,7 @@ void CB1_Overworld(void)
{
if (gMain.callback2 == CB2_Overworld)
{
- if (sub_8112CAC() == TRUE || gQuestLogState == QL_STATE_2)
+ if (sub_8112CAC() == 1 || gQuestLogState == QL_STATE_PLAYBACK)
DoCB1_Overworld_QuestLogPlayback();
else
DoCB1_Overworld(gMain.newKeys, gMain.heldKeys);
@@ -1555,7 +1555,7 @@ void CB2_WhiteOut(void)
gFieldCallback = FieldCB_RushInjuredPokemonToCenter;
val = 0;
do_load_map_stuff_loop(&val);
- QuestLog_OnInteractionWithSpecialNpc();
+ QuestLog_CutRecording();
SetFieldVBlankCallback();
SetMainCallback1(CB1_Overworld);
SetMainCallback2(CB2_Overworld);
@@ -1575,9 +1575,9 @@ void CB2_LoadMap(void)
static void CB2_LoadMap2(void)
{
do_load_map_stuff_loop(&gMain.state);
- if (sub_8113748() == TRUE)
+ if (QuestLog_ShouldEndSceneOnMapChange() == TRUE)
{
- sub_81119C8();
+ QuestLog_AdvancePlayhead_();
}
else
{
@@ -1671,14 +1671,14 @@ void CB2_ReturnToFieldContinueScriptPlayMapMusic(void)
CB2_ReturnToField();
}
-void sub_80568FC(void)
+void CB2_ReturnToFieldFromDiploma(void)
{
FieldClearVBlankHBlankCallbacks();
gFieldCallback = FieldCB_WarpExitFadeFromBlack;
CB2_ReturnToField();
}
-static void sub_8056918(void)
+static void FieldCB_ShowMapNameOnContinue(void)
{
if (SHOW_MAP_NAME_ENABLED)
ShowMapNamePopup(FALSE);
@@ -1693,7 +1693,7 @@ void CB2_ContinueSavedGame(void)
LoadSaveblockMapHeader();
LoadSaveblockObjEventScripts();
UnfreezeObjectEvents();
- sub_8054E40();
+ Overworld_ResetStateOnContinue();
InitMapFromSavedGame();
PlayTimeCounter_Start();
ScriptContext1_Init();
@@ -1709,7 +1709,7 @@ void CB2_ContinueSavedGame(void)
}
else
{
- gFieldCallback = sub_8056918;
+ gFieldCallback = FieldCB_ShowMapNameOnContinue;
SetMainCallback1(CB1_Overworld);
CB2_ReturnToField();
}
@@ -1861,14 +1861,14 @@ static bool32 load_map_stuff(u8 *state, bool32 a1)
(*state)++;
break;
case 3:
- if (sub_8113748() == TRUE)
+ if (QuestLog_ShouldEndSceneOnMapChange() == TRUE)
return TRUE;
(*state)++;
break;
case 4:
mli4_mapscripts_and_other();
sub_8057114();
- if (gQuestLogState != QL_STATE_2)
+ if (gQuestLogState != QL_STATE_PLAYBACK)
{
sub_80CC534();
sub_80CC59C();
@@ -2205,7 +2205,7 @@ static void CreateLinkPlayerSprites(void)
// Quest Log
-void sub_805726C(void)
+void CB2_SetUpOverworldForQLPlaybackWithWarpExit(void)
{
FieldClearVBlankHBlankCallbacks();
gUnknown_2036E28 = 1;
@@ -2213,10 +2213,10 @@ void sub_805726C(void)
ScriptContext2_Disable();
SetMainCallback1(NULL);
SetMainCallback2(CB2_DoChangeMap);
- gMain.savedCallback = sub_80572D8;
+ gMain.savedCallback = CB2_LoadMapForQLPlayback;
}
-void sub_80572A8(void)
+void CB2_SetUpOverworldForQLPlayback(void)
{
FieldClearVBlankHBlankCallbacks();
gUnknown_2036E28 = 1;
@@ -2224,24 +2224,24 @@ void sub_80572A8(void)
ScriptContext1_Init();
ScriptContext2_Disable();
SetMainCallback1(NULL);
- SetMainCallback2(sub_80572D8);
+ SetMainCallback2(CB2_LoadMapForQLPlayback);
}
-static void sub_80572D8(void)
+static void CB2_LoadMapForQLPlayback(void)
{
- sub_8057300(&gMain.state);
+ DoLoadMap_QLPlayback(&gMain.state);
SetFieldVBlankCallback();
SetMainCallback1(CB1_Overworld);
SetMainCallback2(CB2_Overworld);
}
-static void sub_8057300(u8 *state)
+static void DoLoadMap_QLPlayback(u8 *state)
{
- while (!sub_8057314(state))
+ while (!LoadMap_QLPlayback(state))
;
}
-static bool32 sub_8057314(u8 *state)
+static bool32 LoadMap_QLPlayback(u8 *state)
{
switch (*state)
{
@@ -2251,7 +2251,7 @@ static bool32 sub_8057314(u8 *state)
sub_8111F14();
sub_81113E4();
sub_8111438();
- if (sub_8110AC8() == 2)
+ if (GetQuestLogStartType() == QL_START_WARP)
{
gUnknown_2031DE0 = FALSE;
mli0_load_map(FALSE);
@@ -2317,7 +2317,7 @@ static bool32 sub_8057314(u8 *state)
return FALSE;
}
-void sub_8057430(void)
+void CB2_EnterFieldFromQuestLog(void)
{
FieldClearVBlankHBlankCallbacks();
StopMapMusic();
@@ -2326,7 +2326,7 @@ void sub_8057430(void)
LoadSaveblockMapHeader();
LoadSaveblockObjEventScripts();
UnfreezeObjectEvents();
- sub_8054E40();
+ Overworld_ResetStateOnContinue();
InitMapFromSavedGame();
PlayTimeCounter_Start();
ScriptContext1_Init();
diff --git a/src/palette.c b/src/palette.c
index 04638f6d1..014199a7a 100644
--- a/src/palette.c
+++ b/src/palette.c
@@ -1,8 +1,7 @@
#include "global.h"
-#include "palette.h"
+#include "gflib.h"
#include "util.h"
#include "decompress.h"
-#include "gpu_regs.h"
#include "task.h"
enum
diff --git a/src/party_menu.c b/src/party_menu.c
index 306a5ce70..93c6c6398 100644
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -19,6 +19,7 @@
#include "fieldmap.h"
#include "fldeff.h"
#include "graphics.h"
+#include "help_message.h"
#include "help_system.h"
#include "item.h"
#include "item_menu.h"
diff --git a/src/party_menu_specials.c b/src/party_menu_specials.c
index 48406da9a..56e3373ec 100644
--- a/src/party_menu_specials.c
+++ b/src/party_menu_specials.c
@@ -1,14 +1,12 @@
#include "global.h"
+#include "gflib.h"
#include "data.h"
#include "script.h"
#include "overworld.h"
-#include "palette.h"
-#include "pokemon.h"
#include "party_menu.h"
#include "field_fadetransition.h"
#include "pokemon_summary_screen.h"
#include "event_data.h"
-#include "string_util.h"
#include "constants/moves.h"
static void sub_80BF97C(u8 taskId);
diff --git a/src/pc_screen_effect.c b/src/pc_screen_effect.c
index 5ee8e2b7b..5b5952c26 100644
--- a/src/pc_screen_effect.c
+++ b/src/pc_screen_effect.c
@@ -1,7 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "task.h"
-#include "gpu_regs.h"
-#include "palette.h"
/*
* Animates the screen as though it was a CRT monitor turning on or off.
diff --git a/src/player_pc.c b/src/player_pc.c
index 736c67a51..1c6c9c3d4 100644
--- a/src/player_pc.c
+++ b/src/player_pc.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "palette.h"
+#include "gflib.h"
#include "item.h"
#include "task.h"
#include "menu_indicators.h"
@@ -9,7 +9,6 @@
#include "mail.h"
#include "mail_data.h"
#include "help_system.h"
-#include "sound.h"
#include "overworld.h"
#include "script.h"
#include "mailbox_pc.h"
@@ -17,7 +16,6 @@
#include "field_weather.h"
#include "event_scripts.h"
#include "field_fadetransition.h"
-#include "string_util.h"
#include "item_menu.h"
#include "item_pc.h"
#include "party_menu.h"
diff --git a/src/pokeball.c b/src/pokeball.c
index 92b22abe6..4b908ddea 100644
--- a/src/pokeball.c
+++ b/src/pokeball.c
@@ -1,14 +1,11 @@
#include "global.h"
+#include "gflib.h"
#include "battle.h"
#include "battle_anim.h"
#include "decompress.h"
#include "graphics.h"
-#include "main.h"
#include "m4a.h"
#include "pokeball.h"
-#include "pokemon.h"
-#include "sound.h"
-#include "sprite.h"
#include "task.h"
#include "trig.h"
#include "util.h"
diff --git a/src/pokedex_area_markers.c b/src/pokedex_area_markers.c
index 3ff2aa496..a47d6876d 100644
--- a/src/pokedex_area_markers.c
+++ b/src/pokedex_area_markers.c
@@ -1,9 +1,6 @@
#include "global.h"
-#include "malloc.h"
-#include "bg.h"
+#include "gflib.h"
#include "decompress.h"
-#include "gpu_regs.h"
-#include "palette.h"
#include "task.h"
#include "wild_pokemon_area.h"
#include "pokedex_area_markers.h"
diff --git a/src/pokedex_screen.c b/src/pokedex_screen.c
index 0219ca466..d80a2eefa 100644
--- a/src/pokedex_screen.c
+++ b/src/pokedex_screen.c
@@ -1,17 +1,10 @@
#include "global.h"
-#include "bg.h"
-#include "malloc.h"
-#include "palette.h"
+#include "gflib.h"
#include "graphics.h"
-#include "dma3.h"
-#include "gpu_regs.h"
#include "m4a.h"
#include "scanline_effect.h"
#include "task.h"
-#include "text.h"
-#include "window.h"
#include "new_menu_helpers.h"
-#include "sound.h"
#include "event_data.h"
#include "help_system.h"
#include "menu_indicators.h"
@@ -21,7 +14,6 @@
#include "pokedex_screen.h"
#include "data.h"
#include "pokedex.h"
-#include "string_util.h"
#include "trainer_pokemon_sprites.h"
#include "constants/songs.h"
#include "constants/species.h"
diff --git a/src/pokemon.c b/src/pokemon.c
index 4c5a3e867..c85c7772c 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -1,12 +1,10 @@
#define IS_POKEMON_C
#include "global.h"
-#include "pokemon.h"
+#include "gflib.h"
#include "random.h"
-#include "main.h"
#include "text.h"
#include "data.h"
-#include "string_util.h"
#include "battle.h"
#include "battle_anim.h"
#include "item.h"
@@ -20,10 +18,8 @@
#include "battle_util.h"
#include "link.h"
#include "m4a.h"
-#include "sound.h"
#include "pokedex.h"
#include "strings.h"
-#include "malloc.h"
#include "overworld.h"
#include "party_menu.h"
#include "field_specials.h"
diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c
index 4c7681231..133caeb63 100644
--- a/src/pokemon_icon.c
+++ b/src/pokemon_icon.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "palette.h"
+#include "gflib.h"
#include "mail_data.h"
#include "pokemon_icon.h"
#include "graphics.h"
diff --git a/src/pokemon_jump_4.c b/src/pokemon_jump_4.c
index c125734a3..123aafdc1 100644
--- a/src/pokemon_jump_4.c
+++ b/src/pokemon_jump_4.c
@@ -220,7 +220,7 @@ static void sub_8149DC8(void)
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
sub_814A84C();
sub_814AA24(0);
- sub_814FDA0(0, 1, 0xE0);
+ DrawWindowBorderWithStdpal3(0, 1, 0xE0);
LoadUserWindowBorderGfx(0, 0x00A, 0xD0);
CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(2);
diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c
index 66bdb9194..6041ce7ff 100644
--- a/src/pokemon_size_record.c
+++ b/src/pokemon_size_record.c
@@ -1,9 +1,8 @@
#include "global.h"
+#include "gflib.h"
#include "data.h"
#include "event_data.h"
#include "pokedex.h"
-#include "pokemon.h"
-#include "string_util.h"
#include "text.h"
#include "strings.h"
#include "constants/species.h"
diff --git a/src/psychic.c b/src/psychic.c
index 722ea014f..eb3522188 100644
--- a/src/psychic.c
+++ b/src/psychic.c
@@ -1,8 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "battle_anim.h"
-#include "gpu_regs.h"
-#include "palette.h"
-#include "sound.h"
#include "scanline_effect.h"
#include "trig.h"
#include "constants/songs.h"
diff --git a/src/quest_log.c b/src/quest_log.c
index 5dc9f7f11..2ba377bd9 100644
--- a/src/quest_log.c
+++ b/src/quest_log.c
@@ -1,18 +1,10 @@
#include "global.h"
-#include "data.h"
-#include "malloc.h"
-#include "main.h"
+#include "gflib.h"
#include "task.h"
-#include "palette.h"
#include "menu.h"
-#include "random.h"
#include "menu_helpers.h"
-#include "window.h"
#include "text_window.h"
-#include "dynamic_placeholder_text_util.h"
#include "event_data.h"
-#include "event_scripts.h"
-#include "string_util.h"
#include "script.h"
#include "overworld.h"
#include "field_fadetransition.h"
@@ -20,16 +12,13 @@
#include "event_object_movement.h"
#include "event_object_lock.h"
#include "field_player_avatar.h"
-#include "battle.h"
#include "item.h"
#include "region_map.h"
#include "map_name_popup.h"
#include "wild_encounter.h"
#include "help_system.h"
-#include "party_menu.h"
#include "pokemon_storage_system.h"
#include "save.h"
-#include "link.h"
#include "quest_log_objects.h"
#include "quest_log_player.h"
#include "quest_log.h"
@@ -37,11 +26,8 @@
#include "strings.h"
#include "constants/event_objects.h"
#include "constants/maps.h"
-#include "constants/party_menu.h"
#include "constants/quest_log.h"
-#include "constants/trainer_classes.h"
#include "constants/species.h"
-#include "constants/items.h"
#include "constants/field_weather.h"
#include "constants/event_object_movement.h"
@@ -60,44 +46,27 @@ struct TrainerFanClub
struct UnkStruct_203AE94
{
- u8 unk_0_0:4;
- u8 unk_0_4:2;
- u8 unk_0_6:2;
- u8 unk_1;
- u8 unk_2;
- u8 unk_3;
+ u8 playbackSubstate:4;
+ u8 playingEvent:2;
+ u8 sceneEndMode:2;
+ u8 cursor;
+ u8 timer;
+ u8 overlapTimer;
};
-struct QuestLogEntry
-{
- u8 unk_0;
- u8 unk_1;
- u8 unk_2;
- u8 unk_3;
- u16 unk_4;
- u8 unk_6;
-};
-
-struct UnkStruct_300201C
+struct FlagOrVarRecord
{
u16 idx:15;
u16 isFlag:1;
u16 value;
};
-struct UnkStruct_203B044
-{
- u8 unk_0;
- u8 unk_1;
- u16 unk_2;
-};
-
-u8 gUnknown_3005E88;
+u8 gQuestLogPlaybackState;
u16 sNumEventsInLogEntry;
struct FieldInput gQuestLogFieldInput;
struct QuestLogEntry * sCurQuestLogEntry;
-static struct UnkStruct_300201C * sFlagOrVarRecords;
+static struct FlagOrVarRecord * sFlagOrVarRecords;
static u16 sNumFlagsOrVars;
static EWRAM_DATA u8 sCurrentSceneNum = 0;
@@ -105,28 +74,21 @@ static EWRAM_DATA u8 sNumScenes = 0;
EWRAM_DATA u8 gQuestLogState = 0;
static EWRAM_DATA u16 gUnknown_203ADFC = 0;
static EWRAM_DATA u8 sQuestLogHeaderWindowIds[3] = {0};
-static EWRAM_DATA u16 *gUnknown_203AE04 = NULL;
-static EWRAM_DATA u16 *sEventRecordingPointer = NULL;
+EWRAM_DATA u16 *gUnknown_203AE04 = NULL;
+EWRAM_DATA u16 *sEventRecordingPointer = NULL;
static EWRAM_DATA u16 *gUnknown_203AE0C[32] = {NULL};
static EWRAM_DATA void (* sQuestLogCB)(void) = NULL;
static EWRAM_DATA u16 *gUnknown_203AE90 = NULL;
-static EWRAM_DATA struct UnkStruct_203AE94 gUnknown_203AE94 = {0};
+static EWRAM_DATA struct UnkStruct_203AE94 sQuestLogCurrentScene = {0};
static EWRAM_DATA struct QuestLogEntry sQuestLogSceneRecordBuffer[32] = {0};
-static EWRAM_DATA u16 sQuestLogCursor = 0;
+EWRAM_DATA u16 sQuestLogCursor = 0;
static EWRAM_DATA u8 sMovementScripts[64][2] = {{0}};
static EWRAM_DATA u16 sNextStepDelay = 0;
-static EWRAM_DATA u16 gUnknown_203B01C = 0;
+static EWRAM_DATA u16 sLastQuestLogCursor = 0;
static EWRAM_DATA u16 sFlagOrVarPlayhead = 0;
-static EWRAM_DATA u8 sHelpMessageWindowId = 0;
-static EWRAM_DATA struct UnkStruct_203B024 gUnknown_203B024 = {0};
-static EWRAM_DATA struct UnkStruct_203B044 gUnknown_203B044 = {0};
-static EWRAM_DATA u8 gUnknown_203B048 = 0;
-static EWRAM_DATA bool8 sNewlyEnteredMap = FALSE;
-static EWRAM_DATA u8 gUnknown_203B04A = 0;
-static EWRAM_DATA bool8 gUnknown_203B04B = FALSE;
-
-static void sub_8110A00(void);
-static void sub_8110A3C(void);
+
+static void QLogCB_Recording(void);
+static void QLogCB_Playback(void);
static void SetPlayerInitialCoordsAtScene(u8);
static void SetNPCInitialCoordsAtScene(u8);
static void TryRecordEvent39_GoToNextScene(void);
@@ -134,36 +96,36 @@ static void BackUpTrainerRematchesToVars(void);
static void BackUpMapLayoutToVar(void);
static void SetGameStateAtScene(u8);
static u8 TryRecordQuestLogEntrySequence(struct QuestLogEntry *);
-static void sub_8110F90(u8);
+static void Task_BeginQuestLogPlayback(u8);
static void QuestLogPlaybackSetObjectEventTemplates(u8);
-static void sub_8111368(void);
+static void QLPlayback_InitOverworldState(void);
static void QuestLog_GetSaneMonCounts(void);
static u16 QuestLog_GetSanePartyCount(void);
static u16 QuestLog_GetSaneBoxCount(void);
static void sub_8111688(void);
-static void sub_811175C(u8, struct QuestLogEntry *);
-static void sub_81118F4(s8);
+static void ReadQuestLogScriptFromSav1(u8, struct QuestLogEntry *);
+static void QuestLog_BeginFadeAtEndOfScene(s8 delay);
static void QuestLog_AdvancePlayhead(void);
static void QuestLog_StartFinalScene(void);
static void Task_RunPlaybackCB(u8);
-static void sub_8111AD8(void);
-static void sub_8111B80(void);
-static u8 sub_8111BD4(void);
+static void QuestLog_PlayCurrentEvent(void);
+static void HandleShowQuestLogMessage(void);
+static u8 GetQuestLogTextDisplayDuration(void);
static void DrawQuestLogSceneDescription(void);
static void sub_8111D90(u8);
static void QuestLog_CloseTextWindow(void);
static void QuestLog_SkipToEndOfPlayback(s8 delay);
static void QuestLog_WaitFadeAndCancelPlayback(void);
-static bool8 sub_8111F60(void);
-static void sub_8111F8C(u8);
+static bool8 FieldCB2_FinalScene(void);
+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 void sub_811229C(void);
-static void sub_8112888(u8);
+static void TogglePlaybackStateForOverworldLock(u8);
static void SetUpQuestLogEntry(u8, struct QuestLogEntry *, u16);
-static bool8 sub_8112CEC(void);
+static bool8 RecordHeadAtEndOfEntryOrScriptContext2Enabled(void);
static bool8 RecordHeadAtEndOfEntry(void);
static void TryLoseFansFromPlayTimeAfterLinkBattle(struct TrainerFanClub *);
static void UpdateTrainerFanClubGameClear(struct TrainerFanClub *);
@@ -182,104 +144,6 @@ static bool8 sub_81137E4(u16, const u16 *);
static u16 *sub_8113828(u16, const u16 *);
static bool8 TrySetLinkQuestLogEvent(u16, const u16 *);
static bool8 TrySetTrainerBattleQuestLogEvent(u16, const u16 *);
-static void TryRecordEvent41_IncCursor(u16);
-static void sub_811381C(void);
-static bool8 IsQuestLogEventWithSpecialEncounterSpecies(u16, const u16 *);
-static u16 *QuestLog_SkipCommand(u16 *, u16 **);
-static void sub_8113ABC(const u16 *);
-static bool8 sub_8113AE8(const u16 *);
-static bool8 sub_8113B44(const u16 *);
-static void sub_8113B88(void);
-static void sub_8113B94(u16);
-static void sub_8113BD8(void);
-static u16 *TryRecordEvent39_NoParams(u16 *);
-static u16 *sub_8113C20(u16 *, struct QuestLogEntry *);
-static u16 *TryRecordEvent41(u16 *, u16);
-static u16 *sub_8113C8C(u16 *, struct QuestLogEntry *);
-static u16 *sub_8113CC8(u16 *, struct QuestLogEntry *);
-static u16 *sub_8113D08(u16 *, struct QuestLogEntry *);
-static u16 *sub_8113D48(u16 *, struct QuestLogEntry *);
-static u16 *sub_8113D94(u16 *, struct QuestLogEntry *);
-static u16 *BufferQuestLogData_SwitchedPartyOrder(u16 *, const u16 *);
-static u16 *BufferQuestLogData_UsedItem(u16 *, const u16 *);
-static u16 *BufferQuestLogData_GaveHeldItemFromPartyMenu(u16 *, const u16 *);
-static u16 *BufferQuestLogData_GaveHeldItemFromBagMenu(u16 *, const u16 *);
-static u16 *BufferQuestLogData_GaveHeldItemFromPC(u16 *, const u16 *);
-static u16 *BufferQuestLogData_TookHeldItem(u16 *, const u16 *);
-static u16 *BufferQuestLogData_SwappedHeldItem(u16 *, const u16 *);
-static u16 *BufferQuestLogData_SwappedHeldItemFromPC(u16 *, const u16 *);
-static u16 *BufferQuestLogData_UsedPkmnCenter(u16 *, const u16 *);
-static u16 *BufferQuestLogData_LinkTraded(u16 *, const u16 *);
-static u16 *BufferQuestLogData_LinkBattledSingle(u16 *, const u16 *);
-static u16 *BufferQuestLogData_LinkBattledDouble(u16 *, const u16 *);
-static u16 *BufferQuestLogData_LinkBattledMulti(u16 *, const u16 *);
-static u16 *BufferQuestLogData_UsedUnionRoom(u16 *, const u16 *);
-static u16 *BufferQuestLogData_UsedUnionRoomChat(u16 *, const u16 *);
-static u16 *BufferQuestLogData_LinkTradedUnionRoom(u16 *, const u16 *);
-static u16 *BufferQuestLogData_LinkBattledUnionRoom(u16 *, const u16 *);
-static u16 *BufferQuestLogData_SwitchedMonsBetweenBoxes(u16 *, const u16 *);
-static u16 *BufferQuestLogData_SwitchedMonsWithinBox(u16 *, const u16 *);
-static u16 *BufferQuestLogData_SwitchedPartyMonForPCMon(u16 *, const u16 *);
-static u16 *BufferQuestLogData_MovedMonBetweenBoxes(u16 *, const u16 *);
-static u16 *BufferQuestLogData_MovedMonWithinBox(u16 *, const u16 *);
-static u16 *BufferQuestLogData_WithdrewMonFromPC(u16 *, const u16 *);
-static u16 *BufferQuestLogData_DepositedMonInPC(u16 *, const u16 *);
-static u16 *BufferQuestLogData_SwitchedMultipleMons(u16 *, const u16 *);
-static u16 *BufferQuestLogData_DepositedItemInPC(u16 *, const u16 *);
-static u16 *BufferQuestLogData_WithdrewItemFromPC(u16 *, const u16 *);
-static u16 *BufferQuestLogData_DefeatedGymLeader(u16 *, const u16 *);
-static u16 *BufferQuestLogData_DefeatedWildMon(u16 *, const u16 *);
-static u16 *BufferQuestLogData_DefeatedEliteFourMember(u16 *, const u16 *);
-static u16 *BufferQuestLogData_DefeatedChampion(u16 *, const u16 *);
-static u16 *BufferQuestLogData_DefeatedTrainer(u16 *, const u16 *);
-static u16 *BufferQuestLogData_DepartedLocation(u16 *, const u16 *);
-static u16 *BufferQuestLogData_UsedFieldMove(u16 *, const u16 *);
-static u16 *BufferQuestLogData_BoughtItem(u16 *, const u16 *);
-static u16 *BufferQuestLogData_SoldItem(u16 *, const u16 *);
-static u16 *BufferQuestLogData_ObtainedItem(u16 *, const u16 *);
-static u16 *BufferQuestLogData_ArrivedInLocation(u16 *, const u16 *);
-static const u16 *BufferQuestLogText_SwitchedPartyOrder(const u16 *);
-static const u16 *BufferQuestLogText_UsedItem(const u16 *);
-static const u16 *BufferQuestLogText_GaveHeldItemFromPartyMenu(const u16 *);
-static const u16 *BufferQuestLogText_GaveHeldItemFromBagMenu(const u16 *);
-static const u16 *BufferQuestLogText_GaveHeldItemFromPC(const u16 *);
-static const u16 *BufferQuestLogText_TookHeldItem(const u16 *);
-static const u16 *BufferQuestLogText_SwappedHeldItem(const u16 *);
-static const u16 *BufferQuestLogText_SwappedHeldItemFromPC(const u16 *);
-static const u16 *BufferQuestLogText_UsedPkmnCenter(const u16 *);
-static const u16 *BufferQuestLogText_LinkTraded(const u16 *);
-static const u16 *BufferQuestLogText_LinkBattledSingle(const u16 *);
-static const u16 *BufferQuestLogText_LinkBattledDouble(const u16 *);
-static const u16 *BufferQuestLogText_LinkBattledMulti(const u16 *);
-static const u16 *BufferQuestLogText_UsedUnionRoom(const u16 *);
-static const u16 *BufferQuestLogText_UsedUnionRoomChat(const u16 *);
-static const u16 *BufferQuestLogText_LinkTradedUnionRoom(const u16 *);
-static const u16 *BufferQuestLogText_LinkBattledUnionRoom(const u16 *);
-static const u16 *BufferQuestLogText_SwitchedMonsBetweenBoxes(const u16 *);
-static const u16 *BufferQuestLogText_SwitchedMonsWithinBox(const u16 *);
-static const u16 *BufferQuestLogText_SwitchedPartyMonForPCMon(const u16 *);
-static const u16 *BufferQuestLogText_MovedMonBetweenBoxes(const u16 *);
-static const u16 *BufferQuestLogText_MovedMonWithinBox(const u16 *);
-static const u16 *BufferQuestLogText_WithdrewMonFromPC(const u16 *);
-static const u16 *BufferQuestLogText_DepositedMonInPC(const u16 *);
-static const u16 *BufferQuestLogText_SwitchedMultipleMons(const u16 *);
-static const u16 *BufferQuestLogText_DepositedItemInPC(const u16 *);
-static const u16 *BufferQuestLogText_WithdrewItemFromPC(const u16 *);
-static const u16 *BufferQuestLogText_DefeatedGymLeader(const u16 *);
-static const u16 *BufferQuestLogText_DefeatedWildMon(const u16 *);
-static const u16 *BufferQuestLogText_DefeatedEliteFourMember(const u16 *);
-static const u16 *BufferQuestLogText_DefeatedChampion(const u16 *);
-static const u16 *BufferQuestLogText_DefeatedTrainer(const u16 *);
-static const u16 *BufferQuestLogText_DepartedLocation(const u16 *);
-static const u16 *BufferQuestLogText_UsedFieldMove(const u16 *);
-static const u16 *BufferQuestLogText_BoughtItem(const u16 *);
-static const u16 *BufferQuestLogText_SoldItem(const u16 *);
-static const u16 *BufferQuestLogText_ObtainedItem(const u16 *);
-static const u16 *BufferQuestLogText_ArrivedInLocation(const u16 *);
-static bool8 IsSpeciesFromSpecialEncounter(u16);
-static bool8 sub_81153A8(u16, const u16 *);
-static bool8 sub_81153E4(u16, const u16 *);
-static void BufferLinkPartnersName(u8 *);
static const struct WindowTemplate sQuestLogHeaderWindowTemplates[3] = {
{ 0, 0, 0, 30, 2, 15, 0x0e9 },
@@ -293,7 +157,7 @@ static const u16 sUnknown_8456638[] = INCBIN_U16("graphics/unknown/unknown_84566
static const u8 sQuestLogTextLineYCoords[] = {17, 10, 3};
-void sub_8110840(void * oldPointer)
+void SetQuestLogRecordAndPlaybackPointers(void * oldPointer)
{
ptrdiff_t offset = (void *)gSaveBlock1Ptr - oldPointer;
if (gUnknown_203AE04)
@@ -302,7 +166,7 @@ void sub_8110840(void * oldPointer)
{
if (sEventRecordingPointer)
sEventRecordingPointer = (void *)sEventRecordingPointer + offset;
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
{
int r3;
for (r3 = 0; r3 < (int)NELEMS(gUnknown_203AE0C); r3++)
@@ -321,7 +185,7 @@ void ResetQuestLog(void)
sEventRecordingPointer = NULL;
gUnknown_203AE04 = NULL;
sub_8113BD8();
- sub_81138F8();
+ ResetDeferredLinkEvent();
}
static void DestroySav1QuestLogEntry(u8 a0)
@@ -343,7 +207,7 @@ void RunQuestLogCB(void)
bool8 sub_8110944(const void * a0, size_t cmdSize)
{
- void * r2 = gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_568;
+ void * r2 = gSaveBlock1Ptr->questLog[sCurrentSceneNum].script;
void * r0 = gSaveBlock1Ptr->questLog[sCurrentSceneNum].end;
r0 -= cmdSize;
if ((const void *)a0 < r2 || (const void *)a0 > r0)
@@ -351,9 +215,9 @@ bool8 sub_8110944(const void * a0, size_t cmdSize)
return TRUE;
}
-static bool8 WillCommandOfSizeFitInSav1Record(u16 *cursor, size_t size)
+bool8 WillCommandOfSizeFitInSav1Record(u16 *cursor, size_t size)
{
- void * start = gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_568;
+ void * start = gSaveBlock1Ptr->questLog[sCurrentSceneNum].script;
void * end = gSaveBlock1Ptr->questLog[sCurrentSceneNum].end;
end -= size;
if ((void *)cursor < start || (void *)cursor > end)
@@ -364,37 +228,40 @@ static bool8 WillCommandOfSizeFitInSav1Record(u16 *cursor, size_t size)
static void SetQuestLogState(u8 state)
{
gQuestLogState = state;
- if (state == 1)
- sQuestLogCB = sub_8110A00;
+ if (state == QL_STATE_RECORDING)
+ sQuestLogCB = QLogCB_Recording;
else
- sQuestLogCB = sub_8110A3C;
+ sQuestLogCB = QLogCB_Playback;
}
-static void sub_8110A00(void)
+static void QLogCB_Recording(void)
{
if (TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer) != 1)
{
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
TryRecordEvent39_GoToNextScene();
gQuestLogState = 0;
sQuestLogCB = NULL;
}
}
-static void sub_8110A3C(void)
+static void QLogCB_Playback(void)
{
- if (gUnknown_203AE94.unk_0_0 == 2)
- gUnknown_203AE94.unk_0_0 = 0;
+ if (sQuestLogCurrentScene.playbackSubstate == 2)
+ sQuestLogCurrentScene.playbackSubstate = 0;
- if (gUnknown_203AE94.unk_0_6 == 0)
+ if (sQuestLogCurrentScene.sceneEndMode == 0)
{
- if (gUnknown_3005E88 || gUnknown_203AE94.unk_0_0 == 1 || (gUnknown_203AE94.unk_1 < NELEMS(gUnknown_203AE0C) && gUnknown_203AE0C[gUnknown_203AE94.unk_1] != NULL))
- sub_8111AD8();
+ if (gQuestLogPlaybackState != 0
+ || sQuestLogCurrentScene.playbackSubstate == 1
+ || (sQuestLogCurrentScene.cursor < NELEMS(gUnknown_203AE0C)
+ && gUnknown_203AE0C[sQuestLogCurrentScene.cursor] != NULL))
+ QuestLog_PlayCurrentEvent();
else
{
- gUnknown_203AE94.unk_0_6 = 2;
+ sQuestLogCurrentScene.sceneEndMode = 2;
ScriptContext2_Enable();
- sub_81118F4(0);
+ QuestLog_BeginFadeAtEndOfScene(0);
}
}
}
@@ -404,23 +271,23 @@ void GetQuestLogState(void)
gSpecialVar_Result = gQuestLogState;
}
-u8 sub_8110AC8(void)
+u8 GetQuestLogStartType(void)
{
- return gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000;
+ return gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType;
}
-static void StartRecordingQuestLogEntry(u16 eventId)
+void StartRecordingQuestLogEntry(u16 eventId)
{
if (sCurrentSceneNum >= QUEST_LOG_SCENE_COUNT)
sCurrentSceneNum = 0;
DestroySav1QuestLogEntry(sCurrentSceneNum);
- sub_8113B88();
- sEventRecordingPointer = gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_568;
+ ResetUnk203B044();
+ sEventRecordingPointer = gSaveBlock1Ptr->questLog[sCurrentSceneNum].script;
if (IS_LINK_QL_EVENT(eventId) || eventId == QL_EVENT_DEPARTED)
- gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000 = 2;
+ gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType = QL_START_WARP;
else
- gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000 = 1;
+ gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType = QL_START_NORMAL;
QuestLog_GetSaneMonCounts();
SetPlayerInitialCoordsAtScene(sCurrentSceneNum);
SetNPCInitialCoordsAtScene(sCurrentSceneNum);
@@ -430,7 +297,7 @@ static void StartRecordingQuestLogEntry(u16 eventId)
gUnknown_203ADFC = 0;
SetUpQuestLogEntry(2, sQuestLogSceneRecordBuffer, 0x100);
TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer);
- SetQuestLogState(QL_STATE_1);
+ SetQuestLogState(QL_STATE_RECORDING);
}
static void SetPlayerInitialCoordsAtScene(u8 sceneNum)
@@ -524,7 +391,7 @@ static bool8 TryRecordQuestLogEntrySequence(struct QuestLogEntry * entry)
{
if (sEventRecordingPointer == NULL)
return FALSE;
- switch (entry[i].unk_6)
+ switch (entry[i].command)
{
case 0:
case 1:
@@ -536,12 +403,12 @@ static bool8 TryRecordQuestLogEntrySequence(struct QuestLogEntry * entry)
}
if (sEventRecordingPointer == NULL)
{
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
return FALSE;
}
}
- if (gUnknown_3005E88 == 0)
+ if (gQuestLogPlaybackState == 0)
{
sEventRecordingPointer = TryRecordEvent39_NoParams(sEventRecordingPointer);
return FALSE;
@@ -558,14 +425,14 @@ void TrySetUpQuestLogScenes_ElseContinueFromSave(u8 taskId)
sNumScenes = 0;
for (i = 0; i < QUEST_LOG_SCENE_COUNT; i++)
{
- if (gSaveBlock1Ptr->questLog[i].unk_000)
+ if (gSaveBlock1Ptr->questLog[i].startType != 0)
sNumScenes++;
}
if (sNumScenes != 0)
{
gHelpSystemEnabled = FALSE;
- sub_8110F90(taskId);
+ Task_BeginQuestLogPlayback(taskId);
DestroyTask(taskId);
}
else
@@ -575,42 +442,42 @@ void TrySetUpQuestLogScenes_ElseContinueFromSave(u8 taskId)
}
}
-static void sub_8110F90(u8 unused)
+static void Task_BeginQuestLogPlayback(u8 taskId)
{
- gSaveBlock1Ptr->location.mapGroup = 3;
- gSaveBlock1Ptr->location.mapNum = 19;
+ gSaveBlock1Ptr->location.mapGroup = MAP_GROUP(ROUTE1);
+ gSaveBlock1Ptr->location.mapNum = MAP_NUM(ROUTE1);
gSaveBlock1Ptr->location.warpId = -1;
sCurrentSceneNum = 0;
gDisableMapMusicChangeOnMapLoad = 1;
DisableWildEncounters(TRUE);
- sub_8111368();
+ QLPlayback_InitOverworldState();
}
void sub_8110FCC(void)
{
- sub_811175C(sCurrentSceneNum, sQuestLogSceneRecordBuffer);
- sub_8113B88();
+ ReadQuestLogScriptFromSav1(sCurrentSceneNum, sQuestLogSceneRecordBuffer);
+ ResetUnk203B044();
SetUpQuestLogEntry(1, sQuestLogSceneRecordBuffer, 0x100);
QuestLogPlaybackSetObjectEventTemplates(sCurrentSceneNum);
}
-bool8 sub_8111000(void)
+static bool8 FieldCB2_QuestLogStartPlaybackWithWarpExit(void)
{
LoadPalette(stdpal_get(4), 0xF0, 0x20);
- SetQuestLogState(QL_STATE_2);
+ SetQuestLogState(QL_STATE_PLAYBACK);
FieldCB_DefaultWarpExit();
- gUnknown_203AE94 = (struct UnkStruct_203AE94){};
- gUnknown_203AE94.unk_0_0 = 2;
+ sQuestLogCurrentScene = (struct UnkStruct_203AE94){};
+ sQuestLogCurrentScene.playbackSubstate = 2;
return 1;
}
-bool8 sub_8111038(void)
+static bool8 FieldCB2_QuestLogStartPlaybackStandingInPlace(void)
{
LoadPalette(stdpal_get(4), 0xF0, 0x20);
- SetQuestLogState(QL_STATE_2);
+ SetQuestLogState(QL_STATE_PLAYBACK);
FieldCB_WarpExitFadeFromBlack();
- gUnknown_203AE94 = (struct UnkStruct_203AE94){};
- gUnknown_203AE94.unk_0_0 = 2;
+ sQuestLogCurrentScene = (struct UnkStruct_203AE94){};
+ sQuestLogCurrentScene.playbackSubstate = 2;
return 1;
}
@@ -669,11 +536,11 @@ static void QuestLogPlaybackSetObjectEventTemplates(u8 sceneNum)
SetSav1ObjectEventsFromQuestLog(questLog, gSaveBlock1Ptr->objectEventTemplates);
}
-void sub_8111274(u8 sceneNum, bool8 a1)
+static void QLPlayback_SetInitialPlayerPosition(u8 sceneNum, bool8 isWarp)
{
struct WarpData sp0;
- if (!a1)
+ if (!isWarp)
{
gSaveBlock1Ptr->location.mapGroup = gSaveBlock1Ptr->questLog[sceneNum].mapGroup;
gSaveBlock1Ptr->location.mapNum = gSaveBlock1Ptr->questLog[sceneNum].mapNum;
@@ -688,28 +555,28 @@ void sub_8111274(u8 sceneNum, bool8 a1)
sp0.warpId = gSaveBlock1Ptr->questLog[sceneNum].warpId;
sp0.x = gSaveBlock1Ptr->questLog[sceneNum].x;
sp0.y = gSaveBlock1Ptr->questLog[sceneNum].y;
- sub_8055D5C(&sp0);
+ Overworld_SetWarpDestinationFromWarp(&sp0);
}
}
-static void sub_8111368(void)
+static void QLPlayback_InitOverworldState(void)
{
- gQuestLogState = QL_STATE_2;
+ gQuestLogState = QL_STATE_PLAYBACK;
ResetSpecialVars();
ClearBag();
ClearPCItemSlots();
- if (sub_8110AC8() == 1)
+ if (GetQuestLogStartType() == QL_START_NORMAL)
{
- sub_8111274(sCurrentSceneNum, FALSE);
- gFieldCallback2 = sub_8111038;
- SetMainCallback2(sub_80572A8);
+ QLPlayback_SetInitialPlayerPosition(sCurrentSceneNum, FALSE);
+ gFieldCallback2 = FieldCB2_QuestLogStartPlaybackStandingInPlace;
+ SetMainCallback2(CB2_SetUpOverworldForQLPlayback);
}
else
{
- sub_8111274(sCurrentSceneNum, TRUE);
+ QLPlayback_SetInitialPlayerPosition(sCurrentSceneNum, TRUE);
WarpIntoMap();
- gFieldCallback2 = sub_8111000;
- SetMainCallback2(sub_805726C);
+ gFieldCallback2 = FieldCB2_QuestLogStartPlaybackWithWarpExit;
+ SetMainCallback2(CB2_SetUpOverworldForQLPlaybackWithWarpExit);
}
}
@@ -871,7 +738,7 @@ void sub_8111708(void)
}
}
-static void sub_811175C(u8 sceneNum, struct QuestLogEntry * a1)
+static void ReadQuestLogScriptFromSav1(u8 sceneNum, struct QuestLogEntry * a1)
{
u16 i;
u16 *r4;
@@ -884,7 +751,7 @@ static void sub_811175C(u8 sceneNum, struct QuestLogEntry * a1)
gUnknown_203AE0C[i] = NULL;
}
- r4 = gSaveBlock1Ptr->questLog[sceneNum].unk_568;
+ r4 = gSaveBlock1Ptr->questLog[sceneNum].script;
for (i = 0; i < 32; i++)
{
switch (r4[0] & 0xFFF)
@@ -918,9 +785,9 @@ static void sub_811175C(u8 sceneNum, struct QuestLogEntry * a1)
}
}
-static void sub_81118F4(s8 a0)
+static void QuestLog_BeginFadeAtEndOfScene(s8 delay)
{
- FadeScreen(FADE_TO_BLACK, a0);
+ FadeScreen(FADE_TO_BLACK, delay);
sQuestLogCB = QuestLog_AdvancePlayhead;
}
@@ -929,14 +796,14 @@ static void QuestLog_AdvancePlayhead(void)
if (!gPaletteFade.active)
{
ScriptContext2_Enable();
- if (++sCurrentSceneNum < QUEST_LOG_SCENE_COUNT && gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000)
+ if (++sCurrentSceneNum < QUEST_LOG_SCENE_COUNT && gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType != 0)
{
sNumScenes--;
- sub_8111368();
+ QLPlayback_InitOverworldState();
}
else
{
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
QuestLog_StartFinalScene();
}
}
@@ -947,14 +814,14 @@ static void QuestLog_StartFinalScene(void)
ResetSpecialVars();
Save_ResetSaveCounters();
Save_LoadGameData(SAVE_NORMAL);
- SetMainCallback2(sub_8057430);
- gFieldCallback2 = sub_8111F60;
+ SetMainCallback2(CB2_EnterFieldFromQuestLog);
+ gFieldCallback2 = FieldCB2_FinalScene;
FreeAllWindowBuffers();
- gQuestLogState = QL_STATE_3;
+ gQuestLogState = QL_STATE_PLAYBACK_LAST;
sQuestLogCB = NULL;
}
-void sub_81119C8(void)
+void QuestLog_AdvancePlayhead_(void)
{
QuestLog_AdvancePlayhead();
}
@@ -965,11 +832,11 @@ bool8 QuestLog_SchedulePlaybackCB(void (*callback)(void))
switch (gQuestLogState)
{
- case 1:
- QuestLog_OnInteractionWithSpecialNpc();
+ case QL_STATE_RECORDING:
+ QuestLog_CutRecording();
break;
- case 2:
- gUnknown_3005E88 = 3;
+ case QL_STATE_PLAYBACK:
+ gQuestLogPlaybackState = 3;
taskId = CreateTask(Task_RunPlaybackCB, 80);
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = 0;
@@ -990,14 +857,14 @@ static void Task_RunPlaybackCB(u8 taskId)
if (++data[0] == 0x7F)
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
- gUnknown_203AE94.unk_0_6 = 2;
+ sQuestLogCurrentScene.sceneEndMode = 2;
data[1]++;
}
break;
case 1:
if (!gPaletteFade.active)
{
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
routine = (void (*)(void)) GetWordTaskArg(taskId, 14);
if (routine != NULL)
routine();
@@ -1008,53 +875,53 @@ static void Task_RunPlaybackCB(u8 taskId)
}
}
-static void sub_8111AD8(void)
+static void QuestLog_PlayCurrentEvent(void)
{
- if (gUnknown_203AE94.unk_0_0 == 1)
+ if (sQuestLogCurrentScene.playbackSubstate == 1)
{
- if (--gUnknown_203AE94.unk_2 != 0)
+ if (--sQuestLogCurrentScene.timer != 0)
return;
- gUnknown_203AE94.unk_0_0 = 0;
- gUnknown_203AE94.unk_0_4 = 1;
- sub_8112888(2);
+ sQuestLogCurrentScene.playbackSubstate = 0;
+ sQuestLogCurrentScene.playingEvent = 1;
+ TogglePlaybackStateForOverworldLock(2);
}
- if (gUnknown_203AE94.unk_0_4 == 1)
+ if (sQuestLogCurrentScene.playingEvent == 1)
{
- if (++gUnknown_203AE94.unk_3 > 15)
+ if (++sQuestLogCurrentScene.overlapTimer > 15)
{
QuestLog_CloseTextWindow();
- gUnknown_203AE94.unk_0_4 = 0;
- gUnknown_203AE94.unk_3 = 0;
+ sQuestLogCurrentScene.playingEvent = 0;
+ sQuestLogCurrentScene.overlapTimer = 0;
}
}
- if (gUnknown_203AE94.unk_1 < NELEMS(gUnknown_203AE0C))
+ if (sQuestLogCurrentScene.cursor < NELEMS(gUnknown_203AE0C))
{
- if (sub_8113B44(gUnknown_203AE0C[gUnknown_203AE94.unk_1]) == 1)
- sub_8111B80();
- else if (sub_8113AE8(gUnknown_203AE0C[gUnknown_203AE94.unk_1]) == 1)
- sub_8111B80();
+ if (sub_8113B44(gUnknown_203AE0C[sQuestLogCurrentScene.cursor]) == 1)
+ HandleShowQuestLogMessage();
+ else if (sub_8113AE8(gUnknown_203AE0C[sQuestLogCurrentScene.cursor]) == 1)
+ HandleShowQuestLogMessage();
}
}
-static void sub_8111B80(void)
+static void HandleShowQuestLogMessage(void)
{
- if (gUnknown_203AE94.unk_0_0 == 0)
+ if (sQuestLogCurrentScene.playbackSubstate == 0)
{
- gUnknown_203AE94.unk_0_0 = 1;
- gUnknown_203AE94.unk_0_4 = 0;
- gUnknown_203AE94.unk_3 = 0;
- gUnknown_203AE94.unk_2 = sub_8111BD4();
+ sQuestLogCurrentScene.playbackSubstate = 1;
+ sQuestLogCurrentScene.playingEvent = 0;
+ sQuestLogCurrentScene.overlapTimer = 0;
+ sQuestLogCurrentScene.timer = GetQuestLogTextDisplayDuration();
if (gUnknown_203B044.unk_2 == 0)
- gUnknown_203AE94.unk_1++;
- if (gUnknown_203AE94.unk_1 > 32)
+ sQuestLogCurrentScene.cursor++;
+ if (sQuestLogCurrentScene.cursor > 32)
return;
DrawQuestLogSceneDescription();
}
- sub_8112888(1);
+ TogglePlaybackStateForOverworldLock(1); // lock
}
-static u8 sub_8111BD4(void)
+static u8 GetQuestLogTextDisplayDuration(void)
{
u16 i;
u16 count = 0;
@@ -1076,42 +943,42 @@ static u8 sub_8111BD4(void)
bool8 sub_8111C2C(void)
{
- if (gQuestLogState != QL_STATE_2)
+ if (gQuestLogState != QL_STATE_PLAYBACK)
return FALSE;
- if (gUnknown_3005E88 == 0 || gUnknown_203AE94.unk_0_0 == 1 || gUnknown_203AE94.unk_0_0 == 2)
+ if (gQuestLogPlaybackState == 0 || sQuestLogCurrentScene.playbackSubstate == 1 || sQuestLogCurrentScene.playbackSubstate == 2)
return TRUE;
return FALSE;
}
void sub_8111C68(void)
{
- if (gUnknown_203AE94.unk_0_6 == 0)
+ if (sQuestLogCurrentScene.sceneEndMode == 0)
{
if (JOY_NEW(A_BUTTON))
{
- gUnknown_203AE94.unk_0_6 = 2;
- gUnknown_3005E88 = 0;
- sub_81118F4(-3);
+ sQuestLogCurrentScene.sceneEndMode = 2;
+ gQuestLogPlaybackState = 0;
+ QuestLog_BeginFadeAtEndOfScene(-3);
}
else if (JOY_NEW(B_BUTTON))
{
- gUnknown_203AE94.unk_0_6 = 1;
- gUnknown_3005E88 = 0;
+ sQuestLogCurrentScene.sceneEndMode = 1;
+ gQuestLogPlaybackState = 0;
QuestLog_SkipToEndOfPlayback(-3);
}
}
}
-bool8 sub_8111CD0(void)
+bool8 QuestLogScenePlaybackIsEnding(void)
{
- if (gUnknown_203AE94.unk_0_6 != 0)
+ if (sQuestLogCurrentScene.sceneEndMode != 0)
return TRUE;
return FALSE;
}
-void sub_8111CF0(void)
+void QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode(void)
{
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
DrawPreviouslyOnQuestHeader(sNumScenes);
}
@@ -1191,18 +1058,18 @@ static void QuestLog_WaitFadeAndCancelPlayback(void)
ScriptContext2_Enable();
for (sCurrentSceneNum = sCurrentSceneNum; sCurrentSceneNum < QUEST_LOG_SCENE_COUNT; sCurrentSceneNum++)
{
- if (gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000 == 0)
+ if (gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType == 0)
break;
- sub_811175C(sCurrentSceneNum, sQuestLogSceneRecordBuffer);
+ ReadQuestLogScriptFromSav1(sCurrentSceneNum, sQuestLogSceneRecordBuffer);
}
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
QuestLog_StartFinalScene();
}
}
void sub_8111F14(void)
{
- if (gQuestLogState == QL_STATE_3)
+ if (gQuestLogState == QL_STATE_PLAYBACK_LAST)
gUnknown_203AE90 = AllocZeroed(0x200 * sizeof(u16));
}
@@ -1211,23 +1078,23 @@ void sub_8111F38(u16 a0, u16 a1)
CpuSet(gPlttBufferUnfaded + a0, gUnknown_203AE90 + a0, a1);
}
-static bool8 sub_8111F60(void)
+static bool8 FieldCB2_FinalScene(void)
{
LoadPalette(stdpal_get(4), 0xF0, 0x20);
DrawPreviouslyOnQuestHeader(0);
FieldCB_WarpExitFadeFromBlack();
- CreateTask(sub_8111F8C, 0xFF);
+ CreateTask(Task_FinalScene_WaitFade, 0xFF);
return TRUE;
}
-static void sub_8111F8C(u8 taskId)
+static void Task_FinalScene_WaitFade(u8 taskId)
{
struct Task *task = &gTasks[taskId];
if (ScriptContext2_IsEnabled() != TRUE)
{
FreezeObjectEvents();
- sub_805C270();
+ HandleEnforcedLookDirectionOnPlayerStopMoving();
StopPlayerAvatar();
ScriptContext2_Enable();
task->func = Task_QuestLogScene_SavedGame;
@@ -1240,7 +1107,7 @@ static void Task_QuestLogScene_SavedGame(u8 taskId)
if (!gPaletteFade.active)
{
- if (gUnknown_203AE94.unk_0_6 != 1)
+ if (sQuestLogCurrentScene.sceneEndMode != 1)
{
GetMapNameGeneric(gStringVar1, gMapHeader.regionMapSectionId);
StringExpandPlaceholders(gStringVar4, gText_QuestLog_SavedGameAtLocation);
@@ -1260,7 +1127,7 @@ static void Task_WaitAtEndOfQuestLog(u8 taskId)
{
struct Task *task = &gTasks[taskId];
- if (JOY_NEW(A_BUTTON | B_BUTTON) || task->tTimer >= 127 || gUnknown_203AE94.unk_0_6 == 1)
+ if (JOY_NEW(A_BUTTON | B_BUTTON) || task->tTimer >= 127 || sQuestLogCurrentScene.sceneEndMode == 1)
{
QuestLog_CloseTextWindow();
task->tTimer = 0;
@@ -1310,12 +1177,12 @@ static void Task_EndQuestLog(u8 taskId)
tState++;
break;
default:
- if (gUnknown_203AE94.unk_0_6 == 1)
+ if (sQuestLogCurrentScene.sceneEndMode == 1)
ShowMapNamePopup(TRUE);
CpuCopy16(gUnknown_203AE90, gPlttBufferUnfaded, 0x400);
Free(gUnknown_203AE90);
- gUnknown_203AE94 = (struct UnkStruct_203AE94){};
- sub_80696C0();
+ sQuestLogCurrentScene = (struct UnkStruct_203AE94){};
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
gTextFlags.autoScroll = FALSE;
gUnknown_2036E28 = 0;
@@ -1359,9 +1226,9 @@ static void sub_811229C(void)
Free(buffer);
}
-void sub_811231C(void)
+void FinishRecordingQuestLogScene(void)
{
- if (gQuestLogState == QL_STATE_1)
+ if (gQuestLogState == QL_STATE_RECORDING)
{
TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer);
TryRecordEvent39_GoToNextScene();
@@ -1369,18 +1236,18 @@ void sub_811231C(void)
sQuestLogCB = NULL;
gUnknown_203AE04 = NULL;
sEventRecordingPointer = NULL;
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
}
}
-void QuestLog_OnInteractionWithSpecialNpc(void)
+void QuestLog_CutRecording(void)
{
- if (gUnknown_3005E88 && gQuestLogState == QL_STATE_1)
+ if (gQuestLogPlaybackState != 0 && gQuestLogState == QL_STATE_RECORDING)
{
TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer);
TryRecordEvent41_IncCursor(1);
TryRecordEvent39_GoToNextScene();
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
gQuestLogState = 0;
sQuestLogCB = NULL;
}
@@ -1398,7 +1265,7 @@ static void SortQuestLogInSav1(void)
{
if (sceneNum >= QUEST_LOG_SCENE_COUNT)
sceneNum = 0;
- if (gSaveBlock1Ptr->questLog[sceneNum].unk_000)
+ if (gSaveBlock1Ptr->questLog[sceneNum].startType != 0)
{
buffer[count] = gSaveBlock1Ptr->questLog[sceneNum];
count++;
@@ -1414,7 +1281,7 @@ void SaveQuestLogData(void)
{
if (MenuHelpers_LinkSomething() != TRUE)
{
- QuestLog_OnInteractionWithSpecialNpc();
+ QuestLog_CutRecording();
SortQuestLogInSav1();
}
}
@@ -1447,16 +1314,16 @@ void sub_811246C(struct Sprite *sprite)
}
}
-void sub_81124EC(u8 a0, u8 a1, u8 a2, u8 movementActionId)
+void sub_81124EC(u8 localId, u8 mapNum, u8 mapGroup, u8 movementActionId)
{
- if (!sub_8112CEC())
+ if (!RecordHeadAtEndOfEntryOrScriptContext2Enabled())
{
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = a0;
- sCurQuestLogEntry[sQuestLogCursor].unk_1 = a1;
- sCurQuestLogEntry[sQuestLogCursor].unk_2 = a2;
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId;
+ sCurQuestLogEntry[sQuestLogCursor].duration = sNextStepDelay;
+ sCurQuestLogEntry[sQuestLogCursor].command = 0;
+ sCurQuestLogEntry[sQuestLogCursor].localId = localId;
+ sCurQuestLogEntry[sQuestLogCursor].mapNum = mapNum;
+ sCurQuestLogEntry[sQuestLogCursor].mapGroup = mapGroup;
+ sCurQuestLogEntry[sQuestLogCursor].animId = movementActionId;
sQuestLogCursor++;
sNextStepDelay = 0;
}
@@ -1466,12 +1333,12 @@ void sub_8112588(u8 localId, u8 mapNum, u8 mapGroup, u8 movementActionId, u8 dur
{
if (!RecordHeadAtEndOfEntry())
{
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = localId;
- sCurQuestLogEntry[sQuestLogCursor].unk_1 = mapNum;
- sCurQuestLogEntry[sQuestLogCursor].unk_2 = mapGroup;
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId;
+ sCurQuestLogEntry[sQuestLogCursor].duration = sNextStepDelay;
+ sCurQuestLogEntry[sQuestLogCursor].command = 0;
+ sCurQuestLogEntry[sQuestLogCursor].localId = localId;
+ sCurQuestLogEntry[sQuestLogCursor].mapNum = mapNum;
+ sCurQuestLogEntry[sQuestLogCursor].mapGroup = mapGroup;
+ sCurQuestLogEntry[sQuestLogCursor].animId = movementActionId;
sQuestLogCursor++;
sNextStepDelay = duration;
}
@@ -1479,15 +1346,15 @@ void sub_8112588(u8 localId, u8 mapNum, u8 mapGroup, u8 movementActionId, u8 dur
void sub_8112628(u8 movementActionId)
{
- if (!sub_8112CEC())
+ if (!RecordHeadAtEndOfEntryOrScriptContext2Enabled())
{
- if (movementActionId != sCurQuestLogEntry[gUnknown_203B01C].unk_3 || movementActionId > MOVEMENT_ACTION_FACE_RIGHT)
+ if (movementActionId != sCurQuestLogEntry[sLastQuestLogCursor].animId || movementActionId > MOVEMENT_ACTION_FACE_RIGHT)
{
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId;
- gUnknown_203B01C = sQuestLogCursor;
+ sCurQuestLogEntry[sQuestLogCursor].duration = sNextStepDelay;
+ sCurQuestLogEntry[sQuestLogCursor].command = 0;
+ sCurQuestLogEntry[sQuestLogCursor].localId = 0;
+ sCurQuestLogEntry[sQuestLogCursor].animId = movementActionId;
+ sLastQuestLogCursor = sQuestLogCursor;
sQuestLogCursor++;
sNextStepDelay = 0;
}
@@ -1498,11 +1365,11 @@ void sub_81126AC(u8 movementActionId, u8 duration)
{
if (!RecordHeadAtEndOfEntry())
{
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId;
- gUnknown_203B01C = sQuestLogCursor;
+ sCurQuestLogEntry[sQuestLogCursor].duration = sNextStepDelay;
+ sCurQuestLogEntry[sQuestLogCursor].command = 0;
+ sCurQuestLogEntry[sQuestLogCursor].localId = 0;
+ sCurQuestLogEntry[sQuestLogCursor].animId = movementActionId;
+ sLastQuestLogCursor = sQuestLogCursor;
sQuestLogCursor++;
sNextStepDelay = duration;
}
@@ -1512,10 +1379,10 @@ void sub_8112720(u8 movementActionId)
{
if (!RecordHeadAtEndOfEntry())
{
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 1;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId;
+ sCurQuestLogEntry[sQuestLogCursor].duration = sNextStepDelay;
+ sCurQuestLogEntry[sQuestLogCursor].command = 1;
+ sCurQuestLogEntry[sQuestLogCursor].localId = 0;
+ sCurQuestLogEntry[sQuestLogCursor].animId = movementActionId;
sQuestLogCursor++;
sNextStepDelay = 0;
}
@@ -1525,10 +1392,10 @@ void sub_811278C(u8 movementActionId, u8 duration)
{
if (!RecordHeadAtEndOfEntry())
{
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 1;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId;
+ sCurQuestLogEntry[sQuestLogCursor].duration = sNextStepDelay;
+ sCurQuestLogEntry[sQuestLogCursor].command = 1;
+ sCurQuestLogEntry[sQuestLogCursor].localId = 0;
+ sCurQuestLogEntry[sQuestLogCursor].animId = movementActionId;
sQuestLogCursor++;
sNextStepDelay = duration;
}
@@ -1539,12 +1406,12 @@ void sub_81127F8(struct FieldInput * a0)
if (sQuestLogCursor < sNumEventsInLogEntry)
{
u32 r2 = *(u32 *)a0 & 0x00FF00F3;
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 2;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = r2;
- sCurQuestLogEntry[sQuestLogCursor].unk_1 = r2 >> 8;
- sCurQuestLogEntry[sQuestLogCursor].unk_2 = r2 >> 16;
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = r2 >> 24;
+ sCurQuestLogEntry[sQuestLogCursor].duration = sNextStepDelay;
+ sCurQuestLogEntry[sQuestLogCursor].command = 2;
+ sCurQuestLogEntry[sQuestLogCursor].localId = r2;
+ sCurQuestLogEntry[sQuestLogCursor].mapNum = r2 >> 8;
+ sCurQuestLogEntry[sQuestLogCursor].mapGroup = r2 >> 16;
+ sCurQuestLogEntry[sQuestLogCursor].animId = r2 >> 24;
sQuestLogCursor++;
if (ScriptContext2_IsEnabled())
sNextStepDelay = TRUE;
@@ -1553,17 +1420,17 @@ void sub_81127F8(struct FieldInput * a0)
}
}
-static void sub_8112888(u8 a0)
+static void TogglePlaybackStateForOverworldLock(u8 a0)
{
switch (a0)
{
case 1:
- if (gUnknown_3005E88 == 1)
- gUnknown_3005E88 = 3;
+ if (gQuestLogPlaybackState == 1)
+ gQuestLogPlaybackState = 3; // Message visible, overworld locked
break;
case 2:
- if (gUnknown_3005E88 == 3)
- gUnknown_3005E88 = 1;
+ if (gQuestLogPlaybackState == 3)
+ gQuestLogPlaybackState = 1; // Overworld unlocked
break;
}
}
@@ -1576,21 +1443,21 @@ void sub_81128BC(u8 a0)
{
case 1:
if (r1 == 1)
- gUnknown_3005E88 = 3;
+ gQuestLogPlaybackState = 3;
else if (r1 == 2)
{
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 3;
+ sCurQuestLogEntry[sQuestLogCursor].duration = sNextStepDelay;
+ sCurQuestLogEntry[sQuestLogCursor].command = 3;
sQuestLogCursor++;
sNextStepDelay = 0;
- gUnknown_3005E88 = 4;
+ gQuestLogPlaybackState = 4;
}
break;
case 2:
if (r1 == 1)
- gUnknown_3005E88 = 1;
+ gQuestLogPlaybackState = 1;
else if (r1 == 2)
- gUnknown_3005E88 = 2;
+ gQuestLogPlaybackState = 2;
break;
}
}
@@ -1602,7 +1469,7 @@ static void SetUpQuestLogEntry(u8 kind, struct QuestLogEntry *entry, u16 size)
switch (kind)
{
default:
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
break;
case 1:
sCurQuestLogEntry = entry;
@@ -1613,12 +1480,12 @@ static void SetUpQuestLogEntry(u8 kind, struct QuestLogEntry *entry, u16 size)
sMovementScripts[i][1] |= 0xFF;
}
sQuestLogCursor = 0;
- gUnknown_203B01C = 0;
+ sLastQuestLogCursor = 0;
gQuestLogFieldInput = (struct FieldInput){};
- sNextStepDelay = sCurQuestLogEntry[sQuestLogCursor].unk_4;
- sMovementScripts[0][0] = sCurQuestLogEntry[sQuestLogCursor].unk_3;
+ sNextStepDelay = sCurQuestLogEntry[sQuestLogCursor].duration;
+ sMovementScripts[0][0] = sCurQuestLogEntry[sQuestLogCursor].animId;
sMovementScripts[0][1] = 0xFF;
- gUnknown_3005E88 = 1;
+ gQuestLogPlaybackState = 1;
break;
case 2:
sCurQuestLogEntry = entry;
@@ -1629,47 +1496,47 @@ static void SetUpQuestLogEntry(u8 kind, struct QuestLogEntry *entry, u16 size)
}
sQuestLogCursor = 0;
sNextStepDelay = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0;
+ sCurQuestLogEntry[sQuestLogCursor].duration = 0;
+ sCurQuestLogEntry[sQuestLogCursor].command = 0;
+ sCurQuestLogEntry[sQuestLogCursor].localId = 0;
switch (GetPlayerFacingDirection())
{
case DIR_NONE:
case DIR_SOUTH:
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = MOVEMENT_ACTION_FACE_DOWN;
+ sCurQuestLogEntry[sQuestLogCursor].animId = MOVEMENT_ACTION_FACE_DOWN;
break;
case DIR_EAST:
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = MOVEMENT_ACTION_FACE_RIGHT;
+ sCurQuestLogEntry[sQuestLogCursor].animId = MOVEMENT_ACTION_FACE_RIGHT;
break;
case DIR_NORTH:
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = MOVEMENT_ACTION_FACE_UP;
+ sCurQuestLogEntry[sQuestLogCursor].animId = MOVEMENT_ACTION_FACE_UP;
break;
case DIR_WEST:
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = MOVEMENT_ACTION_FACE_LEFT;
+ sCurQuestLogEntry[sQuestLogCursor].animId = MOVEMENT_ACTION_FACE_LEFT;
break;
}
- gUnknown_203B01C = 0;
+ sLastQuestLogCursor = 0;
sQuestLogCursor++;
- sCurQuestLogEntry[sQuestLogCursor].unk_4 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_6 = 2;
- sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_1 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_2 = 0;
- sCurQuestLogEntry[sQuestLogCursor].unk_3 = 0;
+ sCurQuestLogEntry[sQuestLogCursor].duration = 0;
+ sCurQuestLogEntry[sQuestLogCursor].command = 2;
+ sCurQuestLogEntry[sQuestLogCursor].localId = 0;
+ sCurQuestLogEntry[sQuestLogCursor].mapNum = 0;
+ sCurQuestLogEntry[sQuestLogCursor].mapGroup = 0;
+ sCurQuestLogEntry[sQuestLogCursor].animId = 0;
sQuestLogCursor++;
- gUnknown_3005E88 = 2;
+ gQuestLogPlaybackState = 2;
break;
}
}
void sub_8112B3C(void)
{
- switch (gUnknown_3005E88)
+ switch (gQuestLogPlaybackState)
{
case 0:
break;
case 1:
- if (!sub_8112CEC())
+ if (!RecordHeadAtEndOfEntryOrScriptContext2Enabled())
{
if (sNextStepDelay != 0)
sNextStepDelay--;
@@ -1677,42 +1544,42 @@ void sub_8112B3C(void)
{
do
{
- switch (sCurQuestLogEntry[sQuestLogCursor].unk_6)
+ switch (sCurQuestLogEntry[sQuestLogCursor].command)
{
case 0:
- sMovementScripts[sCurQuestLogEntry[sQuestLogCursor].unk_0][0] = sCurQuestLogEntry[sQuestLogCursor].unk_3;
+ sMovementScripts[sCurQuestLogEntry[sQuestLogCursor].localId][0] = sCurQuestLogEntry[sQuestLogCursor].animId;
break;
case 1:
- sMovementScripts[sCurQuestLogEntry[sQuestLogCursor].unk_0][1] = sCurQuestLogEntry[sQuestLogCursor].unk_3;
+ sMovementScripts[sCurQuestLogEntry[sQuestLogCursor].localId][1] = sCurQuestLogEntry[sQuestLogCursor].animId;
break;
case 2:
// Player input command
- *(u32 *)&gQuestLogFieldInput = ((sCurQuestLogEntry[sQuestLogCursor].unk_3 << 24) | (sCurQuestLogEntry[sQuestLogCursor].unk_2 << 16) | (sCurQuestLogEntry[sQuestLogCursor].unk_1 << 8) | (sCurQuestLogEntry[sQuestLogCursor].unk_0 << 0));
+ *(u32 *)&gQuestLogFieldInput = ((sCurQuestLogEntry[sQuestLogCursor].animId << 24) | (sCurQuestLogEntry[sQuestLogCursor].mapGroup << 16) | (sCurQuestLogEntry[sQuestLogCursor].mapNum << 8) | (sCurQuestLogEntry[sQuestLogCursor].localId << 0));
break;
case 3:
- gUnknown_3005E88 = 3;
+ gQuestLogPlaybackState = 3;
break;
case 0xFE:
break;
case 0xFF:
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
break;
}
- if (gUnknown_3005E88 == 0)
+ if (gQuestLogPlaybackState == 0)
break;
if (++sQuestLogCursor >= sNumEventsInLogEntry)
{
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
break;
}
- sNextStepDelay = sCurQuestLogEntry[sQuestLogCursor].unk_4;
- } while (gUnknown_3005E88 != 3
+ sNextStepDelay = sCurQuestLogEntry[sQuestLogCursor].duration;
+ } while (gQuestLogPlaybackState != 3
&& (sNextStepDelay == 0 || sNextStepDelay == 0xFFFF));
}
}
else if (sQuestLogCursor >= sNumEventsInLogEntry)
{
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
}
break;
case 2:
@@ -1720,7 +1587,7 @@ void sub_8112B3C(void)
{
sNextStepDelay++;
if (sQuestLogCursor >= sNumEventsInLogEntry)
- gUnknown_3005E88 = 0;
+ gQuestLogPlaybackState = 0;
}
break;
case 3:
@@ -1737,7 +1604,7 @@ void sub_8112C9C(void)
u8 sub_8112CAC(void)
{
- switch (gUnknown_3005E88)
+ switch (gQuestLogPlaybackState)
{
case 0:
default:
@@ -1751,7 +1618,7 @@ u8 sub_8112CAC(void)
}
}
-static bool8 sub_8112CEC(void)
+static bool8 RecordHeadAtEndOfEntryOrScriptContext2Enabled(void)
{
if (sQuestLogCursor >= sNumEventsInLogEntry || ScriptContext2_IsEnabled() == TRUE)
return TRUE;
@@ -1765,7 +1632,7 @@ static bool8 RecordHeadAtEndOfEntry(void)
return FALSE;
}
-static const struct UnkStruct_300201C gUnknown_84566A4 = {
+static const struct FlagOrVarRecord sDummyFlagOrVarRecord = {
0,
FALSE,
0x7FFF
@@ -1804,2567 +1671,23 @@ void QuestLogSetFlagOrVar(bool8 isFlag, u16 idx, u16 value)
sFlagOrVarPlayhead++;
}
-void sub_8112E3C(u8 a0, struct UnkStruct_300201C * a1, u16 a2)
+void sub_8112E3C(u8 state, struct FlagOrVarRecord * records, u16 size)
{
s32 i;
- if (a0 == 0 || a0 > 2)
- gUnknown_3005E88 = 0;
+ if (state == 0 || state > QL_STATE_PLAYBACK)
+ gQuestLogPlaybackState = 0;
else
{
- sFlagOrVarRecords = a1;
- sNumFlagsOrVars = a2 >> 2;
+ sFlagOrVarRecords = records;
+ sNumFlagsOrVars = size >> 2;
sFlagOrVarPlayhead = 0;
- if (a0 == 2)
+ if (state == QL_STATE_PLAYBACK)
{
for (i = 0; i < sNumEventsInLogEntry; i++)
{
- sFlagOrVarRecords[i] = gUnknown_84566A4;
- }
- }
- }
-}
-
-
-// Probable file boundary, help_message.c below, quest_log.c above
-
-
-const u16 gUnknown_84566A8[] = INCBIN_U16("graphics/unknown/unknown_84566a8.bin");
-
-static const struct WindowTemplate sHelpMessageWindowTemplate = {
- 0x00, 0, 15, 30, 5, 15, 0x008F
-};
-
-void MapNamePopupWindowIdSetDummy(void)
-{
- sHelpMessageWindowId = 0xFF;
-}
-
-u8 CreateHelpMessageWindow(void)
-{
- if (sHelpMessageWindowId == 0xFF)
- {
- sHelpMessageWindowId = AddWindow(&sHelpMessageWindowTemplate);
- PutWindowTilemap(sHelpMessageWindowId);
- }
- return sHelpMessageWindowId;
-}
-
-void DestroyHelpMessageWindow(u8 a0)
-{
- if (sHelpMessageWindowId != 0xFF)
- {
- FillWindowPixelBuffer(sHelpMessageWindowId, PIXEL_FILL(0));
- ClearWindowTilemap(sHelpMessageWindowId);
-
- if (a0)
- CopyWindowToVram(sHelpMessageWindowId, a0);
-
- RemoveWindow(sHelpMessageWindowId);
- sHelpMessageWindowId = 0xFF;
- }
-}
-
-#ifdef NONMATCHING
-void sub_8112F18(u8 windowId)
-{
- u8 width = GetWindowAttribute(windowId, WINDOW_WIDTH);
- u8 height = GetWindowAttribute(windowId, WINDOW_HEIGHT);
- u8 *buffer = Alloc(32 * width * height);
- u8 i, j;
- u8 k;
-
- if (buffer != NULL)
- {
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- if (i == 0)
- k = 0;
- else if (i == height - 1)
- k = 14;
- else
- k = 5;
- CpuCopy32(
- (void *)gUnknown_84566A8 + 32 * k, // operand swap on "add" instruction
- buffer + 32 * (i * width + j),
- 32
- );
- }
- }
- CopyToWindowPixelBuffer(windowId, buffer, width * height * 32, 0);
- Free(buffer);
- }
-}
-#else
-NAKED
-void sub_8112F18(u8 windowId)
-{
- asm_unified("\tpush {r4-r7,lr}\n"
- "\tmov r7, r10\n"
- "\tmov r6, r9\n"
- "\tmov r5, r8\n"
- "\tpush {r5-r7}\n"
- "\tsub sp, 0x8\n"
- "\tlsls r0, 24\n"
- "\tlsrs r0, 24\n"
- "\tmov r10, r0\n"
- "\tmovs r1, 0x3\n"
- "\tbl GetWindowAttribute\n"
- "\tlsls r0, 24\n"
- "\tlsrs r6, r0, 24\n"
- "\tmov r0, r10\n"
- "\tmovs r1, 0x4\n"
- "\tbl GetWindowAttribute\n"
- "\tlsls r0, 24\n"
- "\tlsrs r7, r0, 24\n"
- "\tlsls r0, r7, 5\n"
- "\tmuls r0, r6\n"
- "\tbl Alloc\n"
- "\tmov r8, r0\n"
- "\tcmp r0, 0\n"
- "\tbeq _08112FB8\n"
- "\tmovs r5, 0\n"
- "\tadds r0, r6, 0\n"
- "\tmuls r0, r7\n"
- "\tstr r0, [sp]\n"
- "\tcmp r5, r7\n"
- "\tbcs _08112FA2\n"
- "_08112F5A:\n"
- "\tmovs r4, 0\n"
- "\tadds r1, r5, 0x1\n"
- "\tmov r9, r1\n"
- "\tcmp r4, r6\n"
- "\tbcs _08112F98\n"
- "\tsubs r3, r7, 0x1\n"
- "_08112F66:\n"
- "\tmovs r0, 0\n"
- "\tcmp r5, 0\n"
- "\tbeq _08112F74\n"
- "\tmovs r0, 0x5\n"
- "\tcmp r5, r3\n"
- "\tbne _08112F74\n"
- "\tmovs r0, 0xE\n"
- "_08112F74:\n"
- "\tlsls r0, 5\n"
- "\tldr r1, _08112FC8 @ =gUnknown_84566A8\n"
- "\tadds r0, r1, r0\n"
- "\tadds r1, r5, 0\n"
- "\tmuls r1, r6\n"
- "\tadds r1, r4\n"
- "\tlsls r1, 5\n"
- "\tadd r1, r8\n"
- "\tldr r2, _08112FCC @ =0x04000008\n"
- "\tstr r3, [sp, 0x4]\n"
- "\tbl CpuSet\n"
- "\tadds r0, r4, 0x1\n"
- "\tlsls r0, 24\n"
- "\tlsrs r4, r0, 24\n"
- "\tldr r3, [sp, 0x4]\n"
- "\tcmp r4, r6\n"
- "\tbcc _08112F66\n"
- "_08112F98:\n"
- "\tmov r1, r9\n"
- "\tlsls r0, r1, 24\n"
- "\tlsrs r5, r0, 24\n"
- "\tcmp r5, r7\n"
- "\tbcc _08112F5A\n"
- "_08112FA2:\n"
- "\tldr r0, [sp]\n"
- "\tlsls r2, r0, 21\n"
- "\tlsrs r2, 16\n"
- "\tmov r0, r10\n"
- "\tmov r1, r8\n"
- "\tmovs r3, 0\n"
- "\tbl CopyToWindowPixelBuffer\n"
- "\tmov r0, r8\n"
- "\tbl Free\n"
- "_08112FB8:\n"
- "\tadd sp, 0x8\n"
- "\tpop {r3-r5}\n"
- "\tmov r8, r3\n"
- "\tmov r9, r4\n"
- "\tmov r10, r5\n"
- "\tpop {r4-r7}\n"
- "\tpop {r0}\n"
- "\tbx r0\n"
- "\t.align 2, 0\n"
- "_08112FC8: .4byte gUnknown_84566A8\n"
- "_08112FCC: .4byte 0x04000008");
-}
-#endif
-
-static void sub_8112FD0(void)
-{
- sub_8112F18(sHelpMessageWindowId);
-}
-
-static const u8 sHelpMessageTextColors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_DYNAMIC_COLOR_1, TEXT_COLOR_DARK_GREY};
-
-static void PrintHelpMessageText(const u8 *text)
-{
- AddTextPrinterParameterized4(sHelpMessageWindowId, 2, 2, 5, 1, 1, sHelpMessageTextColors, -1, text);
-}
-
-void PrintTextOnHelpMessageWindow(const u8 *text, u8 mode)
-{
- sub_8112FD0();
- PrintHelpMessageText(text);
- if (mode)
- CopyWindowToVram(sHelpMessageWindowId, mode);
-}
-
-
-// Probable file boundary, trainer_fan_club.c below, help_message.c above
-
-
-void ResetTrainerFanClub(void)
-{
- VarSet(VAR_FANCLUB_FAN_COUNTER, 0);
- VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, 0);
-}
-
-void Script_TryLoseFansFromPlayTimeAfterLinkBattle(void)
-{
- TryLoseFansFromPlayTimeAfterLinkBattle(TRAINER_FAN_CLUB);
-}
-
-static void TryLoseFansFromPlayTimeAfterLinkBattle(struct TrainerFanClub *fanClub)
-{
- if (DidPlayerGetFirstFans(fanClub))
- {
- TryLoseFansFromPlayTime(fanClub);
- VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, gSaveBlock2Ptr->playTimeHours);
- }
-}
-
-void Script_UpdateTrainerFanClubGameClear(void)
-{
- UpdateTrainerFanClubGameClear(TRAINER_FAN_CLUB);
-}
-
-static void UpdateTrainerFanClubGameClear(struct TrainerFanClub *fanClub)
-{
- if (!fanClub->gotInitialFans)
- {
- SetPlayerGotFirstFans(fanClub);
- SetInitialFansOfPlayer(fanClub);
- VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, gSaveBlock2Ptr->playTimeHours);
- FlagClear(FLAG_HIDE_SAFFRON_FAN_CLUB_BLACKBELT);
- FlagClear(FLAG_HIDE_SAFFRON_FAN_CLUB_ROCKER);
- FlagClear(FLAG_HIDE_SAFFRON_FAN_CLUB_WOMAN);
- FlagClear(FLAG_HIDE_SAFFRON_FAN_CLUB_BEAUTY);
- VarSet(VAR_MAP_SCENE_SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB, 1);
- }
-}
-
-ALIGNED(4) const u8 sCounterIncrements[] = {2, 1, 2, 1};
-
-static u8 TryGainNewFanFromCounter(struct TrainerFanClub *fanClub, u8 a1)
-{
- if (VarGet(VAR_MAP_SCENE_SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB) == 2)
- {
- if (fanClub->timer + sCounterIncrements[a1] >= 20)
- {
- if (GetNumFansOfPlayerInTrainerFanClub(fanClub) < 3)
- {
- PlayerGainRandomTrainerFan(fanClub);
- fanClub->timer = 0;
- }
- else
- fanClub->timer = 20;
- }
- else
- fanClub->timer += sCounterIncrements[a1];
- }
-
- return fanClub->timer;
-}
-
-
-static u8 PlayerGainRandomTrainerFan(struct TrainerFanClub *fanClub)
-{
- static const u8 sFanClubMemberIds[] =
- {
- FANCLUB_MEMBER2,
- FANCLUB_MEMBER4,
- FANCLUB_MEMBER6,
- FANCLUB_MEMBER1,
- FANCLUB_MEMBER8,
- FANCLUB_MEMBER7,
- FANCLUB_MEMBER5,
- FANCLUB_MEMBER3
- };
-
- u8 i;
- u8 idx = 0;
-
- for (i = 0; i < NUM_TRAINER_FAN_CLUB_MEMBERS; i++)
- {
- if (!(GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i])))
- {
- idx = i;
- if (Random() % 2)
- {
- SET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i]);
- return sFanClubMemberIds[i];
- }
- }
- }
-
- SET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]);
- return sFanClubMemberIds[idx];
-}
-
-static u8 PlayerLoseRandomTrainerFan(struct TrainerFanClub *fanClub)
-{
- static const u8 sFanClubMemberIds[] =
- {
- FANCLUB_MEMBER6,
- FANCLUB_MEMBER7,
- FANCLUB_MEMBER4,
- FANCLUB_MEMBER8,
- FANCLUB_MEMBER5,
- FANCLUB_MEMBER2,
- FANCLUB_MEMBER1,
- FANCLUB_MEMBER3
- };
-
- u8 i;
- u8 idx = 0;
-
- if (GetNumFansOfPlayerInTrainerFanClub(fanClub) == 1)
- return 0;
-
- for (i = 0; i < NUM_TRAINER_FAN_CLUB_MEMBERS; i++)
- {
- if (GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i]))
- {
- idx = i;
- if (Random() % 2)
- {
- FLIP_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i]);
- return sFanClubMemberIds[i];
+ sFlagOrVarRecords[i] = sDummyFlagOrVarRecord;
}
}
}
-
- if (GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]))
- FLIP_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]);
-
- return sFanClubMemberIds[idx];
-}
-
-u16 Script_GetNumFansOfPlayerInTrainerFanClub(void)
-{
- return GetNumFansOfPlayerInTrainerFanClub(TRAINER_FAN_CLUB);
-}
-
-static u16 GetNumFansOfPlayerInTrainerFanClub(struct TrainerFanClub *fanClub)
-{
- u8 count = 0;
- u8 i;
-
- for (i = 0; i < NUM_TRAINER_FAN_CLUB_MEMBERS; i++)
- {
- if (GET_TRAINER_FAN_CLUB_FLAG(i))
- count++;
- }
-
- return count;
-}
-
-void Script_TryLoseFansFromPlayTime(void)
-{
- TryLoseFansFromPlayTime(TRAINER_FAN_CLUB);
-}
-
-static void TryLoseFansFromPlayTime(struct TrainerFanClub *fanClub)
-{
- u8 i = 0;
- u16 timer;
-
- if (gSaveBlock2Ptr->playTimeHours < 999)
- {
- while (1)
- {
- if (GetNumFansOfPlayerInTrainerFanClub(fanClub) < 5)
- {
- VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, gSaveBlock2Ptr->playTimeHours);
- break;
- }
- if (i == NUM_TRAINER_FAN_CLUB_MEMBERS)
- break;
-
- timer = VarGet(VAR_FANCLUB_LOSE_FAN_TIMER);
- if (gSaveBlock2Ptr->playTimeHours - timer < 12)
- break;
-
- PlayerLoseRandomTrainerFan(fanClub);
- timer = VarGet(VAR_FANCLUB_LOSE_FAN_TIMER);
- VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, timer + 12);
- i++;
- }
- }
-}
-
-bool16 Script_IsFanClubMemberFanOfPlayer(void)
-{
- return IsFanClubMemberFanOfPlayer(TRAINER_FAN_CLUB);
-}
-
-static bool16 IsFanClubMemberFanOfPlayer(struct TrainerFanClub *fanClub)
-{
- return GET_TRAINER_FAN_CLUB_FLAG(gSpecialVar_0x8004);
-}
-
-static void SetInitialFansOfPlayer(struct TrainerFanClub *fanClub)
-{
- SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER1);
- SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER2);
- SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER3);
-}
-
-void Script_BufferFanClubTrainerName(void)
-{
- u8 whichLinkTrainer = 0;
- u8 whichNPCTrainer = 0;
-
- switch (gSpecialVar_0x8004)
- {
- case FANCLUB_MEMBER1:
- whichNPCTrainer = 0;
- whichLinkTrainer = 0;
- break;
- case FANCLUB_MEMBER2:
- case FANCLUB_MEMBER3:
- case FANCLUB_MEMBER4:
- case FANCLUB_MEMBER8:
- break;
- case FANCLUB_MEMBER5:
- whichNPCTrainer = 1;
- whichLinkTrainer = 0;
- break;
- case FANCLUB_MEMBER6:
- whichNPCTrainer = 0;
- whichLinkTrainer = 1;
- break;
- case FANCLUB_MEMBER7:
- whichNPCTrainer = 2;
- whichLinkTrainer = 1;
- break;
- }
- BufferFanClubTrainerName(&gSaveBlock2Ptr->linkBattleRecords, whichLinkTrainer, whichNPCTrainer);
-}
-
-static void BufferFanClubTrainerName(struct LinkBattleRecords *linkRecords, u8 whichLinkTrainer, u8 whichNPCTrainer)
-{
- u8 *str;
- const u8 *linkTrainerName = linkRecords->entries[whichLinkTrainer].name;
- if (linkTrainerName[0] == EOS)
- {
- switch (whichNPCTrainer)
- {
- case 0:
- StringCopy(gStringVar1, gSaveBlock1Ptr->rivalName);
- break;
- case 1:
- StringCopy(gStringVar1, gText_LtSurge);
- break;
- case 2:
- StringCopy(gStringVar1, gText_Koga);
- break;
- default:
- StringCopy(gStringVar1, gSaveBlock1Ptr->rivalName);
- break;
- }
- }
- else
- {
- str = gStringVar1;
- StringCopyN(str, linkTrainerName, PLAYER_NAME_LENGTH);
- str[PLAYER_NAME_LENGTH] = EOS;
- if ( str[0] == EXT_CTRL_CODE_BEGIN
- && str[1] == EXT_CTRL_CODE_JPN)
- {
- str += 2;
- while (*str != EOS)
- str++;
- *str++ = EXT_CTRL_CODE_BEGIN;
- *str++ = EXT_CTRL_CODE_ENG;
- *str++ = EOS;
- }
- }
-}
-
-void Special_UpdateTrainerFansAfterLinkBattle(void)
-{
- UpdateTrainerFansAfterLinkBattle(TRAINER_FAN_CLUB);
-}
-
-static void UpdateTrainerFansAfterLinkBattle(struct TrainerFanClub *fanClub)
-{
- if (VarGet(VAR_MAP_SCENE_SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB) == 2)
- {
- TryLoseFansFromPlayTimeAfterLinkBattle(fanClub);
- if (gBattleOutcome == B_OUTCOME_WON)
- PlayerGainRandomTrainerFan(fanClub);
- else
- PlayerLoseRandomTrainerFan(fanClub);
- }
-}
-
-static bool8 DidPlayerGetFirstFans(struct TrainerFanClub *fanClub)
-{
- return fanClub->gotInitialFans;
-}
-
-void Script_SetPlayerGotFirstFans(void)
-{
- SetPlayerGotFirstFans(TRAINER_FAN_CLUB);
-}
-
-static void SetPlayerGotFirstFans(struct TrainerFanClub *fanClub)
-{
- fanClub->gotInitialFans = TRUE;
-}
-
-u8 Script_TryGainNewFanFromCounter(void)
-{
- return TryGainNewFanFromCounter(TRAINER_FAN_CLUB, gSpecialVar_0x8004);
-}
-
-
-// Probable file boundary, quest_log_events.c below, trainer_fan_club.c above
-
-
-static u16 *(*const sQuestLogStorageCBs[])(u16 *, const u16 *) = {
- [QL_EVENT_0] = NULL,
- [QL_EVENT_1] = NULL,
- [QL_EVENT_2] = NULL,
- [QL_EVENT_SWITCHED_PARTY_ORDER] = BufferQuestLogData_SwitchedPartyOrder,
- [QL_EVENT_USED_ITEM] = BufferQuestLogData_UsedItem,
- [QL_EVENT_GAVE_HELD_ITEM] = BufferQuestLogData_GaveHeldItemFromPartyMenu,
- [QL_EVENT_GAVE_HELD_ITEM_BAG] = BufferQuestLogData_GaveHeldItemFromBagMenu,
- [QL_EVENT_GAVE_HELD_ITEM_PC] = BufferQuestLogData_GaveHeldItemFromPC,
- [QL_EVENT_TOOK_HELD_ITEM] = BufferQuestLogData_TookHeldItem,
- [QL_EVENT_SWAPPED_HELD_ITEM] = BufferQuestLogData_SwappedHeldItem,
- [QL_EVENT_SWAPPED_HELD_ITEM_PC] = BufferQuestLogData_SwappedHeldItemFromPC,
- [QL_EVENT_USED_PKMN_CENTER] = BufferQuestLogData_UsedPkmnCenter,
- [QL_EVENT_LINK_TRADED] = BufferQuestLogData_LinkTraded,
- [QL_EVENT_LINK_BATTLED_SINGLE] = BufferQuestLogData_LinkBattledSingle,
- [QL_EVENT_LINK_BATTLED_DOUBLE] = BufferQuestLogData_LinkBattledDouble,
- [QL_EVENT_LINK_BATTLED_MULTI] = BufferQuestLogData_LinkBattledMulti,
- [QL_EVENT_USED_UNION_ROOM] = BufferQuestLogData_UsedUnionRoom,
- [QL_EVENT_USED_UNION_ROOM_CHAT] = BufferQuestLogData_UsedUnionRoomChat,
- [QL_EVENT_LINK_TRADED_UNION] = BufferQuestLogData_LinkTradedUnionRoom,
- [QL_EVENT_LINK_BATTLED_UNION] = BufferQuestLogData_LinkBattledUnionRoom,
- [QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES] = BufferQuestLogData_SwitchedMonsBetweenBoxes,
- [QL_EVENT_SWITCHED_MONS_WITHIN_BOX] = BufferQuestLogData_SwitchedMonsWithinBox,
- [QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON] = BufferQuestLogData_SwitchedPartyMonForPCMon,
- [QL_EVENT_MOVED_MON_BETWEEN_BOXES] = BufferQuestLogData_MovedMonBetweenBoxes,
- [QL_EVENT_MOVED_MON_WITHIN_BOX] = BufferQuestLogData_MovedMonWithinBox,
- [QL_EVENT_WITHDREW_MON_PC] = BufferQuestLogData_WithdrewMonFromPC,
- [QL_EVENT_DEPOSITED_MON_PC] = BufferQuestLogData_DepositedMonInPC,
- [QL_EVENT_SWITCHED_MULTIPLE_MONS] = BufferQuestLogData_SwitchedMultipleMons,
- [QL_EVENT_DEPOSITED_ITEM_PC] = BufferQuestLogData_DepositedItemInPC,
- [QL_EVENT_WITHDREW_ITEM_PC] = BufferQuestLogData_WithdrewItemFromPC,
- [QL_EVENT_DEFEATED_GYM_LEADER] = BufferQuestLogData_DefeatedGymLeader,
- [QL_EVENT_DEFEATED_WILD_MON] = BufferQuestLogData_DefeatedWildMon,
- [QL_EVENT_DEFEATED_E4_MEMBER] = BufferQuestLogData_DefeatedEliteFourMember,
- [QL_EVENT_DEFEATED_CHAMPION] = BufferQuestLogData_DefeatedChampion,
- [QL_EVENT_DEFEATED_TRAINER] = BufferQuestLogData_DefeatedTrainer,
- [QL_EVENT_DEPARTED] = BufferQuestLogData_DepartedLocation,
- [QL_EVENT_USED_FIELD_MOVE] = BufferQuestLogData_UsedFieldMove,
- [QL_EVENT_BOUGHT_ITEM] = BufferQuestLogData_BoughtItem,
- [QL_EVENT_SOLD_ITEM] = BufferQuestLogData_SoldItem,
- [QL_EVENT_39] = NULL,
- [QL_EVENT_OBTAINED_ITEM] = BufferQuestLogData_ObtainedItem,
- [QL_EVENT_41] = NULL,
- [QL_EVENT_ARRIVED] = BufferQuestLogData_ArrivedInLocation
-};
-
-void SetQuestLogEvent(u16 eventId, const u16 *eventData)
-{
- u16 *r1;
-
- if (eventId == QL_EVENT_DEPARTED && gUnknown_203B048 == 2)
- {
- sub_811381C();
- return;
- }
- sub_811381C();
- if (gQuestLogState == QL_STATE_2)
- return;
-
- if (!IS_VALID_QL_EVENT(eventId))
- return;
-
- if (InQuestLogDisabledLocation() == TRUE)
- return;
-
- if (TrySetLinkQuestLogEvent(eventId, eventData) == TRUE)
- return;
-
- if (MenuHelpers_LinkSomething() == TRUE)
- return;
-
- if (InUnionRoom() == TRUE)
- return;
-
- if (TrySetTrainerBattleQuestLogEvent(eventId, eventData) == TRUE)
- return;
-
- if (IsQuestLogEventWithSpecialEncounterSpecies(eventId, eventData) == TRUE)
- return;
-
- if (sub_81153E4(eventId, eventData) == FALSE)
- return;
-
- if (gUnknown_3005E88 == 0)
- {
- if (sub_8113778(eventId, eventData) == TRUE)
- return;
-
- if (eventId != QL_EVENT_DEFEATED_WILD_MON || gUnknown_203AE04 == NULL)
- {
- if (sub_81153A8(eventId, eventData) == FALSE)
- return;
- StartRecordingQuestLogEntry(eventId);
- }
- }
- else if (eventId == QL_EVENT_OBTAINED_ITEM)
- return;
-
- sub_8113B94(eventId);
- if (eventId == QL_EVENT_DEFEATED_WILD_MON)
- {
- if (gUnknown_203AE04 == NULL)
- {
- gUnknown_203AE04 = sEventRecordingPointer;
- r1 = sQuestLogStorageCBs[eventId](gUnknown_203AE04, eventData);
- }
- else
- {
- sQuestLogStorageCBs[eventId](gUnknown_203AE04, eventData);
- return;
- }
- }
- else
- {
- gUnknown_203AE04 = NULL;
- r1 = sQuestLogStorageCBs[eventId](sEventRecordingPointer, eventData);
- }
-
- if (r1 == NULL)
- {
- sub_811231C();
- r1 = sub_8113828(eventId, eventData);
- if (r1 == NULL)
- return;
- }
-
- sEventRecordingPointer = r1;
- if (gUnknown_203B048 == 0)
- return;
- sub_811231C();
-}
-
-static bool8 InQuestLogDisabledLocation(void)
-{
- // In Trainer Tower
- if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRAINER_TOWER_1F)
- && (gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_1F)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_2F)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_3F)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_4F)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_5F)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_6F)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_7F)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_8F)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_ROOF)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_LOBBY)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_ELEVATOR)))
- return TRUE;
-
- // In pokemon trainer fan club
- if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB))
- return TRUE;
-
- // In E-Reader house
- if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SEVEN_ISLAND_HOUSE_ROOM1) &&
- (gSaveBlock1Ptr->location.mapNum == MAP_NUM(SEVEN_ISLAND_HOUSE_ROOM1)
- || gSaveBlock1Ptr->location.mapNum == MAP_NUM(SEVEN_ISLAND_HOUSE_ROOM2)))
- return TRUE;
-
- // In elevator
- if ((gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROCKET_HIDEOUT_ELEVATOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROCKET_HIDEOUT_ELEVATOR))
- || (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SILPH_CO_ELEVATOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SILPH_CO_ELEVATOR))
- || (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRAINER_TOWER_ELEVATOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_ELEVATOR))
- || (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(CELADON_CITY_DEPARTMENT_STORE_ELEVATOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(CELADON_CITY_DEPARTMENT_STORE_ELEVATOR)))
- return TRUE;
-
- return FALSE;
-}
-
-bool8 sub_8113748(void)
-{
- if (InQuestLogDisabledLocation() != TRUE)
- return FALSE;
-
- if (gQuestLogState == QL_STATE_2)
- return TRUE;
-
- if (gQuestLogState == QL_STATE_1)
- QuestLog_OnInteractionWithSpecialNpc();
-
- return FALSE;
-}
-
-static bool8 sub_8113778(u16 eventId, const u16 *eventData)
-{
- if (eventId == QL_EVENT_USED_FIELD_MOVE || eventId == QL_EVENT_USED_PKMN_CENTER)
- return TRUE;
-
- if (!FlagGet(FLAG_SYS_GAME_CLEAR))
- {
- if (eventId == QL_EVENT_SWITCHED_PARTY_ORDER || eventId == QL_EVENT_DEFEATED_WILD_MON || sub_81137E4(eventId, eventData) == TRUE)
- return TRUE;
- }
-
- if (!FlagGet(FLAG_SYS_CAN_LINK_WITH_RS))
- {
- if (eventId == QL_EVENT_USED_ITEM
- || eventId == QL_EVENT_GAVE_HELD_ITEM
- || eventId == QL_EVENT_GAVE_HELD_ITEM_BAG
- || eventId == QL_EVENT_GAVE_HELD_ITEM_PC
- || eventId == QL_EVENT_TOOK_HELD_ITEM
- || eventId == QL_EVENT_SWAPPED_HELD_ITEM
- || eventId == QL_EVENT_SWAPPED_HELD_ITEM_PC
- || eventId == QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON
- || eventId == QL_EVENT_WITHDREW_MON_PC
- || eventId == QL_EVENT_DEPOSITED_MON_PC)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static bool8 sub_81137E4(u16 eventId, const u16 *eventData)
-{
- if (eventId == QL_EVENT_DEFEATED_TRAINER)
- {
- u8 trainerClass = gTrainers[*eventData].trainerClass;
- if ( trainerClass == CLASS_RIVAL
- || trainerClass == CLASS_RIVAL_2
- || trainerClass == CLASS_CHAMPION_2
- || trainerClass == CLASS_BOSS)
- return FALSE;
- return TRUE;
- }
- return FALSE;
-}
-
-static void sub_811381C(void)
-{
- gUnknown_203B048 = 0;
-}
-
-static u16 *sub_8113828(u16 eventId, const u16 *eventData)
-{
- if (sub_8113778(eventId, eventData) == TRUE)
- return NULL;
-
- if (sub_81153A8(eventId, eventData) == FALSE)
- return NULL;
-
- StartRecordingQuestLogEntry(eventId);
- sub_8113B94(eventId);
-
- if (eventId == QL_EVENT_DEFEATED_WILD_MON)
- gUnknown_203AE04 = sEventRecordingPointer;
- else
- gUnknown_203AE04 = NULL;
-
- return sQuestLogStorageCBs[eventId](sEventRecordingPointer, eventData);
-}
-
-static bool8 TrySetLinkQuestLogEvent(u16 eventId, const u16 *eventData)
-{
- if (!IS_LINK_QL_EVENT(eventId))
- return FALSE;
-
- sub_81138F8();
- gUnknown_203B024.unk_00 = eventId;
-
- if (eventId != QL_EVENT_USED_UNION_ROOM && eventId != QL_EVENT_USED_UNION_ROOM_CHAT)
- {
- if (eventId == QL_EVENT_LINK_TRADED || eventId == QL_EVENT_LINK_TRADED_UNION)
- memcpy(gUnknown_203B024.unk_04, eventData, 12);
- else
- memcpy(gUnknown_203B024.unk_04, eventData, 24);
- }
- return TRUE;
-}
-
-void sub_81138F8(void)
-{
- gUnknown_203B024 = (struct UnkStruct_203B024){};
-}
-
-void QuestLog_StartRecordingInputsAfterDeferredEvent(void)
-{
- if (gUnknown_203B024.unk_00 != QL_EVENT_0)
- {
- u16 *resp;
- gUnknown_203B04A = 0;
- StartRecordingQuestLogEntry(gUnknown_203B024.unk_00);
- resp = sQuestLogStorageCBs[gUnknown_203B024.unk_00](sEventRecordingPointer, gUnknown_203B024.unk_04);
- sEventRecordingPointer = resp;
- sub_81138F8();
- }
-}
-
-static bool8 TrySetTrainerBattleQuestLogEvent(u16 eventId, const u16 *eventData)
-{
- if (eventId != QL_EVENT_DEFEATED_TRAINER
- && eventId != QL_EVENT_DEFEATED_GYM_LEADER
- && eventId != QL_EVENT_DEFEATED_E4_MEMBER
- && eventId != QL_EVENT_DEFEATED_CHAMPION)
- return FALSE;
-
- sub_81138F8();
- if (gUnknown_3005E88 != 0 || FlagGet(FLAG_SYS_GAME_CLEAR) || sub_81137E4(eventId, eventData) != TRUE)
- {
- gUnknown_203B024.unk_00 = eventId;
- memcpy(gUnknown_203B024.unk_04, eventData, 8);
- }
- return TRUE;
-}
-
-void sub_81139BC(void)
-{
- if (gUnknown_203B024.unk_00 != QL_EVENT_0)
- {
- u16 *resp;
- if (gUnknown_3005E88 == 0)
- {
- gUnknown_203B04A = 0;
- StartRecordingQuestLogEntry(gUnknown_203B024.unk_00);
- }
- sub_8113B94(gUnknown_203B024.unk_00);
- resp = sQuestLogStorageCBs[gUnknown_203B024.unk_00](sEventRecordingPointer, gUnknown_203B024.unk_04);
- sEventRecordingPointer = resp;
- TryRecordEvent41_IncCursor(1);
- sub_81138F8();
- sub_811231C();
- }
-}
-
-static void TryRecordEvent41_IncCursor(u16 a0)
-{
- sEventRecordingPointer = TryRecordEvent41(sEventRecordingPointer, a0);
- sQuestLogCursor++;
-}
-
-static bool8 IsQuestLogEventWithSpecialEncounterSpecies(u16 eventId, const u16 *eventData)
-{
- if (eventId != QL_EVENT_DEFEATED_WILD_MON)
- return FALSE;
-
- if (IsSpeciesFromSpecialEncounter(eventData[0]) == TRUE)
- return TRUE;
-
- if (IsSpeciesFromSpecialEncounter(eventData[1]) == TRUE)
- return TRUE;
-
- return FALSE;
-}
-
-static const u16 *(*const sQuestLogEventTextBufferCBs[])(const u16 *) = {
- [QL_EVENT_0] = NULL,
- [QL_EVENT_1] = NULL,
- [QL_EVENT_2] = NULL,
- [QL_EVENT_SWITCHED_PARTY_ORDER] = BufferQuestLogText_SwitchedPartyOrder,
- [QL_EVENT_USED_ITEM] = BufferQuestLogText_UsedItem,
- [QL_EVENT_GAVE_HELD_ITEM] = BufferQuestLogText_GaveHeldItemFromPartyMenu,
- [QL_EVENT_GAVE_HELD_ITEM_BAG] = BufferQuestLogText_GaveHeldItemFromBagMenu,
- [QL_EVENT_GAVE_HELD_ITEM_PC] = BufferQuestLogText_GaveHeldItemFromPC,
- [QL_EVENT_TOOK_HELD_ITEM] = BufferQuestLogText_TookHeldItem,
- [QL_EVENT_SWAPPED_HELD_ITEM] = BufferQuestLogText_SwappedHeldItem,
- [QL_EVENT_SWAPPED_HELD_ITEM_PC] = BufferQuestLogText_SwappedHeldItemFromPC,
- [QL_EVENT_USED_PKMN_CENTER] = BufferQuestLogText_UsedPkmnCenter,
- [QL_EVENT_LINK_TRADED] = BufferQuestLogText_LinkTraded,
- [QL_EVENT_LINK_BATTLED_SINGLE] = BufferQuestLogText_LinkBattledSingle,
- [QL_EVENT_LINK_BATTLED_DOUBLE] = BufferQuestLogText_LinkBattledDouble,
- [QL_EVENT_LINK_BATTLED_MULTI] = BufferQuestLogText_LinkBattledMulti,
- [QL_EVENT_USED_UNION_ROOM] = BufferQuestLogText_UsedUnionRoom,
- [QL_EVENT_USED_UNION_ROOM_CHAT] = BufferQuestLogText_UsedUnionRoomChat,
- [QL_EVENT_LINK_TRADED_UNION] = BufferQuestLogText_LinkTradedUnionRoom,
- [QL_EVENT_LINK_BATTLED_UNION] = BufferQuestLogText_LinkBattledUnionRoom,
- [QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES] = BufferQuestLogText_SwitchedMonsBetweenBoxes,
- [QL_EVENT_SWITCHED_MONS_WITHIN_BOX] = BufferQuestLogText_SwitchedMonsWithinBox,
- [QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON] = BufferQuestLogText_SwitchedPartyMonForPCMon,
- [QL_EVENT_MOVED_MON_BETWEEN_BOXES] = BufferQuestLogText_MovedMonBetweenBoxes,
- [QL_EVENT_MOVED_MON_WITHIN_BOX] = BufferQuestLogText_MovedMonWithinBox,
- [QL_EVENT_WITHDREW_MON_PC] = BufferQuestLogText_WithdrewMonFromPC,
- [QL_EVENT_DEPOSITED_MON_PC] = BufferQuestLogText_DepositedMonInPC,
- [QL_EVENT_SWITCHED_MULTIPLE_MONS] = BufferQuestLogText_SwitchedMultipleMons,
- [QL_EVENT_DEPOSITED_ITEM_PC] = BufferQuestLogText_DepositedItemInPC,
- [QL_EVENT_WITHDREW_ITEM_PC] = BufferQuestLogText_WithdrewItemFromPC,
- [QL_EVENT_DEFEATED_GYM_LEADER] = BufferQuestLogText_DefeatedGymLeader,
- [QL_EVENT_DEFEATED_WILD_MON] = BufferQuestLogText_DefeatedWildMon,
- [QL_EVENT_DEFEATED_E4_MEMBER] = BufferQuestLogText_DefeatedEliteFourMember,
- [QL_EVENT_DEFEATED_CHAMPION] = BufferQuestLogText_DefeatedChampion,
- [QL_EVENT_DEFEATED_TRAINER] = BufferQuestLogText_DefeatedTrainer,
- [QL_EVENT_DEPARTED] = BufferQuestLogText_DepartedLocation,
- [QL_EVENT_USED_FIELD_MOVE] = BufferQuestLogText_UsedFieldMove,
- [QL_EVENT_BOUGHT_ITEM] = BufferQuestLogText_BoughtItem,
- [QL_EVENT_SOLD_ITEM] = BufferQuestLogText_SoldItem,
- [QL_EVENT_39] = NULL,
- [QL_EVENT_OBTAINED_ITEM] = BufferQuestLogText_ObtainedItem,
- [QL_EVENT_41] = NULL,
- [QL_EVENT_ARRIVED] = BufferQuestLogText_ArrivedInLocation
-};
-
-static const u8 sQuestLogEventCmdSizes[] = {
- [QL_EVENT_0] = 0x08,
- [QL_EVENT_1] = 0x08,
- [QL_EVENT_2] = 0x08,
- [QL_EVENT_SWITCHED_PARTY_ORDER] = 0x08,
- [QL_EVENT_USED_ITEM] = 0x0a,
- [QL_EVENT_GAVE_HELD_ITEM] = 0x08,
- [QL_EVENT_GAVE_HELD_ITEM_BAG] = 0x08,
- [QL_EVENT_GAVE_HELD_ITEM_PC] = 0x08,
- [QL_EVENT_TOOK_HELD_ITEM] = 0x08,
- [QL_EVENT_SWAPPED_HELD_ITEM] = 0x0a,
- [QL_EVENT_SWAPPED_HELD_ITEM_PC] = 0x0a,
- [QL_EVENT_USED_PKMN_CENTER] = 0x04,
- [QL_EVENT_LINK_TRADED] = 0x10,
- [QL_EVENT_LINK_BATTLED_SINGLE] = 0x0c,
- [QL_EVENT_LINK_BATTLED_DOUBLE] = 0x0c,
- [QL_EVENT_LINK_BATTLED_MULTI] = 0x1a,
- [QL_EVENT_USED_UNION_ROOM] = 0x04,
- [QL_EVENT_USED_UNION_ROOM_CHAT] = 0x04,
- [QL_EVENT_LINK_TRADED_UNION] = 0x10,
- [QL_EVENT_LINK_BATTLED_UNION] = 0x0c,
- [QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES] = 0x0a,
- [QL_EVENT_SWITCHED_MONS_WITHIN_BOX] = 0x0a,
- [QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON] = 0x0a,
- [QL_EVENT_MOVED_MON_BETWEEN_BOXES] = 0x08,
- [QL_EVENT_MOVED_MON_WITHIN_BOX] = 0x08,
- [QL_EVENT_WITHDREW_MON_PC] = 0x08,
- [QL_EVENT_DEPOSITED_MON_PC] = 0x08,
- [QL_EVENT_SWITCHED_MULTIPLE_MONS] = 0x06,
- [QL_EVENT_DEPOSITED_ITEM_PC] = 0x06,
- [QL_EVENT_WITHDREW_ITEM_PC] = 0x06,
- [QL_EVENT_DEFEATED_GYM_LEADER] = 0x0c,
- [QL_EVENT_DEFEATED_WILD_MON] = 0x0c,
- [QL_EVENT_DEFEATED_E4_MEMBER] = 0x0c,
- [QL_EVENT_DEFEATED_CHAMPION] = 0x0a,
- [QL_EVENT_DEFEATED_TRAINER] = 0x0c,
- [QL_EVENT_DEPARTED] = 0x06,
- [QL_EVENT_USED_FIELD_MOVE] = 0x08,
- [QL_EVENT_BOUGHT_ITEM] = 0x0e,
- [QL_EVENT_SOLD_ITEM] = 0x0e,
- [QL_EVENT_39] = 0x02,
- [QL_EVENT_OBTAINED_ITEM] = 0x08,
- [QL_EVENT_41] = 0x04,
- [QL_EVENT_ARRIVED] = 0x06
-};
-
-static u16 *QuestLog_SkipCommand(u16 *curPtr, u16 **prevPtr_p)
-{
- u16 eventId = curPtr[0] & 0xfff;
- u16 cnt = curPtr[0] >> 12;
-
- if (eventId == QL_EVENT_DEFEATED_CHAMPION)
- cnt = 0;
-
- if (!IS_VALID_QL_EVENT(eventId))
- return NULL;
-
- *prevPtr_p = curPtr;
- return sQuestLogEventCmdSizes[eventId] + (sQuestLogEventCmdSizes[eventId] - 4) * cnt + (void *)curPtr;
-}
-
-static void sub_8113ABC(const u16 *a0)
-{
- const u8 *r2 = (const u8 *)(a0 + 2);
- if ((a0[0] & 0xFFF) != QL_EVENT_DEPARTED)
- gUnknown_203B04A = 0;
- else
- gUnknown_203B04A = r2[1] + 1;
-}
-
-static bool8 sub_8113AE8(const u16 *a0)
-{
-#ifndef NONMATCHING
- register const u16 *r0 asm("r0") = a0;
-#else
- const u16 *r0 = a0;
-#endif
-
- if (r0 == NULL || r0[1] > sQuestLogCursor)
- return FALSE;
-
- sQuestLogEventTextBufferCBs[a0[0] & 0xFFF](a0);
- gUnknown_203B044.unk_0 = a0[0];
- gUnknown_203B044.unk_1 = (a0[0] & 0xF000) >> 12;
- if (gUnknown_203B044.unk_1 != 0)
- gUnknown_203B044.unk_2 = 1;
- return TRUE;
-}
-
-static bool8 sub_8113B44(const u16 *a0)
-{
- if (gUnknown_203B044.unk_2 == 0)
- return FALSE;
-
- sQuestLogEventTextBufferCBs[gUnknown_203B044.unk_0](a0);
- gUnknown_203B044.unk_2++;
- if (gUnknown_203B044.unk_2 > gUnknown_203B044.unk_1)
- sub_8113B88();
- return TRUE;
-}
-
-static void sub_8113B88(void)
-{
- gUnknown_203B044 = (struct UnkStruct_203B044){};
-}
-
-static void sub_8113B94(u16 eventId)
-{
- if (gUnknown_203B044.unk_0 != (u8)eventId || gUnknown_203B044.unk_2 != sQuestLogCursor)
- {
- gUnknown_203B044.unk_0 = eventId;
- gUnknown_203B044.unk_1 = 0;
- gUnknown_203B044.unk_2 = sQuestLogCursor;
- }
- else if (gUnknown_203B044.unk_1 < 5)
- gUnknown_203B044.unk_1++;
-}
-
-static void sub_8113BD8(void)
-{
- sNewlyEnteredMap = FALSE;
- gUnknown_203B04A = 0;
- gUnknown_203B04B = FALSE;
-}
-
-static u16 *TryRecordEvent39_NoParams(u16 *a0)
-{
- if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_39]))
- return NULL;
- a0[0] = QL_EVENT_39;
- return a0 + 1;
-}
-
-static u16 *sub_8113C20(u16 *a0, struct QuestLogEntry * a1)
-{
- if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_39]))
- return NULL;
- a1->unk_6 = 0xFF;
- a1->unk_4 = 0;
- a1->unk_0 = 0;
- a1->unk_1 = 0;
- a1->unk_2 = 0;
- a1->unk_3 = 0;
- return a0 + 1;
-}
-
-static u16 *TryRecordEvent41(u16 *a0, u16 a1)
-{
- if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_41]))
- return NULL;
- a0[0] = QL_EVENT_41;
- a0[1] = a1;
- return a0 + 2;
-}
-
-static u16 *sub_8113C8C(u16 *a0, struct QuestLogEntry * a1)
-{
- if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_41]))
- return NULL;
- a1->unk_6 = 0xFE;
- a1->unk_4 = a0[1];
- a1->unk_0 = 0;
- a1->unk_1 = 0;
- a1->unk_2 = 0;
- a1->unk_3 = 0;
- return a0 + 2;
-}
-
-static u16 *sub_8113CC8(u16 *a0, struct QuestLogEntry * a1)
-{
- u8 *r6 = (u8 *)a0 + 4;
-
- if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_0]))
- return NULL;
- a0[0] = 0;
- a0[1] = a1->unk_4;
- r6[0] = a1->unk_0;
- r6[1] = a1->unk_1;
- r6[2] = a1->unk_2;
- r6[3] = a1->unk_3;
- return (u16 *)(r6 + 4);
-}
-
-static u16 *sub_8113D08(u16 *a0, struct QuestLogEntry * a1)
-{
- u8 *r6 = (u8 *)a0 + 4;
-
- if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_0]))
- return NULL;
- a1->unk_6 = 2;
- a1->unk_4 = a0[1];
- a1->unk_0 = r6[0];
- a1->unk_1 = r6[1];
- a1->unk_2 = r6[2];
- a1->unk_3 = r6[3];
- return (u16 *)(r6 + 4);
-}
-
-static u16 *sub_8113D48(u16 *a0, struct QuestLogEntry * a1)
-{
- u16 *r4 = a0;
- u8 *r6 = (u8 *)a0 + 4;
-
- if (!WillCommandOfSizeFitInSav1Record(r4, sQuestLogEventCmdSizes[QL_EVENT_2]))
- return NULL;
- if (a1->unk_6 == 0)
- r4[0] = 2;
- else
- r4[0] = 1;
- r4[1] = a1->unk_4;
- r6[0] = a1->unk_0;
- r6[1] = a1->unk_1;
- r6[2] = a1->unk_2;
- r6[3] = a1->unk_3;
- return (u16 *)(r6 + 4);
-}
-
-static u16 *sub_8113D94(u16 *a0, struct QuestLogEntry * a1)
-{
- u16 *r5 = a0;
- u8 *r6 = (u8 *)a0 + 4;
-
- if (!WillCommandOfSizeFitInSav1Record(r5, sQuestLogEventCmdSizes[QL_EVENT_2]))
- return NULL;
- if (r5[0] == 2)
- a1->unk_6 = 0;
- else
- a1->unk_6 = 1;
- a1->unk_4 = r5[1];
- a1->unk_0 = r6[0];
- a1->unk_1 = r6[1];
- a1->unk_2 = r6[2];
- a1->unk_3 = r6[3];
- return (u16 *)(r6 + 4);
-}
-
-u16 *sub_8113DE0(u16 eventId, u16 *a1)
-{
- u8 cmdSize;
- u16 *r5;
- u8 r4;
- u8 r1;
-
- if (gUnknown_203B044.unk_1 == 0)
- cmdSize = sQuestLogEventCmdSizes[eventId];
- else
- cmdSize = sQuestLogEventCmdSizes[eventId] - 4;
- if (!sub_8110944(a1, cmdSize))
- return NULL;
-
- r5 = (void *)a1;
-
- if (gUnknown_203B044.unk_1 != 0)
- r5 = (void *)r5 - (gUnknown_203B044.unk_1 * cmdSize + 4);
-
- if (gUnknown_203B044.unk_1 == 5)
- {
- for (r4 = 0; r4 < 4; r4++)
- {
- memcpy(
- (void *)r5 + (r4 * cmdSize + 4),
- (void *)r5 + ((r4 + 1) * cmdSize + 4),
- cmdSize
- );
- }
- r1 = 4;
- }
- else
- r1 = gUnknown_203B044.unk_1;
-
- r5[0] = eventId + (r1 << 12);
- r5[1] = sQuestLogCursor;
- r5 = (void *)r5 + (r1 * cmdSize + 4);
- return r5;
-}
-
-static const u16 *sub_8113E88(u16 eventId, const u16 *eventData)
-{
- eventData = (const void *)eventData + (gUnknown_203B044.unk_2 * (sQuestLogEventCmdSizes[eventId] - 4) + 4);
- return eventData;
-}
-
-static void QuestLog_GetSpeciesName(u16 species, u8 *dest, u8 stringVarId)
-{
- if (dest != NULL)
- {
- if (species != SPECIES_EGG)
- GetSpeciesName(dest, species);
- else
- StringCopy(dest, gText_EggNickname);
- }
- else
- {
- if (species != SPECIES_EGG)
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(stringVarId, gSpeciesNames[species]);
- else
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(stringVarId, gText_EggNickname);
- }
-}
-
-static u16 *BufferQuestLogData_SwitchedPartyOrder(u16 *a0, const u16 *eventData)
-{
- u16 *r2 = sub_8113DE0(QL_EVENT_SWITCHED_PARTY_ORDER, a0);
- if (r2 == NULL)
- return NULL;
-
- r2[0] = eventData[0];
- r2[1] = eventData[1];
- return r2 + 2;
-}
-
-static const u16 *BufferQuestLogText_SwitchedPartyOrder(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_SWITCHED_PARTY_ORDER, eventData);
- QuestLog_GetSpeciesName(r4[0], gStringVar1, 0);
- QuestLog_GetSpeciesName(r4[1], gStringVar2, 0);
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchMon1WithMon2);
- r4 += 2;
- return r4;
-}
-
-static u16 *BufferQuestLogData_UsedItem(u16 *a0, const u16 *eventData)
-{
- u16 *r2 = sub_8113DE0(QL_EVENT_USED_ITEM, a0);
- if (r2 == NULL)
- return NULL;
-
- r2[0] = eventData[0];
- r2[1] = eventData[2];
- r2[2] = eventData[3];
-
- if (eventData[0] == ITEM_ESCAPE_ROPE)
- gUnknown_203B048 = 2;
-
- return r2 + 3;
-}
-
-static const u16 *BufferQuestLogText_UsedItem(const u16 *eventData)
-{
- const u16 *r5 = sub_8113E88(QL_EVENT_USED_ITEM, eventData);
-
- switch (ItemId_GetPocket(r5[0]))
- {
- case POCKET_ITEMS:
- case POCKET_POKE_BALLS:
- case POCKET_BERRY_POUCH:
- StringCopy(gStringVar1, ItemId_GetName(r5[0]));
- if (r5[0] == ITEM_ESCAPE_ROPE)
- {
- GetMapNameGeneric(gStringVar2, (u8)r5[2]);
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_UsedEscapeRope);
- }
- else if (r5[1] != 0xFFFF)
- {
- QuestLog_GetSpeciesName(r5[1], gStringVar2, 0);
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_UsedItemOnMonAtThisLocation);
- }
- else
- {
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_UsedTheItem);
- }
- break;
- case POCKET_KEY_ITEMS:
- StringCopy(gStringVar1, ItemId_GetName(r5[0]));
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_UsedTheKeyItem);
- break;
- case POCKET_TM_CASE:
- QuestLog_GetSpeciesName(r5[1], gStringVar1, 0);
- StringCopy(gStringVar2, gMoveNames[ItemIdToBattleMoveId(r5[0])]);
- if (r5[2] != 0xFFFF)
- {
- StringCopy(gStringVar3, gMoveNames[r5[2]]);
- if (r5[0] > ITEM_TM50)
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonReplacedMoveWithHM);
- else
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonReplacedMoveWithTM);
- }
- else
- {
- if (r5[0] > ITEM_TM50)
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonLearnedMoveFromHM);
- else
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonLearnedMoveFromTM);
- }
- break;
- }
- return r5 + 3;
-}
-
-u16 *BufferQuestLogData_GiveTakeHeldItem(u16 eventId, u16 *a1, const u16 *eventData)
-{
- u16 *r1 = sub_8113DE0(eventId, a1);
- if (r1 == NULL)
- return NULL;
-
- r1[0] = eventData[0];
- r1[1] = eventData[2];
- return r1 + 2;
-}
-
-static u16 *BufferQuestLogData_GaveHeldItemFromPartyMenu(u16 *a0, const u16 *eventData)
-{
- return BufferQuestLogData_GiveTakeHeldItem(QL_EVENT_GAVE_HELD_ITEM, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_GaveHeldItemFromPartyMenu(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_GAVE_HELD_ITEM, eventData);
- QuestLog_GetSpeciesName(r4[1], gStringVar1, 0);
- StringCopy(gStringVar2, ItemId_GetName(r4[0]));
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_GaveMonHeldItem);
- r4 += 2;
- return r4;
-}
-
-static u16 *BufferQuestLogData_GaveHeldItemFromBagMenu(u16 *a0, const u16 *eventData)
-{
- return BufferQuestLogData_GiveTakeHeldItem(QL_EVENT_GAVE_HELD_ITEM_BAG, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_GaveHeldItemFromBagMenu(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_GAVE_HELD_ITEM_BAG, eventData);
- QuestLog_GetSpeciesName(r4[1], gStringVar1, 0);
- StringCopy(gStringVar2, ItemId_GetName(r4[0]));
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_GaveMonHeldItem2);
- r4 += 2;
- return r4;
-}
-
-static u16 *BufferQuestLogData_GaveHeldItemFromPC(u16 *a0, const u16 *eventData)
-{
- return BufferQuestLogData_GiveTakeHeldItem(QL_EVENT_GAVE_HELD_ITEM_PC, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_GaveHeldItemFromPC(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_GAVE_HELD_ITEM_PC, eventData);
-
- QuestLog_GetSpeciesName(r4[1], gStringVar2, 0);
- StringCopy(gStringVar1, ItemId_GetName(r4[0]));
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_GaveMonHeldItemFromPC);
- r4 += 2;
- return r4;
-}
-
-static u16 *BufferQuestLogData_TookHeldItem(u16 *a0, const u16 *eventData)
-{
- return BufferQuestLogData_GiveTakeHeldItem(QL_EVENT_TOOK_HELD_ITEM, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_TookHeldItem(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_TOOK_HELD_ITEM, eventData);
-
- QuestLog_GetSpeciesName(r4[1], gStringVar1, 0);
- StringCopy(gStringVar2, ItemId_GetName(r4[0]));
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_TookHeldItemFromMon);
- r4 += 2;
- return r4;
-}
-
-u16 *BufferQuestLogData_SwappedHeldItem_(u16 eventId, u16 *a1, const u16 *eventData)
-{
- u16 *r1 = sub_8113DE0(eventId, a1);
- if (r1 == NULL)
- return NULL;
-
- r1[0] = eventData[0];
- r1[1] = eventData[1];
- r1[2] = eventData[2];
- return r1 + 3;
-}
-
-static u16 *BufferQuestLogData_SwappedHeldItem(u16 *a0, const u16 *eventData)
-{
- return BufferQuestLogData_SwappedHeldItem_(QL_EVENT_SWAPPED_HELD_ITEM, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_SwappedHeldItem(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_SWAPPED_HELD_ITEM, eventData);
- QuestLog_GetSpeciesName(r4[2], gStringVar1, 0);
- StringCopy(gStringVar2, ItemId_GetName(r4[0])); // Item taken
- StringCopy(gStringVar3, ItemId_GetName(r4[1])); // Item given
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_SwappedHeldItemsOnMon);
- r4 += 3;
- return r4;
-}
-
-static u16 *BufferQuestLogData_SwappedHeldItemFromPC(u16 *a0, const u16 *eventData)
-{
- return BufferQuestLogData_SwappedHeldItem_(QL_EVENT_SWAPPED_HELD_ITEM_PC, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_SwappedHeldItemFromPC(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_SWAPPED_HELD_ITEM_PC, eventData);
- QuestLog_GetSpeciesName(r4[2], gStringVar2, 0);
- StringCopy(gStringVar3, ItemId_GetName(r4[0]));
- StringCopy(gStringVar1, ItemId_GetName(r4[1]));
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_SwappedHeldItemFromPC);
- r4 += 3;
- return r4;
-}
-
-static u16 *BufferQuestLogData_UsedPkmnCenter(u16 *a0, const u16 *eventData)
-{
- u16 *r4 = a0;
- if (gUnknown_203B044.unk_0 == QL_EVENT_USED_PKMN_CENTER && gUnknown_203B044.unk_1 != 0)
- return r4;
-
- if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_USED_PKMN_CENTER]))
- return NULL;
-
- r4[0] = QL_EVENT_USED_PKMN_CENTER;
- r4[1] = sQuestLogCursor;
- return r4 + 2;
-}
-
-static const u16 *BufferQuestLogText_UsedPkmnCenter(const u16 *a0)
-{
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonsWereFullyRestoredAtCenter);
- a0 += 2;
- return a0;
-}
-
-static u16 *BufferQuestLogData_LinkTraded(u16 *a0, const u16 *eventData)
-{
- u16 *r4 = a0 + 4;
-
- a0[0] = QL_EVENT_LINK_TRADED;
- a0[1] = sQuestLogCursor;
- a0[2] = eventData[0];
- a0[3] = eventData[1];
- eventData += 2;
- memcpy(r4, eventData, 7);
- r4 += 4;
- return r4;
-}
-
-static const u16 *BufferQuestLogText_LinkTraded(const u16 *a0)
-{
- const u16 *r6 = a0 + 4;
-
- memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
- memcpy(gStringVar1, r6, PLAYER_NAME_LENGTH);
-
- BufferLinkPartnersName(gStringVar1);
- QuestLog_GetSpeciesName(a0[3], gStringVar2, 0); // Mon received
- QuestLog_GetSpeciesName(a0[2], gStringVar3, 0); // Mon sent
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_TradedMon1ForPersonsMon2);
- r6 += 4;
- return r6;
-}
-
-static const u8 *const sDefeatedOpponentFlavorTexts[] = {
- gText_QuestLog_Handily,
- gText_QuestLog_Tenaciously,
- gText_QuestLog_Somehow
-};
-
-static const u8 *const sDefeatedChampionFlavorTexts[] = {
- gText_QuestLog_Coolly,
- gText_QuestLog_Somehow,
- gText_QuestLog_Barely
-};
-
-static const u8 *const sBattleOutcomeTexts[] = {
- gText_QuestLog_Win,
- gText_QuestLog_Loss,
- gText_QuestLog_Draw
-};
-
-static u16 *BufferQuestLogData_LinkBattledSingle(u16 *a0, const u16 *eventData)
-{
- a0[0] = QL_EVENT_LINK_BATTLED_SINGLE;
- a0[1] = sQuestLogCursor;
- *((u8 *)a0 + 4) = *((const u8 *)eventData + 0);
- memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH);
- a0 += 6;
- return a0;
-}
-
-static const u16 *BufferQuestLogText_LinkBattledSingle(const u16 *a0)
-{
- DynamicPlaceholderTextUtil_Reset();
-
- memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
- memcpy(gStringVar1, (const u8 *)a0 + 5, PLAYER_NAME_LENGTH);
- BufferLinkPartnersName(gStringVar1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, sBattleOutcomeTexts[((const u8 *)a0)[4]]);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SingleBattleWithPersonResultedInOutcome);
- a0 += 6;
- return a0;
-}
-
-static u16 *BufferQuestLogData_LinkBattledDouble(u16 *a0, const u16 *eventData)
-{
- a0[0] = QL_EVENT_LINK_BATTLED_DOUBLE;
- a0[1] = sQuestLogCursor;
- *((u8 *)a0 + 4) = *((const u8 *)eventData + 0);
- memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH);
- a0 += 6;
- return a0;
-}
-
-static const u16 *BufferQuestLogText_LinkBattledDouble(const u16 *a0)
-{
- DynamicPlaceholderTextUtil_Reset();
-
- memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
- memcpy(gStringVar1, (const u8 *)a0 + 5, PLAYER_NAME_LENGTH);
- BufferLinkPartnersName(gStringVar1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, sBattleOutcomeTexts[((const u8 *)a0)[4]]);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DoubleBattleWithPersonResultedInOutcome);
- a0 += 6;
- return a0;
-}
-
-static u16 *BufferQuestLogData_LinkBattledMulti(u16 *a0, const u16 *eventData)
-{
- a0[0] = QL_EVENT_LINK_BATTLED_MULTI;
- a0[1] = sQuestLogCursor;
- *((u8 *)a0 + 4) = *((const u8 *)eventData + 0);
- memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH);
- memcpy((u8 *)a0 + 12, (const u8 *)eventData + 8, PLAYER_NAME_LENGTH);
- memcpy((u8 *)a0 + 19, (const u8 *)eventData + 15, PLAYER_NAME_LENGTH);
- a0 += 13;
- return a0;
-}
-
-static const u16 *BufferQuestLogText_LinkBattledMulti(const u16 *a0)
-{
- DynamicPlaceholderTextUtil_Reset();
-
- memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
- memset(gStringVar2, EOS, PLAYER_NAME_LENGTH + 1);
- memset(gStringVar3, EOS, PLAYER_NAME_LENGTH + 1);
- StringCopy7(gStringVar1, (const u8 *)a0 + 5);
- StringCopy7(gStringVar2, (const u8 *)a0 + 12);
- StringCopy7(gStringVar3, (const u8 *)a0 + 19);
- BufferLinkPartnersName(gStringVar1);
- BufferLinkPartnersName(gStringVar2);
- BufferLinkPartnersName(gStringVar3);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gStringVar1); // partner
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar2); // opponent 1
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, gStringVar3); // opponent 2
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, sBattleOutcomeTexts[((const u8 *)a0)[4]]);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_MultiBattleWithPeopleResultedInOutcome);
- a0 += 13;
- return a0;
-}
-
-static u16 *BufferQuestLogData_UsedUnionRoom(u16 *a0, const u16 *eventData)
-{
- a0[0] = QL_EVENT_USED_UNION_ROOM;
- a0[1] = sQuestLogCursor;
- return a0 + 2;
-}
-
-static const u16 *BufferQuestLogText_UsedUnionRoom(const u16 *a0)
-{
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_MingledInUnionRoom);
- a0 += 2;
- return a0;
-}
-
-static u16 *BufferQuestLogData_UsedUnionRoomChat(u16 *a0, const u16 *eventData)
-{
- a0[0] = QL_EVENT_USED_UNION_ROOM_CHAT;
- a0[1] = sQuestLogCursor;
- return a0 + 2;
-}
-
-static const u16 *BufferQuestLogText_UsedUnionRoomChat(const u16 *a0)
-{
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_ChattedWithManyTrainers);
- a0 += 2;
- return a0;
-}
-
-static u16 *BufferQuestLogData_LinkTradedUnionRoom(u16 *a0, const u16 *eventData)
-{
- u8 *r4 = (u8 *)(a0 + 4);
- a0[0] = QL_EVENT_LINK_TRADED_UNION;
- a0[1] = sQuestLogCursor;
- a0[2] = eventData[0];
- a0[3] = eventData[1];
- memcpy(r4, eventData + 2, PLAYER_NAME_LENGTH);
- r4 += 8;
- return (u16 *)r4;
-}
-
-static const u16 *BufferQuestLogText_LinkTradedUnionRoom(const u16 *a0)
-{
- const u8 *r6 = (const u8 *)(a0 + 4);
- memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
- memcpy(gStringVar1, r6, PLAYER_NAME_LENGTH);
- BufferLinkPartnersName(gStringVar1);
- QuestLog_GetSpeciesName(a0[3], gStringVar2, 0);
- QuestLog_GetSpeciesName(a0[2], gStringVar3, 0);
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_TradedMon1ForTrainersMon2);
- r6 += 8;
- return (const u16 *)r6;
-}
-
-static u16 *BufferQuestLogData_LinkBattledUnionRoom(u16 *a0, const u16 *eventData)
-{
- a0[0] = QL_EVENT_LINK_BATTLED_UNION;
- a0[1] = sQuestLogCursor;
- *(u8 *)&a0[2] = *(const u8 *)&eventData[0];
- memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH);
- a0 += 6;
- return a0;
-}
-
-static const u16 *BufferQuestLogText_LinkBattledUnionRoom(const u16 *a0)
-{
- memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
- memcpy(gStringVar1, (const u8 *)a0 + 5, PLAYER_NAME_LENGTH);
- BufferLinkPartnersName(gStringVar1);
- StringCopy(gStringVar2, sBattleOutcomeTexts[*(const u8 *)&a0[2]]);
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_BattledTrainerEndedInOutcome);
- a0 += 6;
- return a0;
-}
-
-static u16 *BufferQuestLogData_SwitchedMonsBetweenBoxes(u16 *a0, const u16 *eventData)
-{
- a0 = sub_8113DE0(QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[0];
- a0[1] = eventData[1];
- *((u8 *)a0 + 4) = *((const u8 *)eventData + 4);
- *((u8 *)a0 + 5) = *((const u8 *)eventData + 5);
- return a0 + 3;
-}
-
-static const u16 *BufferQuestLogText_SwitchedMonsBetweenBoxes(const u16 *eventData)
-{
- const u8 *boxIdxs;
- eventData = sub_8113E88(QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES, eventData);
- boxIdxs = (const u8 *)eventData + 4;
- DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
- QuestLog_GetSpeciesName(eventData[0], NULL, 1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, GetBoxNamePtr(boxIdxs[1]));
- QuestLog_GetSpeciesName(eventData[1], NULL, 3);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchedMonsBetweenBoxes);
- return eventData + 3;
-}
-
-static u16 *BufferQuestLogData_SwitchedMonsWithinBox(u16 *a0, const u16 *eventData)
-{
- a0 = sub_8113DE0(QL_EVENT_SWITCHED_MONS_WITHIN_BOX, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[0];
- a0[1] = eventData[1];
- *((u8 *)a0 + 4) = *((const u8 *)eventData + 4);
- return a0 + 3;
-}
-
-static const u16 *BufferQuestLogText_SwitchedMonsWithinBox(const u16 *eventData)
-{
- const u8 *boxIdxs;
- eventData = sub_8113E88(QL_EVENT_SWITCHED_MONS_WITHIN_BOX, eventData);
- boxIdxs = (const u8 *)eventData + 4;
- DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
- QuestLog_GetSpeciesName(eventData[0], NULL, 1);
- QuestLog_GetSpeciesName(eventData[1], NULL, 2);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchedMonsWithinBox);
- return eventData + 3;
-}
-
-static u16 *BufferQuestLogData_SwitchedPartyMonForPCMon(u16 *a0, const u16 *eventData)
-{
- u16 *r2;
- u16 *ret;
- r2 = sub_8113DE0(QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON, a0);
- if (r2 == NULL)
- return NULL;
- ret = r2 + 2;
- if (*((const u8 *)eventData + 4) == TOTAL_BOXES_COUNT)
- {
- r2[0] = eventData[1];
- r2[1] = eventData[0];
- *((u8 *)r2 + 4) = *((const u8 *)eventData + 5);
- }
- else
- {
- r2[0] = eventData[0];
- r2[1] = eventData[1];
- *((u8 *)r2 + 4) = *((const u8 *)eventData + 4);
- }
- return ret + 1;
-}
-
-static const u16 *BufferQuestLogText_SwitchedPartyMonForPCMon(const u16 *eventData)
-{
- const u8 *boxIdxs;
- eventData = sub_8113E88(QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON, eventData);
- boxIdxs = (const u8 *)eventData + 4;
- DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
- QuestLog_GetSpeciesName(eventData[0], NULL, 1);
- QuestLog_GetSpeciesName(eventData[1], NULL, 2);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchedPartyMonForPCMon);
- return eventData + 3;
-}
-
-static u16 *BufferQuestLogData_MovedMonBetweenBoxes(u16 *a0, const u16 *eventData)
-{
- u16 *r2;
- u16 *ret;
- r2 = sub_8113DE0(QL_EVENT_MOVED_MON_BETWEEN_BOXES, a0);
- if (r2 == NULL)
- return NULL;
- r2[0] = eventData[0];
- ret = r2 + 1;
- *((u8 *)ret + 0) = *((const u8 *)eventData + 4);
- *((u8 *)ret + 1) = *((const u8 *)eventData + 5);
- return ret + 1;
-}
-
-static const u16 *BufferQuestLogText_MovedMonBetweenBoxes(const u16 *eventData)
-{
- const u8 *boxIdxs;
- eventData = sub_8113E88(QL_EVENT_MOVED_MON_BETWEEN_BOXES, eventData);
- boxIdxs = (const u8 *)eventData + 2;
- DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
- QuestLog_GetSpeciesName(eventData[0], NULL, 1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, GetBoxNamePtr(boxIdxs[1]));
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_MovedMonToNewBox);
- return (const u16 *)boxIdxs + 1;
-}
-
-static u16 *BufferQuestLogData_MovedMonWithinBox(u16 *a0, const u16 *eventData)
-{
- u16 *r2;
- r2 = sub_8113DE0(QL_EVENT_MOVED_MON_WITHIN_BOX, a0);
- if (r2 == NULL)
- return NULL;
- r2[0] = eventData[0];
- *((u8 *)r2 + 2) = *((const u8 *)eventData + 4);
- return r2 + 2;
-}
-
-static const u16 *BufferQuestLogText_MovedMonWithinBox(const u16 *eventData)
-{
- const u8 *boxIdxs;
- eventData = sub_8113E88(QL_EVENT_MOVED_MON_WITHIN_BOX, eventData);
- boxIdxs = (const u8 *)eventData + 2;
- DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
- QuestLog_GetSpeciesName(eventData[0], NULL, 1);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_MovedMonWithinBox);
- return (const u16 *)boxIdxs + 1;
-}
-
-static u16 *BufferQuestLogData_WithdrewMonFromPC(u16 *a0, const u16 *eventData)
-{
- u16 *r2;
- r2 = sub_8113DE0(QL_EVENT_WITHDREW_MON_PC, a0);
- if (r2 == NULL)
- return NULL;
- r2[0] = eventData[0];
- *((u8 *)r2 + 2) = *((const u8 *)eventData + 4);
- return r2 + 2;
-}
-
-static const u16 *BufferQuestLogText_WithdrewMonFromPC(const u16 *eventData)
-{
- const u8 *boxIdxs;
- eventData = sub_8113E88(QL_EVENT_WITHDREW_MON_PC, eventData);
- boxIdxs = (const u8 *)eventData + 2;
- DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
- QuestLog_GetSpeciesName(eventData[0], NULL, 1);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_WithdrewMonFromPC);
- return (const u16 *)boxIdxs + 1;
-}
-
-static u16 *BufferQuestLogData_DepositedMonInPC(u16 *a0, const u16 *eventData)
-{
- u16 *r2;
- r2 = sub_8113DE0(QL_EVENT_DEPOSITED_MON_PC, a0);
- if (r2 == NULL)
- return NULL;
- r2[0] = eventData[0];
- *((u8 *)r2 + 2) = *((const u8 *)eventData + 4);
- return r2 + 2;
-}
-
-static const u16 *BufferQuestLogText_DepositedMonInPC(const u16 *eventData)
-{
- const u8 *boxIdxs;
- eventData = sub_8113E88(QL_EVENT_DEPOSITED_MON_PC, eventData);
- boxIdxs = (const u8 *)eventData + 2;
- DynamicPlaceholderTextUtil_Reset();
- QuestLog_GetSpeciesName(eventData[0], NULL, 0);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, GetBoxNamePtr(boxIdxs[0]));
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DepositedMonInPC);
- return (const u16 *)boxIdxs + 1;
-}
-
-static u16 *BufferQuestLogData_SwitchedMultipleMons(u16 *a0, const u16 *eventData)
-{
- u16 *r2;
- r2 = sub_8113DE0(QL_EVENT_SWITCHED_MULTIPLE_MONS, a0);
- if (r2 == NULL)
- return NULL;
- *((u8 *)r2 + 0) = *((const u8 *)eventData + 4);
- *((u8 *)r2 + 1) = *((const u8 *)eventData + 5);
- return r2 + 1;
-}
-
-static const u16 *BufferQuestLogText_SwitchedMultipleMons(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_SWITCHED_MULTIPLE_MONS, eventData);
- DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(*((const u8 *)r4 + 0)));
- if (*((const u8 *)r4 + 0) == *((const u8 *)r4 + 1))
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gText_QuestLog_ADifferentSpot);
- else
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, GetBoxNamePtr(*((const u8 *)r4 + 1)));
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchedMultipleMons);
- return r4 + 1;
-}
-
-static u16 *BufferQuestLogData_DepositedItemInPC(u16 *a0, const u16 *eventData)
-{
- a0 = sub_8113DE0(QL_EVENT_DEPOSITED_ITEM_PC, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[0];
- return a0 + 1;
-}
-
-static const u16 *BufferQuestLogText_DepositedItemInPC(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_DEPOSITED_ITEM_PC, eventData);
- CopyItemName(r4[0], gStringVar1);
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_StoredItemInPC);
- return r4 + 1;
-}
-
-static u16 *BufferQuestLogData_WithdrewItemFromPC(u16 *a0, const u16 *eventData)
-{
- a0 = sub_8113DE0(QL_EVENT_WITHDREW_ITEM_PC, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[0];
- return a0 + 1;
-}
-
-static const u16 *BufferQuestLogText_WithdrewItemFromPC(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_WITHDREW_ITEM_PC, eventData);
- CopyItemName(r4[0], gStringVar1);
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_WithdrewItemFromPC);
- return r4 + 1;
-}
-
-u16 *BufferQuestLogData_DefeatedTrainer_(u16 eventId, u16 *a1, const u16 *a2)
-{
- a1 = sub_8113DE0(eventId, a1);
- if (a1 == NULL)
- return NULL;
- a1[0] = a2[1];
- a1[1] = a2[2];
- a1[2] = a2[0];
- *((u8 *)a1 + 6) = *((const u8 *)a2 + 7);
- *((u8 *)a1 + 7) = *((const u8 *)a2 + 6);
- return a1 + 4;
-}
-
-static u16 *BufferQuestLogData_DefeatedGymLeader(u16 *a0, const u16 *eventData)
-{
- gUnknown_203B048 = 1;
- return BufferQuestLogData_DefeatedTrainer_(QL_EVENT_DEFEATED_GYM_LEADER, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_DefeatedGymLeader(const u16 *eventData)
-{
- const u8 *r6;
- eventData = sub_8113E88(QL_EVENT_DEFEATED_GYM_LEADER, eventData);
- r6 = (const u8 *)eventData + 6;
- DynamicPlaceholderTextUtil_Reset();
- GetMapNameGeneric(gStringVar1, r6[0]);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gTrainers[eventData[2]].trainerName);
- QuestLog_GetSpeciesName(eventData[0], 0, 2);
- QuestLog_GetSpeciesName(eventData[1], 0, 3);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, sDefeatedOpponentFlavorTexts[r6[1]]);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_TookOnGymLeadersMonWithMonAndWon);
- return eventData + 4;
-}
-
-static u16 *BufferQuestLogData_DefeatedWildMon(u16 *a0, const u16 *eventData)
-{
- u16 *r4 = a0;
- u8 *r5 = (u8 *)a0 + 8;
- if (!sub_8110944(r4, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_WILD_MON]))
- return NULL;
- if (r5[0] == 0 && r5[1] == 0)
- {
- r4[0] = QL_EVENT_DEFEATED_WILD_MON;
- r4[1] = sQuestLogCursor;
- }
- if (eventData[0])
- r4[2] = eventData[0];
- if (eventData[1])
- r4[3] = eventData[1];
- if (eventData[0] && r5[0] != 0xFF)
- r5[0]++;
- if (eventData[1] && r5[1] != 0xFF)
- r5[1]++;
- r5[2] = *((const u8 *)eventData + 4);
- return (u16 *)(r5 + 4);
-}
-
-static const u16 *BufferQuestLogText_DefeatedWildMon(const u16 *a0)
-{
- const u8 *data;
- if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_WILD_MON]))
- return NULL;
-
- data = (const u8 *)a0 + 8;
- DynamicPlaceholderTextUtil_Reset();
- GetMapNameGeneric(gStringVar1, data[2]);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
- QuestLog_GetSpeciesName(a0[2], NULL, 1);
- ConvertIntToDecimalStringN(gStringVar2, data[0], STR_CONV_MODE_LEFT_ALIGN, 3);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar2);
- QuestLog_GetSpeciesName(a0[3], NULL, 3);
- ConvertIntToDecimalStringN(gStringVar3, data[1], STR_CONV_MODE_LEFT_ALIGN, 3);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, gStringVar3);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(5, gSaveBlock2Ptr->playerName);
- if (data[0] == 0)
- {
- if (data[1] == 1)
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_CaughtWildMon);
- else
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_CaughtWildMons);
- }
- else if (data[1] == 0)
- {
- if (data[0] == 1)
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMon);
- else
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMons);
- }
- else if (data[0] == 1)
- {
- if (data[1] == 1)
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMonAndCaughtWildMon);
- else
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMonAndCaughtWildMons);
- }
- else
- {
- if (data[1] == 1)
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMonsAndCaughtWildMon);
- else
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMonsAndCaughtWildMons);
- }
- return (const u16 *)(data + 4);
-}
-
-static bool8 IsSpeciesFromSpecialEncounter(u16 species)
-{
- switch (species)
- {
- case SPECIES_SNORLAX:
- case SPECIES_ARTICUNO:
- case SPECIES_ZAPDOS:
- case SPECIES_MOLTRES:
- case SPECIES_MEWTWO:
- case SPECIES_LUGIA:
- case SPECIES_HO_OH:
- case SPECIES_DEOXYS:
- return TRUE;
- }
- return FALSE;
-}
-
-static u16 *BufferQuestLogData_DefeatedEliteFourMember(u16 *a0, const u16 *eventData)
-{
- gUnknown_203B048 = 1;
- return BufferQuestLogData_DefeatedTrainer_(QL_EVENT_DEFEATED_E4_MEMBER, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_DefeatedEliteFourMember(const u16 *eventData)
-{
- const u8 *r5;
- eventData = sub_8113E88(QL_EVENT_DEFEATED_E4_MEMBER, eventData);
- r5 = (const u8 *)eventData + 6;
- DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gTrainers[eventData[2]].trainerName);
- QuestLog_GetSpeciesName(eventData[0], NULL, 1);
- QuestLog_GetSpeciesName(eventData[1], NULL, 2);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, sDefeatedOpponentFlavorTexts[r5[1]]);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_TookOnEliteFoursMonWithMonAndWon);
- return eventData + 4;
-}
-
-static u16 *BufferQuestLogData_DefeatedChampion(u16 *a0, const u16 *eventData)
-{
- if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_CHAMPION]))
- return NULL;
- a0[0] = 0x2021;
- a0[1] = sQuestLogCursor;
- a0[2] = eventData[1];
- a0[3] = eventData[2];
- *((u8 *)a0 + 8) = *((const u8 *)eventData + 6);
- gUnknown_203B048 = 1;
- return a0 + 5;
-}
-
-static const u16 *BufferQuestLogText_DefeatedChampion(const u16 *a0)
-{
- const u8 *r5;
- if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_CHAMPION]))
- return NULL;
-
- r5 = (const u8 *)a0 + 8;
- DynamicPlaceholderTextUtil_Reset();
-
- switch (gUnknown_203B044.unk_2)
- {
- case 0:
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gSaveBlock1Ptr->rivalName);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_PlayerBattledChampionRival);
- break;
- case 1:
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock1Ptr->rivalName);
- QuestLog_GetSpeciesName(a0[2], NULL, 1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gSaveBlock2Ptr->playerName);
- QuestLog_GetSpeciesName(a0[3], NULL, 3);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_PlayerSentOutMon1RivalSentOutMon2);
- break;
- case 2:
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sDefeatedChampionFlavorTexts[r5[0]]);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_WonTheMatchAsAResult);
- break;
- }
- return (const u16 *)(r5 + 2);
-}
-
-static u16 *BufferQuestLogData_DefeatedTrainer(u16 *a0, const u16 *eventData)
-{
- gUnknown_203B048 = 1;
- return BufferQuestLogData_DefeatedTrainer_(QL_EVENT_DEFEATED_TRAINER, a0, eventData);
-}
-
-static const u16 *BufferQuestLogText_DefeatedTrainer(const u16 *eventData)
-{
- const u16 *r5 = sub_8113E88(QL_EVENT_DEFEATED_TRAINER, eventData);
- const u8 *r6 = (const u8 *)r5 + 6;
- DynamicPlaceholderTextUtil_Reset();
- GetMapNameGeneric(gStringVar1, r6[0]);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
-
- if (gTrainers[r5[2]].trainerClass == CLASS_RIVAL
- || gTrainers[r5[2]].trainerClass == CLASS_RIVAL_2
- || gTrainers[r5[2]].trainerClass == CLASS_CHAMPION_2)
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, GetExpandedPlaceholder(PLACEHOLDER_ID_RIVAL));
- else
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gTrainers[r5[2]].trainerName);
-
- QuestLog_GetSpeciesName(r5[0], NULL, 2);
- QuestLog_GetSpeciesName(r5[1], NULL, 3);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, sDefeatedOpponentFlavorTexts[r6[1]]);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_TookOnTrainersMonWithMonAndWon);
- return (const u16 *)(r6 + 2);
-}
-
-static const u8 *const sLocationNameTexts[] =
-{
- [QL_LOCATION_HOME] = gText_QuestLog_Home,
- [QL_LOCATION_OAKS_LAB] = gText_QuestLog_OakResearchLab,
- [QL_LOCATION_VIRIDIAN_GYM] = gText_QuestLog_Gym,
- [QL_LOCATION_LEAGUE_GATE_1] = gText_QuestLog_PokemonLeagueGate,
- [QL_LOCATION_LEAGUE_GATE_2] = gText_QuestLog_PokemonLeagueGate,
- [QL_LOCATION_VIRIDIAN_FOREST_1] = gText_QuestLog_ViridianForest,
- [QL_LOCATION_VIRIDIAN_FOREST_2] = gText_QuestLog_ViridianForest,
- [QL_LOCATION_PEWTER_MUSEUM] = gText_QuestLog_PewterMuseumOfScience,
- [QL_LOCATION_PEWTER_GYM] = gText_QuestLog_Gym,
- [QL_LOCATION_MT_MOON_1] = gText_QuestLog_MtMoon,
- [QL_LOCATION_MT_MOON_2] = gText_QuestLog_MtMoon,
- [QL_LOCATION_CERULEAN_GYM] = gText_QuestLog_Gym,
- [QL_LOCATION_BIKE_SHOP] = gText_QuestLog_BikeShop,
- [QL_LOCATION_BILLS_HOUSE] = gText_QuestLog_BillsHouse,
- [QL_LOCATION_DAY_CARE] = gText_QuestLog_DayCare,
- [QL_LOCATION_UNDERGROUND_PATH_1] = gText_QuestLog_UndergroundPath,
- [QL_LOCATION_UNDERGROUND_PATH_2] = gText_QuestLog_UndergroundPath,
- [QL_LOCATION_PKMN_FAN_CLUB] = gText_QuestLog_PokemonFanClub,
- [QL_LOCATION_VERMILION_GYM] = gText_QuestLog_Gym,
- [QL_LOCATION_SS_ANNE] = gText_QuestLog_SSAnne,
- [QL_LOCATION_DIGLETTS_CAVE_1] = gText_QuestLog_DiglettsCave,
- [QL_LOCATION_DIGLETTS_CAVE_2] = gText_QuestLog_DiglettsCave,
- [QL_LOCATION_ROCK_TUNNEL_1] = gText_QuestLog_RockTunnel,
- [QL_LOCATION_ROCK_TUNNEL_2] = gText_QuestLog_RockTunnel,
- [QL_LOCATION_POWER_PLANT] = gText_QuestLog_PowerPlant,
- [QL_LOCATION_PKMN_TOWER] = gText_QuestLog_PokemonTower,
- [QL_LOCATION_VOLUNTEER_HOUSE] = gText_QuestLog_VolunteerHouse,
- [QL_LOCATION_NAME_RATERS_HOUSE] = gText_QuestLog_NameRatersHouse,
- [QL_LOCATION_UNDERGROUND_PATH_3] = gText_QuestLog_UndergroundPath,
- [QL_LOCATION_UNDERGROUND_PATH_4] = gText_QuestLog_UndergroundPath,
- [QL_LOCATION_CELADON_DEPT_STORE] = gText_QuestLog_CeladonDeptStore,
- [QL_LOCATION_CELADON_MANSION] = gText_QuestLog_CeladonMansion,
- [QL_LOCATION_GAME_CORNER] = gText_QuestLog_RocketGameCorner,
- [QL_LOCATION_CELADON_GYM] = gText_QuestLog_Gym,
- [QL_LOCATION_CELADON_RESTAURANT] = gText_QuestLog_Restaurant,
- [QL_LOCATION_ROCKET_HIDEOUT] = gText_QuestLog_RocketHideout,
- [QL_LOCATION_SAFARI_ZONE] = gText_QuestLog_SafariZone,
- [QL_LOCATION_FUCHSIA_GYM] = gText_QuestLog_Gym,
- [QL_LOCATION_WARDENS_HOME] = gText_QuestLog_WardensHome,
- [QL_LOCATION_FIGHTING_DOJO] = gText_QuestLog_FightingDojo,
- [QL_LOCATION_SAFFRON_GYM] = gText_QuestLog_Gym,
- [QL_LOCATION_SILPH_CO] = gText_QuestLog_SilphCo,
- [QL_LOCATION_SEAFOAM_ISLANDS_1] = gText_QuestLog_SeafoamIslands,
- [QL_LOCATION_SEAFOAM_ISLANDS_2] = gText_QuestLog_SeafoamIslands,
- [QL_LOCATION_PKMN_MANSION] = gText_QuestLog_PokemonMansion,
- [QL_LOCATION_CINNABAR_GYM] = gText_QuestLog_Gym,
- [QL_LOCATION_CINNABAR_LAB] = gText_QuestLog_PokemonResearchLab,
- [QL_LOCATION_VICTORY_ROAD_1] = gText_QuestLog_VictoryRoad,
- [QL_LOCATION_VICTORY_ROAD_2] = gText_QuestLog_VictoryRoad,
- [QL_LOCATION_PKMN_LEAGUE] = gText_QuestLog_PokemonLeague,
- [QL_LOCATION_CERULEAN_CAVE] = gText_QuestLog_CeruleanCave
-};
-
-static const u8 *const sDepartedLocationTexts[] =
-{
- [QL_DEPARTED_TOWN_BUILDING] = gText_QuestLog_DepartedPlaceInTownForNextDestination,
- [QL_DEPARTED_MUSEUM] = gText_QuestLog_LeftTownsLocationForNextDestination,
- [QL_DEPARTED_GAME_CORNER] = gText_QuestLog_PlayedGamesAtGameCorner,
- [QL_DEPARTED_HOME] = gText_QuestLog_RestedAtHome,
- [QL_DEPARTED_OAKS_LAB] = gText_QuestLog_LeftOaksLab,
- [QL_DEPARTED_GYM] = gText_QuestLog_GymWasFullOfToughTrainers,
- [QL_DEPARTED_SAFARI_ZONE] = gText_QuestLog_HadGreatTimeInSafariZone,
- [QL_DEPARTED_CAVE] = gText_QuestLog_ManagedToGetOutOfLocation,
- [QL_DEPARTED_MISC_BUILDING_1] = gText_QuestLog_DepartedTheLocationForNextDestination,
- [QL_DEPARTED_MISC_BUILDING_2] = gText_QuestLog_DepartedFromLocationToNextDestination
-};
-
-static const u8 sLocationToDepartedTextId[] =
-{
- [QL_LOCATION_HOME] = QL_DEPARTED_HOME,
- [QL_LOCATION_OAKS_LAB] = QL_DEPARTED_OAKS_LAB,
- [QL_LOCATION_VIRIDIAN_GYM] = QL_DEPARTED_GYM,
- [QL_LOCATION_LEAGUE_GATE_1] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_LEAGUE_GATE_2] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_VIRIDIAN_FOREST_1] = QL_DEPARTED_CAVE,
- [QL_LOCATION_VIRIDIAN_FOREST_2] = QL_DEPARTED_CAVE,
- [QL_LOCATION_PEWTER_MUSEUM] = QL_DEPARTED_MUSEUM,
- [QL_LOCATION_PEWTER_GYM] = QL_DEPARTED_GYM,
- [QL_LOCATION_MT_MOON_1] = QL_DEPARTED_CAVE,
- [QL_LOCATION_MT_MOON_2] = QL_DEPARTED_CAVE,
- [QL_LOCATION_CERULEAN_GYM] = QL_DEPARTED_GYM,
- [QL_LOCATION_BIKE_SHOP] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_BILLS_HOUSE] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_DAY_CARE] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_UNDERGROUND_PATH_1] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_UNDERGROUND_PATH_2] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_PKMN_FAN_CLUB] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_VERMILION_GYM] = QL_DEPARTED_GYM,
- [QL_LOCATION_SS_ANNE] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_DIGLETTS_CAVE_1] = QL_DEPARTED_CAVE,
- [QL_LOCATION_DIGLETTS_CAVE_2] = QL_DEPARTED_CAVE,
- [QL_LOCATION_ROCK_TUNNEL_1] = QL_DEPARTED_CAVE,
- [QL_LOCATION_ROCK_TUNNEL_2] = QL_DEPARTED_CAVE,
- [QL_LOCATION_POWER_PLANT] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_PKMN_TOWER] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_VOLUNTEER_HOUSE] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_NAME_RATERS_HOUSE] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_UNDERGROUND_PATH_3] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_UNDERGROUND_PATH_4] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_CELADON_DEPT_STORE] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_CELADON_MANSION] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_GAME_CORNER] = QL_DEPARTED_GAME_CORNER,
- [QL_LOCATION_CELADON_GYM] = QL_DEPARTED_GYM,
- [QL_LOCATION_CELADON_RESTAURANT] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_ROCKET_HIDEOUT] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_SAFARI_ZONE] = QL_DEPARTED_SAFARI_ZONE,
- [QL_LOCATION_FUCHSIA_GYM] = QL_DEPARTED_GYM,
- [QL_LOCATION_WARDENS_HOME] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_FIGHTING_DOJO] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_SAFFRON_GYM] = QL_DEPARTED_GYM,
- [QL_LOCATION_SILPH_CO] = QL_DEPARTED_MISC_BUILDING_2,
- [QL_LOCATION_SEAFOAM_ISLANDS_1] = QL_DEPARTED_CAVE,
- [QL_LOCATION_SEAFOAM_ISLANDS_2] = QL_DEPARTED_CAVE,
- [QL_LOCATION_PKMN_MANSION] = QL_DEPARTED_MISC_BUILDING_2,
- [QL_LOCATION_CINNABAR_GYM] = QL_DEPARTED_GYM,
- [QL_LOCATION_CINNABAR_LAB] = QL_DEPARTED_TOWN_BUILDING,
- [QL_LOCATION_VICTORY_ROAD_1] = QL_DEPARTED_CAVE,
- [QL_LOCATION_VICTORY_ROAD_2] = QL_DEPARTED_CAVE,
- [QL_LOCATION_PKMN_LEAGUE] = QL_DEPARTED_MISC_BUILDING_1,
- [QL_LOCATION_CERULEAN_CAVE] = QL_DEPARTED_CAVE
-};
-
-static const u8 gUnknown_8456C17[] = {
- 0x5a,
- 0x5b,
- 0x5d,
- 0x5e,
- 0x5f,
- 0x62,
- 0x60,
- 0x59
-};
-
-static const u8 *const sUsedFieldMoveTexts[] =
-{
- [FIELD_MOVE_FLASH] = gText_QuestLog_UsedFlash,
- [FIELD_MOVE_CUT] = gText_QuestLog_UsedCut,
- [FIELD_MOVE_FLY] = gText_QuestLog_UsedFly,
- [FIELD_MOVE_STRENGTH] = gText_QuestLog_UsedStrength,
- [FIELD_MOVE_SURF] = gText_QuestLog_UsedSurf,
- [FIELD_MOVE_ROCK_SMASH] = gText_QuestLog_UsedRockSmash,
- [FIELD_MOVE_WATERFALL] = gText_QuestLog_UsedWaterfall,
- [FIELD_MOVE_TELEPORT] = gText_QuestLog_UsedTeleportToLocation,
- [FIELD_MOVE_DIG] = gText_QuestLog_UsedDigInLocation,
- [FIELD_MOVE_MILK_DRINK] = gText_QuestLog_UsedMilkDrink,
- [FIELD_MOVE_SOFT_BOILED] = gText_QuestLog_UsedSoftboiled,
- [FIELD_MOVE_SWEET_SCENT] = gText_QuestLog_UsedSweetScent
-};
-
-static u16 *BufferQuestLogData_DepartedLocation(u16 *a0, const u16 *eventData)
-{
- u16 *r2 = sub_8113DE0(QL_EVENT_DEPARTED, a0);
- if (r2 == NULL)
- return NULL;
- *((u8 *)r2 + 0) = *((const u8 *)eventData + 0);
- if ((*((u8 *)r2 + 1) = *((const u8 *)eventData + 1)) == 0x24)
- gUnknown_203B048 = 1;
- return r2 + 1;
-}
-
-static const u16 *BufferQuestLogText_DepartedLocation(const u16 *eventData)
-{
- u8 r4, locationId;
- const u16 *r5 = sub_8113E88(QL_EVENT_DEPARTED, eventData);
- const u8 *r5_2 = (const u8 *)r5 + 0;
- locationId = r5_2[1];
- GetMapNameGeneric(gStringVar1, r5_2[0]);
- StringCopy(gStringVar2, sLocationNameTexts[locationId]);
- if (sLocationToDepartedTextId[locationId] == QL_DEPARTED_GYM)
- {
- for (r4 = 0; r4 < ARRAY_COUNT(gUnknown_8456C17); r4++)
- {
- if (r5_2[0] != gUnknown_8456C17[r4])
- continue;
- if (FlagGet(FLAG_BADGE01_GET + r4) == TRUE)
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_DepartedGym);
- else
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_GymWasFullOfToughTrainers);
- break;
- }
- if (r4 == 8)
- StringExpandPlaceholders(gStringVar4, sDepartedLocationTexts[sLocationToDepartedTextId[locationId]]);
- }
- else
- StringExpandPlaceholders(gStringVar4, sDepartedLocationTexts[sLocationToDepartedTextId[locationId]]);
-
- return (const u16 *)(r5_2 + 2);
-}
-
-void sub_811539C(void)
-{
- gUnknown_203B04B = TRUE;
-}
-
-static bool8 sub_81153A8(u16 eventId, const u16 *eventData)
-{
- if (eventId != QL_EVENT_DEPARTED)
- {
- gUnknown_203B04A = 0;
- return TRUE;
- }
- if (gUnknown_203B04A == *((u8 *)eventData + 1) + 1)
- return FALSE;
- gUnknown_203B04A = *((u8 *)eventData + 1) + 1;
- return TRUE;
-}
-
-static bool8 sub_81153E4(u16 eventId, const u16 *eventData)
-{
- if (eventId != QL_EVENT_DEPARTED)
- return TRUE;
-
- if (*((u8 *)eventData + 1) == 32 && !gUnknown_203B04B)
- return FALSE;
-
- gUnknown_203B04B = FALSE;
- return TRUE;
-}
-
-static u16 *BufferQuestLogData_UsedFieldMove(u16 *a0, const u16 *eventData)
-{
- u8 *r3;
- a0 = sub_8113DE0(QL_EVENT_USED_FIELD_MOVE, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[0];
- r3 = (u8 *)a0 + 2;
- r3[0] = *((const u8 *)eventData + 2);
- r3[1] = *((const u8 *)eventData + 3);
- if (r3[0] == FIELD_MOVE_TELEPORT || r3[0] == FIELD_MOVE_DIG)
- gUnknown_203B048 = 2;
- else
- gUnknown_203B048 = 1;
- return (u16 *)(r3 + 2);
-}
-
-static const u16 *BufferQuestLogText_UsedFieldMove(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_USED_FIELD_MOVE, eventData);
- const u8 *r5 = (const u8 *)r4 + 2;
- QuestLog_GetSpeciesName(r4[0], gStringVar1, 0);
- if (r5[1] != 0xFF)
- GetMapNameGeneric(gStringVar2, r5[1]);
-
- // If used Teleport, get name of destination
- if (r5[0] == FIELD_MOVE_TELEPORT)
- {
- if (r5[1] == 0x58)
- StringCopy(gStringVar3, gText_QuestLog_Home);
- else
- StringCopy(gStringVar3, gText_PokemonCenter);
- }
-
- StringExpandPlaceholders(gStringVar4, sUsedFieldMoveTexts[r5[0]]);
- return (const u16 *)(r5 + 2);
-}
-
-static u16 *BufferQuestLogData_BoughtItem(u16 *a0, const u16 *eventData)
-{
- a0 = sub_8113DE0(QL_EVENT_BOUGHT_ITEM, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[2];
- a0[1] = eventData[3];
- a0[2] = *((const u32 *)eventData) >> 16;
- a0[3] = *((const u32 *)eventData);
- *((u8 *)a0 + 8) = *((const u8 *)eventData + 8);
- *((u8 *)a0 + 9) = 1;
- return a0 + 5;
-}
-
-static const u16 *BufferQuestLogText_BoughtItem(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_BOUGHT_ITEM, eventData);
- const u8 *r7 = (const u8 *)r4 + 8;
- u32 r6 = (r4[2] << 16) + r4[3];
- DynamicPlaceholderTextUtil_Reset();
- GetMapNameGeneric(gStringVar1, r7[0]);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, ItemId_GetName(r4[0]));
- if (r4[1] < 2)
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_BoughtItem);
- else
- {
- ConvertIntToDecimalStringN(gStringVar2, r6, STR_CONV_MODE_LEFT_ALIGN, 6);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar2);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_BoughtItemsIncludingItem);
- }
- return (const u16 *)(r7 + 2);
-}
-
-static u16 *BufferQuestLogData_SoldItem(u16 *a0, const u16 *eventData)
-{
- a0 = sub_8113DE0(QL_EVENT_SOLD_ITEM, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[2];
- a0[1] = eventData[3];
- a0[2] = *((const u32 *)eventData) >> 16;
- a0[3] = *((const u32 *)eventData);
- *((u8 *)a0 + 8) = *((const u8 *)eventData + 8);
- *((u8 *)a0 + 9) = *((const u8 *)eventData + 9);
- return a0 + 5;
-}
-
-static const u16 *BufferQuestLogText_SoldItem(const u16 *eventData)
-{
- const u16 *r5 = sub_8113E88(QL_EVENT_SOLD_ITEM, eventData);
- const u8 *r7 = (const u8 *) r5 + 8;
- u32 r6 = (r5[2] << 16) + r5[3];
- DynamicPlaceholderTextUtil_Reset();
- GetMapNameGeneric(gStringVar1, r7[0]);
- if (r7[1] == 0) {
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gStringVar1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, ItemId_GetName(r5[0]));
- if (r5[1] == 1)
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, gText_QuestLog_JustOne);
- else
- {
- ConvertIntToDecimalStringN(gStringVar2, r5[1], STR_CONV_MODE_LEFT_ALIGN, 3);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, gStringVar2);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar3, gText_QuestLog_Num);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, gStringVar3);
- }
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SoldNumOfItem);
- }
- else
- {
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, ItemId_GetName(r5[0]));
- ConvertIntToDecimalStringN(gStringVar2, r6, STR_CONV_MODE_LEFT_ALIGN, 6);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar2);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SoldItemsIncludingItem);
- }
- return (const u16 *)(r7 + 2);
-}
-
-static u16 *BufferQuestLogData_ObtainedItem(u16 *a0, const u16 *eventData)
-{
- a0 = sub_8113DE0(QL_EVENT_OBTAINED_ITEM, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[0];
- *((u8 *)a0 + 2) = *((const u8 *)eventData + 2);
- return a0 + 2;
-}
-
-static const u16 *BufferQuestLogText_ObtainedItem(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_OBTAINED_ITEM, eventData);
- const u8 *r5 = (const u8 *)r4 + 2;
- GetMapNameGeneric(gStringVar1, r5[0]);
- StringCopy(gStringVar2, ItemId_GetName(r4[0]));
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_ObtainedItemInLocation);
- return (const u16 *)(r5 + 2);
-}
-
-static const u16 sQuestLogWorldMapFlags[] =
-{
- FLAG_WORLD_MAP_VIRIDIAN_CITY,
- FLAG_WORLD_MAP_PEWTER_CITY,
- FLAG_WORLD_MAP_CERULEAN_CITY,
- FLAG_WORLD_MAP_LAVENDER_TOWN,
- FLAG_WORLD_MAP_VERMILION_CITY,
- FLAG_WORLD_MAP_CELADON_CITY,
- FLAG_WORLD_MAP_FUCHSIA_CITY,
- FLAG_WORLD_MAP_CINNABAR_ISLAND,
- FLAG_WORLD_MAP_INDIGO_PLATEAU_EXTERIOR,
- FLAG_WORLD_MAP_SAFFRON_CITY,
- FLAG_WORLD_MAP_ONE_ISLAND,
- FLAG_WORLD_MAP_TWO_ISLAND,
- FLAG_WORLD_MAP_THREE_ISLAND,
- FLAG_WORLD_MAP_FOUR_ISLAND,
- FLAG_WORLD_MAP_FIVE_ISLAND,
- FLAG_WORLD_MAP_SEVEN_ISLAND,
- FLAG_WORLD_MAP_SIX_ISLAND
-};
-
-void QuestLog_RecordEnteredMap(u16 worldMapFlag)
-{
- s32 i;
-
- if (gQuestLogState == QL_STATE_2 || gQuestLogState == QL_STATE_3)
- return;
-
- for (i = 0; i < (int)NELEMS(sQuestLogWorldMapFlags); i++)
- {
- if (worldMapFlag == sQuestLogWorldMapFlags[i])
- {
- if (!FlagGet(worldMapFlag))
- {
- sNewlyEnteredMap = TRUE;
- break;
- }
- else
- {
- sNewlyEnteredMap += 0;
- sNewlyEnteredMap = FALSE;
- break;
- }
- }
- }
-}
-
-void sub_8115798(void)
-{
- u16 sp0;
- if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3)
- {
- if (sNewlyEnteredMap)
- {
- sp0 = gMapHeader.regionMapSectionId;
- SetQuestLogEvent(QL_EVENT_ARRIVED, &sp0);
- sNewlyEnteredMap = FALSE;
- }
- }
-}
-
-static u16 *BufferQuestLogData_ArrivedInLocation(u16 *a0, const u16 *eventData)
-{
- a0 = sub_8113DE0(QL_EVENT_ARRIVED, a0);
- if (a0 == NULL)
- return NULL;
- a0[0] = eventData[0];
- return a0 + 1;
-}
-
-static const u16 *BufferQuestLogText_ArrivedInLocation(const u16 *eventData)
-{
- const u16 *r4 = sub_8113E88(QL_EVENT_ARRIVED, eventData);
- GetMapNameGeneric(gStringVar1, (u8)r4[0]);
- StringExpandPlaceholders(gStringVar4, gText_QuestLog_ArrivedInLocation);
- return r4 + 1;
-}
-
-static void BufferLinkPartnersName(u8 *dest)
-{
- s32 i;
- if (*dest++ == EXT_CTRL_CODE_BEGIN && *dest++ == EXT_CTRL_CODE_JPN)
- {
- for (i = 0; i < 5; i++)
- {
- if (*dest == EXT_CTRL_CODE_BEGIN)
- break;
- dest++;
- }
- *dest++ = EXT_CTRL_CODE_BEGIN;
- *dest++ = EXT_CTRL_CODE_ENG;
- *dest++ = EOS;
- }
}
diff --git a/src/quest_log_battle.c b/src/quest_log_battle.c
index 7ae4d7c2c..fc3390508 100644
--- a/src/quest_log_battle.c
+++ b/src/quest_log_battle.c
@@ -1,6 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "constants/species.h"
-#include "malloc.h"
#include "battle.h"
#include "battle_anim.h"
#include "link.h"
diff --git a/src/quest_log_events.c b/src/quest_log_events.c
new file mode 100644
index 000000000..a223804c4
--- /dev/null
+++ b/src/quest_log_events.c
@@ -0,0 +1,2155 @@
+#include "global.h"
+#include "gflib.h"
+#include "battle.h"
+#include "data.h"
+#include "dynamic_placeholder_text_util.h"
+#include "event_data.h"
+#include "event_scripts.h"
+#include "menu_helpers.h"
+#include "item.h"
+#include "link.h"
+#include "quest_log.h"
+#include "party_menu.h"
+#include "pokemon_storage_system.h"
+#include "region_map.h"
+#include "strings.h"
+#include "constants/maps.h"
+#include "constants/flags.h"
+#include "constants/trainer_classes.h"
+#include "constants/species.h"
+#include "constants/items.h"
+#include "constants/region_map_sections.h"
+
+struct DeferredLinkEvent
+{
+ u16 id;
+ u16 ALIGNED(4) data[14];
+};
+
+static EWRAM_DATA struct DeferredLinkEvent sDeferredEvent = {0};
+EWRAM_DATA struct UnkStruct_203B044 gUnknown_203B044 = {0};
+static EWRAM_DATA u8 sEventShouldNotRecordSteps = 0;
+static EWRAM_DATA bool8 sNewlyEnteredMap = FALSE;
+static EWRAM_DATA u8 sLastDepartedMap = 0;
+static EWRAM_DATA bool8 sPlayedTheSlots = FALSE;
+
+static bool8 InQuestLogDisabledLocation(void);
+static bool8 ShouldRegisterEvent_HandlePartyActions(u16, const u16 *);
+static bool8 ShouldRegisterEvent_HandleBeatStoryTrainer(u16, const u16 *);
+static u16 *ShouldRegisterEvent(u16, const u16 *);
+static bool8 TrySetLinkQuestLogEvent(u16, const u16 *);
+static bool8 TrySetTrainerBattleQuestLogEvent(u16, const u16 *);
+static bool8 IsQuestLogEventWithSpecialEncounterSpecies(u16, const u16 *);
+static void SetQuestLogEventToActive(u16);
+static u16 *TryRecordEvent41(u16 *, u16);
+static u16 *BufferQuestLogData_SwitchedPartyOrder(u16 *, const u16 *);
+static u16 *BufferQuestLogData_UsedItem(u16 *, const u16 *);
+static u16 *BufferQuestLogData_GaveHeldItemFromPartyMenu(u16 *, const u16 *);
+static u16 *BufferQuestLogData_GaveHeldItemFromBagMenu(u16 *, const u16 *);
+static u16 *BufferQuestLogData_GaveHeldItemFromPC(u16 *, const u16 *);
+static u16 *BufferQuestLogData_TookHeldItem(u16 *, const u16 *);
+static u16 *BufferQuestLogData_SwappedHeldItem(u16 *, const u16 *);
+static u16 *BufferQuestLogData_SwappedHeldItemFromPC(u16 *, const u16 *);
+static u16 *BufferQuestLogData_UsedPkmnCenter(u16 *, const u16 *);
+static u16 *BufferQuestLogData_LinkTraded(u16 *, const u16 *);
+static u16 *BufferQuestLogData_LinkBattledSingle(u16 *, const u16 *);
+static u16 *BufferQuestLogData_LinkBattledDouble(u16 *, const u16 *);
+static u16 *BufferQuestLogData_LinkBattledMulti(u16 *, const u16 *);
+static u16 *BufferQuestLogData_UsedUnionRoom(u16 *, const u16 *);
+static u16 *BufferQuestLogData_UsedUnionRoomChat(u16 *, const u16 *);
+static u16 *BufferQuestLogData_LinkTradedUnionRoom(u16 *, const u16 *);
+static u16 *BufferQuestLogData_LinkBattledUnionRoom(u16 *, const u16 *);
+static u16 *BufferQuestLogData_SwitchedMonsBetweenBoxes(u16 *, const u16 *);
+static u16 *BufferQuestLogData_SwitchedMonsWithinBox(u16 *, const u16 *);
+static u16 *BufferQuestLogData_SwitchedPartyMonForPCMon(u16 *, const u16 *);
+static u16 *BufferQuestLogData_MovedMonBetweenBoxes(u16 *, const u16 *);
+static u16 *BufferQuestLogData_MovedMonWithinBox(u16 *, const u16 *);
+static u16 *BufferQuestLogData_WithdrewMonFromPC(u16 *, const u16 *);
+static u16 *BufferQuestLogData_DepositedMonInPC(u16 *, const u16 *);
+static u16 *BufferQuestLogData_SwitchedMultipleMons(u16 *, const u16 *);
+static u16 *BufferQuestLogData_DepositedItemInPC(u16 *, const u16 *);
+static u16 *BufferQuestLogData_WithdrewItemFromPC(u16 *, const u16 *);
+static u16 *BufferQuestLogData_DefeatedGymLeader(u16 *, const u16 *);
+static u16 *BufferQuestLogData_DefeatedWildMon(u16 *, const u16 *);
+static u16 *BufferQuestLogData_DefeatedEliteFourMember(u16 *, const u16 *);
+static u16 *BufferQuestLogData_DefeatedChampion(u16 *, const u16 *);
+static u16 *BufferQuestLogData_DefeatedTrainer(u16 *, const u16 *);
+static u16 *BufferQuestLogData_DepartedLocation(u16 *, const u16 *);
+static u16 *BufferQuestLogData_UsedFieldMove(u16 *, const u16 *);
+static u16 *BufferQuestLogData_BoughtItem(u16 *, const u16 *);
+static u16 *BufferQuestLogData_SoldItem(u16 *, const u16 *);
+static u16 *BufferQuestLogData_ObtainedItem(u16 *, const u16 *);
+static u16 *BufferQuestLogData_ArrivedInLocation(u16 *, const u16 *);
+static const u16 *BufferQuestLogText_SwitchedPartyOrder(const u16 *);
+static const u16 *BufferQuestLogText_UsedItem(const u16 *);
+static const u16 *BufferQuestLogText_GaveHeldItemFromPartyMenu(const u16 *);
+static const u16 *BufferQuestLogText_GaveHeldItemFromBagMenu(const u16 *);
+static const u16 *BufferQuestLogText_GaveHeldItemFromPC(const u16 *);
+static const u16 *BufferQuestLogText_TookHeldItem(const u16 *);
+static const u16 *BufferQuestLogText_SwappedHeldItem(const u16 *);
+static const u16 *BufferQuestLogText_SwappedHeldItemFromPC(const u16 *);
+static const u16 *BufferQuestLogText_UsedPkmnCenter(const u16 *);
+static const u16 *BufferQuestLogText_LinkTraded(const u16 *);
+static const u16 *BufferQuestLogText_LinkBattledSingle(const u16 *);
+static const u16 *BufferQuestLogText_LinkBattledDouble(const u16 *);
+static const u16 *BufferQuestLogText_LinkBattledMulti(const u16 *);
+static const u16 *BufferQuestLogText_UsedUnionRoom(const u16 *);
+static const u16 *BufferQuestLogText_UsedUnionRoomChat(const u16 *);
+static const u16 *BufferQuestLogText_LinkTradedUnionRoom(const u16 *);
+static const u16 *BufferQuestLogText_LinkBattledUnionRoom(const u16 *);
+static const u16 *BufferQuestLogText_SwitchedMonsBetweenBoxes(const u16 *);
+static const u16 *BufferQuestLogText_SwitchedMonsWithinBox(const u16 *);
+static const u16 *BufferQuestLogText_SwitchedPartyMonForPCMon(const u16 *);
+static const u16 *BufferQuestLogText_MovedMonBetweenBoxes(const u16 *);
+static const u16 *BufferQuestLogText_MovedMonWithinBox(const u16 *);
+static const u16 *BufferQuestLogText_WithdrewMonFromPC(const u16 *);
+static const u16 *BufferQuestLogText_DepositedMonInPC(const u16 *);
+static const u16 *BufferQuestLogText_SwitchedMultipleMons(const u16 *);
+static const u16 *BufferQuestLogText_DepositedItemInPC(const u16 *);
+static const u16 *BufferQuestLogText_WithdrewItemFromPC(const u16 *);
+static const u16 *BufferQuestLogText_DefeatedGymLeader(const u16 *);
+static const u16 *BufferQuestLogText_DefeatedWildMon(const u16 *);
+static const u16 *BufferQuestLogText_DefeatedEliteFourMember(const u16 *);
+static const u16 *BufferQuestLogText_DefeatedChampion(const u16 *);
+static const u16 *BufferQuestLogText_DefeatedTrainer(const u16 *);
+static const u16 *BufferQuestLogText_DepartedLocation(const u16 *);
+static const u16 *BufferQuestLogText_UsedFieldMove(const u16 *);
+static const u16 *BufferQuestLogText_BoughtItem(const u16 *);
+static const u16 *BufferQuestLogText_SoldItem(const u16 *);
+static const u16 *BufferQuestLogText_ObtainedItem(const u16 *);
+static const u16 *BufferQuestLogText_ArrivedInLocation(const u16 *);
+static bool8 IsSpeciesFromSpecialEncounter(u16);
+static bool8 ShouldRegisterEvent_HandleDeparted(u16, const u16 *);
+static bool8 ShouldRegisterEvent_HandleGameCorner(u16, const u16 *);
+static void BufferLinkPartnersName(u8 *);
+
+static u16 *(*const sQuestLogStorageCBs[])(u16 *, const u16 *) = {
+ [QL_EVENT_0] = NULL,
+ [QL_EVENT_1] = NULL,
+ [QL_EVENT_2] = NULL,
+ [QL_EVENT_SWITCHED_PARTY_ORDER] = BufferQuestLogData_SwitchedPartyOrder,
+ [QL_EVENT_USED_ITEM] = BufferQuestLogData_UsedItem,
+ [QL_EVENT_GAVE_HELD_ITEM] = BufferQuestLogData_GaveHeldItemFromPartyMenu,
+ [QL_EVENT_GAVE_HELD_ITEM_BAG] = BufferQuestLogData_GaveHeldItemFromBagMenu,
+ [QL_EVENT_GAVE_HELD_ITEM_PC] = BufferQuestLogData_GaveHeldItemFromPC,
+ [QL_EVENT_TOOK_HELD_ITEM] = BufferQuestLogData_TookHeldItem,
+ [QL_EVENT_SWAPPED_HELD_ITEM] = BufferQuestLogData_SwappedHeldItem,
+ [QL_EVENT_SWAPPED_HELD_ITEM_PC] = BufferQuestLogData_SwappedHeldItemFromPC,
+ [QL_EVENT_USED_PKMN_CENTER] = BufferQuestLogData_UsedPkmnCenter,
+ [QL_EVENT_LINK_TRADED] = BufferQuestLogData_LinkTraded,
+ [QL_EVENT_LINK_BATTLED_SINGLE] = BufferQuestLogData_LinkBattledSingle,
+ [QL_EVENT_LINK_BATTLED_DOUBLE] = BufferQuestLogData_LinkBattledDouble,
+ [QL_EVENT_LINK_BATTLED_MULTI] = BufferQuestLogData_LinkBattledMulti,
+ [QL_EVENT_USED_UNION_ROOM] = BufferQuestLogData_UsedUnionRoom,
+ [QL_EVENT_USED_UNION_ROOM_CHAT] = BufferQuestLogData_UsedUnionRoomChat,
+ [QL_EVENT_LINK_TRADED_UNION] = BufferQuestLogData_LinkTradedUnionRoom,
+ [QL_EVENT_LINK_BATTLED_UNION] = BufferQuestLogData_LinkBattledUnionRoom,
+ [QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES] = BufferQuestLogData_SwitchedMonsBetweenBoxes,
+ [QL_EVENT_SWITCHED_MONS_WITHIN_BOX] = BufferQuestLogData_SwitchedMonsWithinBox,
+ [QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON] = BufferQuestLogData_SwitchedPartyMonForPCMon,
+ [QL_EVENT_MOVED_MON_BETWEEN_BOXES] = BufferQuestLogData_MovedMonBetweenBoxes,
+ [QL_EVENT_MOVED_MON_WITHIN_BOX] = BufferQuestLogData_MovedMonWithinBox,
+ [QL_EVENT_WITHDREW_MON_PC] = BufferQuestLogData_WithdrewMonFromPC,
+ [QL_EVENT_DEPOSITED_MON_PC] = BufferQuestLogData_DepositedMonInPC,
+ [QL_EVENT_SWITCHED_MULTIPLE_MONS] = BufferQuestLogData_SwitchedMultipleMons,
+ [QL_EVENT_DEPOSITED_ITEM_PC] = BufferQuestLogData_DepositedItemInPC,
+ [QL_EVENT_WITHDREW_ITEM_PC] = BufferQuestLogData_WithdrewItemFromPC,
+ [QL_EVENT_DEFEATED_GYM_LEADER] = BufferQuestLogData_DefeatedGymLeader,
+ [QL_EVENT_DEFEATED_WILD_MON] = BufferQuestLogData_DefeatedWildMon,
+ [QL_EVENT_DEFEATED_E4_MEMBER] = BufferQuestLogData_DefeatedEliteFourMember,
+ [QL_EVENT_DEFEATED_CHAMPION] = BufferQuestLogData_DefeatedChampion,
+ [QL_EVENT_DEFEATED_TRAINER] = BufferQuestLogData_DefeatedTrainer,
+ [QL_EVENT_DEPARTED] = BufferQuestLogData_DepartedLocation,
+ [QL_EVENT_USED_FIELD_MOVE] = BufferQuestLogData_UsedFieldMove,
+ [QL_EVENT_BOUGHT_ITEM] = BufferQuestLogData_BoughtItem,
+ [QL_EVENT_SOLD_ITEM] = BufferQuestLogData_SoldItem,
+ [QL_EVENT_39] = NULL,
+ [QL_EVENT_OBTAINED_ITEM] = BufferQuestLogData_ObtainedItem,
+ [QL_EVENT_41] = NULL,
+ [QL_EVENT_ARRIVED] = BufferQuestLogData_ArrivedInLocation
+};
+
+void SetQuestLogEvent(u16 eventId, const u16 *eventData)
+{
+ u16 *r1;
+
+ if (eventId == QL_EVENT_DEPARTED && sEventShouldNotRecordSteps == 2)
+ {
+ sub_811381C();
+ return;
+ }
+ sub_811381C();
+ if (gQuestLogState == QL_STATE_PLAYBACK)
+ return;
+
+ if (!IS_VALID_QL_EVENT(eventId))
+ return;
+
+ if (InQuestLogDisabledLocation() == TRUE)
+ return;
+
+ if (TrySetLinkQuestLogEvent(eventId, eventData) == TRUE)
+ return;
+
+ if (MenuHelpers_LinkSomething() == TRUE)
+ return;
+
+ if (InUnionRoom() == TRUE)
+ return;
+
+ if (TrySetTrainerBattleQuestLogEvent(eventId, eventData) == TRUE)
+ return;
+
+ if (IsQuestLogEventWithSpecialEncounterSpecies(eventId, eventData) == TRUE)
+ return;
+
+ if (ShouldRegisterEvent_HandleGameCorner(eventId, eventData) == FALSE)
+ return;
+
+ if (gQuestLogPlaybackState == 0)
+ {
+ if (ShouldRegisterEvent_HandlePartyActions(eventId, eventData) == TRUE)
+ return;
+
+ if (eventId != QL_EVENT_DEFEATED_WILD_MON || gUnknown_203AE04 == NULL)
+ {
+ if (ShouldRegisterEvent_HandleDeparted(eventId, eventData) == FALSE)
+ return;
+ StartRecordingQuestLogEntry(eventId);
+ }
+ }
+ else if (eventId == QL_EVENT_OBTAINED_ITEM)
+ return;
+
+ SetQuestLogEventToActive(eventId);
+ if (eventId == QL_EVENT_DEFEATED_WILD_MON)
+ {
+ if (gUnknown_203AE04 == NULL)
+ {
+ gUnknown_203AE04 = sEventRecordingPointer;
+ r1 = sQuestLogStorageCBs[eventId](gUnknown_203AE04, eventData);
+ }
+ else
+ {
+ sQuestLogStorageCBs[eventId](gUnknown_203AE04, eventData);
+ return;
+ }
+ }
+ else
+ {
+ gUnknown_203AE04 = NULL;
+ r1 = sQuestLogStorageCBs[eventId](sEventRecordingPointer, eventData);
+ }
+
+ if (r1 == NULL)
+ {
+ FinishRecordingQuestLogScene();
+ r1 = ShouldRegisterEvent(eventId, eventData);
+ if (r1 == NULL)
+ return;
+ }
+
+ sEventRecordingPointer = r1;
+ if (sEventShouldNotRecordSteps == 0)
+ return;
+ FinishRecordingQuestLogScene();
+}
+
+static bool8 InQuestLogDisabledLocation(void)
+{
+ // In Trainer Tower
+ if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRAINER_TOWER_1F)
+ && (gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_1F)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_2F)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_3F)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_4F)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_5F)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_6F)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_7F)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_8F)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_ROOF)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_LOBBY)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_ELEVATOR)))
+ return TRUE;
+
+ // In pokemon trainer fan club
+ if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB))
+ return TRUE;
+
+ // In E-Reader house
+ if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SEVEN_ISLAND_HOUSE_ROOM1) &&
+ (gSaveBlock1Ptr->location.mapNum == MAP_NUM(SEVEN_ISLAND_HOUSE_ROOM1)
+ || gSaveBlock1Ptr->location.mapNum == MAP_NUM(SEVEN_ISLAND_HOUSE_ROOM2)))
+ return TRUE;
+
+ // In elevator
+ if ((gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROCKET_HIDEOUT_ELEVATOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROCKET_HIDEOUT_ELEVATOR))
+ || (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SILPH_CO_ELEVATOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SILPH_CO_ELEVATOR))
+ || (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRAINER_TOWER_ELEVATOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_TOWER_ELEVATOR))
+ || (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(CELADON_CITY_DEPARTMENT_STORE_ELEVATOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(CELADON_CITY_DEPARTMENT_STORE_ELEVATOR)))
+ return TRUE;
+
+ return FALSE;
+}
+
+bool8 QuestLog_ShouldEndSceneOnMapChange(void)
+{
+ if (InQuestLogDisabledLocation() != TRUE)
+ return FALSE;
+
+ if (gQuestLogState == QL_STATE_PLAYBACK)
+ return TRUE;
+
+ if (gQuestLogState == QL_STATE_RECORDING)
+ QuestLog_CutRecording();
+
+ return FALSE;
+}
+
+static bool8 ShouldRegisterEvent_HandlePartyActions(u16 eventId, const u16 *eventData)
+{
+ if (eventId == QL_EVENT_USED_FIELD_MOVE || eventId == QL_EVENT_USED_PKMN_CENTER)
+ return TRUE;
+
+ if (!FlagGet(FLAG_SYS_GAME_CLEAR))
+ {
+ if (eventId == QL_EVENT_SWITCHED_PARTY_ORDER || eventId == QL_EVENT_DEFEATED_WILD_MON || ShouldRegisterEvent_HandleBeatStoryTrainer(eventId, eventData) == TRUE)
+ return TRUE;
+ }
+
+ if (!FlagGet(FLAG_SYS_CAN_LINK_WITH_RS))
+ {
+ if (eventId == QL_EVENT_USED_ITEM
+ || eventId == QL_EVENT_GAVE_HELD_ITEM
+ || eventId == QL_EVENT_GAVE_HELD_ITEM_BAG
+ || eventId == QL_EVENT_GAVE_HELD_ITEM_PC
+ || eventId == QL_EVENT_TOOK_HELD_ITEM
+ || eventId == QL_EVENT_SWAPPED_HELD_ITEM
+ || eventId == QL_EVENT_SWAPPED_HELD_ITEM_PC
+ || eventId == QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON
+ || eventId == QL_EVENT_WITHDREW_MON_PC
+ || eventId == QL_EVENT_DEPOSITED_MON_PC)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static bool8 ShouldRegisterEvent_HandleBeatStoryTrainer(u16 eventId, const u16 *eventData)
+{
+ if (eventId == QL_EVENT_DEFEATED_TRAINER)
+ {
+ u8 trainerClass = gTrainers[*eventData].trainerClass;
+ if ( trainerClass == CLASS_RIVAL
+ || trainerClass == CLASS_RIVAL_2
+ || trainerClass == CLASS_CHAMPION_2
+ || trainerClass == CLASS_BOSS)
+ return FALSE;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void sub_811381C(void)
+{
+ sEventShouldNotRecordSteps = 0;
+}
+
+static u16 *ShouldRegisterEvent(u16 eventId, const u16 *eventData)
+{
+ if (ShouldRegisterEvent_HandlePartyActions(eventId, eventData) == TRUE)
+ return NULL;
+
+ if (ShouldRegisterEvent_HandleDeparted(eventId, eventData) == FALSE)
+ return NULL;
+
+ StartRecordingQuestLogEntry(eventId);
+ SetQuestLogEventToActive(eventId);
+
+ if (eventId == QL_EVENT_DEFEATED_WILD_MON)
+ gUnknown_203AE04 = sEventRecordingPointer;
+ else
+ gUnknown_203AE04 = NULL;
+
+ return sQuestLogStorageCBs[eventId](sEventRecordingPointer, eventData);
+}
+
+static bool8 TrySetLinkQuestLogEvent(u16 eventId, const u16 *eventData)
+{
+ if (!IS_LINK_QL_EVENT(eventId))
+ return FALSE;
+
+ ResetDeferredLinkEvent();
+ sDeferredEvent.id = eventId;
+
+ if (eventId != QL_EVENT_USED_UNION_ROOM && eventId != QL_EVENT_USED_UNION_ROOM_CHAT)
+ {
+ if (eventId == QL_EVENT_LINK_TRADED || eventId == QL_EVENT_LINK_TRADED_UNION)
+ memcpy(sDeferredEvent.data, eventData, 12);
+ else
+ memcpy(sDeferredEvent.data, eventData, 24);
+ }
+ return TRUE;
+}
+
+void ResetDeferredLinkEvent(void)
+{
+ sDeferredEvent = (struct DeferredLinkEvent){};
+}
+
+void QuestLog_StartRecordingInputsAfterDeferredEvent(void)
+{
+ if (sDeferredEvent.id != QL_EVENT_0)
+ {
+ u16 *resp;
+ sLastDepartedMap = 0;
+ StartRecordingQuestLogEntry(sDeferredEvent.id);
+ resp = sQuestLogStorageCBs[sDeferredEvent.id](sEventRecordingPointer, sDeferredEvent.data);
+ sEventRecordingPointer = resp;
+ ResetDeferredLinkEvent();
+ }
+}
+
+static bool8 TrySetTrainerBattleQuestLogEvent(u16 eventId, const u16 *eventData)
+{
+ if (eventId != QL_EVENT_DEFEATED_TRAINER
+ && eventId != QL_EVENT_DEFEATED_GYM_LEADER
+ && eventId != QL_EVENT_DEFEATED_E4_MEMBER
+ && eventId != QL_EVENT_DEFEATED_CHAMPION)
+ return FALSE;
+
+ ResetDeferredLinkEvent();
+ if (gQuestLogPlaybackState != 0 || FlagGet(FLAG_SYS_GAME_CLEAR) || ShouldRegisterEvent_HandleBeatStoryTrainer(eventId, eventData) != TRUE)
+ {
+ sDeferredEvent.id = eventId;
+ memcpy(sDeferredEvent.data, eventData, 8);
+ }
+ return TRUE;
+}
+
+void sub_81139BC(void)
+{
+ if (sDeferredEvent.id != QL_EVENT_0)
+ {
+ u16 *resp;
+ if (gQuestLogPlaybackState == 0)
+ {
+ sLastDepartedMap = 0;
+ StartRecordingQuestLogEntry(sDeferredEvent.id);
+ }
+ SetQuestLogEventToActive(sDeferredEvent.id);
+ resp = sQuestLogStorageCBs[sDeferredEvent.id](sEventRecordingPointer, sDeferredEvent.data);
+ sEventRecordingPointer = resp;
+ TryRecordEvent41_IncCursor(1);
+ ResetDeferredLinkEvent();
+ FinishRecordingQuestLogScene();
+ }
+}
+
+void TryRecordEvent41_IncCursor(u16 a0)
+{
+ sEventRecordingPointer = TryRecordEvent41(sEventRecordingPointer, a0);
+ sQuestLogCursor++;
+}
+
+static bool8 IsQuestLogEventWithSpecialEncounterSpecies(u16 eventId, const u16 *eventData)
+{
+ if (eventId != QL_EVENT_DEFEATED_WILD_MON)
+ return FALSE;
+
+ if (IsSpeciesFromSpecialEncounter(eventData[0]) == TRUE)
+ return TRUE;
+
+ if (IsSpeciesFromSpecialEncounter(eventData[1]) == TRUE)
+ return TRUE;
+
+ return FALSE;
+}
+
+static const u16 *(*const sQuestLogEventTextBufferCBs[])(const u16 *) = {
+ [QL_EVENT_0] = NULL,
+ [QL_EVENT_1] = NULL,
+ [QL_EVENT_2] = NULL,
+ [QL_EVENT_SWITCHED_PARTY_ORDER] = BufferQuestLogText_SwitchedPartyOrder,
+ [QL_EVENT_USED_ITEM] = BufferQuestLogText_UsedItem,
+ [QL_EVENT_GAVE_HELD_ITEM] = BufferQuestLogText_GaveHeldItemFromPartyMenu,
+ [QL_EVENT_GAVE_HELD_ITEM_BAG] = BufferQuestLogText_GaveHeldItemFromBagMenu,
+ [QL_EVENT_GAVE_HELD_ITEM_PC] = BufferQuestLogText_GaveHeldItemFromPC,
+ [QL_EVENT_TOOK_HELD_ITEM] = BufferQuestLogText_TookHeldItem,
+ [QL_EVENT_SWAPPED_HELD_ITEM] = BufferQuestLogText_SwappedHeldItem,
+ [QL_EVENT_SWAPPED_HELD_ITEM_PC] = BufferQuestLogText_SwappedHeldItemFromPC,
+ [QL_EVENT_USED_PKMN_CENTER] = BufferQuestLogText_UsedPkmnCenter,
+ [QL_EVENT_LINK_TRADED] = BufferQuestLogText_LinkTraded,
+ [QL_EVENT_LINK_BATTLED_SINGLE] = BufferQuestLogText_LinkBattledSingle,
+ [QL_EVENT_LINK_BATTLED_DOUBLE] = BufferQuestLogText_LinkBattledDouble,
+ [QL_EVENT_LINK_BATTLED_MULTI] = BufferQuestLogText_LinkBattledMulti,
+ [QL_EVENT_USED_UNION_ROOM] = BufferQuestLogText_UsedUnionRoom,
+ [QL_EVENT_USED_UNION_ROOM_CHAT] = BufferQuestLogText_UsedUnionRoomChat,
+ [QL_EVENT_LINK_TRADED_UNION] = BufferQuestLogText_LinkTradedUnionRoom,
+ [QL_EVENT_LINK_BATTLED_UNION] = BufferQuestLogText_LinkBattledUnionRoom,
+ [QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES] = BufferQuestLogText_SwitchedMonsBetweenBoxes,
+ [QL_EVENT_SWITCHED_MONS_WITHIN_BOX] = BufferQuestLogText_SwitchedMonsWithinBox,
+ [QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON] = BufferQuestLogText_SwitchedPartyMonForPCMon,
+ [QL_EVENT_MOVED_MON_BETWEEN_BOXES] = BufferQuestLogText_MovedMonBetweenBoxes,
+ [QL_EVENT_MOVED_MON_WITHIN_BOX] = BufferQuestLogText_MovedMonWithinBox,
+ [QL_EVENT_WITHDREW_MON_PC] = BufferQuestLogText_WithdrewMonFromPC,
+ [QL_EVENT_DEPOSITED_MON_PC] = BufferQuestLogText_DepositedMonInPC,
+ [QL_EVENT_SWITCHED_MULTIPLE_MONS] = BufferQuestLogText_SwitchedMultipleMons,
+ [QL_EVENT_DEPOSITED_ITEM_PC] = BufferQuestLogText_DepositedItemInPC,
+ [QL_EVENT_WITHDREW_ITEM_PC] = BufferQuestLogText_WithdrewItemFromPC,
+ [QL_EVENT_DEFEATED_GYM_LEADER] = BufferQuestLogText_DefeatedGymLeader,
+ [QL_EVENT_DEFEATED_WILD_MON] = BufferQuestLogText_DefeatedWildMon,
+ [QL_EVENT_DEFEATED_E4_MEMBER] = BufferQuestLogText_DefeatedEliteFourMember,
+ [QL_EVENT_DEFEATED_CHAMPION] = BufferQuestLogText_DefeatedChampion,
+ [QL_EVENT_DEFEATED_TRAINER] = BufferQuestLogText_DefeatedTrainer,
+ [QL_EVENT_DEPARTED] = BufferQuestLogText_DepartedLocation,
+ [QL_EVENT_USED_FIELD_MOVE] = BufferQuestLogText_UsedFieldMove,
+ [QL_EVENT_BOUGHT_ITEM] = BufferQuestLogText_BoughtItem,
+ [QL_EVENT_SOLD_ITEM] = BufferQuestLogText_SoldItem,
+ [QL_EVENT_39] = NULL,
+ [QL_EVENT_OBTAINED_ITEM] = BufferQuestLogText_ObtainedItem,
+ [QL_EVENT_41] = NULL,
+ [QL_EVENT_ARRIVED] = BufferQuestLogText_ArrivedInLocation
+};
+
+static const u8 sQuestLogEventCmdSizes[] = {
+ [QL_EVENT_0] = 0x08,
+ [QL_EVENT_1] = 0x08,
+ [QL_EVENT_2] = 0x08,
+ [QL_EVENT_SWITCHED_PARTY_ORDER] = 0x08,
+ [QL_EVENT_USED_ITEM] = 0x0a,
+ [QL_EVENT_GAVE_HELD_ITEM] = 0x08,
+ [QL_EVENT_GAVE_HELD_ITEM_BAG] = 0x08,
+ [QL_EVENT_GAVE_HELD_ITEM_PC] = 0x08,
+ [QL_EVENT_TOOK_HELD_ITEM] = 0x08,
+ [QL_EVENT_SWAPPED_HELD_ITEM] = 0x0a,
+ [QL_EVENT_SWAPPED_HELD_ITEM_PC] = 0x0a,
+ [QL_EVENT_USED_PKMN_CENTER] = 0x04,
+ [QL_EVENT_LINK_TRADED] = 0x10,
+ [QL_EVENT_LINK_BATTLED_SINGLE] = 0x0c,
+ [QL_EVENT_LINK_BATTLED_DOUBLE] = 0x0c,
+ [QL_EVENT_LINK_BATTLED_MULTI] = 0x1a,
+ [QL_EVENT_USED_UNION_ROOM] = 0x04,
+ [QL_EVENT_USED_UNION_ROOM_CHAT] = 0x04,
+ [QL_EVENT_LINK_TRADED_UNION] = 0x10,
+ [QL_EVENT_LINK_BATTLED_UNION] = 0x0c,
+ [QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES] = 0x0a,
+ [QL_EVENT_SWITCHED_MONS_WITHIN_BOX] = 0x0a,
+ [QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON] = 0x0a,
+ [QL_EVENT_MOVED_MON_BETWEEN_BOXES] = 0x08,
+ [QL_EVENT_MOVED_MON_WITHIN_BOX] = 0x08,
+ [QL_EVENT_WITHDREW_MON_PC] = 0x08,
+ [QL_EVENT_DEPOSITED_MON_PC] = 0x08,
+ [QL_EVENT_SWITCHED_MULTIPLE_MONS] = 0x06,
+ [QL_EVENT_DEPOSITED_ITEM_PC] = 0x06,
+ [QL_EVENT_WITHDREW_ITEM_PC] = 0x06,
+ [QL_EVENT_DEFEATED_GYM_LEADER] = 0x0c,
+ [QL_EVENT_DEFEATED_WILD_MON] = 0x0c,
+ [QL_EVENT_DEFEATED_E4_MEMBER] = 0x0c,
+ [QL_EVENT_DEFEATED_CHAMPION] = 0x0a,
+ [QL_EVENT_DEFEATED_TRAINER] = 0x0c,
+ [QL_EVENT_DEPARTED] = 0x06,
+ [QL_EVENT_USED_FIELD_MOVE] = 0x08,
+ [QL_EVENT_BOUGHT_ITEM] = 0x0e,
+ [QL_EVENT_SOLD_ITEM] = 0x0e,
+ [QL_EVENT_39] = 0x02,
+ [QL_EVENT_OBTAINED_ITEM] = 0x08,
+ [QL_EVENT_41] = 0x04,
+ [QL_EVENT_ARRIVED] = 0x06
+};
+
+u16 *QuestLog_SkipCommand(u16 *curPtr, u16 **prevPtr_p)
+{
+ u16 eventId = curPtr[0] & 0xfff;
+ u16 cnt = curPtr[0] >> 12;
+
+ if (eventId == QL_EVENT_DEFEATED_CHAMPION)
+ cnt = 0;
+
+ if (!IS_VALID_QL_EVENT(eventId))
+ return NULL;
+
+ *prevPtr_p = curPtr;
+ return sQuestLogEventCmdSizes[eventId] + (sQuestLogEventCmdSizes[eventId] - 4) * cnt + (void *)curPtr;
+}
+
+void sub_8113ABC(const u16 *a0)
+{
+ const u8 *r2 = (const u8 *)(a0 + 2);
+ if ((a0[0] & 0xFFF) != QL_EVENT_DEPARTED)
+ sLastDepartedMap = 0;
+ else
+ sLastDepartedMap = r2[1] + 1;
+}
+
+bool8 sub_8113AE8(const u16 *a0)
+{
+#ifndef NONMATCHING
+ register const u16 *r0 asm("r0") = a0;
+#else
+ const u16 *r0 = a0;
+#endif
+
+ if (r0 == NULL || r0[1] > sQuestLogCursor)
+ return FALSE;
+
+ sQuestLogEventTextBufferCBs[a0[0] & 0xFFF](a0);
+ gUnknown_203B044.id = a0[0];
+ gUnknown_203B044.unk_1 = (a0[0] & 0xF000) >> 12;
+ if (gUnknown_203B044.unk_1 != 0)
+ gUnknown_203B044.unk_2 = 1;
+ return TRUE;
+}
+
+bool8 sub_8113B44(const u16 *a0)
+{
+ if (gUnknown_203B044.unk_2 == 0)
+ return FALSE;
+
+ sQuestLogEventTextBufferCBs[gUnknown_203B044.id](a0);
+ gUnknown_203B044.unk_2++;
+ if (gUnknown_203B044.unk_2 > gUnknown_203B044.unk_1)
+ ResetUnk203B044();
+ return TRUE;
+}
+
+void ResetUnk203B044(void)
+{
+ gUnknown_203B044 = (struct UnkStruct_203B044){};
+}
+
+static void SetQuestLogEventToActive(u16 eventId)
+{
+ if (gUnknown_203B044.id != (u8)eventId || gUnknown_203B044.unk_2 != sQuestLogCursor)
+ {
+ gUnknown_203B044.id = eventId;
+ gUnknown_203B044.unk_1 = 0;
+ gUnknown_203B044.unk_2 = sQuestLogCursor;
+ }
+ else if (gUnknown_203B044.unk_1 < 5)
+ gUnknown_203B044.unk_1++;
+}
+
+void sub_8113BD8(void)
+{
+ sNewlyEnteredMap = FALSE;
+ sLastDepartedMap = 0;
+ sPlayedTheSlots = FALSE;
+}
+
+u16 *TryRecordEvent39_NoParams(u16 *a0)
+{
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_39]))
+ return NULL;
+ a0[0] = QL_EVENT_39;
+ return a0 + 1;
+}
+
+u16 *sub_8113C20(u16 *a0, struct QuestLogEntry * a1)
+{
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_39]))
+ return NULL;
+ a1->command = 0xFF;
+ a1->duration = 0;
+ a1->localId = 0;
+ a1->mapNum = 0;
+ a1->mapGroup = 0;
+ a1->animId = 0;
+ return a0 + 1;
+}
+
+static u16 *TryRecordEvent41(u16 *a0, u16 a1)
+{
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_41]))
+ return NULL;
+ a0[0] = QL_EVENT_41;
+ a0[1] = a1;
+ return a0 + 2;
+}
+
+u16 *sub_8113C8C(u16 *a0, struct QuestLogEntry * a1)
+{
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_41]))
+ return NULL;
+ a1->command = 0xFE;
+ a1->duration = a0[1];
+ a1->localId = 0;
+ a1->mapNum = 0;
+ a1->mapGroup = 0;
+ a1->animId = 0;
+ return a0 + 2;
+}
+
+u16 *sub_8113CC8(u16 *a0, struct QuestLogEntry * a1)
+{
+ u8 *r6 = (u8 *)a0 + 4;
+
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_0]))
+ return NULL;
+ a0[0] = 0;
+ a0[1] = a1->duration;
+ r6[0] = a1->localId;
+ r6[1] = a1->mapNum;
+ r6[2] = a1->mapGroup;
+ r6[3] = a1->animId;
+ return (u16 *)(r6 + 4);
+}
+
+u16 *sub_8113D08(u16 *a0, struct QuestLogEntry * a1)
+{
+ u8 *r6 = (u8 *)a0 + 4;
+
+ if (!WillCommandOfSizeFitInSav1Record(a0, sQuestLogEventCmdSizes[QL_EVENT_0]))
+ return NULL;
+ a1->command = 2;
+ a1->duration = a0[1];
+ a1->localId = r6[0];
+ a1->mapNum = r6[1];
+ a1->mapGroup = r6[2];
+ a1->animId = r6[3];
+ return (u16 *)(r6 + 4);
+}
+
+u16 *sub_8113D48(u16 *a0, struct QuestLogEntry * a1)
+{
+ u16 *r4 = a0;
+ u8 *r6 = (u8 *)a0 + 4;
+
+ if (!WillCommandOfSizeFitInSav1Record(r4, sQuestLogEventCmdSizes[QL_EVENT_2]))
+ return NULL;
+ if (a1->command == 0)
+ r4[0] = 2;
+ else
+ r4[0] = 1;
+ r4[1] = a1->duration;
+ r6[0] = a1->localId;
+ r6[1] = a1->mapNum;
+ r6[2] = a1->mapGroup;
+ r6[3] = a1->animId;
+ return (u16 *)(r6 + 4);
+}
+
+u16 *sub_8113D94(u16 *a0, struct QuestLogEntry * a1)
+{
+ u16 *r5 = a0;
+ u8 *r6 = (u8 *)a0 + 4;
+
+ if (!WillCommandOfSizeFitInSav1Record(r5, sQuestLogEventCmdSizes[QL_EVENT_2]))
+ return NULL;
+ if (r5[0] == 2)
+ a1->command = 0;
+ else
+ a1->command = 1;
+ a1->duration = r5[1];
+ a1->localId = r6[0];
+ a1->mapNum = r6[1];
+ a1->mapGroup = r6[2];
+ a1->animId = r6[3];
+ return (u16 *)(r6 + 4);
+}
+
+u16 *sub_8113DE0(u16 eventId, u16 *a1)
+{
+ u8 cmdSize;
+ u16 *r5;
+ u8 r4;
+ u8 r1;
+
+ if (gUnknown_203B044.unk_1 == 0)
+ cmdSize = sQuestLogEventCmdSizes[eventId];
+ else
+ cmdSize = sQuestLogEventCmdSizes[eventId] - 4;
+ if (!sub_8110944(a1, cmdSize))
+ return NULL;
+
+ r5 = (void *)a1;
+
+ if (gUnknown_203B044.unk_1 != 0)
+ r5 = (void *)r5 - (gUnknown_203B044.unk_1 * cmdSize + 4);
+
+ if (gUnknown_203B044.unk_1 == 5)
+ {
+ for (r4 = 0; r4 < 4; r4++)
+ {
+ memcpy(
+ (void *)r5 + (r4 * cmdSize + 4),
+ (void *)r5 + ((r4 + 1) * cmdSize + 4),
+ cmdSize
+ );
+ }
+ r1 = 4;
+ }
+ else
+ r1 = gUnknown_203B044.unk_1;
+
+ r5[0] = eventId + (r1 << 12);
+ r5[1] = sQuestLogCursor;
+ r5 = (void *)r5 + (r1 * cmdSize + 4);
+ return r5;
+}
+
+static const u16 *sub_8113E88(u16 eventId, const u16 *eventData)
+{
+ eventData = (const void *)eventData + (gUnknown_203B044.unk_2 * (sQuestLogEventCmdSizes[eventId] - 4) + 4);
+ return eventData;
+}
+
+static void QuestLog_GetSpeciesName(u16 species, u8 *dest, u8 stringVarId)
+{
+ if (dest != NULL)
+ {
+ if (species != SPECIES_EGG)
+ GetSpeciesName(dest, species);
+ else
+ StringCopy(dest, gText_EggNickname);
+ }
+ else
+ {
+ if (species != SPECIES_EGG)
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(stringVarId, gSpeciesNames[species]);
+ else
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(stringVarId, gText_EggNickname);
+ }
+}
+
+static u16 *BufferQuestLogData_SwitchedPartyOrder(u16 *a0, const u16 *eventData)
+{
+ u16 *r2 = sub_8113DE0(QL_EVENT_SWITCHED_PARTY_ORDER, a0);
+ if (r2 == NULL)
+ return NULL;
+
+ r2[0] = eventData[0];
+ r2[1] = eventData[1];
+ return r2 + 2;
+}
+
+static const u16 *BufferQuestLogText_SwitchedPartyOrder(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_SWITCHED_PARTY_ORDER, eventData);
+ QuestLog_GetSpeciesName(r4[0], gStringVar1, 0);
+ QuestLog_GetSpeciesName(r4[1], gStringVar2, 0);
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchMon1WithMon2);
+ r4 += 2;
+ return r4;
+}
+
+static u16 *BufferQuestLogData_UsedItem(u16 *a0, const u16 *eventData)
+{
+ u16 *r2 = sub_8113DE0(QL_EVENT_USED_ITEM, a0);
+ if (r2 == NULL)
+ return NULL;
+
+ r2[0] = eventData[0];
+ r2[1] = eventData[2];
+ r2[2] = eventData[3];
+
+ if (eventData[0] == ITEM_ESCAPE_ROPE)
+ sEventShouldNotRecordSteps = 2;
+
+ return r2 + 3;
+}
+
+static const u16 *BufferQuestLogText_UsedItem(const u16 *eventData)
+{
+ const u16 *r5 = sub_8113E88(QL_EVENT_USED_ITEM, eventData);
+
+ switch (ItemId_GetPocket(r5[0]))
+ {
+ case POCKET_ITEMS:
+ case POCKET_POKE_BALLS:
+ case POCKET_BERRY_POUCH:
+ StringCopy(gStringVar1, ItemId_GetName(r5[0]));
+ if (r5[0] == ITEM_ESCAPE_ROPE)
+ {
+ GetMapNameGeneric(gStringVar2, (u8)r5[2]);
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_UsedEscapeRope);
+ }
+ else if (r5[1] != 0xFFFF)
+ {
+ QuestLog_GetSpeciesName(r5[1], gStringVar2, 0);
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_UsedItemOnMonAtThisLocation);
+ }
+ else
+ {
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_UsedTheItem);
+ }
+ break;
+ case POCKET_KEY_ITEMS:
+ StringCopy(gStringVar1, ItemId_GetName(r5[0]));
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_UsedTheKeyItem);
+ break;
+ case POCKET_TM_CASE:
+ QuestLog_GetSpeciesName(r5[1], gStringVar1, 0);
+ StringCopy(gStringVar2, gMoveNames[ItemIdToBattleMoveId(r5[0])]);
+ if (r5[2] != 0xFFFF)
+ {
+ StringCopy(gStringVar3, gMoveNames[r5[2]]);
+ if (r5[0] > ITEM_TM50)
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonReplacedMoveWithHM);
+ else
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonReplacedMoveWithTM);
+ }
+ else
+ {
+ if (r5[0] > ITEM_TM50)
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonLearnedMoveFromHM);
+ else
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonLearnedMoveFromTM);
+ }
+ break;
+ }
+ return r5 + 3;
+}
+
+u16 *BufferQuestLogData_GiveTakeHeldItem(u16 eventId, u16 *a1, const u16 *eventData)
+{
+ u16 *r1 = sub_8113DE0(eventId, a1);
+ if (r1 == NULL)
+ return NULL;
+
+ r1[0] = eventData[0];
+ r1[1] = eventData[2];
+ return r1 + 2;
+}
+
+static u16 *BufferQuestLogData_GaveHeldItemFromPartyMenu(u16 *a0, const u16 *eventData)
+{
+ return BufferQuestLogData_GiveTakeHeldItem(QL_EVENT_GAVE_HELD_ITEM, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_GaveHeldItemFromPartyMenu(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_GAVE_HELD_ITEM, eventData);
+ QuestLog_GetSpeciesName(r4[1], gStringVar1, 0);
+ StringCopy(gStringVar2, ItemId_GetName(r4[0]));
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_GaveMonHeldItem);
+ r4 += 2;
+ return r4;
+}
+
+static u16 *BufferQuestLogData_GaveHeldItemFromBagMenu(u16 *a0, const u16 *eventData)
+{
+ return BufferQuestLogData_GiveTakeHeldItem(QL_EVENT_GAVE_HELD_ITEM_BAG, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_GaveHeldItemFromBagMenu(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_GAVE_HELD_ITEM_BAG, eventData);
+ QuestLog_GetSpeciesName(r4[1], gStringVar1, 0);
+ StringCopy(gStringVar2, ItemId_GetName(r4[0]));
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_GaveMonHeldItem2);
+ r4 += 2;
+ return r4;
+}
+
+static u16 *BufferQuestLogData_GaveHeldItemFromPC(u16 *a0, const u16 *eventData)
+{
+ return BufferQuestLogData_GiveTakeHeldItem(QL_EVENT_GAVE_HELD_ITEM_PC, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_GaveHeldItemFromPC(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_GAVE_HELD_ITEM_PC, eventData);
+
+ QuestLog_GetSpeciesName(r4[1], gStringVar2, 0);
+ StringCopy(gStringVar1, ItemId_GetName(r4[0]));
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_GaveMonHeldItemFromPC);
+ r4 += 2;
+ return r4;
+}
+
+static u16 *BufferQuestLogData_TookHeldItem(u16 *a0, const u16 *eventData)
+{
+ return BufferQuestLogData_GiveTakeHeldItem(QL_EVENT_TOOK_HELD_ITEM, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_TookHeldItem(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_TOOK_HELD_ITEM, eventData);
+
+ QuestLog_GetSpeciesName(r4[1], gStringVar1, 0);
+ StringCopy(gStringVar2, ItemId_GetName(r4[0]));
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_TookHeldItemFromMon);
+ r4 += 2;
+ return r4;
+}
+
+u16 *BufferQuestLogData_SwappedHeldItem_(u16 eventId, u16 *a1, const u16 *eventData)
+{
+ u16 *r1 = sub_8113DE0(eventId, a1);
+ if (r1 == NULL)
+ return NULL;
+
+ r1[0] = eventData[0];
+ r1[1] = eventData[1];
+ r1[2] = eventData[2];
+ return r1 + 3;
+}
+
+static u16 *BufferQuestLogData_SwappedHeldItem(u16 *a0, const u16 *eventData)
+{
+ return BufferQuestLogData_SwappedHeldItem_(QL_EVENT_SWAPPED_HELD_ITEM, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_SwappedHeldItem(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_SWAPPED_HELD_ITEM, eventData);
+ QuestLog_GetSpeciesName(r4[2], gStringVar1, 0);
+ StringCopy(gStringVar2, ItemId_GetName(r4[0])); // Item taken
+ StringCopy(gStringVar3, ItemId_GetName(r4[1])); // Item given
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_SwappedHeldItemsOnMon);
+ r4 += 3;
+ return r4;
+}
+
+static u16 *BufferQuestLogData_SwappedHeldItemFromPC(u16 *a0, const u16 *eventData)
+{
+ return BufferQuestLogData_SwappedHeldItem_(QL_EVENT_SWAPPED_HELD_ITEM_PC, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_SwappedHeldItemFromPC(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_SWAPPED_HELD_ITEM_PC, eventData);
+ QuestLog_GetSpeciesName(r4[2], gStringVar2, 0);
+ StringCopy(gStringVar3, ItemId_GetName(r4[0]));
+ StringCopy(gStringVar1, ItemId_GetName(r4[1]));
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_SwappedHeldItemFromPC);
+ r4 += 3;
+ return r4;
+}
+
+static u16 *BufferQuestLogData_UsedPkmnCenter(u16 *a0, const u16 *eventData)
+{
+ u16 *r4 = a0;
+ if (gUnknown_203B044.id == QL_EVENT_USED_PKMN_CENTER && gUnknown_203B044.unk_1 != 0)
+ return r4;
+
+ if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_USED_PKMN_CENTER]))
+ return NULL;
+
+ r4[0] = QL_EVENT_USED_PKMN_CENTER;
+ r4[1] = sQuestLogCursor;
+ return r4 + 2;
+}
+
+static const u16 *BufferQuestLogText_UsedPkmnCenter(const u16 *a0)
+{
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_MonsWereFullyRestoredAtCenter);
+ a0 += 2;
+ return a0;
+}
+
+static u16 *BufferQuestLogData_LinkTraded(u16 *a0, const u16 *eventData)
+{
+ u16 *r4 = a0 + 4;
+
+ a0[0] = QL_EVENT_LINK_TRADED;
+ a0[1] = sQuestLogCursor;
+ a0[2] = eventData[0];
+ a0[3] = eventData[1];
+ eventData += 2;
+ memcpy(r4, eventData, 7);
+ r4 += 4;
+ return r4;
+}
+
+static const u16 *BufferQuestLogText_LinkTraded(const u16 *a0)
+{
+ const u16 *r6 = a0 + 4;
+
+ memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
+ memcpy(gStringVar1, r6, PLAYER_NAME_LENGTH);
+
+ BufferLinkPartnersName(gStringVar1);
+ QuestLog_GetSpeciesName(a0[3], gStringVar2, 0); // Mon received
+ QuestLog_GetSpeciesName(a0[2], gStringVar3, 0); // Mon sent
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_TradedMon1ForPersonsMon2);
+ r6 += 4;
+ return r6;
+}
+
+static const u8 *const sDefeatedOpponentFlavorTexts[] = {
+ gText_QuestLog_Handily,
+ gText_QuestLog_Tenaciously,
+ gText_QuestLog_Somehow
+};
+
+static const u8 *const sDefeatedChampionFlavorTexts[] = {
+ gText_QuestLog_Coolly,
+ gText_QuestLog_Somehow,
+ gText_QuestLog_Barely
+};
+
+static const u8 *const sBattleOutcomeTexts[] = {
+ gText_QuestLog_Win,
+ gText_QuestLog_Loss,
+ gText_QuestLog_Draw
+};
+
+static u16 *BufferQuestLogData_LinkBattledSingle(u16 *a0, const u16 *eventData)
+{
+ a0[0] = QL_EVENT_LINK_BATTLED_SINGLE;
+ a0[1] = sQuestLogCursor;
+ *((u8 *)a0 + 4) = *((const u8 *)eventData + 0);
+ memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH);
+ a0 += 6;
+ return a0;
+}
+
+static const u16 *BufferQuestLogText_LinkBattledSingle(const u16 *a0)
+{
+ DynamicPlaceholderTextUtil_Reset();
+
+ memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
+ memcpy(gStringVar1, (const u8 *)a0 + 5, PLAYER_NAME_LENGTH);
+ BufferLinkPartnersName(gStringVar1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, sBattleOutcomeTexts[((const u8 *)a0)[4]]);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SingleBattleWithPersonResultedInOutcome);
+ a0 += 6;
+ return a0;
+}
+
+static u16 *BufferQuestLogData_LinkBattledDouble(u16 *a0, const u16 *eventData)
+{
+ a0[0] = QL_EVENT_LINK_BATTLED_DOUBLE;
+ a0[1] = sQuestLogCursor;
+ *((u8 *)a0 + 4) = *((const u8 *)eventData + 0);
+ memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH);
+ a0 += 6;
+ return a0;
+}
+
+static const u16 *BufferQuestLogText_LinkBattledDouble(const u16 *a0)
+{
+ DynamicPlaceholderTextUtil_Reset();
+
+ memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
+ memcpy(gStringVar1, (const u8 *)a0 + 5, PLAYER_NAME_LENGTH);
+ BufferLinkPartnersName(gStringVar1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, sBattleOutcomeTexts[((const u8 *)a0)[4]]);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DoubleBattleWithPersonResultedInOutcome);
+ a0 += 6;
+ return a0;
+}
+
+static u16 *BufferQuestLogData_LinkBattledMulti(u16 *a0, const u16 *eventData)
+{
+ a0[0] = QL_EVENT_LINK_BATTLED_MULTI;
+ a0[1] = sQuestLogCursor;
+ *((u8 *)a0 + 4) = *((const u8 *)eventData + 0);
+ memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH);
+ memcpy((u8 *)a0 + 12, (const u8 *)eventData + 8, PLAYER_NAME_LENGTH);
+ memcpy((u8 *)a0 + 19, (const u8 *)eventData + 15, PLAYER_NAME_LENGTH);
+ a0 += 13;
+ return a0;
+}
+
+static const u16 *BufferQuestLogText_LinkBattledMulti(const u16 *a0)
+{
+ DynamicPlaceholderTextUtil_Reset();
+
+ memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
+ memset(gStringVar2, EOS, PLAYER_NAME_LENGTH + 1);
+ memset(gStringVar3, EOS, PLAYER_NAME_LENGTH + 1);
+ StringCopy7(gStringVar1, (const u8 *)a0 + 5);
+ StringCopy7(gStringVar2, (const u8 *)a0 + 12);
+ StringCopy7(gStringVar3, (const u8 *)a0 + 19);
+ BufferLinkPartnersName(gStringVar1);
+ BufferLinkPartnersName(gStringVar2);
+ BufferLinkPartnersName(gStringVar3);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gStringVar1); // partner
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar2); // opponent 1
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, gStringVar3); // opponent 2
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, sBattleOutcomeTexts[((const u8 *)a0)[4]]);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_MultiBattleWithPeopleResultedInOutcome);
+ a0 += 13;
+ return a0;
+}
+
+static u16 *BufferQuestLogData_UsedUnionRoom(u16 *a0, const u16 *eventData)
+{
+ a0[0] = QL_EVENT_USED_UNION_ROOM;
+ a0[1] = sQuestLogCursor;
+ return a0 + 2;
+}
+
+static const u16 *BufferQuestLogText_UsedUnionRoom(const u16 *a0)
+{
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_MingledInUnionRoom);
+ a0 += 2;
+ return a0;
+}
+
+static u16 *BufferQuestLogData_UsedUnionRoomChat(u16 *a0, const u16 *eventData)
+{
+ a0[0] = QL_EVENT_USED_UNION_ROOM_CHAT;
+ a0[1] = sQuestLogCursor;
+ return a0 + 2;
+}
+
+static const u16 *BufferQuestLogText_UsedUnionRoomChat(const u16 *a0)
+{
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_ChattedWithManyTrainers);
+ a0 += 2;
+ return a0;
+}
+
+static u16 *BufferQuestLogData_LinkTradedUnionRoom(u16 *a0, const u16 *eventData)
+{
+ u8 *r4 = (u8 *)(a0 + 4);
+ a0[0] = QL_EVENT_LINK_TRADED_UNION;
+ a0[1] = sQuestLogCursor;
+ a0[2] = eventData[0];
+ a0[3] = eventData[1];
+ memcpy(r4, eventData + 2, PLAYER_NAME_LENGTH);
+ r4 += 8;
+ return (u16 *)r4;
+}
+
+static const u16 *BufferQuestLogText_LinkTradedUnionRoom(const u16 *a0)
+{
+ const u8 *r6 = (const u8 *)(a0 + 4);
+ memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
+ memcpy(gStringVar1, r6, PLAYER_NAME_LENGTH);
+ BufferLinkPartnersName(gStringVar1);
+ QuestLog_GetSpeciesName(a0[3], gStringVar2, 0);
+ QuestLog_GetSpeciesName(a0[2], gStringVar3, 0);
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_TradedMon1ForTrainersMon2);
+ r6 += 8;
+ return (const u16 *)r6;
+}
+
+static u16 *BufferQuestLogData_LinkBattledUnionRoom(u16 *a0, const u16 *eventData)
+{
+ a0[0] = QL_EVENT_LINK_BATTLED_UNION;
+ a0[1] = sQuestLogCursor;
+ *(u8 *)&a0[2] = *(const u8 *)&eventData[0];
+ memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH);
+ a0 += 6;
+ return a0;
+}
+
+static const u16 *BufferQuestLogText_LinkBattledUnionRoom(const u16 *a0)
+{
+ memset(gStringVar1, EOS, PLAYER_NAME_LENGTH + 1);
+ memcpy(gStringVar1, (const u8 *)a0 + 5, PLAYER_NAME_LENGTH);
+ BufferLinkPartnersName(gStringVar1);
+ StringCopy(gStringVar2, sBattleOutcomeTexts[*(const u8 *)&a0[2]]);
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_BattledTrainerEndedInOutcome);
+ a0 += 6;
+ return a0;
+}
+
+static u16 *BufferQuestLogData_SwitchedMonsBetweenBoxes(u16 *a0, const u16 *eventData)
+{
+ a0 = sub_8113DE0(QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[0];
+ a0[1] = eventData[1];
+ *((u8 *)a0 + 4) = *((const u8 *)eventData + 4);
+ *((u8 *)a0 + 5) = *((const u8 *)eventData + 5);
+ return a0 + 3;
+}
+
+static const u16 *BufferQuestLogText_SwitchedMonsBetweenBoxes(const u16 *eventData)
+{
+ const u8 *boxIdxs;
+ eventData = sub_8113E88(QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES, eventData);
+ boxIdxs = (const u8 *)eventData + 4;
+ DynamicPlaceholderTextUtil_Reset();
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
+ QuestLog_GetSpeciesName(eventData[0], NULL, 1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, GetBoxNamePtr(boxIdxs[1]));
+ QuestLog_GetSpeciesName(eventData[1], NULL, 3);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchedMonsBetweenBoxes);
+ return eventData + 3;
+}
+
+static u16 *BufferQuestLogData_SwitchedMonsWithinBox(u16 *a0, const u16 *eventData)
+{
+ a0 = sub_8113DE0(QL_EVENT_SWITCHED_MONS_WITHIN_BOX, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[0];
+ a0[1] = eventData[1];
+ *((u8 *)a0 + 4) = *((const u8 *)eventData + 4);
+ return a0 + 3;
+}
+
+static const u16 *BufferQuestLogText_SwitchedMonsWithinBox(const u16 *eventData)
+{
+ const u8 *boxIdxs;
+ eventData = sub_8113E88(QL_EVENT_SWITCHED_MONS_WITHIN_BOX, eventData);
+ boxIdxs = (const u8 *)eventData + 4;
+ DynamicPlaceholderTextUtil_Reset();
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
+ QuestLog_GetSpeciesName(eventData[0], NULL, 1);
+ QuestLog_GetSpeciesName(eventData[1], NULL, 2);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchedMonsWithinBox);
+ return eventData + 3;
+}
+
+static u16 *BufferQuestLogData_SwitchedPartyMonForPCMon(u16 *a0, const u16 *eventData)
+{
+ u16 *r2;
+ u16 *ret;
+ r2 = sub_8113DE0(QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON, a0);
+ if (r2 == NULL)
+ return NULL;
+ ret = r2 + 2;
+ if (*((const u8 *)eventData + 4) == TOTAL_BOXES_COUNT)
+ {
+ r2[0] = eventData[1];
+ r2[1] = eventData[0];
+ *((u8 *)r2 + 4) = *((const u8 *)eventData + 5);
+ }
+ else
+ {
+ r2[0] = eventData[0];
+ r2[1] = eventData[1];
+ *((u8 *)r2 + 4) = *((const u8 *)eventData + 4);
+ }
+ return ret + 1;
+}
+
+static const u16 *BufferQuestLogText_SwitchedPartyMonForPCMon(const u16 *eventData)
+{
+ const u8 *boxIdxs;
+ eventData = sub_8113E88(QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON, eventData);
+ boxIdxs = (const u8 *)eventData + 4;
+ DynamicPlaceholderTextUtil_Reset();
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
+ QuestLog_GetSpeciesName(eventData[0], NULL, 1);
+ QuestLog_GetSpeciesName(eventData[1], NULL, 2);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchedPartyMonForPCMon);
+ return eventData + 3;
+}
+
+static u16 *BufferQuestLogData_MovedMonBetweenBoxes(u16 *a0, const u16 *eventData)
+{
+ u16 *r2;
+ u16 *ret;
+ r2 = sub_8113DE0(QL_EVENT_MOVED_MON_BETWEEN_BOXES, a0);
+ if (r2 == NULL)
+ return NULL;
+ r2[0] = eventData[0];
+ ret = r2 + 1;
+ *((u8 *)ret + 0) = *((const u8 *)eventData + 4);
+ *((u8 *)ret + 1) = *((const u8 *)eventData + 5);
+ return ret + 1;
+}
+
+static const u16 *BufferQuestLogText_MovedMonBetweenBoxes(const u16 *eventData)
+{
+ const u8 *boxIdxs;
+ eventData = sub_8113E88(QL_EVENT_MOVED_MON_BETWEEN_BOXES, eventData);
+ boxIdxs = (const u8 *)eventData + 2;
+ DynamicPlaceholderTextUtil_Reset();
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
+ QuestLog_GetSpeciesName(eventData[0], NULL, 1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, GetBoxNamePtr(boxIdxs[1]));
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_MovedMonToNewBox);
+ return (const u16 *)boxIdxs + 1;
+}
+
+static u16 *BufferQuestLogData_MovedMonWithinBox(u16 *a0, const u16 *eventData)
+{
+ u16 *r2;
+ r2 = sub_8113DE0(QL_EVENT_MOVED_MON_WITHIN_BOX, a0);
+ if (r2 == NULL)
+ return NULL;
+ r2[0] = eventData[0];
+ *((u8 *)r2 + 2) = *((const u8 *)eventData + 4);
+ return r2 + 2;
+}
+
+static const u16 *BufferQuestLogText_MovedMonWithinBox(const u16 *eventData)
+{
+ const u8 *boxIdxs;
+ eventData = sub_8113E88(QL_EVENT_MOVED_MON_WITHIN_BOX, eventData);
+ boxIdxs = (const u8 *)eventData + 2;
+ DynamicPlaceholderTextUtil_Reset();
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
+ QuestLog_GetSpeciesName(eventData[0], NULL, 1);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_MovedMonWithinBox);
+ return (const u16 *)boxIdxs + 1;
+}
+
+static u16 *BufferQuestLogData_WithdrewMonFromPC(u16 *a0, const u16 *eventData)
+{
+ u16 *r2;
+ r2 = sub_8113DE0(QL_EVENT_WITHDREW_MON_PC, a0);
+ if (r2 == NULL)
+ return NULL;
+ r2[0] = eventData[0];
+ *((u8 *)r2 + 2) = *((const u8 *)eventData + 4);
+ return r2 + 2;
+}
+
+static const u16 *BufferQuestLogText_WithdrewMonFromPC(const u16 *eventData)
+{
+ const u8 *boxIdxs;
+ eventData = sub_8113E88(QL_EVENT_WITHDREW_MON_PC, eventData);
+ boxIdxs = (const u8 *)eventData + 2;
+ DynamicPlaceholderTextUtil_Reset();
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(boxIdxs[0]));
+ QuestLog_GetSpeciesName(eventData[0], NULL, 1);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_WithdrewMonFromPC);
+ return (const u16 *)boxIdxs + 1;
+}
+
+static u16 *BufferQuestLogData_DepositedMonInPC(u16 *a0, const u16 *eventData)
+{
+ u16 *r2;
+ r2 = sub_8113DE0(QL_EVENT_DEPOSITED_MON_PC, a0);
+ if (r2 == NULL)
+ return NULL;
+ r2[0] = eventData[0];
+ *((u8 *)r2 + 2) = *((const u8 *)eventData + 4);
+ return r2 + 2;
+}
+
+static const u16 *BufferQuestLogText_DepositedMonInPC(const u16 *eventData)
+{
+ const u8 *boxIdxs;
+ eventData = sub_8113E88(QL_EVENT_DEPOSITED_MON_PC, eventData);
+ boxIdxs = (const u8 *)eventData + 2;
+ DynamicPlaceholderTextUtil_Reset();
+ QuestLog_GetSpeciesName(eventData[0], NULL, 0);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, GetBoxNamePtr(boxIdxs[0]));
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DepositedMonInPC);
+ return (const u16 *)boxIdxs + 1;
+}
+
+static u16 *BufferQuestLogData_SwitchedMultipleMons(u16 *a0, const u16 *eventData)
+{
+ u16 *r2;
+ r2 = sub_8113DE0(QL_EVENT_SWITCHED_MULTIPLE_MONS, a0);
+ if (r2 == NULL)
+ return NULL;
+ *((u8 *)r2 + 0) = *((const u8 *)eventData + 4);
+ *((u8 *)r2 + 1) = *((const u8 *)eventData + 5);
+ return r2 + 1;
+}
+
+static const u16 *BufferQuestLogText_SwitchedMultipleMons(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_SWITCHED_MULTIPLE_MONS, eventData);
+ DynamicPlaceholderTextUtil_Reset();
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, GetBoxNamePtr(*((const u8 *)r4 + 0)));
+ if (*((const u8 *)r4 + 0) == *((const u8 *)r4 + 1))
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gText_QuestLog_ADifferentSpot);
+ else
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, GetBoxNamePtr(*((const u8 *)r4 + 1)));
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SwitchedMultipleMons);
+ return r4 + 1;
+}
+
+static u16 *BufferQuestLogData_DepositedItemInPC(u16 *a0, const u16 *eventData)
+{
+ a0 = sub_8113DE0(QL_EVENT_DEPOSITED_ITEM_PC, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[0];
+ return a0 + 1;
+}
+
+static const u16 *BufferQuestLogText_DepositedItemInPC(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_DEPOSITED_ITEM_PC, eventData);
+ CopyItemName(r4[0], gStringVar1);
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_StoredItemInPC);
+ return r4 + 1;
+}
+
+static u16 *BufferQuestLogData_WithdrewItemFromPC(u16 *a0, const u16 *eventData)
+{
+ a0 = sub_8113DE0(QL_EVENT_WITHDREW_ITEM_PC, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[0];
+ return a0 + 1;
+}
+
+static const u16 *BufferQuestLogText_WithdrewItemFromPC(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_WITHDREW_ITEM_PC, eventData);
+ CopyItemName(r4[0], gStringVar1);
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_WithdrewItemFromPC);
+ return r4 + 1;
+}
+
+u16 *BufferQuestLogData_DefeatedTrainer_(u16 eventId, u16 *a1, const u16 *a2)
+{
+ a1 = sub_8113DE0(eventId, a1);
+ if (a1 == NULL)
+ return NULL;
+ a1[0] = a2[1];
+ a1[1] = a2[2];
+ a1[2] = a2[0];
+ *((u8 *)a1 + 6) = *((const u8 *)a2 + 7);
+ *((u8 *)a1 + 7) = *((const u8 *)a2 + 6);
+ return a1 + 4;
+}
+
+static u16 *BufferQuestLogData_DefeatedGymLeader(u16 *a0, const u16 *eventData)
+{
+ sEventShouldNotRecordSteps = 1;
+ return BufferQuestLogData_DefeatedTrainer_(QL_EVENT_DEFEATED_GYM_LEADER, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_DefeatedGymLeader(const u16 *eventData)
+{
+ const u8 *r6;
+ eventData = sub_8113E88(QL_EVENT_DEFEATED_GYM_LEADER, eventData);
+ r6 = (const u8 *)eventData + 6;
+ DynamicPlaceholderTextUtil_Reset();
+ GetMapNameGeneric(gStringVar1, r6[0]);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gTrainers[eventData[2]].trainerName);
+ QuestLog_GetSpeciesName(eventData[0], 0, 2);
+ QuestLog_GetSpeciesName(eventData[1], 0, 3);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, sDefeatedOpponentFlavorTexts[r6[1]]);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_TookOnGymLeadersMonWithMonAndWon);
+ return eventData + 4;
+}
+
+static u16 *BufferQuestLogData_DefeatedWildMon(u16 *a0, const u16 *eventData)
+{
+ u16 *r4 = a0;
+ u8 *r5 = (u8 *)a0 + 8;
+ if (!sub_8110944(r4, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_WILD_MON]))
+ return NULL;
+ if (r5[0] == 0 && r5[1] == 0)
+ {
+ r4[0] = QL_EVENT_DEFEATED_WILD_MON;
+ r4[1] = sQuestLogCursor;
+ }
+ if (eventData[0])
+ r4[2] = eventData[0];
+ if (eventData[1])
+ r4[3] = eventData[1];
+ if (eventData[0] && r5[0] != 0xFF)
+ r5[0]++;
+ if (eventData[1] && r5[1] != 0xFF)
+ r5[1]++;
+ r5[2] = *((const u8 *)eventData + 4);
+ return (u16 *)(r5 + 4);
+}
+
+static const u16 *BufferQuestLogText_DefeatedWildMon(const u16 *a0)
+{
+ const u8 *data;
+ if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_WILD_MON]))
+ return NULL;
+
+ data = (const u8 *)a0 + 8;
+ DynamicPlaceholderTextUtil_Reset();
+ GetMapNameGeneric(gStringVar1, data[2]);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
+ QuestLog_GetSpeciesName(a0[2], NULL, 1);
+ ConvertIntToDecimalStringN(gStringVar2, data[0], STR_CONV_MODE_LEFT_ALIGN, 3);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar2);
+ QuestLog_GetSpeciesName(a0[3], NULL, 3);
+ ConvertIntToDecimalStringN(gStringVar3, data[1], STR_CONV_MODE_LEFT_ALIGN, 3);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, gStringVar3);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(5, gSaveBlock2Ptr->playerName);
+ if (data[0] == 0)
+ {
+ if (data[1] == 1)
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_CaughtWildMon);
+ else
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_CaughtWildMons);
+ }
+ else if (data[1] == 0)
+ {
+ if (data[0] == 1)
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMon);
+ else
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMons);
+ }
+ else if (data[0] == 1)
+ {
+ if (data[1] == 1)
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMonAndCaughtWildMon);
+ else
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMonAndCaughtWildMons);
+ }
+ else
+ {
+ if (data[1] == 1)
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMonsAndCaughtWildMon);
+ else
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_DefeatedWildMonsAndCaughtWildMons);
+ }
+ return (const u16 *)(data + 4);
+}
+
+static bool8 IsSpeciesFromSpecialEncounter(u16 species)
+{
+ switch (species)
+ {
+ case SPECIES_SNORLAX:
+ case SPECIES_ARTICUNO:
+ case SPECIES_ZAPDOS:
+ case SPECIES_MOLTRES:
+ case SPECIES_MEWTWO:
+ case SPECIES_LUGIA:
+ case SPECIES_HO_OH:
+ case SPECIES_DEOXYS:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static u16 *BufferQuestLogData_DefeatedEliteFourMember(u16 *a0, const u16 *eventData)
+{
+ sEventShouldNotRecordSteps = 1;
+ return BufferQuestLogData_DefeatedTrainer_(QL_EVENT_DEFEATED_E4_MEMBER, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_DefeatedEliteFourMember(const u16 *eventData)
+{
+ const u8 *r5;
+ eventData = sub_8113E88(QL_EVENT_DEFEATED_E4_MEMBER, eventData);
+ r5 = (const u8 *)eventData + 6;
+ DynamicPlaceholderTextUtil_Reset();
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gTrainers[eventData[2]].trainerName);
+ QuestLog_GetSpeciesName(eventData[0], NULL, 1);
+ QuestLog_GetSpeciesName(eventData[1], NULL, 2);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, sDefeatedOpponentFlavorTexts[r5[1]]);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_TookOnEliteFoursMonWithMonAndWon);
+ return eventData + 4;
+}
+
+static u16 *BufferQuestLogData_DefeatedChampion(u16 *a0, const u16 *eventData)
+{
+ if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_CHAMPION]))
+ return NULL;
+ a0[0] = QL_EVENT_DEFEATED_CHAMPION | (2 << 12);
+ a0[1] = sQuestLogCursor;
+ a0[2] = eventData[1];
+ a0[3] = eventData[2];
+ *((u8 *)a0 + 8) = *((const u8 *)eventData + 6);
+ sEventShouldNotRecordSteps = 1;
+ return a0 + 5;
+}
+
+static const u16 *BufferQuestLogText_DefeatedChampion(const u16 *a0)
+{
+ const u8 *r5;
+ if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_CHAMPION]))
+ return NULL;
+
+ r5 = (const u8 *)a0 + 8;
+ DynamicPlaceholderTextUtil_Reset();
+
+ switch (gUnknown_203B044.unk_2)
+ {
+ case 0:
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gSaveBlock1Ptr->rivalName);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_PlayerBattledChampionRival);
+ break;
+ case 1:
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock1Ptr->rivalName);
+ QuestLog_GetSpeciesName(a0[2], NULL, 1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gSaveBlock2Ptr->playerName);
+ QuestLog_GetSpeciesName(a0[3], NULL, 3);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_PlayerSentOutMon1RivalSentOutMon2);
+ break;
+ case 2:
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sDefeatedChampionFlavorTexts[r5[0]]);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_WonTheMatchAsAResult);
+ break;
+ }
+ return (const u16 *)(r5 + 2);
+}
+
+static u16 *BufferQuestLogData_DefeatedTrainer(u16 *a0, const u16 *eventData)
+{
+ sEventShouldNotRecordSteps = 1;
+ return BufferQuestLogData_DefeatedTrainer_(QL_EVENT_DEFEATED_TRAINER, a0, eventData);
+}
+
+static const u16 *BufferQuestLogText_DefeatedTrainer(const u16 *eventData)
+{
+ const u16 *r5 = sub_8113E88(QL_EVENT_DEFEATED_TRAINER, eventData);
+ const u8 *r6 = (const u8 *)r5 + 6;
+ DynamicPlaceholderTextUtil_Reset();
+ GetMapNameGeneric(gStringVar1, r6[0]);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
+
+ if (gTrainers[r5[2]].trainerClass == CLASS_RIVAL
+ || gTrainers[r5[2]].trainerClass == CLASS_RIVAL_2
+ || gTrainers[r5[2]].trainerClass == CLASS_CHAMPION_2)
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, GetExpandedPlaceholder(PLACEHOLDER_ID_RIVAL));
+ else
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gTrainers[r5[2]].trainerName);
+
+ QuestLog_GetSpeciesName(r5[0], NULL, 2);
+ QuestLog_GetSpeciesName(r5[1], NULL, 3);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, sDefeatedOpponentFlavorTexts[r6[1]]);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_TookOnTrainersMonWithMonAndWon);
+ return (const u16 *)(r6 + 2);
+}
+
+static const u8 *const sLocationNameTexts[] =
+ {
+ [QL_LOCATION_HOME] = gText_QuestLog_Home,
+ [QL_LOCATION_OAKS_LAB] = gText_QuestLog_OakResearchLab,
+ [QL_LOCATION_VIRIDIAN_GYM] = gText_QuestLog_Gym,
+ [QL_LOCATION_LEAGUE_GATE_1] = gText_QuestLog_PokemonLeagueGate,
+ [QL_LOCATION_LEAGUE_GATE_2] = gText_QuestLog_PokemonLeagueGate,
+ [QL_LOCATION_VIRIDIAN_FOREST_1] = gText_QuestLog_ViridianForest,
+ [QL_LOCATION_VIRIDIAN_FOREST_2] = gText_QuestLog_ViridianForest,
+ [QL_LOCATION_PEWTER_MUSEUM] = gText_QuestLog_PewterMuseumOfScience,
+ [QL_LOCATION_PEWTER_GYM] = gText_QuestLog_Gym,
+ [QL_LOCATION_MT_MOON_1] = gText_QuestLog_MtMoon,
+ [QL_LOCATION_MT_MOON_2] = gText_QuestLog_MtMoon,
+ [QL_LOCATION_CERULEAN_GYM] = gText_QuestLog_Gym,
+ [QL_LOCATION_BIKE_SHOP] = gText_QuestLog_BikeShop,
+ [QL_LOCATION_BILLS_HOUSE] = gText_QuestLog_BillsHouse,
+ [QL_LOCATION_DAY_CARE] = gText_QuestLog_DayCare,
+ [QL_LOCATION_UNDERGROUND_PATH_1] = gText_QuestLog_UndergroundPath,
+ [QL_LOCATION_UNDERGROUND_PATH_2] = gText_QuestLog_UndergroundPath,
+ [QL_LOCATION_PKMN_FAN_CLUB] = gText_QuestLog_PokemonFanClub,
+ [QL_LOCATION_VERMILION_GYM] = gText_QuestLog_Gym,
+ [QL_LOCATION_SS_ANNE] = gText_QuestLog_SSAnne,
+ [QL_LOCATION_DIGLETTS_CAVE_1] = gText_QuestLog_DiglettsCave,
+ [QL_LOCATION_DIGLETTS_CAVE_2] = gText_QuestLog_DiglettsCave,
+ [QL_LOCATION_ROCK_TUNNEL_1] = gText_QuestLog_RockTunnel,
+ [QL_LOCATION_ROCK_TUNNEL_2] = gText_QuestLog_RockTunnel,
+ [QL_LOCATION_POWER_PLANT] = gText_QuestLog_PowerPlant,
+ [QL_LOCATION_PKMN_TOWER] = gText_QuestLog_PokemonTower,
+ [QL_LOCATION_VOLUNTEER_HOUSE] = gText_QuestLog_VolunteerHouse,
+ [QL_LOCATION_NAME_RATERS_HOUSE] = gText_QuestLog_NameRatersHouse,
+ [QL_LOCATION_UNDERGROUND_PATH_3] = gText_QuestLog_UndergroundPath,
+ [QL_LOCATION_UNDERGROUND_PATH_4] = gText_QuestLog_UndergroundPath,
+ [QL_LOCATION_CELADON_DEPT_STORE] = gText_QuestLog_CeladonDeptStore,
+ [QL_LOCATION_CELADON_MANSION] = gText_QuestLog_CeladonMansion,
+ [QL_LOCATION_GAME_CORNER] = gText_QuestLog_RocketGameCorner,
+ [QL_LOCATION_CELADON_GYM] = gText_QuestLog_Gym,
+ [QL_LOCATION_CELADON_RESTAURANT] = gText_QuestLog_Restaurant,
+ [QL_LOCATION_ROCKET_HIDEOUT] = gText_QuestLog_RocketHideout,
+ [QL_LOCATION_SAFARI_ZONE] = gText_QuestLog_SafariZone,
+ [QL_LOCATION_FUCHSIA_GYM] = gText_QuestLog_Gym,
+ [QL_LOCATION_WARDENS_HOME] = gText_QuestLog_WardensHome,
+ [QL_LOCATION_FIGHTING_DOJO] = gText_QuestLog_FightingDojo,
+ [QL_LOCATION_SAFFRON_GYM] = gText_QuestLog_Gym,
+ [QL_LOCATION_SILPH_CO] = gText_QuestLog_SilphCo,
+ [QL_LOCATION_SEAFOAM_ISLANDS_1] = gText_QuestLog_SeafoamIslands,
+ [QL_LOCATION_SEAFOAM_ISLANDS_2] = gText_QuestLog_SeafoamIslands,
+ [QL_LOCATION_PKMN_MANSION] = gText_QuestLog_PokemonMansion,
+ [QL_LOCATION_CINNABAR_GYM] = gText_QuestLog_Gym,
+ [QL_LOCATION_CINNABAR_LAB] = gText_QuestLog_PokemonResearchLab,
+ [QL_LOCATION_VICTORY_ROAD_1] = gText_QuestLog_VictoryRoad,
+ [QL_LOCATION_VICTORY_ROAD_2] = gText_QuestLog_VictoryRoad,
+ [QL_LOCATION_PKMN_LEAGUE] = gText_QuestLog_PokemonLeague,
+ [QL_LOCATION_CERULEAN_CAVE] = gText_QuestLog_CeruleanCave
+ };
+
+static const u8 *const sDepartedLocationTexts[] =
+ {
+ [QL_DEPARTED_TOWN_BUILDING] = gText_QuestLog_DepartedPlaceInTownForNextDestination,
+ [QL_DEPARTED_MUSEUM] = gText_QuestLog_LeftTownsLocationForNextDestination,
+ [QL_DEPARTED_GAME_CORNER] = gText_QuestLog_PlayedGamesAtGameCorner,
+ [QL_DEPARTED_HOME] = gText_QuestLog_RestedAtHome,
+ [QL_DEPARTED_OAKS_LAB] = gText_QuestLog_LeftOaksLab,
+ [QL_DEPARTED_GYM] = gText_QuestLog_GymWasFullOfToughTrainers,
+ [QL_DEPARTED_SAFARI_ZONE] = gText_QuestLog_HadGreatTimeInSafariZone,
+ [QL_DEPARTED_CAVE] = gText_QuestLog_ManagedToGetOutOfLocation,
+ [QL_DEPARTED_MISC_BUILDING_1] = gText_QuestLog_DepartedTheLocationForNextDestination,
+ [QL_DEPARTED_MISC_BUILDING_2] = gText_QuestLog_DepartedFromLocationToNextDestination
+ };
+
+static const u8 sLocationToDepartedTextId[] =
+ {
+ [QL_LOCATION_HOME] = QL_DEPARTED_HOME,
+ [QL_LOCATION_OAKS_LAB] = QL_DEPARTED_OAKS_LAB,
+ [QL_LOCATION_VIRIDIAN_GYM] = QL_DEPARTED_GYM,
+ [QL_LOCATION_LEAGUE_GATE_1] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_LEAGUE_GATE_2] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_VIRIDIAN_FOREST_1] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_VIRIDIAN_FOREST_2] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_PEWTER_MUSEUM] = QL_DEPARTED_MUSEUM,
+ [QL_LOCATION_PEWTER_GYM] = QL_DEPARTED_GYM,
+ [QL_LOCATION_MT_MOON_1] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_MT_MOON_2] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_CERULEAN_GYM] = QL_DEPARTED_GYM,
+ [QL_LOCATION_BIKE_SHOP] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_BILLS_HOUSE] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_DAY_CARE] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_UNDERGROUND_PATH_1] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_UNDERGROUND_PATH_2] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_PKMN_FAN_CLUB] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_VERMILION_GYM] = QL_DEPARTED_GYM,
+ [QL_LOCATION_SS_ANNE] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_DIGLETTS_CAVE_1] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_DIGLETTS_CAVE_2] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_ROCK_TUNNEL_1] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_ROCK_TUNNEL_2] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_POWER_PLANT] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_PKMN_TOWER] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_VOLUNTEER_HOUSE] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_NAME_RATERS_HOUSE] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_UNDERGROUND_PATH_3] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_UNDERGROUND_PATH_4] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_CELADON_DEPT_STORE] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_CELADON_MANSION] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_GAME_CORNER] = QL_DEPARTED_GAME_CORNER,
+ [QL_LOCATION_CELADON_GYM] = QL_DEPARTED_GYM,
+ [QL_LOCATION_CELADON_RESTAURANT] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_ROCKET_HIDEOUT] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_SAFARI_ZONE] = QL_DEPARTED_SAFARI_ZONE,
+ [QL_LOCATION_FUCHSIA_GYM] = QL_DEPARTED_GYM,
+ [QL_LOCATION_WARDENS_HOME] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_FIGHTING_DOJO] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_SAFFRON_GYM] = QL_DEPARTED_GYM,
+ [QL_LOCATION_SILPH_CO] = QL_DEPARTED_MISC_BUILDING_2,
+ [QL_LOCATION_SEAFOAM_ISLANDS_1] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_SEAFOAM_ISLANDS_2] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_PKMN_MANSION] = QL_DEPARTED_MISC_BUILDING_2,
+ [QL_LOCATION_CINNABAR_GYM] = QL_DEPARTED_GYM,
+ [QL_LOCATION_CINNABAR_LAB] = QL_DEPARTED_TOWN_BUILDING,
+ [QL_LOCATION_VICTORY_ROAD_1] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_VICTORY_ROAD_2] = QL_DEPARTED_CAVE,
+ [QL_LOCATION_PKMN_LEAGUE] = QL_DEPARTED_MISC_BUILDING_1,
+ [QL_LOCATION_CERULEAN_CAVE] = QL_DEPARTED_CAVE
+ };
+
+static const u8 sGymCityMapSecs[] = {
+ MAPSEC_PEWTER_CITY,
+ MAPSEC_CERULEAN_CITY,
+ MAPSEC_VERMILION_CITY,
+ MAPSEC_CELADON_CITY,
+ MAPSEC_FUCHSIA_CITY,
+ MAPSEC_SAFFRON_CITY,
+ MAPSEC_CINNABAR_ISLAND,
+ MAPSEC_VIRIDIAN_CITY
+};
+
+static const u8 *const sUsedFieldMoveTexts[] =
+ {
+ [FIELD_MOVE_FLASH] = gText_QuestLog_UsedFlash,
+ [FIELD_MOVE_CUT] = gText_QuestLog_UsedCut,
+ [FIELD_MOVE_FLY] = gText_QuestLog_UsedFly,
+ [FIELD_MOVE_STRENGTH] = gText_QuestLog_UsedStrength,
+ [FIELD_MOVE_SURF] = gText_QuestLog_UsedSurf,
+ [FIELD_MOVE_ROCK_SMASH] = gText_QuestLog_UsedRockSmash,
+ [FIELD_MOVE_WATERFALL] = gText_QuestLog_UsedWaterfall,
+ [FIELD_MOVE_TELEPORT] = gText_QuestLog_UsedTeleportToLocation,
+ [FIELD_MOVE_DIG] = gText_QuestLog_UsedDigInLocation,
+ [FIELD_MOVE_MILK_DRINK] = gText_QuestLog_UsedMilkDrink,
+ [FIELD_MOVE_SOFT_BOILED] = gText_QuestLog_UsedSoftboiled,
+ [FIELD_MOVE_SWEET_SCENT] = gText_QuestLog_UsedSweetScent
+ };
+
+static u16 *BufferQuestLogData_DepartedLocation(u16 *a0, const u16 *eventData)
+{
+ u16 *r2 = sub_8113DE0(QL_EVENT_DEPARTED, a0);
+ if (r2 == NULL)
+ return NULL;
+ *((u8 *)r2 + 0) = *((const u8 *)eventData + 0);
+ if ((*((u8 *)r2 + 1) = *((const u8 *)eventData + 1)) == QL_LOCATION_SAFARI_ZONE)
+ sEventShouldNotRecordSteps = 1;
+ return r2 + 1;
+}
+
+static const u16 *BufferQuestLogText_DepartedLocation(const u16 *eventData)
+{
+ u8 r4, locationId;
+ const u16 *r5 = sub_8113E88(QL_EVENT_DEPARTED, eventData);
+ const u8 *r5_2 = (const u8 *)r5 + 0;
+ locationId = r5_2[1];
+ GetMapNameGeneric(gStringVar1, r5_2[0]);
+ StringCopy(gStringVar2, sLocationNameTexts[locationId]);
+ if (sLocationToDepartedTextId[locationId] == QL_DEPARTED_GYM)
+ {
+ for (r4 = 0; r4 < NELEMS(sGymCityMapSecs); r4++)
+ {
+ if (r5_2[0] != sGymCityMapSecs[r4])
+ continue;
+ if (FlagGet(FLAG_BADGE01_GET + r4) == TRUE)
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_DepartedGym);
+ else
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_GymWasFullOfToughTrainers);
+ break;
+ }
+ if (r4 == 8)
+ StringExpandPlaceholders(gStringVar4, sDepartedLocationTexts[sLocationToDepartedTextId[locationId]]);
+ }
+ else
+ StringExpandPlaceholders(gStringVar4, sDepartedLocationTexts[sLocationToDepartedTextId[locationId]]);
+
+ return (const u16 *)(r5_2 + 2);
+}
+
+void SetQLPlayedTheSlots(void)
+{
+ sPlayedTheSlots = TRUE;
+}
+
+static bool8 ShouldRegisterEvent_HandleDeparted(u16 eventId, const u16 *eventData)
+{
+ if (eventId != QL_EVENT_DEPARTED)
+ {
+ sLastDepartedMap = 0;
+ return TRUE;
+ }
+ if (sLastDepartedMap == *((u8 *)eventData + 1) + 1)
+ return FALSE;
+ sLastDepartedMap = *((u8 *)eventData + 1) + 1;
+ return TRUE;
+}
+
+static bool8 ShouldRegisterEvent_HandleGameCorner(u16 eventId, const u16 *eventData)
+{
+ if (eventId != QL_EVENT_DEPARTED)
+ return TRUE;
+
+ // Bug: should be QL_LOCATION_GAME_CORNER + 1
+ if (*((u8 *)eventData + 1) == QL_LOCATION_GAME_CORNER && !sPlayedTheSlots)
+ return FALSE;
+
+ sPlayedTheSlots = FALSE;
+ return TRUE;
+}
+
+static u16 *BufferQuestLogData_UsedFieldMove(u16 *a0, const u16 *eventData)
+{
+ u8 *r3;
+ a0 = sub_8113DE0(QL_EVENT_USED_FIELD_MOVE, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[0];
+ r3 = (u8 *)a0 + 2;
+ r3[0] = *((const u8 *)eventData + 2);
+ r3[1] = *((const u8 *)eventData + 3);
+ if (r3[0] == FIELD_MOVE_TELEPORT || r3[0] == FIELD_MOVE_DIG)
+ sEventShouldNotRecordSteps = 2;
+ else
+ sEventShouldNotRecordSteps = 1;
+ return (u16 *)(r3 + 2);
+}
+
+static const u16 *BufferQuestLogText_UsedFieldMove(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_USED_FIELD_MOVE, eventData);
+ const u8 *r5 = (const u8 *)r4 + 2;
+ QuestLog_GetSpeciesName(r4[0], gStringVar1, 0);
+ if (r5[1] != 0xFF)
+ GetMapNameGeneric(gStringVar2, r5[1]);
+
+ // If used Teleport, get name of destination
+ if (r5[0] == FIELD_MOVE_TELEPORT)
+ {
+ if (r5[1] == 0x58)
+ StringCopy(gStringVar3, gText_QuestLog_Home);
+ else
+ StringCopy(gStringVar3, gText_PokemonCenter);
+ }
+
+ StringExpandPlaceholders(gStringVar4, sUsedFieldMoveTexts[r5[0]]);
+ return (const u16 *)(r5 + 2);
+}
+
+static u16 *BufferQuestLogData_BoughtItem(u16 *a0, const u16 *eventData)
+{
+ a0 = sub_8113DE0(QL_EVENT_BOUGHT_ITEM, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[2];
+ a0[1] = eventData[3];
+ a0[2] = *((const u32 *)eventData) >> 16;
+ a0[3] = *((const u32 *)eventData);
+ *((u8 *)a0 + 8) = *((const u8 *)eventData + 8);
+ *((u8 *)a0 + 9) = 1;
+ return a0 + 5;
+}
+
+static const u16 *BufferQuestLogText_BoughtItem(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_BOUGHT_ITEM, eventData);
+ const u8 *r7 = (const u8 *)r4 + 8;
+ u32 r6 = (r4[2] << 16) + r4[3];
+ DynamicPlaceholderTextUtil_Reset();
+ GetMapNameGeneric(gStringVar1, r7[0]);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, ItemId_GetName(r4[0]));
+ if (r4[1] < 2)
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_BoughtItem);
+ else
+ {
+ ConvertIntToDecimalStringN(gStringVar2, r6, STR_CONV_MODE_LEFT_ALIGN, 6);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar2);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_BoughtItemsIncludingItem);
+ }
+ return (const u16 *)(r7 + 2);
+}
+
+static u16 *BufferQuestLogData_SoldItem(u16 *a0, const u16 *eventData)
+{
+ a0 = sub_8113DE0(QL_EVENT_SOLD_ITEM, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[2];
+ a0[1] = eventData[3];
+ a0[2] = *((const u32 *)eventData) >> 16;
+ a0[3] = *((const u32 *)eventData);
+ *((u8 *)a0 + 8) = *((const u8 *)eventData + 8);
+ *((u8 *)a0 + 9) = *((const u8 *)eventData + 9);
+ return a0 + 5;
+}
+
+static const u16 *BufferQuestLogText_SoldItem(const u16 *eventData)
+{
+ const u16 *r5 = sub_8113E88(QL_EVENT_SOLD_ITEM, eventData);
+ const u8 *r7 = (const u8 *) r5 + 8;
+ u32 r6 = (r5[2] << 16) + r5[3];
+ DynamicPlaceholderTextUtil_Reset();
+ GetMapNameGeneric(gStringVar1, r7[0]);
+ if (r7[1] == 0) {
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gStringVar1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, ItemId_GetName(r5[0]));
+ if (r5[1] == 1)
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, gText_QuestLog_JustOne);
+ else
+ {
+ ConvertIntToDecimalStringN(gStringVar2, r5[1], STR_CONV_MODE_LEFT_ALIGN, 3);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, gStringVar2);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar3, gText_QuestLog_Num);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, gStringVar3);
+ }
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SoldNumOfItem);
+ }
+ else
+ {
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, ItemId_GetName(r5[0]));
+ ConvertIntToDecimalStringN(gStringVar2, r6, STR_CONV_MODE_LEFT_ALIGN, 6);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar2);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_QuestLog_SoldItemsIncludingItem);
+ }
+ return (const u16 *)(r7 + 2);
+}
+
+static u16 *BufferQuestLogData_ObtainedItem(u16 *a0, const u16 *eventData)
+{
+ a0 = sub_8113DE0(QL_EVENT_OBTAINED_ITEM, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[0];
+ *((u8 *)a0 + 2) = *((const u8 *)eventData + 2);
+ return a0 + 2;
+}
+
+static const u16 *BufferQuestLogText_ObtainedItem(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_OBTAINED_ITEM, eventData);
+ const u8 *r5 = (const u8 *)r4 + 2;
+ GetMapNameGeneric(gStringVar1, r5[0]);
+ StringCopy(gStringVar2, ItemId_GetName(r4[0]));
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_ObtainedItemInLocation);
+ return (const u16 *)(r5 + 2);
+}
+
+static const u16 sQuestLogWorldMapFlags[] =
+ {
+ FLAG_WORLD_MAP_VIRIDIAN_CITY,
+ FLAG_WORLD_MAP_PEWTER_CITY,
+ FLAG_WORLD_MAP_CERULEAN_CITY,
+ FLAG_WORLD_MAP_LAVENDER_TOWN,
+ FLAG_WORLD_MAP_VERMILION_CITY,
+ FLAG_WORLD_MAP_CELADON_CITY,
+ FLAG_WORLD_MAP_FUCHSIA_CITY,
+ FLAG_WORLD_MAP_CINNABAR_ISLAND,
+ FLAG_WORLD_MAP_INDIGO_PLATEAU_EXTERIOR,
+ FLAG_WORLD_MAP_SAFFRON_CITY,
+ FLAG_WORLD_MAP_ONE_ISLAND,
+ FLAG_WORLD_MAP_TWO_ISLAND,
+ FLAG_WORLD_MAP_THREE_ISLAND,
+ FLAG_WORLD_MAP_FOUR_ISLAND,
+ FLAG_WORLD_MAP_FIVE_ISLAND,
+ FLAG_WORLD_MAP_SEVEN_ISLAND,
+ FLAG_WORLD_MAP_SIX_ISLAND
+ };
+
+void QuestLog_RecordEnteredMap(u16 worldMapFlag)
+{
+ s32 i;
+
+ if (QL_IS_PLAYBACK_STATE)
+ return;
+
+ for (i = 0; i < (int)NELEMS(sQuestLogWorldMapFlags); i++)
+ {
+ if (worldMapFlag == sQuestLogWorldMapFlags[i])
+ {
+ if (!FlagGet(worldMapFlag))
+ {
+ sNewlyEnteredMap = TRUE;
+ break;
+ }
+ else
+ {
+ sNewlyEnteredMap += 0;
+ sNewlyEnteredMap = FALSE;
+ break;
+ }
+ }
+ }
+}
+
+void sub_8115798(void)
+{
+ u16 sp0;
+ if (!QL_IS_PLAYBACK_STATE)
+ {
+ if (sNewlyEnteredMap)
+ {
+ sp0 = gMapHeader.regionMapSectionId;
+ SetQuestLogEvent(QL_EVENT_ARRIVED, &sp0);
+ sNewlyEnteredMap = FALSE;
+ }
+ }
+}
+
+static u16 *BufferQuestLogData_ArrivedInLocation(u16 *a0, const u16 *eventData)
+{
+ a0 = sub_8113DE0(QL_EVENT_ARRIVED, a0);
+ if (a0 == NULL)
+ return NULL;
+ a0[0] = eventData[0];
+ return a0 + 1;
+}
+
+static const u16 *BufferQuestLogText_ArrivedInLocation(const u16 *eventData)
+{
+ const u16 *r4 = sub_8113E88(QL_EVENT_ARRIVED, eventData);
+ GetMapNameGeneric(gStringVar1, (u8)r4[0]);
+ StringExpandPlaceholders(gStringVar4, gText_QuestLog_ArrivedInLocation);
+ return r4 + 1;
+}
+
+static void BufferLinkPartnersName(u8 *dest)
+{
+ s32 i;
+ if (*dest++ == EXT_CTRL_CODE_BEGIN && *dest++ == EXT_CTRL_CODE_JPN)
+ {
+ for (i = 0; i < 5; i++)
+ {
+ if (*dest == EXT_CTRL_CODE_BEGIN)
+ break;
+ dest++;
+ }
+ *dest++ = EXT_CTRL_CODE_BEGIN;
+ *dest++ = EXT_CTRL_CODE_ENG;
+ *dest++ = EOS;
+ }
+}
diff --git a/src/quest_log_objects.c b/src/quest_log_objects.c
index 64b4b7fe5..fa3bbcce5 100644
--- a/src/quest_log_objects.c
+++ b/src/quest_log_objects.c
@@ -131,7 +131,7 @@ void SetSav1ObjectEventsFromQuestLog(const struct QuestLog * questLog, const str
void sub_815A540(void)
{
- if (gQuestLogState == QL_STATE_2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
{
s16 x, y;
@@ -139,7 +139,7 @@ void sub_815A540(void)
if (!MetatileBehavior_IsSurfable(MapGridGetMetatileBehaviorAt(x, y)) && TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
{
struct ObjectEvent * objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
- SetPlayerAvatarTransitionFlags(0x01);
+ SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
DestroySprite(&gSprites[objectEvent->fieldEffectSpriteId]);
}
}
diff --git a/src/quest_log_player.c b/src/quest_log_player.c
index 8abf7fab5..715061963 100644
--- a/src/quest_log_player.c
+++ b/src/quest_log_player.c
@@ -41,7 +41,7 @@ void sub_8150454(u8 a0)
bool32 sub_8150474(u8 a0)
{
- if (gUnknown_3005E88 == 2)
+ if (gQuestLogPlaybackState == 2)
{
sub_8112720(a0);
return TRUE;
@@ -76,7 +76,7 @@ static void sub_8150530(void)
struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
struct Sprite *sprite = &gSprites[objectEvent->spriteId];
- if (gUnknown_3005E88 == 1 || gUnknown_3005E88 == 3)
+ if (gQuestLogPlaybackState == 1 || gQuestLogPlaybackState == 3)
{
u8 taskId;
ScriptContext2_Enable();
diff --git a/src/region_map.c b/src/region_map.c
index 33cf665d0..81bd4aca4 100644
--- a/src/region_map.c
+++ b/src/region_map.c
@@ -1,20 +1,15 @@
#include "global.h"
-#include "palette.h"
-#include "gpu_regs.h"
+#include "gflib.h"
#include "scanline_effect.h"
#include "task.h"
#include "m4a.h"
-#include "malloc.h"
#include "overworld.h"
#include "event_data.h"
#include "region_map.h"
-#include "window.h"
-#include "sound.h"
#include "party_menu.h"
#include "field_effect.h"
#include "new_menu_helpers.h"
#include "menu.h"
-#include "string_util.h"
#include "strings.h"
#include "map_preview_screen.h"
#include "constants/flags.h"
diff --git a/src/reset_save_heap.c b/src/reset_save_heap.c
index 7b9d30c06..20527fa85 100644
--- a/src/reset_save_heap.c
+++ b/src/reset_save_heap.c
@@ -1,12 +1,10 @@
#include "global.h"
-#include "main.h"
-#include "gpu_regs.h"
+#include "gflib.h"
#include "m4a.h"
#include "load_save.h"
#include "save.h"
#include "new_game.h"
#include "overworld.h"
-#include "malloc.h"
void ResetSaveHeap(void)
{
diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c
index 25470fc43..c65169710 100644
--- a/src/reshow_battle_screen.c
+++ b/src/reshow_battle_screen.c
@@ -1,12 +1,7 @@
#include "global.h"
-#include "bg.h"
-#include "palette.h"
-#include "pokemon.h"
-#include "main.h"
+#include "gflib.h"
#include "link.h"
#include "data.h"
-#include "sprite.h"
-#include "gpu_regs.h"
#include "scanline_effect.h"
#include "help_system.h"
#include "battle.h"
diff --git a/src/rock.c b/src/rock.c
index 3ec9cec04..a2d28d057 100644
--- a/src/rock.c
+++ b/src/rock.c
@@ -1,9 +1,7 @@
#include "global.h"
+#include "gflib.h"
#include "battle_anim.h"
-#include "gpu_regs.h"
#include "graphics.h"
-#include "palette.h"
-#include "sound.h"
#include "task.h"
#include "trig.h"
#include "constants/songs.h"
diff --git a/src/roulette_util.c b/src/roulette_util.c
index 3c5a3c825..9dab23342 100644
--- a/src/roulette_util.c
+++ b/src/roulette_util.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "palette.h"
+#include "gflib.h"
#include "roulette_util.h"
#include "util.h"
diff --git a/src/safari_zone.c b/src/safari_zone.c
index 29e436d35..748a7d996 100644
--- a/src/safari_zone.c
+++ b/src/safari_zone.c
@@ -67,7 +67,7 @@ void CB2_EndSafariBattle(void)
{
ScriptContext2_RunNewScript(SafariZone_EventScript_OutOfBallsMidBattle);
WarpIntoMap();
- gFieldCallback = sub_807E3EC;
+ gFieldCallback = FieldCB_SafariZoneRanOutOfBalls;
SetMainCallback2(CB2_LoadMap);
}
else if (gBattleOutcome == B_OUTCOME_CAUGHT)
diff --git a/src/save.c b/src/save.c
index 3db8dcdbf..3c192c098 100644
--- a/src/save.c
+++ b/src/save.c
@@ -1,7 +1,6 @@
#include "global.h"
#include "save.h"
#include "decompress.h"
-#include "main.h"
#include "overworld.h"
#include "load_save.h"
#include "task.h"
diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c
index 09e49a1bb..e71910485 100644
--- a/src/save_failed_screen.c
+++ b/src/save_failed_screen.c
@@ -1,13 +1,11 @@
#include "global.h"
+#include "gflib.h"
#include "decompress.h"
-#include "dma3.h"
#include "gba/flash_internal.h"
-#include "gpu_regs.h"
#include "help_system.h"
#include "m4a.h"
#include "save.h"
#include "strings.h"
-#include "text.h"
bool32 sIsInSaveFailedScreen;
diff --git a/src/save_menu_util.c b/src/save_menu_util.c
index 54073785e..5f5f1f492 100644
--- a/src/save_menu_util.c
+++ b/src/save_menu_util.c
@@ -1,6 +1,5 @@
#include "global.h"
-#include "string_util.h"
-#include "text.h"
+#include "gflib.h"
#include "event_data.h"
#include "pokedex.h"
#include "region_map.h"
diff --git a/src/scrcmd.c b/src/scrcmd.c
index bec0f4942..75761f0a3 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -1,6 +1,5 @@
#include "global.h"
-#include "gba/isagbprint.h"
-#include "palette.h"
+#include "gflib.h"
#include "script.h"
#include "mystery_event_script.h"
#include "event_data.h"
@@ -14,15 +13,12 @@
#include "field_tasks.h"
#include "field_fadetransition.h"
#include "field_player_avatar.h"
-#include "sound.h"
#include "script_movement.h"
#include "event_object_movement.h"
#include "event_object_lock.h"
#include "field_message_box.h"
#include "new_menu_helpers.h"
-#include "window.h"
#include "script_menu.h"
-#include "string_util.h"
#include "data.h"
#include "field_specials.h"
#include "constants/items.h"
@@ -37,24 +33,25 @@
#include "field_effect.h"
#include "fieldmap.h"
#include "field_door.h"
+#include "constants/event_objects.h"
extern u16 (*const gSpecials[])(void);
extern u16 (*const gSpecialsEnd[])(void);
extern const u8 *const gStdScripts[];
extern const u8 *const gStdScriptsEnd[];
-static bool8 sub_806B93C(struct ScriptContext * ctx);
-static u8 sub_806B96C(struct ScriptContext * ctx);
+static bool8 ScriptContext_NextCommandEndsScript(struct ScriptContext * ctx);
+static u8 ScriptContext_GetQuestLogInput(struct ScriptContext * ctx);
static EWRAM_DATA ptrdiff_t gVScriptOffset = 0;
-static EWRAM_DATA u8 gUnknown_20370AC = 0;
+static EWRAM_DATA u8 sQuestLogWaitButtonPressTimer = 0;
static EWRAM_DATA u16 sPauseCounter = 0;
static EWRAM_DATA u16 sMovingNpcId = 0;
static EWRAM_DATA u16 sMovingNpcMapBank = 0;
static EWRAM_DATA u16 sMovingNpcMapId = 0;
static EWRAM_DATA u16 sFieldEffectScriptId = 0;
-struct ScriptContext * gUnknown_3005070;
+struct ScriptContext * sQuestLogScriptContextPtr;
u8 gSelectedObjectEvent;
// This is defined in here so the optimizer can't see its value when compiling
@@ -803,7 +800,7 @@ bool8 ScrCmd_warpteleport2(struct ScriptContext * ctx)
SetWarpDestination(mapGroup, mapNum, warpId, x, y);
SavePlayerFacingDirectionForTeleport(GetPlayerFacingDirection());
- sub_807E500();
+ DoTeleport2Warp();
ResetInitialPlayerAvatarState();
return TRUE;
}
@@ -926,7 +923,7 @@ bool8 ScrCmd_playbgm(struct ScriptContext * ctx)
u16 songId = ScriptReadHalfword(ctx);
bool8 val = ScriptReadByte(ctx);
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return FALSE;
if (val == TRUE)
Overworld_SetSavedMusic(songId);
@@ -942,7 +939,7 @@ bool8 ScrCmd_savebgm(struct ScriptContext * ctx)
bool8 ScrCmd_fadedefaultbgm(struct ScriptContext * ctx)
{
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return FALSE;
Overworld_ChangeMusicToDefault();
return FALSE;
@@ -951,7 +948,7 @@ bool8 ScrCmd_fadedefaultbgm(struct ScriptContext * ctx)
bool8 ScrCmd_fadenewbgm(struct ScriptContext * ctx)
{
u16 music = ScriptReadHalfword(ctx);
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return FALSE;
Overworld_ChangeMusicTo(music);
return FALSE;
@@ -961,7 +958,7 @@ bool8 ScrCmd_fadeoutbgm(struct ScriptContext * ctx)
{
u8 speed = ScriptReadByte(ctx);
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return FALSE;
if (speed != 0)
FadeOutBGMTemporarily(4 * speed);
@@ -975,7 +972,7 @@ bool8 ScrCmd_fadeinbgm(struct ScriptContext * ctx)
{
u8 speed = ScriptReadByte(ctx);
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return FALSE;
if (speed != 0)
FadeInBGM(4 * speed);
@@ -1203,7 +1200,7 @@ bool8 ScrCmd_lockall(struct ScriptContext * ctx)
else
{
ScriptFreezeObjectEvents();
- SetupNativeScript(ctx, sub_8069590);
+ SetupNativeScript(ctx, NativeScript_WaitPlayerStopMoving);
return TRUE;
}
}
@@ -1219,12 +1216,12 @@ bool8 ScrCmd_lock(struct ScriptContext * ctx)
if (gObjectEvents[gSelectedObjectEvent].active)
{
LockSelectedObjectEvent();
- SetupNativeScript(ctx, sub_8069648);
+ SetupNativeScript(ctx, NativeScript_WaitPlayerAndTargetNPCStopMoving);
}
else
{
ScriptFreezeObjectEvents();
- SetupNativeScript(ctx, sub_8069590);
+ SetupNativeScript(ctx, NativeScript_WaitPlayerStopMoving);
}
return TRUE;
}
@@ -1235,7 +1232,7 @@ bool8 ScrCmd_releaseall(struct ScriptContext * ctx)
u8 playerObjectId;
HideFieldMessageBox();
- playerObjectId = GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0);
+ playerObjectId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[playerObjectId]);
ScriptMovement_UnfreezeObjectEvents();
UnfreezeObjectEvents();
@@ -1249,7 +1246,7 @@ bool8 ScrCmd_release(struct ScriptContext * ctx)
HideFieldMessageBox();
if (gObjectEvents[gSelectedObjectEvent].active)
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[gSelectedObjectEvent]);
- playerObjectId = GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0);
+ playerObjectId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[playerObjectId]);
ScriptMovement_UnfreezeObjectEvents();
UnfreezeObjectEvents();
@@ -1319,16 +1316,16 @@ static bool8 WaitForAorBPress(void)
if (JOY_NEW(B_BUTTON))
return TRUE;
- if (sub_806B93C(gUnknown_3005070) == TRUE)
+ if (ScriptContext_NextCommandEndsScript(sQuestLogScriptContextPtr) == TRUE)
{
- u8 r4 = sub_806B96C(gUnknown_3005070);
- RegisterQuestLogInput(r4);
- if (r4 != QL_INPUT_OFF)
+ u8 qlogInput = ScriptContext_GetQuestLogInput(sQuestLogScriptContextPtr);
+ RegisterQuestLogInput(qlogInput);
+ if (qlogInput != QL_INPUT_OFF)
{
- if (gQuestLogState != QL_STATE_2)
+ if (gQuestLogState != QL_STATE_PLAYBACK)
{
ClearMsgBoxCancelableState();
- if (r4 != QL_INPUT_A && r4 != QL_INPUT_B)
+ if (qlogInput != QL_INPUT_A && qlogInput != QL_INPUT_B)
SetQuestLogInputIsDpadFlag();
else
{
@@ -1339,18 +1336,18 @@ static bool8 WaitForAorBPress(void)
}
}
}
- if (sub_8112CAC() == 1 || gQuestLogState == QL_STATE_2)
+ if (sub_8112CAC() == 1 || gQuestLogState == QL_STATE_PLAYBACK)
{
- if (gUnknown_20370AC == 120)
+ if (sQuestLogWaitButtonPressTimer == 120)
return TRUE;
else
- gUnknown_20370AC++;
+ sQuestLogWaitButtonPressTimer++;
}
return FALSE;
}
-static bool8 sub_806B93C(struct ScriptContext * ctx)
+static bool8 ScriptContext_NextCommandEndsScript(struct ScriptContext * ctx)
{
const u8 * script = ctx->scriptPtr;
u8 nextCmd = *script;
@@ -1365,7 +1362,7 @@ static bool8 sub_806B93C(struct ScriptContext * ctx)
return TRUE;
}
-static u8 sub_806B96C(struct ScriptContext * ctx)
+static u8 ScriptContext_GetQuestLogInput(struct ScriptContext * ctx)
{
if (JOY_HELD(DPAD_UP) && gSpecialVar_Facing != DIR_NORTH)
return QL_INPUT_UP;
@@ -1402,10 +1399,10 @@ static u8 sub_806B96C(struct ScriptContext * ctx)
bool8 ScrCmd_waitbuttonpress(struct ScriptContext * ctx)
{
- gUnknown_3005070 = ctx;
+ sQuestLogScriptContextPtr = ctx;
- if (sub_8112CAC() == 1 || gQuestLogState == 2)
- gUnknown_20370AC = 0;
+ if (sub_8112CAC() == 1 || gQuestLogState == QL_STATE_PLAYBACK)
+ sQuestLogWaitButtonPressTimer = 0;
SetupNativeScript(ctx, WaitForAorBPress);
return TRUE;
}
diff --git a/src/script.c b/src/script.c
index 097f6d3f3..c45c6744c 100644
--- a/src/script.c
+++ b/src/script.c
@@ -435,7 +435,7 @@ bool8 TryRunOnFrameMapScript(void)
{
u8 *ptr;
- if(gQuestLogState == 3)
+ if(gQuestLogState == QL_STATE_PLAYBACK_LAST)
return 0;
ptr = mapheader_get_first_match_from_tagged_ptr_list(2);
diff --git a/src/script_menu.c b/src/script_menu.c
index b2748db38..4e5ba905c 100644
--- a/src/script_menu.c
+++ b/src/script_menu.c
@@ -1,17 +1,13 @@
#include "global.h"
-#include "palette.h"
-#include "text.h"
+#include "gflib.h"
#include "menu.h"
#include "task.h"
-#include "sound.h"
#include "script_menu.h"
#include "quest_log.h"
-#include "window.h"
#include "new_menu_helpers.h"
#include "event_data.h"
#include "script.h"
#include "strings.h"
-#include "string_util.h"
#include "field_effect.h"
#include "event_scripts.h"
#include "constants/songs.h"
diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c
index 677759497..f0bfad455 100644
--- a/src/script_pokemon_util.c
+++ b/src/script_pokemon_util.c
@@ -1,9 +1,9 @@
#include "global.h"
+#include "gflib.h"
#include "berry.h"
#include "daycare.h"
#include "event_data.h"
#include "load_save.h"
-#include "malloc.h"
#include "overworld.h"
#include "party_menu.h"
#include "pokedex.h"
diff --git a/src/seagallop.c b/src/seagallop.c
index 11022f315..da020f882 100644
--- a/src/seagallop.c
+++ b/src/seagallop.c
@@ -1,13 +1,8 @@
#include "global.h"
-#include "gpu_regs.h"
-#include "bg.h"
-#include "palette.h"
-#include "malloc.h"
+#include "gflib.h"
#include "scanline_effect.h"
#include "trainer_pokemon_sprites.h"
-#include "window.h"
#include "text_window.h"
-#include "sound.h"
#include "task.h"
#include "help_system.h"
#include "overworld.h"
diff --git a/src/shop.c b/src/shop.c
index b84007bed..66b9fdb49 100644
--- a/src/shop.c
+++ b/src/shop.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "gflib.h"
#include "shop.h"
#include "menu.h"
#include "data.h"
@@ -7,24 +8,15 @@
#include "list_menu.h"
#include "new_menu_helpers.h"
#include "party_menu.h"
-#include "window.h"
#include "field_specials.h"
#include "field_weather.h"
#include "task.h"
-#include "text.h"
#include "item.h"
#include "item_menu.h"
-#include "main.h"
-#include "sound.h"
-#include "string_util.h"
#include "overworld.h"
-#include "palette.h"
#include "field_fadetransition.h"
#include "scanline_effect.h"
#include "item_menu_icons.h"
-#include "bg.h"
-#include "gpu_regs.h"
-#include "malloc.h"
#include "decompress.h"
#include "menu_indicators.h"
#include "field_player_avatar.h"
diff --git a/src/slot_machine.c b/src/slot_machine.c
index d0422ab99..7fb199419 100644
--- a/src/slot_machine.c
+++ b/src/slot_machine.c
@@ -1,13 +1,7 @@
#include "global.h"
-#include "gpu_regs.h"
-#include "dma3.h"
-#include "bg.h"
-#include "palette.h"
+#include "gflib.h"
#include "decompress.h"
#include "task.h"
-#include "main.h"
-#include "malloc.h"
-#include "sound.h"
#include "coins.h"
#include "quest_log.h"
#include "overworld.h"
@@ -19,61 +13,99 @@
#include "strings.h"
#include "constants/songs.h"
+#define SLOT_IMAGE_7 0
+#define SLOT_IMAGE_ROCKET 1
+#define SLOT_IMAGE_PIKACHU 2
+#define SLOT_IMAGE_PSYDUCK 3
+#define SLOT_IMAGE_CHERRIES 4
+#define SLOT_IMAGE_MAGNEMITE 5
+#define SLOT_IMAGE_SHELLDER 6
+
+#define SLOT_PAYOUT_NONE 0
+#define SLOT_PAYOUT_CHERRIES2 1
+#define SLOT_PAYOUT_CHERRIES3 2
+#define SLOT_PAYOUT_MAGSHELL 3
+#define SLOT_PAYOUT_PIKAPSY 4
+#define SLOT_PAYOUT_ROCKET 5
+#define SLOT_PAYOUT_7 6
+
+#define ROWATTR_COL1POS 0
+#define ROWATTR_COL2POS 1
+#define ROWATTR_COL3POS 2
+#define ROWATTR_MINBET 3
+
+#define SLOTTASK_GFX_INIT 0
+#define SLOTTASK_FADEOUT_EXIT 1
+#define SLOTTASK_UPDATE_LINE_LIGHTS 2
+#define SLOTTASK_CLEFAIRY_BOUNCE 3
+#define SLOTTASK_ANIM_WIN 4
+#define SLOTTASK_END_ANIM_WIN 5
+#define SLOTTASK_ANIM_LOSE 6
+#define SLOTTASK_ANIM_BETTING 7
+#define SLOTTASK_SHOW_AMOUNTS 8
+#define SLOTTASK_MSG_NO_COINS 9
+#define SLOTTASK_ASK_QUIT 10
+#define SLOTTASK_DESTROY_YESNO 11
+#define SLOTTASK_PRESS_BUTTON 12
+#define SLOTTASK_RELEASE_BUTTONS 13
+#define SLOTTASK_SHOWHELP 14
+#define SLOTTASK_HIDEHELP 15
+
struct SlotMachineState
{
MainCallback savedCallback;
u16 machineidx;
- u16 field_06;
- u16 field_08;
+ u16 currentReel;
+ u16 machineBias;
u16 slotRewardClass;
- u16 field_0C;
+ u16 biasCooldown;
u16 bet;
- u8 field_10;
- u8 field_11;
- bool32 field_14[3];
- s16 field_20[3];
- s16 field_26[3];
- s16 field_2C[3];
- s16 field_32[3];
- u32 field_38;
- u32 field_3C[5];
+ u8 taskId;
+ u8 spinReelsTaskId;
+ bool32 reelIsSpinning[3];
+ s16 reelPositions[3];
+ s16 reelSubpixel[3];
+ s16 destReelPos[3];
+ s16 reelStopOrder[3];
+ u32 reel2BiasInPlay;
+ bool32 winFlags[5];
u16 payout;
};
struct SlotMachineGfxManager
{
u32 field_00[3];
- struct Sprite * field_0C[3][5];
- struct Sprite * field_48[4];
- struct Sprite * field_58[4];
- struct Sprite * field_68[2];
- vu16 * field_70;
+ struct Sprite * reelIconSprites[3][5];
+ struct Sprite * creditDigitSprites[4];
+ struct Sprite * payoutDigitSprites[4];
+ struct Sprite * clefairySprites[2];
+ vu16 * reelIconAffineParamPtr;
};
struct SlotMachineSetupTaskDataSub_0000
{
- u16 unk0;
- u8 unk2;
- u8 unk3;
+ u16 funcno;
+ u8 state;
+ bool8 active;
};
struct SlotMachineSetupTaskData
{
- struct SlotMachineSetupTaskDataSub_0000 field_0000[8];
- u8 field_0020;
+ struct SlotMachineSetupTaskDataSub_0000 tasks[8];
+ u8 reelButtonToPress;
// align 2
- s32 field_0024;
- u32 field_0028;
- u16 field_002C[3][4];
- u16 field_0044[3][4];
+ s32 bg1X;
+ bool32 yesNoMenuActive;
+ u16 buttonPressedTiles[3][4];
+ u16 buttonReleasedTiles[3][4];
u8 field_005C[0x800];
- u8 field_085C[0x800];
- u8 field_105C[0x800];
- u8 field_185C[0x800];
- u8 field_205C[0x800];
+ u8 bg0TilemapBuffer[0x800];
+ u8 bg1TilemapBuffer[0x800];
+ u8 bg2TilemapBuffer[0x800];
+ u8 bg3TilemapBuffer[0x800];
}; // size: 285C
-struct UnkStruct_8466C0C
+struct LineStateTileIdxList
{
const u16 * tiles;
u32 count;
@@ -82,10 +114,10 @@ struct UnkStruct_8466C0C
static EWRAM_DATA struct SlotMachineState * sSlotMachineState = NULL;
static EWRAM_DATA struct SlotMachineGfxManager * sSlotMachineGfxManager = NULL;
-static void sub_813F84C(struct SlotMachineState * ptr);
-static void sub_813F898(void);
-static void sub_813F92C(void);
-static void sub_813F94C(void);
+static void InitSlotMachineState(struct SlotMachineState * ptr);
+static void CB2_InitSlotMachine(void);
+static void CleanSupSlotMachineState(void);
+static void CB2_RunSlotMachine(void);
static void MainTask_SlotsGameLoop(u8 taskId);
static void MainTask_NoCoinsGameOver(u8 taskId);
static void MainTask_ShowHelp(u8 taskId);
@@ -94,57 +126,57 @@ static void MainTask_DarnNoPayout(u8 taskId);
static void MainTask_WinHandlePayout(u8 taskId);
static void MainTask_ExitSlots(u8 taskId);
static void SetMainTask(TaskFunc taskFunc);
-static void sub_8140060(u8 taskId);
-static void sub_8140148(void);
-static void sub_814016C(u16 whichReel, u16 whichReel2);
-static bool32 sub_81401A0(u16);
-static void sub_81401F0(u16 whichReel);
-static void sub_81403BC(u16 whichReel);
-static void sub_81404B8(u16 whichReel);
-static bool32 sub_814054C(s32, s32, s32, s32, s32);
-static bool32 sub_81406E8(s32, s32, s32);
-static bool32 sub_81408F4(s32, s32);
-static void sub_81409B4(void);
-static void sub_8140A70(void);
-static u16 sub_8140A80(void);
-static void sub_8140C6C(struct SlotMachineGfxManager * manager);
-static void sub_8140D7C(const s16 *, const s16 *);
-static bool32 sub_814104C(void);
-static void sub_8141094(void);
-static struct SlotMachineSetupTaskData * sub_814112C(void);
-static void sub_81410CC(u8 taskId);
-static void sub_8141148(u16 a0, u8 a1);
-static bool32 sub_8141180(u8 a0);
-static bool8 sub_8141198(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141460(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_81414AC(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_81414EC(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_81414FC(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141518(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141558(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141568(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141578(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141584(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_81415C8(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141610(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141650(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141690(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_81416C8(u8 *, struct SlotMachineSetupTaskData *);
-static bool8 sub_8141764(u8 *, struct SlotMachineSetupTaskData *);
-static void sub_81417E4(const u8 * str);
-static void sub_8141828(void);
-static void sub_8141834(u16 * bgTilemapBuffer);
-static void sub_81418C4(u16 * bgTilemapBuffer, u16 a0, u16 a1);
-static void sub_814191C(u8 taskId);
-static void sub_8141AB0(void);
-static void sub_8141AD8(u8 a0);
-static void sub_8141B18(void);
-static void sub_8141B34(void);
-static void sub_8141BA0(u8 a0);
-static void sub_8141BE4(void);
-static void sub_8141C30(u8, u8);
-
-static const u8 gUnknown_8464890[][2] = {
+static void Task_SpinReels(u8 taskId);
+static void StartReels(void);
+static void StopCurrentReel(u16 whichReel, u16 whichReel2);
+static bool32 IsReelSpinning(u16);
+static void StopReel1(u16 whichReel);
+static void StopReel2(u16 whichReel);
+static void StopReel3(u16 whichReel);
+static bool32 TwoReelBiasCheck(s32 reel0id, s32 reel0pos, s32 reel1id, s32 reel1pos, s32 icon);
+static bool32 OneReelBiasCheck(s32, s32, s32);
+static bool32 TestReelIconAttribute(s32 attr, s32 icon);
+static void CalcSlotBias(void);
+static void ResetMachineBias(void);
+static u16 CalcPayout(void);
+static void InitGfxManager(struct SlotMachineGfxManager * manager);
+static void UpdateReelIconSprites(const s16 *, const s16 *);
+static bool32 CreateSlotMachine(void);
+static void DestroySlotMachine(void);
+static struct SlotMachineSetupTaskData * GetSlotMachineSetupTaskDataPtr(void);
+static void Task_SlotMachine(u8 taskId);
+static void SetSlotMachineSetupTask(u16 funcno, u8 taskId);
+static bool32 IsSlotMachineSetupTaskActive(u8 taskId);
+static bool8 SlotsTask_GraphicsInit(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_FadeOut(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_UpdateLineStates(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_ClefairyUpdateOnReelsStart(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_StartClefairyDanceAndWinningLineFlash(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_StopWinningLineFlashTask(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_ClefairyFainted(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_ClefairyNeutral(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_UpdateCoinsDisplay(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_MessageOutOfCoins(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_AskQuitPlaying(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_DestroyYesNoMenu(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_PressReelButton(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_ReleaseReelButtons(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_ShowHelp(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static bool8 SlotsTask_HideHelp(u8 *state, struct SlotMachineSetupTaskData * ptr);
+static void Slot_PrintOnWindow0(const u8 * str);
+static void Slot_ClearWindow0(void);
+static void SetLineStatesByBet(u16 * bgTilemapBuffer);
+static void SetLineState(u16 * bgTilemapBuffer, u16 lineId, u16 paletteNo);
+static void Task_FlashWinningLine(u8 taskId);
+static void SignalStopWinningLineFlashTask(void);
+static void Slot_CreateYesNoMenu(u8 cursorPos);
+static void Slot_DestroyYesNoMenu(void);
+static void InitReelButtonTileMem(void);
+static void SetReelButtonPressed(u8 reel);
+static void ReleaseReelButtons(void);
+static void PressReelButton(u8 reel, u8 taskId);
+
+static const u8 sSecondReelBiasCheckIndices[][2] = {
{0x00, 0x03},
{0x00, 0x06},
{0x03, 0x06},
@@ -166,7 +198,7 @@ static const u8 gUnknown_8464890[][2] = {
{0x04, 0x06}
};
-static const u8 gUnknown_84648AE[][3] = {
+static const u8 sThirdReelBiasCheckIndices[][3] = {
{0x00, 0x03, 0x06}, // top row
{0x01, 0x04, 0x07}, // middle row
{0x02, 0x05, 0x08}, // bottom row
@@ -174,7 +206,7 @@ static const u8 gUnknown_84648AE[][3] = {
{0x02, 0x04, 0x06} // bl-tr
};
-static const u8 gUnknown_84648BD[][4] = {
+static const u8 sRowAttributes[][4] = {
{0x00, 0x04, 0x08, 0x03}, // tl-br
{0x00, 0x03, 0x06, 0x02}, // top row
{0x01, 0x04, 0x07, 0x01}, // middle row
@@ -182,7 +214,7 @@ static const u8 gUnknown_84648BD[][4] = {
{0x02, 0x04, 0x06, 0x03} // bl-tr
};
-static const u16 gUnknown_84648D2[][7] = {
+static const u16 sReelBiasChances[][7] = {
{0x1fa1, 0x2eab, 0x3630, 0x39f3, 0x3bd4, 0x3bfc, 0x0049},
{0x1f97, 0x2ea2, 0x3627, 0x39e9, 0x3bca, 0x3bf8, 0x0049},
{0x1f91, 0x2e9b, 0x3620, 0x39e3, 0x3bc4, 0x3bf4, 0x0049},
@@ -191,79 +223,143 @@ static const u16 gUnknown_84648D2[][7] = {
{0x1fc9, 0x2efc, 0x3696, 0x3a63, 0x3c49, 0x3c8b, 0x0073},
};
-static const u8 gUnknown_8464926[][21] = {
- {0x00, 0x03, 0x04, 0x01, 0x02, 0x06, 0x02, 0x05, 0x00, 0x06, 0x03, 0x01, 0x04, 0x02, 0x06, 0x00, 0x05, 0x02, 0x01, 0x06, 0x02},
- {0x00, 0x05, 0x04, 0x03, 0x01, 0x05, 0x04, 0x03, 0x02, 0x05, 0x04, 0x03, 0x00, 0x05, 0x04, 0x01, 0x03, 0x06, 0x05, 0x03, 0x04},
- {0x00, 0x03, 0x06, 0x05, 0x02, 0x03, 0x06, 0x05, 0x02, 0x03, 0x05, 0x06, 0x02, 0x03, 0x05, 0x06, 0x02, 0x03, 0x05, 0x06, 0x01},
+static const u8 sReelIconAnimByReelAndPos[][21] = {
+ {
+ SLOT_IMAGE_7,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_CHERRIES,
+ SLOT_IMAGE_ROCKET,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_7,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_ROCKET,
+ SLOT_IMAGE_CHERRIES,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_7,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_ROCKET,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_PIKACHU
+ }, {
+ SLOT_IMAGE_7,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_CHERRIES,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_ROCKET,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_CHERRIES,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_CHERRIES,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_7,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_CHERRIES,
+ SLOT_IMAGE_ROCKET,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_CHERRIES
+ }, {
+ SLOT_IMAGE_7,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_PIKACHU,
+ SLOT_IMAGE_PSYDUCK,
+ SLOT_IMAGE_MAGNEMITE,
+ SLOT_IMAGE_SHELLDER,
+ SLOT_IMAGE_ROCKET
+ },
};
-static const u16 gUnknown_8464966[] = {
- 0,
- 2,
- 6,
- 8,
- 15,
- 100,
- 300
+static const u16 sPayoutTable[] = {
+ [SLOT_PAYOUT_NONE] = 0,
+ [SLOT_PAYOUT_CHERRIES2] = 2,
+ [SLOT_PAYOUT_CHERRIES3] = 6,
+ [SLOT_PAYOUT_MAGSHELL] = 8,
+ [SLOT_PAYOUT_PIKAPSY] = 15,
+ [SLOT_PAYOUT_ROCKET] = 100,
+ [SLOT_PAYOUT_7] = 300
};
-static const u16 gUnknown_8464974[] = INCBIN_U16("graphics/slot_machine/unk_8464974.gbapal");
-static const u16 gUnknown_8464994[] = INCBIN_U16("graphics/slot_machine/unk_8464994.gbapal");
-static const u16 gUnknown_84649B4[] = INCBIN_U16("graphics/slot_machine/unk_84649b4.gbapal");
-static const u16 gUnknown_84649D4[] = INCBIN_U16("graphics/slot_machine/unk_84649d4.gbapal");
-static const u16 gUnknown_84649F4[] = INCBIN_U16("graphics/slot_machine/unk_84649f4.gbapal");
+static const u16 sSpritePal_ReelIcons_0[] = INCBIN_U16("graphics/slot_machine/unk_8464974.gbapal");
+static const u16 sSpritePal_ReelIcons_1[] = INCBIN_U16("graphics/slot_machine/unk_8464994.gbapal");
+static const u16 sSpritePal_ReelIcons_2[] = INCBIN_U16("graphics/slot_machine/unk_84649b4.gbapal");
+static const u16 sSpritePal_ReelIcons_3[] = INCBIN_U16("graphics/slot_machine/unk_84649d4.gbapal");
+static const u16 sSpritePal_ReelIcons_4[] = INCBIN_U16("graphics/slot_machine/unk_84649f4.gbapal");
#if defined(FIRERED)
-static const u32 gUnknown_8464A14[] = INCBIN_U32("graphics/slot_machine/unk_8464a14.4bpp.lz");
-static const u16 gUnknown_846504C[] = INCBIN_U16("graphics/slot_machine/unk_846506c.gbapal");
-static const u32 gUnknown_846506C[] = INCBIN_U32("graphics/slot_machine/unk_846506c.4bpp.lz");
+static const u32 sSpriteTiles_ReelIcons[] = INCBIN_U32("graphics/slot_machine/unk_8464a14.4bpp.lz");
+static const u16 sSpritePal_Clefairy[] = INCBIN_U16("graphics/slot_machine/unk_846506c.gbapal");
+static const u32 sSpriteTiles_Clefairy[] = INCBIN_U32("graphics/slot_machine/unk_846506c.4bpp.lz");
#elif defined(LEAFGREEN)
-static const u32 gUnknown_8464A14[] = INCBIN_U32("graphics/slot_machine/unk_lg_8464434.4bpp.lz");
-static const u16 gUnknown_846504C[] = INCBIN_U16("graphics/slot_machine/unk_lg_8464a3c.gbapal");
-static const u32 gUnknown_846506C[] = INCBIN_U32("graphics/slot_machine/unk_lg_8464a3c.4bpp.lz");
+static const u32 sSpriteTiles_ReelIcons[] = INCBIN_U32("graphics/slot_machine/unk_lg_8464434.4bpp.lz");
+static const u16 sSpritePal_Clefairy[] = INCBIN_U16("graphics/slot_machine/unk_lg_8464a3c.gbapal");
+static const u32 sSpriteTiles_Clefairy[] = INCBIN_U32("graphics/slot_machine/unk_lg_8464a3c.4bpp.lz");
#endif
-static const u16 gUnknown_8465524[] = INCBIN_U16("graphics/slot_machine/unk_8465524.gbapal");
-static const u32 gUnknown_8465544[] = INCBIN_U32("graphics/slot_machine/unk_8465544.4bpp.lz");
-
-static const struct CompressedSpriteSheet gUnknown_84655B0[] = {
- {(const void *)gUnknown_8464A14, 0xe00, 0},
- {(const void *)gUnknown_846506C, 0xc00, 1},
- {(const void *)gUnknown_8465544, 0x280, 2},
-};
-
-static const struct SpritePalette gUnknown_84655C8[] = {
- {gUnknown_8464974, 0},
- {gUnknown_8464994, 1},
- {gUnknown_84649B4, 2},
- {gUnknown_84649D4, 3},
- {gUnknown_84649F4, 4},
- {gUnknown_846504C, 5},
- {gUnknown_8465524, 6},
+static const u16 sSpritePal_Digits[] = INCBIN_U16("graphics/slot_machine/unk_8465524.gbapal");
+static const u32 sSpriteTiles_Digits[] = INCBIN_U32("graphics/slot_machine/unk_8465544.4bpp.lz");
+
+static const struct CompressedSpriteSheet sSpriteSheets[] = {
+ {(const void *)sSpriteTiles_ReelIcons, 0xe00, 0},
+ {(const void *)sSpriteTiles_Clefairy, 0xc00, 1},
+ {(const void *)sSpriteTiles_Digits, 0x280, 2},
+};
+
+static const struct SpritePalette sSpritePalettes[] = {
+ {sSpritePal_ReelIcons_0, 0},
+ {sSpritePal_ReelIcons_1, 1},
+ {sSpritePal_ReelIcons_2, 2},
+ {sSpritePal_ReelIcons_3, 3},
+ {sSpritePal_ReelIcons_4, 4},
+ {sSpritePal_Clefairy, 5},
+ {sSpritePal_Digits, 6},
{NULL}
};
#if defined(FIRERED)
-static const u16 gUnknown_8465608[] = {
- 2,
- 2,
- 0,
- 0,
- 2,
- 4,
- 3
+static const u16 sReelIconPaletteTags[] = {
+ [SLOT_IMAGE_7] = 2,
+ [SLOT_IMAGE_ROCKET] = 2,
+ [SLOT_IMAGE_PIKACHU] = 0,
+ [SLOT_IMAGE_PSYDUCK] = 0,
+ [SLOT_IMAGE_CHERRIES] = 2,
+ [SLOT_IMAGE_MAGNEMITE] = 4,
+ [SLOT_IMAGE_SHELLDER] = 3
};
#elif defined(LEAFGREEN)
-static const u16 gUnknown_8465608[] = {
- 2,
- 2,
- 0,
- 3,
- 2,
- 1,
- 1
+static const u16 sReelIconPaletteTags[] = {
+ [SLOT_IMAGE_7] = 2,
+ [SLOT_IMAGE_ROCKET] = 2,
+ [SLOT_IMAGE_PIKACHU] = 0,
+ [SLOT_IMAGE_PSYDUCK] = 3,
+ [SLOT_IMAGE_CHERRIES] = 2,
+ [SLOT_IMAGE_MAGNEMITE] = 1,
+ [SLOT_IMAGE_SHELLDER] = 1
};
#endif
-static const u16 gUnknown_8465616[] = {
+static const u16 sReelIconAffineParams[] = {
0x0120, 0x011f, 0x011e, 0x011d, 0x011c, 0x011b, 0x011a, 0x0119, 0x0118, 0x0117, 0x0116, 0x0115, 0x0114, 0x0113, 0x0112, 0x0111,
0x0110, 0x010f, 0x010e, 0x010d, 0x010c, 0x010b, 0x010a, 0x0109, 0x0108, 0x0107, 0x0106, 0x0105, 0x0104, 0x0103, 0x0102, 0x0101,
0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
@@ -272,13 +368,13 @@ static const u16 gUnknown_8465616[] = {
0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, 0x0119, 0x011a, 0x011b, 0x011c, 0x011d, 0x011e, 0x011f, 0x0120
};
-static const u8 gUnknown_84656D6[] = {
+static const u8 sReelIconBldY[] = {
0x10, 0x10, 0x10, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0c, 0x0b, 0x0a, 0x0a, 0x09, 0x08, 0x07, 0x07, 0x06, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x09, 0x09, 0x0a, 0x0b, 0x0c, 0x0c, 0x0d, 0x0e, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f
};
-static const struct OamData gUnknown_8465738 = {
+static const struct OamData sOamData_ReelIcons = {
.y = 0,
.affineMode = ST_OAM_AFFINE_NORMAL,
.objMode = ST_OAM_OBJ_NORMAL,
@@ -294,95 +390,101 @@ static const struct OamData gUnknown_8465738 = {
.affineParam = 0
};
-static const union AnimCmd gUnknown_8465740[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_7[] = {
ANIMCMD_FRAME(0x00, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465748[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Rocket[] = {
ANIMCMD_FRAME(0x10, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465750[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Pikachu[] = {
ANIMCMD_FRAME(0x20, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465758[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Psyduck[] = {
ANIMCMD_FRAME(0x30, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465760[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Cherries[] = {
ANIMCMD_FRAME(0x40, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465768[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Magnemite[] = {
ANIMCMD_FRAME(0x50, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465770[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Shellder[] = {
ANIMCMD_FRAME(0x60, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465778[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Pikachu_2[] = {
ANIMCMD_FRAME(0x20, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465780[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Psyduck_2[] = {
ANIMCMD_FRAME(0x30, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465788[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Cherries_2[] = {
ANIMCMD_FRAME(0x40, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465790[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Magnemite_2[] = {
ANIMCMD_FRAME(0x50, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465798[] = {
+static const union AnimCmd sAnimCmd_ReelIcon_Shellder_2[] = {
ANIMCMD_FRAME(0x60, 4),
ANIMCMD_END
};
-static const union AnimCmd *const gUnknown_84657A0[] = {
- gUnknown_8465740,
- gUnknown_8465748,
- gUnknown_8465750,
- gUnknown_8465758,
- gUnknown_8465760,
- gUnknown_8465768,
- gUnknown_8465770,
- gUnknown_8465778,
- gUnknown_8465780,
- gUnknown_8465788,
- gUnknown_8465790,
- gUnknown_8465798
+static const union AnimCmd *const sAnimTable_ReelIcons[] = {
+ sAnimCmd_ReelIcon_7,
+ sAnimCmd_ReelIcon_Rocket,
+ sAnimCmd_ReelIcon_Pikachu,
+ sAnimCmd_ReelIcon_Psyduck,
+ sAnimCmd_ReelIcon_Cherries,
+ sAnimCmd_ReelIcon_Magnemite,
+ sAnimCmd_ReelIcon_Shellder,
+ sAnimCmd_ReelIcon_Pikachu_2,
+ sAnimCmd_ReelIcon_Psyduck_2,
+ sAnimCmd_ReelIcon_Cherries_2,
+ sAnimCmd_ReelIcon_Magnemite_2,
+ sAnimCmd_ReelIcon_Shellder_2
};
-static const union AffineAnimCmd gUnknown_84657D0[] = {
+static const union AffineAnimCmd sAffineAnimCmd_ReelIcons_Unused[] = {
AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 1),
AFFINEANIMCMD_END
};
-static const union AffineAnimCmd *const gUnknown_84657E0[] = {
- gUnknown_84657D0
+static const union AffineAnimCmd *const sAffineAnimTable_ReelIcons_Unused[] = {
+ sAffineAnimCmd_ReelIcons_Unused
};
-static const struct SpriteTemplate gUnknown_84657E4 = {
- 0, 0, &gUnknown_8465738, gUnknown_84657A0, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
+static const struct SpriteTemplate sSpriteTemplate_ReelIcons = {
+ .tileTag = 0,
+ .paletteTag = 0,
+ .oam = &sOamData_ReelIcons,
+ .anims = sAnimTable_ReelIcons,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy
};
-static const struct OamData gUnknown_84657FC = {
+static const struct OamData sOamData_Digits = {
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
@@ -398,74 +500,80 @@ static const struct OamData gUnknown_84657FC = {
.affineParam = 0
};
-static const union AnimCmd gUnknown_8465804[] = {
+static const union AnimCmd sSpriteAnim_Digit0[] = {
ANIMCMD_FRAME(0x00, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_846580C[] = {
+static const union AnimCmd sSpriteAnim_Digit1[] = {
ANIMCMD_FRAME(0x02, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465814[] = {
+static const union AnimCmd sSpriteAnim_Digit2[] = {
ANIMCMD_FRAME(0x04, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_846581C[] = {
+static const union AnimCmd sSpriteAnim_Digit3[] = {
ANIMCMD_FRAME(0x06, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465824[] = {
+static const union AnimCmd sSpriteAnim_Digit4[] = {
ANIMCMD_FRAME(0x08, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_846582C[] = {
+static const union AnimCmd sSpriteAnim_Digit5[] = {
ANIMCMD_FRAME(0x0a, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465834[] = {
+static const union AnimCmd sSpriteAnim_Digit6[] = {
ANIMCMD_FRAME(0x0c, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_846583C[] = {
+static const union AnimCmd sSpriteAnim_Digit7[] = {
ANIMCMD_FRAME(0x0e, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_8465844[] = {
+static const union AnimCmd sSpriteAnim_Digit8[] = {
ANIMCMD_FRAME(0x10, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_846584C[] = {
+static const union AnimCmd sSpriteAnim_Digit9[] = {
ANIMCMD_FRAME(0x12, 4),
ANIMCMD_END
};
-static const union AnimCmd *const gUnknown_8465854[] = {
- gUnknown_8465804,
- gUnknown_846580C,
- gUnknown_8465814,
- gUnknown_846581C,
- gUnknown_8465824,
- gUnknown_846582C,
- gUnknown_8465834,
- gUnknown_846583C,
- gUnknown_8465844,
- gUnknown_846584C
+static const union AnimCmd *const sAnimTable_Digits[] = {
+ sSpriteAnim_Digit0,
+ sSpriteAnim_Digit1,
+ sSpriteAnim_Digit2,
+ sSpriteAnim_Digit3,
+ sSpriteAnim_Digit4,
+ sSpriteAnim_Digit5,
+ sSpriteAnim_Digit6,
+ sSpriteAnim_Digit7,
+ sSpriteAnim_Digit8,
+ sSpriteAnim_Digit9
};
-static const struct SpriteTemplate gUnknown_846587C = {
- 2, 6, &gUnknown_84657FC, gUnknown_8465854, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
+static const struct SpriteTemplate sSpriteTemplate_Digits = {
+ .tileTag = 2,
+ .paletteTag = 6,
+ .oam = &sOamData_Digits,
+ .anims = sAnimTable_Digits,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy
};
-static const struct OamData gUnknown_8465894 = {
+static const struct OamData sOamData_Clefairy = {
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
@@ -481,93 +589,99 @@ static const struct OamData gUnknown_8465894 = {
.affineParam = 0
};
-static const union AnimCmd gUnknown_846589C[] = {
+static const union AnimCmd sAnimCmd_Clefairy_Neutral[] = {
ANIMCMD_FRAME(0, 4),
ANIMCMD_END
};
-static const union AnimCmd gUnknown_84658A4[] = {
+static const union AnimCmd sAnimCmd_Clefairy_Spinning[] = {
ANIMCMD_FRAME( 0, 24),
ANIMCMD_FRAME(16, 24),
ANIMCMD_JUMP(0)
};
-static const union AnimCmd gUnknown_84658B0[] = {
+static const union AnimCmd sAnimCmd_Clefairy_Payout[] = {
ANIMCMD_FRAME(32, 28),
ANIMCMD_FRAME(48, 28),
ANIMCMD_JUMP(0)
};
-static const union AnimCmd gUnknown_84658BC[] = {
+static const union AnimCmd sAnimCmd_Clefairy_Lose[] = {
ANIMCMD_FRAME(64, 12),
ANIMCMD_FRAME(80, 12),
ANIMCMD_JUMP(0)
};
-static const union AnimCmd *const gUnknown_84658C8[] = {
- gUnknown_846589C,
- gUnknown_84658A4,
- gUnknown_84658B0,
- gUnknown_84658BC
-};
-
-static const struct SpriteTemplate gUnknown_84658D8 = {
- 1, 5, &gUnknown_8465894, gUnknown_84658C8, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
-};
-
-bool8 (*const gUnknown_84658F0[])(u8 *, struct SlotMachineSetupTaskData *) = {
- sub_8141198,
- sub_8141460,
- sub_81414AC,
- sub_81414EC,
- sub_81414FC,
- sub_8141518,
- sub_8141558,
- sub_8141568,
- sub_8141578,
- sub_8141584,
- sub_81415C8,
- sub_8141610,
- sub_8141650,
- sub_8141690,
- sub_81416C8,
- sub_8141764
+static const union AnimCmd *const sAnimTable_Clefairy[] = {
+ sAnimCmd_Clefairy_Neutral,
+ sAnimCmd_Clefairy_Spinning,
+ sAnimCmd_Clefairy_Payout,
+ sAnimCmd_Clefairy_Lose
+};
+
+static const struct SpriteTemplate sSpriteTemplate_Clefairy = {
+ .tileTag = 1,
+ .paletteTag = 5,
+ .oam = &sOamData_Clefairy,
+ .anims = sAnimTable_Clefairy,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy
+};
+
+bool8 (*const sSlotMachineSetupTasks[])(u8 *, struct SlotMachineSetupTaskData *) = {
+ [SLOTTASK_GFX_INIT] = SlotsTask_GraphicsInit,
+ [SLOTTASK_FADEOUT_EXIT] = SlotsTask_FadeOut,
+ [SLOTTASK_UPDATE_LINE_LIGHTS] = SlotsTask_UpdateLineStates,
+ [SLOTTASK_CLEFAIRY_BOUNCE] = SlotsTask_ClefairyUpdateOnReelsStart,
+ [SLOTTASK_ANIM_WIN] = SlotsTask_StartClefairyDanceAndWinningLineFlash,
+ [SLOTTASK_END_ANIM_WIN] = SlotsTask_StopWinningLineFlashTask,
+ [SLOTTASK_ANIM_LOSE] = SlotsTask_ClefairyFainted,
+ [SLOTTASK_ANIM_BETTING] = SlotsTask_ClefairyNeutral,
+ [SLOTTASK_SHOW_AMOUNTS] = SlotsTask_UpdateCoinsDisplay,
+ [SLOTTASK_MSG_NO_COINS] = SlotsTask_MessageOutOfCoins,
+ [SLOTTASK_ASK_QUIT] = SlotsTask_AskQuitPlaying,
+ [SLOTTASK_DESTROY_YESNO] = SlotsTask_DestroyYesNoMenu,
+ [SLOTTASK_PRESS_BUTTON] = SlotsTask_PressReelButton,
+ [SLOTTASK_RELEASE_BUTTONS] = SlotsTask_ReleaseReelButtons,
+ [SLOTTASK_SHOWHELP] = SlotsTask_ShowHelp,
+ [SLOTTASK_HIDEHELP] = SlotsTask_HideHelp
};
#if defined(FIRERED)
-static const u16 gUnknown_8465930[] = INCBIN_U16("graphics/slot_machine/unk_8465930.gbapal");
-static const u16 gUnknown_8465950[] = INCBIN_U16("graphics/slot_machine/unk_8465950.gbapal");
-static const u16 gUnknown_8465970[] = INCBIN_U16("graphics/slot_machine/unk_8465970.gbapal");
-static const u16 gUnknown_8465990[] = INCBIN_U16("graphics/slot_machine/unk_8465990.gbapal");
-static const u16 gUnknown_84659B0[] = INCBIN_U16("graphics/slot_machine/unk_84659b0.gbapal");
-static const u32 gUnknown_84659D0[] = INCBIN_U32("graphics/slot_machine/unk_84659d0.4bpp.lz");
-static const u32 gUnknown_84661D4[] = INCBIN_U32("graphics/slot_machine/unk_84661d4.bin.lz");
-static const u16 gUnknown_84664BC[] = INCBIN_U16("graphics/slot_machine/unk_84664bc.gbapal");
-static const u16 gUnknown_84664DC[] = INCBIN_U16("graphics/slot_machine/unk_84664dc.gbapal","graphics/slot_machine/unk_84664fc.gbapal", "graphics/slot_machine/unk_846651c.gbapal");
+static const u16 sBgPal_00[] = INCBIN_U16("graphics/slot_machine/unk_8465930.gbapal");
+static const u16 sBgPal_10[] = INCBIN_U16("graphics/slot_machine/unk_8465950.gbapal");
+static const u16 sBgPal_20[] = INCBIN_U16("graphics/slot_machine/unk_8465970.gbapal");
+static const u16 sBgPal_30[] = INCBIN_U16("graphics/slot_machine/unk_8465990.gbapal");
+static const u16 sBgPal_40[] = INCBIN_U16("graphics/slot_machine/unk_84659b0.gbapal");
+static const u32 sBg2Tiles_00[] = INCBIN_U32("graphics/slot_machine/unk_84659d0.4bpp.lz");
+static const u32 sBg2Map[] = INCBIN_U32("graphics/slot_machine/unk_84661d4.bin.lz");
+static const u16 sBgPal_50[] = INCBIN_U16("graphics/slot_machine/unk_84664bc.gbapal");
+static const u16 sBgPal_VictoryFlash[] = INCBIN_U16("graphics/slot_machine/unk_84664dc.gbapal","graphics/slot_machine/unk_84664fc.gbapal", "graphics/slot_machine/unk_846651c.gbapal");
#elif defined(LEAFGREEN)
-static const u16 gUnknown_8465930[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652bc.gbapal");
-static const u16 gUnknown_8465950[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652dc.gbapal");
-static const u16 gUnknown_8465970[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652fc.gbapal");
-static const u16 gUnknown_8465990[] = INCBIN_U16("graphics/slot_machine/unk_lg_846531c.gbapal");
-static const u16 gUnknown_84659B0[] = INCBIN_U16("graphics/slot_machine/unk_lg_846533c.gbapal");
-static const u32 gUnknown_84659D0[] = INCBIN_U32("graphics/slot_machine/unk_lg_846535c.4bpp.lz");
-static const u32 gUnknown_84661D4[] = INCBIN_U32("graphics/slot_machine/unk_lg_8465ab8.bin.lz");
-static const u16 gUnknown_84664BC[] = INCBIN_U16("graphics/slot_machine/unk_lg_8465d9c.gbapal");
-static const u16 gUnknown_84664DC[] = INCBIN_U16("graphics/slot_machine/unk_lg_8465dbc.gbapal","graphics/slot_machine/unk_lg_8465ddc.gbapal", "graphics/slot_machine/unk_lg_8465dfc.gbapal");
+static const u16 sBgPal_00[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652bc.gbapal");
+static const u16 sBgPal_10[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652dc.gbapal");
+static const u16 sBgPal_20[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652fc.gbapal");
+static const u16 sBgPal_30[] = INCBIN_U16("graphics/slot_machine/unk_lg_846531c.gbapal");
+static const u16 sBgPal_40[] = INCBIN_U16("graphics/slot_machine/unk_lg_846533c.gbapal");
+static const u32 sBg2Tiles_00[] = INCBIN_U32("graphics/slot_machine/unk_lg_846535c.4bpp.lz");
+static const u32 sBg2Map[] = INCBIN_U32("graphics/slot_machine/unk_lg_8465ab8.bin.lz");
+static const u16 sBgPal_50[] = INCBIN_U16("graphics/slot_machine/unk_lg_8465d9c.gbapal");
+static const u16 sBgPal_VictoryFlash[] = INCBIN_U16("graphics/slot_machine/unk_lg_8465dbc.gbapal","graphics/slot_machine/unk_lg_8465ddc.gbapal", "graphics/slot_machine/unk_lg_8465dfc.gbapal");
#endif
-static const u32 gUnknown_846653C[] = INCBIN_U32("graphics/slot_machine/unk_846653c.4bpp.lz");
-static const u16 gUnknown_84665C0[] = INCBIN_U16("graphics/slot_machine/unk_84665c0.gbapal");
-static const u16 gUnknown_84665E0[] = INCBIN_U16("graphics/slot_machine/unk_84665e0.gbapal");
-static const u16 gUnknown_8466600[] = INCBIN_U16("graphics/slot_machine/unk_8466600.gbapal");
+static const u32 sBg2Tiles_C0[] = INCBIN_U32("graphics/slot_machine/unk_846653c.4bpp.lz");
+static const u16 sBgPal_70[] = INCBIN_U16("graphics/slot_machine/unk_84665c0.gbapal");
+static const u16 sBgPal_80[] = INCBIN_U16("graphics/slot_machine/unk_84665e0.gbapal");
+static const u16 sBgPal_90[] = INCBIN_U16("graphics/slot_machine/unk_8466600.gbapal");
#if defined(FIRERED)
-static const u32 gUnknown_8466620[] = INCBIN_U32("graphics/slot_machine/unk_8466620.4bpp.lz");
-static const u32 gUnknown_8466998[] = INCBIN_U32("graphics/slot_machine/unk_8466998.bin.lz");
+static const u32 sBg1Tiles[] = INCBIN_U32("graphics/slot_machine/unk_8466620.4bpp.lz");
+static const u32 sBg1Map[] = INCBIN_U32("graphics/slot_machine/unk_8466998.bin.lz");
#elif defined(LEAFGREEN)
-static const u32 gUnknown_8466620[] = INCBIN_U32("graphics/slot_machine/unk_lg_8465f00.4bpp.lz");
-static const u32 gUnknown_8466998[] = INCBIN_U32("graphics/slot_machine/unk_lg_8466278.bin.lz");
+static const u32 sBg1Tiles[] = INCBIN_U32("graphics/slot_machine/unk_lg_8465f00.4bpp.lz");
+static const u32 sBg1Map[] = INCBIN_U32("graphics/slot_machine/unk_lg_8466278.bin.lz");
#endif
-static const struct BgTemplate gUnknown_8466B10[] = {
+static const struct BgTemplate sBgTemplates[] = {
{
.bg = 0,
.charBaseIndex = 0,
@@ -603,7 +717,7 @@ static const struct BgTemplate gUnknown_8466B10[] = {
}
};
-static const struct WindowTemplate gUnknown_8466B20[] = {
+static const struct WindowTemplate sWindowTemplates[] = {
{
.bg = 0,
.tilemapLeft = 5,
@@ -624,37 +738,37 @@ static const struct WindowTemplate gUnknown_8466B20[] = {
DUMMY_WIN_TEMPLATE
};
-static const u16 gUnknown_8466B38[] = {
+static const u16 sLineTiles_TLBR[] = {
0x00a4, 0x00a5, 0x00a6, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00e7, 0x012c, 0x014c, 0x0191, 0x01b1, 0x01f6, 0x0216, 0x0217, 0x0218, 0x0219, 0x0237, 0x0238, 0x0239
};
-static const u16 gUnknown_8466B60[] = {
+static const u16 sLineTiles_TopRow[] = {
0x00e4, 0x00e5, 0x00e6, 0x00f7, 0x00f8, 0x00f9, 0x0104, 0x0105, 0x0106, 0x0107, 0x010c, 0x0111, 0x0116, 0x0117, 0x0118, 0x0119, 0x0124, 0x0125, 0x0126, 0x0137, 0x0138, 0x0139
};
-static const u16 gUnknown_8466B8C[] = {
+static const u16 sLineTiles_MiddleRow[] = {
0x0144, 0x0145, 0x0146, 0x0157, 0x0158, 0x0159, 0x0164, 0x0165, 0x0166, 0x0167, 0x016c, 0x0171, 0x0176, 0x0177, 0x0178, 0x0179, 0x0184, 0x0185, 0x0186, 0x0197, 0x0198, 0x0199
};
-static const u16 gUnknown_8466BB8[] = {
+static const u16 sLineTiles_BottomRow[] = {
0x01a4, 0x01a5, 0x01a6, 0x01b7, 0x01b8, 0x01b9, 0x01c4, 0x01c5, 0x01c6, 0x01c7, 0x01cc, 0x01d1, 0x01d6, 0x01d7, 0x01d8, 0x01d9, 0x01e4, 0x01e5, 0x01e6, 0x01f7, 0x01f8, 0x01f9
};
-static const u16 gUnknown_8466BE4[] = {
+static const u16 sLineTiles_BLTR[] = {
0x0204, 0x0205, 0x0206, 0x0224, 0x0225, 0x0226, 0x01e7, 0x0207, 0x018c, 0x01ac, 0x0131, 0x0151, 0x00d6, 0x00f6, 0x00b7, 0x00b8, 0x00b9, 0x00d7, 0x00d8, 0x00d9
};
-static const struct UnkStruct_8466C0C gUnknown_8466C0C[] = {
- { gUnknown_8466B38, NELEMS(gUnknown_8466B38) },
- { gUnknown_8466B60, NELEMS(gUnknown_8466B60) },
- { gUnknown_8466B8C, NELEMS(gUnknown_8466B8C) },
- { gUnknown_8466BB8, NELEMS(gUnknown_8466BB8) },
- { gUnknown_8466BE4, NELEMS(gUnknown_8466BE4) }
+static const struct LineStateTileIdxList sLineStateTileIdxs[] = {
+ { sLineTiles_TLBR, NELEMS(sLineTiles_TLBR) },
+ { sLineTiles_TopRow, NELEMS(sLineTiles_TopRow) },
+ { sLineTiles_MiddleRow, NELEMS(sLineTiles_MiddleRow) },
+ { sLineTiles_BottomRow, NELEMS(sLineTiles_BottomRow) },
+ { sLineTiles_BLTR, NELEMS(sLineTiles_BLTR) }
};
-static const u8 gUnknown_8466C34[2] = {2, 4};
+static const u8 sWInningLineFlashPalIdxs[2] = {2, 4};
-static const struct WindowTemplate gUnknown_8466C38 = {
+static const struct WindowTemplate sYesNoWindowTemplate = {
.bg = 0,
.tilemapLeft = 19,
.tilemapTop = 9,
@@ -664,7 +778,7 @@ static const struct WindowTemplate gUnknown_8466C38 = {
.baseBlock = 0x9F
};
-static const u16 gUnknown_8466C40[][4] = {
+static const u16 sReelButtonMapTileIdxs[][4] = {
{0x0229, 0x022a, 0x0249, 0x024a},
{0x022e, 0x022f, 0x024e, 0x024f},
{0x0233, 0x0234, 0x0253, 0x0254}
@@ -682,29 +796,29 @@ void PlaySlotMachine(u16 machineIdx, MainCallback savedCallback)
machineIdx = 0;
sSlotMachineState->machineidx = machineIdx;
sSlotMachineState->savedCallback = savedCallback;
- sub_813F84C(sSlotMachineState);
- SetMainCallback2(sub_813F898);
+ InitSlotMachineState(sSlotMachineState);
+ SetMainCallback2(CB2_InitSlotMachine);
}
}
-static void sub_813F84C(struct SlotMachineState * ptr)
+static void InitSlotMachineState(struct SlotMachineState * ptr)
{
s32 i;
- ptr->field_06 = 0;
+ ptr->currentReel = 0;
ptr->bet = 0;
ptr->payout = 0;
// for whatever reason, the loop does not use the ptr param
for (i = 0; i < 3; i++)
{
- sSlotMachineState->field_14[i] = FALSE;
- sSlotMachineState->field_20[i] = 0;
- sSlotMachineState->field_26[i] = 0;
- sSlotMachineState->field_2C[i] = 21;
+ sSlotMachineState->reelIsSpinning[i] = FALSE;
+ sSlotMachineState->reelPositions[i] = 0;
+ sSlotMachineState->reelSubpixel[i] = 0;
+ sSlotMachineState->destReelPos[i] = 21;
}
}
-static void sub_813F898(void)
+static void CB2_InitSlotMachine(void)
{
RunTasks();
AnimateSprites();
@@ -713,31 +827,31 @@ static void sub_813F898(void)
switch (gMain.state)
{
case 0:
- if (sub_814104C())
+ if (CreateSlotMachine())
{
SetMainCallback2(sSlotMachineState->savedCallback);
- sub_813F92C();
+ CleanSupSlotMachineState();
}
else
{
- sub_8141148(0, 0);
+ SetSlotMachineSetupTask(SLOTTASK_GFX_INIT, 0);
gMain.state++;
}
break;
case 1:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
{
- sSlotMachineState->field_10 = CreateTask(MainTask_SlotsGameLoop, 0);
- sSlotMachineState->field_11 = CreateTask(sub_8140060, 1);
- SetMainCallback2(sub_813F94C);
+ sSlotMachineState->taskId = CreateTask(MainTask_SlotsGameLoop, 0);
+ sSlotMachineState->spinReelsTaskId = CreateTask(Task_SpinReels, 1);
+ SetMainCallback2(CB2_RunSlotMachine);
}
break;
}
}
-static void sub_813F92C(void)
+static void CleanSupSlotMachineState(void)
{
- sub_8141094();
+ DestroySlotMachine();
if (sSlotMachineState != NULL)
{
Free(sSlotMachineState);
@@ -745,7 +859,7 @@ static void sub_813F92C(void)
}
}
-static void sub_813F94C(void)
+static void CB2_RunSlotMachine(void)
{
RunTasks();
AnimateSprites();
@@ -760,6 +874,7 @@ static void MainTask_SlotsGameLoop(u8 taskId)
switch (data[0])
{
case 0:
+ // Betting Phase
if (GetCoins() == 0)
{
SetMainTask(MainTask_NoCoinsGameOver);
@@ -769,8 +884,8 @@ static void MainTask_SlotsGameLoop(u8 taskId)
sSlotMachineState->bet++;
RemoveCoins(1);
PlaySE(SE_REGI);
- sub_8141148(8, 0);
- sub_8141148(2, 1);
+ SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0);
+ SetSlotMachineSetupTask(SLOTTASK_UPDATE_LINE_LIGHTS, 1);
data[0] = 1;
}
else if (JOY_NEW(R_BUTTON))
@@ -787,8 +902,8 @@ static void MainTask_SlotsGameLoop(u8 taskId)
SetCoins(0);
}
PlaySE(SE_REGI);
- sub_8141148(8, 0);
- sub_8141148(2, 1);
+ SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0);
+ SetSlotMachineSetupTask(SLOTTASK_UPDATE_LINE_LIGHTS, 1);
data[0] = 1;
}
else if (JOY_NEW(A_BUTTON) && sSlotMachineState->bet != 0)
@@ -805,7 +920,7 @@ static void MainTask_SlotsGameLoop(u8 taskId)
}
break;
case 1:
- if (!sub_8141180(0) && !sub_8141180(1))
+ if (!IsSlotMachineSetupTaskActive(0) && !IsSlotMachineSetupTaskActive(1))
{
if (sSlotMachineState->bet == 3 || GetCoins() == 0)
data[0] = 2;
@@ -814,41 +929,41 @@ static void MainTask_SlotsGameLoop(u8 taskId)
}
break;
case 2:
- sub_811539C();
- sub_81409B4();
- sub_8140148();
- sSlotMachineState->field_06 = 0;
- sub_8141148(3, 0);
+ SetQLPlayedTheSlots();
+ CalcSlotBias();
+ StartReels();
+ sSlotMachineState->currentReel = 0;
+ SetSlotMachineSetupTask(SLOTTASK_CLEFAIRY_BOUNCE, 0);
data[0] = 3;
break;
case 3:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
{
if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_JYUNI);
- sub_814016C(sSlotMachineState->field_06, sSlotMachineState->field_06);
- sub_8141C30(sSlotMachineState->field_06, 0);
+ StopCurrentReel(sSlotMachineState->currentReel, sSlotMachineState->currentReel);
+ PressReelButton(sSlotMachineState->currentReel, 0);
data[0] = 4;
}
}
break;
case 4:
- if (sub_81401A0(sSlotMachineState->field_06) == 0 && !sub_8141180(0))
+ if (IsReelSpinning(sSlotMachineState->currentReel) == 0 && !IsSlotMachineSetupTaskActive(0))
{
- sSlotMachineState->field_06++;
- if (sSlotMachineState->field_06 >= 3)
+ sSlotMachineState->currentReel++;
+ if (sSlotMachineState->currentReel >= 3)
{
- sSlotMachineState->slotRewardClass = sub_8140A80();
+ sSlotMachineState->slotRewardClass = CalcPayout();
sSlotMachineState->bet = 0;
- sSlotMachineState->field_06 = 0;
- if (sSlotMachineState->slotRewardClass == 0)
+ sSlotMachineState->currentReel = 0;
+ if (sSlotMachineState->slotRewardClass == SLOT_PAYOUT_NONE)
SetMainTask(MainTask_DarnNoPayout);
else
{
- if (sSlotMachineState->slotRewardClass == 6)
+ if (sSlotMachineState->slotRewardClass == SLOT_PAYOUT_7)
IncrementGameStat(GAME_STAT_SLOT_JACKPOTS);
- sub_8140A70();
+ ResetMachineBias();
SetMainTask(MainTask_WinHandlePayout);
}
}
@@ -866,11 +981,11 @@ static void MainTask_NoCoinsGameOver(u8 taskId)
switch (data[0])
{
case 0:
- sub_8141148(9, 0);
+ SetSlotMachineSetupTask(SLOTTASK_MSG_NO_COINS, 0);
data[0]++;
break;
case 1:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
data[0]++;
break;
case 2:
@@ -887,22 +1002,22 @@ static void MainTask_ShowHelp(u8 taskId)
switch (data[0])
{
case 0:
- sub_8141148(14, 0);
+ SetSlotMachineSetupTask(SLOTTASK_SHOWHELP, 0);
data[0]++;
break;
case 1:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
data[0]++;
break;
case 2:
if (JOY_NEW(DPAD_LEFT))
{
- sub_8141148(15, 0);
+ SetSlotMachineSetupTask(SLOTTASK_HIDEHELP, 0);
data[0]++;
}
break;
case 3:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
SetMainTask(MainTask_SlotsGameLoop);
break;
}
@@ -915,11 +1030,11 @@ static void MainTask_ConfirmExitGame(u8 taskId)
switch (data[0])
{
case 0:
- sub_8141148(10, 0);
+ SetSlotMachineSetupTask(SLOTTASK_ASK_QUIT, 0);
data[0]++;
break;
case 1:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
data[0]++;
break;
case 2:
@@ -927,22 +1042,22 @@ static void MainTask_ConfirmExitGame(u8 taskId)
{
case 0:
AddCoins(sSlotMachineState->bet);
- sub_8141148(8, 0);
+ SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0);
data[0] = 3;
break;
case 1:
case -1:
- sub_8141148(11, 0);
+ SetSlotMachineSetupTask(SLOTTASK_DESTROY_YESNO, 0);
data[0] = 4;
break;
}
break;
case 3:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
SetMainTask(MainTask_ExitSlots);
break;
case 4:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
SetMainTask(MainTask_SlotsGameLoop);
break;
}
@@ -955,7 +1070,7 @@ static void MainTask_DarnNoPayout(u8 taskId)
switch (data[0])
{
case 0:
- sub_8141148(6, 0);
+ SetSlotMachineSetupTask(SLOTTASK_ANIM_LOSE, 0);
data[1] = 0;
data[0]++;
break;
@@ -963,14 +1078,14 @@ static void MainTask_DarnNoPayout(u8 taskId)
data[1]++;
if (data[1] > 60)
{
- sub_8141148(7, 0);
- sub_8141148(2, 1);
- sub_8141148(13, 2);
+ SetSlotMachineSetupTask(SLOTTASK_ANIM_BETTING, 0);
+ SetSlotMachineSetupTask(SLOTTASK_UPDATE_LINE_LIGHTS, 1);
+ SetSlotMachineSetupTask(SLOTTASK_RELEASE_BUTTONS, 2);
data[0]++;
}
break;
case 2:
- if (!sub_8141180(0) && !sub_8141180(1) && !sub_8141180(2))
+ if (!IsSlotMachineSetupTaskActive(0) && !IsSlotMachineSetupTaskActive(1) && !IsSlotMachineSetupTaskActive(2))
SetMainTask(MainTask_SlotsGameLoop);
break;
}
@@ -983,12 +1098,12 @@ static void MainTask_WinHandlePayout(u8 taskId)
switch (data[0])
{
case 0:
- if (sSlotMachineState->slotRewardClass == 5 || sSlotMachineState->slotRewardClass == 6)
+ if (sSlotMachineState->slotRewardClass == SLOT_PAYOUT_ROCKET || sSlotMachineState->slotRewardClass == SLOT_PAYOUT_7)
PlayFanfare(MUS_ME_B_BIG);
else
PlayFanfare(MUS_ME_B_SMALL);
- sub_8141148(8, 0);
- sub_8141148(4, 1);
+ SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0);
+ SetSlotMachineSetupTask(SLOTTASK_ANIM_WIN, 1);
data[1] = 8;
data[0]++;
break;
@@ -1003,7 +1118,7 @@ static void MainTask_WinHandlePayout(u8 taskId)
}
break;
case 2:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
{
if (IsFanfareTaskInactive() && JOY_NEW(START_BUTTON))
{
@@ -1027,28 +1142,28 @@ static void MainTask_WinHandlePayout(u8 taskId)
data[1] = 2;
}
}
- sub_8141148(8, 0);
+ SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0);
if (sSlotMachineState->payout == 0)
data[0]++;
}
break;
case 3:
- if (IsFanfareTaskInactive() && !sub_8141180(0))
+ if (IsFanfareTaskInactive() && !IsSlotMachineSetupTaskActive(0))
{
- sub_8141148(5, 0);
+ SetSlotMachineSetupTask(SLOTTASK_END_ANIM_WIN, 0);
data[0]++;
}
break;
case 4:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
{
- sub_8141148(2, 0);
- sub_8141148(13, 1);
+ SetSlotMachineSetupTask(SLOTTASK_UPDATE_LINE_LIGHTS, 0);
+ SetSlotMachineSetupTask(SLOTTASK_RELEASE_BUTTONS, 1);
data[0]++;
}
break;
case 5:
- if (!sub_8141180(0) && !sub_8141180(1))
+ if (!IsSlotMachineSetupTaskActive(0) && !IsSlotMachineSetupTaskActive(1))
SetMainTask(MainTask_SlotsGameLoop);
break;
}
@@ -1061,14 +1176,14 @@ static void MainTask_ExitSlots(u8 taskId)
switch (data[0])
{
case 0:
- sub_8141148(1, 0);
+ SetSlotMachineSetupTask(SLOTTASK_FADEOUT_EXIT, 0);
data[0]++;
break;
case 1:
- if (!sub_8141180(0))
+ if (!IsSlotMachineSetupTaskActive(0))
{
SetMainCallback2(sSlotMachineState->savedCallback);
- sub_813F92C();
+ CleanSupSlotMachineState();
}
break;
}
@@ -1076,11 +1191,11 @@ static void MainTask_ExitSlots(u8 taskId)
static void SetMainTask(TaskFunc taskFunc)
{
- gTasks[sSlotMachineState->field_10].func = taskFunc;
- gTasks[sSlotMachineState->field_10].data[0] = 0;
+ gTasks[sSlotMachineState->taskId].func = taskFunc;
+ gTasks[sSlotMachineState->taskId].data[0] = 0;
}
-static void sub_8140060(u8 taskId)
+static void Task_SpinReels(u8 taskId)
{
// taskId is never used
@@ -1088,63 +1203,63 @@ static void sub_8140060(u8 taskId)
for (i = 0; i < 3; i++)
{
- if (sSlotMachineState->field_14[i] || sSlotMachineState->field_26[i] != 0)
+ if (sSlotMachineState->reelIsSpinning[i] || sSlotMachineState->reelSubpixel[i] != 0)
{
- if (sSlotMachineState->field_26[i] != 0 || sSlotMachineState->field_20[i] != sSlotMachineState->field_2C[i])
+ if (sSlotMachineState->reelSubpixel[i] != 0 || sSlotMachineState->reelPositions[i] != sSlotMachineState->destReelPos[i])
{
- sSlotMachineState->field_26[i]++;
- if (sSlotMachineState->field_26[i] > 2)
+ sSlotMachineState->reelSubpixel[i]++;
+ if (sSlotMachineState->reelSubpixel[i] > 2)
{
- sSlotMachineState->field_26[i] = 0;
- sSlotMachineState->field_20[i]--;
- if (sSlotMachineState->field_20[i] < 0)
- sSlotMachineState->field_20[i] = 20;
+ sSlotMachineState->reelSubpixel[i] = 0;
+ sSlotMachineState->reelPositions[i]--;
+ if (sSlotMachineState->reelPositions[i] < 0)
+ sSlotMachineState->reelPositions[i] = 20;
}
- if (sSlotMachineState->field_20[i] != sSlotMachineState->field_2C[i])
+ if (sSlotMachineState->reelPositions[i] != sSlotMachineState->destReelPos[i])
continue;
}
- sSlotMachineState->field_2C[i] = 21;
- sSlotMachineState->field_14[i] = FALSE;
+ sSlotMachineState->destReelPos[i] = 21;
+ sSlotMachineState->reelIsSpinning[i] = FALSE;
}
}
- sub_8140D7C(sSlotMachineState->field_20, sSlotMachineState->field_26);
+ UpdateReelIconSprites(sSlotMachineState->reelPositions, sSlotMachineState->reelSubpixel);
}
-static void sub_8140148(void)
+static void StartReels(void)
{
s32 i;
for (i = 0; i < 3; i++)
{
- sSlotMachineState->field_14[i] = TRUE;
+ sSlotMachineState->reelIsSpinning[i] = TRUE;
}
}
-static void sub_814016C(u16 whichReel, u16 whichReel2)
+static void StopCurrentReel(u16 whichReel, u16 whichReel2)
{
switch (whichReel2)
{
case 0:
- sub_81401F0(whichReel);
+ StopReel1(whichReel);
break;
case 1:
- sub_81403BC(whichReel);
+ StopReel2(whichReel);
break;
case 2:
- sub_81404B8(whichReel);
+ StopReel3(whichReel);
break;
}
}
-static bool32 sub_81401A0(u16 whichReel)
+static bool32 IsReelSpinning(u16 whichReel)
{
- return sSlotMachineState->field_14[whichReel];
+ return sSlotMachineState->reelIsSpinning[whichReel];
}
-static s16 sub_81401B4(u16 whichReel)
+static s16 GetNextReelPosition(u16 whichReel)
{
- s16 position = sSlotMachineState->field_20[whichReel];
- if (sSlotMachineState->field_26[whichReel] != 0)
+ s16 position = sSlotMachineState->reelPositions[whichReel];
+ if (sSlotMachineState->reelSubpixel[whichReel] != 0)
{
position--;
if (position < 0)
@@ -1153,205 +1268,204 @@ static s16 sub_81401B4(u16 whichReel)
return position;
}
-static void sub_81401F0(u16 whichReel)
+static void StopReel1(u16 whichReel)
{
s32 i, j;
- s16 r2;
- u8 sp0[5];
- s16 sp0C = sub_81401B4(whichReel);
- s32 r8 = 0;
+ s16 destPos;
+ u8 posToSample[5];
+ s16 nextPos = GetNextReelPosition(whichReel);
+ s32 numPosToSample = 0;
- if (sSlotMachineState->field_08 == 0 && whichReel == 0)
+ if (sSlotMachineState->machineBias == 0 && whichReel == 0)
{
for (i = 0; i < 5; i++)
{
- for (j = 0, r2 = sp0C - i + 1; j < 3; j++, r2++)
+ for (j = 0, destPos = nextPos - i + 1; j < 3; j++, destPos++)
{
- if (r2 >= 21)
- r2 = 0;
- if (sub_81408F4(1, gUnknown_8464926[whichReel][r2]))
+ if (destPos >= 21)
+ destPos = 0;
+ if (TestReelIconAttribute(1, sReelIconAnimByReelAndPos[whichReel][destPos]))
break;
}
if (j == 3)
{
- sp0[r8] = i;
- r8++;
+ posToSample[numPosToSample] = i;
+ numPosToSample++;
}
}
}
- else if (sSlotMachineState->field_08 != 1 || whichReel == 0)
+ else if (sSlotMachineState->machineBias != 1 || whichReel == 0)
{
- for (i = 0, r2 = sp0C + 1; i < 3; i++, r2++)
+ for (i = 0, destPos = nextPos + 1; i < 3; i++, destPos++)
{
- if (r2 >= 21)
- r2 = 0;
- if (sub_81408F4(sSlotMachineState->field_08, gUnknown_8464926[whichReel][r2]))
+ if (destPos >= 21)
+ destPos = 0;
+ if (TestReelIconAttribute(sSlotMachineState->machineBias, sReelIconAnimByReelAndPos[whichReel][destPos]))
{
- sp0[0] = 0;
- r8 = 1;
+ posToSample[0] = 0;
+ numPosToSample = 1;
break;
}
}
- for (i = 0, r2 = sp0C; i < 4; i++, r2--)
+ for (i = 0, destPos = nextPos; i < 4; i++, destPos--)
{
- if (r2 < 0)
- r2 = 20;
- if (sub_81408F4(sSlotMachineState->field_08, gUnknown_8464926[whichReel][r2]))
+ if (destPos < 0)
+ destPos = 20;
+ if (TestReelIconAttribute(sSlotMachineState->machineBias, sReelIconAnimByReelAndPos[whichReel][destPos]))
{
- sp0[r8] = i + 1;
- r8++;
+ posToSample[numPosToSample] = i + 1;
+ numPosToSample++;
}
}
}
- if (r8 == 0)
+ if (numPosToSample == 0)
{
- r2 = Random() % 5;
+ destPos = Random() % 5;
}
else
{
- r2 = sp0[Random() % r8];
+ destPos = posToSample[Random() % numPosToSample];
}
- r2 = sp0C - r2;
- if (r2 < 0)
- r2 += 21;
- sSlotMachineState->field_32[0] = whichReel;
- sSlotMachineState->field_2C[whichReel] = r2;
+ destPos = nextPos - destPos;
+ if (destPos < 0)
+ destPos += 21;
+ sSlotMachineState->reelStopOrder[0] = whichReel;
+ sSlotMachineState->destReelPos[whichReel] = destPos;
}
-static void sub_81403BC(u16 whichReel)
+static void StopReel2(u16 whichReel)
{
- s16 r2, r4, r7, sp10;
+ s16 pos, firstStoppedReelPos, firstStoppedReelId, nextPos;
s32 i;
- s32 r6;
- u8 sp4[5];
-
- r7 = sSlotMachineState->field_32[0];
- r4 = sSlotMachineState->field_20[r7] + 1;
- if (r4 >= 21)
- r4 = 0;
- sp10 = sub_81401B4(whichReel);
- r2 = sp10 + 1;
- if (r2 >= 21)
- r2 = 0;
- r6 = 0;
+ s32 numPossiblePositions;
+ u8 possiblePositions[5];
+
+ firstStoppedReelId = sSlotMachineState->reelStopOrder[0];
+ firstStoppedReelPos = sSlotMachineState->reelPositions[firstStoppedReelId] + 1;
+ if (firstStoppedReelPos >= 21)
+ firstStoppedReelPos = 0;
+ nextPos = GetNextReelPosition(whichReel);
+ pos = nextPos + 1;
+ if (pos >= 21)
+ pos = 0;
+ numPossiblePositions = 0;
for (i = 0; i < 5; i++)
{
- if (sub_814054C(r7, r4, whichReel, r2, sSlotMachineState->field_08))
+ if (TwoReelBiasCheck(firstStoppedReelId, firstStoppedReelPos, whichReel, pos, sSlotMachineState->machineBias))
{
- sp4[r6] = i;
- r6++;
+ possiblePositions[numPossiblePositions] = i;
+ numPossiblePositions++;
}
- r2--;
- if (r2 < 0)
- r2 = 20;
+ pos--;
+ if (pos < 0)
+ pos = 20;
}
- if (r6 == 0)
+ if (numPossiblePositions == 0)
{
- sSlotMachineState->field_38 = 0;
- if (sSlotMachineState->field_08 == 5 || sSlotMachineState->field_08 == 6)
- r2 = 4;
+ sSlotMachineState->reel2BiasInPlay = 0;
+ if (sSlotMachineState->machineBias == SLOT_PAYOUT_ROCKET || sSlotMachineState->machineBias == SLOT_PAYOUT_7)
+ pos = 4;
else
- r2 = 0;
+ pos = 0;
}
else
{
- sSlotMachineState->field_38 = 1;
- r2 = sp4[0];
+ sSlotMachineState->reel2BiasInPlay = 1;
+ pos = possiblePositions[0];
}
- r2 = sp10 - r2;
- if (r2 < 0)
- r2 += 21;
- sSlotMachineState->field_32[1] = whichReel;
- sSlotMachineState->field_2C[whichReel] = r2;
+ pos = nextPos - pos;
+ if (pos < 0)
+ pos += 21;
+ sSlotMachineState->reelStopOrder[1] = whichReel;
+ sSlotMachineState->destReelPos[whichReel] = pos;
}
-static void sub_81404B8(u16 whichReel)
+static void StopReel3(u16 whichReel)
{
s32 i;
- s32 r6;
- s32 r9;
- s32 r4;
- s32 r2;
- u8 sp0[5];
-
- r9 = sub_81401B4(whichReel);
- r4 = r9;
- r6 = 0;
+ s32 numPossiblePositions;
+ s32 nextPos;
+ s32 testPos;
+ s32 pos;
+ u8 possiblePositions[5];
+
+ nextPos = GetNextReelPosition(whichReel);
+ testPos = nextPos;
+ numPossiblePositions = 0;
for (i = 0; i < 5; i++)
{
- if (sub_81406E8(whichReel, r4, sSlotMachineState->field_08))
+ if (OneReelBiasCheck(whichReel, testPos, sSlotMachineState->machineBias))
{
- sp0[r6] = i;
- r6++;
+ possiblePositions[numPossiblePositions] = i;
+ numPossiblePositions++;
}
- r4--;
- if (r4 < 0)
- r4 = 20;
+ testPos--;
+ if (testPos < 0)
+ testPos = 20;
}
- if (r6 == 0)
+ if (numPossiblePositions == 0)
{
- if (sSlotMachineState->field_08 == 5 || sSlotMachineState->field_08 == 6)
- r2 = 4;
+ if (sSlotMachineState->machineBias == SLOT_PAYOUT_ROCKET || sSlotMachineState->machineBias == SLOT_PAYOUT_7)
+ pos = 4;
else
- r2 = 0;
+ pos = 0;
}
else
- r2 = sp0[0];
- r2 = r9 - r2;
- if (r2 < 0)
- r2 += 21;
- sSlotMachineState->field_2C[whichReel] = r2;
+ pos = possiblePositions[0];
+ pos = nextPos - pos;
+ if (pos < 0)
+ pos += 21;
+ sSlotMachineState->destReelPos[whichReel] = pos;
}
-static bool32 sub_814054C(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4)
+static bool32 TwoReelBiasCheck(s32 reel0id, s32 reel0pos, s32 reel1id, s32 reel1pos, s32 icon)
{
s32 i;
- s32 r5;
- u8 sp0[9] = {};
+ u8 icons[9] = {};
for (i = 0; i < 9; i++)
- sp0[i] = 7;
+ icons[i] = 7;
for (i = 0; i < 3; i++)
{
- sp0[3 * a0 + i] = gUnknown_8464926[a0][a1];
- sp0[3 * a2 + i] = gUnknown_8464926[a2][a3];
- a1++;
- if (a1 >= 21)
- a1 = 0;
- a3++;
- if (a3 >= 21)
- a3 = 0;
+ icons[3 * reel0id + i] = sReelIconAnimByReelAndPos[reel0id][reel0pos];
+ icons[3 * reel1id + i] = sReelIconAnimByReelAndPos[reel1id][reel1pos];
+ reel0pos++;
+ if (reel0pos >= 21)
+ reel0pos = 0;
+ reel1pos++;
+ if (reel1pos >= 21)
+ reel1pos = 0;
}
- switch (a4)
+ switch (icon)
{
case 0:
for (i = 0; i < 3; i++)
{
- if (sub_81408F4(1, sp0[i]))
+ if (TestReelIconAttribute(1, icons[i]))
return FALSE;
}
for (i = 0; i < 15; i++)
{
- if (sp0[gUnknown_8464890[i][0]] == sp0[gUnknown_8464890[i][1]])
+ if (icons[sSecondReelBiasCheckIndices[i][0]] == icons[sSecondReelBiasCheckIndices[i][1]])
return TRUE;
}
return FALSE;
case 1:
- if (a0 == 0 || a2 == 0)
+ if (reel0id == 0 || reel1id == 0)
{
- if (a0 == 1 || a2 == 1)
+ if (reel0id == 1 || reel1id == 1)
{
for (i = 0; i < 15; i += 3)
{
- if (sp0[gUnknown_8464890[i][0]] == sp0[gUnknown_8464890[i][1]])
+ if (icons[sSecondReelBiasCheckIndices[i][0]] == icons[sSecondReelBiasCheckIndices[i][1]])
return FALSE;
}
}
for (i = 0; i < 3; i++)
{
- if (sub_81408F4(a4, sp0[i]))
+ if (TestReelIconAttribute(icon, icons[i]))
return TRUE;
}
return FALSE;
@@ -1359,11 +1473,11 @@ static bool32 sub_814054C(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4)
else
return TRUE;
case 2:
- if (a0 == 2 || a2 == 2)
+ if (reel0id == 2 || reel1id == 2)
{
for (i = 0; i < 9; i++)
{
- if (sub_81408F4(a4, sp0[i]))
+ if (TestReelIconAttribute(icon, icons[i]))
return TRUE;
}
return FALSE; // wrong level
@@ -1371,239 +1485,240 @@ static bool32 sub_814054C(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4)
}
for (i = 0; i < 15; i++)
{
- if (sp0[gUnknown_8464890[i][0]] == sp0[gUnknown_8464890[i][1]] && sub_81408F4(a4, sp0[gUnknown_8464890[i][0]]))
+ if (icons[sSecondReelBiasCheckIndices[i][0]] == icons[sSecondReelBiasCheckIndices[i][1]] && TestReelIconAttribute(icon, icons[sSecondReelBiasCheckIndices[i][0]]))
return TRUE;
}
return FALSE;
}
-static bool32 sub_81406E8(s32 a0, s32 a1, s32 a2)
+static bool32 OneReelBiasCheck(s32 reelId, s32 reelPos, s32 biasIcon)
{
- u8 sp0[9];
- s32 r3, r6;
+ u8 icons[9];
+ s32 secondStoppedPos, firstStoppedPos;
s32 i;
- r6++; r6--;
- r6 = sSlotMachineState->field_20[sSlotMachineState->field_32[0]] + 1;
- r3 = sSlotMachineState->field_20[sSlotMachineState->field_32[1]] + 1;
- a1++;
- if (r6 >= 21)
- r6 = 0;
- if (r3 >= 21)
- r3 = 0;
- if (a1 >= 21)
- a1 = 0;
+ firstStoppedPos++; firstStoppedPos--;
+ firstStoppedPos = sSlotMachineState->reelPositions[sSlotMachineState->reelStopOrder[0]] + 1;
+ secondStoppedPos = sSlotMachineState->reelPositions[sSlotMachineState->reelStopOrder[1]] + 1;
+ reelPos++;
+ if (firstStoppedPos >= 21)
+ firstStoppedPos = 0;
+ if (secondStoppedPos >= 21)
+ secondStoppedPos = 0;
+ if (reelPos >= 21)
+ reelPos = 0;
for (i = 0; i < 3; i++)
{
- sp0[sSlotMachineState->field_32[0] * 3 + i] = gUnknown_8464926[sSlotMachineState->field_32[0]][r6];
- sp0[sSlotMachineState->field_32[1] * 3 + i] = gUnknown_8464926[sSlotMachineState->field_32[1]][r3];
- sp0[a0 * 3 + i] = gUnknown_8464926[a0][a1];
- if (++r6 >= 21)
- r6 = 0;
- if (++r3 >= 21)
- r3 = 0;
- if (++a1 >= 21)
- a1 = 0;
+ icons[sSlotMachineState->reelStopOrder[0] * 3 + i] = sReelIconAnimByReelAndPos[sSlotMachineState->reelStopOrder[0]][firstStoppedPos];
+ icons[sSlotMachineState->reelStopOrder[1] * 3 + i] = sReelIconAnimByReelAndPos[sSlotMachineState->reelStopOrder[1]][secondStoppedPos];
+ icons[reelId * 3 + i] = sReelIconAnimByReelAndPos[reelId][reelPos];
+ if (++firstStoppedPos >= 21)
+ firstStoppedPos = 0;
+ if (++secondStoppedPos >= 21)
+ secondStoppedPos = 0;
+ if (++reelPos >= 21)
+ reelPos = 0;
}
- switch (a2)
+ switch (biasIcon)
{
- case 0:
+ case SLOT_PAYOUT_NONE:
for (i = 0; i < 3; i++)
{
- if (sub_81408F4(1, sp0[i]))
+ if (TestReelIconAttribute(1, icons[i]))
return FALSE;
}
for (i = 0; i < 5; i++)
{
- if (sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][1]] && sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][2]])
+ if (icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][1]] && icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][2]])
return FALSE;
}
return TRUE;
- case 1:
+ case SLOT_PAYOUT_CHERRIES2:
for (i = 0; i < 5; i++)
{
- if (sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][1]] && sub_81408F4(a2, sp0[gUnknown_84648AE[i][0]]))
+ if (icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][1]] && TestReelIconAttribute(biasIcon, icons[sThirdReelBiasCheckIndices[i][0]]))
return FALSE;
}
for (i = 0; i < 3; i++)
{
- if (sub_81408F4(a2, sp0[i]))
+ if (TestReelIconAttribute(biasIcon, icons[i]))
return TRUE;
}
return FALSE;
- case 2:
+ case SLOT_PAYOUT_CHERRIES3:
for (i = 0; i < 5; i++)
{
- if (sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][1]] && sub_81408F4(a2, sp0[gUnknown_84648AE[i][0]]))
+ if (icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][1]] && TestReelIconAttribute(biasIcon, icons[sThirdReelBiasCheckIndices[i][0]]))
return TRUE;
}
return FALSE;
}
for (i = 0; i < 5; i++)
{
- if (sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][1]] && sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][2]] && sub_81408F4(a2, sp0[gUnknown_84648AE[i][0]]))
+ if (icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][1]] && icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][2]] && TestReelIconAttribute(biasIcon, icons[sThirdReelBiasCheckIndices[i][0]]))
return TRUE;
}
return FALSE;
}
-static bool32 sub_81408F4(s32 a0, s32 a1)
+static bool32 TestReelIconAttribute(s32 attr, s32 icon)
{
- switch (a0)
+ switch (attr)
{
- case 0:
- return a1 ^ 4 ? TRUE : FALSE;
- case 1:
- case 2:
- return a1 == 4 ? TRUE : FALSE;
- case 3:
- return a1 == 5 || a1 == 6 ? TRUE : FALSE;
- case 4:
- return a1 == 2 || a1 == 3 ? TRUE : FALSE;
- case 5:
- return a1 == 1 ? TRUE : FALSE;
- case 6:
- return a1 == 0 ? TRUE : FALSE;
+ case SLOT_PAYOUT_NONE:
+ return icon ^ 4 ? TRUE : FALSE;
+ case SLOT_PAYOUT_CHERRIES2:
+ case SLOT_PAYOUT_CHERRIES3:
+ return icon == SLOT_IMAGE_CHERRIES ? TRUE : FALSE;
+ case SLOT_PAYOUT_MAGSHELL:
+ return icon == SLOT_IMAGE_MAGNEMITE || icon == SLOT_IMAGE_SHELLDER ? TRUE : FALSE;
+ case SLOT_PAYOUT_PIKAPSY:
+ return icon == SLOT_IMAGE_PIKACHU || icon == SLOT_IMAGE_PSYDUCK ? TRUE : FALSE;
+ case SLOT_PAYOUT_ROCKET:
+ return icon == SLOT_IMAGE_ROCKET ? TRUE : FALSE;
+ case SLOT_PAYOUT_7:
+ return icon == SLOT_IMAGE_7 ? TRUE : FALSE;
default:
return FALSE;
}
}
-static u8 sub_814096C(s32 a0)
+static u8 ReelIconToPayoutRank(s32 iconId)
{
- switch (a0)
+ switch (iconId)
{
default:
- case 4:
- return 1;
- case 5:
- case 6:
- return 3;
- case 2:
- case 3:
- return 4;
- case 1:
- return 5;
- case 0:
- return 6;
+ case SLOT_IMAGE_CHERRIES:
+ return SLOT_PAYOUT_CHERRIES2;
+ case SLOT_IMAGE_MAGNEMITE:
+ case SLOT_IMAGE_SHELLDER:
+ return SLOT_PAYOUT_MAGSHELL;
+ case SLOT_IMAGE_PIKACHU:
+ case SLOT_IMAGE_PSYDUCK:
+ return SLOT_PAYOUT_PIKAPSY;
+ case SLOT_IMAGE_ROCKET:
+ return SLOT_PAYOUT_ROCKET;
+ case SLOT_IMAGE_7:
+ return SLOT_PAYOUT_7;
}
}
-static void sub_81409B4(void)
+static void CalcSlotBias(void)
{
- u16 r2 = Random() / 4;
+ u16 rval = Random() / 4;
s32 i;
- const u16 * r4 = gUnknown_84648D2[sSlotMachineState->machineidx];
+ const u16 * biasChances = sReelBiasChances[sSlotMachineState->machineidx];
for (i = 0; i < 6; i++)
{
- if (r2 < r4[i])
+ if (rval < biasChances[i])
break;
}
- if (sSlotMachineState->field_08 < 5)
+ if (sSlotMachineState->machineBias < SLOT_PAYOUT_ROCKET)
{
- if (sSlotMachineState->field_0C == 0)
+ if (sSlotMachineState->biasCooldown == 0)
{
- if ((Random() & 0x3FFF) < r4[6])
- sSlotMachineState->field_0C = (Random() & 1) ? 5 : 60;
+ if ((Random() & 0x3FFF) < biasChances[SLOT_PAYOUT_7])
+ sSlotMachineState->biasCooldown = (Random() & 1) ? 5 : 60;
}
- if (sSlotMachineState->field_0C != 0)
+ if (sSlotMachineState->biasCooldown != 0)
{
- if (i == 0 && (Random() & 0x3FFF) < 0x2CCC)
- sSlotMachineState->field_0C = (Random() & 1) ? 5 : 60;
- sSlotMachineState->field_0C--;
+ if (i == 0 && (Random() & 0x3FFF) < 0x2CCC) // 70%
+ sSlotMachineState->biasCooldown = (Random() & 1) ? 5 : 60;
+ sSlotMachineState->biasCooldown--;
}
- sSlotMachineState->field_08 = i;
+ sSlotMachineState->machineBias = i;
}
}
-static void sub_8140A70(void)
+static void ResetMachineBias(void)
{
- sSlotMachineState->field_08 = 0;
+ sSlotMachineState->machineBias = 0;
}
-static u16 sub_8140A80(void)
+static u16 CalcPayout(void)
{
- u8 sp0[9] = {};
+ u8 visibleIcons[9] = {};
s32 i;
- s32 r4, r3, r2;
- s32 r9;
+ s32 reel1pos, reel2pos, reel3pos;
+ s32 bestMatch;
for (i = 0; i < 5; i++)
- sSlotMachineState->field_3C[i] = 0;
+ sSlotMachineState->winFlags[i] = FALSE;
- r9 = 0;
- r4 = sSlotMachineState->field_20[0];
- r3 = sSlotMachineState->field_20[1];
- r2 = sSlotMachineState->field_20[2];
+ bestMatch = 0;
+ reel1pos = sSlotMachineState->reelPositions[0];
+ reel2pos = sSlotMachineState->reelPositions[1];
+ reel3pos = sSlotMachineState->reelPositions[2];
for (i = 0; i < 3; i++)
{
- r4++;
- if (r4 >= 21)
- r4 = 0;
- r3++;
- if (r3 >= 21)
- r3 = 0;
- r2++;
- if (r2 >= 21)
- r2 = 0;
- sp0[0 * 3 + i] = gUnknown_8464926[0][r4];
- sp0[1 * 3 + i] = gUnknown_8464926[1][r3];
- sp0[2 * 3 + i] = gUnknown_8464926[2][r2];
+ reel1pos++;
+ if (reel1pos >= 21)
+ reel1pos = 0;
+ reel2pos++;
+ if (reel2pos >= 21)
+ reel2pos = 0;
+ reel3pos++;
+ if (reel3pos >= 21)
+ reel3pos = 0;
+ visibleIcons[0 * 3 + i] = sReelIconAnimByReelAndPos[0][reel1pos];
+ visibleIcons[1 * 3 + i] = sReelIconAnimByReelAndPos[1][reel2pos];
+ visibleIcons[2 * 3 + i] = sReelIconAnimByReelAndPos[2][reel3pos];
}
sSlotMachineState->payout = 0;
for (i = 0; i < 5; i++)
{
- if (sSlotMachineState->bet >= gUnknown_84648BD[i][3])
+ if (sSlotMachineState->bet >= sRowAttributes[i][ROWATTR_MINBET])
{
- if (sub_81408F4(1, sp0[gUnknown_84648BD[i][0]]))
- r3 = sub_81408F4(2, sp0[gUnknown_84648BD[i][1]]) ? 2 : 1;
- else if (sp0[gUnknown_84648BD[i][0]] == sp0[gUnknown_84648BD[i][1]] && sp0[gUnknown_84648BD[i][0]] == sp0[gUnknown_84648BD[i][2]])
- r3 = sub_814096C(sp0[gUnknown_84648BD[i][0]]);
+ int curMatch;
+ if (TestReelIconAttribute(1, visibleIcons[sRowAttributes[i][ROWATTR_COL1POS]]))
+ curMatch = TestReelIconAttribute(2, visibleIcons[sRowAttributes[i][ROWATTR_COL2POS]]) ? 2 : 1;
+ else if (visibleIcons[sRowAttributes[i][ROWATTR_COL1POS]] == visibleIcons[sRowAttributes[i][ROWATTR_COL2POS]] && visibleIcons[sRowAttributes[i][ROWATTR_COL1POS]] == visibleIcons[sRowAttributes[i][ROWATTR_COL3POS]])
+ curMatch = ReelIconToPayoutRank(visibleIcons[sRowAttributes[i][ROWATTR_COL1POS]]);
else
- r3 = 0;
- if (r3 != 0)
+ curMatch = 0;
+ if (curMatch != 0)
{
- sSlotMachineState->field_3C[i] = 1;
- sSlotMachineState->payout += gUnknown_8464966[r3];
+ sSlotMachineState->winFlags[i] = TRUE;
+ sSlotMachineState->payout += sPayoutTable[curMatch];
}
- if (r3 > r9)
- r9 = r3;
+ if (curMatch > bestMatch)
+ bestMatch = curMatch;
}
}
- return r9;
+ return bestMatch;
}
-static u16 sub_8140BDC(void)
+static u16 GetPayout(void)
{
return sSlotMachineState->payout;
}
-static u8 sub_8140BEC(void)
+static u8 GetPlayerBet(void)
{
return sSlotMachineState->bet;
}
-static bool32 sub_8140BF8(s32 a0)
+static bool32 GetWinFlagByLine(int a0)
{
- return sSlotMachineState->field_3C[a0];
+ return sSlotMachineState->winFlags[a0];
}
-static bool32 sub_8140C0C(void)
+static bool32 LoadSpriteGraphicsAndAllocateManager(void)
{
s32 i;
- for (i = 0; i < NELEMS(gUnknown_84655B0); i++)
- LoadCompressedSpriteSheet(&gUnknown_84655B0[i]);
- LoadSpritePalettes(gUnknown_84655C8);
+ for (i = 0; i < NELEMS(sSpriteSheets); i++)
+ LoadCompressedSpriteSheet(&sSpriteSheets[i]);
+ LoadSpritePalettes(sSpritePalettes);
sSlotMachineGfxManager = Alloc(sizeof(*sSlotMachineGfxManager));
if (sSlotMachineGfxManager == NULL)
return FALSE;
- sub_8140C6C(sSlotMachineGfxManager);
+ InitGfxManager(sSlotMachineGfxManager);
return TRUE;
}
-static void sub_8140C50(void)
+static void DestroyGfxManager(void)
{
if (sSlotMachineGfxManager != NULL)
{
@@ -1612,7 +1727,7 @@ static void sub_8140C50(void)
}
}
-static void sub_8140C6C(struct SlotMachineGfxManager * manager)
+static void InitGfxManager(struct SlotMachineGfxManager * manager)
{
s32 i, j;
@@ -1621,12 +1736,12 @@ static void sub_8140C6C(struct SlotMachineGfxManager * manager)
manager->field_00[i] = 0;
for (j = 0; j < 5; j++)
{
- manager->field_0C[i][j] = NULL;
+ manager->reelIconSprites[i][j] = NULL;
}
}
}
-static void sub_8140CA0(void)
+static void CreateReelIconSprites(void)
{
struct Sprite * sprite;
s32 i, j;
@@ -1636,87 +1751,87 @@ static void sub_8140CA0(void)
{
for (j = 0; j < 5; j++)
{
- spriteId = CreateSprite(&gUnknown_84657E4, 80 + 40 * i, 44 + 24 * j, 2);
- animId = gUnknown_8464926[i][j];
+ spriteId = CreateSprite(&sSpriteTemplate_ReelIcons, 80 + 40 * i, 44 + 24 * j, 2);
+ animId = sReelIconAnimByReelAndPos[i][j];
sprite = &gSprites[spriteId];
StartSpriteAnim(sprite, animId);
- sprite->oam.paletteNum = IndexOfSpritePaletteTag(gUnknown_8465608[animId]);
+ sprite->oam.paletteNum = IndexOfSpritePaletteTag(sReelIconPaletteTags[animId]);
sprite->data[0] = i;
sprite->data[1] = j;
sprite->data[2] = j;
sprite->data[3] = 0;
sprite->oam.matrixNum = 0;
- sSlotMachineGfxManager->field_0C[i][j] = sprite;
- sSlotMachineGfxManager->field_70 = (vu16 *)(OAM + 0 * sizeof(struct OamData) + offsetof(struct OamData, affineParam));
+ sSlotMachineGfxManager->reelIconSprites[i][j] = sprite;
+ sSlotMachineGfxManager->reelIconAffineParamPtr = (vu16 *)(OAM + 0 * sizeof(struct OamData) + offsetof(struct OamData, affineParam));
}
}
}
-static void sub_8140D7C(const s16 * a0, const s16 * a1)
+static void UpdateReelIconSprites(const s16 * reelPosPtr, const s16 * yposPtr)
{
s32 i, j;
- s32 r6, r10;
+ s32 reelPos, ypos;
for (i = 0; i < 3; i++)
{
- r6 = *a0;
- r10 = *a1 * 8;
+ reelPos = *reelPosPtr;
+ ypos = *yposPtr * 8;
for (j = 0; j < 5; j++)
{
- sSlotMachineGfxManager->field_0C[i][j]->pos2.y = r10;
+ sSlotMachineGfxManager->reelIconSprites[i][j]->pos2.y = ypos;
{
- s32 r4 = gUnknown_8464926[i][r6];
- struct Sprite * sprite = sSlotMachineGfxManager->field_0C[i][j];
- StartSpriteAnim(sprite, r4);
+ s32 animId = sReelIconAnimByReelAndPos[i][reelPos];
+ struct Sprite * sprite = sSlotMachineGfxManager->reelIconSprites[i][j];
+ StartSpriteAnim(sprite, animId);
}
{
- s32 r4 = gUnknown_8464926[i][r6];
- struct Sprite * sprite = sSlotMachineGfxManager->field_0C[i][j];
- StartSpriteAnim(sprite, r4);
+ s32 animId = sReelIconAnimByReelAndPos[i][reelPos];
+ struct Sprite * sprite = sSlotMachineGfxManager->reelIconSprites[i][j];
+ StartSpriteAnim(sprite, animId);
}
- sSlotMachineGfxManager->field_0C[i][j]->oam.paletteNum = IndexOfSpritePaletteTag(gUnknown_8465608[gUnknown_8464926[i][r6]]);
- r6++;
- if (r6 >= 21)
- r6 = 0;
+ sSlotMachineGfxManager->reelIconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag(sReelIconPaletteTags[sReelIconAnimByReelAndPos[i][reelPos]]);
+ reelPos++;
+ if (reelPos >= 21)
+ reelPos = 0;
}
- a0++;
- a1++;
+ reelPosPtr++;
+ yposPtr++;
}
}
-static void sub_8140E40(void)
+static void HBlankCB_SlotMachine(void)
{
s32 vcount = REG_VCOUNT - 0x2B;
- if (vcount >= 0 && vcount < 0x54)
+ if (vcount < 0x54u)
{
- *sSlotMachineGfxManager->field_70 = gUnknown_8465616[vcount];
- REG_BLDY = gUnknown_84656D6[vcount];
+ *sSlotMachineGfxManager->reelIconAffineParamPtr = sReelIconAffineParams[vcount];
+ REG_BLDY = sReelIconBldY[vcount];
}
else
{
- *sSlotMachineGfxManager->field_70 = 0x100;
+ *sSlotMachineGfxManager->reelIconAffineParamPtr = 0x100;
REG_BLDY = 0;
}
}
-static void sub_8140E9C(void)
+static void CreateScoreDigitSprites(void)
{
s32 i;
s32 spriteId;
for (i = 0; i < 4; i++)
{
- spriteId = CreateSprite(&gUnknown_846587C, 0x55 + 7 * i, 30, 0);
- sSlotMachineGfxManager->field_48[i] = &gSprites[spriteId];
- spriteId = CreateSprite(&gUnknown_846587C, 0x85 + 7 * i, 30, 0);
- sSlotMachineGfxManager->field_58[i] = &gSprites[spriteId];
+ spriteId = CreateSprite(&sSpriteTemplate_Digits, 0x55 + 7 * i, 30, 0);
+ sSlotMachineGfxManager->creditDigitSprites[i] = &gSprites[spriteId];
+ spriteId = CreateSprite(&sSpriteTemplate_Digits, 0x85 + 7 * i, 30, 0);
+ sSlotMachineGfxManager->payoutDigitSprites[i] = &gSprites[spriteId];
}
}
-static void sub_8140F2C(void)
+static void UpdateCoinsDisplay(void)
{
s32 coins = GetCoins();
- s32 payout = sub_8140BDC();
+ s32 payout = GetPayout();
s32 i;
s32 divisor = 1000;
s32 quotient;
@@ -1724,36 +1839,36 @@ static void sub_8140F2C(void)
for (i = 0; i < 4; i++)
{
quotient = coins / divisor;
- StartSpriteAnim(sSlotMachineGfxManager->field_48[i], quotient);
+ StartSpriteAnim(sSlotMachineGfxManager->creditDigitSprites[i], quotient);
coins -= quotient * divisor;
quotient = payout / divisor;
- StartSpriteAnim(sSlotMachineGfxManager->field_58[i], quotient);
+ StartSpriteAnim(sSlotMachineGfxManager->payoutDigitSprites[i], quotient);
payout -= quotient * divisor;
divisor /= 10;
}
}
-static void sub_8140FC4(void)
+static void CreateClefairySprites(void)
{
s32 spriteId;
- spriteId = CreateSprite(&gUnknown_84658D8, 0x10, 0x88, 1);
- sSlotMachineGfxManager->field_68[0] = &gSprites[spriteId];
- spriteId = CreateSprite(&gUnknown_84658D8, 0xE0, 0x88, 1);
- sSlotMachineGfxManager->field_68[1] = &gSprites[spriteId];
- sSlotMachineGfxManager->field_68[1]->hFlip = TRUE;
+ spriteId = CreateSprite(&sSpriteTemplate_Clefairy, 0x10, 0x88, 1);
+ sSlotMachineGfxManager->clefairySprites[0] = &gSprites[spriteId];
+ spriteId = CreateSprite(&sSpriteTemplate_Clefairy, 0xE0, 0x88, 1);
+ sSlotMachineGfxManager->clefairySprites[1] = &gSprites[spriteId];
+ sSlotMachineGfxManager->clefairySprites[1]->hFlip = TRUE;
}
-static void sub_8141020(u8 a0)
+static void SetClefairySpriteAnim(u8 animId)
{
s32 i;
for (i = 0; i < 2; i++)
{
- StartSpriteAnim(sSlotMachineGfxManager->field_68[i], a0);
+ StartSpriteAnim(sSlotMachineGfxManager->clefairySprites[i], animId);
}
}
-static bool32 sub_814104C(void)
+static bool32 CreateSlotMachine(void)
{
s32 i;
@@ -1761,58 +1876,58 @@ static bool32 sub_814104C(void)
if (ptr == NULL)
return FALSE;
for (i = 0; i < 8; i++)
- ptr->field_0000[i].unk3 = 0;
- ptr->field_0028 = 0;
- SetWordTaskArg(CreateTask(sub_81410CC, 2), 0, (uintptr_t)ptr);
+ ptr->tasks[i].active = 0;
+ ptr->yesNoMenuActive = FALSE;
+ SetWordTaskArg(CreateTask(Task_SlotMachine, 2), 0, (uintptr_t)ptr);
return FALSE;
}
-static void sub_8141094(void)
+static void DestroySlotMachine(void)
{
- if (FuncIsActiveTask(sub_81410CC))
+ if (FuncIsActiveTask(Task_SlotMachine))
{
- Free(sub_814112C());
- DestroyTask(FindTaskIdByFunc(sub_81410CC));
+ Free(GetSlotMachineSetupTaskDataPtr());
+ DestroyTask(FindTaskIdByFunc(Task_SlotMachine));
}
- sub_8140C50();
+ DestroyGfxManager();
FreeAllWindowBuffers();
}
-static void sub_81410CC(u8 taskId)
+static void Task_SlotMachine(u8 taskId)
{
struct SlotMachineSetupTaskData * ptr = (void *)GetWordTaskArg(taskId, 0);
s32 i;
for (i = 0; i < 8; i++)
{
- if (ptr->field_0000[i].unk3)
- ptr->field_0000[i].unk3 = gUnknown_84658F0[ptr->field_0000[i].unk0](&ptr->field_0000[i].unk2, ptr);
+ if (ptr->tasks[i].active)
+ ptr->tasks[i].active = sSlotMachineSetupTasks[ptr->tasks[i].funcno](&ptr->tasks[i].state, ptr);
}
}
-static void sub_8141118(void)
+static void VBlankCB_SlotMachine(void)
{
TransferPlttBuffer();
LoadOam();
ProcessSpriteCopyRequests();
}
-static struct SlotMachineSetupTaskData * sub_814112C(void)
+static struct SlotMachineSetupTaskData * GetSlotMachineSetupTaskDataPtr(void)
{
- return (void *)GetWordTaskArg(FindTaskIdByFunc(sub_81410CC), 0);
+ return (void *)GetWordTaskArg(FindTaskIdByFunc(Task_SlotMachine), 0);
}
-static void sub_8141148(u16 a0, u8 a1)
+static void SetSlotMachineSetupTask(u16 funcno, u8 taskId)
{
- struct SlotMachineSetupTaskData * ptr = sub_814112C();
- ptr->field_0000[a1].unk0 = a0;
- ptr->field_0000[a1].unk2 = 0;
- ptr->field_0000[a1].unk3 = gUnknown_84658F0[a0](&ptr->field_0000[a1].unk2, ptr);
+ struct SlotMachineSetupTaskData * ptr = GetSlotMachineSetupTaskDataPtr();
+ ptr->tasks[taskId].funcno = funcno;
+ ptr->tasks[taskId].state = 0;
+ ptr->tasks[taskId].active = sSlotMachineSetupTasks[funcno](&ptr->tasks[taskId].state, ptr);
}
-static bool32 sub_8141180(u8 a0)
+static bool32 IsSlotMachineSetupTaskActive(u8 taskId)
{
- return sub_814112C()->field_0000[a0].unk3;
+ return GetSlotMachineSetupTaskDataPtr()->tasks[taskId].active;
}
static inline void LoadColor(u16 color, u16 *pal)
@@ -1821,7 +1936,7 @@ static inline void LoadColor(u16 color, u16 *pal)
LoadPalette(pal, 0x00, 0x02);
}
-static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_GraphicsInit(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
u16 pal[2];
u8 textColor[3];
@@ -1842,54 +1957,54 @@ static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr)
RequestDma3Fill(0, (void *)(VRAM + 0xC000), 0x20, 1);
SetGpuReg(REG_OFFSET_DISPCNT, 0);
ResetBgPositions();
- ResetBgsAndClearDma3BusyFlags(0);
- InitBgsFromTemplates(0, gUnknown_8466B10, NELEMS(gUnknown_8466B10));
- InitWindows(gUnknown_8466B20);
+ ResetBgsAndClearDma3BusyFlags(FALSE);
+ InitBgsFromTemplates(0, sBgTemplates, NELEMS(sBgTemplates));
+ InitWindows(sWindowTemplates);
- SetBgTilemapBuffer(3, ptr->field_205C);
+ SetBgTilemapBuffer(3, ptr->bg3TilemapBuffer);
FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 32, 32);
CopyBgTilemapBufferToVram(3);
ResetTempTileDataBuffers();
- DecompressAndCopyTileDataToVram(2, gUnknown_84659D0, 0, 0x00, 0);
- DecompressAndCopyTileDataToVram(2, gUnknown_846653C, 0, 0xC0, 0);
- SetBgTilemapBuffer(2, ptr->field_185C);
- CopyToBgTilemapBuffer(2, gUnknown_84661D4, 0, 0x00);
+ DecompressAndCopyTileDataToVram(2, sBg2Tiles_00, 0, 0x00, 0);
+ DecompressAndCopyTileDataToVram(2, sBg2Tiles_C0, 0, 0xC0, 0);
+ SetBgTilemapBuffer(2, ptr->bg2TilemapBuffer);
+ CopyToBgTilemapBuffer(2, sBg2Map, 0, 0x00);
CopyBgTilemapBufferToVram(2);
- LoadPalette(gUnknown_8465930, 0x00, 0xA0);
- LoadPalette(gUnknown_84664BC, 0x50, 0x20);
- LoadPalette(gUnknown_84665C0, 0x70, 0x60);
+ LoadPalette(sBgPal_00, 0x00, 0xA0);
+ LoadPalette(sBgPal_50, 0x50, 0x20);
+ LoadPalette(sBgPal_70, 0x70, 0x60);
LoadColor(RGB(30, 30, 31), pal);
LoadUserWindowBorderGfx(0, 0x00A, 0xD0);
- sub_814FDA0(0, 0x001, 0xF0);
+ DrawWindowBorderWithStdpal3(0, 0x001, 0xF0);
- SetBgTilemapBuffer(0, ptr->field_085C);
+ SetBgTilemapBuffer(0, ptr->bg0TilemapBuffer);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 2, 32, 30);
- DecompressAndCopyTileDataToVram(1, gUnknown_8466620, 0, 0, 0);
- DecompressAndCopyTileDataToVram(1, gUnknown_8466998, 0, 0, 1);
+ DecompressAndCopyTileDataToVram(1, sBg1Tiles, 0, 0, 0);
+ DecompressAndCopyTileDataToVram(1, sBg1Map, 0, 0, 1);
CopyBgTilemapBufferToVram(1);
LoadPalette(stdpal_get(2), 0xE0, 0x20);
FillWindowPixelBuffer(1, 0xFF);
PutWindowTilemap(1);
- x = 0xEC - GetStringWidth(0, gString_SlotMachineControls, 0);
- textColor[0] = 15;
- textColor[1] = 1;
- textColor[2] = 2;
+ x = 236 - GetStringWidth(0, gString_SlotMachineControls, 0);
+ textColor[0] = TEXT_DYNAMIC_COLOR_6;
+ textColor[1] = TEXT_COLOR_WHITE;
+ textColor[2] = TEXT_COLOR_DARK_GREY;
AddTextPrinterParameterized3(1, 0, x, 0, textColor, 0, gString_SlotMachineControls);
CopyBgTilemapBufferToVram(0);
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | 0x20 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD | BLDCNT_EFFECT_DARKEN);
- sub_8140C0C();
- sub_8140CA0();
- sub_8140E9C();
- sub_8140FC4();
- sub_8140F2C();
+ LoadSpriteGraphicsAndAllocateManager();
+ CreateReelIconSprites();
+ CreateScoreDigitSprites();
+ CreateClefairySprites();
+ UpdateCoinsDisplay();
BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK);
- SetVBlankCallback(sub_8141118);
- SetHBlankCallback(sub_8140E40);
+ SetVBlankCallback(VBlankCB_SlotMachine);
+ SetHBlankCallback(HBlankCB_SlotMachine);
(*state)++;
break;
case 2:
@@ -1899,7 +2014,7 @@ static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr)
ShowBg(3);
ShowBg(2);
HideBg(1);
- sub_8141B34();
+ InitReelButtonTileMem();
BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK);
BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK);
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK);
@@ -1915,7 +2030,7 @@ static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_8141460(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_FadeOut(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
@@ -1931,12 +2046,12 @@ static bool8 sub_8141460(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_81414AC(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_UpdateLineStates(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
case 0:
- sub_8141834(GetBgTilemapBuffer(2));
+ SetLineStatesByBet(GetBgTilemapBuffer(2));
CopyBgTilemapBufferToVram(2);
(*state)++;
break;
@@ -1948,31 +2063,31 @@ static bool8 sub_81414AC(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_81414EC(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_ClefairyUpdateOnReelsStart(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
- sub_8141020(1);
+ SetClefairySpriteAnim(1);
return FALSE;
}
-static bool8 sub_81414FC(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_StartClefairyDanceAndWinningLineFlash(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
- sub_8141020(2);
- CreateTask(sub_814191C, 3);
+ SetClefairySpriteAnim(2);
+ CreateTask(Task_FlashWinningLine, 3);
return FALSE;
}
-static bool8 sub_8141518(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_StopWinningLineFlashTask(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
case 0:
- sub_8141AB0();
+ SignalStopWinningLineFlashTask();
(*state)++;
break;
case 1:
- if (!FuncIsActiveTask(sub_814191C))
+ if (!FuncIsActiveTask(Task_FlashWinningLine))
{
- sub_8141020(0);
+ SetClefairySpriteAnim(0);
return FALSE;
}
break;
@@ -1980,30 +2095,30 @@ static bool8 sub_8141518(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_8141558(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_ClefairyFainted(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
- sub_8141020(3);
+ SetClefairySpriteAnim(3);
return FALSE;
}
-static bool8 sub_8141568(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_ClefairyNeutral(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
- sub_8141020(FALSE);
+ SetClefairySpriteAnim(0);
return FALSE;
}
-static bool8 sub_8141578(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_UpdateCoinsDisplay(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
- sub_8140F2C();
+ UpdateCoinsDisplay();
return FALSE;
}
-static bool8 sub_8141584(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_MessageOutOfCoins(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
case 0:
- sub_81417E4(gString_OutOfCoins);
+ Slot_PrintOnWindow0(gString_OutOfCoins);
CopyWindowToVram(0, 3);
(*state)++;
break;
@@ -2015,13 +2130,13 @@ static bool8 sub_8141584(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_81415C8(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_AskQuitPlaying(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
case 0:
- sub_81417E4(gString_QuitPlaying);
- sub_8141AD8(0);
+ Slot_PrintOnWindow0(gString_QuitPlaying);
+ Slot_CreateYesNoMenu(0);
CopyWindowToVram(0, 3);
(*state)++;
break;
@@ -2033,13 +2148,13 @@ static bool8 sub_81415C8(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_8141610(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_DestroyYesNoMenu(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
case 0:
- sub_8141828();
- sub_8141B18();
+ Slot_ClearWindow0();
+ Slot_DestroyYesNoMenu();
CopyWindowToVram(0, 3);
(*state)++;
break;
@@ -2051,12 +2166,12 @@ static bool8 sub_8141610(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_8141650(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_PressReelButton(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
case 0:
- sub_8141BA0(ptr->field_0020);
+ SetReelButtonPressed(ptr->reelButtonToPress);
CopyBgTilemapBufferToVram(2);
(*state)++;
break;
@@ -2068,12 +2183,12 @@ static bool8 sub_8141650(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_8141690(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_ReleaseReelButtons(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
case 0:
- sub_8141BE4();
+ ReleaseReelButtons();
CopyBgTilemapBufferToVram(2);
(*state)++;
break;
@@ -2085,30 +2200,30 @@ static bool8 sub_8141690(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_81416C8(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_ShowHelp(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
case 0:
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
- SetGpuReg(REG_OFFSET_WININ, 0x3F);
- SetGpuReg(REG_OFFSET_WINOUT, 0x3D);
- SetGpuReg(REG_OFFSET_WIN0H, 0x00);
- SetGpuReg(REG_OFFSET_WIN1H, 0xA0);
+ SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR);
+ SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
+ SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, 0));
+ SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE(0, 160));
ShowBg(1);
PlaySE(SE_WIN_OPEN);
- ptr->field_0024 = 0;
+ ptr->bg1X = 0;
(*state)++;
break;
case 1:
- ptr->field_0024 += 16;
- if (ptr->field_0024 >= 256)
+ ptr->bg1X += 16;
+ if (ptr->bg1X >= 256)
{
- ptr->field_0024 = 256;
+ ptr->bg1X = 256;
(*state)++;
}
- ChangeBgX(1, 256 * (256 - ptr->field_0024), 0);
- SetGpuReg(REG_OFFSET_WIN0H, ptr->field_0024);
+ ChangeBgX(1, 256 * (256 - ptr->bg1X), 0);
+ SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, ptr->bg1X));
break;
case 2:
return FALSE;
@@ -2116,7 +2231,7 @@ static bool8 sub_81416C8(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static bool8 sub_8141764(u8 * state, struct SlotMachineSetupTaskData * ptr)
+static bool8 SlotsTask_HideHelp(u8 * state, struct SlotMachineSetupTaskData * ptr)
{
switch (*state)
{
@@ -2125,14 +2240,14 @@ static bool8 sub_8141764(u8 * state, struct SlotMachineSetupTaskData * ptr)
(*state)++;
// fallthrough
case 1:
- ptr->field_0024 -= 16;
- if (ptr->field_0024 <= 0)
+ ptr->bg1X -= 16;
+ if (ptr->bg1X <= 0)
{
- ptr->field_0024 = 0;
+ ptr->bg1X = 0;
(*state)++;
}
- ChangeBgX(1, 256 * (256 - ptr->field_0024), 0);
- SetGpuReg(REG_OFFSET_WIN0H, ptr->field_0024);
+ ChangeBgX(1, 256 * (256 - ptr->bg1X), 0);
+ SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, ptr->bg1X));
break;
case 2:
HideBg(1);
@@ -2145,49 +2260,49 @@ static bool8 sub_8141764(u8 * state, struct SlotMachineSetupTaskData * ptr)
return TRUE;
}
-static void sub_81417E4(const u8 * str)
+static void Slot_PrintOnWindow0(const u8 * str)
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
PutWindowTilemap(0);
DrawTextBorderOuter(0, 0x001, 15);
- AddTextPrinterParameterized5(0, 2, str, 1, 2, -1, NULL, 1, 2);
+ AddTextPrinterParameterized5(0, 2, str, 1, 2, TEXT_SPEED_FF, NULL, 1, 2);
}
-static void sub_8141828(void)
+static void Slot_ClearWindow0(void)
{
rbox_fill_rectangle(0);
}
-static void sub_8141834(u16 * bgTilemapBuffer)
+static void SetLineStatesByBet(u16 * bgTilemapBuffer)
{
- switch (sub_8140BEC())
+ switch (GetPlayerBet())
{
case 0:
- sub_81418C4(bgTilemapBuffer, 0, 4);
- sub_81418C4(bgTilemapBuffer, 1, 4);
- sub_81418C4(bgTilemapBuffer, 2, 4);
- sub_81418C4(bgTilemapBuffer, 3, 4);
- sub_81418C4(bgTilemapBuffer, 4, 4);
+ SetLineState(bgTilemapBuffer, 0, 4);
+ SetLineState(bgTilemapBuffer, 1, 4);
+ SetLineState(bgTilemapBuffer, 2, 4);
+ SetLineState(bgTilemapBuffer, 3, 4);
+ SetLineState(bgTilemapBuffer, 4, 4);
break;
case 3:
- sub_81418C4(bgTilemapBuffer, 0, 5);
- sub_81418C4(bgTilemapBuffer, 4, 5);
+ SetLineState(bgTilemapBuffer, 0, 5);
+ SetLineState(bgTilemapBuffer, 4, 5);
case 2:
- sub_81418C4(bgTilemapBuffer, 1, 5);
- sub_81418C4(bgTilemapBuffer, 3, 5);
+ SetLineState(bgTilemapBuffer, 1, 5);
+ SetLineState(bgTilemapBuffer, 3, 5);
case 1:
- sub_81418C4(bgTilemapBuffer, 2, 5);
+ SetLineState(bgTilemapBuffer, 2, 5);
break;
}
}
-static void sub_81418C4(u16 * bgTilemapBuffer, u16 whichLine, u16 paletteNum)
+static void SetLineState(u16 * bgTilemapBuffer, u16 whichLine, u16 paletteNum)
{
s32 i;
- const u16 * tileIdxs = gUnknown_8466C0C[whichLine].tiles;
+ const u16 * tileIdxs = sLineStateTileIdxs[whichLine].tiles;
u16 palMask = (paletteNum & 0xF) << 12;
- for (i = 0; i < gUnknown_8466C0C[whichLine].count; i++)
+ for (i = 0; i < sLineStateTileIdxs[whichLine].count; i++)
{
bgTilemapBuffer[*tileIdxs] &= 0x0FFF;
bgTilemapBuffer[*tileIdxs] |= palMask;
@@ -2195,7 +2310,7 @@ static void sub_81418C4(u16 * bgTilemapBuffer, u16 whichLine, u16 paletteNum)
}
}
-static void sub_814191C(u8 taskId)
+static void Task_FlashWinningLine(u8 taskId)
{
s16 * data = gTasks[taskId].data;
s32 i;
@@ -2203,11 +2318,11 @@ static void sub_814191C(u8 taskId)
switch (data[0])
{
case 0:
- LoadPalette(gUnknown_84664BC, 0x60, 0x20);
+ LoadPalette(sBgPal_50, 0x60, 0x20);
for (i = 0; i < 5; i++)
{
- if (sub_8140BF8(i))
- sub_81418C4(GetBgTilemapBuffer(2), i, 6);
+ if (GetWinFlagByLine(i))
+ SetLineState(GetBgTilemapBuffer(2), i, 6);
}
CopyBgTilemapBufferToVram(2);
data[0]++;
@@ -2216,7 +2331,7 @@ static void sub_814191C(u8 taskId)
if (data[1] == 0)
{
u16 y = gSineTable[data[2]] >> 7;
- LoadPalette(&gUnknown_84664DC[16 * y], 0x10, 0x20);
+ LoadPalette(&sBgPal_VictoryFlash[16 * y], 0x10, 0x20);
data[2] += 32;
data[2] &= 0x7F;
data[1] = 8;
@@ -2243,18 +2358,18 @@ static void sub_814191C(u8 taskId)
}
}
- for (i = 0; i < NELEMS(gUnknown_8466C34); i++)
+ for (i = 0; i < NELEMS(sWInningLineFlashPalIdxs); i++)
{
- gPlttBufferFaded[gUnknown_8466C34[i] + 0x60] = gPlttBufferUnfaded[gUnknown_8466C34[i] + 0x60];
+ gPlttBufferFaded[sWInningLineFlashPalIdxs[i] + 0x60] = gPlttBufferUnfaded[sWInningLineFlashPalIdxs[i] + 0x60];
}
break;
case 2:
for (i = 0; i < 5; i++)
{
- if (sub_8140BF8(i))
- sub_81418C4(GetBgTilemapBuffer(2), i, 4);
+ if (GetWinFlagByLine(i))
+ SetLineState(GetBgTilemapBuffer(2), i, 4);
}
- LoadPalette(gUnknown_8465950, 0x10, 0x20);
+ LoadPalette(sBgPal_10, 0x10, 0x20);
CopyBgTilemapBufferToVram(2);
data[0]++;
break;
@@ -2265,78 +2380,78 @@ static void sub_814191C(u8 taskId)
}
}
-static void sub_8141AB0(void)
+static void SignalStopWinningLineFlashTask(void)
{
- gTasks[FindTaskIdByFunc(sub_814191C)].data[0] = 2;
+ gTasks[FindTaskIdByFunc(Task_FlashWinningLine)].data[0] = 2;
}
-static void sub_8141AD8(u8 cursorPos)
+static void Slot_CreateYesNoMenu(u8 cursorPos)
{
- CreateYesNoMenu(&gUnknown_8466C38, 2, 0, 2, 10, 13, cursorPos);
+ CreateYesNoMenu(&sYesNoWindowTemplate, 2, 0, 2, 10, 13, cursorPos);
Menu_MoveCursorNoWrapAround(cursorPos);
- sub_814112C()->field_0028 = TRUE;
+ GetSlotMachineSetupTaskDataPtr()->yesNoMenuActive = TRUE;
}
-static void sub_8141B18(void)
+static void Slot_DestroyYesNoMenu(void)
{
- struct SlotMachineSetupTaskData * data = sub_814112C();
- if (data->field_0028)
+ struct SlotMachineSetupTaskData * data = GetSlotMachineSetupTaskDataPtr();
+ if (data->yesNoMenuActive)
{
DestroyYesNoMenu();
- data->field_0028 = FALSE;
+ data->yesNoMenuActive = FALSE;
}
}
-static void sub_8141B34(void)
+static void InitReelButtonTileMem(void)
{
s32 i, j;
- struct SlotMachineSetupTaskData * data = sub_814112C();
+ struct SlotMachineSetupTaskData * data = GetSlotMachineSetupTaskDataPtr();
u16 * buffer = GetBgTilemapBuffer(2);
for (i = 0; i < 3; i++)
{
for (j = 0; j < 4; j++)
{
- u16 idx = gUnknown_8466C40[i][j];
- data->field_0044[i][j] = buffer[idx];
- data->field_002C[i][j] = j + 0xC0;
+ u16 idx = sReelButtonMapTileIdxs[i][j];
+ data->buttonReleasedTiles[i][j] = buffer[idx];
+ data->buttonPressedTiles[i][j] = j + 0xC0;
}
}
}
-static void sub_8141BA0(u8 reel)
+static void SetReelButtonPressed(u8 reel)
{
if (reel < 3)
{
s32 i;
- struct SlotMachineSetupTaskData * data = sub_814112C();
+ struct SlotMachineSetupTaskData * data = GetSlotMachineSetupTaskDataPtr();
u16 * buffer = GetBgTilemapBuffer(2);
for (i = 0; i < 4; i++)
{
- u16 idx = gUnknown_8466C40[reel][i];
- buffer[idx] = data->field_002C[reel][i];
+ u16 idx = sReelButtonMapTileIdxs[reel][i];
+ buffer[idx] = data->buttonPressedTiles[reel][i];
}
}
}
-static void sub_8141BE4(void)
+static void ReleaseReelButtons(void)
{
s32 i, j;
- struct SlotMachineSetupTaskData * data = sub_814112C();
+ struct SlotMachineSetupTaskData * data = GetSlotMachineSetupTaskDataPtr();
u16 * buffer = GetBgTilemapBuffer(2);
for (i = 0; i < 3; i++)
{
for (j = 0; j < 4; j++)
{
- u16 idx = gUnknown_8466C40[i][j];
- buffer[idx] = data->field_0044[i][j];
+ u16 idx = sReelButtonMapTileIdxs[i][j];
+ buffer[idx] = data->buttonReleasedTiles[i][j];
}
}
}
-static void sub_8141C30(u8 a0, u8 a1)
+static void PressReelButton(u8 reel, u8 taskId)
{
- sub_814112C()->field_0020 = a0;
- sub_8141148(12, a1);
+ GetSlotMachineSetupTaskDataPtr()->reelButtonToPress = reel;
+ SetSlotMachineSetupTask(SLOTTASK_PRESS_BUTTON, taskId);
}
diff --git a/src/sound.c b/src/sound.c
index 99e9a162e..ed3f368ad 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -1,10 +1,9 @@
#include "global.h"
#include "gba/m4a_internal.h"
-#include "sound.h"
+#include "gflib.h"
#include "battle.h"
#include "quest_log.h"
#include "m4a.h"
-#include "main.h"
#include "constants/songs.h"
#include "constants/fanfares.h"
#include "task.h"
@@ -193,7 +192,7 @@ void PlayFanfareByFanfareNum(u8 fanfareNum)
{
u16 songNum;
- if(gQuestLogState == 2)
+ if(gQuestLogState == QL_STATE_PLAYBACK)
{
sFanfareCounter = 0xFF;
}
@@ -362,7 +361,7 @@ void PlayCry4(u16 species, s8 pan, u8 mode)
void PlayCry7(u16 species, u8 mode) // exclusive to FR/LG
{
- if (gQuestLogState != 2 && gQuestLogState != 3)
+ if (!QL_IS_PLAYBACK_STATE)
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
PlayCryInternal(species, 0, CRY_VOLUME, 10, mode);
@@ -571,7 +570,7 @@ void PlayBGM(u16 songNum)
void PlaySE(u16 songNum)
{
- if(gDisableMapMusicChangeOnMapLoad == 0 && gQuestLogState != 2)
+ if(gDisableMapMusicChangeOnMapLoad == 0 && gQuestLogState != QL_STATE_PLAYBACK)
m4aSongNumStart(songNum);
}
diff --git a/src/ss_anne.c b/src/ss_anne.c
index df04d8c66..fd0195830 100644
--- a/src/ss_anne.c
+++ b/src/ss_anne.c
@@ -1,6 +1,6 @@
#include "global.h"
+#include "gflib.h"
#include "task.h"
-#include "sound.h"
#include "event_object_movement.h"
#include "script.h"
#include "constants/songs.h"
diff --git a/src/start_menu.c b/src/start_menu.c
index 6fd69d9e0..d52ef47ef 100644
--- a/src/start_menu.c
+++ b/src/start_menu.c
@@ -8,6 +8,7 @@
#include "party_menu.h"
#include "save.h"
#include "link_rfu.h"
+#include "help_message.h"
#include "event_data.h"
#include "fieldmap.h"
#include "safari_zone.h"
@@ -390,7 +391,7 @@ void ShowStartMenu(void)
if (!IsUpdateLinkStateCBActive())
{
FreezeObjectEvents();
- sub_805C270();
+ HandleEnforcedLookDirectionOnPlayerStopMoving();
StopPlayerAvatar();
}
OpenStartMenuWithFollowupFunc(Task_StartMenuHandleInput);
@@ -574,7 +575,7 @@ static bool8 StartCB_Save2(void)
break;
case SAVECB_RETURN_OKAY:
ClearDialogWindowAndFrameToTransparent(0, TRUE);
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
RestoreHelpContext();
return TRUE;
@@ -586,7 +587,7 @@ static bool8 StartCB_Save2(void)
break;
case SAVECB_RETURN_ERROR:
ClearDialogWindowAndFrameToTransparent(0, TRUE);
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
RestoreHelpContext();
return TRUE;
@@ -994,7 +995,7 @@ static void CloseStartMenu(void)
PlaySE(SE_SELECT);
ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE);
RemoveStartMenuWindow();
- sub_80696C0();
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
}
diff --git a/src/string_util.c b/src/string_util.c
index 0a2365d25..17507b0e8 100644
--- a/src/string_util.c
+++ b/src/string_util.c
@@ -1,6 +1,5 @@
#include "global.h"
-#include "string_util.h"
-#include "text.h"
+#include "gflib.h"
EWRAM_DATA u8 gStringVar1[32] = {};
EWRAM_DATA u8 gStringVar2[20] = {};
diff --git a/src/strings.c b/src/strings.c
index de428ddd9..29bbd2fdf 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -185,7 +185,7 @@ const u8 gText_NoRoomToStoreItems[] = _("There's no room to\nstore items.");
const u8 gText_TossOutHowManyStrVar1s[] = _("Toss out how many\n{STR_VAR_1}(s)?");
const u8 gText_ThrewAwayStrVar2StrVar1s[] = _("Threw away {STR_VAR_2}\n{STR_VAR_1}(s).");
const u8 gText_ThrowAwayStrVar2OfThisItemQM[] = _("Throw away {STR_VAR_2} of\nthis item?");
-const u8 gUnknown_8416425[] = _("OAK: {PLAYER}!\nThis isn't the time to use that!{PAUSE_UNTIL_PRESS}");
+const u8 gText_OakForbidsUseOfItemHere[] = _("OAK: {PLAYER}!\nThis isn't the time to use that!{PAUSE_UNTIL_PRESS}");
const u8 gUnknown_8416451[] = _("You can't dismount your BIKE here.{PAUSE_UNTIL_PRESS}");
const u8 gText_ItemfinderResponding[] = _("Huh?\nThe ITEMFINDER's responding!\pThere's an item buried around here!{PAUSE_UNTIL_PRESS}");
const u8 gText_ItemfinderShakingWildly[] = _("Oh!\nThe ITEMFINDER's shaking wildly!\pThere's an item buried underfoot!\p‥ ‥ ‥ ‥ ‥ ‥{PAUSE_UNTIL_PRESS}");
@@ -1203,9 +1203,9 @@ const u8 gText_ThreeQuestionMarks[] = _("???");
const u8 gText_UnusedEmpty[] = _("");
const u8 gText_UnusedLv[] = _("Lv");
const u8 gText_UnusedDashes[] = _("---");
-const u8 gUnknown_841E09F[] = _("????");
+const u8 gText_4Qmark[] = _("????");
const u8 gText_UnusedEmpty2[] = _("");
-const u8 gUnknown_841E0A5[] = _("Is this trade okay?");
+const u8 gText_IsThisTradeOkay[] = _("Is this trade okay?");
const u8 gTradeText_Cancel[] = _("CANCEL");
const u8 gTradeText_ChooseAPokemon[] = _("Choose a POKéMON.");
const u8 gTradeText_Summary[] = _("SUMMARY");
diff --git a/src/teachy_tv.c b/src/teachy_tv.c
index 1d49ee3d9..6924f8e9d 100644
--- a/src/teachy_tv.c
+++ b/src/teachy_tv.c
@@ -1,23 +1,15 @@
#include "task.h"
-#include "menu.h"
-#include "palette.h"
-#include "sprite.h"
+#include "gflib.h"
#include "menu_helpers.h"
#include "new_menu_helpers.h"
-#include "sound.h"
-#include "malloc.h"
#include "scanline_effect.h"
-#include "bg.h"
-#include "gpu_regs.h"
#include "decompress.h"
-#include "window.h"
#include "list_menu.h"
#include "item_menu.h"
#include "item.h"
#include "menu_indicators.h"
#include "event_object_movement.h"
#include "random.h"
-#include "text.h"
#include "constants/songs.h"
#include "constants/items.h"
#include "event_data.h"
diff --git a/src/text.c b/src/text.c
index b1a098f53..9e0bb4c5f 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1,9 +1,5 @@
#include "global.h"
-#include "main.h"
-#include "window.h"
-#include "text.h"
-#include "sprite.h"
-#include "sound.h"
+#include "gflib.h"
#include "m4a.h"
#include "quest_log.h"
#include "graphics.h"
@@ -523,7 +519,7 @@ void TextPrinterClearDownArrow(struct TextPrinter *textPrinter)
bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub;
- u8 delay = (gQuestLogState == 2) ? 50 : 120;
+ u8 delay = (gQuestLogState == QL_STATE_PLAYBACK) ? 50 : 120;
if (subStruct->autoScrollDelay == delay)
{
@@ -712,7 +708,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->printerTemplate.currentChar++;
currChar |= *textPrinter->printerTemplate.currentChar << 8;
textPrinter->printerTemplate.currentChar++;
- if (gQuestLogState != 2 && gQuestLogState != 3)
+ if (!QL_IS_PLAYBACK_STATE)
PlayBGM(currChar);
return 2;
case 16:
diff --git a/src/text_window.c b/src/text_window.c
index 6fde39078..b4914e07b 100644
--- a/src/text_window.c
+++ b/src/text_window.c
@@ -1,7 +1,5 @@
#include "global.h"
-#include "bg.h"
-#include "palette.h"
-#include "window.h"
+#include "gflib.h"
#include "text_window.h"
#include "text_window_graphics.h"
#include "quest_log.h"
@@ -28,7 +26,7 @@ void sub_814FD6C(u8 bgId, u16 destOffset, u8 palIdx)
LoadPalette(stdpal_get(1), palIdx, 32);
}
-void sub_814FDA0(u8 bgId, u16 destOffset, u8 palIdx)
+void DrawWindowBorderWithStdpal3(u8 bgId, u16 destOffset, u8 palIdx)
{
LoadBgTiles(bgId, gStdFrame0, 0x120, destOffset);
LoadPalette(stdpal_get(3), palIdx, 32);
diff --git a/src/title_screen.c b/src/title_screen.c
index e7ac79401..156dfa50d 100644
--- a/src/title_screen.c
+++ b/src/title_screen.c
@@ -1,10 +1,6 @@
#include "global.h"
-#include "malloc.h"
-#include "palette.h"
-#include "gpu_regs.h"
-#include "bg.h"
+#include "gflib.h"
#include "task.h"
-#include "main.h"
#include "new_menu_helpers.h"
#include "m4a.h"
#include "scanline_effect.h"
@@ -12,7 +8,6 @@
#include "help_system.h"
#include "intro.h"
#include "load_save.h"
-#include "sound.h"
#include "new_game.h"
#include "save.h"
#include "main_menu.h"
diff --git a/src/tm_case.c b/src/tm_case.c
index 57eee6faf..0ec19d134 100644
--- a/src/tm_case.c
+++ b/src/tm_case.c
@@ -1,12 +1,8 @@
#include "global.h"
-#include "malloc.h"
-#include "bg.h"
+#include "gflib.h"
#include "decompress.h"
-#include "gpu_regs.h"
-#include "palette.h"
#include "graphics.h"
#include "task.h"
-#include "text.h"
#include "text_window.h"
#include "menu.h"
#include "menu_helpers.h"
@@ -19,11 +15,9 @@
#include "shop.h"
#include "teachy_tv.h"
#include "pokemon_storage_system.h"
-#include "string_util.h"
#include "party_menu.h"
#include "data.h"
#include "scanline_effect.h"
-#include "sound.h"
#include "strings.h"
#include "menu_indicators.h"
#include "constants/items.h"
diff --git a/src/trade.c b/src/trade.c
index bb2634613..81403cb7d 100644
--- a/src/trade.c
+++ b/src/trade.c
@@ -24,37 +24,37 @@
#include "constants/songs.h"
#include "constants/moves.h"
+#define NUM_TRADED_GIFT_RIBBONS 11
+
struct TradeMenuResources
{
- /*0x0000*/ u8 unk_0;
- /*0x0001*/ u8 unk_1;
+ /*0x0000*/ u8 bg2hofs;
+ /*0x0001*/ u8 bg3hofs;
/*0x0002*/ u8 filler_2[0x28 - 2];
/*0x0028*/ u8 partyIcons[2][PARTY_SIZE];
/*0x0034*/ u8 tradeMenuCursorSpriteIdx;
/*0x0035*/ u8 tradeMenuCursorPosition;
/*0x0036*/ u8 partyCounts[2];
/*0x0038*/ bool8 tradeMenuOptionsActive[13];
- /*0x0045*/ u8 unk_45[2][PARTY_SIZE];
- /*0x0051*/ u8 unk_51[2][PARTY_SIZE];
- /*0x005D*/ u8 unk_5D[2][PARTY_SIZE];
- /*0x0069*/ u8 unk_69;
+ /*0x0045*/ bool8 battleableFlags[2][PARTY_SIZE];
+ /*0x0051*/ bool8 eggFlags[2][PARTY_SIZE];
+ /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE];
+ /*0x0069*/ u8 state;
/*0x006A*/ u8 filler_6A[0x6F - 0x6A];
- /*0x006F*/ u8 unk_6F;
+ /*0x006F*/ u8 tradeMenuCBnum;
/*0x0070*/ u8 unk_70;
- /*0x0071*/ u8 filler_71;
- /*0x0072*/ u16 unk_72;
- /*0x0074*/ u8 unk_74[2];
- /*0x0076*/ u8 unk_76[2];
+ /*0x0072*/ u16 cursorStartTile;
+ /*0x0074*/ u8 menuRedrawState[2];
+ /*0x0076*/ u8 menuRedrawCursorPos[2];
/*0x0078*/ u8 unk_78;
/*0x0079*/ u8 unk_79;
/*0x007A*/ u8 unk_7A;
/*0x007B*/ u8 unk_7B;
/*0x007C*/ u8 filler_7C[0x7E - 0x7C];
- /*0x007E*/ u8 unk_7E;
- /*0x007F*/ u8 filler_7F;
+ /*0x007E*/ u8 otherPlayerCursorPosition;
/*0x0080*/ u16 linkData[20];
- /*0x00A8*/ u8 unk_A8;
- /*0x00A9*/ u8 unk_A9[11];
+ /*0x00A8*/ u8 loadUISpritesState;
+ /*0x00A9*/ u8 giftRibbons[NUM_TRADED_GIFT_RIBBONS];
/*0x00B4*/ u8 filler_B4[0x8D0-0xB4];
/*0x08D0*/ struct {
bool8 active;
@@ -83,37 +83,37 @@ EWRAM_DATA struct MailStruct gLinkPartnerMail[6] = {};
EWRAM_DATA u8 gSelectedTradeMonPositions[2] = {0};
static EWRAM_DATA struct TradeMenuResources * sTradeMenuResourcesPtr = NULL;
-static void sub_804C728(void);
-static void sub_804D4F8(void);
-static void sub_804D638(void);
-static void sub_804D694(u8 state);
-static void sub_804D764(void);
+static void CB2_ReturnFromLinkTrade2(void);
+static void VblankCB_Trade(void);
+static void CB2_TradeMenu(void);
+static void LoadTradeBackgroundGfxAndPals(u8 state);
+static void SetTradeMenuOptionActiveFlags(void);
static u8 shedinja_maker_maybe(void);
-static void sub_804DFF0(void);
+static void CB1_HandleBlockReceive(void);
static void RunTradeMenuCallback(void);
-static void sub_804EAAC(u8 a0);
-static void sub_804EAE4(u8 side);
-static u8 sub_804EE6C(u8 *str, u8 whichParty, u8 partyIdx);
-static void sub_804EED4(u8 *str, u8 whichParty, u8 partyIdx);
-static void sub_804F020(u8 side);
-static void sub_804F08C(u8 a0, u8 partyIdx, u8 a2, u8 a3, u8 a4, u8 a5);
-static void sub_804F284(u8 side);
-static void sub_804F3B4(void);
-static void sub_804F3C8(u8 a0);
+static void SignalRedrawTradeMenus(u8 a0);
+static void HandleRedrawTradeMenuOnSide(u8 side);
+static u8 GetNicknameStringWidthByPartyAndMonIdx(u8 *str, u8 whichParty, u8 partyIdx);
+static void BuildMovesString(u8 *str, u8 whichParty, u8 partyIdx);
+static void PrintPartyNicknames(u8 side);
+static void PrintLevelAndGenderDirectlyOnVram(u8 a0, u8 partyIdx, u8 a2, u8 a3, u8 a4, u8 a5);
+static void PrintPartyLevelsAndGendersDirectlyOnVram(u8 side);
+static void PrintTradePartnerPartyNicknames(void);
+static void RedrawPartyWindow(u8 a0);
static void TradeMenuAction_Summary(u8 taskId);
static void TradeMenuAction_Trade(u8 taskId);
static void ScheduleLinkTaskWithDelay(u16 delay, u8 kind);
static void RunScheduledLinkTasks(void);
static void PrintTradeErrorOrStatusMessage(u8 strIdx);
-static bool8 sub_804F610(void);
+static bool8 LoadUISprites(void);
static void RenderTextToVramViaBuffer(const u8 *name, u8 *a1, u8 unused);
-static void sub_804F748(u8 side);
-static void sub_804F890(u8 side);
-static void sub_804F964(void);
-static void sub_804F9D8(void);
-static u32 sub_804FA14(struct Pokemon * party, int partyCount, int cursorPos);
+static void ComputePartyTradeableFlags(u8 side);
+static void ComputePartyHPBarLevels(u8 side);
+static void SetMonIconsAnimByHPBarLevel(void);
+static void CopyGiftRibbonsToSav1(void);
+static u32 TestWhetherSelectedMonCanBeTraded(struct Pokemon * party, int partyCount, int cursorPos);
-static const size_t gUnknown_8260814[] = {
+static const size_t sSizesAndOffsets[] = {
sizeof(struct SaveBlock2),
sizeof(struct SaveBlock1),
sizeof(struct MapLayout),
@@ -339,7 +339,7 @@ static const u8 sTradeMonSpriteCoords[][2] = {
{0x17, 0x12},
};
-static const u8 gUnknown_8261E5A[][2][2] = {
+static const u8 sTradeMenuGenderLevelPrintCoords[][2][2] = {
{
{0x05, 0x04},
{0x0c, 0x04},
@@ -366,7 +366,7 @@ static const u8 gUnknown_8261E5A[][2][2] = {
},
};
-static const u8 gUnknown_8261E72[][2][2] = {
+static const u8 sTradeMenuGenderLevelWindowCoords[][2][2] = {
{
{0x01, 0x03},
{0x08, 0x03},
@@ -410,14 +410,14 @@ static const u8 gUnknown_8261E92[] = {
0x07, 0x07, 0x17, 0x0c
};
-const u8 gUnknown_8261EB6[] = _("");
-const u8 gUnknown_8261EB7[] = _("{COLOR DARK_GREY}{HIGHLIGHT TRANSPARENT}{SHADOW RED}");
+const u8 sText_Dummy[] = _("");
+const u8 sText_ClrDkGryHltTranspShdwRed[] = _("{COLOR DARK_GREY}{HIGHLIGHT TRANSPARENT}{SHADOW RED}");
const u8 gText_MaleSymbol4[] = _("♂");
const u8 gText_FemaleSymbol4[] = _("♀");
const u8 gText_GenderlessSymbol[] = _("");
-const u8 gUnknown_8261EC6[] = _("");
-const u8 gUnknown_8261EC7[] = _("\n");
-const u8 gUnknown_8261EC9[] = _("/");
+const u8 sText_Dummy2[] = _("");
+const u8 sText_Newline[] = _("\n");
+const u8 sText_Slash[] = _("/");
enum TradeUIText
{
@@ -438,7 +438,7 @@ static const u8 *const sTradeUITextPtrs[] = {
gTradeText_PressBButtonToExit
};
-static const struct MenuAction gUnknown_8261EE4[] = {
+static const struct MenuAction sMenuAction_SummaryTrade[] = {
{gUnknown_841E10A, { .void_u8 = TradeMenuAction_Summary }},
{gUnknown_841E112, { .void_u8 = TradeMenuAction_Trade }}
};
@@ -455,9 +455,9 @@ static const u8 *const sTradeErrorOrStatusMessagePtrs[] = {
gText_OtherTrainersPkmnCantBeTraded // The other TRAINER's POKéMON can't be traded now
};
-static const u8 gUnknown_8261F18[] = { 0, 1, 2 };
+static const u8 sTextColor_PartyMonNickname[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY };
-static const struct BgTemplate gUnknown_8261F1C[] = {
+static const struct BgTemplate sBgTemplates[] = {
{
.bg = 0,
.charBaseIndex = 2,
@@ -493,7 +493,7 @@ static const struct BgTemplate gUnknown_8261F1C[] = {
}
};
-static const struct WindowTemplate gUnknown_8261F2C[] = {
+static const struct WindowTemplate sWindowTemplates[] = {
{
.bg = 0,
.tilemapLeft = 4,
@@ -641,7 +641,7 @@ static const struct WindowTemplate gUnknown_8261F2C[] = {
}, DUMMY_WIN_TEMPLATE
};
-static const struct WindowTemplate gUnknown_8261FC4 = {
+static const struct WindowTemplate sWindowTemplate_YesNo = {
.bg = 0,
.tilemapLeft = 21,
.tilemapTop = 13,
@@ -671,7 +671,7 @@ static const u8 gUnknown_8262055[][2] = {
{19, 3}
};
-static void sub_804C600(void)
+static void InitTradeMenuResources(void)
{
int i;
static vu16 dummy;
@@ -681,17 +681,17 @@ static void sub_804C600(void)
ResetTasks();
ResetPaletteFade();
gPaletteFade.bufferTransferDisabled = TRUE;
- SetVBlankCallback(sub_804D4F8);
+ SetVBlankCallback(VblankCB_Trade);
LoadPalette(gTMCaseMainWindowPalette, 0xF0, 0x14);
LoadPalette(gTMCaseMainWindowPalette, 0xD0, 0x14);
ResetBgsAndClearDma3BusyFlags(FALSE);
- InitBgsFromTemplates(0, gUnknown_8261F1C, NELEMS(gUnknown_8261F1C));
+ InitBgsFromTemplates(0, sBgTemplates, NELEMS(sBgTemplates));
SetBgTilemapBuffer(1, sTradeMenuResourcesPtr->tilemapBuffer);
- if (InitWindows(gUnknown_8261F2C))
+ if (InitWindows(sWindowTemplates))
{
DeactivateAllTextPrinters();
dummy = 590; // ?
- for (i = 0; i < NELEMS(gUnknown_8261F2C) - 1; i++)
+ for (i = 0; i < NELEMS(sWindowTemplates) - 1; i++)
{
ClearWindowTilemap(i);
FillWindowPixelBuffer(i, PIXEL_FILL(0));
@@ -700,23 +700,23 @@ static void sub_804C600(void)
TextWindow_SetStdFrame0_WithPal(0, 0x014, 0xC0);
TextWindow_SetUserSelectedFrame(2, 0x001, 0xE0);
LoadMonIconPalettes();
- sTradeMenuResourcesPtr->unk_69 = 0;
- sTradeMenuResourcesPtr->unk_6F = 0;
+ sTradeMenuResourcesPtr->state = 0;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 0;
sTradeMenuResourcesPtr->unk_70 = 0;
- sTradeMenuResourcesPtr->unk_74[0] = 0;
- sTradeMenuResourcesPtr->unk_74[1] = 0;
+ sTradeMenuResourcesPtr->menuRedrawState[0] = 0;
+ sTradeMenuResourcesPtr->menuRedrawState[1] = 0;
sTradeMenuResourcesPtr->unk_7A = 0;
sTradeMenuResourcesPtr->unk_7B = 0;
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
}
}
void CB2_ReturnFromLinkTrade(void)
{
- SetMainCallback2(sub_804C728);
+ SetMainCallback2(CB2_ReturnFromLinkTrade2);
}
-static void sub_804C728(void)
+static void CB2_ReturnFromLinkTrade2(void)
{
int i;
struct SpriteTemplate temp;
@@ -734,7 +734,7 @@ static void sub_804C728(void)
{
case 0:
sTradeMenuResourcesPtr = AllocZeroed(sizeof(*sTradeMenuResourcesPtr));
- sub_804C600();
+ InitTradeMenuResources();
sSpriteTextTileBuffer = AllocZeroed(0xE00);
for (i = 0; i < 14; i++)
@@ -758,7 +758,7 @@ static void sub_804C728(void)
if (!gReceivedRemoteLinkPlayers)
{
gLinkType = 0x1122;
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
if (gWirelessCommType)
{
@@ -772,7 +772,7 @@ static void sub_804C728(void)
gMain.state++;
}
if (gWirelessCommType == 0)
- CreateTask(sub_8081A90, 1);
+ CreateTask(Task_WaitForReceivedRemoteLinkPlayers5SecondTimeout, 1);
}
else
{
@@ -780,10 +780,10 @@ static void sub_804C728(void)
}
break;
case 2:
- sTradeMenuResourcesPtr->unk_A8++;
- if (sTradeMenuResourcesPtr->unk_A8 > 11)
+ sTradeMenuResourcesPtr->loadUISpritesState++;
+ if (sTradeMenuResourcesPtr->loadUISpritesState > 11)
{
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
gMain.state++;
}
break;
@@ -792,7 +792,7 @@ static void sub_804C728(void)
{
if (IsLinkMaster())
{
- if (++sTradeMenuResourcesPtr->unk_A8 > 30)
+ if (++sTradeMenuResourcesPtr->loadUISpritesState > 30)
{
CheckShouldAdvanceLinkState();
gMain.state++;
@@ -810,10 +810,10 @@ static void sub_804C728(void)
LinkRfu_DestroyIdleTask();
CalculatePlayerPartyCount();
gMain.state++;
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
if (gWirelessCommType)
{
- sub_80FA484(TRUE);
+ ToggleLMANlinkRecovery(TRUE);
PrepareSendLinkCmd2FFE_or_RfuCmd6600();
}
}
@@ -836,7 +836,7 @@ static void sub_804C728(void)
case 6:
if (shedinja_maker_maybe())
{
- sub_804F9D8();
+ CopyGiftRibbonsToSav1();
gMain.state++;
}
break;
@@ -888,10 +888,10 @@ static void sub_804C728(void)
DrawTextWindowAndBufferTiles(sTradeUITextPtrs[TRADEUITEXT_CANCEL], sSpriteTextTilePtrs[6], 0, 0, gDecompressionBuffer, 2);
RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CHOOSE], sSpriteTextTilePtrs[8], 24);
gMain.state++;
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
break;
case 11:
- if (sub_804F610())
+ if (LoadUISprites())
gMain.state++;
break;
case 12:
@@ -937,25 +937,25 @@ static void sub_804C728(void)
rbox_fill_rectangle(0);
break;
case 14:
- sub_804F748(0);
- sub_804F020(0);
- sTradeMenuResourcesPtr->unk_0 = 0;
- sTradeMenuResourcesPtr->unk_1 = 0;
- sub_804D764();
+ ComputePartyTradeableFlags(0);
+ PrintPartyNicknames(0);
+ sTradeMenuResourcesPtr->bg2hofs = 0;
+ sTradeMenuResourcesPtr->bg3hofs = 0;
+ SetTradeMenuOptionActiveFlags();
gMain.state++;
PlayBGM(MUS_SLOT);
break;
case 15:
- sub_804F748(1);
- sub_804F020(1);
+ ComputePartyTradeableFlags(1);
+ PrintPartyNicknames(1);
gMain.state++;
// fallthrough
case 16:
- sub_804D694(0);
+ LoadTradeBackgroundGfxAndPals(0);
gMain.state++;
break;
case 17:
- sub_804D694(1);
+ LoadTradeBackgroundGfxAndPals(1);
gMain.state++;
break;
case 18:
@@ -964,23 +964,23 @@ static void sub_804C728(void)
break;
case 19:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
- sub_804D694(2);
+ LoadTradeBackgroundGfxAndPals(2);
gMain.state++;
break;
case 20:
- sub_804F890(0);
+ ComputePartyHPBarLevels(0);
gMain.state++;
break;
case 21:
- sub_804F890(1);
- sub_804F964();
+ ComputePartyHPBarLevels(1);
+ SetMonIconsAnimByHPBarLevel();
gMain.state++;
break;
case 22:
if (!gPaletteFade.active)
{
- gMain.callback1 = sub_804DFF0;
- SetMainCallback2(sub_804D638);
+ gMain.callback1 = CB1_HandleBlockReceive;
+ SetMainCallback2(CB2_TradeMenu);
}
break;
}
@@ -992,7 +992,7 @@ static void sub_804C728(void)
UpdatePaletteFade();
}
-void sub_804CF14(void)
+void CB2_ReturnToTradeMenuFromSummary(void)
{
int i;
struct SpriteTemplate temp;
@@ -1009,12 +1009,12 @@ void sub_804CF14(void)
switch (gMain.state)
{
case 0:
- sub_804C600();
+ InitTradeMenuResources();
gMain.state++;
break;
case 1:
gMain.state++;
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
break;
case 2:
gMain.state++;
@@ -1042,8 +1042,8 @@ void sub_804CF14(void)
sTradeMenuResourcesPtr->partyCounts[0] = gPlayerPartyCount;
sTradeMenuResourcesPtr->partyCounts[1] = gEnemyPartyCount;
ClearWindowTilemap(0);
- sub_804F020(0);
- sub_804F020(1);
+ PrintPartyNicknames(0);
+ PrintPartyNicknames(1);
for (i = 0; i < sTradeMenuResourcesPtr->partyCounts[0]; i++)
{
sTradeMenuResourcesPtr->partyIcons[0][i] = CreateMonIcon(
@@ -1086,10 +1086,10 @@ void sub_804CF14(void)
DrawTextWindowAndBufferTiles(sTradeUITextPtrs[TRADEUITEXT_CANCEL], sSpriteTextTilePtrs[6], 0, 0, gDecompressionBuffer, 2);
RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CHOOSE], sSpriteTextTilePtrs[8], 24);
gMain.state++;
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
break;
case 11:
- if (sub_804F610())
+ if (LoadUISprites())
{
gMain.state++;
}
@@ -1140,14 +1140,14 @@ void sub_804CF14(void)
gMain.state = 16;
break;
case 16:
- sub_804D694(0);
+ LoadTradeBackgroundGfxAndPals(0);
gMain.state++;
break;
case 17:
- sub_804D694(1);
- sTradeMenuResourcesPtr->unk_0 = 0;
- sTradeMenuResourcesPtr->unk_1 = 0;
- sub_804D764();
+ LoadTradeBackgroundGfxAndPals(1);
+ sTradeMenuResourcesPtr->bg2hofs = 0;
+ sTradeMenuResourcesPtr->bg3hofs = 0;
+ SetTradeMenuOptionActiveFlags();
gMain.state++;
break;
case 18:
@@ -1158,20 +1158,20 @@ void sub_804CF14(void)
break;
case 19:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
- sub_804D694(2);
+ LoadTradeBackgroundGfxAndPals(2);
gMain.state++;
break;
case 20:
gMain.state++;
break;
case 21:
- sub_804F964();
+ SetMonIconsAnimByHPBarLevel();
gMain.state++;
break;
case 22:
if (!gPaletteFade.active)
{
- SetMainCallback2(sub_804D638);
+ SetMainCallback2(CB2_TradeMenu);
}
break;
}
@@ -1182,41 +1182,41 @@ void sub_804CF14(void)
UpdatePaletteFade();
}
-static void sub_804D4F8(void)
+static void VblankCB_Trade(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
-static void sub_804D50C(void)
+static void TradeMenuCB_9(void)
{
- if (++sTradeMenuResourcesPtr->unk_A8 >= 16)
+ if (++sTradeMenuResourcesPtr->loadUISpritesState >= 16)
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
- sTradeMenuResourcesPtr->unk_6F = 10;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 10;
}
}
-static void sub_804D548(void)
+static void TradeMenuCB_10(void)
{
if (!gPaletteFade.active)
{
gSelectedTradeMonPositions[0] = sTradeMenuResourcesPtr->tradeMenuCursorPosition;
- gSelectedTradeMonPositions[1] = sTradeMenuResourcesPtr->unk_7E;
+ gSelectedTradeMonPositions[1] = sTradeMenuResourcesPtr->otherPlayerCursorPosition;
if (gWirelessCommType != 0)
{
- sTradeMenuResourcesPtr->unk_6F = 16;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 16;
}
else
{
Link_StartSend5FFFwithParam(32);
- sTradeMenuResourcesPtr->unk_6F = 13;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 13;
}
}
}
-static void sub_804D5A4(void)
+static void TradeMenuCB_13(void)
{
gMain.savedCallback = CB2_ReturnFromLinkTrade;
if (gWirelessCommType != 0)
@@ -1244,14 +1244,14 @@ static void sub_804D5A4(void)
}
}
-static void sub_804D638(void)
+static void CB2_TradeMenu(void)
{
RunTradeMenuCallback();
RunScheduledLinkTasks();
- sub_804EAE4(0);
- sub_804EAE4(1);
- SetGpuReg(REG_OFFSET_BG2HOFS, sTradeMenuResourcesPtr->unk_0++);
- SetGpuReg(REG_OFFSET_BG3HOFS, sTradeMenuResourcesPtr->unk_1--);
+ HandleRedrawTradeMenuOnSide(0);
+ HandleRedrawTradeMenuOnSide(1);
+ SetGpuReg(REG_OFFSET_BG2HOFS, sTradeMenuResourcesPtr->bg2hofs++);
+ SetGpuReg(REG_OFFSET_BG3HOFS, sTradeMenuResourcesPtr->bg3hofs--);
RunTextPrinters_CheckPrinter0Active();
RunTasks();
AnimateSprites();
@@ -1259,7 +1259,7 @@ static void sub_804D638(void)
UpdatePaletteFade();
}
-static void sub_804D694(u8 state)
+static void LoadTradeBackgroundGfxAndPals(u8 state)
{
int i;
@@ -1273,8 +1273,8 @@ static void sub_804D694(u8 state)
break;
case 1:
LoadBgTilemap(3, sTradeStripesBG3Tilemap, 0x800, 0);
- sub_804F284(0);
- sub_804F284(1);
+ PrintPartyLevelsAndGendersDirectlyOnVram(0);
+ PrintPartyLevelsAndGendersDirectlyOnVram(1);
CopyBgTilemapBufferToVram(1);
break;
case 2:
@@ -1291,7 +1291,7 @@ static void sub_804D694(u8 state)
}
}
-static void sub_804D764(void)
+static void SetTradeMenuOptionActiveFlags(void)
{
int i;
for (i = 0; i < PARTY_SIZE; i++)
@@ -1333,116 +1333,116 @@ static bool8 shedinja_maker_maybe(void)
int i;
struct Pokemon * mon;
- switch (sTradeMenuResourcesPtr->unk_69)
+ switch (sTradeMenuResourcesPtr->state)
{
case 0:
Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[0], 2 * sizeof(struct Pokemon));
- sTradeMenuResourcesPtr->unk_69++;
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->state++;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
break;
case 1:
if (IsLinkTaskFinished())
{
if (GetBlockReceivedStatus() == 0)
{
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
}
else
{
ResetBlockReceivedFlags();
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
}
}
break;
case 3:
if (id == 0)
{
- sub_800A474(1);
+ Link_PrepareCmd0xCCCC_Rfu0xA100(1);
}
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
break;
case 4:
if (GetBlockReceivedStatus() == 3)
{
Trade_Memcpy(&gEnemyParty[0], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon));
ResetBlockReceivedFlags();
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
}
break;
case 5:
Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[2], 2 * sizeof(struct Pokemon));
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
break;
case 7:
if (id == 0)
{
- sub_800A474(1);
+ Link_PrepareCmd0xCCCC_Rfu0xA100(1);
}
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
break;
case 8:
if (GetBlockReceivedStatus() == 3)
{
- Trade_Memcpy(&gEnemyParty[2], gBlockRecvBuffer[id ^ 1], 200);
+ Trade_Memcpy(&gEnemyParty[2], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon));
ResetBlockReceivedFlags();
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
}
break;
case 9:
- Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[4], 200);
- sTradeMenuResourcesPtr->unk_69++;
+ Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[4], 2 * sizeof(struct Pokemon));
+ sTradeMenuResourcesPtr->state++;
break;
case 11:
if (id == 0)
{
- sub_800A474(1);
+ Link_PrepareCmd0xCCCC_Rfu0xA100(1);
}
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
break;
case 12:
if (GetBlockReceivedStatus() == 3)
{
- Trade_Memcpy(&gEnemyParty[4], gBlockRecvBuffer[id ^ 1], 200);
+ Trade_Memcpy(&gEnemyParty[4], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon));
ResetBlockReceivedFlags();
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
}
break;
case 13:
- Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->mail, 220);
- sTradeMenuResourcesPtr->unk_69++;
+ Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->mail, PARTY_SIZE * sizeof(struct MailStruct) + 4); // why the extra 4 bytes?
+ sTradeMenuResourcesPtr->state++;
break;
case 15:
if (id == 0)
{
- sub_800A474(3);
+ Link_PrepareCmd0xCCCC_Rfu0xA100(3);
}
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
break;
case 16:
if (GetBlockReceivedStatus() == 3)
{
- Trade_Memcpy(gLinkPartnerMail, gBlockRecvBuffer[id ^ 1], 216);
+ Trade_Memcpy(gLinkPartnerMail, gBlockRecvBuffer[id ^ 1], PARTY_SIZE * sizeof(struct MailStruct));
ResetBlockReceivedFlags();
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
}
break;
case 17:
- Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, 11);
- sTradeMenuResourcesPtr->unk_69++;
+ Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, NUM_TRADED_GIFT_RIBBONS);
+ sTradeMenuResourcesPtr->state++;
break;
case 19:
if (id == 0)
{
- sub_800A474(4);
+ Link_PrepareCmd0xCCCC_Rfu0xA100(4);
}
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
break;
case 20:
if (GetBlockReceivedStatus() == 3)
{
- Trade_Memcpy(sTradeMenuResourcesPtr->unk_A9, gBlockRecvBuffer[id ^ 1], 11);
+ Trade_Memcpy(sTradeMenuResourcesPtr->giftRibbons, gBlockRecvBuffer[id ^ 1], NUM_TRADED_GIFT_RIBBONS);
ResetBlockReceivedFlags();
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->state++;
}
break;
case 21:
@@ -1470,25 +1470,25 @@ static bool8 shedinja_maker_maybe(void)
case 10:
case 14:
case 18:
- sTradeMenuResourcesPtr->unk_A8++;
- if (sTradeMenuResourcesPtr->unk_A8 > 10)
+ sTradeMenuResourcesPtr->loadUISpritesState++;
+ if (sTradeMenuResourcesPtr->loadUISpritesState > 10)
{
- sTradeMenuResourcesPtr->unk_A8 = 0;
- sTradeMenuResourcesPtr->unk_69++;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
+ sTradeMenuResourcesPtr->state++;
}
break;
}
return FALSE;
}
-static void sub_804DBAC(void)
+static void PrintIsThisTradeOkay(void)
{
- RenderTextToVramViaBuffer(gUnknown_841E0A5, (u8 *)OBJ_VRAM0 + sTradeMenuResourcesPtr->unk_72 * 32, 0x18);
+ RenderTextToVramViaBuffer(gText_IsThisTradeOkay, (u8 *)OBJ_VRAM0 + sTradeMenuResourcesPtr->cursorStartTile * 32, 0x18);
}
-static void sub_804DBD4(u8 a0, u8 a1)
+static void Master_HandleBlockReceivedStatus(u8 mpId, u8 blockReceivedFlags)
{
- if (a1 & 1)
+ if (blockReceivedFlags & 1)
{
switch (gBlockRecvBuffer[0][0])
{
@@ -1508,7 +1508,7 @@ static void sub_804DBD4(u8 a0, u8 a1)
ResetBlockReceivedFlag(0);
}
- if (a1 & 2)
+ if (blockReceivedFlags & 2)
{
switch (gBlockRecvBuffer[1][0])
{
@@ -1516,7 +1516,7 @@ static void sub_804DBD4(u8 a0, u8 a1)
sTradeMenuResourcesPtr->unk_79 = 2;
break;
case 0xAABB:
- sTradeMenuResourcesPtr->unk_7E = gBlockRecvBuffer[1][1] + 6;
+ sTradeMenuResourcesPtr->otherPlayerCursorPosition = gBlockRecvBuffer[1][1] + 6;
sTradeMenuResourcesPtr->unk_79 = 1;
break;
case 0xBBBB:
@@ -1530,50 +1530,50 @@ static void sub_804DBD4(u8 a0, u8 a1)
}
}
-static void sub_804DCF4(u8 a0, u8 a1)
+static void Slave_HandleBlockReceivedStatus(u8 mpId, u8 blockReceivedFlags)
{
- if (a1 & 1)
+ if (blockReceivedFlags & 1)
{
switch (gBlockRecvBuffer[0][0])
{
case 0xEEBB:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
PrintTradeErrorOrStatusMessage(TRADESTATMSG_WAITINGFORFRIEND);
- sTradeMenuResourcesPtr->unk_6F = 11;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 11;
break;
case 0xEECC:
PrintTradeErrorOrStatusMessage(TRADESTATMSG_FRIENDWANTSTOTRADE);
- sTradeMenuResourcesPtr->unk_6F = 8;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 8;
break;
case 0xDDDD:
- sTradeMenuResourcesPtr->unk_7E = gBlockRecvBuffer[0][1] + 6;
+ sTradeMenuResourcesPtr->otherPlayerCursorPosition = gBlockRecvBuffer[0][1] + 6;
rbox_fill_rectangle(0);
- sub_804EAAC(sTradeMenuResourcesPtr->tradeMenuCursorPosition);
- sub_804EAAC(sTradeMenuResourcesPtr->unk_7E);
- sTradeMenuResourcesPtr->unk_6F = 7;
+ SignalRedrawTradeMenus(sTradeMenuResourcesPtr->tradeMenuCursorPosition);
+ SignalRedrawTradeMenus(sTradeMenuResourcesPtr->otherPlayerCursorPosition);
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 7;
break;
case 0xCCDD:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
- sTradeMenuResourcesPtr->unk_6F = 10;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 10;
break;
case 0xDDEE:
PrintTradeErrorOrStatusMessage(TRADESTATMSG_CANCELED);
- sTradeMenuResourcesPtr->unk_6F = 8;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 8;
}
ResetBlockReceivedFlag(0);
}
- if (a1 & 2)
+ if (blockReceivedFlags & 2)
ResetBlockReceivedFlag(1);
}
-static void sub_804DDF0(void)
+static void Master_HandleCommunication(void)
{
if (sTradeMenuResourcesPtr->unk_78 && sTradeMenuResourcesPtr->unk_79)
{
if (sTradeMenuResourcesPtr->unk_78 == 1 && sTradeMenuResourcesPtr->unk_79 == 1)
{
- sTradeMenuResourcesPtr->unk_6F = 6;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 6;
sTradeMenuResourcesPtr->linkData[0] = 0xDDDD;
sTradeMenuResourcesPtr->linkData[1] = sTradeMenuResourcesPtr->tradeMenuCursorPosition;
ScheduleLinkTaskWithDelay(5, 0);
@@ -1587,7 +1587,7 @@ static void sub_804DDF0(void)
ScheduleLinkTaskWithDelay(5, 0);
sTradeMenuResourcesPtr->unk_7A = sTradeMenuResourcesPtr->unk_7B = 0;
sTradeMenuResourcesPtr->unk_78 = sTradeMenuResourcesPtr->unk_79 = 0;
- sTradeMenuResourcesPtr->unk_6F = 8;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 8;
}
else if (sTradeMenuResourcesPtr->unk_78 == 2 && sTradeMenuResourcesPtr->unk_79 == 1)
{
@@ -1597,7 +1597,7 @@ static void sub_804DDF0(void)
ScheduleLinkTaskWithDelay(5, 0);
sTradeMenuResourcesPtr->unk_7A = sTradeMenuResourcesPtr->unk_7B = 0;
sTradeMenuResourcesPtr->unk_78 = sTradeMenuResourcesPtr->unk_79 = 0;
- sTradeMenuResourcesPtr->unk_6F = 8;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 8;
}
else if (sTradeMenuResourcesPtr->unk_78 == 2 && sTradeMenuResourcesPtr->unk_79 == 2)
{
@@ -1606,7 +1606,7 @@ static void sub_804DDF0(void)
ScheduleLinkTaskWithDelay(5, 0);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
sTradeMenuResourcesPtr->unk_78 = sTradeMenuResourcesPtr->unk_79 = 0;
- sTradeMenuResourcesPtr->unk_6F = 11;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 11;
}
}
@@ -1619,7 +1619,7 @@ static void sub_804DDF0(void)
ScheduleLinkTaskWithDelay(5, 0);
sTradeMenuResourcesPtr->unk_7A = 0;
sTradeMenuResourcesPtr->unk_7B = 0;
- sTradeMenuResourcesPtr->unk_6F = 9;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 9;
}
if (sTradeMenuResourcesPtr->unk_7A == 2 || sTradeMenuResourcesPtr->unk_7B == 2)
@@ -1630,27 +1630,27 @@ static void sub_804DDF0(void)
ScheduleLinkTaskWithDelay(5, 0);
sTradeMenuResourcesPtr->unk_7A = 0;
sTradeMenuResourcesPtr->unk_7B = 0;
- sTradeMenuResourcesPtr->unk_6F = 8;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 8;
}
}
}
-static void sub_804DFF0(void)
+static void CB1_HandleBlockReceive(void)
{
u8 mpId = GetMultiplayerId();
u8 status;
if ((status = GetBlockReceivedStatus()))
{
if (mpId == 0)
- sub_804DBD4(0, status);
+ Master_HandleBlockReceivedStatus(mpId, status);
else
- sub_804DCF4(mpId, status);
+ Slave_HandleBlockReceivedStatus(mpId, status);
}
if (mpId == 0)
- sub_804DDF0();
+ Master_HandleCommunication();
}
-static u8 sub_804E028(u8 oldPosition, u8 direction)
+static u8 TradeMenuGetNewCursorLocation(u8 oldPosition, u8 direction)
{
int i;
u8 newPosition = 0;
@@ -1670,7 +1670,7 @@ static u8 sub_804E028(u8 oldPosition, u8 direction)
static void TradeMenuMoveCursor(u8 *tradeMenuCursorPosition, u8 direction)
{
- u8 newPosition = sub_804E028(*tradeMenuCursorPosition, direction);
+ u8 newPosition = TradeMenuGetNewCursorLocation(*tradeMenuCursorPosition, direction);
if (newPosition == 12) // CANCEL
{
@@ -1693,16 +1693,16 @@ static void TradeMenuMoveCursor(u8 *tradeMenuCursorPosition, u8 direction)
*tradeMenuCursorPosition = newPosition;
}
-static void sub_804E134(void)
+static void CommunicatePlayerSelectedMonForTrade(void)
{
PrintTradeErrorOrStatusMessage(TRADESTATMSG_COMMSTANDBY);
- sTradeMenuResourcesPtr->unk_6F = 5;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 5;
if (GetMultiplayerId() == 1)
{
sTradeMenuResourcesPtr->linkData[0] = 0xAABB;
sTradeMenuResourcesPtr->linkData[1] = sTradeMenuResourcesPtr->tradeMenuCursorPosition;
- SendBlock(bitmask_all_link_players_but_self(), sTradeMenuResourcesPtr->linkData, 0x14);
+ SendBlock(bitmask_all_link_players_but_self(), sTradeMenuResourcesPtr->linkData, 20);
}
else
{
@@ -1710,7 +1710,7 @@ static void sub_804E134(void)
}
}
-static void sub_804E194(void)
+static void TradeMenuCB_0(void)
{
int i;
@@ -1739,22 +1739,22 @@ static void sub_804E194(void)
{
DrawTextBorderOuter(1, 1, 14);
FillWindowPixelBuffer(1, PIXEL_FILL(1));
- UnionRoomAndTradeMenuPrintOptions(1, 3, 16, 2, gUnknown_8261EE4);
+ UnionRoomAndTradeMenuPrintOptions(1, 3, 16, 2, sMenuAction_SummaryTrade);
Menu_InitCursor(1, 3, 0, 0, 16, 2, 0);
PutWindowTilemap(1);
CopyWindowToVram(1, 3);
- sTradeMenuResourcesPtr->unk_6F = 1;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 1;
}
else if (sTradeMenuResourcesPtr->tradeMenuCursorPosition < 12)
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
- sTradeMenuResourcesPtr->unk_6F = 2;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 2;
}
else if (sTradeMenuResourcesPtr->tradeMenuCursorPosition == 12)
{
- CreateYesNoMenu(&gUnknown_8261FC4, 3, 0, 2, 0x001, 14, 0);
- sTradeMenuResourcesPtr->unk_6F = 4;
- RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_ASKCANCEL], (void *)OBJ_VRAM0 + sTradeMenuResourcesPtr->unk_72 * 32, 24);
+ CreateYesNoMenu(&sWindowTemplate_YesNo, 3, 0, 2, 0x001, 14, 0);
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 4;
+ RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_ASKCANCEL], (void *)OBJ_VRAM0 + sTradeMenuResourcesPtr->cursorStartTile * 32, 24);
}
}
if (JOY_NEW(R_BUTTON))
@@ -1765,76 +1765,76 @@ static void sub_804E194(void)
}
}
-static void sub_804E330(void)
+static void RedrawChooseAPokemonWindow(void)
{
- sub_804F3B4();
- sTradeMenuResourcesPtr->unk_6F = 0;
+ PrintTradePartnerPartyNicknames();
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 0;
gSprites[sTradeMenuResourcesPtr->tradeMenuCursorSpriteIdx].invisible = FALSE;
- RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CHOOSE], (void *)OBJ_VRAM0 + sTradeMenuResourcesPtr->unk_72 * 32, 24);
+ RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CHOOSE], (void *)OBJ_VRAM0 + sTradeMenuResourcesPtr->cursorStartTile * 32, 24);
}
-static void sub_804E388(void)
+static void TradeMenuCB_1(void)
{
switch (Menu_ProcessInputNoWrapAround())
{
case MENU_B_PRESSED:
PlaySE(SE_SELECT);
- sub_804E330();
+ RedrawChooseAPokemonWindow();
break;
case MENU_NOTHING_CHOSEN:
break;
- case 0:
+ case 0: // SUMMARY
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
- sTradeMenuResourcesPtr->unk_6F = 2;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 2;
break;
- case 1:
- switch (sub_804FA14(gPlayerParty, gPlayerPartyCount, sTradeMenuResourcesPtr->tradeMenuCursorPosition))
+ case 1: // Trade
+ switch (TestWhetherSelectedMonCanBeTraded(gPlayerParty, gPlayerPartyCount, sTradeMenuResourcesPtr->tradeMenuCursorPosition))
{
- case 0:
- sub_804E134();
+ case 0: // Can trade
+ CommunicatePlayerSelectedMonForTrade();
gSprites[sTradeMenuResourcesPtr->tradeMenuCursorSpriteIdx].invisible = TRUE;
break;
- case 1:
+ case 1: // Don't have enough alive mons
ScheduleLinkTaskWithDelay(3, 3);
- sTradeMenuResourcesPtr->unk_6F = 8;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 8;
break;
- case 2:
- case 4:
+ case 2: // Player lacks national dex
+ case 4: // Partner lacks national dex
ScheduleLinkTaskWithDelay(3, 6);
- sTradeMenuResourcesPtr->unk_6F = 8;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 8;
break;
- case 3:
- case 5:
+ case 3: // Player lacks national dex (egg)
+ case 5: // Partner lacks national dex (egg)
ScheduleLinkTaskWithDelay(3, 7);
- sTradeMenuResourcesPtr->unk_6F = 8;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 8;
break;
}
break;
}
}
-static void sub_804E46C(void)
+static void TradeMenuCB_15(void)
{
if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
- sub_804E330();
+ RedrawChooseAPokemonWindow();
}
}
-static void sub_804E494(void)
+static void TradeMenuCB_2(void)
{
if (!gPaletteFade.active)
{
if (sTradeMenuResourcesPtr->tradeMenuCursorPosition < 6)
- ShowPokemonSummaryScreen(gPlayerParty, sTradeMenuResourcesPtr->tradeMenuCursorPosition, sTradeMenuResourcesPtr->partyCounts[0] - 1, sub_804CF14, 4);
+ ShowPokemonSummaryScreen(gPlayerParty, sTradeMenuResourcesPtr->tradeMenuCursorPosition, sTradeMenuResourcesPtr->partyCounts[0] - 1, CB2_ReturnToTradeMenuFromSummary, 4);
else
- ShowPokemonSummaryScreen(gEnemyParty, sTradeMenuResourcesPtr->tradeMenuCursorPosition - 6, sTradeMenuResourcesPtr->partyCounts[1] - 1, sub_804CF14, 4);
+ ShowPokemonSummaryScreen(gEnemyParty, sTradeMenuResourcesPtr->tradeMenuCursorPosition - 6, sTradeMenuResourcesPtr->partyCounts[1] - 1, CB2_ReturnToTradeMenuFromSummary, 4);
FreeAllWindowBuffers();
}
}
-static u8 sub_804E50C(u8 *flags, u8 partyCount, u8 cursorPos)
+static u8 PlayerHasEnoughPokemonToTrade_HandleMewDeoxys(u8 *flags, u8 partyCount, u8 cursorPos)
{
s32 i;
u16 species;
@@ -1844,30 +1844,30 @@ static u8 sub_804E50C(u8 *flags, u8 partyCount, u8 cursorPos)
if (cursorPos != i)
count += flags[i];
}
- species = GetMonData(&gEnemyParty[sTradeMenuResourcesPtr->unk_7E % 6], MON_DATA_SPECIES);
- if ((species == SPECIES_DEOXYS || species == SPECIES_MEW) && !GetMonData(&gEnemyParty[sTradeMenuResourcesPtr->unk_7E % 6], MON_DATA_OBEDIENCE))
+ species = GetMonData(&gEnemyParty[sTradeMenuResourcesPtr->otherPlayerCursorPosition % 6], MON_DATA_SPECIES);
+ if ((species == SPECIES_DEOXYS || species == SPECIES_MEW) && !GetMonData(&gEnemyParty[sTradeMenuResourcesPtr->otherPlayerCursorPosition % 6], MON_DATA_OBEDIENCE))
return 2;
if (count != 0)
count = 1;
return count;
}
-static void sub_804E5A0(void)
+static void CommunicateWhetherMonCanBeTraded(void)
{
int i;
u8 arr[12];
for (i = 0; i < sTradeMenuResourcesPtr->partyCounts[0]; i++)
{
- arr[i] = sTradeMenuResourcesPtr->unk_45[0][i];
+ arr[i] = sTradeMenuResourcesPtr->battleableFlags[0][i];
}
- switch (sub_804E50C(arr, sTradeMenuResourcesPtr->partyCounts[0], sTradeMenuResourcesPtr->tradeMenuCursorPosition))
+ switch (PlayerHasEnoughPokemonToTrade_HandleMewDeoxys(arr, sTradeMenuResourcesPtr->partyCounts[0], sTradeMenuResourcesPtr->tradeMenuCursorPosition))
{
case 0:
ScheduleLinkTaskWithDelay(3, 3);
sTradeMenuResourcesPtr->linkData[0] = 0xBBCC;
- ScheduleLinkTaskWithDelay(0xB4, 0);
+ ScheduleLinkTaskWithDelay(180, 0);
break;
case 1:
ScheduleLinkTaskWithDelay(3, 1);
@@ -1880,18 +1880,18 @@ static void sub_804E5A0(void)
case 2:
ScheduleLinkTaskWithDelay(3, 8);
sTradeMenuResourcesPtr->linkData[0] = 0xBBCC;
- ScheduleLinkTaskWithDelay(0xB4, 0);
+ ScheduleLinkTaskWithDelay(180, 0);
break;
}
}
-static void sub_804E674(void)
+static void TradeMenuCB_3(void)
{
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
case 0:
- sub_804E5A0();
- sTradeMenuResourcesPtr->unk_6F = 100;
+ CommunicateWhetherMonCanBeTraded();
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 100;
PutWindowTilemap(17);
break;
case 1:
@@ -1902,13 +1902,13 @@ static void sub_804E674(void)
sTradeMenuResourcesPtr->linkData[0] = 0xBBCC;
SendBlock(bitmask_all_link_players_but_self(), sTradeMenuResourcesPtr->linkData, 20);
}
- sTradeMenuResourcesPtr->unk_6F = 100;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 100;
PutWindowTilemap(17);
break;
}
}
-static void sub_804E6FC(void)
+static void CommitWindows(void)
{
int i;
@@ -1919,7 +1919,7 @@ static void sub_804E6FC(void)
}
}
-static void sub_804E744(void)
+static void TradeMenuCB_4(void)
{
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
@@ -1929,50 +1929,50 @@ static void sub_804E744(void)
sTradeMenuResourcesPtr->linkData[1] = 0;
ScheduleLinkTaskWithDelay(5, 0);
gSprites[sTradeMenuResourcesPtr->tradeMenuCursorSpriteIdx].invisible = TRUE;
- sTradeMenuResourcesPtr->unk_6F = 100;
- sub_804E6FC();
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 100;
+ CommitWindows();
break;
case 1:
case MENU_B_PRESSED:
PlaySE(SE_SELECT);
- sub_804E330();
+ RedrawChooseAPokemonWindow();
break;
}
}
-static void sub_804E7C8(void)
+static void TradeMenuCB_6(void)
{
if (GetMultiplayerId() == 0)
{
rbox_fill_rectangle(0);
- sub_804EAAC(sTradeMenuResourcesPtr->tradeMenuCursorPosition);
- sub_804EAAC(sTradeMenuResourcesPtr->unk_7E);
+ SignalRedrawTradeMenus(sTradeMenuResourcesPtr->tradeMenuCursorPosition);
+ SignalRedrawTradeMenus(sTradeMenuResourcesPtr->otherPlayerCursorPosition);
}
- sTradeMenuResourcesPtr->unk_6F = 7;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 7;
}
-static void sub_804E804(void)
+static void TradeMenuCB_7(void)
{
- if (sTradeMenuResourcesPtr->unk_74[0] == 5 && sTradeMenuResourcesPtr->unk_74[1] == 5)
+ if (sTradeMenuResourcesPtr->menuRedrawState[0] == 5 && sTradeMenuResourcesPtr->menuRedrawState[1] == 5)
{
- sub_804DBAC();
- sTradeMenuResourcesPtr->unk_6F = 14;
+ PrintIsThisTradeOkay();
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 14;
}
}
-static void sub_804E830(void)
+static void TradeMenuCB_14(void)
{
- sTradeMenuResourcesPtr->unk_A8++;
+ sTradeMenuResourcesPtr->loadUISpritesState++;
- if (sTradeMenuResourcesPtr->unk_A8 > 120)
+ if (sTradeMenuResourcesPtr->loadUISpritesState > 120)
{
- CreateYesNoMenu(&gUnknown_8261FC4, 3, 0, 2, 1, 14, 0);
- sTradeMenuResourcesPtr->unk_A8 = 0;
- sTradeMenuResourcesPtr->unk_6F = 3;
+ CreateYesNoMenu(&sWindowTemplate_YesNo, 3, 0, 2, 1, 14, 0);
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 3;
}
}
-static void sub_804E880(void)
+static void TradeMenuCB_8(void)
{
int i;
@@ -1988,14 +1988,14 @@ static void sub_804E880(void)
rbox_fill_rectangle(i + 14);
}
- sub_804F3C8(0);
- sub_804F3C8(1);
- sTradeMenuResourcesPtr->unk_6F = 0;
+ RedrawPartyWindow(0);
+ RedrawPartyWindow(1);
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 0;
gSprites[sTradeMenuResourcesPtr->tradeMenuCursorSpriteIdx].invisible = FALSE;
}
}
-static void sub_804E908(void)
+static void TradeMenuCB_11(void)
{
if (!gPaletteFade.active)
{
@@ -2008,11 +2008,11 @@ static void sub_804E908(void)
Link_StartSend5FFFwithParam(12);
}
- sTradeMenuResourcesPtr->unk_6F = 12;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 12;
}
}
-static void sub_804E944(void)
+static void TradeMenuCB_12(void)
{
if (gWirelessCommType)
{
@@ -2037,82 +2037,85 @@ static void sub_804E944(void)
}
}
-static void sub_804E9C0(void)
+static void TradeMenuCB_16(void)
{
- if (!sub_80FA484(FALSE))
+ if (!ToggleLMANlinkRecovery(FALSE))
{
PrepareSendLinkCmd2FFE_or_RfuCmd6600();
- sTradeMenuResourcesPtr->unk_6F = 13;
+ sTradeMenuResourcesPtr->tradeMenuCBnum = 13;
}
}
static void RunTradeMenuCallback(void)
{
- switch (sTradeMenuResourcesPtr->unk_6F)
+ switch (sTradeMenuResourcesPtr->tradeMenuCBnum)
{
case 0:
- sub_804E194();
+ TradeMenuCB_0();
break;
case 1:
- sub_804E388();
+ TradeMenuCB_1();
break;
case 2:
- sub_804E494();
+ TradeMenuCB_2();
break;
case 3:
- sub_804E674();
+ TradeMenuCB_3();
break;
case 4:
- sub_804E744();
+ TradeMenuCB_4();
+ break;
+ case 5:
+ // nop
break;
case 6:
- sub_804E7C8();
+ TradeMenuCB_6();
break;
case 7:
- sub_804E804();
+ TradeMenuCB_7();
break;
case 8:
- sub_804E880();
+ TradeMenuCB_8();
break;
case 9:
- sub_804D50C();
+ TradeMenuCB_9();
break;
case 10:
- sub_804D548();
+ TradeMenuCB_10();
break;
case 11:
- sub_804E908();
+ TradeMenuCB_11();
break;
case 12:
- sub_804E944();
+ TradeMenuCB_12();
break;
case 13:
- sub_804D5A4();
+ TradeMenuCB_13();
break;
case 14:
- sub_804E830();
+ TradeMenuCB_14();
break;
case 15:
- sub_804E46C();
+ TradeMenuCB_15();
break;
case 16:
- sub_804E9C0();
+ TradeMenuCB_16();
break;
}
}
-static void sub_804EAAC(u8 a0)
+static void SignalRedrawTradeMenus(u8 monIdx)
{
- u8 whichParty = a0 / PARTY_SIZE;
+ u8 whichParty = monIdx / PARTY_SIZE;
- if (sTradeMenuResourcesPtr->unk_74[whichParty] == 0)
+ if (sTradeMenuResourcesPtr->menuRedrawState[whichParty] == 0)
{
- sTradeMenuResourcesPtr->unk_74[whichParty] = 1;
- sTradeMenuResourcesPtr->unk_76[whichParty] = a0;
+ sTradeMenuResourcesPtr->menuRedrawState[whichParty] = 1;
+ sTradeMenuResourcesPtr->menuRedrawCursorPos[whichParty] = monIdx;
}
}
-static void sub_804EAE4(u8 a0)
+static void HandleRedrawTradeMenuOnSide(u8 side)
{
s8 nameStringWidth;
u8 nickname[20];
@@ -2120,25 +2123,25 @@ static void sub_804EAE4(u8 a0)
u8 i;
u8 partyIdx;
u8 whichParty;
- u8 monIdx = sTradeMenuResourcesPtr->unk_76[a0];
+ u8 monIdx = sTradeMenuResourcesPtr->menuRedrawCursorPos[side];
whichParty = 1;
- if (sTradeMenuResourcesPtr->unk_76[a0] < PARTY_SIZE)
+ if (sTradeMenuResourcesPtr->menuRedrawCursorPos[side] < PARTY_SIZE)
whichParty = 0;
partyIdx = monIdx % PARTY_SIZE;
nameStringWidth = 0;
- switch (sTradeMenuResourcesPtr->unk_74[a0])
+ switch (sTradeMenuResourcesPtr->menuRedrawState[side])
{
case 1:
- for (i = 0; i < sTradeMenuResourcesPtr->partyCounts[a0]; i++)
+ for (i = 0; i < sTradeMenuResourcesPtr->partyCounts[side]; i++)
{
gSprites[sTradeMenuResourcesPtr->partyIcons[0][i + (whichParty * PARTY_SIZE)]].invisible = TRUE;
}
for (i = 0; i < 6; i++)
{
- ClearWindowTilemap(i + (a0 * 6 + 2));
+ ClearWindowTilemap(i + (side * 6 + 2));
}
gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].invisible = FALSE;
@@ -2146,18 +2149,18 @@ static void sub_804EAE4(u8 a0)
gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[2] = (sTradeMonSpriteCoords[whichParty * PARTY_SIZE][0] + sTradeMonSpriteCoords[whichParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14;
gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[4] = (sTradeMonSpriteCoords[whichParty * PARTY_SIZE][1] * 8) - 12;
StoreSpriteCallbackInData6(&gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]], SpriteCB_MonIcon);
- sTradeMenuResourcesPtr->unk_74[a0]++;
- sub_8075490(&gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]]);
- CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, a0 * 15, 0, 15, 17, 0);
+ sTradeMenuResourcesPtr->menuRedrawState[side]++;
+ StartSpriteLinearTranslationFromCurrentPos(&gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]]);
+ CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, side * 15, 0, 15, 17, 0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(0);
if (whichParty == 0)
- sub_804F3B4();
+ PrintTradePartnerPartyNicknames();
break;
case 2:
if (gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].callback == SpriteCB_MonIcon)
- sTradeMenuResourcesPtr->unk_74[a0] = 3;
+ sTradeMenuResourcesPtr->menuRedrawState[side] = 3;
break;
case 3:
CopyToBgTilemapBufferRect_ChangePalette(1, sTradeMovesBoxTilemap, whichParty * 15, 0, 15, 17, 0);
@@ -2166,26 +2169,26 @@ static void sub_804EAE4(u8 a0)
gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos1.y = (sTradeMonSpriteCoords[whichParty * PARTY_SIZE][1] * 8) - 12;
gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos2.x = 0;
gSprites[sTradeMenuResourcesPtr->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos2.y = 0;
- nameStringWidth = sub_804EE6C(nickname, whichParty, partyIdx);
- AddTextPrinterParameterized3((a0 * 2) + 14, 0, (80 - nameStringWidth) / 2, 4, gUnknown_8261F18, 0, nickname);
- sub_804EED4(movesString, whichParty, partyIdx);
- AddTextPrinterParameterized4((a0 * 2) + 15, 1, 0, 0, 0, 0, gUnknown_8261F18, 0, movesString);
- PutWindowTilemap((a0 * 2) + 14);
- CopyWindowToVram((a0 * 2) + 14, 3);
- PutWindowTilemap((a0 * 2) + 15);
- CopyWindowToVram((a0 * 2) + 15, 3);
- sTradeMenuResourcesPtr->unk_74[a0]++;
+ nameStringWidth = GetNicknameStringWidthByPartyAndMonIdx(nickname, whichParty, partyIdx);
+ AddTextPrinterParameterized3((side * 2) + 14, 0, (80 - nameStringWidth) / 2, 4, sTextColor_PartyMonNickname, 0, nickname);
+ BuildMovesString(movesString, whichParty, partyIdx);
+ AddTextPrinterParameterized4((side * 2) + 15, 1, 0, 0, 0, 0, sTextColor_PartyMonNickname, 0, movesString);
+ PutWindowTilemap((side * 2) + 14);
+ CopyWindowToVram((side * 2) + 14, 3);
+ PutWindowTilemap((side * 2) + 15);
+ CopyWindowToVram((side * 2) + 15, 3);
+ sTradeMenuResourcesPtr->menuRedrawState[side]++;
break;
case 4:
- sub_804F08C(a0, partyIdx, gUnknown_8262055[a0][0] + 4, gUnknown_8262055[a0][1] + 1, gUnknown_8262055[a0][0], gUnknown_8262055[a0][1]);
- sTradeMenuResourcesPtr->unk_74[a0]++;
+ PrintLevelAndGenderDirectlyOnVram(side, partyIdx, gUnknown_8262055[side][0] + 4, gUnknown_8262055[side][1] + 1, gUnknown_8262055[side][0], gUnknown_8262055[side][1]);
+ sTradeMenuResourcesPtr->menuRedrawState[side]++;
break;
}
}
-static u8 sub_804EE6C(u8 *dest, u8 whichParty, u8 partyIdx)
+static u8 GetNicknameStringWidthByPartyAndMonIdx(u8 *dest, u8 whichParty, u8 partyIdx)
{
- u8 nickname[11];
+ u8 nickname[POKEMON_NAME_LENGTH];
if (whichParty == 0)
GetMonData(&gPlayerParty[partyIdx], MON_DATA_NICKNAME, nickname);
else
@@ -2194,57 +2197,57 @@ static u8 sub_804EE6C(u8 *dest, u8 whichParty, u8 partyIdx)
return GetStringWidth(0, dest, GetFontAttribute(0, FONTATTR_LETTER_SPACING));
}
-static void sub_804EED4(u8 *a0, u8 a1, u8 a2)
+static void BuildMovesString(u8 *movesString, u8 whichParty, u8 whichMon)
{
u16 moves[MAX_MON_MOVES];
u16 i;
- if (!sTradeMenuResourcesPtr->unk_51[a1][a2])
+ if (!sTradeMenuResourcesPtr->eggFlags[whichParty][whichMon])
{
for (i = 0; i < MAX_MON_MOVES; i++)
{
- if (!a1)
+ if (!whichParty)
{
- moves[i] = GetMonData(&gPlayerParty[a2], i + MON_DATA_MOVE1, NULL);
+ moves[i] = GetMonData(&gPlayerParty[whichMon], i + MON_DATA_MOVE1, NULL);
}
else
{
- moves[i] = GetMonData(&gEnemyParty[a2], i + MON_DATA_MOVE1, NULL);
+ moves[i] = GetMonData(&gEnemyParty[whichMon], i + MON_DATA_MOVE1, NULL);
}
}
- StringCopy(a0, gUnknown_8261EB6);
+ StringCopy(movesString, sText_Dummy);
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE)
{
- StringAppend(a0, gMoveNames[moves[i]]);
+ StringAppend(movesString, gMoveNames[moves[i]]);
}
- StringAppend(a0, gUnknown_8261EC7);
+ StringAppend(movesString, sText_Newline);
}
}
else
{
- StringCopy(a0, gUnknown_8261EB6);
- StringAppend(a0, gUnknown_841E09F);
+ StringCopy(movesString, sText_Dummy);
+ StringAppend(movesString, gText_4Qmark);
}
}
-static void sub_804EFB4(u8 whichParty, u8 windowId, const u8 *str)
+static void PrintPartyMonNickname(u8 whichParty, u8 windowId, const u8 *str)
{
u8 xPos;
s8 speed;
windowId += (whichParty * PARTY_SIZE) + 2;
speed = 0;
xPos = (64u - GetStringWidth(0, str, GetFontAttribute(0, FONTATTR_LETTER_SPACING))) / 2;
- AddTextPrinterParameterized3(windowId, 0, xPos, 4, gUnknown_8261F18, speed, str);
+ AddTextPrinterParameterized3(windowId, 0, xPos, 4, sTextColor_PartyMonNickname, speed, str);
PutWindowTilemap(windowId);
CopyWindowToVram(windowId, 3);
}
-static void sub_804F020(u8 whichParty)
+static void PrintPartyNicknames(u8 whichParty)
{
u8 buff[20];
u8 nickname[30];
@@ -2254,18 +2257,18 @@ static void sub_804F020(u8 whichParty)
{
GetMonData(&party[i], MON_DATA_NICKNAME, buff);
StringCopy10(nickname, buff);
- sub_804EFB4(whichParty, i, nickname);
+ PrintPartyMonNickname(whichParty, i, nickname);
}
}
-static void sub_804F08C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5)
+static void PrintLevelAndGenderDirectlyOnVram(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 winLeft, u8 winTop)
{
u8 level;
- u32 r2;
+ u32 tileNum;
u8 gender;
u8 nickname[12];
- CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMenuMonBox_Tilemap, a4, a5, 6, 3, 0);
+ CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMenuMonBox_Tilemap, winLeft, winTop, 6, 3, 0);
CopyBgTilemapBufferToVram(1);
if (whichParty == 0)
@@ -2273,22 +2276,22 @@ static void sub_804F08C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5)
else
level = GetMonData(&gEnemyParty[monIdx], MON_DATA_LEVEL, NULL);
- if (sTradeMenuResourcesPtr->unk_51[whichParty][monIdx] == 0)
+ if (sTradeMenuResourcesPtr->eggFlags[whichParty][monIdx] == 0)
{
if (level / 10 != 0)
- sTradeMenuResourcesPtr->tilemapBuffer[a2 + (a3 * 32)] = (level / 10) + 0x60;
+ sTradeMenuResourcesPtr->tilemapBuffer[x + (y * 32)] = (level / 10) + 0x60;
- sTradeMenuResourcesPtr->tilemapBuffer[a2 + (a3 * 32) + 1] = (level % 10) + 0x70;
+ sTradeMenuResourcesPtr->tilemapBuffer[x + (y * 32) + 1] = (level % 10) + 0x70;
}
else
{
- sTradeMenuResourcesPtr->tilemapBuffer[a2 + (a3 * 32) - 32] = sTradeMenuResourcesPtr->tilemapBuffer[a2 + (a3 * 32) - 33];
- sTradeMenuResourcesPtr->tilemapBuffer[a2 + (a3 * 32) - 31] = sTradeMenuResourcesPtr->tilemapBuffer[a2 + (a3 * 32) - 36] | 0x400;
+ sTradeMenuResourcesPtr->tilemapBuffer[x + (y * 32) - 32] = sTradeMenuResourcesPtr->tilemapBuffer[x + (y * 32) - 33];
+ sTradeMenuResourcesPtr->tilemapBuffer[x + (y * 32) - 31] = sTradeMenuResourcesPtr->tilemapBuffer[x + (y * 32) - 36] | 0x400;
}
- if (sTradeMenuResourcesPtr->unk_51[whichParty][monIdx] != 0)
+ if (sTradeMenuResourcesPtr->eggFlags[whichParty][monIdx])
{
- r2 = 0x480;
+ tileNum = 0x480;
}
else
{
@@ -2306,43 +2309,43 @@ static void sub_804F08C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5)
switch (gender)
{
case MON_MALE:
- r2 = !NameHasGenderSymbol(nickname, MON_MALE) ? 0x84 : 0x83;
+ tileNum = !NameHasGenderSymbol(nickname, MON_MALE) ? 0x84 : 0x83;
break;
case MON_FEMALE:
- r2 = !NameHasGenderSymbol(nickname, MON_FEMALE) ? 0x85 : 0x83;
+ tileNum = !NameHasGenderSymbol(nickname, MON_FEMALE) ? 0x85 : 0x83;
break;
default:
- r2 = 0x83;
+ tileNum = 0x83;
break;
}
}
- sTradeMenuResourcesPtr->tilemapBuffer[(a3 - 1) * 32 + a2 + 1] = r2;
+ sTradeMenuResourcesPtr->tilemapBuffer[(y - 1) * 32 + x + 1] = tileNum;
}
-static void sub_804F284(u8 whichParty)
+static void PrintPartyLevelsAndGendersDirectlyOnVram(u8 whichParty)
{
s32 i;
for (i = 0; i < sTradeMenuResourcesPtr->partyCounts[whichParty]; i++)
{
- const u8 (*r5)[2];
- const u8 (*r4)[2];
+ const u8 (*drawCoords)[2];
+ const u8 (*winCoords)[2];
u32 r0 = 3 * whichParty;
- const u8 (*r1)[2][2] = gUnknown_8261E5A;
- r5 = r1[r0];
- r4 = gUnknown_8261E72[r0];
+ const u8 (*drawCoords_p)[2][2] = sTradeMenuGenderLevelPrintCoords;
+ drawCoords = drawCoords_p[r0];
+ winCoords = sTradeMenuGenderLevelWindowCoords[r0];
- sub_804F08C(
+ PrintLevelAndGenderDirectlyOnVram(
whichParty,
i,
- r5[i][0],
- r5[i][1],
- r4[i][0],
- r4[i][1]
+ drawCoords[i][0],
+ drawCoords[i][1],
+ winCoords[i][0],
+ winCoords[i][1]
);
}
}
-static void sub_804F2E8(u8 whichParty)
+static void ShowTradePartyMonIcons(u8 whichParty)
{
int i;
@@ -2356,21 +2359,21 @@ static void sub_804F2E8(u8 whichParty)
}
}
-static void sub_804F3B4(void)
+static void PrintTradePartnerPartyNicknames(void)
{
rbox_fill_rectangle(1);
- sub_804F020(1);
+ PrintPartyNicknames(1);
}
-static void sub_804F3C8(u8 whichParty)
+static void RedrawPartyWindow(u8 whichParty)
{
CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, 15 * whichParty, 0, 15, 17, 0);
CopyBgTilemapBufferToVram(1);
- sub_804F284(whichParty);
- sub_804F020(whichParty);
- sub_804F2E8(whichParty);
- RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CHOOSE], (void *)OBJ_VRAM0 + 32 * sTradeMenuResourcesPtr->unk_72, 24);
- sTradeMenuResourcesPtr->unk_74[whichParty] = 0;
+ PrintPartyLevelsAndGendersDirectlyOnVram(whichParty);
+ PrintPartyNicknames(whichParty);
+ ShowTradePartyMonIcons(whichParty);
+ RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CHOOSE], (void *)OBJ_VRAM0 + 32 * sTradeMenuResourcesPtr->cursorStartTile, 24);
+ sTradeMenuResourcesPtr->menuRedrawState[whichParty] = 0;
}
static void TradeMenuAction_Summary(u8 taskId)
@@ -2455,45 +2458,45 @@ static void PrintTradeErrorOrStatusMessage(u8 idx)
CopyWindowToVram(0, 3);
}
-static bool8 sub_804F610(void)
+static bool8 LoadUISprites(void)
{
struct SpriteSheet sheet;
- if (sTradeMenuResourcesPtr->unk_A8 < 14)
+ if (sTradeMenuResourcesPtr->loadUISpritesState < 14)
{
- sheet.data = sSpriteTextTilePtrs[sTradeMenuResourcesPtr->unk_A8];
+ sheet.data = sSpriteTextTilePtrs[sTradeMenuResourcesPtr->loadUISpritesState];
sheet.size = 0x100;
- sheet.tag = 200 + sTradeMenuResourcesPtr->unk_A8;
+ sheet.tag = 200 + sTradeMenuResourcesPtr->loadUISpritesState;
}
- switch (sTradeMenuResourcesPtr->unk_A8)
+ switch (sTradeMenuResourcesPtr->loadUISpritesState)
{
case 0 ... 7:
LoadSpriteSheet(&sheet);
- sTradeMenuResourcesPtr->unk_A8++;
+ sTradeMenuResourcesPtr->loadUISpritesState++;
break;
case 8:
- sTradeMenuResourcesPtr->unk_72 = LoadSpriteSheet(&sheet);
- sTradeMenuResourcesPtr->unk_A8++;
+ sTradeMenuResourcesPtr->cursorStartTile = LoadSpriteSheet(&sheet);
+ sTradeMenuResourcesPtr->loadUISpritesState++;
break;
case 9 ... 13:
LoadSpriteSheet(&sheet);
- sTradeMenuResourcesPtr->unk_A8++;
+ sTradeMenuResourcesPtr->loadUISpritesState++;
break;
case 14:
LoadSpritePalette(&sSpritePalette_Text);
- sTradeMenuResourcesPtr->unk_A8++;
+ sTradeMenuResourcesPtr->loadUISpritesState++;
break;
case 15:
LoadSpritePalette(&sTradeButtons_SpritePal);
- sTradeMenuResourcesPtr->unk_A8++;
+ sTradeMenuResourcesPtr->loadUISpritesState++;
break;
case 16:
LoadSpriteSheet(&sTradeButtons_SpriteSheet);
- sTradeMenuResourcesPtr->unk_A8++;
+ sTradeMenuResourcesPtr->loadUISpritesState++;
break;
case 17:
- sTradeMenuResourcesPtr->unk_A8 = 0;
+ sTradeMenuResourcesPtr->loadUISpritesState = 0;
return TRUE;
}
@@ -2505,7 +2508,7 @@ static void RenderTextToVramViaBuffer(const u8 *name, u8 *dest, u8 unused)
DrawTextWindowAndBufferTiles(name, dest, 0, 0, gDecompressionBuffer, 6);
}
-static void sub_804F748(u8 who)
+static void ComputePartyTradeableFlags(u8 who)
{
int i;
@@ -2516,18 +2519,18 @@ static void sub_804F748(u8 who)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) == TRUE)
{
- sTradeMenuResourcesPtr->unk_45[who][i] = 0;
- sTradeMenuResourcesPtr->unk_51[who][i] = 1;
+ sTradeMenuResourcesPtr->battleableFlags[who][i] = FALSE;
+ sTradeMenuResourcesPtr->eggFlags[who][i] = TRUE;
}
else if (GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0)
{
- sTradeMenuResourcesPtr->unk_45[who][i] = 0;
- sTradeMenuResourcesPtr->unk_51[who][i] = 0;
+ sTradeMenuResourcesPtr->battleableFlags[who][i] = FALSE;
+ sTradeMenuResourcesPtr->eggFlags[who][i] = FALSE;
}
else
{
- sTradeMenuResourcesPtr->unk_45[who][i] = 1;
- sTradeMenuResourcesPtr->unk_51[who][i] = 0;
+ sTradeMenuResourcesPtr->battleableFlags[who][i] = TRUE;
+ sTradeMenuResourcesPtr->eggFlags[who][i] = FALSE;
}
}
break;
@@ -2536,25 +2539,25 @@ static void sub_804F748(u8 who)
{
if (GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) == TRUE)
{
- sTradeMenuResourcesPtr->unk_45[who][i] = 0;
- sTradeMenuResourcesPtr->unk_51[who][i] = 1;
+ sTradeMenuResourcesPtr->battleableFlags[who][i] = FALSE;
+ sTradeMenuResourcesPtr->eggFlags[who][i] = TRUE;
}
else if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
{
- sTradeMenuResourcesPtr->unk_45[who][i] = 0;
- sTradeMenuResourcesPtr->unk_51[who][i] = 0;
+ sTradeMenuResourcesPtr->battleableFlags[who][i] = FALSE;
+ sTradeMenuResourcesPtr->eggFlags[who][i] = FALSE;
}
else
{
- sTradeMenuResourcesPtr->unk_45[who][i] = 1;
- sTradeMenuResourcesPtr->unk_51[who][i] = 0;
+ sTradeMenuResourcesPtr->battleableFlags[who][i] = TRUE;
+ sTradeMenuResourcesPtr->eggFlags[who][i] = FALSE;
}
}
break;
}
}
-static void sub_804F890(u8 who)
+static void ComputePartyHPBarLevels(u8 who)
{
u16 i, curHp, maxHp;
@@ -2565,7 +2568,7 @@ static void sub_804F890(u8 who)
{
curHp = GetMonData(&gPlayerParty[i], MON_DATA_HP);
maxHp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP);
- sTradeMenuResourcesPtr->unk_5D[0][i] = GetHPBarLevel(curHp, maxHp);
+ sTradeMenuResourcesPtr->hpBarLevels[0][i] = GetHPBarLevel(curHp, maxHp);
}
break;
case 1:
@@ -2573,35 +2576,35 @@ static void sub_804F890(u8 who)
{
curHp = GetMonData(&gEnemyParty[i], MON_DATA_HP);
maxHp = GetMonData(&gEnemyParty[i], MON_DATA_MAX_HP);
- sTradeMenuResourcesPtr->unk_5D[1][i] = GetHPBarLevel(curHp, maxHp);
+ sTradeMenuResourcesPtr->hpBarLevels[1][i] = GetHPBarLevel(curHp, maxHp);
}
break;
}
}
-static void sub_804F964(void)
+static void SetMonIconsAnimByHPBarLevel(void)
{
int i, j;
for (i = 0; i < 2; i++)
{
for (j = 0; j < sTradeMenuResourcesPtr->partyCounts[i]; j++)
{
- SetPartyHPBarSprite(&gSprites[sTradeMenuResourcesPtr->partyIcons[i][j]], 4 - sTradeMenuResourcesPtr->unk_5D[i][j]);
+ SetPartyHPBarSprite(&gSprites[sTradeMenuResourcesPtr->partyIcons[i][j]], 4 - sTradeMenuResourcesPtr->hpBarLevels[i][j]);
}
}
}
-static void sub_804F9D8(void)
+static void CopyGiftRibbonsToSav1(void)
{
int i;
for (i = 0; i < 11; i++)
{
- if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeMenuResourcesPtr->unk_A9[i] != 0)
- gSaveBlock1Ptr->giftRibbons[i] = sTradeMenuResourcesPtr->unk_A9[i];
+ if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeMenuResourcesPtr->giftRibbons[i] != 0)
+ gSaveBlock1Ptr->giftRibbons[i] = sTradeMenuResourcesPtr->giftRibbons[i];
}
}
-static u32 sub_804FA14(struct Pokemon * party, int partyCount, int cursorPos)
+static u32 TestWhetherSelectedMonCanBeTraded(struct Pokemon * party, int partyCount, int cursorPos)
{
int i, sum;
struct LinkPlayer * player;
@@ -2678,7 +2681,7 @@ static u32 sub_804FA14(struct Pokemon * party, int partyCount, int cursorPos)
}
}
-s32 sub_804FB34(void)
+s32 Trade_CalcLinkPlayerCompatibilityParam(void)
{
s32 val;
u16 version;
diff --git a/src/trade_scene.c b/src/trade_scene.c
index 308cd6e5b..e23a2e307 100644
--- a/src/trade_scene.c
+++ b/src/trade_scene.c
@@ -1,17 +1,11 @@
#include "global.h"
+#include "gflib.h"
#include "task.h"
-#include "malloc.h"
-#include "bg.h"
-#include "gpu_regs.h"
#include "util.h"
-#include "window.h"
-#include "sound.h"
#include "decompress.h"
-#include "palette.h"
#include "trade.h"
#include "link.h"
#include "link_rfu.h"
-#include "text.h"
#include "mevent.h"
#include "graphics.h"
#include "strings.h"
@@ -20,7 +14,6 @@
#include "battle.h"
#include "script.h"
#include "event_data.h"
-#include "string_util.h"
#include "mail.h"
#include "mail_data.h"
#include "pokeball.h"
diff --git a/src/trainer_card.c b/src/trainer_card.c
index 01bd2c228..33440e5a5 100644
--- a/src/trainer_card.c
+++ b/src/trainer_card.c
@@ -1,23 +1,15 @@
#include "global.h"
+#include "gflib.h"
#include "scanline_effect.h"
-#include "palette.h"
#include "task.h"
-#include "main.h"
-#include "window.h"
-#include "malloc.h"
#include "link.h"
-#include "bg.h"
-#include "sound.h"
#include "overworld.h"
#include "menu.h"
-#include "text.h"
#include "event_data.h"
#include "easy_chat.h"
#include "money.h"
#include "strings.h"
-#include "string_util.h"
#include "trainer_card.h"
-#include "gpu_regs.h"
#include "pokedex.h"
#include "pokemon_icon.h"
#include "graphics.h"
diff --git a/src/trainer_fan_club.c b/src/trainer_fan_club.c
new file mode 100644
index 000000000..9040d3405
--- /dev/null
+++ b/src/trainer_fan_club.c
@@ -0,0 +1,359 @@
+#include "global.h"
+#include "gflib.h"
+#include "battle.h"
+#include "event_data.h"
+#include "event_scripts.h"
+#include "random.h"
+#include "constants/vars.h"
+#include "constants/flags.h"
+
+struct TrainerFanClub
+{
+ u8 timer:7;
+ u8 gotInitialFans:1;
+ u8 fanFlags;
+};
+
+#define TRAINER_FAN_CLUB ((struct TrainerFanClub *)GetVarPointer(VAR_FANCLUB_FAN_COUNTER))
+
+#define GET_TRAINER_FAN_CLUB_FLAG(flag) (fanClub->fanFlags >> (flag) & 1)
+#define SET_TRAINER_FAN_CLUB_FLAG(flag) (fanClub->fanFlags |= 1 << (flag))
+#define FLIP_TRAINER_FAN_CLUB_FLAG(flag)(fanClub->fanFlags ^= 1 << (flag))
+
+#define FANCLUB_MEMBER1 0
+#define FANCLUB_MEMBER2 1
+#define FANCLUB_MEMBER3 2
+#define FANCLUB_MEMBER4 3
+#define FANCLUB_MEMBER5 4
+#define FANCLUB_MEMBER6 5
+#define FANCLUB_MEMBER7 6
+#define FANCLUB_MEMBER8 7
+
+#define NUM_TRAINER_FAN_CLUB_MEMBERS 8
+
+static void TryLoseFansFromPlayTimeAfterLinkBattle(struct TrainerFanClub *);
+static void UpdateTrainerFanClubGameClear(struct TrainerFanClub *);
+static u8 PlayerGainRandomTrainerFan(struct TrainerFanClub *);
+static u16 GetNumFansOfPlayerInTrainerFanClub(struct TrainerFanClub *);
+static void TryLoseFansFromPlayTime(struct TrainerFanClub *);
+static bool16 IsFanClubMemberFanOfPlayer(struct TrainerFanClub *);
+static void SetInitialFansOfPlayer(struct TrainerFanClub *);
+static void BufferFanClubTrainerName(struct LinkBattleRecords *, u8, u8);
+static void UpdateTrainerFansAfterLinkBattle(struct TrainerFanClub *);
+static bool8 DidPlayerGetFirstFans(struct TrainerFanClub * );
+static void SetPlayerGotFirstFans(struct TrainerFanClub *);
+
+void ResetTrainerFanClub(void)
+{
+ VarSet(VAR_FANCLUB_FAN_COUNTER, 0);
+ VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, 0);
+}
+
+void Script_TryLoseFansFromPlayTimeAfterLinkBattle(void)
+{
+ TryLoseFansFromPlayTimeAfterLinkBattle(TRAINER_FAN_CLUB);
+}
+
+static void TryLoseFansFromPlayTimeAfterLinkBattle(struct TrainerFanClub *fanClub)
+{
+ if (DidPlayerGetFirstFans(fanClub))
+ {
+ TryLoseFansFromPlayTime(fanClub);
+ VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, gSaveBlock2Ptr->playTimeHours);
+ }
+}
+
+void Script_UpdateTrainerFanClubGameClear(void)
+{
+ UpdateTrainerFanClubGameClear(TRAINER_FAN_CLUB);
+}
+
+static void UpdateTrainerFanClubGameClear(struct TrainerFanClub *fanClub)
+{
+ if (!fanClub->gotInitialFans)
+ {
+ SetPlayerGotFirstFans(fanClub);
+ SetInitialFansOfPlayer(fanClub);
+ VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, gSaveBlock2Ptr->playTimeHours);
+ FlagClear(FLAG_HIDE_SAFFRON_FAN_CLUB_BLACKBELT);
+ FlagClear(FLAG_HIDE_SAFFRON_FAN_CLUB_ROCKER);
+ FlagClear(FLAG_HIDE_SAFFRON_FAN_CLUB_WOMAN);
+ FlagClear(FLAG_HIDE_SAFFRON_FAN_CLUB_BEAUTY);
+ VarSet(VAR_MAP_SCENE_SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB, 1);
+ }
+}
+
+ALIGNED(4) const u8 sCounterIncrements[] = {2, 1, 2, 1};
+
+static u8 TryGainNewFanFromCounter(struct TrainerFanClub *fanClub, u8 a1)
+{
+ if (VarGet(VAR_MAP_SCENE_SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB) == 2)
+ {
+ if (fanClub->timer + sCounterIncrements[a1] >= 20)
+ {
+ if (GetNumFansOfPlayerInTrainerFanClub(fanClub) < 3)
+ {
+ PlayerGainRandomTrainerFan(fanClub);
+ fanClub->timer = 0;
+ }
+ else
+ fanClub->timer = 20;
+ }
+ else
+ fanClub->timer += sCounterIncrements[a1];
+ }
+
+ return fanClub->timer;
+}
+
+
+static u8 PlayerGainRandomTrainerFan(struct TrainerFanClub *fanClub)
+{
+ static const u8 sFanClubMemberIds[] = {
+ FANCLUB_MEMBER2,
+ FANCLUB_MEMBER4,
+ FANCLUB_MEMBER6,
+ FANCLUB_MEMBER1,
+ FANCLUB_MEMBER8,
+ FANCLUB_MEMBER7,
+ FANCLUB_MEMBER5,
+ FANCLUB_MEMBER3
+ };
+
+ u8 i;
+ u8 idx = 0;
+
+ for (i = 0; i < NUM_TRAINER_FAN_CLUB_MEMBERS; i++)
+ {
+ if (!(GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i])))
+ {
+ idx = i;
+ if (Random() % 2)
+ {
+ SET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i]);
+ return sFanClubMemberIds[i];
+ }
+ }
+ }
+
+ SET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]);
+ return sFanClubMemberIds[idx];
+}
+
+static u8 PlayerLoseRandomTrainerFan(struct TrainerFanClub *fanClub)
+{
+ static const u8 sFanClubMemberIds[] =
+ {
+ FANCLUB_MEMBER6,
+ FANCLUB_MEMBER7,
+ FANCLUB_MEMBER4,
+ FANCLUB_MEMBER8,
+ FANCLUB_MEMBER5,
+ FANCLUB_MEMBER2,
+ FANCLUB_MEMBER1,
+ FANCLUB_MEMBER3
+ };
+
+ u8 i;
+ u8 idx = 0;
+
+ if (GetNumFansOfPlayerInTrainerFanClub(fanClub) == 1)
+ return 0;
+
+ for (i = 0; i < NUM_TRAINER_FAN_CLUB_MEMBERS; i++)
+ {
+ if (GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i]))
+ {
+ idx = i;
+ if (Random() % 2)
+ {
+ FLIP_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i]);
+ return sFanClubMemberIds[i];
+ }
+ }
+ }
+
+ if (GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]))
+ FLIP_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]);
+
+ return sFanClubMemberIds[idx];
+}
+
+u16 Script_GetNumFansOfPlayerInTrainerFanClub(void)
+{
+ return GetNumFansOfPlayerInTrainerFanClub(TRAINER_FAN_CLUB);
+}
+
+static u16 GetNumFansOfPlayerInTrainerFanClub(struct TrainerFanClub *fanClub)
+{
+ u8 count = 0;
+ u8 i;
+
+ for (i = 0; i < NUM_TRAINER_FAN_CLUB_MEMBERS; i++)
+ {
+ if (GET_TRAINER_FAN_CLUB_FLAG(i))
+ count++;
+ }
+
+ return count;
+}
+
+void Script_TryLoseFansFromPlayTime(void)
+{
+ TryLoseFansFromPlayTime(TRAINER_FAN_CLUB);
+}
+
+static void TryLoseFansFromPlayTime(struct TrainerFanClub *fanClub)
+{
+ u8 i = 0;
+ u16 timer;
+
+ if (gSaveBlock2Ptr->playTimeHours < 999)
+ {
+ while (1)
+ {
+ if (GetNumFansOfPlayerInTrainerFanClub(fanClub) < 5)
+ {
+ VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, gSaveBlock2Ptr->playTimeHours);
+ break;
+ }
+ if (i == NUM_TRAINER_FAN_CLUB_MEMBERS)
+ break;
+
+ timer = VarGet(VAR_FANCLUB_LOSE_FAN_TIMER);
+ if (gSaveBlock2Ptr->playTimeHours - timer < 12)
+ break;
+
+ PlayerLoseRandomTrainerFan(fanClub);
+ timer = VarGet(VAR_FANCLUB_LOSE_FAN_TIMER);
+ VarSet(VAR_FANCLUB_LOSE_FAN_TIMER, timer + 12);
+ i++;
+ }
+ }
+}
+
+bool16 Script_IsFanClubMemberFanOfPlayer(void)
+{
+ return IsFanClubMemberFanOfPlayer(TRAINER_FAN_CLUB);
+}
+
+static bool16 IsFanClubMemberFanOfPlayer(struct TrainerFanClub *fanClub)
+{
+ return GET_TRAINER_FAN_CLUB_FLAG(gSpecialVar_0x8004);
+}
+
+static void SetInitialFansOfPlayer(struct TrainerFanClub *fanClub)
+{
+ SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER1);
+ SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER2);
+ SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER3);
+}
+
+void Script_BufferFanClubTrainerName(void)
+{
+ u8 whichLinkTrainer = 0;
+ u8 whichNPCTrainer = 0;
+
+ switch (gSpecialVar_0x8004)
+ {
+ case FANCLUB_MEMBER1:
+ whichNPCTrainer = 0;
+ whichLinkTrainer = 0;
+ break;
+ case FANCLUB_MEMBER2:
+ case FANCLUB_MEMBER3:
+ case FANCLUB_MEMBER4:
+ case FANCLUB_MEMBER8:
+ break;
+ case FANCLUB_MEMBER5:
+ whichNPCTrainer = 1;
+ whichLinkTrainer = 0;
+ break;
+ case FANCLUB_MEMBER6:
+ whichNPCTrainer = 0;
+ whichLinkTrainer = 1;
+ break;
+ case FANCLUB_MEMBER7:
+ whichNPCTrainer = 2;
+ whichLinkTrainer = 1;
+ break;
+ }
+ BufferFanClubTrainerName(&gSaveBlock2Ptr->linkBattleRecords, whichLinkTrainer, whichNPCTrainer);
+}
+
+static void BufferFanClubTrainerName(struct LinkBattleRecords *linkRecords, u8 whichLinkTrainer, u8 whichNPCTrainer)
+{
+ u8 *str;
+ const u8 *linkTrainerName = linkRecords->entries[whichLinkTrainer].name;
+ if (linkTrainerName[0] == EOS)
+ {
+ switch (whichNPCTrainer)
+ {
+ case 0:
+ StringCopy(gStringVar1, gSaveBlock1Ptr->rivalName);
+ break;
+ case 1:
+ StringCopy(gStringVar1, gText_LtSurge);
+ break;
+ case 2:
+ StringCopy(gStringVar1, gText_Koga);
+ break;
+ default:
+ StringCopy(gStringVar1, gSaveBlock1Ptr->rivalName);
+ break;
+ }
+ }
+ else
+ {
+ str = gStringVar1;
+ StringCopyN(str, linkTrainerName, PLAYER_NAME_LENGTH);
+ str[PLAYER_NAME_LENGTH] = EOS;
+ if ( str[0] == EXT_CTRL_CODE_BEGIN
+ && str[1] == EXT_CTRL_CODE_JPN)
+ {
+ str += 2;
+ while (*str != EOS)
+ str++;
+ *str++ = EXT_CTRL_CODE_BEGIN;
+ *str++ = EXT_CTRL_CODE_ENG;
+ *str++ = EOS;
+ }
+ }
+}
+
+void Special_UpdateTrainerFansAfterLinkBattle(void)
+{
+ UpdateTrainerFansAfterLinkBattle(TRAINER_FAN_CLUB);
+}
+
+static void UpdateTrainerFansAfterLinkBattle(struct TrainerFanClub *fanClub)
+{
+ if (VarGet(VAR_MAP_SCENE_SAFFRON_CITY_POKEMON_TRAINER_FAN_CLUB) == 2)
+ {
+ TryLoseFansFromPlayTimeAfterLinkBattle(fanClub);
+ if (gBattleOutcome == B_OUTCOME_WON)
+ PlayerGainRandomTrainerFan(fanClub);
+ else
+ PlayerLoseRandomTrainerFan(fanClub);
+ }
+}
+
+static bool8 DidPlayerGetFirstFans(struct TrainerFanClub *fanClub)
+{
+ return fanClub->gotInitialFans;
+}
+
+void Script_SetPlayerGotFirstFans(void)
+{
+ SetPlayerGotFirstFans(TRAINER_FAN_CLUB);
+}
+
+static void SetPlayerGotFirstFans(struct TrainerFanClub *fanClub)
+{
+ fanClub->gotInitialFans = TRUE;
+}
+
+u8 Script_TryGainNewFanFromCounter(void)
+{
+ return TryGainNewFanFromCounter(TRAINER_FAN_CLUB, gSpecialVar_0x8004);
+}
diff --git a/src/trainer_pokemon_sprites.c b/src/trainer_pokemon_sprites.c
index 8567d791b..f88a0d803 100644
--- a/src/trainer_pokemon_sprites.c
+++ b/src/trainer_pokemon_sprites.c
@@ -1,10 +1,6 @@
#include "global.h"
-#include "sprite.h"
-#include "window.h"
-#include "malloc.h"
-#include "palette.h"
+#include "gflib.h"
#include "decompress.h"
-#include "pokemon.h"
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const struct CompressedSpriteSheet gMonBackPicTable[];
diff --git a/src/trainer_tower.c b/src/trainer_tower.c
index 64acbacd8..06c4a2fad 100644
--- a/src/trainer_tower.c
+++ b/src/trainer_tower.c
@@ -1,23 +1,17 @@
#include "global.h"
-#include "main.h"
-#include "task.h"
-#include "malloc.h"
+#include "gflib.h"
#include "util.h"
-#include "string_util.h"
#include "event_data.h"
#include "cereader_tool.h"
#include "easy_chat.h"
-#include "text.h"
#include "battle_setup.h"
#include "battle_transition.h"
#include "battle.h"
#include "battle_main.h"
#include "overworld.h"
#include "item.h"
-#include "window.h"
#include "menu.h"
#include "new_menu_helpers.h"
-#include "sound.h"
#include "constants/vars.h"
#include "constants/items.h"
#include "constants/species.h"
diff --git a/src/union_room.c b/src/union_room.c
index 7bace05ef..ea9b213ab 100644
--- a/src/union_room.c
+++ b/src/union_room.c
@@ -1789,7 +1789,7 @@ static void Task_ExchangeCards(u8 taskId)
{
case 0:
if (GetMultiplayerId() == 0)
- sub_800A474(2);
+ Link_PrepareCmd0xCCCC_Rfu0xA100(2);
gTasks[taskId].data[0]++;
break;
case 1:
@@ -3461,7 +3461,7 @@ void InitUnionRoom(void)
struct UnkStruct_URoom * ptr;
sUnionRoomPlayerName[0] = EOS;
- if (gQuestLogState == 2 || gQuestLogState == 3)
+ if (QL_IS_PLAYBACK_STATE)
return;
CreateTask(Task_InitUnionRoom, 0);
sUnionRoomMain.uRoom = sUnionRoomMain.uRoom; // Needed to match.
diff --git a/src/union_room_battle.c b/src/union_room_battle.c
index b4d8af9ce..c6b5f485b 100644
--- a/src/union_room_battle.c
+++ b/src/union_room_battle.c
@@ -1,18 +1,14 @@
#include "global.h"
-#include "bg.h"
+#include "gflib.h"
#include "battle.h"
-#include "gpu_regs.h"
#include "link.h"
-#include "malloc.h"
#include "menu.h"
#include "new_menu_helpers.h"
#include "overworld.h"
-#include "palette.h"
#include "party_menu.h"
#include "strings.h"
#include "text_window.h"
#include "union_room.h"
-#include "window.h"
#include "constants/union_room.h"
struct UnionRoomBattleWork
diff --git a/src/vs_seeker.c b/src/vs_seeker.c
index 849c599e8..eb49a5e45 100644
--- a/src/vs_seeker.c
+++ b/src/vs_seeker.c
@@ -1,8 +1,7 @@
#include "global.h"
+#include "gflib.h"
#include "constants/songs.h"
-#include "sound.h"
#include "task.h"
-#include "malloc.h"
#include "event_object_movement.h"
#include "new_menu_helpers.h"
#include "item_use.h"
@@ -26,6 +25,7 @@
#include "constants/maps.h"
#include "constants/items.h"
#include "constants/quest_log.h"
+#include "constants/trainer_types.h"
enum
{
@@ -83,28 +83,30 @@ static EWRAM_DATA struct VsSeekerStruct *sVsSeeker = NULL;
static void VsSeekerResetInBagStepCounter(void);
static void VsSeekerResetChargingStepCounter(void);
static void Task_ResetObjectsRematchWantedState(u8 taskId);
-static void sub_810C594(void);
+static void ResetMovementOfRematchableTrainers(void);
static void Task_VsSeeker_1(u8 taskId);
static void Task_VsSeeker_2(u8 taskId);
static void GatherNearbyTrainerInfo(void);
static void Task_VsSeeker_3(u8 taskId);
static bool8 CanUseVsSeeker(void);
static u8 GetVsSeekerResponseInArea(const VsSeekerData *);
-static u8 GetRematchTrainerIdGivenGameState(const u16 *, u8);
-static u8 sub_810CD80(const VsSeekerData *, u16);
+static u8 GetRematchTrainerIdGivenGameState(const u16 *trainerIdxs, u8 rematchIdx);
+static u8 ShouldTryRematchBattleInternal(const VsSeekerData *, u16);
static u8 HasRematchTrainerAlreadyBeenFought(const VsSeekerData *, u16);
-static s32 sub_810CE10(const VsSeekerData * a0, u16 a1);
-static bool8 sub_810CED0(const VsSeekerData *, u16);
+static int LookupVsSeekerOpponentInArray(const VsSeekerData * array, u16 trainerId);
+static bool8 IsTrainerReadyForRematchInternal(const VsSeekerData *, u16);
static u8 GetRunningBehaviorFromGraphicsId(u8);
static u16 GetTrainerFlagFromScript(const u8 *);
-static s32 GetRematchIdx(const VsSeekerData *, u16);
+static int GetRematchIdx(const VsSeekerData *, u16);
static bool32 IsThisTrainerRematchable(u32);
+static void ClearAllTrainerRematchStates(void);
static bool8 IsTrainerVisibleOnScreen(struct VsSeekerTrainerInfo *);
static u8 GetNextAvailableRematchTrainer(const VsSeekerData *, u16, u8 *);
static u8 GetRematchableTrainerLocalId(void);
static void StartTrainerObjectMovementScript(struct VsSeekerTrainerInfo *, const u8 *);
static u8 GetCurVsSeekerResponse(s32, u16);
static void StartAllRespondantIdleMovements(void);
+static bool8 ObjectEventIdIsSane(u8 a0);
static u8 GetRandomFaceDirectionMovementType();
// rodata
@@ -553,14 +555,14 @@ static const VsSeekerData sVsSeekerData[] = {
MAP_GROUP(SEVEN_ISLAND_TANOBY_RUINS), MAP_NUM(SEVEN_ISLAND_TANOBY_RUINS) },
};
-static const u8 gUnknown_8453F5C[] = {
+static const u8 sMovementScript_Wait48[] = {
MOVEMENT_ACTION_DELAY_16,
MOVEMENT_ACTION_DELAY_16,
MOVEMENT_ACTION_DELAY_16,
MOVEMENT_ACTION_STEP_END
};
-static const u8 gUnknown_8453F60[] = {
+static const u8 sMovementScript_TrainerUnfought[] = {
MOVEMENT_ACTION_EMOTE_EXCLAMATION_MARK,
MOVEMENT_ACTION_STEP_END
};
@@ -576,7 +578,7 @@ static const u8 sMovementScript_TrainerRematch[] = {
MOVEMENT_ACTION_STEP_END
};
-static const u8 gUnknown_8453F67[] = {
+static const u8 sFaceDirectionMovementTypeByFacingDirection[] = {
MOVEMENT_TYPE_FACE_DOWN,
MOVEMENT_TYPE_FACE_DOWN,
MOVEMENT_TYPE_FACE_UP,
@@ -598,7 +600,7 @@ static void Task_ResetObjectsRematchWantedState(u8 taskId)
if (task->data[0] == 0 && walkrun_is_standing_still() == TRUE)
{
- sub_805C270();
+ HandleEnforcedLookDirectionOnPlayerStopMoving();
task->data[0] = 1;
}
@@ -606,7 +608,7 @@ static void Task_ResetObjectsRematchWantedState(u8 taskId)
{
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
- if (sub_810CF04(i) == TRUE)
+ if (ObjectEventIdIsSane(i) == TRUE)
{
if (gObjectEvents[i].singleMovementActive)
return;
@@ -639,7 +641,7 @@ void VsSeekerResetObjectMovementAfterChargeComplete(void)
movementType = GetRandomFaceDirectionMovementType();
TryGetObjectEventIdByLocalIdAndMap(templates[i].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objEventId);
objectEvent = &gObjectEvents[objEventId];
- if (sub_810CF04(objEventId) == TRUE)
+ if (ObjectEventIdIsSane(objEventId) == TRUE)
{
SetTrainerMovementType(objectEvent, movementType);
}
@@ -674,7 +676,7 @@ bool8 UpdateVsSeekerStepCounter(void)
{
FlagClear(FLAG_SYS_VS_SEEKER_CHARGING);
VsSeekerResetChargingStepCounter();
- sub_810D0D0();
+ ClearAllTrainerRematchStates();
return TRUE;
}
}
@@ -682,15 +684,15 @@ bool8 UpdateVsSeekerStepCounter(void)
return FALSE;
}
-void TryUpdateRandomTrainerRematches(u16 mapGroup, u16 mapNum)
+void MapResetTrainerRematches(u16 mapGroup, u16 mapNum)
{
FlagClear(FLAG_SYS_VS_SEEKER_CHARGING);
VsSeekerResetChargingStepCounter();
- sub_810D0D0();
- sub_810C594();
+ ClearAllTrainerRematchStates();
+ ResetMovementOfRematchableTrainers();
}
-static void sub_810C594(void)
+static void ResetMovementOfRematchableTrainers(void)
{
u8 i;
@@ -746,12 +748,12 @@ void Task_VsSeeker_0(u8 taskId)
if (respval == VSSEEKER_NOT_CHARGED)
{
Free(sVsSeeker);
- DisplayItemMessageOnField(taskId, 2, VSSeeker_Text_BatteryNotChargedNeedXSteps, sub_80A1E0C);
+ DisplayItemMessageOnField(taskId, 2, VSSeeker_Text_BatteryNotChargedNeedXSteps, Task_ItemUse_CloseMessageBoxAndReturnToField_VsSeeker);
}
else if (respval == VSSEEKER_NO_ONE_IN_RANGE)
{
Free(sVsSeeker);
- DisplayItemMessageOnField(taskId, 2, VSSeeker_Text_NoTrainersWithinRange, sub_80A1E0C);
+ DisplayItemMessageOnField(taskId, 2, VSSeeker_Text_NoTrainersWithinRange, Task_ItemUse_CloseMessageBoxAndReturnToField_VsSeeker);
}
else if (respval == VSSEEKER_CAN_USE)
{
@@ -788,7 +790,7 @@ static void Task_VsSeeker_2(u8 taskId)
data[2] = 0;
VsSeekerResetInBagStepCounter();
sVsSeeker->responseCode = GetVsSeekerResponseInArea(sVsSeekerData);
- ScriptMovement_StartObjectMovementScript(0xFF, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gUnknown_8453F5C);
+ ScriptMovement_StartObjectMovementScript(0xFF, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, sMovementScript_Wait48);
gTasks[taskId].func = Task_VsSeeker_3;
}
}
@@ -824,14 +826,14 @@ static void Task_VsSeeker_3(u8 taskId)
{
if (sVsSeeker->responseCode == VSSEEKER_RESPONSE_NO_RESPONSE)
{
- DisplayItemMessageOnField(taskId, 2, VSSeeker_Text_TrainersNotReady, sub_80A1E0C);
+ DisplayItemMessageOnField(taskId, 2, VSSeeker_Text_TrainersNotReady, Task_ItemUse_CloseMessageBoxAndReturnToField_VsSeeker);
}
else
{
if (sVsSeeker->responseCode == VSSEEKER_RESPONSE_FOUND_REMATCHES)
StartAllRespondantIdleMovements();
- ClearDialogWindowAndFrame(0, 1);
- sub_80696C0();
+ ClearDialogWindowAndFrame(0, TRUE);
+ ClearPlayerHeldMovementAndUnfreezeObjectEvents();
ScriptContext2_Disable();
DestroyTask(taskId);
}
@@ -875,7 +877,7 @@ static u8 GetVsSeekerResponseInArea(const VsSeekerData * a0)
r8 = sVsSeeker->trainerInfo[vsSeekerIdx].trainerIdx;
if (!HasTrainerBeenFought(r8))
{
- StartTrainerObjectMovementScript(&sVsSeeker->trainerInfo[vsSeekerIdx], gUnknown_8453F60);
+ StartTrainerObjectMovementScript(&sVsSeeker->trainerInfo[vsSeekerIdx], sMovementScript_TrainerUnfought);
sVsSeeker->trainerInfo[vsSeekerIdx].trainerIdx += 0;
sVsSeeker->trainerHasNotYetBeenFought = 1;
}
@@ -943,86 +945,86 @@ static u8 GetVsSeekerResponseInArea(const VsSeekerData * a0)
return VSSEEKER_RESPONSE_NO_RESPONSE;
}
-void sub_810CB90(void)
+void ClearRematchStateByTrainerId(void)
{
u8 objEventId = 0;
- struct ObjectEventTemplate *r4 = gSaveBlock1Ptr->objectEventTemplates;
- s32 r9 = sub_810CE10(sVsSeekerData, gTrainerBattleOpponent_A);
+ struct ObjectEventTemplate *objectEventTemplates = gSaveBlock1Ptr->objectEventTemplates;
+ int vsSeekerDataIdx = LookupVsSeekerOpponentInArray(sVsSeekerData, gTrainerBattleOpponent_A);
- if (r9 != -1)
+ if (vsSeekerDataIdx != -1)
{
- s32 r8;
+ int i;
- for (r8 = 0; r8 < gMapHeader.events->objectEventCount; r8++)
+ for (i = 0; i < gMapHeader.events->objectEventCount; i++)
{
- if ((r4[r8].trainerType == 1 || r4[r8].trainerType == 3) && r9 == sub_810CE10(sVsSeekerData, GetTrainerFlagFromScript(r4[r8].script)))
+ if ((objectEventTemplates[i].trainerType == TRAINER_TYPE_NORMAL || objectEventTemplates[i].trainerType == TRAINER_TYPE_BURIED) && vsSeekerDataIdx == LookupVsSeekerOpponentInArray(sVsSeekerData, GetTrainerFlagFromScript(objectEventTemplates[i].script)))
{
- struct ObjectEvent *r4_2;
+ struct ObjectEvent *objectEvent;
- TryGetObjectEventIdByLocalIdAndMap(r4[r8].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objEventId);
- r4_2 = &gObjectEvents[objEventId];
- GetRandomFaceDirectionMovementType(&r4[r8]); // You are using this function incorrectly. Please consult the manual.
- OverrideMovementTypeForObjectEvent(r4_2, gUnknown_8453F67[r4_2->facingDirection]);
- gSaveBlock1Ptr->trainerRematches[r4[r8].localId] = 0;
+ TryGetObjectEventIdByLocalIdAndMap(objectEventTemplates[i].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objEventId);
+ objectEvent = &gObjectEvents[objEventId];
+ GetRandomFaceDirectionMovementType(&objectEventTemplates[i]); // You are using this function incorrectly. Please consult the manual.
+ OverrideMovementTypeForObjectEvent(objectEvent, sFaceDirectionMovementTypeByFacingDirection[objectEvent->facingDirection]);
+ gSaveBlock1Ptr->trainerRematches[objectEventTemplates[i].localId] = 0;
if (gSelectedObjectEvent == objEventId)
- r4_2->movementType = gUnknown_8453F67[r4_2->facingDirection];
+ objectEvent->movementType = sFaceDirectionMovementTypeByFacingDirection[objectEvent->facingDirection];
else
- r4_2->movementType = MOVEMENT_TYPE_FACE_DOWN;
+ objectEvent->movementType = MOVEMENT_TYPE_FACE_DOWN;
}
}
}
}
-static void TryGetRematchTrainerIdGivenGameState(const u16 * a0, u8 * a1)
+static void TryGetRematchTrainerIdGivenGameState(const u16 * trainerIdxs, u8 * rematchIdx_p)
{
- switch (*a1)
+ switch (*rematchIdx_p)
{
case 0:
break;
case 1:
if (!FlagGet(FLAG_GOT_VS_SEEKER))
- *a1 = GetRematchTrainerIdGivenGameState(a0, *a1);
+ *rematchIdx_p = GetRematchTrainerIdGivenGameState(trainerIdxs, *rematchIdx_p);
break;
case 2:
if (!FlagGet(FLAG_WORLD_MAP_CELADON_CITY))
- *a1 = GetRematchTrainerIdGivenGameState(a0, *a1);
+ *rematchIdx_p = GetRematchTrainerIdGivenGameState(trainerIdxs, *rematchIdx_p);
break;
case 3:
if (!FlagGet(FLAG_WORLD_MAP_FUCHSIA_CITY))
- *a1 = GetRematchTrainerIdGivenGameState(a0, *a1);
+ *rematchIdx_p = GetRematchTrainerIdGivenGameState(trainerIdxs, *rematchIdx_p);
break;
case 4:
if (!FlagGet(FLAG_SYS_GAME_CLEAR))
- *a1 = GetRematchTrainerIdGivenGameState(a0, *a1);
+ *rematchIdx_p = GetRematchTrainerIdGivenGameState(trainerIdxs, *rematchIdx_p);
break;
case 5:
if (!FlagGet(FLAG_SYS_CAN_LINK_WITH_RS))
- *a1 = GetRematchTrainerIdGivenGameState(a0, *a1);
+ *rematchIdx_p = GetRematchTrainerIdGivenGameState(trainerIdxs, *rematchIdx_p);
break;
}
}
-static u8 GetRematchTrainerIdGivenGameState(const u16 * a0, u8 a1)
+static u8 GetRematchTrainerIdGivenGameState(const u16 *trainerIdxs, u8 rematchIdx)
{
- while (--a1 != 0)
+ while (--rematchIdx != 0)
{
- const u16 *r0 = a0 + a1;
- if (*r0 != 0xFFFF)
- return a1;
+ const u16 *rematch_p = trainerIdxs + rematchIdx;
+ if (*rematch_p != 0xFFFF)
+ return rematchIdx;
}
return 0;
}
u8 ShouldTryRematchBattle(void)
{
- if (sub_810CD80(sVsSeekerData, gTrainerBattleOpponent_A))
+ if (ShouldTryRematchBattleInternal(sVsSeekerData, gTrainerBattleOpponent_A))
{
return 1;
}
return HasRematchTrainerAlreadyBeenFought(sVsSeekerData, gTrainerBattleOpponent_A);
}
-static bool8 sub_810CD80(const VsSeekerData *vsSeekerData, u16 trainerBattleOpponent)
+static bool8 ShouldTryRematchBattleInternal(const VsSeekerData *vsSeekerData, u16 trainerBattleOpponent)
{
s32 rematchIdx = GetRematchIdx(vsSeekerData, trainerBattleOpponent);
@@ -1047,40 +1049,39 @@ static bool8 HasRematchTrainerAlreadyBeenFought(const VsSeekerData *vsSeekerData
return TRUE;
}
-void sub_810CDE8(void)
+void ClearRematchStateOfLastTalked(void)
{
gSaveBlock1Ptr->trainerRematches[gSpecialVar_LastTalked] = 0;
SetBattledTrainerFlag();
}
-static s32 sub_810CE10(const VsSeekerData * a0, u16 a1)
+static int LookupVsSeekerOpponentInArray(const VsSeekerData * array, u16 trainerId)
{
- u32 r1;
- s32 r3;
+ int i, j;
- for (r1 = 0; r1 < NELEMS(sVsSeekerData); r1++)
+ for (i = 0; i < NELEMS(sVsSeekerData); i++)
{
- for (r3 = 0; r3 < 6; r3++)
+ for (j = 0; j < 6; j++)
{
- u16 r0;
- if (a0[r1].trainerIdxs[r3] == 0)
+ u16 testTrainerId;
+ if (array[i].trainerIdxs[j] == 0)
break;
- r0 = a0[r1].trainerIdxs[r3];
- if (r0 == 0xFFFF)
+ testTrainerId = array[i].trainerIdxs[j];
+ if (testTrainerId == 0xFFFF)
continue;
- if (r0 == a1)
- return r1;
+ if (testTrainerId == trainerId)
+ return i;
}
}
return -1;
}
-s32 GetRematchTrainerId(u16 a0)
+int GetRematchTrainerId(u16 trainerId)
{
u8 i;
u8 j;
- j = GetNextAvailableRematchTrainer(sVsSeekerData, a0, &i);
+ j = GetNextAvailableRematchTrainer(sVsSeekerData, trainerId, &i);
if (!j)
return 0;
TryGetRematchTrainerIdGivenGameState(sVsSeekerData[i].trainerIdxs, &j);
@@ -1089,27 +1090,27 @@ s32 GetRematchTrainerId(u16 a0)
u8 IsTrainerReadyForRematch(void)
{
- return sub_810CED0(sVsSeekerData, gTrainerBattleOpponent_A);
+ return IsTrainerReadyForRematchInternal(sVsSeekerData, gTrainerBattleOpponent_A);
}
-static bool8 sub_810CED0(const VsSeekerData * a0, u16 a1)
+static bool8 IsTrainerReadyForRematchInternal(const VsSeekerData * array, u16 trainerId)
{
- s32 r1 = sub_810CE10(a0, a1);
+ int rematchTrainerIdx = LookupVsSeekerOpponentInArray(array, trainerId);
- if (r1 == -1)
+ if (rematchTrainerIdx == -1)
return FALSE;
- if ((u32)r1 >= NELEMS(sVsSeekerData))
+ if (rematchTrainerIdx >= NELEMS(sVsSeekerData))
return FALSE;
if (!IsThisTrainerRematchable(gSpecialVar_LastTalked))
return FALSE;
return TRUE;
}
-bool8 sub_810CF04(u8 a0)
+static bool8 ObjectEventIdIsSane(u8 objectEventId)
{
- struct ObjectEvent *r1 = &gObjectEvents[a0];
+ struct ObjectEvent *objectEvent = &gObjectEvents[objectEventId];
- if (r1->active && gMapHeader.events->objectEventCount >= r1->localId && gSprites[r1->spriteId].data[0] == a0)
+ if (objectEvent->active && gMapHeader.events->objectEventCount >= objectEvent->localId && gSprites[objectEvent->spriteId].data[0] == objectEventId)
return TRUE;
return FALSE;
}
@@ -1190,9 +1191,9 @@ static u16 GetTrainerFlagFromScript(const u8 *script)
return trainerFlag;
}
-static s32 GetRematchIdx(const VsSeekerData * vsSeekerData, u16 trainerFlagIdx)
+static int GetRematchIdx(const VsSeekerData * vsSeekerData, u16 trainerFlagIdx)
{
- u32 i;
+ int i;
for (i = 0; i < NELEMS(sVsSeekerData); i++)
{
@@ -1210,7 +1211,7 @@ static bool32 IsThisTrainerRematchable(u32 a0)
return TRUE;
}
-void sub_810D0D0(void)
+static void ClearAllTrainerRematchStates(void)
{
u8 i;
@@ -1231,15 +1232,14 @@ static bool8 IsTrainerVisibleOnScreen(struct VsSeekerTrainerInfo * trainerInfo)
&& x + 7 >= trainerInfo->xCoord
&& y - 5 <= trainerInfo->yCoord
&& y + 5 >= trainerInfo->yCoord
- && sub_810CF04(trainerInfo->objectEventId) == 1)
+ && ObjectEventIdIsSane(trainerInfo->objectEventId) == 1)
return TRUE;
return FALSE;
}
static u8 GetNextAvailableRematchTrainer(const VsSeekerData * vsSeekerData, u16 trainerFlagNo, u8 * idxPtr)
{
- u32 i;
- s32 j;
+ int i, j;
for (i = 0; i < NELEMS(sVsSeekerData); i++)
{
@@ -1321,7 +1321,7 @@ static void StartAllRespondantIdleMovements(void)
{
struct ObjectEvent *r4 = &gObjectEvents[sVsSeeker->trainerInfo[j].objectEventId];
- if (sub_810CF04(sVsSeeker->trainerInfo[j].objectEventId) == 1)
+ if (ObjectEventIdIsSane(sVsSeeker->trainerInfo[j].objectEventId) == 1)
SetTrainerMovementType(r4, sVsSeeker->runningBehaviourEtcArray[i]);
OverrideMovementTypeForObjectEvent(r4, sVsSeeker->runningBehaviourEtcArray[i]);
gSaveBlock1Ptr->trainerRematches[sVsSeeker->trainerInfo[j].localId] = GetNextAvailableRematchTrainer(sVsSeekerData, sVsSeeker->trainerInfo[j].trainerIdx, &dummy);
diff --git a/src/wild_encounter.c b/src/wild_encounter.c
index 118df3c8c..5e1daaf36 100644
--- a/src/wild_encounter.c
+++ b/src/wild_encounter.c
@@ -584,7 +584,7 @@ bool8 UpdateRepelCounter(void)
if (InUnionRoom() == TRUE)
return FALSE;
- if (gQuestLogState == 2)
+ if (gQuestLogState == QL_STATE_PLAYBACK)
return FALSE;
steps = VarGet(VAR_REPEL_STEP_COUNT);
diff --git a/src/window.c b/src/window.c
index 4aaa6d9b4..a7cec4186 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,8 +1,5 @@
#include "global.h"
-#include "window.h"
-#include "malloc.h"
-#include "bg.h"
-#include "blit.h"
+#include "gflib.h"
u8 gWindowClearTile;
void *gWindowBgTilemapBuffers[4];
diff --git a/src/window_8bpp.c b/src/window_8bpp.c
index 8977d61e4..441dbbef8 100644
--- a/src/window_8bpp.c
+++ b/src/window_8bpp.c
@@ -1,8 +1,5 @@
#include "global.h"
-#include "window.h"
-#include "malloc.h"
-#include "bg.h"
-#include "blit.h"
+#include "gflib.h"
EWRAM_DATA static struct Window* sWindowPtr = NULL;
EWRAM_DATA static u16 sWindowSize = 0;
diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c
index a284a6d16..f8f552711 100644
--- a/src/wireless_communication_status_screen.c
+++ b/src/wireless_communication_status_screen.c
@@ -1,18 +1,11 @@
#include "global.h"
-#include "bg.h"
-#include "palette.h"
-#include "gpu_regs.h"
-#include "malloc.h"
+#include "gflib.h"
#include "task.h"
-#include "text.h"
-#include "window.h"
#include "new_menu_helpers.h"
#include "scanline_effect.h"
#include "m4a.h"
-#include "string_util.h"
#include "dynamic_placeholder_text_util.h"
#include "overworld.h"
-#include "sound.h"
#include "strings.h"
#include "menu.h"
#include "librfu.h"