diff --git a/Makefile b/Makefile index 1841eb6b8..c9a7c2e05 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ ASFLAGS := -mcpu=arm7tdmi CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include +CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include -Wno-trigraphs LDFLAGS = -Map ../../$(MAP) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 091c32a2a..fa0b3fa06 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -313,7 +313,7 @@ .endm @ Runs time based events. In FireRed, this command is a nop. - .macro dodailyevents + .macro dotimebasedevents .byte 0x2d .endm diff --git a/data/event_scripts.s b/data/event_scripts.s index 8d8b0cd68..7ee8e6cf2 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1748,7 +1748,7 @@ RustboroCity_Gym_EventScript_271E84:: @ 8271E84 DewfordTown_EventScript_271E8B:: @ 8271E8B DewfordTown_Hall_EventScript_271E8B:: @ 8271E8B - dodailyevents + dotimebasedevents setvar VAR_0x8004, 0 special BufferTrendyPhraseString return diff --git a/data/maps/LilycoveCity/scripts.inc b/data/maps/LilycoveCity/scripts.inc index c1cec509f..cfa6b3867 100644 --- a/data/maps/LilycoveCity/scripts.inc +++ b/data/maps/LilycoveCity/scripts.inc @@ -33,7 +33,7 @@ LilycoveCity_EventScript_1E2B6B:: @ 81E2B6B LilycoveCity_EventScript_1E2BD8:: @ 81E2BD8 lock faceplayer - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_LILYCOVE_RECEIVED_BERRY, LilycoveCity_EventScript_1E2C18 msgbox LilycoveCity_Text_2A7244, MSGBOX_DEFAULT random 10 diff --git a/data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc b/data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc index 2f8fcda3a..ffa2244f4 100644 --- a/data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc +++ b/data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc @@ -8,7 +8,7 @@ LilycoveCity_DepartmentStore_1F_EventScript_21F693:: @ 821F693 LilycoveCity_DepartmentStore_1F_EventScript_21F69C:: @ 821F69C lock faceplayer - dodailyevents + dotimebasedevents compare VAR_POKELOT_PRIZE, 0 goto_if_ne LilycoveCity_DepartmentStore_1F_EventScript_21F7F7 goto_if_set FLAG_DAILY_PICKED_LOTO_TICKET, LilycoveCity_DepartmentStore_1F_EventScript_21F78D diff --git a/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc b/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc index e875be96f..6d9022065 100644 --- a/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc +++ b/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc @@ -52,7 +52,7 @@ MossdeepCity_SpaceCenter_1F_EventScript_222FD8:: @ 8222FD8 faceplayer compare VAR_0x405D, 2 goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_223024 - dodailyevents + dotimebasedevents specialvar VAR_RESULT, GetWeekCount buffernumberstring 0, VAR_RESULT compare VAR_RESULT, 0 @@ -74,7 +74,7 @@ MossdeepCity_SpaceCenter_1F_EventScript_22301B:: @ 822301B return MossdeepCity_SpaceCenter_1F_EventScript_223024:: @ 8223024 - dodailyevents + dotimebasedevents specialvar VAR_RESULT, GetWeekCount buffernumberstring 0, VAR_RESULT compare VAR_RESULT, 0 diff --git a/data/maps/PacifidlogTown_House2/scripts.inc b/data/maps/PacifidlogTown_House2/scripts.inc index b3078fa2d..c7c04c0bd 100644 --- a/data/maps/PacifidlogTown_House2/scripts.inc +++ b/data/maps/PacifidlogTown_House2/scripts.inc @@ -4,7 +4,7 @@ PacifidlogTown_House2_MapScripts:: @ 8203791 PacifidlogTown_House2_EventScript_203792:: @ 8203792 lock faceplayer - dodailyevents + dotimebasedevents call PacifidlogTown_House2_EventScript_2037DE goto_if_set FLAG_RECEIVED_FANCLUB_TM_THIS_WEEK, PacifidlogTown_House2_EventScript_20387E call_if_set FLAG_MET_FANCLUB_YOUNGER_BROTHER, PacifidlogTown_House2_EventScript_2037F8 diff --git a/data/maps/Route104_PrettyPetalFlowerShop/scripts.inc b/data/maps/Route104_PrettyPetalFlowerShop/scripts.inc index e9af43d73..7f5e35287 100644 --- a/data/maps/Route104_PrettyPetalFlowerShop/scripts.inc +++ b/data/maps/Route104_PrettyPetalFlowerShop/scripts.inc @@ -84,7 +84,7 @@ Route104_PrettyPetalFlowerShop_EventScript_22A421:: @ 822A421 Route104_PrettyPetalFlowerShop_EventScript_22A442:: @ 822A442 lock faceplayer - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_FLOWER_SHOP_RECEIVED_BERRY, Route104_PrettyPetalFlowerShop_EventScript_22A482 msgbox Route104_PrettyPetalFlowerShop_Text_2A7A98, MSGBOX_DEFAULT random 8 diff --git a/data/maps/Route111/scripts.inc b/data/maps/Route111/scripts.inc index 75de7dce7..74ee42c64 100644 --- a/data/maps/Route111/scripts.inc +++ b/data/maps/Route111/scripts.inc @@ -159,7 +159,7 @@ Route111_Movement_1F0EB1:: @ 81F0EB1 Route111_EventScript_1F0EB9:: @ 81F0EB9 lock faceplayer - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_ROUTE_111_RECEIVED_BERRY, Route111_EventScript_1F0EF4 msgbox Route111_Text_2A6EBD, MSGBOX_DEFAULT giveitem_std ITEM_RAZZ_BERRY diff --git a/data/maps/Route114/scripts.inc b/data/maps/Route114/scripts.inc index 8f0c1c6ac..cccc8de5f 100644 --- a/data/maps/Route114/scripts.inc +++ b/data/maps/Route114/scripts.inc @@ -27,7 +27,7 @@ Route114_MapScript2_1F2578: @ 81F2578 Route114_EventScript_1F2582:: @ 81F2582 lock faceplayer - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_ROUTE_114_RECEIVED_BERRY, Route114_EventScript_1F25C7 msgbox Route114_Text_2A6FCB, MSGBOX_DEFAULT random 5 diff --git a/data/maps/Route120/scripts.inc b/data/maps/Route120/scripts.inc index cd864e1dc..a66026283 100644 --- a/data/maps/Route120/scripts.inc +++ b/data/maps/Route120/scripts.inc @@ -98,7 +98,7 @@ Route120_EventScript_1F5523:: @ 81F5523 Route120_EventScript_1F5527:: @ 81F5527 lock faceplayer - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_ROUTE_120_RECEIVED_BERRY, Route120_EventScript_1F5625 msgbox Route120_Text_2A70C7, MSGBOX_YESNO compare VAR_RESULT, 1 diff --git a/data/maps/Route123_BerryMastersHouse/scripts.inc b/data/maps/Route123_BerryMastersHouse/scripts.inc index a3ae5df93..a7175e698 100644 --- a/data/maps/Route123_BerryMastersHouse/scripts.inc +++ b/data/maps/Route123_BerryMastersHouse/scripts.inc @@ -9,7 +9,7 @@ Route123_BerryMastersHouse_MapScript1_26F841: @ 826F841 Route123_BerryMastersHouse_EventScript_26F845:: @ 826F845 lock faceplayer - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_BERRY_MASTER_RECEIVED_BERRY, Route123_BerryMastersHouse_EventScript_26F8B6 msgbox Route123_BerryMastersHouse_Text_2A7386, MSGBOX_DEFAULT random 10 @@ -38,7 +38,7 @@ Route123_BerryMastersHouse_EventScript_26F8B6:: @ 826F8B6 Route123_BerryMastersHouse_EventScript_26F8C0:: @ 826F8C0 lock faceplayer - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_BERRY_MASTERS_WIFE, Route123_BerryMastersHouse_EventScript_26FA6F msgbox Route123_BerryMastersHouse_Text_2A74E6, MSGBOX_DEFAULT setvar VAR_0x8004, 13 diff --git a/data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc b/data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc index 6e0f4eddb..2874da963 100644 --- a/data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc +++ b/data/maps/ShoalCave_LowTideEntranceRoom/scripts.inc @@ -18,7 +18,7 @@ ShoalCave_LowTideEntranceRoom_EventScript_236DD5:: @ 8236DD5 ShoalCave_LowTideEntranceRoom_EventScript_236DD9:: @ 8236DD9 lock faceplayer - dodailyevents + dotimebasedevents call_if_set FLAG_SYS_SHOAL_ITEM, ShoalCave_LowTideEntranceRoom_EventScript_236ED9 checkitem ITEM_SHOAL_SALT, 4 compare VAR_RESULT, 0 diff --git a/data/maps/SootopolisCity/scripts.inc b/data/maps/SootopolisCity/scripts.inc index 5666ce6cf..1cd4611e9 100644 --- a/data/maps/SootopolisCity/scripts.inc +++ b/data/maps/SootopolisCity/scripts.inc @@ -742,7 +742,7 @@ SootopolisCity_EventScript_1E5F10:: @ 81E5F10 end SootopolisCity_EventScript_1E5F1B:: @ 81E5F1B - dodailyevents + dotimebasedevents special GetPlayerBigGuyGirlString goto_if_set FLAG_DAILY_SOOTOPOLIS_RECEIVED_BERRY, SootopolisCity_EventScript_1E5FBB msgbox SootopolisCity_Text_2A7BB0, MSGBOX_DEFAULT diff --git a/data/script_cmd_table.inc b/data/script_cmd_table.inc index 07b22dda2..39864b2a8 100644 --- a/data/script_cmd_table.inc +++ b/data/script_cmd_table.inc @@ -45,7 +45,7 @@ gScriptCmdTable:: @ 81DB67C .4byte ScrCmd_clearflag .4byte ScrCmd_checkflag .4byte ScrCmd_initclock - .4byte ScrCmd_dodailyevents + .4byte ScrCmd_dotimebasedevents .4byte ScrCmd_gettime .4byte ScrCmd_playse .4byte ScrCmd_waitse diff --git a/data/scripts/pokeblocks.inc b/data/scripts/pokeblocks.inc index 05b468e23..c2a580a61 100644 --- a/data/scripts/pokeblocks.inc +++ b/data/scripts/pokeblocks.inc @@ -264,7 +264,7 @@ EventScript_Pblock1_No: @ 8293C70 EventScript_Pblock1_NoBerries: @ 8293C7A msgbox Text_Pblock1_NoBerries, MSGBOX_DEFAULT - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY, LilycoveCity_ContestLobby_EventScript_293C92 goto LilycoveCity_ContestLobby_EventScript_293C9C end @@ -551,7 +551,7 @@ LilycoveCity_ContestLobby_EventScript_293FF8: @ 8293FF8 specialvar VAR_RESULT, GetFirstFreePokeblockSlot compare VAR_RESULT, 65535 goto_if_eq LilycoveCity_ContestLobby_EventScript_294028 - dodailyevents + dotimebasedevents goto_if_set FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY, LilycoveCity_ContestLobby_EventScript_294028 goto LilycoveCity_ContestLobby_EventScript_294032 end diff --git a/include/event_data.h b/include/event_data.h index e09b32d44..3b8e2701f 100644 --- a/include/event_data.h +++ b/include/event_data.h @@ -6,7 +6,7 @@ void InitEventData(void); void ClearTempFieldEventData(void); -void ClearUpperFlags(void); +void ClearDailyFlags(void); void DisableNationalPokedex(void); void EnableNationalPokedex(void); bool32 IsNationalPokedexEnabled(void); diff --git a/include/intro.h b/include/intro.h index b1bfe20a4..198ae2669 100644 --- a/include/intro.h +++ b/include/intro.h @@ -9,6 +9,6 @@ void CB2_InitCopyrightScreenAfterBootup(void); void CB2_InitCopyrightScreenAfterBootup(void); void CB2_InitCopyrightScreenAfterTitleScreen(void); -void sub_816F2A8(u16, u16, u16, u16); +void PanFadeAndZoomScreen(u16, u16, u16, u16); #endif // GUARD_INTRO_H diff --git a/include/intro_credits_graphics.h b/include/intro_credits_graphics.h index 354d62e05..2c7ceaf57 100644 --- a/include/intro_credits_graphics.h +++ b/include/intro_credits_graphics.h @@ -9,7 +9,7 @@ extern const struct CompressedSpriteSheet gIntro2BrendanSpriteSheet[]; extern const struct CompressedSpriteSheet gIntro2MaySpriteSheet[]; extern const struct CompressedSpriteSheet gIntro2BicycleSpriteSheet[]; extern const struct CompressedSpriteSheet gIntro2FlygonSpriteSheet[]; -extern const struct SpritePalette gUnknown_085F530C[]; +extern const struct SpritePalette gIntroBikeAndFlygonPalette[]; extern const struct CompressedSpriteSheet gUnknown_085F5334[]; extern const struct CompressedSpriteSheet gUnknown_085F5344[]; extern const struct CompressedSpriteSheet gUnknown_085F5354[]; @@ -21,7 +21,7 @@ void load_intro_part2_graphics(u8 a); void sub_817B150(u8 a); void sub_817B1C8(u8); void sub_817B3A8(u8); -u8 sub_817B3DC(u8 a, u16 b, u16 c, u16 d); +u8 CreateBicycleAnimationTask(u8 a, u16 b, u16 c, u16 d); void sub_817B540(u8); u8 intro_create_brendan_sprite(s16 a, s16 b); u8 intro_create_may_sprite(s16 a, s16 b); diff --git a/include/new_game.h b/include/new_game.h index f4d69cbce..8fab05483 100644 --- a/include/new_game.h +++ b/include/new_game.h @@ -8,7 +8,7 @@ void SetTrainerId(u32 trainerId, u8 *dst); u32 GetTrainerId(u8 *trainerId); void CopyTrainerId(u8 *dst, u8 *src); void NewGameInitData(void); -void sub_808447C(void); +void ResetMenuAndMonGlobals(void); void Sav2_ClearSetDefault(void); #endif // GUARD_NEW_GAME_H diff --git a/include/palette.h b/include/palette.h index e24da3e00..8d16270aa 100644 --- a/include/palette.h +++ b/include/palette.h @@ -9,6 +9,11 @@ #define PLTT_BUFFER_SIZE 0x200 #define PLTT_DECOMP_BUFFER_SIZE (PLTT_BUFFER_SIZE * 2) +#define PALETTE_FADE_STATUS_DELAY 2 +#define PALETTE_FADE_STATUS_ACTIVE 1 +#define PALETTE_FADE_STATUS_DONE 0 +#define PALETTE_FADE_STATUS_LOADING 0xFF + enum { FAST_FADE_IN_FROM_WHITE, diff --git a/include/title_screen.h b/include/title_screen.h index b660792fc..ad0809ed2 100644 --- a/include/title_screen.h +++ b/include/title_screen.h @@ -1,7 +1,7 @@ #ifndef GUARD_TITLE_SCREEN_H #define GUARD_TITLE_SCREEN_H -extern const u16 gUnknown_0853FF70[]; +extern const u16 gIntroWaterDropData[]; void CB2_InitTitleScreen(void); diff --git a/src/clock.c b/src/clock.c index d52fde22e..1e7c5f83e 100644 --- a/src/clock.c +++ b/src/clock.c @@ -41,7 +41,7 @@ static void UpdatePerDay(struct Time *localTime) if (*days != localTime->days && *days <= localTime->days) { daysSince = localTime->days - *days; - ClearUpperFlags(); + ClearDailyFlags(); UpdateDewfordTrendPerDay(daysSince); UpdateTVShowsPerDay(daysSince); UpdateWeatherPerDay(daysSince); diff --git a/src/credits.c b/src/credits.c index 747d63f09..cc08d635b 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1869,7 +1869,7 @@ static void sub_817664C(u8 data, u8 taskIdA) gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data[0] = 0; gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = sub_817B3DC(0, 0x2000, 0x20, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleAnimationTask(0, 0x2000, 0x20, 8); break; case 1: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1880,7 +1880,7 @@ static void sub_817664C(u8 data, u8 taskIdA) gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data[0] = 0; gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = sub_817B3DC(0, 0x2000, 0x20, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleAnimationTask(0, 0x2000, 0x20, 8); break; case 2: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1891,7 +1891,7 @@ static void sub_817664C(u8 data, u8 taskIdA) gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data[0] = 0; gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = sub_817B3DC(1, 0x2000, 0x200, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleAnimationTask(1, 0x2000, 0x200, 8); break; case 3: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1902,7 +1902,7 @@ static void sub_817664C(u8 data, u8 taskIdA) gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data[0] = 0; gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = sub_817B3DC(1, 0x2000, 0x200, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleAnimationTask(1, 0x2000, 0x200, 8); break; case 4: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1913,7 +1913,7 @@ static void sub_817664C(u8 data, u8 taskIdA) gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.y = 46; gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].data[0] = 0; gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = sub_817B3DC(2, 0x2000, 0x200, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleAnimationTask(2, 0x2000, 0x200, 8); break; } diff --git a/src/event_data.c b/src/event_data.c index df289c538..a9da142e5 100644 --- a/src/event_data.c +++ b/src/event_data.c @@ -3,7 +3,7 @@ #include "pokedex.h" #define TEMP_FLAGS_SIZE 0x4 -#define TEMP_UPPER_FLAGS_SIZE 0x8 +#define DAILY_FLAGS_SIZE 0x8 #define TEMP_VARS_SIZE 0x20 EWRAM_DATA u16 gSpecialVar_0x8000 = 0; @@ -48,10 +48,9 @@ void ClearTempFieldEventData(void) FlagClear(FLAG_NURSE_UNION_ROOM_REMINDER); } -// Probably had different flag splits at one point. -void ClearUpperFlags(void) +void ClearDailyFlags(void) { - memset(gSaveBlock1Ptr->flags + 0x124, 0, TEMP_UPPER_FLAGS_SIZE); + memset(gSaveBlock1Ptr->flags + 0x124, 0, DAILY_FLAGS_SIZE); } void DisableNationalPokedex(void) diff --git a/src/intro.c b/src/intro.c index 18a899fb0..4f76faf87 100644 --- a/src/intro.c +++ b/src/intro.c @@ -27,14 +27,75 @@ #include "constants/rgb.h" #include "constants/battle_anim.h" +/* + * Intro animation sequence state machine + * -------------------------------------- + * + * Entry Point: CB2_InitCopyrightScreenAfterBootup + * + * Note: States advance sequentially unless otherwise stated. + * + * CB2_InitCopyrightScreenAfterBootup + * - Registers a serial interrupt handler that listens for a GameCube. + * - Waits for 140 frames, and then until palette fading completes. + * - Stops looking for a GameCube for dualboot. + * - Check the save file for corruption + * - Setup global pointers to save file + * - Initialize gHeap + * + * MainCB2_Intro + * - Spawn Task_IntroLoadPart1Graphics + * - If any keys are pressed during the intro, advance to + * MainCB2_EndIntro (which will then kill all tasks). + * + * Task_IntroLoadPart1Graphics + * Task_IntroFadeIn (frame counter starts at 0 here) + * Task_IntroWaterDrops + * - At frame 128 of this state, spawn Task_IntroWaterDrops_1 + * - At frame 256 of this state, spawn Task_IntroWaterDrops_2 + * - At frame 560 of this state, spawn Task_IntroWaterDrops_3 + * Task_IntroScrollDownAndShowFlygon + * Task_IntroWaitToSetupPart2 + * Task_IntroLoadPart2Graphics + * Task_IntroStartBikeRide + * - Spawn Task_AdvanceBicycleAnimation + * Task_IntroHandleBikeAndFlygonMovement + * - At frame 1856, kills the bicycle animation task + * Task_IntroWaitToSetupPart3 + * Task_IntroLoadPart3Graphics (frame counter resets to 0 here) + * Task_IntroSpinAndZoomPokeball + * - Continues until the zoom reaches a certain point + * Task_IntroWaitToSetupPart3LegendsFight + * Task_IntroLoadGroudonScene + * Task_IntroLoadPart3Graphics1 + * Task_IntroLoadPart3Graphics2 + * Task_IntroLoadPart3Graphics3 + * Task_IntroLoadPart3Graphics4 + * Task_IntroGroudonScene + * Task_IntroLoadKyogreScene + * Task_IntroKyogreScene + * Task_IntroLoadClouds1 + * Task_IntroLoadClouds2 + * Task_IntroLoadClouds3 + * Task_IntroCloudsScene + * Task_IntroLoadRayquazaLightningScene + * Task_IntroRayquazaLightningScene + * Task_IntroLoadRayquazaGlowScene + * Task_IntroRayquazaGlowScene_0 + * - Runs concurrently with Task_IntroRayquazaGlowScene_1 + * Task_EndIntroMovie + * MainCB2_EndIntro + * - Advances to CB2_InitTitleScreen + */ + extern const struct CompressedSpriteSheet gBattleAnimPicTable[]; extern const struct CompressedSpritePalette gBattleAnimPaletteTable[]; extern const struct SpriteTemplate gUnknown_08596C10[]; //ewram -EWRAM_DATA u16 gUnknown_0203BCC8 = 0; +EWRAM_DATA u16 gIntroCharacterGender = 0; EWRAM_DATA u16 gUnknown_0203BCCA = 0; -EWRAM_DATA u16 gUnknown_0203BCCC = 0; +EWRAM_DATA u16 gIntroGraphicsFlygonYOffset = 0; //iwram u32 gIntroFrameCounter; @@ -67,12 +128,12 @@ static const u8 sUnknownBytes[] = { 0x10, 0x11, 0x12, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x02, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x00 }; -static const struct CompressedSpriteSheet gUnknown_085E4A74[] = +static const struct CompressedSpriteSheet gIntroSpriteSheet_Sparkle[] = { {gIntro1SparkleGfx, 0x400, 1505}, {NULL}, }; -static const struct SpritePalette gUnknown_085E4A84[] = +static const struct SpritePalette gIntroPalette_Lightning[] = { {gIntro3LightningPal, 1505}, {NULL}, @@ -132,14 +193,14 @@ static const u8 gUnknown_085E4AD0[][2] = {0xD0, 0x26}, {0x00, 0x00}, }; -static const struct CompressedSpriteSheet gUnknown_085E4AE8[] = +static const struct CompressedSpriteSheet gIntroPokemonRunningSpriteSheet[] = { {gIntro2VolbeatGfx, 0x400, 1500}, {gIntro2TorchicGfx, 0xC00, 1501}, {gIntro2ManectricGfx, 0x2000, 1502}, {NULL}, }; -static const struct SpritePalette gUnknown_085E4B08[] = +static const struct SpritePalette gIntroPokemonRunningPalette[] = { {gIntro2VolbeatPal, 1500}, {gIntro2TorchicPal, 1501}, @@ -278,12 +339,12 @@ static const struct SpriteTemplate gUnknown_085E4BDC = .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_816DAE8, }; -static const struct CompressedSpriteSheet gUnknown_085E4BF4[] = +static const struct CompressedSpriteSheet gIntroRayquazaLightningSpriteSheet[] = { {gIntro3LightningGfx, 0xC00, 1503}, {NULL}, }; -static const struct SpritePalette gUnknown_085E4C04[] = +static const struct SpritePalette gIntroRayquazaLightningPalette[] = { {gIntro3LightningPal, 1503}, {NULL}, @@ -328,8 +389,8 @@ static const union AnimCmd *const gUnknown_085E4C40[] = gUnknown_085E4C28, gUnknown_085E4C34, }; -static void sub_816EC6C(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4C4C = +static void SpriteCB_IntroRayquazaLightning(struct Sprite *sprite); +static const struct SpriteTemplate gIntroLightningSprite = { .tileTag = 1503, .paletteTag = 1503, @@ -337,9 +398,9 @@ static const struct SpriteTemplate gUnknown_085E4C4C = .anims = gUnknown_085E4C40, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816EC6C, + .callback = SpriteCB_IntroRayquazaLightning, }; -static const s16 gUnknown_085E4C64[][3] = +static const s16 gIntroGroudonRockData[][3] = { {0x68, 0x00, 0x0C0}, {0x8E, 0x03, 0x280}, @@ -358,7 +419,7 @@ static const struct SpritePalette gUnknown_085E4C98[] = {gIntro2BubblesPal, 1504}, {NULL}, }; -static const s16 gUnknown_085E4CA8[][3] = +static const s16 gIntroKyogreBubbleData[][3] = { {0x42, 0x40, 0x1}, {0x60, 0x60, 0x8}, @@ -402,7 +463,7 @@ static const union AnimCmd *const gUnknown_085E4D10[] = { gUnknown_085E4CF8, }; -static void sub_816E7B4(struct Sprite *sprite); +static void SpriteCB_IntroKyogreBubbles(struct Sprite *sprite); static const struct SpriteTemplate gUnknown_085E4D14 = { .tileTag = 1504, @@ -411,7 +472,7 @@ static const struct SpriteTemplate gUnknown_085E4D14 = .anims = gUnknown_085E4D10, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816E7B4, + .callback = SpriteCB_IntroKyogreBubbles, }; static const struct OamData gUnknown_085E4D2C = { @@ -457,7 +518,7 @@ static const union AnimCmd *const gUnknown_085E4D54[] = gUnknown_085E4D4C, }; static void sub_816F454(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4D64 = +static const struct SpriteTemplate gIntroWaterDropSprite = { .tileTag = 2000, .paletteTag = 2000, @@ -497,7 +558,7 @@ static const union AnimCmd gUnknown_085E4DB4[] = ANIMCMD_FRAME(256, 16), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E4DC4[] = +static const union AnimCmd *const gIntroBicycleAnimationCommands[] = { gUnknown_085E4D7C, gUnknown_085E4D90, @@ -772,17 +833,17 @@ static const struct SpriteTemplate gUnknown_085E4FC4 = .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_816FEDC, }; -static const struct CompressedSpriteSheet gUnknown_085E4FDC[] = +static const struct CompressedSpriteSheet gIntroSpriteSheet_WaterDropAndLogo[] = { {gIntroTiles, 0x1400, 2000}, {NULL}, }; -static const struct CompressedSpriteSheet gUnknown_085E4FEC[] = +static const struct CompressedSpriteSheet gIntroSpriteSheet_Flygon[] = { {gIntro1FlygonGfx, 0x400, 2002}, {NULL}, }; -static const struct SpritePalette gUnknown_085E4FFC[] = +static const struct SpritePalette gIntroPalette_DropLogoFlygon[] = { {gIntro1DropsPal, 2000}, {gIntro1GFLogoPal, 2001}, @@ -814,8 +875,8 @@ static const union AnimCmd *const gUnknown_085E502C[] = { gUnknown_085E5024, }; -static void sub_8170040(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E5030 = +static void SpriteCB_IntroRayquazaHyperbeam(struct Sprite *sprite); +static const struct SpriteTemplate gIntroRayquazaHyperbeamSprite = { .tileTag = 2003, .paletteTag = 2003, @@ -823,14 +884,14 @@ static const struct SpriteTemplate gUnknown_085E5030 = .anims = gUnknown_085E502C, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8170040, + .callback = SpriteCB_IntroRayquazaHyperbeam, }; -static const struct CompressedSpriteSheet gUnknown_085E5048[] = +static const struct CompressedSpriteSheet gIntroRayquazaGlowSpriteSheet[] = { {gIntro3MiscTiles, 0xA00, 2003}, {NULL}, }; -static const struct SpritePalette gUnknown_085E5058[] = +static const struct SpritePalette gIntroRayquazaGlowPalette[] = { {gIntro3Misc1Palette, 2003}, {NULL}, @@ -855,36 +916,36 @@ static void Task_IntroWaitToSetupPart3(u8); static void Task_IntroLoadPart3Graphics(u8); static void Task_IntroSpinAndZoomPokeball(u8); static void Task_IntroWaitToSetupPart3LegendsFight(u8); -static void Task_IntroLoadPart1Graphics3(u8); -static void Task_IntroLoadPart1Graphics4(u8); -static void Task_IntroLoadPart1Graphics5(u8); -static void Task_IntroLoadPart1Graphics6(u8); -static void Task_IntroLoadPart1Graphics7(u8); -static void Task_IntroLoadPart1Graphics8(u8); -static void Task_IntroLoadPart1Graphics9(u8); -static void Task_IntroFadeIn0(u8); -static void Task_IntroFadeIn1(u8); -static void Task_IntroFadeIn2(u8); -static void Task_IntroFadeIn3(u8); -static void Task_IntroFadeIn4(u8); -static void Task_IntroFadeIn5(u8); -static void Task_IntroFadeIn6(u8); -static void Task_IntroFadeIn7(u8); -static void Task_IntroFadeIn8(u8); -static void Task_IntroFadeIn9(u8); -static void sub_816E190(u8); -static void sub_816E1F8(struct Sprite *); -static void sub_816E6D4(u8); -static void sub_816E74C(void); -static void sub_816EEA8(u8); +static void Task_IntroLoadGroudonScene(u8); +static void Task_IntroLoadPart3Graphics1(u8); +static void Task_IntroLoadPart3Graphics2(u8); +static void Task_IntroLoadPart3Graphics3(u8); +static void Task_IntroLoadPart3Graphics4(u8); +static void Task_IntroGroudonScene(u8); +static void Task_IntroLoadKyogreScene(u8); +static void Task_IntroKyogreScene(u8); +static void Task_IntroLoadClouds1(u8); +static void Task_IntroLoadClouds2(u8); +static void Task_IntroLoadClouds3(u8); +static void Task_IntroCloudScene(u8); +static void Task_IntroLoadRayquazaLightningScene(u8); +static void Task_IntroRayquazaLightningScene(u8); +static void Task_IntroLoadRayquazaGlowScene(u8); +static void Task_IntroRayquazaGlowScene_0(u8); +static void Task_EndIntroMovie(u8); +static void CreateGroudonRockSprites(u8); +static void SpriteCB_IntroGroudonRocks(struct Sprite *); +static void CreateKyogreBubbleSprites_0(u8); +static void CreateKyogreBubbleSprites_1(void); +static void Task_IntroRayquazaGlowScene_1(u8); static void sub_816F46C(struct Sprite *); static void sub_816F5B4(struct Sprite *); static void sub_816F660(struct Sprite *); static void SpriteCB_WaterDropFall(struct Sprite *); static void sub_816F318(struct Sprite *); -static void sub_816F9D4(struct Sprite *); -static void sub_816FAB0(struct Sprite *); -static u8 sub_816FDB8(s16, s16, s16); +static void SpriteCB_IntroGraphicsBicycle(struct Sprite *); +static void SpriteCB_IntroGraphicsFlygon(struct Sprite *); +static u8 CreatePart1Animations(s16, s16, s16); static void VBlankCB_Intro(void) { @@ -1006,7 +1067,7 @@ void CB2_InitCopyrightScreenAfterBootup(void) if (!SetUpCopyrightScreen()) { SetSaveBlocksPointers(sub_815355C()); - sub_808447C(); + ResetMenuAndMonGlobals(); Save_ResetSaveCounters(); Save_LoadGameData(SAVE_NORMAL); if (gSaveFileStatus == 0 || gSaveFileStatus == 2) @@ -1024,7 +1085,7 @@ void CB2_InitCopyrightScreenAfterTitleScreen(void) static void Task_IntroLoadPart1Graphics(u8 taskId) { SetVBlankCallback(NULL); - gUnknown_0203BCC8 = Random() & 1; + gIntroCharacterGender = Random() & 1; intro_reset_and_hide_bgs(); SetGpuReg(REG_OFFSET_BG3VOFS, 0); SetGpuReg(REG_OFFSET_BG2VOFS, 0x50); @@ -1044,11 +1105,11 @@ static void Task_IntroLoadPart1Graphics(u8 taskId) SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(20) | BGCNT_16COLOR | BGCNT_TXT256x512); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(18) | BGCNT_16COLOR | BGCNT_TXT256x512); SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(16) | BGCNT_16COLOR | BGCNT_TXT256x512); - LoadCompressedSpriteSheet(gUnknown_085E4FDC); - LoadCompressedSpriteSheet(gUnknown_085E4FEC); - LoadSpritePalettes(gUnknown_085E4FFC); - LoadCompressedSpriteSheet(gUnknown_085E4A74); - LoadSpritePalettes(gUnknown_085E4A84); + LoadCompressedSpriteSheet(gIntroSpriteSheet_WaterDropAndLogo); + LoadCompressedSpriteSheet(gIntroSpriteSheet_Flygon); + LoadSpritePalettes(gIntroPalette_DropLogoFlygon); + LoadCompressedSpriteSheet(gIntroSpriteSheet_Sparkle); + LoadSpritePalettes(gIntroPalette_Lightning); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1F0, 0x20); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1E1, 0x1E); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1D2, 0x1C); @@ -1056,7 +1117,7 @@ static void Task_IntroLoadPart1Graphics(u8 taskId) CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1B4, 0x18); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1A5, 0x16); CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x196, 0x14); - sub_816FDB8(0x78, 0x50, 0); + CreatePart1Animations(0x78, 0x50, 0); gTasks[taskId].data[0] = CreateWaterDrop(236, -14, 0x200, 1, 0x78, FALSE); gTasks[taskId].func = Task_IntroFadeIn; } @@ -1194,7 +1255,7 @@ static void Task_IntroLoadPart2Graphics(u8 taskId) FreeAllSpritePalettes(); gUnknown_0203BD24 = 0; gUnknown_0203BD26 = 0; - gUnknown_0203BCCC = 0; + gIntroGraphicsFlygonYOffset = 0; load_intro_part2_graphics(1); gTasks[taskId].func = Task_IntroStartBikeRide; } @@ -1203,7 +1264,7 @@ static void Task_IntroStartBikeRide(u8 taskId) { u8 spriteId; - if (gUnknown_0203BCC8 == 0) + if (gIntroCharacterGender == 0) LoadCompressedSpriteSheet(gIntro2BrendanSpriteSheet); else LoadCompressedSpriteSheet(gIntro2MaySpriteSheet); @@ -1213,29 +1274,29 @@ static void Task_IntroStartBikeRide(u8 taskId) for (spriteId = 0; spriteId < 3; spriteId++) { - LoadCompressedSpriteSheet(&gUnknown_085E4AE8[spriteId]); + LoadCompressedSpriteSheet(&gIntroPokemonRunningSpriteSheet[spriteId]); } - LoadSpritePalettes(gUnknown_085F530C); - LoadSpritePalettes(gUnknown_085E4B08); + LoadSpritePalettes(gIntroBikeAndFlygonPalette); + LoadSpritePalettes(gIntroPokemonRunningPalette); CreateSprite(&gUnknown_085E4BDC, 0x110, 0x80, 0); CreateSprite(&gUnknown_085E4BA4, 0x120, 0x6E, 1); - if (gUnknown_0203BCC8 == 0) + if (gIntroCharacterGender == 0) spriteId = intro_create_brendan_sprite(0x110, 100); else spriteId = intro_create_may_sprite(0x110, 100); - gSprites[spriteId].callback = sub_816F9D4; - gSprites[spriteId].anims = gUnknown_085E4DC4; + gSprites[spriteId].callback = SpriteCB_IntroGraphicsBicycle; + gSprites[spriteId].anims = gIntroBicycleAnimationCommands; gTasks[taskId].data[1] = spriteId; CreateSprite(&gUnknown_085E4B40, 0x110, 0x50, 0x4); spriteId = intro_create_flygon_sprite(-0x40, 0x3C); - gSprites[spriteId].callback = sub_816FAB0; + gSprites[spriteId].callback = SpriteCB_IntroGraphicsFlygon; gTasks[taskId].data[2] = spriteId; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_WHITEALPHA); SetVBlankCallback(VBlankCB_Intro); - gTasks[taskId].data[0] = sub_817B3DC(1, 0x4000, 0x400, 0x10); + gTasks[taskId].data[0] = CreateBicycleAnimationTask(1, 0x4000, 0x400, 0x10); sub_817B150(1); gTasks[taskId].func = Task_IntroHandleBikeAndFlygonMovement; } @@ -1243,11 +1304,12 @@ static void Task_IntroStartBikeRide(u8 taskId) static void Task_IntroHandleBikeAndFlygonMovement(u8 taskId) { s16 a; - u16 sine; + u16 offset; if (gIntroFrameCounter == 1856) { gUnknown_0203BD28 = 2; + // Destroys the CreateBicycleAnimationTask created earlier. DestroyTask(gTasks[taskId].data[0]); } if (gIntroFrameCounter > 1946) @@ -1268,8 +1330,8 @@ static void Task_IntroHandleBikeAndFlygonMovement(u8 taskId) if (gIntroFrameCounter == 1727) gSprites[gTasks[taskId].data[1]].data[0] = 4; - sine = Sin(gTasks[taskId].data[3] >> 2 & 0x7F, 48); - gUnknown_0203BCCC = sine; + offset = Sin(gTasks[taskId].data[3] >> 2 & 0x7F, 48); + gIntroGraphicsFlygonYOffset = offset; if (gTasks[taskId].data[3] < 512) gTasks[taskId].data[3]++; sub_817B540(0); @@ -1493,7 +1555,7 @@ static void Task_IntroLoadPart3Graphics(u8 taskId) gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 0; gTasks[taskId].data[3] = 0; - sub_816F2A8(0x78, 0x50, 0, 0); + PanFadeAndZoomScreen(0x78, 0x50, 0, 0); ResetSpriteData(); FreeAllSpritePalettes(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_WHITEALPHA); @@ -1518,7 +1580,7 @@ static void Task_IntroSpinAndZoomPokeball(u8 taskId) gTasks[taskId].func = Task_IntroWaitToSetupPart3LegendsFight; } - sub_816F2A8(0x78, 0x50, 0x10000 / gTasks[taskId].data[1], gTasks[taskId].data[0]); + PanFadeAndZoomScreen(0x78, 0x50, 0x10000 / gTasks[taskId].data[1], gTasks[taskId].data[0]); if (gIntroFrameCounter == 28) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA); @@ -1527,10 +1589,10 @@ static void Task_IntroSpinAndZoomPokeball(u8 taskId) static void Task_IntroWaitToSetupPart3LegendsFight(u8 taskId) { if (gIntroFrameCounter > 43) - gTasks[taskId].func = Task_IntroLoadPart1Graphics3; + gTasks[taskId].func = Task_IntroLoadGroudonScene; } -static void Task_IntroLoadPart1Graphics3(u8 taskId) +static void Task_IntroLoadGroudonScene(u8 taskId) { if (!gPaletteFade.active) { @@ -1545,11 +1607,11 @@ static void Task_IntroLoadPart1Graphics3(u8 taskId) LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]); LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]); CpuCopy16(gIntro3BgPal, gPlttBufferUnfaded, sizeof(gIntro3BgPal)); - gTasks[taskId].func = Task_IntroLoadPart1Graphics4; + gTasks[taskId].func = Task_IntroLoadPart3Graphics1; } } -static void Task_IntroLoadPart1Graphics4(u8 taskId) +static void Task_IntroLoadPart3Graphics1(u8 taskId) { SetGpuReg(REG_OFFSET_WIN0H, 0xF0); SetGpuReg(REG_OFFSET_WIN0V, 0xA0); @@ -1577,11 +1639,11 @@ static void Task_IntroLoadPart1Graphics4(u8 taskId) gTasks[taskId].data[1] = 0xFFA0; gTasks[taskId].data[2] = 0xFF51; gTasks[taskId].data[3] = 0x100; - sub_816F2A8(0xFFA0, 0xFF51, 0x100, 0); - gTasks[taskId].func = Task_IntroLoadPart1Graphics5; + PanFadeAndZoomScreen(0xFFA0, 0xFF51, 0x100, 0); + gTasks[taskId].func = Task_IntroLoadPart3Graphics2; } -static void Task_IntroLoadPart1Graphics5(u8 taskId) +static void Task_IntroLoadPart3Graphics2(u8 taskId) { if (gTasks[taskId].data[0] != 32) { @@ -1591,30 +1653,30 @@ static void Task_IntroLoadPart1Graphics5(u8 taskId) else { SetGpuReg(REG_OFFSET_WIN0V, 0x2080); - gTasks[taskId].func = Task_IntroLoadPart1Graphics6; + gTasks[taskId].func = Task_IntroLoadPart3Graphics3; } } -static void Task_IntroLoadPart1Graphics6(u8 taskId) +static void Task_IntroLoadPart3Graphics3(u8 taskId) { - gTasks[taskId].func = Task_IntroLoadPart1Graphics7; + gTasks[taskId].func = Task_IntroLoadPart3Graphics4; } -static void Task_IntroLoadPart1Graphics7(u8 taskId) +static void Task_IntroLoadPart3Graphics4(u8 taskId) { gTasks[taskId].data[0] = 0; - gTasks[taskId].func = Task_IntroLoadPart1Graphics8; + gTasks[taskId].func = Task_IntroGroudonScene; ScanlineEffect_InitWave(0, 0xA0, 0x4, 4, 1, 4, 0); } -static void Task_IntroLoadPart1Graphics8(u8 taskId) +static void Task_IntroGroudonScene(u8 taskId) { s16 *data = gTasks[taskId].data; data[5]++; if ((u16)(data[0] - 1) < 7 && data[5] % 2 == 0) data[4] ^= 3; - sub_816F2A8(data[1], data[2] + data[4], data[3], 0); + PanFadeAndZoomScreen(data[1], data[2] + data[4], data[3], 0); switch (data[0]) { case 0: @@ -1624,7 +1686,7 @@ static void Task_IntroLoadPart1Graphics8(u8 taskId) data[0]++; data[6] = 2; data[7] = 0x1E2; - sub_816E190(taskId); + CreateGroudonRockSprites(taskId); } break; case 1: @@ -1706,30 +1768,30 @@ static void Task_IntroLoadPart1Graphics8(u8 taskId) case 9: if (!gPaletteFade.active) { - gTasks[taskId].func = Task_IntroLoadPart1Graphics9; + gTasks[taskId].func = Task_IntroLoadKyogreScene; gScanlineEffect.state = 3; } break; } } -static void sub_816E190(u8 a0) +static void CreateGroudonRockSprites(u8 a0) { int i; u8 spriteId; for (i = 0; i < 6; i++) { - spriteId = CreateSprite(gUnknown_08596C10, gUnknown_085E4C64[i][0], 0xA0, i); - gSprites[spriteId].callback = sub_816E1F8; + spriteId = CreateSprite(gUnknown_08596C10, gIntroGroudonRockData[i][0], 0xA0, i); + gSprites[spriteId].callback = SpriteCB_IntroGroudonRocks; gSprites[spriteId].oam.priority = 0; gSprites[spriteId].data[1] = i; gSprites[spriteId].data[4] = a0; - StartSpriteAnim(&gSprites[spriteId], gUnknown_085E4C64[i][1]); + StartSpriteAnim(&gSprites[spriteId], gIntroGroudonRockData[i][1]); } } -static void sub_816E1F8(struct Sprite *sprite) +static void SpriteCB_IntroGroudonRocks(struct Sprite *sprite) { sprite->data[3]++; if (sprite->data[3] % 2 == 0) @@ -1738,7 +1800,7 @@ static void sub_816E1F8(struct Sprite *sprite) switch(sprite->data[0]) { case 0: - sprite->data[2] += gUnknown_085E4C64[sprite->data[1]][2]; + sprite->data[2] += gIntroGroudonRockData[sprite->data[1]][2]; sprite->pos1.y -= (sprite->data[2] & 0xFF00) >> 8; sprite->data[2] &= 0xFF; if (gTasks[sprite->data[4]].data[0] > 7) @@ -1758,7 +1820,7 @@ static void sub_816E1F8(struct Sprite *sprite) } } -static void Task_IntroLoadPart1Graphics9(u8 taskId) +static void Task_IntroLoadKyogreScene(u8 taskId) { ResetSpriteData(); LZDecompressVram(gIntro3KyogreGfx, (void *)VRAM); @@ -1767,21 +1829,21 @@ static void Task_IntroLoadPart1Graphics9(u8 taskId) LoadCompressedSpriteSheet(gUnknown_085E4C88); LoadSpritePalette(gUnknown_085E4C98); BeginNormalPaletteFade(0xFFFFFFFE, 0, 0x10, 0, RGB_WHITEALPHA); - gTasks[taskId].func = Task_IntroFadeIn0; + gTasks[taskId].func = Task_IntroKyogreScene; gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0x150; gTasks[taskId].data[2] = 0x50; gTasks[taskId].data[6] = 0x10; gTasks[taskId].data[3] = 0x100; - sub_816F2A8(0x150, 0x50, 0x100, 0); + PanFadeAndZoomScreen(0x150, 0x50, 0x100, 0); ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, 6, 0); } -static void Task_IntroFadeIn0(u8 taskId) +static void Task_IntroKyogreScene(u8 taskId) { s16 *data = gTasks[taskId].data; - sub_816F2A8(data[1], data[2], data[3], 0); + PanFadeAndZoomScreen(data[1], data[2], data[3], 0); switch (data[0]) { @@ -1798,7 +1860,7 @@ static void Task_IntroFadeIn0(u8 taskId) data[6] = 0x19; data[7] = 1; data[0]++; - sub_816E6D4(0); + CreateKyogreBubbleSprites_0(0); } break; case 2: @@ -1808,8 +1870,8 @@ static void Task_IntroFadeIn0(u8 taskId) gTasks[taskId].data[2] -= 0x102; data[6] = 8; data[0]++; - sub_816E6D4(0); - sub_816E74C(); + CreateKyogreBubbleSprites_0(0); + CreateKyogreBubbleSprites_1(); } break; case 3: @@ -1891,7 +1953,7 @@ static void Task_IntroFadeIn0(u8 taskId) { data[6] = 0; data[0]++; - sub_816E6D4(taskId); + CreateKyogreBubbleSprites_0(taskId); } break; case 11: @@ -1914,43 +1976,43 @@ static void Task_IntroFadeIn0(u8 taskId) case 13: if (!gPaletteFade.active) { - gTasks[taskId].func = Task_IntroFadeIn1; + gTasks[taskId].func = Task_IntroLoadClouds1; gScanlineEffect.state = 3; } break; } } -static void sub_816E6D4(u8 a0) +static void CreateKyogreBubbleSprites_0(u8 taskId) { int i; u8 spriteId; for (i = 0; i < 6; i++) { - spriteId = CreateSprite(&gUnknown_085E4D14, gUnknown_085E4CA8[i][0], gUnknown_085E4CA8[i][1], i); + spriteId = CreateSprite(&gUnknown_085E4D14, gIntroKyogreBubbleData[i][0], gIntroKyogreBubbleData[i][1], i); gSprites[spriteId].invisible = TRUE; - gSprites[spriteId].data[5] = a0; - gSprites[spriteId].data[6] = gUnknown_085E4CA8[i][2]; + gSprites[spriteId].data[5] = taskId; + gSprites[spriteId].data[6] = gIntroKyogreBubbleData[i][2]; gSprites[spriteId].data[7] = 0x40; } } -static void sub_816E74C(void) +static void CreateKyogreBubbleSprites_1(void) { int i; u8 spriteId; for (i = 0; i < 6; i++) { - spriteId = CreateSprite(&gUnknown_085E4D14, gUnknown_085E4CA8[i + 6][0], gUnknown_085E4CA8[i + 6][1], i); + spriteId = CreateSprite(&gUnknown_085E4D14, gIntroKyogreBubbleData[i + 6][0], gIntroKyogreBubbleData[i + 6][1], i); gSprites[spriteId].invisible = TRUE; - gSprites[spriteId].data[6] = gUnknown_085E4CA8[i][2]; + gSprites[spriteId].data[6] = gIntroKyogreBubbleData[i][2]; gSprites[spriteId].data[7] = 0x40; } } -static void sub_816E7B4(struct Sprite *sprite) +static void SpriteCB_IntroKyogreBubbles(struct Sprite *sprite) { switch(sprite->data[0]) { @@ -1988,7 +2050,7 @@ static void sub_816E7B4(struct Sprite *sprite) } } -static void Task_IntroFadeIn1(u8 taskId) +static void Task_IntroLoadClouds1(u8 taskId) { SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1 @@ -2027,27 +2089,27 @@ static void Task_IntroFadeIn1(u8 taskId) LZDecompressVram(gIntro3CloudsGfx, (void *)VRAM); LZDecompressVram(gIntro3CloudsGfx, (void *)(VRAM + 0x4000)); LZDecompressVram(gIntro3Clouds3Tilemap, (void *)(VRAM + 0xE000)); - gTasks[taskId].func = Task_IntroFadeIn2; + gTasks[taskId].func = Task_IntroLoadClouds2; } -static void Task_IntroFadeIn2(u8 taskId) +static void Task_IntroLoadClouds2(u8 taskId) { LZDecompressVram(gIntro3Clouds1Tilemap, (void *)(VRAM + 0xC000)); LZDecompressVram(gIntro3Clouds2Tilemap, (void *)(VRAM + 0xD000)); - gTasks[taskId].func = Task_IntroFadeIn3; + gTasks[taskId].func = Task_IntroLoadClouds3; } -static void Task_IntroFadeIn3(u8 taskId) +static void Task_IntroLoadClouds3(u8 taskId) { SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); - gTasks[taskId].func = Task_IntroFadeIn4; + gTasks[taskId].func = Task_IntroCloudScene; gTasks[taskId].data[0] = 0; gTasks[taskId].data[6] = 16; } -static void Task_IntroFadeIn4(u8 taskId) +static void Task_IntroCloudScene(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -2071,12 +2133,12 @@ static void Task_IntroFadeIn4(u8 taskId) if (data[6] != 0) data[6] -= 0x80; else if (!gPaletteFade.active) - gTasks[taskId].func = Task_IntroFadeIn5; + gTasks[taskId].func = Task_IntroLoadRayquazaLightningScene; break; } } -static void Task_IntroFadeIn5(u8 taskId) +static void Task_IntroLoadRayquazaLightningScene(u8 taskId) { LZDecompressVram(gIntro3RayquazaTilemap, (void *)(VRAM + 0xE000)); LZDecompressVram(gIntro3Clouds4Tilemap, (void *)(VRAM + 0xC000)); @@ -2088,15 +2150,15 @@ static void Task_IntroFadeIn5(u8 taskId) | DISPCNT_BG2_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON); - gTasks[taskId].func = Task_IntroFadeIn6; + gTasks[taskId].func = Task_IntroRayquazaLightningScene; gTasks[taskId].data[0] = 0; gTasks[taskId].data[6] = 1; gTasks[taskId].data[7] = 0; - LoadCompressedSpriteSheetUsingHeap(gUnknown_085E4BF4); - LoadSpritePalettes(gUnknown_085E4C04); + LoadCompressedSpriteSheetUsingHeap(gIntroRayquazaLightningSpriteSheet); + LoadSpritePalettes(gIntroRayquazaLightningPalette); } -static void Task_IntroFadeIn6(u8 taskId) +static void Task_IntroRayquazaLightningScene(u8 taskId) { s16 *data = gTasks[taskId].data; u8 spriteId; @@ -2106,10 +2168,10 @@ static void Task_IntroFadeIn6(u8 taskId) case 0: if (--data[6] == 0) { - CreateSprite(&gUnknown_085E4C4C, 200, 48, 0); - spriteId = CreateSprite(&gUnknown_085E4C4C, 200, 80, 1); + CreateSprite(&gIntroLightningSprite, 200, 48, 0); + spriteId = CreateSprite(&gIntroLightningSprite, 200, 80, 1); StartSpriteAnim(&gSprites[spriteId], 1); - spriteId = CreateSprite(&gUnknown_085E4C4C, 200, 112, 2); + spriteId = CreateSprite(&gIntroLightningSprite, 200, 112, 2); StartSpriteAnim(&gSprites[spriteId], 2); data[0]++; data[6] = 72; @@ -2118,10 +2180,10 @@ static void Task_IntroFadeIn6(u8 taskId) case 1: if (--data[6] == 0) { - CreateSprite(&gUnknown_085E4C4C, 40, 48, 0); - spriteId = CreateSprite(&gUnknown_085E4C4C, 40, 80, 1); + CreateSprite(&gIntroLightningSprite, 40, 48, 0); + spriteId = CreateSprite(&gIntroLightningSprite, 40, 80, 1); StartSpriteAnim(&gSprites[spriteId], 1); - spriteId = CreateSprite(&gUnknown_085E4C4C, 40, 112, 2); + spriteId = CreateSprite(&gIntroLightningSprite, 40, 112, 2); StartSpriteAnim(&gSprites[spriteId], 2); data[0]++; data[6] = 48; @@ -2129,12 +2191,12 @@ static void Task_IntroFadeIn6(u8 taskId) break; case 2: if (--data[6] == 0) - gTasks[taskId].func = Task_IntroFadeIn7; + gTasks[taskId].func = Task_IntroLoadRayquazaGlowScene; break; } } -static void sub_816EC6C(struct Sprite *sprite) +static void SpriteCB_IntroRayquazaLightning(struct Sprite *sprite) { if (sprite->animEnded) sprite->invisible = TRUE; @@ -2165,30 +2227,30 @@ static void sub_816EC6C(struct Sprite *sprite) } } -static void Task_IntroFadeIn7(u8 taskId) +static void Task_IntroLoadRayquazaGlowScene(u8 taskId) { u8 newTaskId; - LoadCompressedSpriteSheet(gUnknown_085E5048); - LoadSpritePalettes(gUnknown_085E5058); + LoadCompressedSpriteSheet(gIntroRayquazaGlowSpriteSheet); + LoadSpritePalettes(gIntroRayquazaGlowPalette); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON); - gTasks[taskId].func = Task_IntroFadeIn8; + gTasks[taskId].func = Task_IntroRayquazaGlowScene_0; BeginNormalPaletteFade(0x0000FFDE, 0, 16, 0, RGB(9, 10, 10)); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0xA8; gTasks[taskId].data[2] = -0x10; gTasks[taskId].data[3] = -0x88; gTasks[taskId].data[4] = -0x10; - newTaskId = CreateTask(sub_816EEA8, 0); + newTaskId = CreateTask(Task_IntroRayquazaGlowScene_1, 0); gTasks[newTaskId].data[4] = taskId; } -static void Task_IntroFadeIn8(u8 taskId) +static void Task_IntroRayquazaGlowScene_0(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -2230,22 +2292,22 @@ static void Task_IntroFadeIn8(u8 taskId) break; case 3: if (--data[5] == 0) - gTasks[taskId].func = Task_IntroFadeIn9; + gTasks[taskId].func = Task_EndIntroMovie; break; } } -static void Task_IntroFadeIn9(u8 taskId) +static void Task_EndIntroMovie(u8 taskId) { DestroyTask(taskId); SetMainCallback2(MainCB2_EndIntro); } -static void sub_816EEA8(u8 taskId) +static void Task_IntroRayquazaGlowScene_1(u8 taskId) { + // Note: data[4] contains the taskId of Task_IntroRayquazaGlowScene_0 u8 spriteId; s16 *data = gTasks[taskId].data; - data[2]++; switch(data[0]) @@ -2292,7 +2354,7 @@ static void sub_816EEA8(u8 taskId) } if (data[1] == 6) { - spriteId = CreateSprite(&gUnknown_085E5030, 120, 88, 15); + spriteId = CreateSprite(&gIntroRayquazaHyperbeamSprite, 120, 88, 15); PlaySE(SE_OP_BASYU); gSprites[spriteId].invisible = TRUE; gSprites[spriteId].data[3] = data[4]; @@ -2365,7 +2427,7 @@ static void Task_IntroWaterDrops_1(u8 taskId) | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); - SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0853FF70[31]); + SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropData[31]); SetGpuReg(REG_OFFSET_BLDY, 0); gTasks[taskId].data[1] = 0x40; gTasks[taskId].data[0]++; @@ -2377,11 +2439,11 @@ static void Task_IntroWaterDrops_1(u8 taskId) gTasks[taskId].data[1]--; tmp = gTasks[taskId].data[1] / 2; - SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0853FF70[tmp]); + SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropData[tmp]); } else { - SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0853FF70[0]); + SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropData[0]); gTasks[taskId].data[1] = 0x10; gTasks[taskId].data[0]++; } @@ -2408,7 +2470,7 @@ static void Task_IntroWaterDrops_2(u8 taskId) | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); - SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0853FF70[0]); + SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropData[0]); SetGpuReg(REG_OFFSET_BLDY, 0); gTasks[taskId].data[1] = 0; gTasks[taskId].data[0]++; @@ -2420,11 +2482,11 @@ static void Task_IntroWaterDrops_2(u8 taskId) gTasks[taskId].data[1]++; tmp = gTasks[taskId].data[1] / 2; - SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0853FF70[tmp]); + SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropData[tmp]); } else { - SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0853FF70[31]); + SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropData[31]); gTasks[taskId].data[1] = 0x10; gTasks[taskId].data[0]++; } @@ -2445,15 +2507,15 @@ static void Task_IntroWaterDrops_2(u8 taskId) } } -void sub_816F2A8(u16 scrX, u16 scrY, u16 zoom, u16 alpha) +void PanFadeAndZoomScreen(u16 screenX, u16 screenY, u16 zoom, u16 alpha) { struct BgAffineSrcData src; struct BgAffineDstData dest; src.texX = 0x8000; src.texY = 0x8000; - src.scrX = scrX; - src.scrY = scrY; + src.scrX = screenX; + src.scrY = screenY; src.sx = zoom; src.sy = zoom; src.alpha = alpha; @@ -2662,7 +2724,7 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) u8 spriteId; u8 oldSpriteId; - spriteId = CreateSprite(&gUnknown_085E4D64, x, y, 1); + spriteId = CreateSprite(&gIntroWaterDropSprite, x, y, 1); gSprites[spriteId].data[0] = 0; gSprites[spriteId].data[7] = 0; gSprites[spriteId].data[1] = d; @@ -2680,7 +2742,7 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) gSprites[spriteId].callback = SpriteCB_WaterDropFall_2; oldSpriteId = spriteId; - spriteId = CreateSprite(&gUnknown_085E4D64, x, y, 1); + spriteId = CreateSprite(&gIntroWaterDropSprite, x, y, 1); gSprites[spriteId].data[7] = oldSpriteId; gSprites[spriteId].data[1] = d + 1; gSprites[spriteId].oam.affineMode = 3; @@ -2688,7 +2750,7 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) CalcCenterToCornerVec(&gSprites[spriteId], 0, 2, 2); gSprites[spriteId].callback = sub_816F3A4; - spriteId = CreateSprite(&gUnknown_085E4D64, x, y, 1); + spriteId = CreateSprite(&gIntroWaterDropSprite, x, y, 1); gSprites[spriteId].data[7] = oldSpriteId; gSprites[spriteId].data[1] = d + 2; StartSpriteAnim(&gSprites[spriteId], 1); @@ -2704,7 +2766,7 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) return oldSpriteId; } -static void sub_816F9D4(struct Sprite *sprite) +static void SpriteCB_IntroGraphicsBicycle(struct Sprite *sprite) { switch (sprite->data[0]) { @@ -2753,7 +2815,7 @@ static void sub_816F9D4(struct Sprite *sprite) } } -static void sub_816FAB0(struct Sprite *sprite) +static void SpriteCB_IntroGraphicsFlygon(struct Sprite *sprite) { switch (sprite->data[0]) { @@ -2776,7 +2838,7 @@ static void sub_816FAB0(struct Sprite *sprite) sprite->pos2.x -= 2; break; } - sprite->pos2.y = Sin((u8)sprite->data[1], 8) - gUnknown_0203BCCC; + sprite->pos2.y = Sin((u8)sprite->data[1], 8) - gIntroGraphicsFlygonYOffset; sprite->data[1] += 4; } @@ -2896,7 +2958,7 @@ static void sub_816FD44(struct Sprite *sprite) } } -static u8 sub_816FDB8(s16 a0, s16 a1, s16 a2) +static u8 CreatePart1Animations(s16 a0, s16 a1, s16 a2) { u16 i; u8 spriteId; @@ -2981,7 +3043,7 @@ static void sub_816FEDC(struct Sprite *sprite) } } -static void sub_8170040(struct Sprite *sprite) +static void SpriteCB_IntroRayquazaHyperbeam(struct Sprite *sprite) { u16 foo; diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c index d85e58938..ba1f56158 100644 --- a/src/intro_credits_graphics.c +++ b/src/intro_credits_graphics.c @@ -269,7 +269,7 @@ const struct CompressedSpriteSheet gIntro2FlygonSpriteSheet[] = { { NULL } }; -const struct SpritePalette gUnknown_085F530C[] = { +const struct SpritePalette gIntroBikeAndFlygonPalette[] = { { gIntro2BrendanNoTurnPal, 1002 }, { gIntro2BrendanNoTurnPal, 1003 }, { gIntro2FlygonPal, 1004 }, @@ -358,6 +358,7 @@ void load_intro_part2_graphics(u8 a) gReservedSpritePaletteCount = 8; } +// Note: This is only called with a=1. void sub_817B150(u8 a) { switch (a) @@ -509,7 +510,7 @@ void sub_817B3A8(u8 a) | DISPCNT_OBJ_ON); } -u8 sub_817B3DC(u8 a, u16 b, u16 c, u16 d) +u8 CreateBicycleAnimationTask(u8 a, u16 b, u16 c, u16 d) { u8 taskId = CreateTask(&sub_817B458, 0); diff --git a/src/new_game.c b/src/new_game.c index f68ed3d4f..a4bf2951f 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -146,7 +146,7 @@ void Sav2_ClearSetDefault(void) SetDefaultOptions(); } -void sub_808447C(void) +void ResetMenuAndMonGlobals(void) { gDifferentSaveFile = 0; sub_80BB358(); diff --git a/src/palette.c b/src/palette.c index be5143876..5d1d6635c 100644 --- a/src/palette.c +++ b/src/palette.c @@ -115,7 +115,7 @@ u8 UpdatePaletteFade(void) u8 dummy = 0; if (sPlttBufferTransferPending) - return -1; + return PALETTE_FADE_STATUS_LOADING; if (gPaletteFade.mode == NORMAL_FADE) result = UpdateNormalPaletteFade(); @@ -409,11 +409,11 @@ static u8 UpdateNormalPaletteFade(void) u16 selectedPalettes; if (!gPaletteFade.active) - return 0; + return PALETTE_FADE_STATUS_DONE; if (IsSoftwarePaletteFadeFinishing()) { - return gPaletteFade.active; + return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE; } else { @@ -483,7 +483,9 @@ static u8 UpdateNormalPaletteFade(void) } } - return gPaletteFade.active; + // gPaletteFade.active cannot change since the last time it was checked. So this + // is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;` + return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE; } } @@ -578,10 +580,11 @@ static u8 UpdateFastPaletteFade(void) s8 b; if (!gPaletteFade.active) - return 0; + return PALETTE_FADE_STATUS_DONE; if (IsSoftwarePaletteFadeFinishing()) - return gPaletteFade.active; + return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE; + if (gPaletteFade.objPaletteToggle) { @@ -688,7 +691,9 @@ static u8 UpdateFastPaletteFade(void) gPaletteFade.objPaletteToggle ^= 1; if (gPaletteFade.objPaletteToggle) - return gPaletteFade.active; + // gPaletteFade.active cannot change since the last time it was checked. So this + // is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;` + return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE; if (gPaletteFade.y - gPaletteFade.deltaY < 0) gPaletteFade.y = 0; @@ -714,8 +719,10 @@ static u8 UpdateFastPaletteFade(void) gPaletteFade.mode = NORMAL_FADE; gPaletteFade.softwareFadeFinishing = 1; } - - return gPaletteFade.active; + + // gPaletteFade.active cannot change since the last time it was checked. So this + // is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;` + return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE; } void BeginHardwarePaletteFade(u8 blendCnt, u8 delay, u8 y, u8 targetY, u8 shouldResetBlendRegisters) @@ -739,12 +746,12 @@ void BeginHardwarePaletteFade(u8 blendCnt, u8 delay, u8 y, u8 targetY, u8 should static u8 UpdateHardwarePaletteFade(void) { if (!gPaletteFade.active) - return 0; + return PALETTE_FADE_STATUS_DONE; if (gPaletteFade.delayCounter < gPaletteFade_delay) { gPaletteFade.delayCounter++; - return 2; + return PALETTE_FADE_STATUS_DELAY; } gPaletteFade.delayCounter = 0; @@ -778,7 +785,9 @@ static u8 UpdateHardwarePaletteFade(void) gPaletteFade.shouldResetBlendRegisters = 0; } - return gPaletteFade.active; + // gPaletteFade.active cannot change since the last time it was checked. So this + // is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;` + return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE; } static void UpdateBlendRegisters(void) diff --git a/src/reset_save_heap.c b/src/reset_save_heap.c index d7c93a75c..95d63a323 100644 --- a/src/reset_save_heap.c +++ b/src/reset_save_heap.c @@ -19,7 +19,7 @@ void sub_81700F8(void) REG_IME = imeBackup; gMain.inBattle = FALSE; SetSaveBlocksPointers(sub_815355C()); - sub_808447C(); + ResetMenuAndMonGlobals(); Save_ResetSaveCounters(); Save_LoadGameData(0); if (gSaveFileStatus == 0 || gSaveFileStatus == 2) diff --git a/src/scrcmd.c b/src/scrcmd.c index 4cc8df82e..a1e391b4a 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -690,7 +690,7 @@ bool8 ScrCmd_initclock(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_dodailyevents(struct ScriptContext *ctx) +bool8 ScrCmd_dotimebasedevents(struct ScriptContext *ctx) { DoTimeBasedEvents(); return FALSE; diff --git a/src/title_screen.c b/src/title_screen.c index 48571ff96..06bb066bb 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -64,7 +64,7 @@ static const u32 sTitleScreenRayquazaTilemap[] = INCBIN_U32("graphics/title_scre static const u32 sTitleScreenLogoShineGfx[] = INCBIN_U32("graphics/title_screen/logo_shine.4bpp.lz"); static const u32 sTitleScreenCloudsGfx[] = INCBIN_U32("graphics/title_screen/clouds.4bpp.lz"); -const u16 gUnknown_0853FF70[] = +const u16 gIntroWaterDropData[] = { 0x0010, 0x0110, 0x0210, 0x0310, 0x0410, 0x0510, 0x0610, 0x0710, 0x0810, 0x0910, 0x0a10, 0x0b10, 0x0c10, 0x0d10, 0x0e10, 0x0f10, @@ -324,7 +324,7 @@ static void SpriteCB_VersionBannerLeft(struct Sprite *sprite) sprite->pos1.y++; if (sprite->data[0] != 0) sprite->data[0]--; - SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0853FF70[sprite->data[0]]); + SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropData[sprite->data[0]]); } } @@ -542,7 +542,7 @@ void CB2_InitTitleScreen(void) gMain.state = 4; break; case 4: - sub_816F2A8(0x78, 0x50, 0x100, 0); + PanFadeAndZoomScreen(0x78, 0x50, 0x100, 0); SetGpuReg(REG_OFFSET_BG2X_L, -29 * 256); SetGpuReg(REG_OFFSET_BG2X_H, -1); SetGpuReg(REG_OFFSET_BG2Y_L, -32 * 256); diff --git a/tools/scaninc/c_file.cpp b/tools/scaninc/c_file.cpp index d470f959d..595f366cb 100644 --- a/tools/scaninc/c_file.cpp +++ b/tools/scaninc/c_file.cpp @@ -134,7 +134,7 @@ bool CFile::ConsumeComment() if (m_buffer[m_pos] == '/' && m_buffer[m_pos + 1] == '*') { m_pos += 2; - while (m_buffer[m_pos] != '*' && m_buffer[m_pos + 1] != '/') + while (m_buffer[m_pos] != '*' || m_buffer[m_pos + 1] != '/') { if (m_buffer[m_pos] == 0) return false;