From 22e2c0a47ca876313604f0dd031abb324477186f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 16 Mar 2021 05:40:42 -0400 Subject: [PATCH 01/31] Document Berry Crush --- .../bg.bin} | Bin .../container_cap.bin} | Bin .../tiles.bin => berry_crush/crusher.bin} | 0 .../tiles.pal => berry_crush/crusher.pal} | 0 .../tiles.png => berry_crush/crusher.png} | Bin .../crusher_base.png} | Bin .../crusher_top.bin} | Bin .../effects.pal} | 0 .../impact.png} | Bin .../sparkle.png} | Bin .../timer_digits.png} | Bin .../321start.png | Bin .../321start_static.png | Bin include/berry.h | 8 +- include/berry_crush.h | 2 +- include/constants/game_stat.h | 2 +- include/global.h | 2 +- include/graphics.h | 6 +- include/strings.h | 2 +- src/berry.c | 88 +- src/berry_crush.c | 3284 +++++++++-------- src/graphics.c | 6 +- src/minigame_countdown.c | 8 +- src/strings.c | 2 +- 24 files changed, 1855 insertions(+), 1555 deletions(-) rename graphics/{link_games/berrycrush_background.bin => berry_crush/bg.bin} (100%) rename graphics/{link_games/berrycrush_container_cap.bin => berry_crush/container_cap.bin} (100%) rename graphics/{berry_crusher/tiles.bin => berry_crush/crusher.bin} (100%) rename graphics/{berry_crusher/tiles.pal => berry_crush/crusher.pal} (100%) rename graphics/{berry_crusher/tiles.png => berry_crush/crusher.png} (100%) rename graphics/{link_games/berrycrush_grinder_base.png => berry_crush/crusher_base.png} (100%) rename graphics/{link_games/berrycrush_grinder_top.bin => berry_crush/crusher_top.bin} (100%) rename graphics/{link_games/berrycrush_misc.pal => berry_crush/effects.pal} (100%) rename graphics/{link_games/berrycrush_btnpress.png => berry_crush/impact.png} (100%) rename graphics/{link_games/berrycrush_sparkle.png => berry_crush/sparkle.png} (100%) rename graphics/{link_games/berrycrush_timerdigits.png => berry_crush/timer_digits.png} (100%) rename graphics/{link_games => minigame_countdown}/321start.png (100%) rename graphics/{link_games => minigame_countdown}/321start_static.png (100%) diff --git a/graphics/link_games/berrycrush_background.bin b/graphics/berry_crush/bg.bin similarity index 100% rename from graphics/link_games/berrycrush_background.bin rename to graphics/berry_crush/bg.bin diff --git a/graphics/link_games/berrycrush_container_cap.bin b/graphics/berry_crush/container_cap.bin similarity index 100% rename from graphics/link_games/berrycrush_container_cap.bin rename to graphics/berry_crush/container_cap.bin diff --git a/graphics/berry_crusher/tiles.bin b/graphics/berry_crush/crusher.bin similarity index 100% rename from graphics/berry_crusher/tiles.bin rename to graphics/berry_crush/crusher.bin diff --git a/graphics/berry_crusher/tiles.pal b/graphics/berry_crush/crusher.pal similarity index 100% rename from graphics/berry_crusher/tiles.pal rename to graphics/berry_crush/crusher.pal diff --git a/graphics/berry_crusher/tiles.png b/graphics/berry_crush/crusher.png similarity index 100% rename from graphics/berry_crusher/tiles.png rename to graphics/berry_crush/crusher.png diff --git a/graphics/link_games/berrycrush_grinder_base.png b/graphics/berry_crush/crusher_base.png similarity index 100% rename from graphics/link_games/berrycrush_grinder_base.png rename to graphics/berry_crush/crusher_base.png diff --git a/graphics/link_games/berrycrush_grinder_top.bin b/graphics/berry_crush/crusher_top.bin similarity index 100% rename from graphics/link_games/berrycrush_grinder_top.bin rename to graphics/berry_crush/crusher_top.bin diff --git a/graphics/link_games/berrycrush_misc.pal b/graphics/berry_crush/effects.pal similarity index 100% rename from graphics/link_games/berrycrush_misc.pal rename to graphics/berry_crush/effects.pal diff --git a/graphics/link_games/berrycrush_btnpress.png b/graphics/berry_crush/impact.png similarity index 100% rename from graphics/link_games/berrycrush_btnpress.png rename to graphics/berry_crush/impact.png diff --git a/graphics/link_games/berrycrush_sparkle.png b/graphics/berry_crush/sparkle.png similarity index 100% rename from graphics/link_games/berrycrush_sparkle.png rename to graphics/berry_crush/sparkle.png diff --git a/graphics/link_games/berrycrush_timerdigits.png b/graphics/berry_crush/timer_digits.png similarity index 100% rename from graphics/link_games/berrycrush_timerdigits.png rename to graphics/berry_crush/timer_digits.png diff --git a/graphics/link_games/321start.png b/graphics/minigame_countdown/321start.png similarity index 100% rename from graphics/link_games/321start.png rename to graphics/minigame_countdown/321start.png diff --git a/graphics/link_games/321start_static.png b/graphics/minigame_countdown/321start_static.png similarity index 100% rename from graphics/link_games/321start_static.png rename to graphics/minigame_countdown/321start_static.png diff --git a/include/berry.h b/include/berry.h index 4a5a46615b..22b9158ee2 100644 --- a/include/berry.h +++ b/include/berry.h @@ -28,11 +28,11 @@ void SetBerryTreesSeen(void); extern const struct Berry gBerries[]; -struct UnkStruct_0858AB24 { - u8 unk0; - u16 unk1; +struct BerryCrushBerryData { + u8 difficulty; // The number of A presses required to crush it + u16 powder; }; -extern const struct UnkStruct_0858AB24 gUnknown_0858AB24[]; +extern const struct BerryCrushBerryData gBerryCrush_BerryData[]; #endif // GUARD_BERRY_H diff --git a/include/berry_crush.h b/include/berry_crush.h index a08f1f6996..02dcce5067 100755 --- a/include/berry_crush.h +++ b/include/berry_crush.h @@ -3,6 +3,6 @@ #include "main.h" -void StartBerryCrush(MainCallback callback); +void StartBerryCrush(MainCallback exitCallback); #endif // GUARD_BERRY_CRUSH_H diff --git a/include/constants/game_stat.h b/include/constants/game_stat.h index e302f1345c..2acdfd8a3e 100644 --- a/include/constants/game_stat.h +++ b/include/constants/game_stat.h @@ -52,7 +52,7 @@ #define GAME_STAT_RODE_CABLE_CAR 48 #define GAME_STAT_ENTERED_HOT_SPRINGS 49 #define GAME_STAT_NUM_UNION_ROOM_BATTLES 50 -#define GAME_STAT_51 51 +#define GAME_STAT_PLAYED_BERRY_CRUSH 51 #define NUM_USED_GAME_STATS 52 #define NUM_GAME_STATS 64 diff --git a/include/global.h b/include/global.h index 1992ff8196..7daed8621d 100644 --- a/include/global.h +++ b/include/global.h @@ -209,7 +209,7 @@ struct PyramidBag struct BerryCrush { - u16 berryCrushResults[4]; + u16 pressingSpeeds[4]; // For the record with each possible group size, 2-5 players u32 berryPowderAmount; u32 unk; }; diff --git a/include/graphics.h b/include/graphics.h index b1a781ffff..9be05f38eb 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -5001,9 +5001,9 @@ extern const u16 gUsePokeblockUpDown_Pal[]; extern const u16 gUsePokeblockCondition_Pal[]; // Berry Crush -extern const u32 gUnknown_08DE34B8[]; -extern const u16 gUnknown_08DE3398[]; -extern const u32 gUnknown_08DE3FD4[]; +extern const u32 gBerryCrush_Crusher_Gfx[]; +extern const u16 gBerryCrush_Crusher_Pal[]; +extern const u32 gBerryCrush_Crusher_Tilemap[]; // Pokenav extern const u32 gPokenavMessageBox_Gfx[]; diff --git a/include/strings.h b/include/strings.h index 294ab8aa6f..8880f3a5c8 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2904,7 +2904,7 @@ extern const u8 gText_CrushingResults[]; extern const u8 gText_BerryCrush2[]; extern const u8 gText_PressingSpeedRankings[]; extern const u8 gText_Var1Players[]; -extern const u8 gText_ReadyToBerryCrush[]; +extern const u8 gText_ReadyPickBerry[]; extern const u8 gText_WaitForAllChooseBerry[]; extern const u8 gText_EndedWithXUnitsPowder[]; extern const u8 gText_RecordingGameResults[]; diff --git a/src/berry.c b/src/berry.c index ea62deabf7..d56ec801ca 100644 --- a/src/berry.c +++ b/src/berry.c @@ -889,50 +889,50 @@ const struct Berry gBerries[] = }, }; -const struct UnkStruct_0858AB24 gUnknown_0858AB24[] = { - { 50, 20}, - { 50, 20}, - { 50, 20}, - { 50, 20}, - { 50, 20}, - { 50, 30}, - { 50, 30}, - { 50, 30}, - { 50, 30}, - { 50, 30}, - { 60, 50}, - { 60, 50}, - { 60, 50}, - { 60, 50}, - { 60, 50}, - { 80, 70}, - { 80, 70}, - { 80, 70}, - { 80, 70}, - { 80, 70}, - {100, 100}, - {100, 100}, - {100, 100}, - {100, 100}, - {100, 100}, - {130, 150}, - {130, 150}, - {130, 150}, - {130, 150}, - {130, 150}, - {160, 250}, - {160, 250}, - {160, 250}, - {160, 250}, - {160, 250}, - {180, 500}, - {180, 500}, - {180, 500}, - {180, 500}, - {180, 500}, - {200, 750}, - {200, 750}, - {150, 200} +const struct BerryCrushBerryData gBerryCrush_BerryData[] = { + [ITEM_CHERI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20}, + [ITEM_CHESTO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20}, + [ITEM_PECHA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20}, + [ITEM_RAWST_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20}, + [ITEM_ASPEAR_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20}, + [ITEM_LEPPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30}, + [ITEM_ORAN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30}, + [ITEM_PERSIM_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30}, + [ITEM_LUM_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30}, + [ITEM_SITRUS_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30}, + [ITEM_FIGY_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50}, + [ITEM_WIKI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50}, + [ITEM_MAGO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50}, + [ITEM_AGUAV_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50}, + [ITEM_IAPAPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50}, + [ITEM_RAZZ_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70}, + [ITEM_BLUK_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70}, + [ITEM_NANAB_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70}, + [ITEM_WEPEAR_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70}, + [ITEM_PINAP_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70}, + [ITEM_POMEG_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100}, + [ITEM_KELPSY_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100}, + [ITEM_QUALOT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100}, + [ITEM_HONDEW_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100}, + [ITEM_GREPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100}, + [ITEM_TAMATO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150}, + [ITEM_CORNN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150}, + [ITEM_MAGOST_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150}, + [ITEM_RABUTA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150}, + [ITEM_NOMEL_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150}, + [ITEM_SPELON_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250}, + [ITEM_PAMTRE_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250}, + [ITEM_WATMEL_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250}, + [ITEM_DURIN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250}, + [ITEM_BELUE_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250}, + [ITEM_LIECHI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500}, + [ITEM_GANLON_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500}, + [ITEM_SALAC_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500}, + [ITEM_PETAYA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500}, + [ITEM_APICOT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500}, + [ITEM_LANSAT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 200, .powder = 750}, + [ITEM_STARF_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 200, .powder = 750}, + [ITEM_ENIGMA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 150, .powder = 200} }; const struct BerryTree gBlankBerryTree = {}; diff --git a/src/berry_crush.c b/src/berry_crush.c index 635f2a639a..e63eb9f828 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -38,204 +38,352 @@ #include "constants/rgb.h" #include "constants/songs.h" +#define MAX_TIME (10 * 60 * 60) // Timer can go up to 9:59:59 + +#define TAG_CRUSHER_BASE 1 +#define PALTAG_EFFECT 2 // The next two gfx tags share this pal tag +#define GFXTAG_IMPACT 2 +#define GFXTAG_SPARKLE 3 +#define TAG_TIMER_DIGITS 4 +#define TAG_PLAYER1_BERRY 5 +#define TAG_PLAYER2_BERRY 6 +#define TAG_PLAYER3_BERRY 7 +#define TAG_PLAYER4_BERRY 8 +#define TAG_PLAYER5_BERRY 9 + #define TAG_COUNTDOWN 0x1000 +#define CRUSHER_START_Y (-104) + +enum { + RUN_CMD, + SCHEDULE_CMD, +}; + +// IDs for the main berry crush game functions +enum { + CMD_NONE, + CMD_FADE, + CMD_WAIT_FADE, + CMD_PRINT_MSG, + CMD_SHOW_GAME, + CMD_HIDE_GAME, + CMD_READY_BEGIN, + CMD_ASK_PICK_BERRY, + CMD_PICK_BERRY, + CMD_WAIT_BERRIES, + CMD_DROP_BERRIES, + CMD_DROP_LID, + CMD_COUNTDOWN, + CMD_PLAY_GAME_LEADER, + CMD_PLAY_GAME_MEMBER, + CMD_FINISH_GAME, + CMD_TIMES_UP, + CMD_CALC_RESULTS, + CMD_SHOW_RESULTS, + CMD_SAVE, + CMD_ASK_PLAY_AGAIN, + CMD_COMM_PLAY_AGAIN, + CMD_PLAY_AGAIN_YES, + CMD_PLAY_AGAIN_NO, + CMD_CLOSE_LINK, + CMD_QUIT, +}; + +enum { + MSG_PICK_BERRY, + MSG_WAIT_PICK, + MSG_POWDER, + MSG_SAVING, + MSG_PLAY_AGAIN, + MSG_NO_BERRIES, + MSG_DROPPED, + MSG_TIMES_UP, + MSG_COMM_STANDBY, +}; + +#define F_MSG_CLEAR (1 << 0) +#define F_MSG_EXPAND (1 << 1) + +// Main states for the game. Many are assigned but never checked +enum { + STATE_INIT = 1, + STATE_RESET, + STATE_PICK_BERRY, + STATE_DROP_BERRIES, + STATE_DROP_LID, + STATE_COUNTDOWN, + STATE_PLAYING, + STATE_FINISHED, + STATE_TIMES_UP, + STATE_10, // Unused + STATE_RESULTS_PRESSES, + STATE_RESULTS_RANDOM, + STATE_RESULTS_CRUSHING, + STATE_14, // Unused + STATE_PLAY_AGAIN, +}; + +#define RESULTS_STATE_START STATE_RESULTS_PRESSES +#define RESULTS_STATE_END STATE_RESULTS_CRUSHING + +// IDs for each results page that shows in succession at the game's end. +// Only 3 pages are shown for a given game. Presses and Crushing are always shown 1st and 3rd. +// The 2nd page is random, and can be rankings for either Neatness, Cooperative, or Power. +enum { + RESULTS_PAGE_PRESSES, + RESULTS_PAGE_RANDOM, + RESULTS_PAGE_CRUSHING, + NUM_RESULTS_PAGES, +}; +// Random pages, see above +// "Neatness" is how many of the player's inputs were at a regular interval +// "Cooperative" is how often the player pressed A at the same time as others +// "Power" is how much of the time the player spent pressing A +enum { + RESULTS_PAGE_NEATNESS, + RESULTS_PAGE_COOPERATIVE, + RESULTS_PAGE_POWER, + NUM_RANDOM_RESULTS_PAGES +}; + +#define PLAY_AGAIN_YES 0 +#define PLAY_AGAIN_NO 1 +#define PLAY_AGAIN_NO_BERRIES 3 + +enum { + COLORID_GREY, + COLORID_BLACK, + COLORID_LIGHT_GREY, + COLORID_BLUE, + COLORID_GREEN, + COLORID_RED, +}; + +// Flags for the inputFlags field +// Field is 16 bits; 3 bits for each player, last bit is unused +// The first two bits are interchangeable +// Needlessly complicated system, the inputState field is sufficient by itself +#define F_INPUT_HIT_A (1 << 0) +#define F_INPUT_HIT_B (1 << 1) +#define F_INPUT_HIT_SYNC (1 << 2) // Input at same time as another player +#define INPUT_FLAGS_PER_PLAYER 3 +#define INPUT_FLAG_MASK ((1 << INPUT_FLAGS_PER_PLAYER) - 1) + +// Values for the inputState field +enum { + INPUT_STATE_NONE, + INPUT_STATE_HIT, // Hit the crusher + INPUT_STATE_HIT_SYNC, // Hit the crusher at same time as another player +}; + +// No reason for this to be 2 +// Simply a flag for whether a given player has sent their data this round +// Data is only sent if the player is the leader or if they pressed A +#define SEND_GAME_STATE 2 + struct BerryCrushGame_Player { - u8 unk0[PLAYER_NAME_LENGTH + 1 + 4]; - u16 unkC; - u16 unkE; - u16 unk10; - u16 unk12; - u16 unk14; - u16 unk16; - u16 unk18; - u16 unk1A; - u8 unk1B; - u8 unk1C; + u8 name[PLAYER_NAME_LENGTH + 1 + 4]; + u16 berryId; + u16 inputTime; + u16 neatInputStreak; + u16 timeSincePrevInput; + u16 maxNeatInputStreak; + u16 numAPresses; + u16 numSyncedAPresses; + u16 timePressingA; + u8 inputFlags; + u8 inputState; }; -struct BerryCrushGame_4E +// This data is set locally and sent to the other players +struct BerryCrushGame_LocalState { - u16 unk0; - u16 unk2; - u8 unk4_0:1; - u8 unk4_1:1; - u8 unk4_2:1; - u8 unk4_3:5; - s8 unk5; - u16 unk6; - u16 unk8; - u16 unkA; - u16 unkC; + u16 sendFlag; + bool8 endGame:1; + bool8 bigSparkle:1; + bool8 pushedAButton:1; + u8 playerPressedAFlags:5; // 1 bit for each player + s8 vibration; + u16 depth; + u16 timer; + u16 inputFlags; + u16 sparkleAmount; }; -struct BerryCrushGame_40 +// This data is read from another player's local state above by casting the recvCmd buffer +// It is identical with exception to the addition of rfuCmd +struct BerryCrushGame_LinkState { - s16 unk0; - s16 unk2; - s16 unk4; - s16 unk6; - s16 unk8; - s16 unkA; - s16 unkC; - s16 unkE; + u16 rfuCmd; + u16 sendFlag; + bool8 endGame:1; + bool8 bigSparkle:1; + bool8 pushedAButton:1; + u8 playerPressedAFlags:5; + s8 vibration; + u16 depth; + u16 timer; + u16 inputFlags; + u16 sparkleAmount; }; -struct BerryCrushGame_5C +struct BerryCrushGame_Results { - u16 unk00; - u8 unk02_0:1; - u8 unk02_1:1; - u8 pushedAButton:1; - u8 unk02_3:5; - s8 unk03; - u16 unk04; - u16 unk06; - u16 unk08; - u16 unk0A; + u32 powder; + u16 time; + u16 targetPressesPerSec; // Never read + u16 silkiness; + u16 totalAPresses; + u16 stats[2][MAX_RFU_PLAYERS]; + u8 playerIdsRanked[2][MAX_RFU_PLAYERS + 3]; }; -struct BerryCrushGame_68 +// playerIdsRanked above has 3 additional elements after the players. +// Only 1 of these 2*3 is ever used, and it stores the id for which +// random results page to show. Its define below is for readability. +#define randomPageId playerIdsRanked[0][7] + +// Holds position data for various player-associated graphics +struct BerryCrushPlayerCoords { - u32 unk00; - u16 unk04; - u16 unk06; - u16 unk08; - u16 unk0A; - // 0: Number of A presses - // 1: Neatness - u16 stats[2][5]; - u8 unk20[2][8]; + u8 playerId; + u8 windowGfxX; + u8 windowGfxY; + s16 impactXOffset; + s16 impactYOffset; + s16 berryXOffset; + s16 berryXDest; }; -struct BerryCrushPlayerSeatCoords +struct BerryCrushGame_Gfx { - u8 unk0; - u8 unk1; - u8 unk2; - s16 unk4; - s16 unk6; - s16 unk8; - s16 unkA; -}; - -struct BerryCrushGame_138 -{ - u8 animBerryIdx; - u8 unk1; - u8 unk2; - u8 unk3; + u8 counter; + u8 vibrationIdx; + u8 numVibrations; + bool8 vibrating; s16 minutes; s16 secondsInt; s16 secondsFrac; - const struct BerryCrushPlayerSeatCoords *seatCoords[5]; + const struct BerryCrushPlayerCoords *playerCoords[MAX_RFU_PLAYERS]; struct Sprite *coreSprite; - struct Sprite *impactSprites[5]; - struct Sprite *berrySprites[5]; + struct Sprite *impactSprites[MAX_RFU_PLAYERS]; + struct Sprite *berrySprites[MAX_RFU_PLAYERS]; struct Sprite *sparkleSprites[11]; struct Sprite *timerSprites[2]; - u8 unk80; - u8 filler81; - u8 unk82; - u8 unk83[5]; + u8 resultsState; + u8 unused; + u8 resultsWindowId; + u8 nameWindowIds[MAX_RFU_PLAYERS]; u16 bgBuffers[4][0x800]; }; struct BerryCrushGame { - MainCallback savedCallback; + MainCallback exitCallback; u32 (*cmdCallback)(struct BerryCrushGame *, u8 *); u8 localId; u8 playerCount; - u8 mainTask; + u8 taskId; u8 textSpeed; u8 cmdState; - u8 unkD; + u8 unused; // Never read u8 nextCmd; u8 afterPalFadeCmd; - u16 unk10; + u16 cmdTimer; u16 gameState; - u16 unk14; + u16 playAgainState; u16 pressingSpeed; - s16 unk18; - s16 unk1A; + s16 targetAPresses; + s16 totalAPresses; s32 powder; - s32 unk20; - u8 unk24; - u8 unk25_0:1; - u8 unk25_1:1; - u8 unk25_2:1; - u8 unk25_3:1; - u8 unk25_4:1; - u8 unk25_5:3; - u16 unk26; + s32 targetDepth; + u8 newDepth; + bool8 noRoomForPowder:1; // Never read + bool8 newRecord:1; + bool8 playedSound:1; + bool8 endGame:1; + bool8 bigSparkle:1; + u8 sparkleAmount:3; + u16 leaderTimer; u16 timer; s16 depth; s16 vibration; - s16 unk2E; - s16 unk30; - s16 unk32; - s16 unk34; - u8 commandParams[0xC]; + s16 bigSparkleCounter; + s16 numBigSparkles; + s16 numBigSparkleChecks; + s16 sparkleCounter; + u8 commandArgs[12]; u16 sendCmd[6]; u16 recvCmd[7]; - struct BerryCrushGame_5C localState; - struct BerryCrushGame_68 unk68; - struct BerryCrushGame_Player unk98[5]; - struct BerryCrushGame_138 unk138; + struct BerryCrushGame_LocalState localState; + struct BerryCrushGame_Results results; + struct BerryCrushGame_Player players[MAX_RFU_PLAYERS]; + struct BerryCrushGame_Gfx gfx; }; static void VBlankCB(void); static void MainCB(void); static void MainTask(u8); -static void ParseName_Options(struct BerryCrushGame *); -static void BerryCrush_RunOrScheduleCommand(u16, u8, u8 *); -static void BerryCrush_SetPaletteFadeParams(u8 *, bool8, u32, s8, u8, u8, u16); -static s32 sub_8021450(struct BerryCrushGame *); -static void sub_8022588(struct BerryCrushGame *); -static void sub_8022600(struct BerryCrushGame *); -static void sub_80226D0(struct BerryCrushGame *); -static void sub_8022730(struct BerryCrushGame *); -static void sub_8022960(struct BerryCrushGame *); -static void BerryCrush_PrintTimeOnSprites(struct BerryCrushGame_138 *, u16); -static void sub_8022B28(struct Sprite *); -static void BerryCrush_HideTimerSprites(struct BerryCrushGame_138 *r0); -static void sub_8024578(struct BerryCrushGame *); -static void BerryCrush_SetShowMessageParams(u8 *params, u8 stringId, u8 flags, u16 waitKeys, u8 followupCmd); -static void SpriteCB_BerryCrushImpact(struct Sprite *sprite); -static u32 BerryCrushCommand_BeginNormalPaletteFade(struct BerryCrushGame *r6, u8 *r1); -static u32 BerryCrushCommand_WaitPaletteFade(struct BerryCrushGame *r4, u8 *r5); -static u32 BerryCrushCommand_PrintMessage(struct BerryCrushGame *r7, u8 *r5); -static u32 BerryCrushCommand_InitGfx(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_TeardownGfx(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_SignalReadyToBegin(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_AskPickBerry(struct BerryCrushGame *r4, u8 *r5); -static u32 BerryCrushCommand_GoToBerryPouch(struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_WaitForOthersToPickBerries(struct BerryCrushGame *r5, u8 *r2); -static u32 BerryCrushCommand_DropBerriesIntoCrusher(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_DropLid(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_Countdown(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_PlayGame_Master(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_PlayGame_Slave(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_FinishGame(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_HandleTimeUp(struct BerryCrushGame *r5, u8 *r6); -static u32 BerryCrushCommand_TabulateResults(struct BerryCrushGame *r7, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_ShowResults(struct BerryCrushGame *r5, u8 *r6); -static u32 BerryCrushCommand_SaveGame(struct BerryCrushGame *r5, u8 *r4); -static u32 BerryCrushCommand_AskPlayAgain(struct BerryCrushGame *r5, u8 *r6); -static u32 BerryCrushCommand_CommunicatePlayAgainResponses(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_FadeOutToPlayAgain(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_PlayAgainFailureMessage(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_GracefulExit(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1); -static u32 BerryCrushCommand_Quit(__attribute__((unused)) struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1); +static void SetNamesAndTextSpeed(struct BerryCrushGame *); +static void RunOrScheduleCommand(u16, u8, u8 *); +static void SetPaletteFadeArgs(u8 *, bool8, u32, s8, u8, u8, u16); +static s32 UpdateGame(struct BerryCrushGame *); +static void CreatePlayerNameWindows(struct BerryCrushGame *); +static void DrawPlayerNameWindows(struct BerryCrushGame *); +static void CopyPlayerNameWindowGfxToBg(struct BerryCrushGame *); +static void CreateGameSprites(struct BerryCrushGame *); +static void DestroyGameSprites(struct BerryCrushGame *); +static void PrintTimer(struct BerryCrushGame_Gfx *, u16); +static void SpriteCB_Sparkle_Init(struct Sprite *); +static void HideTimer(struct BerryCrushGame_Gfx *); +static void ResetGame(struct BerryCrushGame *); +static void SetPrintMessageArgs(u8 *, u8, u8, u16, u8); +static void SpriteCB_Impact(struct Sprite *); +static u32 Cmd_BeginNormalPaletteFade(struct BerryCrushGame *, u8 *); +static u32 Cmd_WaitPaletteFade(struct BerryCrushGame *, u8 *); +static u32 Cmd_PrintMessage(struct BerryCrushGame *, u8 *); +static u32 Cmd_ShowGameDisplay(struct BerryCrushGame *, u8 *); +static u32 Cmd_HideGameDisplay(struct BerryCrushGame *, u8 *); +static u32 Cmd_SignalReadyToBegin(struct BerryCrushGame *, u8 *); +static u32 Cmd_AskPickBerry(struct BerryCrushGame *, u8 *); +static u32 Cmd_GoToBerryPouch(struct BerryCrushGame *, u8 *); +static u32 Cmd_WaitForOthersToPickBerries(struct BerryCrushGame *, u8 *); +static u32 Cmd_DropBerriesIntoCrusher(struct BerryCrushGame *, u8 *); +static u32 Cmd_DropLid(struct BerryCrushGame *, u8 *); +static u32 Cmd_Countdown(struct BerryCrushGame *, u8 *); +static u32 Cmd_PlayGame_Leader(struct BerryCrushGame *, u8 *); +static u32 Cmd_PlayGame_Member(struct BerryCrushGame *, u8 *); +static u32 Cmd_FinishGame(struct BerryCrushGame *, u8 *); +static u32 Cmd_HandleTimeUp(struct BerryCrushGame *, u8 *); +static u32 Cmd_TabulateResults(struct BerryCrushGame *, u8 *); +static u32 Cmd_ShowResults(struct BerryCrushGame *, u8 *); +static u32 Cmd_SaveGame(struct BerryCrushGame *, u8 *); +static u32 Cmd_AskPlayAgain(struct BerryCrushGame *, u8 *); +static u32 Cmd_CommunicatePlayAgainResponses(struct BerryCrushGame *, u8 *); +static u32 Cmd_PlayAgain(struct BerryCrushGame *, u8 *); +static u32 Cmd_StopGame(struct BerryCrushGame *, u8 *); +static u32 Cmd_CloseLink(struct BerryCrushGame *, u8 *); +static u32 Cmd_Quit(struct BerryCrushGame *, u8 *); -static EWRAM_DATA struct BerryCrushGame *sBerryCrushGamePtr = NULL; +static EWRAM_DATA struct BerryCrushGame *sGame = NULL; -static const u8 gUnknown_082F325C[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; -static const u8 gUnknown_082F3264[] = { 0, 1, 2, 3, 5, 0, 0, 0 }; - -static const s8 gUnknown_082F326C[][7] = +static const u8 sBitTable[] = { + 1 << 0, + 1 << 1, + 1 << 2, + 1 << 3, + 1 << 4, + 1 << 5, + 1 << 6, + 1 << 7 +}; +// Additional A presses are counted depending on the number of players +// The bonus of 5 is unobtainable +static const u8 sSyncPressBonus[MAX_RFU_PLAYERS] = { 0, 1, 2, 3, 5 }; +ALIGNED(4) +static const s8 sIntroOutroVibrationData[][7] = { { 4, 1, 0, -1, 0, 0, 0}, { 4, 2, 0, -1, 0, 0, 0}, @@ -244,9 +392,8 @@ static const s8 gUnknown_082F326C[][7] = { 6, 4, 1, -2, -4, -2, 0}, }; -static const u8 sUnusedZero = 0; - -static const u8 gUnknown_082F3290[][4] = +ALIGNED(4) +static const u8 sVibrationData[MAX_RFU_PLAYERS][4] = { {3, 2, 1, 0}, {3, 3, 1, 0}, @@ -255,20 +402,20 @@ static const u8 gUnknown_082F3290[][4] = {3, 5, 3, 0}, }; -static const u8 *const sBerryCrushMessages[] = +static const u8 *const sMessages[] = { - gText_ReadyToBerryCrush, - gText_WaitForAllChooseBerry, - gText_EndedWithXUnitsPowder, - gText_RecordingGameResults, - gText_PlayBerryCrushAgain, - gText_YouHaveNoBerries, - gText_MemberDroppedOut, - gText_TimesUpNoGoodPowder, - gText_CommunicationStandby2, + [MSG_PICK_BERRY] = gText_ReadyPickBerry, + [MSG_WAIT_PICK] = gText_WaitForAllChooseBerry, + [MSG_POWDER] = gText_EndedWithXUnitsPowder, + [MSG_SAVING] = gText_RecordingGameResults, + [MSG_PLAY_AGAIN] = gText_PlayBerryCrushAgain, + [MSG_NO_BERRIES] = gText_YouHaveNoBerries, + [MSG_DROPPED] = gText_MemberDroppedOut, + [MSG_TIMES_UP] = gText_TimesUpNoGoodPowder, + [MSG_COMM_STANDBY] = gText_CommunicationStandby2, }; -static const struct BgTemplate gUnknown_082F32C8[4] = +static const struct BgTemplate sBgTemplates[4] = { { .bg = 0, @@ -308,19 +455,18 @@ static const struct BgTemplate gUnknown_082F32C8[4] = }, }; - -static const u8 sBerryCrushTextColorTable[][3] = +static const u8 sTextColorTable[][3] = { - {TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY}, - {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY}, - {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_LIGHT_GREY, TEXT_COLOR_RED}, - {TEXT_COLOR_WHITE, TEXT_COLOR_BLUE, TEXT_COLOR_LIGHT_BLUE}, - {TEXT_COLOR_WHITE, TEXT_COLOR_GREEN, TEXT_COLOR_LIGHT_GREEN}, - {TEXT_COLOR_WHITE, TEXT_COLOR_RED, TEXT_COLOR_LIGHT_RED}, + [COLORID_GREY] = {TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY}, + [COLORID_BLACK] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY}, + [COLORID_LIGHT_GREY] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_LIGHT_GREY, TEXT_COLOR_RED}, + [COLORID_BLUE] = {TEXT_COLOR_WHITE, TEXT_COLOR_BLUE, TEXT_COLOR_LIGHT_BLUE}, + [COLORID_GREEN] = {TEXT_COLOR_WHITE, TEXT_COLOR_GREEN, TEXT_COLOR_LIGHT_GREEN}, + [COLORID_RED] = {TEXT_COLOR_WHITE, TEXT_COLOR_RED, TEXT_COLOR_LIGHT_RED}, }; -static const struct WindowTemplate sWindowTemplate_BerryCrushRankings = +static const struct WindowTemplate sWindowTemplate_Rankings = { .bg = 0, .tilemapLeft = 3, @@ -331,7 +477,7 @@ static const struct WindowTemplate sWindowTemplate_BerryCrushRankings = .baseBlock = 1 }; -static const struct WindowTemplate gUnknown_082F32F4[] = +static const struct WindowTemplate sWindowTemplates_PlayerNames[MAX_RFU_PLAYERS + 1] = { { .bg = 0, @@ -381,9 +527,9 @@ static const struct WindowTemplate gUnknown_082F32F4[] = DUMMY_WIN_TEMPLATE, }; -static const struct WindowTemplate gUnknown_082F3324[] = +static const struct WindowTemplate sWindowTemplates_Results[] = { - { + [STATE_RESULTS_PRESSES - RESULTS_STATE_START] = { .bg = 0, .tilemapLeft = 5, .tilemapTop = 2, @@ -392,7 +538,7 @@ static const struct WindowTemplate gUnknown_082F3324[] = .paletteNum = 15, .baseBlock = 1 }, - { + [STATE_RESULTS_RANDOM - RESULTS_STATE_START] = { .bg = 0, .tilemapLeft = 5, .tilemapTop = 2, @@ -401,7 +547,7 @@ static const struct WindowTemplate gUnknown_082F3324[] = .paletteNum = 15, .baseBlock = 1 }, - { + [STATE_RESULTS_CRUSHING - RESULTS_STATE_START] = { .bg = 0, .tilemapLeft = 4, .tilemapTop = 2, @@ -413,16 +559,16 @@ static const struct WindowTemplate gUnknown_082F3324[] = DUMMY_WIN_TEMPLATE, }; -static const u8 gUnknown_082F3344[][4] = +// The height of the results window depending on the number of players +// 2 players, 3 players, 4 players, or 5 players +static const u8 sResultsWindowHeights[][MAX_RFU_PLAYERS - 1] = { - {6, 8, 9, 11}, - {12, 14, 15, 16}, + {6, 8, 9, 11}, // "Presses" and "Neatness/Cooperative/Power" pages + {12, 14, 15, 16}, // "Crushing" page }; static const u32 sPressingSpeedConversionTable[] = { - // Decimal point is vertically aligned with the pixel - // directly between the >< below. 50000000, // 50 25000000, // 25 12500000, // 12.5 @@ -433,83 +579,85 @@ static const u32 sPressingSpeedConversionTable[] = 390625 // 0.390625 }; -static const u16 gBerryCrushGrinderBasePal[] = INCBIN_U16("graphics/link_games/berrycrush_grinder_base.gbapal"); -static const u16 gBerryCrushMiscSpritesPal[] = INCBIN_U16("graphics/link_games/berrycrush_misc.gbapal"); -static const u16 gBerryCrushTimerDigitsPal[] = INCBIN_U16("graphics/link_games/berrycrush_timerdigits.gbapal"); -static const u32 gBerryCrushGrinderBaseGfx[] = INCBIN_U32("graphics/link_games/berrycrush_grinder_base.4bpp.lz"); -static const u32 gBerryCrushBtnPressGfx[] = INCBIN_U32("graphics/link_games/berrycrush_btnpress.4bpp.lz"); -static const u32 gBerryCrushSparkleGfx[] = INCBIN_U32("graphics/link_games/berrycrush_sparkle.4bpp.lz"); -static const u8 gBerryCrushTimerDigitsGfx[] = INCBIN_U8("graphics/link_games/berrycrush_timerdigits.4bpp.lz"); -static const u8 gBerryCrushGrinderTopTilemap[] = INCBIN_U8("graphics/link_games/berrycrush_grinder_top.bin.lz"); -static const u8 gBerryCrushContainerCapTilemap[] = INCBIN_U8("graphics/link_games/berrycrush_container_cap.bin.lz"); -static const u8 gBerryCrushBackgroundTilemap[] = INCBIN_U8("graphics/link_games/berrycrush_background.bin.lz"); +static const u16 sCrusherBase_Pal[] = INCBIN_U16("graphics/berry_crush/crusher_base.gbapal"); +static const u16 sEffects_Pal[] = INCBIN_U16("graphics/berry_crush/effects.gbapal"); +static const u16 sTimerDigits_Pal[] = INCBIN_U16("graphics/berry_crush/timer_digits.gbapal"); +static const u32 sCrusherBase_Gfx[] = INCBIN_U32("graphics/berry_crush/crusher_base.4bpp.lz"); +static const u32 sImpact_Gfx[] = INCBIN_U32("graphics/berry_crush/impact.4bpp.lz"); +static const u32 sSparkle_Gfx[] = INCBIN_U32("graphics/berry_crush/sparkle.4bpp.lz"); +static const u32 sTimerDigits_Gfx[] = INCBIN_U32("graphics/berry_crush/timer_digits.4bpp.lz"); +static const u8 sCrusherTop_Tilemap[] = INCBIN_U8("graphics/berry_crush/crusher_top.bin.lz"); +static const u8 sContainerCap_Tilemap[] = INCBIN_U8("graphics/berry_crush/container_cap.bin.lz"); +static const u8 sBg_Tilemap[] = INCBIN_U8("graphics/berry_crush/bg.bin.lz"); -static const u8 gUnknown_082F417C[][5] = +// Takes the number of players - 2 and a player id and returns the +// index into sPlayerCoords where that player should be seated +static const u8 sPlayerIdToPosId[MAX_RFU_PLAYERS - 1][MAX_RFU_PLAYERS] = { - {1, 3, 0, 0, 0}, - {0, 1, 3, 0, 0}, - {1, 3, 2, 4, 0}, + {1, 3}, + {0, 1, 3}, + {1, 3, 2, 4}, {0, 1, 3, 2, 4}, }; -static const struct BerryCrushPlayerSeatCoords gUnknown_082F4190[] = +static const struct BerryCrushPlayerCoords sPlayerCoords[MAX_RFU_PLAYERS] = { { - .unk0 = 0, - .unk1 = 0, - .unk2 = 0, - .unk4 = 0, - .unk6 = -16, - .unk8 = 0, - .unkA = 0, + .playerId = 0, + .windowGfxX = 0, + .windowGfxY = 0, + .impactXOffset = 0, + .impactYOffset = -16, + .berryXOffset = 0, + .berryXDest = 0, }, { - .unk0 = 1, - .unk1 = 0, - .unk2 = 3, - .unk4 = -28, - .unk6 = -4, - .unk8 = -24, - .unkA = 16, + .playerId = 1, + .windowGfxX = 0, + .windowGfxY = 3, + .impactXOffset = -28, + .impactYOffset = -4, + .berryXOffset = -24, + .berryXDest = 16, }, { - .unk0 = 2, - .unk1 = 0, - .unk2 = 6, - .unk4 = -16, - .unk6 = 20, - .unk8 = -8, - .unkA = 16, + .playerId = 2, + .windowGfxX = 0, + .windowGfxY = 6, + .impactXOffset = -16, + .impactYOffset = 20, + .berryXOffset = -8, + .berryXDest = 16, }, { - .unk0 = 3, - .unk1 = 20, - .unk2 = 3, - .unk4 = 28, - .unk6 = -4, - .unk8 = 32, - .unkA = -8, + .playerId = 3, + .windowGfxX = 20, + .windowGfxY = 3, + .impactXOffset = 28, + .impactYOffset = -4, + .berryXOffset = 32, + .berryXDest = -8, }, { - .unk0 = 4, - .unk1 = 20, - .unk2 = 6, - .unk4 = 16, - .unk6 = 20, - .unk8 = 16, - .unkA = -8, + .playerId = 4, + .windowGfxX = 20, + .windowGfxY = 6, + .impactXOffset = 16, + .impactYOffset = 20, + .berryXOffset = 16, + .berryXDest = -8, } }; -static const s8 gUnknown_082F41CC[][2] = +static const s8 sImpactCoords[][2] = { { 0, 0}, {-1, 0}, { 1, 1}, }; -static const s8 gUnknown_082F41D2[][2] = +static const s8 sSparkleCoords[][2] = { { 0, 0}, {-16, -4}, @@ -524,37 +672,42 @@ static const s8 gUnknown_082F41D2[][2] = { 40, -16}, }; -static const u16 sPlayerBerrySpriteTags[] = {5, 6, 7, 8, 9, 0}; - -static const struct CompressedSpriteSheet gUnknown_082F41F4[] = +static const u16 sPlayerBerrySpriteTags[MAX_RFU_PLAYERS] = { - { .data = gBerryCrushGrinderBaseGfx, .size = 0x800, .tag = 1 }, - { .data = gBerryCrushBtnPressGfx, .size = 0xE00, .tag = 2 }, - { .data = gBerryCrushSparkleGfx, .size = 0x700, .tag = 3 }, + TAG_PLAYER1_BERRY, + TAG_PLAYER2_BERRY, + TAG_PLAYER3_BERRY, + TAG_PLAYER4_BERRY, + TAG_PLAYER5_BERRY }; -static const struct SpriteSheet gUnknown_082F420C[] = +// sTimerDigits_Gfx is part of this array but is (apparently) uncompressed +// It gets cast to raw uncompressed data when used in sDigitObjTemplates +static const struct CompressedSpriteSheet sSpriteSheets[] = { - { .data = gBerryCrushTimerDigitsGfx, .size = 0x2C0, .tag = 4 }, + { .data = sCrusherBase_Gfx, .size = 0x800, .tag = TAG_CRUSHER_BASE }, + { .data = sImpact_Gfx, .size = 0xE00, .tag = GFXTAG_IMPACT }, + { .data = sSparkle_Gfx, .size = 0x700, .tag = GFXTAG_SPARKLE }, + { .data = sTimerDigits_Gfx, .size = 0x2C0, .tag = TAG_TIMER_DIGITS }, {} }; static const struct SpritePalette sSpritePals[] = { - { .data = gBerryCrushGrinderBasePal, .tag = 1 }, - { .data = gBerryCrushMiscSpritesPal, .tag = 2 }, - { .data = gBerryCrushTimerDigitsPal, .tag = 4 }, + { .data = sCrusherBase_Pal, .tag = TAG_CRUSHER_BASE }, + { .data = sEffects_Pal, .tag = PALTAG_EFFECT }, // For the impact and sparkle effects + { .data = sTimerDigits_Pal, .tag = TAG_TIMER_DIGITS }, {} }; -static const union AnimCmd gUnknown_082F423C[] = +static const union AnimCmd sAnim_CrusherBase[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_END }; -static const union AnimCmd gUnknown_082F4244[] = +static const union AnimCmd sAnim_Impact_Small[] = { ANIMCMD_FRAME(0, 4), ANIMCMD_FRAME(16, 4), @@ -562,7 +715,7 @@ static const union AnimCmd gUnknown_082F4244[] = ANIMCMD_END }; -static const union AnimCmd gUnknown_082F4254[] = +static const union AnimCmd sAnim_Impact_Big[] = { ANIMCMD_FRAME(48, 2), ANIMCMD_FRAME(64, 2), @@ -571,7 +724,7 @@ static const union AnimCmd gUnknown_082F4254[] = ANIMCMD_END }; -static const union AnimCmd gUnknown_082F4268[] = +static const union AnimCmd sAnim_Sparkle_Small[] = { ANIMCMD_FRAME(0, 2), ANIMCMD_FRAME(4, 2), @@ -582,7 +735,7 @@ static const union AnimCmd gUnknown_082F4268[] = ANIMCMD_JUMP(0) }; -static const union AnimCmd gUnknown_082F4284[] = +static const union AnimCmd sAnim_Sparkle_Big[] = { ANIMCMD_FRAME(24, 4), ANIMCMD_FRAME(28, 4), @@ -595,105 +748,105 @@ static const union AnimCmd gUnknown_082F4284[] = ANIMCMD_JUMP(0) }; -static const union AnimCmd gUnknown_082F42A8[] = +static const union AnimCmd sAnim_Timer[] = { ANIMCMD_FRAME(20, 0), ANIMCMD_END }; -static const union AnimCmd gUnknown_082F42B0[] = +static const union AnimCmd sAnim_PlayerBerry[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_END }; -static const union AffineAnimCmd gUnknown_082F42B8[] = +static const union AffineAnimCmd sAffineAnim_PlayerBerry_0[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_FRAME(0, 0, 2, 1), AFFINEANIMCMD_JUMP(1) }; -static const union AffineAnimCmd gUnknown_082F42D0[] = +static const union AffineAnimCmd sAffineAnim_PlayerBerry_1[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_FRAME(0, 0, -2, 1), AFFINEANIMCMD_JUMP(1) }; -static const union AnimCmd *const sAnimTable_BerryCrushCore[] = +static const union AnimCmd *const sAnims_CrusherBase[] = { - gUnknown_082F423C + sAnim_CrusherBase }; -static const union AnimCmd *const sAnimTable_BerryCrushImpact[] = +static const union AnimCmd *const sAnims_Impact[] = { - gUnknown_082F4244, - gUnknown_082F4254, + sAnim_Impact_Small, + sAnim_Impact_Big, }; -static const union AnimCmd *const sAnimTable_BerryCrushPowderSparkles[] = +static const union AnimCmd *const sAnims_Sparkle[] = { - gUnknown_082F4268, - gUnknown_082F4284, + sAnim_Sparkle_Small, + sAnim_Sparkle_Big, }; -static const union AnimCmd *const sAnimTable_BerryCrushTimer[] = +static const union AnimCmd *const sAnims_Timer[] = { - gUnknown_082F42A8 + sAnim_Timer }; -static const union AnimCmd *const gUnknown_082F4300[] = +static const union AnimCmd *const sAnims_PlayerBerry[] = { - gUnknown_082F42B0 + sAnim_PlayerBerry }; -static const union AffineAnimCmd *const gUnknown_082F4304[] = +static const union AffineAnimCmd *const sAffineAnims_PlayerBerry[] = { - gUnknown_082F42B8, - gUnknown_082F42D0, + sAffineAnim_PlayerBerry_0, + sAffineAnim_PlayerBerry_1, }; -static const struct SpriteTemplate sSpriteTemplate_BerryCrushCore = +static const struct SpriteTemplate sSpriteTemplate_CrusherBase = { - .tileTag = 1, - .paletteTag = 1, + .tileTag = TAG_CRUSHER_BASE, + .paletteTag = TAG_CRUSHER_BASE, .oam = &gOamData_AffineOff_ObjNormal_64x64, - .anims = sAnimTable_BerryCrushCore, + .anims = sAnims_CrusherBase, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate sSpriteTemplate_BerryCrushImpact = +static const struct SpriteTemplate sSpriteTemplate_Impact = { - .tileTag = 2, - .paletteTag = 2, + .tileTag = GFXTAG_IMPACT, + .paletteTag = PALTAG_EFFECT, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnimTable_BerryCrushImpact, + .anims = sAnims_Impact, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_BerryCrushImpact + .callback = SpriteCB_Impact }; -static const struct SpriteTemplate sSpriteTemplate_BerryCrushPowderSparkles = +static const struct SpriteTemplate sSpriteTemplate_Sparkle = { - .tileTag = 3, - .paletteTag = 2, + .tileTag = GFXTAG_SPARKLE, + .paletteTag = PALTAG_EFFECT, .oam = &gOamData_AffineOff_ObjNormal_16x16, - .anims = sAnimTable_BerryCrushPowderSparkles, + .anims = sAnims_Sparkle, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate sSpriteTemplate_BerryCrushTimer = +static const struct SpriteTemplate sSpriteTemplate_Timer = { - .tileTag = 4, - .paletteTag = 4, + .tileTag = TAG_TIMER_DIGITS, + .paletteTag = TAG_TIMER_DIGITS, .oam = &gOamData_AffineOff_ObjNormal_8x16, - .anims = sAnimTable_BerryCrushTimer, + .anims = sAnims_Timer, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy @@ -701,18 +854,18 @@ static const struct SpriteTemplate sSpriteTemplate_BerryCrushTimer = static const struct SpriteTemplate sSpriteTemplate_PlayerBerry = { - .tileTag = 5, - .paletteTag = 5, + .tileTag = TAG_PLAYER1_BERRY, + .paletteTag = TAG_PLAYER1_BERRY, .oam = &gOamData_AffineDouble_ObjNormal_32x32, - .anims = gUnknown_082F4300, + .anims = sAnims_PlayerBerry, .images = NULL, - .affineAnims = gUnknown_082F4304, + .affineAnims = sAffineAnims_PlayerBerry, .callback = SpriteCallbackDummy }; static const struct DigitObjUtilTemplate sDigitObjTemplates[] = { - { + { // Minutes .strConvMode = 1, .shape = 2, .size = 0, @@ -721,10 +874,10 @@ static const struct DigitObjUtilTemplate sDigitObjTemplates[] = .xDelta = 8, .x = 156, .y = 0, - .spriteSheet = gUnknown_082F420C, + .spriteSheet = (void*) &sSpriteSheets[3], .spritePal = &sSpritePals[2], }, - { + { // Seconds .strConvMode = 0, .shape = 2, .size = 0, @@ -733,10 +886,10 @@ static const struct DigitObjUtilTemplate sDigitObjTemplates[] = .xDelta = 8, .x = 180, .y = 0, - .spriteSheet = gUnknown_082F420C, + .spriteSheet = (void*) &sSpriteSheets[3], .spritePal = &sSpritePals[2], }, - { + { // 1/60ths of a second .strConvMode = 0, .shape = 2, .size = 0, @@ -745,79 +898,83 @@ static const struct DigitObjUtilTemplate sDigitObjTemplates[] = .xDelta = 8, .x = 204, .y = 0, - .spriteSheet = gUnknown_082F420C, + .spriteSheet = (void*) &sSpriteSheets[3], .spritePal = &sSpritePals[2], } }; -static const u8 *const sBCRankingHeaders[] = +static const u8 *const sResultsTexts[] = { - gText_SpaceTimes2, - gText_XDotY, - gText_Var1Berry, - gText_NeatnessRankings, - gText_CoopRankings, - gText_PressingPowerRankings, + [RESULTS_PAGE_PRESSES] = gText_SpaceTimes2, // " times" + [RESULTS_PAGE_RANDOM] = gText_XDotY, // "##.##", for Neatness, Cooperation, or Power value + [RESULTS_PAGE_CRUSHING] = gText_Var1Berry, + + [RESULTS_PAGE_NEATNESS + NUM_RESULTS_PAGES] = gText_NeatnessRankings, + [RESULTS_PAGE_COOPERATIVE + NUM_RESULTS_PAGES] = gText_CoopRankings, + [RESULTS_PAGE_POWER + NUM_RESULTS_PAGES] = gText_PressingPowerRankings, }; -static u32 (*const sBerryCrushCommands[])(struct BerryCrushGame *, u8 *) = +static u32 (*const sBerryCrushCommands[])(struct BerryCrushGame * game, u8 * data) = { - NULL, - BerryCrushCommand_BeginNormalPaletteFade, - BerryCrushCommand_WaitPaletteFade, - BerryCrushCommand_PrintMessage, - BerryCrushCommand_InitGfx, - BerryCrushCommand_TeardownGfx, - BerryCrushCommand_SignalReadyToBegin, - BerryCrushCommand_AskPickBerry, - BerryCrushCommand_GoToBerryPouch, - BerryCrushCommand_WaitForOthersToPickBerries, - BerryCrushCommand_DropBerriesIntoCrusher, - BerryCrushCommand_DropLid, - BerryCrushCommand_Countdown, - BerryCrushCommand_PlayGame_Master, - BerryCrushCommand_PlayGame_Slave, - BerryCrushCommand_FinishGame, - BerryCrushCommand_HandleTimeUp, - BerryCrushCommand_TabulateResults, - BerryCrushCommand_ShowResults, - BerryCrushCommand_SaveGame, - BerryCrushCommand_AskPlayAgain, - BerryCrushCommand_CommunicatePlayAgainResponses, - BerryCrushCommand_FadeOutToPlayAgain, - BerryCrushCommand_PlayAgainFailureMessage, - BerryCrushCommand_GracefulExit, - BerryCrushCommand_Quit, + [CMD_NONE] = NULL, + [CMD_FADE] = Cmd_BeginNormalPaletteFade, + [CMD_WAIT_FADE] = Cmd_WaitPaletteFade, + [CMD_PRINT_MSG] = Cmd_PrintMessage, + [CMD_SHOW_GAME] = Cmd_ShowGameDisplay, + [CMD_HIDE_GAME] = Cmd_HideGameDisplay, + [CMD_READY_BEGIN] = Cmd_SignalReadyToBegin, + [CMD_ASK_PICK_BERRY] = Cmd_AskPickBerry, + [CMD_PICK_BERRY] = Cmd_GoToBerryPouch, + [CMD_WAIT_BERRIES] = Cmd_WaitForOthersToPickBerries, + [CMD_DROP_BERRIES] = Cmd_DropBerriesIntoCrusher, + [CMD_DROP_LID] = Cmd_DropLid, + [CMD_COUNTDOWN] = Cmd_Countdown, + [CMD_PLAY_GAME_LEADER] = Cmd_PlayGame_Leader, + [CMD_PLAY_GAME_MEMBER] = Cmd_PlayGame_Member, + [CMD_FINISH_GAME] = Cmd_FinishGame, + [CMD_TIMES_UP] = Cmd_HandleTimeUp, + [CMD_CALC_RESULTS] = Cmd_TabulateResults, + [CMD_SHOW_RESULTS] = Cmd_ShowResults, + [CMD_SAVE] = Cmd_SaveGame, + [CMD_ASK_PLAY_AGAIN] = Cmd_AskPlayAgain, + [CMD_COMM_PLAY_AGAIN] = Cmd_CommunicatePlayAgainResponses, + [CMD_PLAY_AGAIN_YES] = Cmd_PlayAgain, + [CMD_PLAY_AGAIN_NO] = Cmd_StopGame, + [CMD_CLOSE_LINK] = Cmd_CloseLink, + [CMD_QUIT] = Cmd_Quit, }; -static const u8 gUnknown_082F4434[][4] = +// Per group size, the number of A presses required to increase the number of sparkles. +static const u8 sSparkleThresholds[MAX_RFU_PLAYERS - 1][4] = { - {2, 4, 6, 7}, - {3, 5, 8, 11}, - {3, 7, 11, 15}, - {4, 8, 12, 17}, + {2, 4, 6, 7}, // 2 players + {3, 5, 8, 11}, // 3 players + {3, 7, 11, 15}, // 4 players + {4, 8, 12, 17}, // 5 players }; -static const u8 gUnknown_082F4444[] = {5, 7, 9, 12}; +// Per group size, the number of A presses required to get big sparkles +static const u8 sBigSparkleThresholds[MAX_RFU_PLAYERS - 1] = {5, 7, 9, 12}; + static const u8 sReceivedPlayerBitmasks[] = {0x03, 0x07, 0x0F, 0x1F}; -struct BerryCrushGame * GetBerryCrushGame(void) +static struct BerryCrushGame * GetBerryCrushGame(void) { - return sBerryCrushGamePtr; + return sGame; } -u32 QuitBerryCrush(MainCallback callback) +static u32 QuitBerryCrush(MainCallback exitCallback) { - if (!sBerryCrushGamePtr) + if (!sGame) return 2; - if (!callback) - callback = sBerryCrushGamePtr->savedCallback; + if (!exitCallback) + exitCallback = sGame->exitCallback; - DestroyTask(sBerryCrushGamePtr->mainTask); - FREE_AND_SET_NULL(sBerryCrushGamePtr); - SetMainCallback2(callback); - if (callback == CB2_ReturnToField) + DestroyTask(sGame->taskId); + FREE_AND_SET_NULL(sGame); + SetMainCallback2(exitCallback); + if (exitCallback == CB2_ReturnToField) { gTextFlags.autoScroll = TRUE; PlayNewMapMusic(MUS_POKE_CENTER); @@ -827,17 +984,23 @@ u32 QuitBerryCrush(MainCallback callback) return 0; } -void StartBerryCrush(MainCallback callback) +#define ERROR_EXIT(exitCallback) \ + { \ + SetMainCallback2(exitCallback); \ + Rfu.unk_10 = 0; \ + Rfu.unk_12 = 0; \ + Rfu.errorState = 1; \ + } + +void StartBerryCrush(MainCallback exitCallback) { u8 playerCount = 0; u8 multiplayerId; if (!gReceivedRemoteLinkPlayers || gWirelessCommType == 0) { - SetMainCallback2(callback); - Rfu.unk_10 = 0; - Rfu.unk_12 = 0; - Rfu.errorState = 1; + // Link disconnected + ERROR_EXIT(exitCallback); return; } @@ -845,35 +1008,31 @@ void StartBerryCrush(MainCallback callback) multiplayerId = GetMultiplayerId(); if (playerCount < 2 || multiplayerId >= playerCount) { - SetMainCallback2(callback); - Rfu.unk_10 = 0; - Rfu.unk_12 = 0; - Rfu.errorState = 1; + // Too few players, or invalid id + ERROR_EXIT(exitCallback); return; } - sBerryCrushGamePtr = AllocZeroed(sizeof(struct BerryCrushGame)); - if (!sBerryCrushGamePtr) + sGame = AllocZeroed(sizeof(*sGame)); + if (!sGame) { - SetMainCallback2(callback); - Rfu.unk_10 = 0; - Rfu.unk_12 = 0; - Rfu.errorState = 1; + // Alloc failed + ERROR_EXIT(exitCallback); return; } - sBerryCrushGamePtr->savedCallback = callback; - sBerryCrushGamePtr->localId = multiplayerId; - sBerryCrushGamePtr->playerCount = playerCount; - ParseName_Options(sBerryCrushGamePtr); - sBerryCrushGamePtr->gameState = 1; - sBerryCrushGamePtr->nextCmd = 1; - sBerryCrushGamePtr->afterPalFadeCmd = 6; - BerryCrush_SetPaletteFadeParams(sBerryCrushGamePtr->commandParams, 1, -1, 0, 16, 0, 0); - BerryCrush_RunOrScheduleCommand(4, 1, sBerryCrushGamePtr->commandParams); + sGame->exitCallback = exitCallback; + sGame->localId = multiplayerId; + sGame->playerCount = playerCount; + SetNamesAndTextSpeed(sGame); + sGame->gameState = STATE_INIT; + sGame->nextCmd = CMD_FADE; + sGame->afterPalFadeCmd = CMD_READY_BEGIN; + SetPaletteFadeArgs(sGame->commandArgs, TRUE, PALETTES_ALL, 0, 16, 0, RGB_BLACK); + RunOrScheduleCommand(CMD_SHOW_GAME, 1, sGame->commandArgs); SetMainCallback2(MainCB); - sBerryCrushGamePtr->mainTask = CreateTask(MainTask, 8); - gTextFlags.autoScroll = 0; + sGame->taskId = CreateTask(MainTask, 8); + gTextFlags.autoScroll = FALSE; } static void GetBerryFromBag(void) @@ -883,18 +1042,18 @@ static void GetBerryFromBag(void) else RemoveBagItem(gSpecialVar_ItemId, 1); - sBerryCrushGamePtr->unk98[sBerryCrushGamePtr->localId].unkC = gSpecialVar_ItemId - FIRST_BERRY_INDEX; - sBerryCrushGamePtr->nextCmd = 1; - sBerryCrushGamePtr->afterPalFadeCmd = 9; - BerryCrush_SetPaletteFadeParams(sBerryCrushGamePtr->commandParams, 0, -1, 0, 16, 0, 0); - BerryCrush_RunOrScheduleCommand(4, 1, sBerryCrushGamePtr->commandParams); - sBerryCrushGamePtr->mainTask = CreateTask(MainTask, 8); + sGame->players[sGame->localId].berryId = gSpecialVar_ItemId - FIRST_BERRY_INDEX; + sGame->nextCmd = CMD_FADE; + sGame->afterPalFadeCmd = CMD_WAIT_BERRIES; + SetPaletteFadeArgs(sGame->commandArgs, FALSE, PALETTES_ALL, 0, 16, 0, RGB_BLACK); + RunOrScheduleCommand(CMD_SHOW_GAME, 1, sGame->commandArgs); + sGame->taskId = CreateTask(MainTask, 8); SetMainCallback2(MainCB); } -static void BerryCrush_SetupMainTask(void) +static void ChooseBerry(void) { - DestroyTask(sBerryCrushGamePtr->mainTask); + DestroyTask(sGame->taskId); ChooseBerryForMachine(GetBerryFromBag); } @@ -908,54 +1067,60 @@ static void BerryCrush_InitVBlankCB(void) SetVBlankCallback(NULL); } -static void BerryCrush_SaveResults(void) +static void SaveResults(void) { - u32 var0, var1; + u32 time, presses; - var0 = sBerryCrushGamePtr->unk68.unk04; - var0 = Q_24_8(var0); - var0 = MathUtil_Div32(var0, Q_24_8(60)); - var1 = sBerryCrushGamePtr->unk68.unk0A; - var1 = Q_24_8(var1); - var1 = MathUtil_Div32(var1, var0) & 0xFFFF; - sBerryCrushGamePtr->pressingSpeed = var1; - switch (sBerryCrushGamePtr->playerCount) + // Calculate pressing speed ((time / 60) / presses) + time = sGame->results.time; + time = Q_24_8(time); + time = MathUtil_Div32(time, Q_24_8(60)); + presses = sGame->results.totalAPresses; + presses = Q_24_8(presses); + presses = MathUtil_Div32(presses, time) & 0xFFFF; + sGame->pressingSpeed = presses; + + switch (sGame->playerCount) { case 2: - if (sBerryCrushGamePtr->pressingSpeed > gSaveBlock2Ptr->berryCrush.berryCrushResults[0]) + if (sGame->pressingSpeed > gSaveBlock2Ptr->berryCrush.pressingSpeeds[0]) { - sBerryCrushGamePtr->unk25_1 = 1; - gSaveBlock2Ptr->berryCrush.berryCrushResults[0] = sBerryCrushGamePtr->pressingSpeed; + // New 2-player record + sGame->newRecord = TRUE; + gSaveBlock2Ptr->berryCrush.pressingSpeeds[0] = sGame->pressingSpeed; } break; case 3: - if (sBerryCrushGamePtr->pressingSpeed > gSaveBlock2Ptr->berryCrush.berryCrushResults[1]) + if (sGame->pressingSpeed > gSaveBlock2Ptr->berryCrush.pressingSpeeds[1]) { - sBerryCrushGamePtr->unk25_1 = 1; - gSaveBlock2Ptr->berryCrush.berryCrushResults[1] = sBerryCrushGamePtr->pressingSpeed; + // New 3-player record + sGame->newRecord = TRUE; + gSaveBlock2Ptr->berryCrush.pressingSpeeds[1] = sGame->pressingSpeed; } break; case 4: - if (sBerryCrushGamePtr->pressingSpeed > gSaveBlock2Ptr->berryCrush.berryCrushResults[2]) + if (sGame->pressingSpeed > gSaveBlock2Ptr->berryCrush.pressingSpeeds[2]) { - sBerryCrushGamePtr->unk25_1 = 1; - gSaveBlock2Ptr->berryCrush.berryCrushResults[2] = sBerryCrushGamePtr->pressingSpeed; + // New 4-player record + sGame->newRecord = TRUE; + gSaveBlock2Ptr->berryCrush.pressingSpeeds[2] = sGame->pressingSpeed; } break; case 5: - if (sBerryCrushGamePtr->pressingSpeed > gSaveBlock2Ptr->berryCrush.berryCrushResults[3]) + if (sGame->pressingSpeed > gSaveBlock2Ptr->berryCrush.pressingSpeeds[3]) { - sBerryCrushGamePtr->unk25_1 = 1; - gSaveBlock2Ptr->berryCrush.berryCrushResults[3] = sBerryCrushGamePtr->pressingSpeed; + // New 5-player record + sGame->newRecord = TRUE; + gSaveBlock2Ptr->berryCrush.pressingSpeeds[3] = sGame->pressingSpeed; } break; } - sBerryCrushGamePtr->powder = sBerryCrushGamePtr->unk68.unk00; - if (GiveBerryPowder(sBerryCrushGamePtr->powder)) + sGame->powder = sGame->results.powder; + if (GiveBerryPowder(sGame->powder)) return; - sBerryCrushGamePtr->unk25_0 = 1; + sGame->noRoomForPowder = TRUE; } static void VBlankCB(void) @@ -975,40 +1140,38 @@ static void MainCB(void) static void MainTask(u8 taskId) { - if (sBerryCrushGamePtr->cmdCallback) - sBerryCrushGamePtr->cmdCallback(sBerryCrushGamePtr, sBerryCrushGamePtr->commandParams); + if (sGame->cmdCallback) + sGame->cmdCallback(sGame, sGame->commandArgs); - sub_8021450(sBerryCrushGamePtr); + UpdateGame(sGame); } -static void ParseName_Options(struct BerryCrushGame *arg0) +static void SetNamesAndTextSpeed(struct BerryCrushGame *game) { - u8 i = 0; - - for (; i < arg0->playerCount; i++) - StringCopy(arg0->unk98[i].unk0, gLinkPlayers[i].name); - for (; i < 5; i++) + u8 i; + for (i = 0; i < game->playerCount; i++) + StringCopy(game->players[i].name, gLinkPlayers[i].name); + for (; i < MAX_RFU_PLAYERS; i++) { - memset(arg0->unk98[i].unk0, 1, PLAYER_NAME_LENGTH); - arg0->unk98[i].unk0[PLAYER_NAME_LENGTH] = EOS; + memset(game->players[i].name, 1, PLAYER_NAME_LENGTH); + game->players[i].name[PLAYER_NAME_LENGTH] = EOS; } switch (gSaveBlock2Ptr->optionsTextSpeed) { case OPTIONS_TEXT_SPEED_SLOW: - arg0->textSpeed = 8; + game->textSpeed = 8; break; case OPTIONS_TEXT_SPEED_MID: - arg0->textSpeed = 4; + game->textSpeed = 4; break; case OPTIONS_TEXT_SPEED_FAST: - arg0->textSpeed = 1; + game->textSpeed = 1; break; } } -// TODO: Everything from here on is likely in separate files. -s32 InitBerryCrushDisplay(void) +static s32 ShowGameDisplay(void) { struct BerryCrushGame *game = GetBerryCrushGame(); if (!game) @@ -1035,10 +1198,10 @@ s32 InitBerryCrushDisplay(void) break; case 3: ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_082F32C8, ARRAY_COUNT(gUnknown_082F32C8)); - SetBgTilemapBuffer(1, game->unk138.bgBuffers[0]); - SetBgTilemapBuffer(2, game->unk138.bgBuffers[2]); - SetBgTilemapBuffer(3, game->unk138.bgBuffers[3]); + InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); + SetBgTilemapBuffer(1, game->gfx.bgBuffers[0]); + SetBgTilemapBuffer(2, game->gfx.bgBuffers[2]); + SetBgTilemapBuffer(3, game->gfx.bgBuffers[3]); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); ChangeBgX(2, 0, 0); @@ -1059,7 +1222,7 @@ s32 InitBerryCrushDisplay(void) CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); - DecompressAndCopyTileDataToVram(1, gUnknown_08DE34B8, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gBerryCrush_Crusher_Gfx, 0, 0, 0); break; case 6: if (FreeTempTileDataBuffersIfPossible()) @@ -1067,16 +1230,16 @@ s32 InitBerryCrushDisplay(void) InitStandardTextBoxWindows(); InitTextBoxGfxAndPrinters(); - sub_8022588(game); - sub_8022600(game); + CreatePlayerNameWindows(game); + DrawPlayerNameWindows(game); gPaletteFade.bufferTransferDisabled = TRUE; break; case 7: - LoadPalette(gUnknown_08DE3398, 0, 0x180); - CopyToBgTilemapBuffer(1, gBerryCrushGrinderTopTilemap, 0, 0); - CopyToBgTilemapBuffer(2, gBerryCrushContainerCapTilemap, 0, 0); - CopyToBgTilemapBuffer(3, gBerryCrushBackgroundTilemap, 0, 0); - sub_80226D0(game); + LoadPalette(gBerryCrush_Crusher_Pal, 0, 0x180); + CopyToBgTilemapBuffer(1, sCrusherTop_Tilemap, 0, 0); + CopyToBgTilemapBuffer(2, sContainerCap_Tilemap, 0, 0); + CopyToBgTilemapBuffer(3, sBg_Tilemap, 0, 0); + CopyPlayerNameWindowGfxToBg(game); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); @@ -1084,7 +1247,7 @@ s32 InitBerryCrushDisplay(void) case 8: LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(0, 0); - sub_8022730(game); + CreateGameSprites(game); SetGpuReg(REG_OFFSET_BG1VOFS, -gSpriteCoordOffsetY); ChangeBgX(1, 0, 0); ChangeBgY(1, 0, 0); @@ -1106,13 +1269,13 @@ s32 InitBerryCrushDisplay(void) return 0; } -static s32 BerryCrush_TeardownBgs(void) +static s32 HideGameDisplay(void) { - struct BerryCrushGame *var0 = GetBerryCrushGame(); - if (!var0) + struct BerryCrushGame *game = GetBerryCrushGame(); + if (!game) return -1; - switch (var0->cmdState) + switch (game->cmdState) { case 0: Rfu_SetLinkStandbyCallback(); @@ -1120,8 +1283,11 @@ static s32 BerryCrush_TeardownBgs(void) case 1: if (!IsLinkTaskFinished()) return 0; - // fall through. The original author forgot to use "break" here - // because this will call BeginNormalPaletteFade() twice. + // fall through + // This will call BeginNormalPaletteFade() twice. +#ifdef BUGFIX + break; +#endif case 2: BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); UpdatePaletteFade(); @@ -1154,83 +1320,98 @@ static s32 BerryCrush_TeardownBgs(void) break; case 6: DestroyWirelessStatusIndicatorSprite(); - sub_8022960(var0); + DestroyGameSprites(game); DigitObjUtil_Free(); break; case 7: - var0->cmdState = 0; + game->cmdState = 0; return 1; } - var0->cmdState++; + game->cmdState++; return 0; } -static s32 sub_8021450(struct BerryCrushGame *arg0) +// Handles the crusher vibration and the timer +static s32 UpdateGame(struct BerryCrushGame *game) { - gSpriteCoordOffsetY = arg0->depth + arg0->vibration; + gSpriteCoordOffsetY = game->depth + game->vibration; SetGpuReg(REG_OFFSET_BG1VOFS, -gSpriteCoordOffsetY); - if (arg0->gameState == 7) - { - BerryCrush_PrintTimeOnSprites(&arg0->unk138, arg0->timer); - } + + if (game->gameState == STATE_PLAYING) + PrintTimer(&game->gfx, game->timer); return 0; } -void sub_8021488(struct BerryCrushGame *arg0) +static void ResetCrusherPos(struct BerryCrushGame *game) { - arg0->depth = -104; - arg0->vibration = 0; + game->depth = CRUSHER_START_Y; + game->vibration = 0; gSpriteCoordOffsetX = 0; - gSpriteCoordOffsetY = -104; + gSpriteCoordOffsetY = CRUSHER_START_Y; } -static void BerryCrush_CreateBerrySprites(struct BerryCrushGame *arg0, struct BerryCrushGame_138 *arg1) +// Sprite data for berry sprites. Identical to fields for sparkle sprites +#define sX data[0] +#define sYSpeed data[1] +#define sYAccel data[2] +#define sXSpeed data[3] +#define sSinIdx data[4] +#define sSinSpeed data[5] +#define sAmplitude data[6] +// The last element (data[7]) is a bitfield. +// The first 15 bits are the y coord to stop at. +// The last bit is a flag for whether or not to move horizontally too +#define sBitfield data[7] +#define MASK_TARGET_Y 0x7FFF +#define F_MOVE_HORIZ 0x8000 + +static void CreateBerrySprites(struct BerryCrushGame *game, struct BerryCrushGame_Gfx *gfx) { u8 i; u8 spriteId; - s16 var0, var1; + s16 distance, var1; s16 *data; - s32 var3; - s16 var5; - u32 var6; + s32 amplitude; + s16 speed; + u32 var2; - for (i = 0; i < arg0->playerCount; i++) + for (i = 0; i < game->playerCount; i++) { spriteId = AddCustomItemIconSprite( &sSpriteTemplate_PlayerBerry, sPlayerBerrySpriteTags[i], sPlayerBerrySpriteTags[i], - arg0->unk98[i].unkC + FIRST_BERRY_INDEX); - arg1->berrySprites[i] = &gSprites[spriteId]; - arg1->berrySprites[i]->oam.priority = 3; - arg1->berrySprites[i]->affineAnimPaused = TRUE; - arg1->berrySprites[i]->pos1.x = arg1->seatCoords[i]->unk8 + 120; - arg1->berrySprites[i]->pos1.y = -16; - data = arg1->berrySprites[i]->data; - var5 = 512; - data[1] = var5; - data[2] = 32; - data[7] = 112; - var0 = arg1->seatCoords[i]->unkA - arg1->seatCoords[i]->unk8; - var3 = var0; - if (var0 < 0) - var3 += 3; + game->players[i].berryId + FIRST_BERRY_INDEX); + gfx->berrySprites[i] = &gSprites[spriteId]; + gfx->berrySprites[i]->oam.priority = 3; + gfx->berrySprites[i]->affineAnimPaused = TRUE; + gfx->berrySprites[i]->pos1.x = gfx->playerCoords[i]->berryXOffset + 120; + gfx->berrySprites[i]->pos1.y = -16; + data = gfx->berrySprites[i]->data; + speed = 512; + sYSpeed = speed; + sYAccel = 32; + sBitfield = 112; // Setting bits in MASK_TARGET_Y + distance = gfx->playerCoords[i]->berryXDest - gfx->playerCoords[i]->berryXOffset; + amplitude = distance; + if (distance < 0) + amplitude += 3; - data[6] = var3 >> 2; - var0 *= 128; - var6 = var5 + 32; - var6 = var6 / 2; - var1 = MathUtil_Div16Shift(7, Q_8_8(63.5), var6); - data[0] = (u16)arg1->berrySprites[i]->pos1.x * 128; - data[3] = MathUtil_Div16Shift(7, var0, var1); + sAmplitude = amplitude >> 2; + distance *= 128; + var2 = speed + 32; + var2 = var2 / 2; + var1 = MathUtil_Div16Shift(7, Q_8_8(63.5), var2); + sX = (u16)gfx->berrySprites[i]->pos1.x * 128; + sXSpeed = MathUtil_Div16Shift(7, distance, var1); var1 = MathUtil_Mul16Shift(7, var1, 85); - data[4] = 0; - data[5] = MathUtil_Div16Shift(7, Q_8_8(63.5), var1); - data[7] |= 0x8000; - if (arg1->seatCoords[i]->unk8 < 0) - StartSpriteAffineAnim(arg1->berrySprites[i], 1); + sSinIdx = 0; + sSinSpeed = MathUtil_Div16Shift(7, Q_8_8(63.5), var1); + sBitfield |= F_MOVE_HORIZ; + if (gfx->playerCoords[i]->berryXOffset < 0) + StartSpriteAffineAnim(gfx->berrySprites[i], 1); } } @@ -1238,22 +1419,22 @@ static void SpriteCB_DropBerryIntoCrusher(struct Sprite *sprite) { s16 *data = sprite->data; - data[1] += data[2]; - sprite->pos2.y += data[1] >> 8; - if (data[7] & 0x8000) + sYSpeed += sYAccel; + sprite->pos2.y += sYSpeed >> 8; + if (sBitfield & F_MOVE_HORIZ) { - sprite->data[0] += data[3]; - data[4] += data[5]; - sprite->pos2.x = Sin(data[4] >> 7, data[6]); - if ((data[7] & 0x8000) && (data[4] >> 7) > 126) + sprite->sX += sXSpeed; + sSinIdx += sSinSpeed; + sprite->pos2.x = Sin(sSinIdx >> 7, sAmplitude); + if ((sBitfield & F_MOVE_HORIZ) && (sSinIdx >> 7) > 126) { sprite->pos2.x = 0; - data[7] &= 0x7FFF; + sBitfield &= MASK_TARGET_Y; } } - sprite->pos1.x = data[0] >> 7; - if (sprite->pos1.y + sprite->pos2.y >= (data[7] & 0x7FFF)) + sprite->pos1.x = sX >> 7; + if (sprite->pos1.y + sprite->pos2.y >= (sBitfield & MASK_TARGET_Y)) { sprite->callback = SpriteCallbackDummy; FreeSpriteOamMatrix(sprite); @@ -1261,119 +1442,143 @@ static void SpriteCB_DropBerryIntoCrusher(struct Sprite *sprite) } } -void BerryCrushFreeBerrySpriteGfx(struct BerryCrushGame *arg0, __attribute__((unused)) struct BerryCrushGame_138 *arg1) +#undef sX +#undef sYSpeed +#undef sYAccel +#undef sXSpeed +#undef sSinIdx +#undef sSinSpeed +#undef sAmplitude +#undef sBitfield +#undef MASK_TARGET_Y +#undef F_MOVE_HORIZ + +static void BerryCrushFreeBerrySpriteGfx(struct BerryCrushGame *game, struct BerryCrushGame_Gfx *gfx) { u8 i; - for (i = 0; i < arg0->playerCount; i++) + for (i = 0; i < game->playerCount; i++) { FreeSpritePaletteByTag(sPlayerBerrySpriteTags[i]); FreeSpriteTilesByTag(sPlayerBerrySpriteTags[i]); } } -void sub_80216E0(struct BerryCrushGame *arg0, struct BerryCrushGame_138 *arg1) +static void UpdateInputEffects(struct BerryCrushGame *game, struct BerryCrushGame_Gfx *gfx) { - u8 sp4; - struct BerryCrushGame_4E *var4E; + u8 numPlayersPressed; + struct BerryCrushGame_LinkState *linkState; u8 i; - u16 var, var2; + u16 temp1, xModifier; - sp4 = 0; - var4E = (struct BerryCrushGame_4E *)arg0->recvCmd; - for (i = 0; i < arg0->playerCount; i++) + numPlayersPressed = 0; + linkState = (struct BerryCrushGame_LinkState *)game->recvCmd; + + // Read inputs and update impact effects + for (i = 0; i < game->playerCount; i++) { - var = var4E->unkA >> (i * 3); - var &= 7; - if (var) - { - sp4++; - if (var & 0x4) - StartSpriteAnim(arg1->impactSprites[i], 1); - else - StartSpriteAnim(arg1->impactSprites[i], 0); + #define flags temp1 - arg1->impactSprites[i]->invisible = FALSE; - arg1->impactSprites[i]->animPaused = FALSE; - arg1->impactSprites[i]->pos2.x = gUnknown_082F41CC[(var % 4) - 1][0]; - arg1->impactSprites[i]->pos2.y = gUnknown_082F41CC[(var % 4) - 1][1]; + flags = linkState->inputFlags >> (i * INPUT_FLAGS_PER_PLAYER); + flags &= INPUT_FLAG_MASK; + if (flags) + { + numPlayersPressed++; + if (flags & F_INPUT_HIT_SYNC) + StartSpriteAnim(gfx->impactSprites[i], 1); // Big impact sprite + else + StartSpriteAnim(gfx->impactSprites[i], 0); // Small impact sprite + + gfx->impactSprites[i]->invisible = FALSE; + gfx->impactSprites[i]->animPaused = FALSE; + gfx->impactSprites[i]->pos2.x = sImpactCoords[(flags % (ARRAY_COUNT(sImpactCoords) + 1)) - 1][0]; + gfx->impactSprites[i]->pos2.y = sImpactCoords[(flags % (ARRAY_COUNT(sImpactCoords) + 1)) - 1][1]; } + + #undef flags } - if (sp4 == 0) + if (numPlayersPressed == 0) { - arg0->unk25_2 = 0; + game->playedSound = FALSE; } else { - var = (u8)(arg0->timer % 3); - var2 = var; - for (i = 0; i < var4E->unkC * 2 + 3; i++) - { - if (arg1->sparkleSprites[i]->invisible) - { - arg1->sparkleSprites[i]->callback = sub_8022B28; - arg1->sparkleSprites[i]->pos1.x = gUnknown_082F41D2[i][0] + 120; - arg1->sparkleSprites[i]->pos1.y = gUnknown_082F41D2[i][1] + 136 - (var * 4); - arg1->sparkleSprites[i]->pos2.x = gUnknown_082F41D2[i][0] + (gUnknown_082F41D2[i][0] / (var2 * 4)); - arg1->sparkleSprites[i]->pos2.y = gUnknown_082F41D2[i][1]; - if (var4E->unk4_1) - StartSpriteAnim(arg1->sparkleSprites[i], 1); - else - StartSpriteAnim(arg1->sparkleSprites[i], 0); + // Update sparkle effect + #define yModifier temp1 - var++; - if (var > 3) - var = 0; + yModifier = (u8)(game->timer % 3); + xModifier = yModifier; + for (i = 0; i < linkState->sparkleAmount * 2 + 3; i++) + { + if (gfx->sparkleSprites[i]->invisible) + { + gfx->sparkleSprites[i]->callback = SpriteCB_Sparkle_Init; + gfx->sparkleSprites[i]->pos1.x = sSparkleCoords[i][0] + 120; + gfx->sparkleSprites[i]->pos1.y = sSparkleCoords[i][1] + 136 - (yModifier * 4); + gfx->sparkleSprites[i]->pos2.x = sSparkleCoords[i][0] + (sSparkleCoords[i][0] / (xModifier * 4)); + gfx->sparkleSprites[i]->pos2.y = sSparkleCoords[i][1]; + if (linkState->bigSparkle) + StartSpriteAnim(gfx->sparkleSprites[i], 1); + else + StartSpriteAnim(gfx->sparkleSprites[i], 0); + + yModifier++; + if (yModifier > 3) + yModifier = 0; } } - if (arg0->unk25_2) + #undef yModifier + + if (game->playedSound) { - arg0->unk25_2 = 0; + game->playedSound = FALSE; } else { - if (sp4 == 1) + if (numPlayersPressed == 1) PlaySE(SE_MUD_BALL); else PlaySE(SE_BREAKABLE_DOOR); - arg0->unk25_2 = 1; + game->playedSound = TRUE; } } } -bool32 sub_80218D4(struct BerryCrushGame *arg0, struct BerryCrushGame_138 *arg1) +static bool32 AreEffectsFinished(struct BerryCrushGame *game, struct BerryCrushGame_Gfx *gfx) { u8 i; - for (i = 0; i < arg0->playerCount; i++) + // Are any impact sprites active + for (i = 0; i < game->playerCount; i++) { - if (!arg1->impactSprites[i]->invisible) + if (!gfx->impactSprites[i]->invisible) return FALSE; } - for (i = 0; i < 11; i++) + // Are any sparkle sprites active + for (i = 0; i < ARRAY_COUNT(gfx->sparkleSprites); i++) { - if (!arg1->sparkleSprites[i]->invisible) + if (!gfx->sparkleSprites[i]->invisible) return FALSE; } - if (arg0->vibration != 0) - arg0->vibration = 0; + if (game->vibration != 0) + game->vibration = 0; return TRUE; } -static void FramesToMinSec(struct BerryCrushGame_138 *arg0, u16 arg1) +static void FramesToMinSec(struct BerryCrushGame_Gfx *gfx, u16 frames) { u8 i = 0; u32 fractionalFrames = 0; s16 r3 = 0; - arg0->minutes = arg1 / 3600; - arg0->secondsInt = (arg1 % 3600) / 60; - r3 = MathUtil_Mul16(Q_8_8(arg1 % 60), 4); + gfx->minutes = frames / (60 * 60); + gfx->secondsInt = (frames % (60 * 60)) / 60; + r3 = MathUtil_Mul16(Q_8_8(frames % 60), 4); for (i = 0; i < 8; i++) { @@ -1381,277 +1586,262 @@ static void FramesToMinSec(struct BerryCrushGame_138 *arg0, u16 arg1) fractionalFrames += sPressingSpeedConversionTable[i]; } - arg0->secondsFrac = fractionalFrames / 1000000; + gfx->secondsFrac = fractionalFrames / 1000000; } static void PrintTextCentered(u8 windowId, u8 left, u8 colorId, const u8 *string) { left = (left * 4) - (GetStringWidth(2, string, -1) / 2u); - AddTextPrinterParameterized3(windowId, 2, left, 0, sBerryCrushTextColorTable[colorId], 0, string); + AddTextPrinterParameterized3(windowId, 2, left, 0, sTextColorTable[colorId], 0, string); } -static void PrintBerryCrushResultWindow(struct BerryCrushGame * sp0C, u8 sp10, u8 sp14, u8 sp18) +static void PrintResultsText(struct BerryCrushGame * game, u8 page, u8 sp14, u8 baseY) { - u8 r8; - u8 sp1C = 0; - u8 sp20 = 0; - u8 r2; - s32 r3; - u8 r7; - struct BerryCrushGame_68 * sp24 = &sp0C->unk68; + u8 i, j; + u8 playerId = 0; + u8 ranking = 0; + s32 x; + u8 stat; + struct BerryCrushGame_Results * results = &game->results; u32 xOffset; - s32 r6; + s32 y; - sp18 -= 16; - if (sp10 == 2) - sp18 -= 42; - r6 = sp18 - 14 * sp0C->playerCount; - if (r6 > 0) - r6 = r6 / 2 + 16; + baseY -= 16; + if (page == RESULTS_PAGE_CRUSHING) + baseY -= 42; + + y = baseY - 14 * game->playerCount; + if (y > 0) + y = y / 2 + 16; else - r6 = 16; + y = 16; - for (r8 = 0; r8 < sp0C->playerCount; r6 += 14, ++r8) + for (i = 0; i < game->playerCount; y += 14, i++) { DynamicPlaceholderTextUtil_Reset(); - switch (sp10) + switch (page) { - case 0: - sp1C = sp24->unk20[sp10][r8]; - if (r8 != 0 && sp24->stats[sp10][r8] != sp24->stats[sp10][r8 - 1]) - sp20 = r8; - ConvertIntToDecimalStringN(gStringVar4, sp24->stats[sp10][r8], STR_CONV_MODE_RIGHT_ALIGN, 4); - StringAppend(gStringVar4, sBCRankingHeaders[sp10]); + case RESULTS_PAGE_PRESSES: + playerId = results->playerIdsRanked[page][i]; + if (i != 0 && results->stats[page][i] != results->stats[page][i - 1]) + ranking = i; + ConvertIntToDecimalStringN(gStringVar4, results->stats[page][i], STR_CONV_MODE_RIGHT_ALIGN, 4); + StringAppend(gStringVar4, sResultsTexts[page]); break; - case 1: - sp1C = sp24->unk20[sp10][r8]; - if (r8 != 0 && sp24->stats[sp10][r8] != sp24->stats[sp10][r8 - 1]) - sp20 = r8; - ConvertIntToDecimalStringN(gStringVar1, sp24->stats[sp10][r8] >> 4, STR_CONV_MODE_RIGHT_ALIGN, 3); + case RESULTS_PAGE_RANDOM: + playerId = results->playerIdsRanked[page][i]; + if (i != 0 && results->stats[page][i] != results->stats[page][i - 1]) + ranking = i; + ConvertIntToDecimalStringN(gStringVar1, results->stats[page][i] >> 4, STR_CONV_MODE_RIGHT_ALIGN, 3); xOffset = 0; - r7 = sp24->stats[sp10][r8] & 15; - for (r2 = 0; r2 < 4; ++r2) - if ((r7 >> (3 - r2)) & 1) - xOffset += sPressingSpeedConversionTable[r2]; - r7 = xOffset / 1000000u; - ConvertIntToDecimalStringN(gStringVar2, r7, STR_CONV_MODE_LEADING_ZEROS, 2); - StringExpandPlaceholders(gStringVar4, sBCRankingHeaders[sp10]); + stat = results->stats[page][i] & 15; + for (j = 0; j < 4; j++) + if ((stat >> (3 - j)) & 1) + xOffset += sPressingSpeedConversionTable[j]; + stat = xOffset / 1000000u; + ConvertIntToDecimalStringN(gStringVar2, stat, STR_CONV_MODE_LEADING_ZEROS, 2); + StringExpandPlaceholders(gStringVar4, sResultsTexts[page]); break; - case 2: - sp1C = r8; - sp20 = r8; - r2 = sp0C->unk98[r8].unkC; - if (r2 >= LAST_BERRY_INDEX - FIRST_BERRY_INDEX + 2) - r2 = 0; - StringCopy(gStringVar1, gBerries[r2].name); - StringExpandPlaceholders(gStringVar4, sBCRankingHeaders[sp10]); + case RESULTS_PAGE_CRUSHING: + playerId = i; + ranking = i; + j = game->players[i].berryId; + if (j >= LAST_BERRY_INDEX - FIRST_BERRY_INDEX + 2) + j = 0; + StringCopy(gStringVar1, gBerries[j].name); + StringExpandPlaceholders(gStringVar4, sResultsTexts[page]); break; } - r3 = GetStringRightAlignXOffset(2, gStringVar4, sp14 - 4); - AddTextPrinterParameterized3(sp0C->unk138.unk82, 2, r3, r6, sBerryCrushTextColorTable[0], 0, gStringVar4); - if (sp1C == sp0C->localId) + x = GetStringRightAlignXOffset(2, gStringVar4, sp14 - 4); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gStringVar4); + if (playerId == game->localId) StringCopy(gStringVar3, gText_1DotBlueF700); else StringCopy(gStringVar3, gText_1DotF700); - gStringVar3[0] = sp20 + CHAR_1; - DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sp0C->unk98[sp1C].unk0); + gStringVar3[0] = ranking + CHAR_1; + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, game->players[playerId].name); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gStringVar3); - AddTextPrinterParameterized3(sp0C->unk138.unk82, 2, 4, r6, sBerryCrushTextColorTable[0], 0, gStringVar4); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, 4, y, sTextColorTable[COLORID_GREY], 0, gStringVar4); } } -static void sub_8021D34(struct BerryCrushGame *r8) +static void PrintCrushingResults(struct BerryCrushGame *game) { - u8 r10 = 0; - u8 r6 = 0; - u32 sp0C = 0; - struct BerryCrushGame_68 *sp10 = &r8->unk68; - u8 r7 = GetWindowAttribute(r8->unk138.unk82, WINDOW_HEIGHT) * 8 - 42; + u8 i = 0; + u8 x = 0; + u32 pressingSpeedFrac = 0; + struct BerryCrushGame_Results *results = &game->results; + u8 y = GetWindowAttribute(game->gfx.resultsWindowId, WINDOW_HEIGHT) * 8 - 42; - FramesToMinSec(&r8->unk138, sp10->unk04); - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[0], 0, gText_TimeColon); - r6 = 176 - (u8)GetStringWidth(2, gText_SpaceSec, -1); - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[0], 0, gText_SpaceSec); - ConvertIntToDecimalStringN(gStringVar1, r8->unk138.secondsInt, STR_CONV_MODE_LEADING_ZEROS, 2); - ConvertIntToDecimalStringN(gStringVar2, r8->unk138.secondsFrac, STR_CONV_MODE_LEADING_ZEROS, 2); + FramesToMinSec(&game->gfx, results->time); + + // Print time text + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gText_TimeColon); + + // Print seconds text + x = 176 - (u8)GetStringWidth(2, gText_SpaceSec, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gText_SpaceSec); + + // Print seconds value + ConvertIntToDecimalStringN(gStringVar1, game->gfx.secondsInt, STR_CONV_MODE_LEADING_ZEROS, 2); + ConvertIntToDecimalStringN(gStringVar2, game->gfx.secondsFrac, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_XDotY2); - r6 -= GetStringWidth(2, gStringVar4, -1); - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[0], 0, gStringVar4); - r6 -= GetStringWidth(2, gText_SpaceMin, -1); - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[0], 0, gText_SpaceMin); - ConvertIntToDecimalStringN(gStringVar1, r8->unk138.minutes, STR_CONV_MODE_LEADING_ZEROS, 1); + x -= GetStringWidth(2, gStringVar4, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gStringVar4); + + // Print minutes text + x -= GetStringWidth(2, gText_SpaceMin, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gText_SpaceMin); + + // Print minutes value + ConvertIntToDecimalStringN(gStringVar1, game->gfx.minutes, STR_CONV_MODE_LEADING_ZEROS, 1); StringExpandPlaceholders(gStringVar4, gText_StrVar1); - r6 -= GetStringWidth(2, gStringVar4, -1); - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[0], 0, gStringVar4); - r7 += 14; - AddTextPrinterParameterized3(r8->unk138.unk82, 2, 0, r7, sBerryCrushTextColorTable[0], 0, gText_PressingSpeed); - r6 = 176 - (u8)GetStringWidth(2, gText_TimesPerSec, -1); - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[0], 0, gText_TimesPerSec); - for (; r10 < 8; ++r10) - if (((u8)r8->pressingSpeed >> (7 - r10)) & 1) - sp0C += *(r10 + sPressingSpeedConversionTable); // It's accessed in a different way here for unknown reason - ConvertIntToDecimalStringN(gStringVar1, r8->pressingSpeed >> 8, STR_CONV_MODE_RIGHT_ALIGN, 3); - ConvertIntToDecimalStringN(gStringVar2, sp0C / 1000000, STR_CONV_MODE_LEADING_ZEROS, 2); + x -= GetStringWidth(2, gStringVar4, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gStringVar4); + + // Print pressing speed text + y += 14; + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, 0, y, sTextColorTable[COLORID_GREY], 0, gText_PressingSpeed); + x = 176 - (u8)GetStringWidth(2, gText_TimesPerSec, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gText_TimesPerSec); + + // Print pressing speed value + for (i = 0; i < 8; i++) + if (((u8)game->pressingSpeed >> (7 - i)) & 1) + pressingSpeedFrac += *(i + sPressingSpeedConversionTable); // It's accessed in a different way here for unknown reason + ConvertIntToDecimalStringN(gStringVar1, game->pressingSpeed >> 8, STR_CONV_MODE_RIGHT_ALIGN, 3); + ConvertIntToDecimalStringN(gStringVar2, pressingSpeedFrac / 1000000, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_XDotY3); - r6 -= GetStringWidth(2, gStringVar4, -1); - if (r8->unk25_1) - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[5], 0, gStringVar4); + x -= GetStringWidth(2, gStringVar4, -1); + if (game->newRecord) + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_RED], 0, gStringVar4); else - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[0], 0, gStringVar4); - r7 += 14; - AddTextPrinterParameterized3(r8->unk138.unk82, 2, 0, r7, sBerryCrushTextColorTable[0], 0, gText_Silkiness); - ConvertIntToDecimalStringN(gStringVar1, sp10->unk08, STR_CONV_MODE_RIGHT_ALIGN, 3); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gStringVar4); + + // Print silkiness text + y += 14; + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, 0, y, sTextColorTable[COLORID_GREY], 0, gText_Silkiness); + + // Print silkiness value + ConvertIntToDecimalStringN(gStringVar1, results->silkiness, STR_CONV_MODE_RIGHT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_Var1Percent); - r6 = 176 - (u8)GetStringWidth(2, gStringVar4, -1); - AddTextPrinterParameterized3(r8->unk138.unk82, 2, r6, r7, sBerryCrushTextColorTable[0], 0, gStringVar4); + x = 176 - (u8)GetStringWidth(2, gStringVar4, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GREY], 0, gStringVar4); } -static bool32 sub_8022070(struct BerryCrushGame *r4, struct BerryCrushGame_138 *r6) +static bool32 OpenResultsWindow(struct BerryCrushGame *game, struct BerryCrushGame_Gfx *gfx) { - u8 r5; + u8 playerCountIdx; struct WindowTemplate template; - switch (r6->unk80) + switch (gfx->resultsState) { case 0: - r5 = r4->playerCount - 2; - BerryCrush_HideTimerSprites(r6); - memcpy(&template, &gUnknown_082F3324[r4->gameState - 11], sizeof(struct WindowTemplate)); - if (r4->gameState == 13) - template.height = gUnknown_082F3344[1][r5]; + playerCountIdx = game->playerCount - 2; + HideTimer(gfx); + memcpy(&template, &sWindowTemplates_Results[game->gameState - RESULTS_STATE_START], sizeof(struct WindowTemplate)); + if (game->gameState == STATE_RESULTS_CRUSHING) + template.height = sResultsWindowHeights[1][playerCountIdx]; else - template.height = gUnknown_082F3344[0][r5]; - r6->unk82 = AddWindow(&template); + template.height = sResultsWindowHeights[0][playerCountIdx]; + gfx->resultsWindowId = AddWindow(&template); break; case 1: - PutWindowTilemap(r6->unk82); - FillWindowPixelBuffer(r6->unk82, PIXEL_FILL(0)); + PutWindowTilemap(gfx->resultsWindowId); + FillWindowPixelBuffer(gfx->resultsWindowId, PIXEL_FILL(0)); break; case 2: - LoadUserWindowBorderGfx_(r6->unk82, 541, 208); - DrawStdFrameWithCustomTileAndPalette(r6->unk82, 0, 541, 13); + LoadUserWindowBorderGfx_(gfx->resultsWindowId, 541, 208); + DrawStdFrameWithCustomTileAndPalette(gfx->resultsWindowId, 0, 541, 13); break; case 3: - r5 = r4->playerCount - 2; - switch (r4->gameState) + playerCountIdx = game->playerCount - 2; + switch (game->gameState) { - case 11: - PrintTextCentered(r6->unk82, 20, 3, gText_PressesRankings); - PrintBerryCrushResultWindow(r4, 0, 0xA0, 8 * gUnknown_082F3344[0][r5]); - r6->unk80 = 5; + case STATE_RESULTS_PRESSES: + PrintTextCentered(gfx->resultsWindowId, 20, COLORID_BLUE, gText_PressesRankings); + PrintResultsText(game, RESULTS_PAGE_PRESSES, 0xA0, 8 * sResultsWindowHeights[0][playerCountIdx]); + gfx->resultsState = 5; // Skip past Crushing Results text return FALSE; - case 12: - PrintTextCentered(r6->unk82, 20, 4, sBCRankingHeaders[r4->unk68.unk20[0][7] + 3]); - PrintBerryCrushResultWindow(r4, 1, 0xA0, 8 * gUnknown_082F3344[0][r5]); - r6->unk80 = 5; + case STATE_RESULTS_RANDOM: + PrintTextCentered(gfx->resultsWindowId, 20, COLORID_GREEN, sResultsTexts[game->results.randomPageId + NUM_RESULTS_PAGES]); + PrintResultsText(game, RESULTS_PAGE_RANDOM, 0xA0, 8 * sResultsWindowHeights[0][playerCountIdx]); + gfx->resultsState = 5; // Skip past Crushing Results text return FALSE; - case 13: - PrintTextCentered(r6->unk82, 22, 3, gText_CrushingResults); - PrintBerryCrushResultWindow(r4, 2, 0xB0, 8 * gUnknown_082F3344[1][r5]); + case STATE_RESULTS_CRUSHING: + PrintTextCentered(gfx->resultsWindowId, 22, COLORID_BLUE, gText_CrushingResults); + PrintResultsText(game, RESULTS_PAGE_CRUSHING, 0xB0, 8 * sResultsWindowHeights[1][playerCountIdx]); break; } break; case 4: - sub_8021D34(r4); + PrintCrushingResults(game); break; case 5: - CopyWindowToVram(r6->unk82, 3); - r6->unk80 = 0; + CopyWindowToVram(gfx->resultsWindowId, 3); + gfx->resultsState = 0; return TRUE; } - ++r6->unk80; + gfx->resultsState++; return FALSE; } -static void sub_802222C(struct BerryCrushGame *r4) +static void CloseResultsWindow(struct BerryCrushGame *game) { - ClearStdWindowAndFrameToTransparent(r4->unk138.unk82, 1); - RemoveWindow(r4->unk138.unk82); - sub_8022600(r4); + ClearStdWindowAndFrameToTransparent(game->gfx.resultsWindowId, 1); + RemoveWindow(game->gfx.resultsWindowId); + DrawPlayerNameWindows(game); } -static void Task_ShowBerryCrushRankings(u8 taskId) +#define tState data[0] +#define tWindowId data[1] +#define tPressingSpeeds(i) data[2 + (i)] // data[2]-[5], for different group sizes + +static void Task_ShowRankings(u8 taskId) { u8 i = 0, j, xPos, yPos; u32 score = 0; s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: - data[1] = AddWindow(&sWindowTemplate_BerryCrushRankings); - PutWindowTilemap(data[1]); - FillWindowPixelBuffer(data[1], PIXEL_FILL(0)); - LoadUserWindowBorderGfx_(data[1], 541, 208); - DrawStdFrameWithCustomTileAndPalette(data[1], 0, 541, 13); + tWindowId = AddWindow(&sWindowTemplate_Rankings); + PutWindowTilemap(tWindowId); + FillWindowPixelBuffer(tWindowId, PIXEL_FILL(0)); + LoadUserWindowBorderGfx_(tWindowId, 541, 208); + DrawStdFrameWithCustomTileAndPalette(tWindowId, 0, 541, 13); break; case 1: + // Print header text xPos = 96 - GetStringWidth(1, gText_BerryCrush2, -1) / 2u; - AddTextPrinterParameterized3( - data[1], - 1, - xPos, - 1, - sBerryCrushTextColorTable[3], - 0, - gText_BerryCrush2 - ); + AddTextPrinterParameterized3(tWindowId, 1, xPos, 1, sTextColorTable[COLORID_BLUE], 0, gText_BerryCrush2); xPos = 96 - GetStringWidth(1, gText_PressingSpeedRankings, -1) / 2u; - AddTextPrinterParameterized3( - data[1], - 1, - xPos, - 17, - sBerryCrushTextColorTable[3], - 0, - gText_PressingSpeedRankings - ); + AddTextPrinterParameterized3(tWindowId, 1, xPos, 17, sTextColorTable[COLORID_BLUE], 0, gText_PressingSpeedRankings); + + // Print pressing speed record for each group size, ranked yPos = 41; - for (i = 0; i < 4; ++i) + for (i = 0; i < MAX_RFU_PLAYERS - 1; i++) { ConvertIntToDecimalStringN(gStringVar1, i + 2, STR_CONV_MODE_LEFT_ALIGN, 1); StringExpandPlaceholders(gStringVar4, gText_Var1Players); - AddTextPrinterParameterized3( - data[1], - 1, - 0, - yPos, - sBerryCrushTextColorTable[0], - 0, - gStringVar4 - ); + AddTextPrinterParameterized3(tWindowId, 1, 0, yPos, sTextColorTable[COLORID_GREY], 0, gStringVar4); xPos = 192 - (u8)GetStringWidth(1, gText_TimesPerSec, -1); - AddTextPrinterParameterized3( - data[1], - 1, - xPos, - yPos, - sBerryCrushTextColorTable[0], - 0, - gText_TimesPerSec - ); - for (j = 0; j < 8; ++j) + AddTextPrinterParameterized3(tWindowId, 1, xPos, yPos, sTextColorTable[COLORID_GREY], 0, gText_TimesPerSec); + for (j = 0; j < 8; j++) { - if (((data[i + 2] & 0xFF) >> (7 - j)) & 1) + if (((tPressingSpeeds(i) & 0xFF) >> (7 - j)) & 1) score += sPressingSpeedConversionTable[j]; } - ConvertIntToDecimalStringN(gStringVar1, (u16)data[i + 2] >> 8, STR_CONV_MODE_RIGHT_ALIGN, 3); + ConvertIntToDecimalStringN(gStringVar1, (u16)tPressingSpeeds(i) >> 8, STR_CONV_MODE_RIGHT_ALIGN, 3); ConvertIntToDecimalStringN(gStringVar2, score / 1000000, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_XDotY3); xPos -= GetStringWidth(1, gStringVar4, -1); - AddTextPrinterParameterized3( - data[1], - 1, - xPos, - yPos, - sBerryCrushTextColorTable[0], - 0, - gStringVar4 - ); + AddTextPrinterParameterized3(tWindowId, 1, xPos, yPos, sTextColorTable[COLORID_GREY], 0, gStringVar4); yPos += 16; score = 0; } - CopyWindowToVram(data[1], 3); + CopyWindowToVram(tWindowId, 3); break; case 2: if (JOY_NEW(A_BUTTON | B_BUTTON)) @@ -1659,16 +1849,16 @@ static void Task_ShowBerryCrushRankings(u8 taskId) else return; case 3: - ClearStdWindowAndFrameToTransparent(data[1], 1); - ClearWindowTilemap(data[1]); - RemoveWindow(data[1]); + ClearStdWindowAndFrameToTransparent(tWindowId, 1); + ClearWindowTilemap(tWindowId); + RemoveWindow(tWindowId); DestroyTask(taskId); EnableBothScriptContexts(); ScriptContext2_Disable(); - data[0] = 0; + tState = 0; return; } - ++data[0]; + tState++; } void ShowBerryCrushRankings(void) @@ -1676,97 +1866,98 @@ void ShowBerryCrushRankings(void) u8 taskId; ScriptContext2_Enable(); - taskId = CreateTask(Task_ShowBerryCrushRankings, 0); - gTasks[taskId].data[2] = gSaveBlock2Ptr->berryCrush.berryCrushResults[0]; - gTasks[taskId].data[3] = gSaveBlock2Ptr->berryCrush.berryCrushResults[1]; - gTasks[taskId].data[4] = gSaveBlock2Ptr->berryCrush.berryCrushResults[2]; - gTasks[taskId].data[5] = gSaveBlock2Ptr->berryCrush.berryCrushResults[3]; + taskId = CreateTask(Task_ShowRankings, 0); + gTasks[taskId].tPressingSpeeds(0) = gSaveBlock2Ptr->berryCrush.pressingSpeeds[0]; + gTasks[taskId].tPressingSpeeds(1) = gSaveBlock2Ptr->berryCrush.pressingSpeeds[1]; + gTasks[taskId].tPressingSpeeds(2) = gSaveBlock2Ptr->berryCrush.pressingSpeeds[2]; + gTasks[taskId].tPressingSpeeds(3) = gSaveBlock2Ptr->berryCrush.pressingSpeeds[3]; } -static void BerryCrush_PrintTimeOnSprites(struct BerryCrushGame_138 *r4, u16 r1) +static void PrintTimer(struct BerryCrushGame_Gfx *gfx, u16 timer) { - FramesToMinSec(r4, r1); - DigitObjUtil_PrintNumOn(0, r4->minutes); - DigitObjUtil_PrintNumOn(1, r4->secondsInt); - DigitObjUtil_PrintNumOn(2, r4->secondsFrac); + FramesToMinSec(gfx, timer); + DigitObjUtil_PrintNumOn(0, gfx->minutes); + DigitObjUtil_PrintNumOn(1, gfx->secondsInt); + DigitObjUtil_PrintNumOn(2, gfx->secondsFrac); } -static void BerryCrush_HideTimerSprites(struct BerryCrushGame_138 *r0) +static void HideTimer(struct BerryCrushGame_Gfx *gfx) { - r0->timerSprites[0]->invisible = TRUE; - r0->timerSprites[1]->invisible = TRUE; + gfx->timerSprites[0]->invisible = TRUE; + gfx->timerSprites[1]->invisible = TRUE; DigitObjUtil_HideOrShow(2, 1); DigitObjUtil_HideOrShow(1, 1); DigitObjUtil_HideOrShow(0, 1); } -static void sub_8022588(struct BerryCrushGame *r5) +static void CreatePlayerNameWindows(struct BerryCrushGame *game) { - u8 r6; - - for (r6 = 0; r6 < r5->playerCount; ++r6) + u8 i; + for (i = 0; i < game->playerCount; i++) { - r5->unk138.seatCoords[r6] = &gUnknown_082F4190[gUnknown_082F417C[r5->playerCount - 2][r6]]; - r5->unk138.unk83[r6] = AddWindow(&gUnknown_082F32F4[r5->unk138.seatCoords[r6]->unk0]); - PutWindowTilemap(r5->unk138.unk83[r6]); - FillWindowPixelBuffer(r5->unk138.unk83[r6], 0); + game->gfx.playerCoords[i] = &sPlayerCoords[sPlayerIdToPosId[game->playerCount - 2][i]]; + game->gfx.nameWindowIds[i] = AddWindow(&sWindowTemplates_PlayerNames[game->gfx.playerCoords[i]->playerId]); + PutWindowTilemap(game->gfx.nameWindowIds[i]); + FillWindowPixelBuffer(game->gfx.nameWindowIds[i], 0); } } -static void sub_8022600(struct BerryCrushGame *r6) +static void DrawPlayerNameWindows(struct BerryCrushGame *game) { - u8 r7; - - for (r7 = 0; r7 < r6->playerCount; ++r7) + u8 i; + for (i = 0; i < game->playerCount; i++) { - PutWindowTilemap(r6->unk138.unk83[r7]); - if (r7 == r6->localId) + PutWindowTilemap(game->gfx.nameWindowIds[i]); + if (i == game->localId) { + // Print the player's name AddTextPrinterParameterized4( - r6->unk138.unk83[r7], + game->gfx.nameWindowIds[i], 2, - 36 - GetStringWidth(2, r6->unk98[r7].unk0, 0) / 2u, + 36 - GetStringWidth(2, game->players[i].name, 0) / 2u, 1, 0, 0, - sBerryCrushTextColorTable[1], + sTextColorTable[COLORID_BLACK], 0, - r6->unk98[r7].unk0 + game->players[i].name ); } else { + // Print a partner's name AddTextPrinterParameterized4( - r6->unk138.unk83[r7], + game->gfx.nameWindowIds[i], 2, - 36 - GetStringWidth(2, r6->unk98[r7].unk0, 0) / 2u, + 36 - GetStringWidth(2, game->players[i].name, 0) / 2u, 1, 0, 0, - sBerryCrushTextColorTable[2], + sTextColorTable[COLORID_LIGHT_GREY], 0, - r6->unk98[r7].unk0 + game->players[i].name ); } - CopyWindowToVram(r6->unk138.unk83[r7], 3); + CopyWindowToVram(game->gfx.nameWindowIds[i], 3); } CopyBgTilemapBufferToVram(0); } -static void sub_80226D0(struct BerryCrushGame *r6) +// Each player name window border uses a color that corresponds to a slot of the crusher lid +static void CopyPlayerNameWindowGfxToBg(struct BerryCrushGame *game) { - u8 r5 = 0; - u8 * r4; + u8 i = 0; + u8 * crusherGfx; - LZ77UnCompWram(gUnknown_08DE3FD4, gDecompressionBuffer); + LZ77UnCompWram(gBerryCrush_Crusher_Tilemap, gDecompressionBuffer); - for (r4 = gDecompressionBuffer; r5 < r6->playerCount; ++r5) + for (crusherGfx = gDecompressionBuffer; i < game->playerCount; i++) { CopyToBgTilemapBufferRect( 3, - &r4[r6->unk138.seatCoords[r5]->unk0 * 40], - r6->unk138.seatCoords[r5]->unk1, - r6->unk138.seatCoords[r5]->unk2, + &crusherGfx[game->gfx.playerCoords[i]->playerId * 40], + game->gfx.playerCoords[i]->windowGfxX, + game->gfx.playerCoords[i]->windowGfxY, 10, 2 ); @@ -1774,96 +1965,99 @@ static void sub_80226D0(struct BerryCrushGame *r6) CopyBgTilemapBufferToVram(3); } -static void sub_8022730(struct BerryCrushGame *r6) +static void CreateGameSprites(struct BerryCrushGame *game) { - u8 r5 = 0; - u8 r2; + u8 i = 0; + u8 spriteId; - r6->depth = -104; - r6->vibration = 0; + game->depth = CRUSHER_START_Y; + game->vibration = 0; gSpriteCoordOffsetX = 0; - gSpriteCoordOffsetY = -104; - for (; r5 < 4; ++r5) - LoadCompressedSpriteSheet(&gUnknown_082F41F4[r5]); + gSpriteCoordOffsetY = CRUSHER_START_Y; + for (i = 0; i < ARRAY_COUNT(sSpriteSheets) - 1; i++) + LoadCompressedSpriteSheet(&sSpriteSheets[i]); LoadSpritePalettes(sSpritePals); - r2 = CreateSprite(&sSpriteTemplate_BerryCrushCore, 120, 88, 5); - r6->unk138.coreSprite = &gSprites[r2]; - r6->unk138.coreSprite->oam.priority = 3; - r6->unk138.coreSprite->coordOffsetEnabled = TRUE; - r6->unk138.coreSprite->animPaused = TRUE; - for (r5 = 0; r5 < r6->playerCount; ++r5) + + // Create sprite for crusher base + spriteId = CreateSprite(&sSpriteTemplate_CrusherBase, 120, 88, 5); + game->gfx.coreSprite = &gSprites[spriteId]; + game->gfx.coreSprite->oam.priority = 3; + game->gfx.coreSprite->coordOffsetEnabled = TRUE; + game->gfx.coreSprite->animPaused = TRUE; + + // Create sprites for the impact effect + for (i = 0; i < game->playerCount; i++) { - r2 = CreateSprite( - &sSpriteTemplate_BerryCrushImpact, - r6->unk138.seatCoords[r5]->unk4 + 120, - r6->unk138.seatCoords[r5]->unk6 + 32, + spriteId = CreateSprite( + &sSpriteTemplate_Impact, + game->gfx.playerCoords[i]->impactXOffset + 120, + game->gfx.playerCoords[i]->impactYOffset + 32, 0 ); - r6->unk138.impactSprites[r5] = &gSprites[r2]; - r6->unk138.impactSprites[r5]->oam.priority = 1; - r6->unk138.impactSprites[r5]->invisible = TRUE; - r6->unk138.impactSprites[r5]->coordOffsetEnabled = TRUE; - r6->unk138.impactSprites[r5]->animPaused = TRUE; + game->gfx.impactSprites[i] = &gSprites[spriteId]; + game->gfx.impactSprites[i]->oam.priority = 1; + game->gfx.impactSprites[i]->invisible = TRUE; + game->gfx.impactSprites[i]->coordOffsetEnabled = TRUE; + game->gfx.impactSprites[i]->animPaused = TRUE; } - for (r5 = 0; r5 < ARRAY_COUNT(r6->unk138.sparkleSprites); ++r5) + + // Create sprites for sparkle effect + for (i = 0; i < ARRAY_COUNT(game->gfx.sparkleSprites); i++) { - r2 = CreateSprite( - &sSpriteTemplate_BerryCrushPowderSparkles, - gUnknown_082F41D2[r5][0] + 120, - gUnknown_082F41D2[r5][1] + 136, + spriteId = CreateSprite( + &sSpriteTemplate_Sparkle, + sSparkleCoords[i][0] + 120, + sSparkleCoords[i][1] + 136, 6 ); - r6->unk138.sparkleSprites[r5] = &gSprites[r2]; - r6->unk138.sparkleSprites[r5]->oam.priority = 3; - r6->unk138.sparkleSprites[r5]->invisible = TRUE; - r6->unk138.sparkleSprites[r5]->animPaused = TRUE; - r6->unk138.sparkleSprites[r5]->data[0] = r5; + game->gfx.sparkleSprites[i] = &gSprites[spriteId]; + game->gfx.sparkleSprites[i]->oam.priority = 3; + game->gfx.sparkleSprites[i]->invisible = TRUE; + game->gfx.sparkleSprites[i]->animPaused = TRUE; + game->gfx.sparkleSprites[i]->data[0] = i; } - for (r5 = 0; r5 < ARRAY_COUNT(r6->unk138.timerSprites); ++r5) + + // Create sprites for timer + for (i = 0; i < ARRAY_COUNT(game->gfx.timerSprites); i++) { - r2 = CreateSprite( - &sSpriteTemplate_BerryCrushTimer, - 24 * r5 + 176, - 8, - 0 - ); - r6->unk138.timerSprites[r5] = &gSprites[r2]; - r6->unk138.timerSprites[r5]->oam.priority = 0; - r6->unk138.timerSprites[r5]->invisible = FALSE; - r6->unk138.timerSprites[r5]->animPaused = FALSE; + spriteId = CreateSprite(&sSpriteTemplate_Timer, 24 * i + 176, 8, 0); + game->gfx.timerSprites[i] = &gSprites[spriteId]; + game->gfx.timerSprites[i]->oam.priority = 0; + game->gfx.timerSprites[i]->invisible = FALSE; + game->gfx.timerSprites[i]->animPaused = FALSE; } DigitObjUtil_CreatePrinter(0, 0, &sDigitObjTemplates[0]); DigitObjUtil_CreatePrinter(1, 0, &sDigitObjTemplates[1]); DigitObjUtil_CreatePrinter(2, 0, &sDigitObjTemplates[2]); - if (r6->gameState == 1) - BerryCrush_HideTimerSprites(&r6->unk138); + + if (game->gameState == STATE_INIT) + HideTimer(&game->gfx); } -static void sub_8022960(struct BerryCrushGame *r5) +static void DestroyGameSprites(struct BerryCrushGame *game) { - u8 r4 = 0; - - FreeSpriteTilesByTag(4); - FreeSpriteTilesByTag(3); - FreeSpriteTilesByTag(2); - FreeSpriteTilesByTag(1); - FreeSpritePaletteByTag(4); - FreeSpritePaletteByTag(2); - FreeSpritePaletteByTag(1); - for (; r4 < ARRAY_COUNT(r5->unk138.timerSprites); ++r4) - DestroySprite(r5->unk138.timerSprites[r4]); + u8 i = 0; + FreeSpriteTilesByTag(TAG_TIMER_DIGITS); + FreeSpriteTilesByTag(GFXTAG_SPARKLE); + FreeSpriteTilesByTag(GFXTAG_IMPACT); + FreeSpriteTilesByTag(TAG_CRUSHER_BASE); + FreeSpritePaletteByTag(TAG_TIMER_DIGITS); + FreeSpritePaletteByTag(PALTAG_EFFECT); + FreeSpritePaletteByTag(TAG_CRUSHER_BASE); + for (i = 0; i < ARRAY_COUNT(game->gfx.timerSprites); i++) + DestroySprite(game->gfx.timerSprites[i]); DigitObjUtil_DeletePrinter(2); DigitObjUtil_DeletePrinter(1); DigitObjUtil_DeletePrinter(0); - for (r4 = 0; r4 < ARRAY_COUNT(r5->unk138.sparkleSprites); ++r4) - DestroySprite(r5->unk138.sparkleSprites[r4]); - for (r4 = 0; r4 < r5->playerCount; ++r4) - DestroySprite(r5->unk138.impactSprites[r4]); - if (r5->unk138.coreSprite->inUse) - DestroySprite(r5->unk138.coreSprite); + for (i = 0; i < ARRAY_COUNT(game->gfx.sparkleSprites); i++) + DestroySprite(game->gfx.sparkleSprites[i]); + for (i = 0; i < game->playerCount; i++) + DestroySprite(game->gfx.impactSprites[i]); + if (game->gfx.coreSprite->inUse) + DestroySprite(game->gfx.coreSprite); } -static void SpriteCB_BerryCrushImpact(struct Sprite *sprite) +static void SpriteCB_Impact(struct Sprite *sprite) { if (sprite->animEnded) { @@ -1872,93 +2066,116 @@ static void SpriteCB_BerryCrushImpact(struct Sprite *sprite) } } -static void sub_8022A4C(struct Sprite *sprite) +static void SpriteCB_Sparkle_End(struct Sprite *sprite) { - u8 r1 = 0; - SpriteCallback r5 = SpriteCallbackDummy; - - for (; r1 < ARRAY_COUNT(sprite->data); ++r1) - sprite->data[r1] = 0; + u8 i; + for (i = 0; i < ARRAY_COUNT(sprite->data); i++) + sprite->data[i] = 0; sprite->pos2.x = 0; sprite->pos2.y = 0; sprite->invisible = TRUE; sprite->animPaused = TRUE; - sprite->callback = r5; + sprite->callback = SpriteCallbackDummy; } -static void sub_8022A94(struct Sprite *sprite) -{ - s16 *r4 = sprite->data; +#define sX data[0] +#define sYSpeed data[1] +#define sYAccel data[2] +#define sXSpeed data[3] +#define sSinIdx data[4] +#define sSinSpeed data[5] +#define sAmplitude data[6] +// The last element (data[7]) is a bitfield. +// The first 15 bits are the y coord to stop at. +// The last bit is a flag for whether or not to move on the x too +#define sBitfield data[7] +#define MASK_TARGET_Y 0x7FFF +#define F_MOVE_HORIZ 0x8000 - r4[1] += r4[2]; - sprite->pos2.y += r4[1] >> 8; - if (r4[7] & 0x8000) +static void SpriteCB_Sparkle(struct Sprite *sprite) +{ + s16 *data = sprite->data; + + sYSpeed += sYAccel; + sprite->pos2.y += sYSpeed >> 8; + if (sBitfield & F_MOVE_HORIZ) { - sprite->data[0] += r4[3]; - r4[4] += r4[5]; - sprite->pos2.x = Sin(r4[4] >> 7, r4[6]); - if (r4[7] & 0x8000 && r4[4] >> 7 > 126) + sprite->sX += sXSpeed; + sSinIdx += sSinSpeed; + sprite->pos2.x = Sin(sSinIdx >> 7, sAmplitude); + if (sBitfield & F_MOVE_HORIZ && sSinIdx >> 7 > 126) { sprite->pos2.x = 0; - r4[7] &= 0x7FFF; + sBitfield &= MASK_TARGET_Y; } } - sprite->pos1.x = r4[0] >> 7; - if (sprite->pos1.y + sprite->pos2.y > (r4[7] & 0x7FFF)) - sprite->callback = sub_8022A4C; + sprite->pos1.x = sX >> 7; + if (sprite->pos1.y + sprite->pos2.y > (sBitfield & MASK_TARGET_Y)) + sprite->callback = SpriteCB_Sparkle_End; } -static void sub_8022B28(struct Sprite *sprite) +static void SpriteCB_Sparkle_Init(struct Sprite *sprite) { - s16 *r7 = sprite->data; - s16 r4, r5; - s32 r2; - u32 r8 = 0; + s16 *data = sprite->data; + s16 xMult, xDiv; + s32 var; + u32 zero = 0; - r2 = 640; - r7[1] = r2; - r7[2] = 32; - r7[7] = 168; - r4 = sprite->pos2.x * 128; - r5 = MathUtil_Div16Shift(7, (168 - sprite->pos1.y) << 7, (r2 + 32) >> 1); - sprite->data[0] = sprite->pos1.x << 7; - r7[3] = MathUtil_Div16Shift(7, r4, r5); - r2 = MathUtil_Mul16Shift(7, r5, 85); - r7[4] = r8; - r7[5] = MathUtil_Div16Shift(7, Q_8_8(63.5), r2); - r7[6] = sprite->pos2.x / 4; - r7[7] |= 0x8000; - sprite->pos2.y = r8; - sprite->pos2.x = r8; - sprite->callback = sub_8022A94; + var = 640; + sYSpeed = var; + sYAccel = 32; + sBitfield = 168; // Setting bits in MASK_TARGET_Y + xMult = sprite->pos2.x * 128; + xDiv = MathUtil_Div16Shift(7, (168 - sprite->pos1.y) << 7, (var + 32) >> 1); + sprite->sX = sprite->pos1.x << 7; + sXSpeed = MathUtil_Div16Shift(7, xMult, xDiv); + var = MathUtil_Mul16Shift(7, xDiv, 85); + sSinIdx = zero; + sSinSpeed = MathUtil_Div16Shift(7, Q_8_8(63.5), var); + sAmplitude = sprite->pos2.x / 4; + sBitfield |= F_MOVE_HORIZ; + sprite->pos2.y = zero; + sprite->pos2.x = zero; + sprite->callback = SpriteCB_Sparkle; sprite->animPaused = FALSE; sprite->invisible = FALSE; } -static void BerryCrush_RunOrScheduleCommand(u16 r5, u8 r4, u8 *r7) -{ - struct BerryCrushGame *r6 = GetBerryCrushGame(); +#undef sX +#undef sYSpeed +#undef sYAccel +#undef sXSpeed +#undef sSinIdx +#undef sSinSpeed +#undef sAmplitude +#undef sBitfield +#undef MASK_TARGET_Y +#undef F_MOVE_HORIZ - if (r5 >= ARRAY_COUNT(sBerryCrushCommands)) - r5 = 0; - switch (r4) +static void RunOrScheduleCommand(u16 cmdId, u8 mode, u8 *args) +{ + struct BerryCrushGame *game = GetBerryCrushGame(); + + if (cmdId >= ARRAY_COUNT(sBerryCrushCommands)) + cmdId = CMD_NONE; + switch (mode) { - case 0: - if (r5 != 0) - sBerryCrushCommands[r5](r6, r7); - if (r6->nextCmd >= ARRAY_COUNT(sBerryCrushCommands)) - r6->nextCmd = r4; - r6->cmdCallback = sBerryCrushCommands[r6->nextCmd]; + case RUN_CMD: + if (cmdId != CMD_NONE) + sBerryCrushCommands[cmdId](game, args); + if (game->nextCmd >= ARRAY_COUNT(sBerryCrushCommands)) + game->nextCmd = CMD_NONE; + game->cmdCallback = sBerryCrushCommands[game->nextCmd]; break; - case 1: - r6->cmdCallback = sBerryCrushCommands[r5]; + case SCHEDULE_CMD: + game->cmdCallback = sBerryCrushCommands[cmdId]; break; } } -static u32 BerryCrushCommand_BeginNormalPaletteFade(struct BerryCrushGame *game, u8 *params) +static u32 Cmd_BeginNormalPaletteFade(struct BerryCrushGame *game, u8 *args) { - // params points to packed values: + // args points to packed values: // bytes 0-3: selectedPals (bitfield) // byte 4: delay // byte 5: startY @@ -1969,126 +2186,128 @@ static u32 BerryCrushCommand_BeginNormalPaletteFade(struct BerryCrushGame *game, u16 color; u32 selectedPals[2]; - selectedPals[0] = (u32)params[0]; - selectedPals[1] = (u32)params[1]; + selectedPals[0] = (u32)args[0]; + selectedPals[1] = (u32)args[1]; selectedPals[1] <<= 8; selectedPals[0] |= selectedPals[1]; - selectedPals[1] = (u32)params[2]; + selectedPals[1] = (u32)args[2]; selectedPals[1] <<= 16; selectedPals[0] |= selectedPals[1]; - selectedPals[1] = (u32)params[3]; + selectedPals[1] = (u32)args[3]; selectedPals[1] <<= 24; selectedPals[0] |= selectedPals[1]; - params[0] = params[9]; + args[0] = args[9]; - color = params[8]; + color = args[8]; color <<= 8; - color |= params[7]; + color |= args[7]; gPaletteFade.bufferTransferDisabled = FALSE; - BeginNormalPaletteFade(selectedPals[0], params[4], params[5], params[6], color); + BeginNormalPaletteFade(selectedPals[0], args[4], args[5], args[6], color); UpdatePaletteFade(); - game->nextCmd = 2; + game->nextCmd = CMD_WAIT_FADE; return 0; } -static u32 BerryCrushCommand_WaitPaletteFade(struct BerryCrushGame *r4, u8 *r5) +static u32 Cmd_WaitPaletteFade(struct BerryCrushGame *game, u8 *args) { - switch (r4->cmdState) + switch (game->cmdState) { case 0: if (UpdatePaletteFade()) return 0; - if(r5[0] != 0) - ++r4->cmdState; + if(args[0] != 0) + game->cmdState++; else - r4->cmdState = 3; + game->cmdState = 3; return 0; case 1: Rfu_SetLinkStandbyCallback(); - ++r4->cmdState; + game->cmdState++; return 0; case 2: if (IsLinkTaskFinished()) { - ++r4->cmdState; + game->cmdState++; return 0; } return 0; case 3: - BerryCrush_RunOrScheduleCommand(r4->afterPalFadeCmd, 1, NULL); - r4->cmdState = 0; + RunOrScheduleCommand(game->afterPalFadeCmd, SCHEDULE_CMD, NULL); + game->cmdState = 0; return 0; default: - ++r4->cmdState; + game->cmdState++; return 0; } } -static u32 BerryCrushCommand_PrintMessage(struct BerryCrushGame *r7, u8 *r5) +static u32 Cmd_PrintMessage(struct BerryCrushGame *game, u8 *args) { - u16 r4 = r5[3]; + u16 keys = args[3]; + keys <<= 8; + keys |= args[2]; - r4 <<= 8; - r4 |= r5[2]; - switch (r7->cmdState) + switch (game->cmdState) { case 0: DrawDialogueFrame(0, 0); - if (r5[1] & 2) + if (args[1] & F_MSG_EXPAND) { - StringExpandPlaceholders(gStringVar4, sBerryCrushMessages[r5[0]]); - AddTextPrinterParameterized2(0, 1, gStringVar4, r7->textSpeed, 0, 2, 1, 3); + StringExpandPlaceholders(gStringVar4, sMessages[args[0]]); + AddTextPrinterParameterized2(0, 1, gStringVar4, game->textSpeed, 0, 2, 1, 3); } else { - AddTextPrinterParameterized2(0, 1, sBerryCrushMessages[r5[0]], r7->textSpeed, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, 1, sMessages[args[0]], game->textSpeed, 0, 2, 1, 3); } CopyWindowToVram(0, 3); break; case 1: if (!IsTextPrinterActive(0)) { - if (r4 == 0) - ++r7->cmdState; + // If no wait keys are given, skip + // waiting state below + if (keys == 0) + game->cmdState++; break; } return 0; case 2: - if (!(r4 & gMain.newKeys)) + if (!JOY_NEW(keys)) return 0; break; case 3: - if (r5[1] & 1) + if (args[1] & F_MSG_CLEAR) ClearDialogWindowAndFrame(0, 1); - BerryCrush_RunOrScheduleCommand(r7->nextCmd, 1, NULL); - r7->cmdState = r5[4]; + RunOrScheduleCommand(game->nextCmd, SCHEDULE_CMD, NULL); + game->cmdState = args[4]; return 0; } - ++r7->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_InitGfx(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_ShowGameDisplay(struct BerryCrushGame *game, u8 *args) { - if (InitBerryCrushDisplay() != 0) - BerryCrush_RunOrScheduleCommand(r4->nextCmd, 0, r4->commandParams); + if (ShowGameDisplay()) + RunOrScheduleCommand(game->nextCmd, RUN_CMD, game->commandArgs); return 0; } -static u32 BerryCrushCommand_TeardownGfx(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_HideGameDisplay(struct BerryCrushGame *game, u8 *args) { - if (BerryCrush_TeardownBgs() != 0) - BerryCrush_RunOrScheduleCommand(r4->nextCmd, 0, r4->commandParams); + if (HideGameDisplay()) + RunOrScheduleCommand(game->nextCmd, RUN_CMD, game->commandArgs); return 0; } -static u32 BerryCrushCommand_SignalReadyToBegin(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_SignalReadyToBegin(struct BerryCrushGame *game, u8 *args) { - switch (r4->cmdState) + switch (game->cmdState) { case 0: Rfu_SetLinkStandbyCallback(); @@ -2097,55 +2316,55 @@ static u32 BerryCrushCommand_SignalReadyToBegin(struct BerryCrushGame *r4, __att if (IsLinkTaskFinished()) { PlayNewMapMusic(MUS_RG_GAME_CORNER); - BerryCrush_RunOrScheduleCommand(7, 1, NULL); - r4->gameState = 3; - r4->cmdState = 0; + RunOrScheduleCommand(CMD_ASK_PICK_BERRY, SCHEDULE_CMD, NULL); + game->gameState = STATE_PICK_BERRY; + game->cmdState = 0; } return 0; } - ++r4->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_AskPickBerry(struct BerryCrushGame *r4, u8 *r5) +static u32 Cmd_AskPickBerry(struct BerryCrushGame *game, u8 *args) { - switch (r4->cmdState) + switch (game->cmdState) { default: - ++r4->cmdState; + game->cmdState++; break; case 0: - sub_8024578(r4); - BerryCrush_SetShowMessageParams(r5, 0, 1, 0, 1); - r4->nextCmd = 7; - BerryCrush_RunOrScheduleCommand(3, 1, NULL); + ResetGame(game); + SetPrintMessageArgs(args, MSG_PICK_BERRY, F_MSG_CLEAR, 0, 1); + game->nextCmd = CMD_ASK_PICK_BERRY; + RunOrScheduleCommand(CMD_PRINT_MSG, SCHEDULE_CMD, NULL); break; case 1: - r4->nextCmd = 8; - BerryCrush_RunOrScheduleCommand(5, 1, NULL); - r4->cmdState = 2; + game->nextCmd = CMD_PICK_BERRY; + RunOrScheduleCommand(CMD_HIDE_GAME, SCHEDULE_CMD, NULL); + game->cmdState = 2; break; } return 0; } -static u32 BerryCrushCommand_GoToBerryPouch(struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1) +static u32 Cmd_GoToBerryPouch(struct BerryCrushGame *game, u8 *args) { - r0->cmdCallback = NULL; - SetMainCallback2(BerryCrush_SetupMainTask); + game->cmdCallback = NULL; + SetMainCallback2(ChooseBerry); return 0; } -static u32 BerryCrushCommand_WaitForOthersToPickBerries(struct BerryCrushGame *r5, u8 *r2) +static u32 Cmd_WaitForOthersToPickBerries(struct BerryCrushGame *game, u8 *args) { - u8 r3; + u8 i; - switch (r5->cmdState) + switch (game->cmdState) { case 0: - BerryCrush_SetShowMessageParams(r2, 1, 0, 0, 1); - r5->nextCmd = 9; - BerryCrush_RunOrScheduleCommand(3, 1, NULL); + SetPrintMessageArgs(args, MSG_WAIT_PICK, 0, 0, 1); + game->nextCmd = CMD_WAIT_BERRIES; + RunOrScheduleCommand(CMD_PRINT_MSG, SCHEDULE_CMD, NULL); return 0; case 1: Rfu_SetLinkStandbyCallback(); @@ -2153,126 +2372,131 @@ static u32 BerryCrushCommand_WaitForOthersToPickBerries(struct BerryCrushGame *r case 2: if (!IsLinkTaskFinished()) return 0; - memset(r5->sendCmd, 0, sizeof(r5->sendCmd)); - r5->sendCmd[0] = r5->unk98[r5->localId].unkC; - SendBlock(0, r5->sendCmd, 2); + + // Send player's chosen berry to partners + memset(game->sendCmd, 0, sizeof(game->sendCmd)); + game->sendCmd[0] = game->players[game->localId].berryId; + SendBlock(0, game->sendCmd, 2); break; case 3: if (!IsLinkTaskFinished()) return 0; - r5->unk10 = 0; + game->cmdTimer = 0; break; case 4: - if (GetBlockReceivedStatus() != sReceivedPlayerBitmasks[r5->playerCount - 2]) + // Wait for partners responses + if (GetBlockReceivedStatus() != sReceivedPlayerBitmasks[game->playerCount - 2]) return 0; - for (r3 = 0; r3 < r5->playerCount; ++r3) + + // Read partners chosen berries + for (i = 0; i < game->playerCount; i++) { - r5->unk98[r3].unkC = gBlockRecvBuffer[r3][0]; - if (r5->unk98[r3].unkC > 0xB0) - r5->unk98[r3].unkC = 0; - r5->unk18 += gUnknown_0858AB24[r5->unk98[r3].unkC].unk0; - r5->powder += gUnknown_0858AB24[r5->unk98[r3].unkC].unk1; + game->players[i].berryId = gBlockRecvBuffer[i][0]; + if (game->players[i].berryId > LAST_BERRY_INDEX + 1) + game->players[i].berryId = 0; + game->targetAPresses += gBerryCrush_BerryData[game->players[i].berryId].difficulty; + game->powder += gBerryCrush_BerryData[game->players[i].berryId].powder; } - r5->unk10 = 0; + game->cmdTimer = 0; ResetBlockReceivedFlags(); - r5->unk20 = MathUtil_Div32(Q_24_8(r5->unk18), Q_24_8(32)); + game->targetDepth = MathUtil_Div32(Q_24_8(game->targetAPresses), Q_24_8(32)); break; case 5: ClearDialogWindowAndFrame(0, 1); - BerryCrush_RunOrScheduleCommand(10, 1, NULL); - r5->gameState = 4; - r5->cmdState = 0; + RunOrScheduleCommand(CMD_DROP_BERRIES, SCHEDULE_CMD, NULL); + game->gameState = STATE_DROP_BERRIES; + game->cmdState = 0; return 0; } - ++r5->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_DropBerriesIntoCrusher(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_DropBerriesIntoCrusher(struct BerryCrushGame *game, u8 *args) { - switch (r4->cmdState) + switch (game->cmdState) { case 0: - BerryCrush_CreateBerrySprites(r4, &r4->unk138); + CreateBerrySprites(game, &game->gfx); Rfu_SetLinkStandbyCallback(); break; case 1: if (!IsLinkTaskFinished()) return 0; - r4->unk138.animBerryIdx = 0; - r4->unk138.unk1 = 0; - r4->unk138.unk2 = 0; - r4->unk138.unk3 = 0; + game->gfx.counter = 0; + game->gfx.vibrationIdx = 0; + game->gfx.numVibrations = 0; + game->gfx.vibrating = FALSE; break; case 2: - r4->unk138.berrySprites[r4->unk138.animBerryIdx]->callback = SpriteCB_DropBerryIntoCrusher; - r4->unk138.berrySprites[r4->unk138.animBerryIdx]->affineAnimPaused = FALSE; + game->gfx.berrySprites[game->gfx.counter]->callback = SpriteCB_DropBerryIntoCrusher; + game->gfx.berrySprites[game->gfx.counter]->affineAnimPaused = FALSE; PlaySE(SE_BALL_THROW); break; case 3: - if (r4->unk138.berrySprites[r4->unk138.animBerryIdx]->callback == SpriteCB_DropBerryIntoCrusher) + if (game->gfx.berrySprites[game->gfx.counter]->callback == SpriteCB_DropBerryIntoCrusher) return 0; - r4->unk138.berrySprites[r4->unk138.animBerryIdx] = NULL; - ++r4->unk138.animBerryIdx; + game->gfx.berrySprites[game->gfx.counter] = NULL; + game->gfx.counter++; Rfu_SetLinkStandbyCallback(); break; case 4: if (!IsLinkTaskFinished()) return 0; - if (r4->unk138.animBerryIdx < r4->playerCount) + if (game->gfx.counter < game->playerCount) { - r4->cmdState = 2; + game->cmdState = 2; return 0; } - r4->unk138.animBerryIdx = 0; + game->gfx.counter = 0; break; case 5: - BerryCrushFreeBerrySpriteGfx(r4, &r4->unk138); + BerryCrushFreeBerrySpriteGfx(game, &game->gfx); Rfu_SetLinkStandbyCallback(); break; case 6: if (!IsLinkTaskFinished()) return 0; PlaySE(SE_FALL); - BerryCrush_RunOrScheduleCommand(11, 1, NULL); - r4->gameState = 5; - r4->cmdState = 0; + RunOrScheduleCommand(CMD_DROP_LID, SCHEDULE_CMD, NULL); + game->gameState = STATE_DROP_LID; + game->cmdState = 0; return 0; } - ++r4->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_DropLid(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_DropLid(struct BerryCrushGame *game, u8 *args) { - switch (r4->cmdState) + switch (game->cmdState) { case 0: - r4->depth += 4; - if (r4->depth < 0) + game->depth += 4; + if (game->depth < 0) return 0; - r4->depth = 0; - r4->unk138.unk1 = 4; - r4->unk138.animBerryIdx = 0; - r4->unk138.unk2 = gUnknown_082F326C[r4->unk138.unk1][0]; + game->depth = 0; + game->gfx.vibrationIdx = 4; + game->gfx.counter = 0; + game->gfx.numVibrations = sIntroOutroVibrationData[game->gfx.vibrationIdx][0]; PlaySE(SE_M_STRENGTH); break; case 1: - r4->vibration = gUnknown_082F326C[r4->unk138.unk1][r4->unk138.animBerryIdx]; - SetGpuReg(REG_OFFSET_BG0VOFS, -r4->vibration); - SetGpuReg(REG_OFFSET_BG2VOFS, -r4->vibration); - SetGpuReg(REG_OFFSET_BG3VOFS, -r4->vibration); - ++r4->unk138.animBerryIdx; - if (r4->unk138.animBerryIdx < r4->unk138.unk2) + game->vibration = sIntroOutroVibrationData[game->gfx.vibrationIdx][game->gfx.counter]; + SetGpuReg(REG_OFFSET_BG0VOFS, -game->vibration); + SetGpuReg(REG_OFFSET_BG2VOFS, -game->vibration); + SetGpuReg(REG_OFFSET_BG3VOFS, -game->vibration); + game->gfx.counter++; + if (game->gfx.counter < game->gfx.numVibrations) return 0; - if (r4->unk138.unk1 == 0) + if (game->gfx.vibrationIdx == 0) break; - --r4->unk138.unk1; - r4->unk138.unk2 = gUnknown_082F326C[r4->unk138.unk1][0]; - r4->unk138.animBerryIdx = 0; + game->gfx.vibrationIdx--; + game->gfx.numVibrations = sIntroOutroVibrationData[game->gfx.vibrationIdx][0]; + game->gfx.counter = 0; return 0; case 2: - r4->vibration = 0; + game->vibration = 0; SetGpuReg(REG_OFFSET_BG0VOFS, 0); SetGpuReg(REG_OFFSET_BG2VOFS, 0); SetGpuReg(REG_OFFSET_BG3VOFS, 0); @@ -2281,18 +2505,18 @@ static u32 BerryCrushCommand_DropLid(struct BerryCrushGame *r4, __attribute__(( case 3: if (!IsLinkTaskFinished()) return 0; - BerryCrush_RunOrScheduleCommand(12, 1, NULL); - r4->gameState = 6; - r4->cmdState = 0; + RunOrScheduleCommand(CMD_COUNTDOWN, SCHEDULE_CMD, NULL); + game->gameState = STATE_COUNTDOWN; + game->cmdState = 0; return 0; } - ++r4->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_Countdown(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_Countdown(struct BerryCrushGame *game, u8 *args) { - switch (r4-> cmdState) + switch (game->cmdState) { case 1: if (!IsLinkTaskFinished()) @@ -2309,405 +2533,442 @@ static u32 BerryCrushCommand_Countdown(struct BerryCrushGame *r4, __attribute__ case 3: if (!IsLinkTaskFinished()) return 0; - r4->unk138.animBerryIdx = 0; - r4->unk138.unk1 = 0; - r4->unk138.unk2 = 0; - r4->unk138.unk3 = 0; - r4->unk10 = 0; - if (r4->localId == 0) - BerryCrush_RunOrScheduleCommand(13, 1, NULL); + game->gfx.counter = 0; + game->gfx.vibrationIdx = 0; + game->gfx.numVibrations = 0; + game->gfx.vibrating = FALSE; + game->cmdTimer = 0; + if (game->localId == 0) + RunOrScheduleCommand(CMD_PLAY_GAME_LEADER, SCHEDULE_CMD, NULL); else - BerryCrush_RunOrScheduleCommand(14, 1, NULL); - r4->gameState = 7; - r4->cmdState = 0; + RunOrScheduleCommand(CMD_PLAY_GAME_MEMBER, SCHEDULE_CMD, NULL); + game->gameState = STATE_PLAYING; + game->cmdState = 0; return 0; } - ++r4->cmdState; + game->cmdState++; return 0; } -void BerryCrush_ProcessGamePartnerInput(struct BerryCrushGame *r4) +// Receive and process data from all players +// Only used by the link leader +static void HandlePartnerInput(struct BerryCrushGame *game) { - u8 r8 = 0; - u8 r7 = 0; - u16 r3; - s32 r2_ = 0; - struct BerryCrushGame_4E *r2; + u8 numPlayersPressed = 0; + u8 i = 0; + u16 timeDiff; + s32 temp = 0; + struct BerryCrushGame_LinkState *linkState; - for (r7 = 0; r7 < r4->playerCount; r7++) + for (i = 0; i < game->playerCount; i++) { - r2 = (struct BerryCrushGame_4E *)gRecvCmds[r7]; - if ((r2->unk0 & 0xFF00) != RFUCMD_SEND_PACKET) + linkState = (struct BerryCrushGame_LinkState *)gRecvCmds[i]; + + // Skip player if we have not received a packet from them + if ((linkState->rfuCmd & 0xFF00) != RFUCMD_SEND_PACKET) continue; - if (r2->unk2 != 2) + if (linkState->sendFlag != SEND_GAME_STATE) continue; - if (r2->unk4_2) + if (linkState->pushedAButton) { - r4->localState.unk02_3 |= gUnknown_082F325C[r7]; - r4->unk98[r7].unk1C = 1; - ++r4->unk98[r7].unk16; - ++r8; - r3 = r4->timer - r4->unk98[r7].unkE; - if (r3 >= r4->unk98[r7].unk12 - 1 && r3 <= r4->unk98[r7].unk12 + 1) + game->localState.playerPressedAFlags |= sBitTable[i]; + game->players[i].inputState = INPUT_STATE_HIT; + game->players[i].numAPresses++; + numPlayersPressed++; + timeDiff = game->timer - game->players[i].inputTime; + + // If the interval between inputs is regular, the input is considered "neat" + // This counts toward the player's neatness score + if (timeDiff >= game->players[i].timeSincePrevInput - 1 + && timeDiff <= game->players[i].timeSincePrevInput + 1) { - ++r4->unk98[r7].unk10; - r4->unk98[r7].unk12 = r3; - if (r4->unk98[r7].unk10 > r4->unk98[r7].unk14) - r4->unk98[r7].unk14 = r4->unk98[r7].unk10; + // On neat input streak + game->players[i].neatInputStreak++; + game->players[i].timeSincePrevInput = timeDiff; + if (game->players[i].neatInputStreak > game->players[i].maxNeatInputStreak) + game->players[i].maxNeatInputStreak = game->players[i].neatInputStreak; } else { - r4->unk98[r7].unk10 = 0; - r4->unk98[r7].unk12 = r3; + // End neat input streak + game->players[i].neatInputStreak = 0; + game->players[i].timeSincePrevInput = timeDiff; } - r4->unk98[r7].unkE = r4->timer; - ++r4->unk98[r7].unk1B; - if (r4->unk98[r7].unk1B > 2) - r4->unk98[r7].unk1B = 0; + + game->players[i].inputTime = game->timer; + game->players[i].inputFlags++; + if (game->players[i].inputFlags > F_INPUT_HIT_B) + game->players[i].inputFlags = 0; } else { - r4->unk98[r7].unk1C = 0; + game->players[i].inputState = INPUT_STATE_NONE; } } - if (r8 > 1) + if (numPlayersPressed > 1) { - for (r7 = 0; r7 < r4->playerCount; ++r7) + // For each player that pressed A, flag their input as synchronous + // This is used to change their impact sprite to a big impact + for (i = 0; i < game->playerCount; i++) { - if (!r4->unk98[r7].unk1C) + if (game->players[i].inputState == INPUT_STATE_NONE) continue; - r4->unk98[r7].unk1C |= 2; - ++r4->unk98[r7].unk18; + game->players[i].inputState |= INPUT_STATE_HIT_SYNC; + game->players[i].numSyncedAPresses++; } } - if (r8 == 0) + if (numPlayersPressed == 0) return; - r4->unk2E += r8; - r8 += gUnknown_082F3264[r8 - 1]; - r4->unk34 += r8; - r4->unk1A += r8; - if (r4->unk18 - r4->unk1A > 0) + game->bigSparkleCounter += numPlayersPressed; + numPlayersPressed += sSyncPressBonus[numPlayersPressed - 1]; + game->sparkleCounter += numPlayersPressed; + game->totalAPresses += numPlayersPressed; + if (game->targetAPresses - game->totalAPresses > 0) { - r2_ = (s32)r4->unk1A; - r2_ <<= 8; - r2_ = MathUtil_Div32(r2_, r4->unk20); - r2_ >>= 8; - r4->unk24 = (u8)r2_; + temp = (s32)game->totalAPresses; + temp = Q_24_8(temp); + temp = MathUtil_Div32(temp, game->targetDepth); + temp = Q_24_8_TO_INT(temp); + game->newDepth = (u8)temp; return; } - r4->unk24 = 32; - r4->localState.unk02_0 = 1; + // Target number of A presses has been reached, game is complete + game->newDepth = 32; + game->localState.endGame = TRUE; } -void BerryCrush_BuildLocalState(struct BerryCrushGame *r3) +// Updates the crusher, input flags, and timer to send to group members +// Only used by the link leader +static void UpdateLeaderGameState(struct BerryCrushGame *game) { - u8 r6 = 0; - u16 r1 = 0; - u16 r2 = 0; - u8 r4 = 0; + u8 numPlayersPressed = 0; + u16 flags = 0; + u16 temp = 0; + u8 i = 0; - for (r4 = 0; r4 < r3->playerCount; ++r4) + for (i = 0; i < game->playerCount; i++) { - if (r3->unk98[r4].unk1C != 0) + if (game->players[i].inputState != INPUT_STATE_NONE) { - ++r6; - r1 = r3->unk98[r4].unk1B + 1; - if (r3->unk98[r4].unk1C & 2) - r1 |= 4; - r1 <<= 3 * r4; - r3->localState.unk08 |= r1; + numPlayersPressed++; + flags = game->players[i].inputFlags + F_INPUT_HIT_A; + if (game->players[i].inputState & INPUT_STATE_HIT_SYNC) + flags |= F_INPUT_HIT_SYNC; + flags <<= INPUT_FLAGS_PER_PLAYER * i; + game->localState.inputFlags |= flags; } } - r2 = (u16)r3->unk24; - r3->localState.unk04 = r2; - if (r6 == 0) + temp = (u16)game->newDepth; + game->localState.depth = temp; + if (numPlayersPressed == 0) { - if (r3->unk138.unk3 != 0) - ++r3->unk138.animBerryIdx; + if (game->gfx.vibrating) + game->gfx.counter++; } - else if (r3->unk138.unk3 != 0) + else if (game->gfx.vibrating) { - if (r6 != r3->unk138.unk1) + if (numPlayersPressed != game->gfx.vibrationIdx) { - r3->unk138.unk1 = r6 - 1; - r3->unk138.unk2 = gUnknown_082F3290[r6 - 1][0]; + game->gfx.vibrationIdx = numPlayersPressed - 1; + game->gfx.numVibrations = sVibrationData[numPlayersPressed - 1][0]; } else { - ++r3->unk138.animBerryIdx; + game->gfx.counter++; } } else { - r3->unk138.animBerryIdx = 0; - r3->unk138.unk1 = r6 - 1; - r3->unk138.unk2 = gUnknown_082F3290[r6 - 1][0]; - r3->unk138.unk3 = 1; + game->gfx.counter = 0; + game->gfx.vibrationIdx = numPlayersPressed - 1; + game->gfx.numVibrations = sVibrationData[numPlayersPressed - 1][0]; + game->gfx.vibrating = TRUE; } - if (r3->unk138.unk3 != 0) + if (game->gfx.vibrating) { - if (r3->unk138.animBerryIdx >= r3->unk138.unk2) + if (game->gfx.counter >= game->gfx.numVibrations) { - r3->unk138.animBerryIdx = 0; - r3->unk138.unk1 = 0; - r3->unk138.unk2 = 0; - r3->unk138.unk3 = 0; - r1 = 0; + game->gfx.counter = 0; + game->gfx.vibrationIdx = 0; + game->gfx.numVibrations = 0; + game->gfx.vibrating = FALSE; + temp = 0; } else { - r1 = gUnknown_082F3290[r3->unk138.unk1][r3->unk138.animBerryIdx + 1]; + temp = sVibrationData[game->gfx.vibrationIdx][game->gfx.counter + 1]; } - r3->localState.unk03 = (u8)r1; + game->localState.vibration = (u8)temp; } else { - r3->localState.unk03 = 0; + game->localState.vibration = 0; } - r3->localState.unk06 = r3->unk26; + game->localState.timer = game->leaderTimer; } -void BerryCrush_HandlePlayerInput(struct BerryCrushGame *r5) +// Checks for input and sends data to group members +static void HandlePlayerInput(struct BerryCrushGame *game) { if (JOY_NEW(A_BUTTON)) - r5->localState.pushedAButton = 1; + game->localState.pushedAButton = TRUE; + if (JOY_HELD(A_BUTTON)) { - if (r5->unk98[r5->localId].unk1A < r5->timer) - ++r5->unk98[r5->localId].unk1A; + if (game->players[game->localId].timePressingA < game->timer) + game->players[game->localId].timePressingA++; } - if (r5->localId != 0 && r5->localState.pushedAButton == 0) + + // Only send data to other players if you are the leader or you pressed A + if (game->localId != 0 && !game->localState.pushedAButton) return; - r5->localState.unk00 = 2; - if (r5->timer % 30 == 0) + game->localState.sendFlag = SEND_GAME_STATE; + + // Every 30 frames, check whether the sparkles produced should be big, + // depending on how many A presses there were in that time + if (game->timer % 30 == 0) { - if (r5->unk2E > gUnknown_082F4444[r5->playerCount - 2]) + if (game->bigSparkleCounter > sBigSparkleThresholds[game->playerCount - 2]) { - ++r5->unk30; - r5->unk25_4 = 1; + game->numBigSparkles++; + game->bigSparkle = TRUE; } else { - r5->unk25_4 = 0; + game->bigSparkle = FALSE; } - r5->unk2E = 0; - ++r5->unk32; + game->bigSparkleCounter = 0; + game->numBigSparkleChecks++; } - if (r5->timer % 15 == 0) + + // Every 15 frames, update the amount of sparkles that should be produced, + // depending on how many A presses there were in that time (including the bonus) + if (game->timer % 15 == 0) { - if (r5->unk34 < gUnknown_082F4434[r5->playerCount - 2][0]) - r5->unk25_5 = 0; - else if (r5->unk34 < gUnknown_082F4434[r5->playerCount - 2][1]) - r5->unk25_5 = 1; - else if (r5->unk34 < gUnknown_082F4434[r5->playerCount - 2][2]) - r5->unk34 = 2; // typo since r5->unk34 will be reset? - else if (r5->unk34 < gUnknown_082F4434[r5->playerCount - 2][3]) - r5->unk34 = 3; // typo since r5->unk34 will be reset? + // BUG: The wrong field is used twice below + // As a result, only a sparkleAmount of 0, 1, or 4 is attainable + #ifdef BUGFIX + #define field sparkleAmount + #else + #define field sparkleCounter + #endif + + if (game->sparkleCounter < sSparkleThresholds[game->playerCount - 2][0]) + game->sparkleAmount = 0; + else if (game->sparkleCounter < sSparkleThresholds[game->playerCount - 2][1]) + game->sparkleAmount = 1; + else if (game->sparkleCounter < sSparkleThresholds[game->playerCount - 2][2]) + game->field = 2; + else if (game->sparkleCounter < sSparkleThresholds[game->playerCount - 2][3]) + game->field = 3; else - r5->unk25_5 = 4; - r5->unk34 = 0; + game->sparkleAmount = 4; + game->sparkleCounter = 0; + + #undef field } else { - ++r5->unk10; - if (r5->unk10 > 60) + game->cmdTimer++; + if (game->cmdTimer > 60) { - if (r5->unk10 > 70) + if (game->cmdTimer > 70) { ClearRecvCommands(); - r5->unk10 = 0; + game->cmdTimer = 0; } - else if (r5->localState.unk02_3 == 0) + else if (game->localState.playerPressedAFlags == 0) { ClearRecvCommands(); - r5->unk10 = 0; + game->cmdTimer = 0; } } } - if (r5->timer >= 36000) - r5->localState.unk02_0 = 1; - r5->localState.unk02_1 = r5->unk25_4; - r5->localState.unk0A = r5->unk25_5; - memcpy(r5->sendCmd, &r5->localState, sizeof(r5->sendCmd)); - Rfu_SendPacket(r5->sendCmd); + if (game->timer >= MAX_TIME) + game->localState.endGame = TRUE; + game->localState.bigSparkle = game->bigSparkle; + game->localState.sparkleAmount = game->sparkleAmount; + memcpy(game->sendCmd, &game->localState, sizeof(game->sendCmd)); + Rfu_SendPacket(game->sendCmd); } -void BerryCrush_UpdateGameState(struct BerryCrushGame *r5) +static void RecvLinkData(struct BerryCrushGame *game) { - u8 r4 = 0; - struct BerryCrushGame_4E *r4_ = NULL; + u8 i = 0; + struct BerryCrushGame_LinkState *linkState = NULL; + + for (i = 0; i < game->playerCount; i++) + game->players[i].inputState = INPUT_STATE_NONE; - for (r4 = 0; r4 < r5->playerCount; r4++) - r5->unk98[r4].unk1C = 0; if ((gRecvCmds[0][0] & 0xFF00) != RFUCMD_SEND_PACKET) { - r5->unk25_2 = 0; + game->playedSound = FALSE; return; } if (gRecvCmds[0][1] != 2) { - r5->unk25_2 = 0; + game->playedSound = FALSE; return; } - memcpy(r5->recvCmd, gRecvCmds[0], 14); - r4_ = (struct BerryCrushGame_4E *)&r5->recvCmd; - r5->depth = r4_->unk6; - r5->vibration = (s16)r4_->unk5; - r5->timer = r4_->unk8; - sub_80216E0(r5, &(r5->unk138)); - if (r4_->unk4_0) - { - r5->unk25_3 = 1; - } + memcpy(game->recvCmd, gRecvCmds[0], sizeof(game->recvCmd)); + linkState = (struct BerryCrushGame_LinkState *)&game->recvCmd; + game->depth = linkState->depth; + game->vibration = (s16)linkState->vibration; + game->timer = linkState->timer; + UpdateInputEffects(game, &(game->gfx)); + + if (linkState->endGame) + game->endGame = TRUE; } -static u32 BerryCrushCommand_PlayGame_Master(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_PlayGame_Leader(struct BerryCrushGame *game, u8 *args) { - memset(&r4->localState, 0, sizeof(r4->localState)); - memset(&r4->recvCmd, 0, sizeof(r4->recvCmd)); - BerryCrush_UpdateGameState(r4); - SetGpuReg(REG_OFFSET_BG0VOFS, -r4->vibration); - SetGpuReg(REG_OFFSET_BG2VOFS, -r4->vibration); - SetGpuReg(REG_OFFSET_BG3VOFS, -r4->vibration); - if (r4->unk25_3) + memset(&game->localState, 0, sizeof(game->localState)); + memset(&game->recvCmd, 0, sizeof(game->recvCmd)); + RecvLinkData(game); + SetGpuReg(REG_OFFSET_BG0VOFS, -game->vibration); + SetGpuReg(REG_OFFSET_BG2VOFS, -game->vibration); + SetGpuReg(REG_OFFSET_BG3VOFS, -game->vibration); + if (game->endGame) { - if (r4->timer >= 36000) + if (game->timer >= MAX_TIME) { - r4->timer = 36000; - BerryCrush_RunOrScheduleCommand(16, 1, NULL); + game->timer = MAX_TIME; + RunOrScheduleCommand(CMD_TIMES_UP, SCHEDULE_CMD, NULL); } else { - BerryCrush_RunOrScheduleCommand(15, 1, NULL); + RunOrScheduleCommand(CMD_FINISH_GAME, SCHEDULE_CMD, NULL); } - r4->unk10 = 0; - r4->cmdState = 0; + game->cmdTimer = 0; + game->cmdState = 0; return 0; } else { - ++r4->unk26; - BerryCrush_ProcessGamePartnerInput(r4); - BerryCrush_BuildLocalState(r4); - BerryCrush_HandlePlayerInput(r4); + game->leaderTimer++; + HandlePartnerInput(game); + UpdateLeaderGameState(game); + HandlePlayerInput(game); return 0; } } -static u32 BerryCrushCommand_PlayGame_Slave(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_PlayGame_Member(struct BerryCrushGame *game, u8 *args) { - memset(&r4->localState, 0, sizeof(r4->localState)); - memset(&r4->recvCmd, 0, sizeof(r4->recvCmd)); - BerryCrush_UpdateGameState(r4); - SetGpuReg(REG_OFFSET_BG0VOFS, -r4->vibration); - SetGpuReg(REG_OFFSET_BG2VOFS, -r4->vibration); - SetGpuReg(REG_OFFSET_BG3VOFS, -r4->vibration); - if (r4->unk25_3) + memset(&game->localState, 0, sizeof(game->localState)); + memset(&game->recvCmd, 0, sizeof(game->recvCmd)); + RecvLinkData(game); + SetGpuReg(REG_OFFSET_BG0VOFS, -game->vibration); + SetGpuReg(REG_OFFSET_BG2VOFS, -game->vibration); + SetGpuReg(REG_OFFSET_BG3VOFS, -game->vibration); + if (game->endGame) { - if (r4->timer >= 36000) + if (game->timer >= MAX_TIME) { - r4->timer = 36000; - BerryCrush_RunOrScheduleCommand(16, 1, NULL); + game->timer = MAX_TIME; + RunOrScheduleCommand(CMD_TIMES_UP, SCHEDULE_CMD, NULL); } else { - BerryCrush_RunOrScheduleCommand(15, 1, NULL); + RunOrScheduleCommand(CMD_FINISH_GAME, SCHEDULE_CMD, NULL); } - r4->unk10 = 0; - r4->cmdState = 0; + game->cmdTimer = 0; + game->cmdState = 0; return 0; } else { - BerryCrush_HandlePlayerInput(r4); + HandlePlayerInput(game); return 0; } } -static u32 BerryCrushCommand_FinishGame(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +// Game was 'won', crusher was pushed down fully before time was up +static u32 Cmd_FinishGame(struct BerryCrushGame *game, u8 *args) { - switch (r4->cmdState) + switch (game->cmdState) { case 0: - r4->gameState = 8; + game->gameState = STATE_FINISHED; PlaySE(SE_M_STRENGTH); BlendPalettes(PALETTES_ALL, 8, RGB(31, 31, 0)); - r4->unk138.animBerryIdx = 2; + game->gfx.counter = 2; break; case 1: - if (--r4->unk138.animBerryIdx != 255) + if (--game->gfx.counter != (u8)-1) return 0; BlendPalettes(PALETTES_ALL, 0, RGB(31, 31, 0)); - r4->unk138.unk1 = 4; - r4->unk138.animBerryIdx = 0; - r4->unk138.unk2 = gUnknown_082F326C[r4->unk138.unk1][0]; + game->gfx.vibrationIdx = 4; + game->gfx.counter = 0; + game->gfx.numVibrations = sIntroOutroVibrationData[game->gfx.vibrationIdx][0]; break; case 2: - r4->vibration = gUnknown_082F326C[r4->unk138.unk1][r4->unk138.animBerryIdx]; - SetGpuReg(REG_OFFSET_BG0VOFS, -r4->vibration); - SetGpuReg(REG_OFFSET_BG2VOFS, -r4->vibration); - SetGpuReg(REG_OFFSET_BG3VOFS, -r4->vibration); - if (++r4->unk138.animBerryIdx < r4->unk138.unk2) + game->vibration = sIntroOutroVibrationData[game->gfx.vibrationIdx][game->gfx.counter]; + SetGpuReg(REG_OFFSET_BG0VOFS, -game->vibration); + SetGpuReg(REG_OFFSET_BG2VOFS, -game->vibration); + SetGpuReg(REG_OFFSET_BG3VOFS, -game->vibration); + if (++game->gfx.counter < game->gfx.numVibrations) return 0; - if (r4->unk138.unk1 != 0) + if (game->gfx.vibrationIdx != 0) { - --r4->unk138.unk1; - r4->unk138.unk2 = gUnknown_082F326C[r4->unk138.unk1][0]; - r4->unk138.animBerryIdx = 0; + game->gfx.vibrationIdx--; + game->gfx.numVibrations = sIntroOutroVibrationData[game->gfx.vibrationIdx][0]; + game->gfx.counter = 0; return 0; } break; case 3: - r4->vibration = 0; + game->vibration = 0; SetGpuReg(REG_OFFSET_BG0VOFS, 0); SetGpuReg(REG_OFFSET_BG2VOFS, 0); SetGpuReg(REG_OFFSET_BG3VOFS, 0); break; case 4: - if (!sub_80218D4(r4, &r4->unk138)) + if (!AreEffectsFinished(game, &game->gfx)) return 0; Rfu_SetLinkStandbyCallback(); - r4->unk10 = 0; + game->cmdTimer = 0; break; case 5: if (!IsLinkTaskFinished()) return 0; - BerryCrush_RunOrScheduleCommand(17, 1, NULL); - r4->unk10 = 0; - r4->cmdState = 0; + RunOrScheduleCommand(CMD_CALC_RESULTS, SCHEDULE_CMD, NULL); + game->cmdTimer = 0; + game->cmdState = 0; return 0; } - ++r4->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_HandleTimeUp(struct BerryCrushGame *r5, u8 *r6) +static u32 Cmd_HandleTimeUp(struct BerryCrushGame *game, u8 *args) { - switch (r5->cmdState) + switch (game->cmdState) { case 0: - r5->gameState = 9; + game->gameState = STATE_TIMES_UP; PlaySE(SE_FAILURE); BlendPalettes(PALETTES_ALL, 8, RGB(31, 0, 0)); - r5->unk138.animBerryIdx = 4; + game->gfx.counter = 4; break; case 1: - if (--r5->unk138.animBerryIdx != 255) + if (--game->gfx.counter != (u8)-1) return 0; BlendPalettes(PALETTES_ALL, 0, RGB(31, 0, 0)); - r5->unk138.animBerryIdx = 0; + game->gfx.counter = 0; break; case 2: - if (!sub_80218D4(r5, &r5->unk138)) + if (!AreEffectsFinished(game, &game->gfx)) return 0; Rfu_SetLinkStandbyCallback(); - r5->unk10 = 0; + game->cmdTimer = 0; SetGpuReg(REG_OFFSET_BG0VOFS, 0); SetGpuReg(REG_OFFSET_BG2VOFS, 0); SetGpuReg(REG_OFFSET_BG3VOFS, 0); @@ -2715,235 +2976,264 @@ static u32 BerryCrushCommand_HandleTimeUp(struct BerryCrushGame *r5, u8 *r6) case 3: if (!IsLinkTaskFinished()) return 0; - ConvertIntToDecimalStringN(gStringVar1, r5->powder, STR_CONV_MODE_LEFT_ALIGN, 6); - BerryCrush_SetShowMessageParams(r6, 7, 1, 0, 0); - r5->nextCmd = 19; - BerryCrush_RunOrScheduleCommand(3, 1, NULL); - r5->unk10 = 0; - r5->cmdState = 0; + ConvertIntToDecimalStringN(gStringVar1, game->powder, STR_CONV_MODE_LEFT_ALIGN, 6); + SetPrintMessageArgs(args, MSG_TIMES_UP, F_MSG_CLEAR, 0, 0); + game->nextCmd = CMD_SAVE; + RunOrScheduleCommand(CMD_PRINT_MSG, SCHEDULE_CMD, NULL); + game->cmdTimer = 0; + game->cmdState = 0; return 0; } - ++r5->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_TabulateResults(struct BerryCrushGame *r7, __attribute__((unused)) u8 *r1) +static u32 Cmd_TabulateResults(struct BerryCrushGame *game, u8 *args) { - u8 r8, r4_, r3; - s32 r2; - s32 r4; - u16 r6; + u8 i, j, tempPlayerId; + s32 temp1, temp2; + u16 tempStat; - switch (r7->cmdState) + switch (game->cmdState) { case 0: - memset(r7->sendCmd, 0, 2 * sizeof(u16)); - if (r7->unk98[r7->localId].unk1A > r7->timer) - r7->unk98[r7->localId].unk1A = r7->timer; - r7->sendCmd[0] = r7->unk98[r7->localId].unk1A; - SendBlock(0, r7->sendCmd, 2); + memset(game->sendCmd, 0, 2 * sizeof(u16)); + if (game->players[game->localId].timePressingA > game->timer) + game->players[game->localId].timePressingA = game->timer; + game->sendCmd[0] = game->players[game->localId].timePressingA; + SendBlock(0, game->sendCmd, 2); break; case 1: if (!IsLinkTaskFinished()) return 0; - r7->unk10 = 0; + game->cmdTimer = 0; break; case 2: - if (GetBlockReceivedStatus() != sReceivedPlayerBitmasks[r7->playerCount - 2]) + if (GetBlockReceivedStatus() != sReceivedPlayerBitmasks[game->playerCount - 2]) return 0; - for (r8 = 0; r8 < r7->playerCount; ++r8) - r7->unk98[r8].unk1A = gBlockRecvBuffer[r8][0]; - r7->unk10 = 0; - r7->sendCmd[0] = 0; + for (i = 0; i < game->playerCount; i++) + game->players[i].timePressingA = gBlockRecvBuffer[i][0]; + + game->cmdTimer = 0; + game->sendCmd[0] = 0; ResetBlockReceivedFlags(); - if (r7->localId == 0) - r7->cmdState = 3; + + // If player is not leader, skip the steps + // where the results are calculated and sent. + // Group members just read the results sent + // to them by the leader. + if (game->localId == 0) + game->cmdState = 3; else - r7->cmdState = 6; + game->cmdState = 6; return 0; case 3: - memset(&r7->unk68, 0, sizeof(struct BerryCrushGame_68)); - r7->unk68.unk04 = r7->timer; - r7->unk68.unk06 = r7->unk18 / (r7->timer / 60); - r2 = MathUtil_Mul32(Q_24_8(r7->unk30), Q_24_8(50)); - r2 = MathUtil_Div32(r2, Q_24_8(r7->unk32)) + Q_24_8(50); - r2 = Q_24_8_TO_INT(r2); - r7->unk68.unk08 = r2 & 0x7F; - r2 = Q_24_8(r2); - r2 = MathUtil_Div32(r2, Q_24_8(100)); - r4 = Q_24_8(r7->powder * r7->playerCount); - r4 = MathUtil_Mul32(r4, r2); - r7->unk68.unk00 = r4 >> 8; - r7->unk68.unk20[0][7] = Random() % 3; - for (r8 = 0; r8 < r7->playerCount; ++r8) + memset(&game->results, 0, sizeof(game->results)); + game->results.time = game->timer; + game->results.targetPressesPerSec = game->targetAPresses / (game->timer / 60); + + // Calculate silkiness + // Silkiness is the percentage of times big sparkles were produced when possible, + // which itself depends on the number of A presses every 30 frames + temp1 = MathUtil_Mul32(Q_24_8(game->numBigSparkles), Q_24_8(50)); + temp1 = MathUtil_Div32(temp1, Q_24_8(game->numBigSparkleChecks)) + Q_24_8(50); + temp1 = Q_24_8_TO_INT(temp1); + game->results.silkiness = temp1 & 0x7F; + + // Calculate amount of powder + temp1 = Q_24_8(temp1); + temp1 = MathUtil_Div32(temp1, Q_24_8(100)); + temp2 = Q_24_8(game->powder * game->playerCount); + temp2 = MathUtil_Mul32(temp2, temp1); + game->results.powder = Q_24_8_TO_INT(temp2); + + // Choose random second results page + game->results.randomPageId = Random() % NUM_RANDOM_RESULTS_PAGES; + + for (i = 0; i < game->playerCount; i++) { - r7->unk68.unk20[0][r8] = r8; - r7->unk68.unk20[1][r8] = r8; - r7->unk68.stats[0][r8] = r7->unk98[r8].unk16; - r7->unk68.unk0A += r7->unk68.stats[0][r8]; - switch (r7->unk68.unk20[0][7]) + game->results.playerIdsRanked[RESULTS_PAGE_PRESSES][i] = i; + game->results.playerIdsRanked[RESULTS_PAGE_RANDOM][i] = i; + game->results.stats[RESULTS_PAGE_PRESSES][i] = game->players[i].numAPresses; + game->results.totalAPresses += game->results.stats[RESULTS_PAGE_PRESSES][i]; + + // Calculate value for random second results page + switch (game->results.randomPageId) { - case 0: - if (r7->unk98[r8].unk16 != 0) + case RESULTS_PAGE_NEATNESS: + if (game->players[i].numAPresses != 0) { - r2 = r7->unk98[r8].unk14; - r2 = Q_24_8(r2); - r2 = MathUtil_Mul32(r2, Q_24_8(100)); - r4 = r7->unk98[r8].unk16; - r4 = Q_24_8(r4); - r4 = MathUtil_Div32(r2, r4); + // Calculate percentage of inputs that were in largest "neat" streak + // "Neat" inputs are those done at a regular interval + temp1 = game->players[i].maxNeatInputStreak; + temp1 = Q_24_8(temp1); + temp1 = MathUtil_Mul32(temp1, Q_24_8(100)); + temp2 = game->players[i].numAPresses; + temp2 = Q_24_8(temp2); + temp2 = MathUtil_Div32(temp1, temp2); } else { - r4 = 0; + temp2 = 0; } break; - case 1: - if (r7->unk98[r8].unk16 != 0) + case RESULTS_PAGE_COOPERATIVE: + if (game->players[i].numAPresses != 0) { - r2 = r7->unk98[r8].unk18; - r2 = Q_24_8(r2); - r2 = MathUtil_Mul32(r2, Q_24_8(100)); - r4 = r7->unk98[r8].unk16; - r4 = Q_24_8(r4); - r4 = MathUtil_Div32(r2, r4); + // Calculate percentage of inputs that were + // done at the same time as another player + temp1 = game->players[i].numSyncedAPresses; + temp1 = Q_24_8(temp1); + temp1 = MathUtil_Mul32(temp1, Q_24_8(100)); + temp2 = game->players[i].numAPresses; + temp2 = Q_24_8(temp2); + temp2 = MathUtil_Div32(temp1, temp2); } else { - r4 = 0; + temp2 = 0; } break; - case 2: - if (r7->unk98[r8].unk16 == 0) + case RESULTS_PAGE_POWER: + if (game->players[i].numAPresses == 0) { - r4 = 0; + temp2 = 0; } - else if (r7->unk98[r8].unk1A >= r7->timer) + else if (game->players[i].timePressingA >= game->timer) { - r4 = 0x6400; + // Spent 100% of the time pressing A + temp2 = Q_24_8(100); } else { - r2 = r7->unk98[r8].unk1A; - r2 = Q_24_8(r2); - r2 = MathUtil_Mul32(r2, Q_24_8(100)); - r4 = r7->timer; - r4 = Q_24_8(r4); - r4 = MathUtil_Div32(r2, r4); + // Calculate percentage of time the + // player spent pressing A + temp1 = game->players[i].timePressingA; + temp1 = Q_24_8(temp1); + temp1 = MathUtil_Mul32(temp1, Q_24_8(100)); + temp2 = game->timer; + temp2 = Q_24_8(temp2); + temp2 = MathUtil_Div32(temp1, temp2); } break; } - r4 >>= 4; - r7->unk68.stats[1][r8] = r4; + temp2 >>= 4; + game->results.stats[RESULTS_PAGE_RANDOM][i] = temp2; } break; case 4: - for (r8 = 0; r8 < r7->playerCount - 1; ++r8) + for (i = 0; i < game->playerCount - 1; i++) { - for (r4_ = r7->playerCount - 1; r4_ > r8; --r4_) + for (j = game->playerCount - 1; j > i; j--) { - if (r7->unk68.stats[0][r4_ - 1] < r7->unk68.stats[0][r4_]) + // Calculate player rankings for "Number of Presses" by sorting arrays + if (game->results.stats[RESULTS_PAGE_PRESSES][j - 1] < game->results.stats[RESULTS_PAGE_PRESSES][j]) { - r6 = r7->unk68.stats[0][r4_]; - r7->unk68.stats[0][r4_] = r7->unk68.stats[0][r4_ - 1]; - r7->unk68.stats[0][r4_ - 1] = r6; - r3 = r7->unk68.unk20[0][r4_]; - r7->unk68.unk20[0][r4_] = r7->unk68.unk20[0][r4_ - 1]; - r7->unk68.unk20[0][r4_ - 1] = r3; + SWAP(game->results.stats[RESULTS_PAGE_PRESSES][j], + game->results.stats[RESULTS_PAGE_PRESSES][j - 1], + tempStat); + SWAP(game->results.playerIdsRanked[RESULTS_PAGE_PRESSES][j], + game->results.playerIdsRanked[RESULTS_PAGE_PRESSES][j - 1], + tempPlayerId); } - if (r7->unk68.stats[1][r4_ - 1] < r7->unk68.stats[1][r4_]) + // Calculate player rankings for random second results page by sorting arrays + if (game->results.stats[RESULTS_PAGE_RANDOM][j - 1] < game->results.stats[RESULTS_PAGE_RANDOM][j]) { - r6 = r7->unk68.stats[1][r4_]; - r7->unk68.stats[1][r4_] = r7->unk68.stats[1][r4_ - 1]; - r7->unk68.stats[1][r4_ - 1] = r6; - r3 = r7->unk68.unk20[1][r4_]; - r7->unk68.unk20[1][r4_] = r7->unk68.unk20[1][r4_ - 1]; - r7->unk68.unk20[1][r4_ - 1] = r3; + SWAP(game->results.stats[RESULTS_PAGE_RANDOM][j], + game->results.stats[RESULTS_PAGE_RANDOM][j - 1], + tempStat); + SWAP(game->results.playerIdsRanked[RESULTS_PAGE_RANDOM][j], + game->results.playerIdsRanked[RESULTS_PAGE_RANDOM][j - 1], + tempPlayerId); } } } - SendBlock(0,&r7->unk68, sizeof(struct BerryCrushGame_68)); + SendBlock(0, &game->results, sizeof(game->results)); break; case 5: if (!IsLinkTaskFinished()) return 0; - r7->unk10 = 0; + game->cmdTimer = 0; break; case 6: if (GetBlockReceivedStatus() != 1) return 0; - memset(&r7->unk68, 0, sizeof(struct BerryCrushGame_68)); - memcpy(&r7->unk68, gBlockRecvBuffer, sizeof(struct BerryCrushGame_68)); + + // Receive results calculated by leader + memset(&game->results, 0, sizeof(game->results)); + memcpy(&game->results, gBlockRecvBuffer, sizeof(game->results)); ResetBlockReceivedFlags(); - r7->unk10 = 0; + game->cmdTimer = 0; break; case 7: - BerryCrush_SaveResults(); - BerryCrush_RunOrScheduleCommand(18, 1, NULL); - r7->gameState = 11; - r7->cmdState = 0; - r7->unk24 = 0; + SaveResults(); + RunOrScheduleCommand(CMD_SHOW_RESULTS, SCHEDULE_CMD, NULL); + game->gameState = STATE_RESULTS_PRESSES; + game->cmdState = 0; + game->newDepth = 0; return 0; } - ++r7->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_ShowResults(struct BerryCrushGame *r5, u8 *r6) +static u32 Cmd_ShowResults(struct BerryCrushGame *game, u8 *args) { - switch (r5->cmdState) + switch (game->cmdState) { case 0: - if (!sub_8022070(r5, &r5->unk138)) + if (!OpenResultsWindow(game, &game->gfx)) return 0; break; case 1: CopyBgTilemapBufferToVram(0); - r5->unk138.animBerryIdx = 30; + game->gfx.counter = 30; break; case 2: - if (r5->unk138.animBerryIdx != 0) + if (game->gfx.counter != 0) { - --r5->unk138.animBerryIdx; + game->gfx.counter--; return 0; } if (!(JOY_NEW(A_BUTTON))) return 0; PlaySE(SE_SELECT); - sub_802222C(r5); + CloseResultsWindow(game); break; case 3: - if (r5->gameState <= 12) + // Progress through each page of the results + if (game->gameState < RESULTS_STATE_END) { - ++r5->gameState; - r5->cmdState = 0; + game->gameState++; + game->cmdState = 0; return 0; } break; case 4: - ConvertIntToDecimalStringN(gStringVar1, r5->powder, STR_CONV_MODE_LEFT_ALIGN, 6); + // Print message showing how much powder was created + ConvertIntToDecimalStringN(gStringVar1, game->powder, STR_CONV_MODE_LEFT_ALIGN, 6); ConvertIntToDecimalStringN(gStringVar2, GetBerryPowder(), STR_CONV_MODE_LEFT_ALIGN, 6); - BerryCrush_SetShowMessageParams(r6, 2, 3, 0, 0); - r5->nextCmd = 19; - BerryCrush_RunOrScheduleCommand(3, 1, NULL); - r5->cmdState = 0; + SetPrintMessageArgs(args, MSG_POWDER, F_MSG_CLEAR | F_MSG_EXPAND, 0, 0); + game->nextCmd = CMD_SAVE; + RunOrScheduleCommand(CMD_PRINT_MSG, SCHEDULE_CMD, NULL); + game->cmdState = 0; return 0; } - ++r5->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_SaveGame(struct BerryCrushGame *r5, u8 *r4) +static u32 Cmd_SaveGame(struct BerryCrushGame *game, u8 *args) { - switch (r5->cmdState) + switch (game->cmdState) { case 0: - if (r5->timer >= 36000) - BerryCrush_HideTimerSprites(&r5->unk138); - BerryCrush_SetShowMessageParams(r4, 8, 0, 0, 1); - r5->nextCmd = 19; - BerryCrush_RunOrScheduleCommand(3, 1, NULL); - r5->cmdState = 0; + if (game->timer >= MAX_TIME) + HideTimer(&game->gfx); + SetPrintMessageArgs(args, MSG_COMM_STANDBY, 0, 0, 1); + game->nextCmd = CMD_SAVE; + RunOrScheduleCommand(CMD_PRINT_MSG, SCHEDULE_CMD, NULL); + game->cmdState = 0; // State is progressed by CMD_PRINT_MSG return 0; case 1: Rfu_SetLinkStandbyCallback(); @@ -2961,63 +3251,67 @@ static u32 BerryCrushCommand_SaveGame(struct BerryCrushGame *r5, u8 *r4) return 0; break; case 4: - BerryCrush_RunOrScheduleCommand(20, 1, NULL); - r5->gameState = 15; - r5->cmdState = 0; + RunOrScheduleCommand(CMD_ASK_PLAY_AGAIN, SCHEDULE_CMD, NULL); + game->gameState = STATE_PLAY_AGAIN; + game->cmdState = 0; return 0; } - ++r5->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_AskPlayAgain(struct BerryCrushGame *r5, u8 *r6) +static u32 Cmd_AskPlayAgain(struct BerryCrushGame *game, u8 *args) { - s8 r4 = 0; + s8 input = 0; - switch (r5->cmdState) + switch (game->cmdState) { case 0: - BerryCrush_SetShowMessageParams(r6, 4, 0, 0, 1); - r5->nextCmd = 20; - BerryCrush_RunOrScheduleCommand(3, 1, NULL); - r5->cmdState = 0; // dunno what it's doing because it's already in case 0 + SetPrintMessageArgs(args, MSG_PLAY_AGAIN, 0, 0, 1); + game->nextCmd = CMD_ASK_PLAY_AGAIN; + RunOrScheduleCommand(CMD_PRINT_MSG, SCHEDULE_CMD, NULL); + game->cmdState = 0; // State is progressed by CMD_PRINT_MSG return 0; case 1: DisplayYesNoMenuDefaultYes(); break; case 2: - r4 = Menu_ProcessInputNoWrapClearOnChoose(); - if (r4 != -2) + input = Menu_ProcessInputNoWrapClearOnChoose(); + if (input != -2) { - memset(r5->sendCmd, 0, sizeof(r5->sendCmd)); - if (r4 == 0) + memset(game->sendCmd, 0, sizeof(game->sendCmd)); + if (input == 0) { + // Selected Yes if (HasAtLeastOneBerry()) - r5->unk14 = 0; + game->playAgainState = PLAY_AGAIN_YES; else - r5->unk14 = 3; + game->playAgainState = PLAY_AGAIN_NO_BERRIES; } else { - r5->unk14 = 1; + // Selected No + game->playAgainState = PLAY_AGAIN_NO; } + + // Close Yes/No and start communication ClearDialogWindowAndFrame(0, 1); - BerryCrush_SetShowMessageParams(r6, 8, 0, 0, 0); - r5->nextCmd = 21; - BerryCrush_RunOrScheduleCommand(3, 1, NULL); - r5->cmdState = 0; + SetPrintMessageArgs(args, MSG_COMM_STANDBY, 0, 0, 0); + game->nextCmd = CMD_COMM_PLAY_AGAIN; + RunOrScheduleCommand(CMD_PRINT_MSG, SCHEDULE_CMD, NULL); + game->cmdState = 0; } return 0; } - ++r5->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_CommunicatePlayAgainResponses(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1) +static u32 Cmd_CommunicatePlayAgainResponses(struct BerryCrushGame *game, u8 *args) { - u8 r5 = 0; + u8 i = 0; - switch (r4->cmdState) + switch (game->cmdState) { case 0: Rfu_SetLinkStandbyCallback(); @@ -3025,41 +3319,47 @@ static u32 BerryCrushCommand_CommunicatePlayAgainResponses(struct BerryCrushGame case 1: if (!IsLinkTaskFinished()) return 0; - r4->sendCmd[0] = r4->unk14; - r4->recvCmd[0] = 0; - SendBlock(0, r4->sendCmd, sizeof(u16)); + + // Send player's Yes/No response to partners + game->sendCmd[0] = game->playAgainState; + game->recvCmd[0] = 0; + SendBlock(0, game->sendCmd, sizeof(u16)); break; case 2: if (!IsLinkTaskFinished()) return 0; - r4->unk10 = 0; + game->cmdTimer = 0; break; case 3: - if (GetBlockReceivedStatus() != sReceivedPlayerBitmasks[r4->playerCount - 2]) + // Wait for partners responses + if (GetBlockReceivedStatus() != sReceivedPlayerBitmasks[game->playerCount - 2]) return 0; - for (; r5 < r4->playerCount; ++r5) - r4->recvCmd[0] += gBlockRecvBuffer[r5][0]; - if (r4->recvCmd[0] != 0) - BerryCrush_RunOrScheduleCommand(23, 1, NULL); + + // Read partners responses + for (i = 0; i < game->playerCount; i++) + game->recvCmd[0] += gBlockRecvBuffer[i][0]; + + if (game->recvCmd[0] != PLAY_AGAIN_YES) + RunOrScheduleCommand(CMD_PLAY_AGAIN_NO, SCHEDULE_CMD, NULL); else - BerryCrush_RunOrScheduleCommand(22, 1, NULL); + RunOrScheduleCommand(CMD_PLAY_AGAIN_YES, SCHEDULE_CMD, NULL); ResetBlockReceivedFlags(); - r4->sendCmd[0] = 0; - r4->recvCmd[0] = 0; - r4->unk10 = 0; - r4->cmdState = 0; + game->sendCmd[0] = 0; + game->recvCmd[0] = 0; + game->cmdTimer = 0; + game->cmdState = 0; return 0; } - ++r4->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_FadeOutToPlayAgain(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1) +static u32 Cmd_PlayAgain(struct BerryCrushGame *game, u8 *args) { - switch (r5->cmdState) + switch (game->cmdState) { case 0: - BeginNormalPaletteFade(PALETTES_ALL, 1, 0, 0x10, RGB_BLACK); + BeginNormalPaletteFade(PALETTES_ALL, 1, 0, 16, RGB_BLACK); UpdatePaletteFade(); break; case 1: @@ -3068,56 +3368,56 @@ static u32 BerryCrushCommand_FadeOutToPlayAgain(struct BerryCrushGame *r5, __att break; case 2: ClearDialogWindowAndFrame(0, 1); - sub_8021488(r5); - BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_BLACK); + ResetCrusherPos(game); + BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); UpdatePaletteFade(); break; case 3: if (UpdatePaletteFade()) return 0; - BerryCrush_RunOrScheduleCommand(7, 1, NULL); - r5->gameState = 3; - r5->cmdState = 0; + RunOrScheduleCommand(CMD_ASK_PICK_BERRY, SCHEDULE_CMD, NULL); + game->gameState = STATE_PICK_BERRY; + game->cmdState = 0; return 0; } - ++r5->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_PlayAgainFailureMessage(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1) +static u32 Cmd_StopGame(struct BerryCrushGame *game, u8 *args) { - switch (r5->cmdState) + switch (game->cmdState) { case 0: DrawDialogueFrame(0, 0); - if (r5->unk14 == 3) - AddTextPrinterParameterized2(0, 1, sBerryCrushMessages[5], r5->textSpeed, 0, 2, 1, 3); + if (game->playAgainState == PLAY_AGAIN_NO_BERRIES) + AddTextPrinterParameterized2(0, 1, sMessages[MSG_NO_BERRIES], game->textSpeed, 0, 2, 1, 3); else - AddTextPrinterParameterized2(0, 1, sBerryCrushMessages[6], r5->textSpeed, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, 1, sMessages[MSG_DROPPED], game->textSpeed, 0, 2, 1, 3); CopyWindowToVram(0, 3); break; case 1: if (IsTextPrinterActive(0)) return 0; - r5->unk138.animBerryIdx = 120; + game->gfx.counter = 120; break; case 2: - if (r5->unk138.animBerryIdx != 0) - --r5->unk138.animBerryIdx; + if (game->gfx.counter != 0) + game->gfx.counter--; else { - BerryCrush_RunOrScheduleCommand(24, 1, NULL); - r5->cmdState = 0; + RunOrScheduleCommand(CMD_CLOSE_LINK, SCHEDULE_CMD, NULL); + game->cmdState = 0; } return 0; } - ++r5->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_GracefulExit(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1) +static u32 Cmd_CloseLink(struct BerryCrushGame *game, u8 *args) { - switch (r5->cmdState) + switch (game->cmdState) { case 0: Rfu_SetLinkStandbyCallback(); @@ -3130,81 +3430,81 @@ static u32 BerryCrushCommand_GracefulExit(struct BerryCrushGame *r5, __attribute case 2: if (gReceivedRemoteLinkPlayers != 0) return 0; - r5->nextCmd = 25; - BerryCrush_RunOrScheduleCommand(5, 1, NULL); - r5->cmdState = 2; // ??? + game->nextCmd = CMD_QUIT; + RunOrScheduleCommand(CMD_HIDE_GAME, SCHEDULE_CMD, NULL); + game->cmdState = 2; // ??? return 0; } - ++r5->cmdState; + game->cmdState++; return 0; } -static u32 BerryCrushCommand_Quit(__attribute__((unused)) struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1) +static u32 Cmd_Quit(struct BerryCrushGame *game, u8 *args) { QuitBerryCrush(NULL); return 0; } -static void sub_8024578(struct BerryCrushGame *r4) +static void ResetGame(struct BerryCrushGame *game) { - u8 r5 = 0; + u8 i = 0; - IncrementGameStat(GAME_STAT_51); - r4->unkD = 0; - r4->unk10 = 0; - r4->gameState = 2; - r4->unk14 = 0; - r4->powder = 0; - r4->unk18 = 0; - r4->unk1A = 0; - r4->unk20 = 0; - r4->unk24 = 0; - r4->unk25_0 = 0; - r4->unk25_1 = 0; - r4->unk25_2 = 0; - r4->unk25_3 = 0; - r4->unk25_4 = 0; - r4->unk25_5 = 0; - r4->unk26 = 0; - r4->timer = 0; - r4->unk2E = 0; - r4->unk32 = -1; - r4->unk30 = 0; - r4->unk34 = 0; - for (; r5 < 5; ++r5) + IncrementGameStat(GAME_STAT_PLAYED_BERRY_CRUSH); + game->unused = 0; + game->cmdTimer = 0; + game->gameState = STATE_RESET; + game->playAgainState = 0; + game->powder = 0; + game->targetAPresses = 0; + game->totalAPresses = 0; + game->targetDepth = 0; + game->newDepth = 0; + game->noRoomForPowder = FALSE; + game->newRecord = FALSE; + game->playedSound = FALSE; + game->endGame = FALSE; + game->bigSparkle = FALSE; + game->sparkleAmount = 0; + game->leaderTimer = 0; + game->timer = 0; + game->bigSparkleCounter = 0; + game->numBigSparkleChecks = -1; + game->numBigSparkles = 0; + game->sparkleCounter = 0; + for (i = 0; i < MAX_RFU_PLAYERS; i++) { - r4->unk98[r5].unkC = -1; - r4->unk98[r5].unkE = 0; - r4->unk98[r5].unk10 = 0; - r4->unk98[r5].unk12 = 1; - r4->unk98[r5].unk14 = 0; - r4->unk98[r5].unk16 = 0; - r4->unk98[r5].unk18 = 0; - r4->unk98[r5].unk1A = 0; - r4->unk98[r5].unk1B = 0; - r4->unk98[r5].unk1C = 0; + game->players[i].berryId = -1; + game->players[i].inputTime = 0; + game->players[i].neatInputStreak = 0; + game->players[i].timeSincePrevInput = 1; + game->players[i].maxNeatInputStreak = 0; + game->players[i].numAPresses = 0; + game->players[i].numSyncedAPresses = 0; + game->players[i].timePressingA = 0; + game->players[i].inputFlags = 0; + game->players[i].inputState = INPUT_STATE_NONE; } } -static void BerryCrush_SetPaletteFadeParams(u8 *params, bool8 communicateAfter, u32 selectedPals, s8 delay, u8 startY, u8 targetY, u16 palette) +static void SetPaletteFadeArgs(u8 *args, bool8 communicateAfter, u32 selectedPals, s8 delay, u8 startY, u8 targetY, u16 palette) { - params[0] = ((u8 *)&selectedPals)[0]; - params[1] = ((u8 *)&selectedPals)[1]; - params[2] = ((u8 *)&selectedPals)[2]; - params[3] = ((u8 *)&selectedPals)[3]; - params[4] = delay; - params[5] = startY; - params[6] = targetY; - params[7] = ((u8 *)&palette)[0]; - params[8] = ((u8 *)&palette)[1]; - params[9] = communicateAfter; + args[0] = ((u8 *)&selectedPals)[0]; + args[1] = ((u8 *)&selectedPals)[1]; + args[2] = ((u8 *)&selectedPals)[2]; + args[3] = ((u8 *)&selectedPals)[3]; + args[4] = delay; + args[5] = startY; + args[6] = targetY; + args[7] = ((u8 *)&palette)[0]; + args[8] = ((u8 *)&palette)[1]; + args[9] = communicateAfter; } -static void BerryCrush_SetShowMessageParams(u8 *params, u8 stringId, u8 flags, u16 waitKeys, u8 followupCmd) +static void SetPrintMessageArgs(u8 *args, u8 msgId, u8 flags, u16 waitKeys, u8 followupState) { - params[0] = stringId; - params[1] = flags; - params[2] = ((u8 *)&waitKeys)[0]; - params[3] = ((u8 *)&waitKeys)[1]; - params[4] = followupCmd; + args[0] = msgId; + args[1] = flags; + args[2] = ((u8 *)&waitKeys)[0]; + args[3] = ((u8 *)&waitKeys)[1]; + args[4] = followupState; } diff --git a/src/graphics.c b/src/graphics.c index 1a3423fb68..7a7a11b2b9 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1543,9 +1543,9 @@ const u16 gUnknown_08DE3350[] = INCBIN_U16("graphics/frontier_pass/tilemap1.bin" const u16 gUnknown_08DE3374[] = INCBIN_U16("graphics/frontier_pass/tilemap2.bin"); // Berry Crush -const u16 gUnknown_08DE3398[] = INCBIN_U16("graphics/berry_crusher/tiles.gbapal"); -const u32 gUnknown_08DE34B8[] = INCBIN_U32("graphics/berry_crusher/tiles.4bpp.lz"); -const u32 gUnknown_08DE3FD4[] = INCBIN_U32("graphics/berry_crusher/tiles.bin.lz"); +const u16 gBerryCrush_Crusher_Pal[] = INCBIN_U16("graphics/berry_crush/crusher.gbapal"); +const u32 gBerryCrush_Crusher_Gfx[] = INCBIN_U32("graphics/berry_crush/crusher.4bpp.lz"); +const u32 gBerryCrush_Crusher_Tilemap[] = INCBIN_U32("graphics/berry_crush/crusher.bin.lz"); // random garbage at the end. static const u8 sEmpty3[0x54BAC] = {0}; diff --git a/src/minigame_countdown.c b/src/minigame_countdown.c index f7dad48005..2d4d981386 100644 --- a/src/minigame_countdown.c +++ b/src/minigame_countdown.c @@ -48,8 +48,8 @@ static void Task_StaticCountdown_Free(u8 taskId); static void Task_StaticCountdown_Start(u8 taskId); static void Task_StaticCountdown_Run(u8 taskId); -static const u16 s321Start_Static_Pal[] = INCBIN_U16("graphics/link_games/321start_static.gbapal"); -static const u32 s321Start_Static_Gfx[] = INCBIN_U32("graphics/link_games/321start_static.4bpp.lz"); +static const u16 s321Start_Static_Pal[] = INCBIN_U16("graphics/minigame_countdown/321start_static.gbapal"); +static const u32 s321Start_Static_Gfx[] = INCBIN_U32("graphics/minigame_countdown/321start_static.4bpp.lz"); static const struct CompressedSpriteSheet sSpriteSheet_321Start_Static[] = { @@ -374,8 +374,8 @@ static void CreateStartSprite(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subprior static void InitStartGraphic(u8 spriteId1, u8 spriteId2, u8 spriteId3); static void SpriteCB_Start(struct Sprite *sprite); -static const u16 s321Start_Pal[] = INCBIN_U16("graphics/link_games/321start.gbapal"); -static const u32 s321Start_Gfx[] = INCBIN_U32("graphics/link_games/321start.4bpp.lz"); +static const u16 s321Start_Pal[] = INCBIN_U16("graphics/minigame_countdown/321start.gbapal"); +static const u32 s321Start_Gfx[] = INCBIN_U32("graphics/minigame_countdown/321start.4bpp.lz"); #define tState data[0] #define tTilesTag data[2] diff --git a/src/strings.c b/src/strings.c index fe5051d711..19d0e3ccad 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1292,7 +1292,7 @@ const u8 gText_MatchCallMay_Intro1[] = _("My POKéMON and I help"); const u8 gText_MatchCallMay_Intro2[] = _("my father's research."); const u8 gText_HatchedFromEgg[] = _("{STR_VAR_1} hatched from the EGG!"); const u8 gText_NicknameHatchPrompt[] = _("Would you like to nickname the newly\nhatched {STR_VAR_1}?"); -ALIGNED(4) const u8 gText_ReadyToBerryCrush[] = _("Are you ready to BERRY-CRUSH?\nPlease pick a BERRY for use.\p"); +ALIGNED(4) const u8 gText_ReadyPickBerry[] = _("Are you ready to BERRY-CRUSH?\nPlease pick a BERRY for use.\p"); ALIGNED(4) const u8 gText_WaitForAllChooseBerry[] = _("Please wait while each member\nchooses a BERRY."); ALIGNED(4) const u8 gText_EndedWithXUnitsPowder[] = _("{PAUSE_MUSIC}{PLAY_BGM MUS_LEVEL_UP}You ended up with {STR_VAR_1} units of\nsilky-smooth BERRY POWDER.{RESUME_MUSIC}\pYour total amount of BERRY POWDER\nis {STR_VAR_2}.\p"); ALIGNED(4) const u8 gText_RecordingGameResults[] = _("Recording your game results in the\nsave file.\lPlease wait."); From 5b910a11b4f6d548b6643455ccb806c0e60f48a2 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Thu, 18 Mar 2021 20:35:39 -0400 Subject: [PATCH 02/31] port miscellaneous fr documentation --- include/overworld.h | 8 ++++---- src/link.c | 4 ++-- src/mail.c | 2 +- src/main.c | 4 ++-- src/menu_helpers.c | 2 +- src/overworld.c | 40 ++++++++++++++++++++-------------------- src/pokenav.c | 2 +- src/trainer_card.c | 6 +++--- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/overworld.h b/include/overworld.h index a2eac7e29a..6efaa6ccb6 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -152,10 +152,10 @@ u16 sub_8087288(void); u16 sub_808729C(void); u16 QueueExitLinkRoomKey(void); u16 sub_80872C4(void); -bool32 sub_8087598(void); -bool32 sub_80875C8(void); -bool32 sub_8087634(void); -bool32 sub_808766C(void); +bool32 Overworld_LinkRecvQueueLengthMoreThan2(void); +bool32 Overworld_RecvKeysFromLinkIsRunning(void); +bool32 Overworld_SendKeysToLinkIsRunning(void); +bool32 IsSendingKeysOverCable(void); void ClearLinkPlayerObjectEvents(void); #endif // GUARD_OVERWORLD_H diff --git a/src/link.c b/src/link.c index 9f0ac6654e..fac5f3252a 100644 --- a/src/link.c +++ b/src/link.c @@ -1832,7 +1832,7 @@ bool8 HandleLinkConnection(void) { gLinkStatus = LinkMain1(&gShouldAdvanceLinkState, gSendCmd, gRecvCmds); LinkMain2(&gMain.heldKeys); - if ((gLinkStatus & LINK_STAT_RECEIVED_NOTHING) && sub_808766C() == TRUE) + if ((gLinkStatus & LINK_STAT_RECEIVED_NOTHING) && IsSendingKeysOverCable() == TRUE) { return TRUE; } @@ -1841,7 +1841,7 @@ bool8 HandleLinkConnection(void) { r4 = sub_8010EC0(); r5 = sub_8010F1C(); - if (sub_808766C() == TRUE) + if (IsSendingKeysOverCable() == TRUE) { if (r4 == TRUE || IsRfuRecvQueueEmpty() || r5) { diff --git a/src/mail.c b/src/mail.c index db8451395d..0ee294787c 100644 --- a/src/mail.c +++ b/src/mail.c @@ -593,7 +593,7 @@ static bool8 MailReadBuildGraphics(void) } break; case 15: - if (sub_8087598() == TRUE) + if (Overworld_LinkRecvQueueLengthMoreThan2() == TRUE) { return FALSE; } diff --git a/src/main.c b/src/main.c index 278b93542b..75861a3acd 100644 --- a/src/main.c +++ b/src/main.c @@ -132,7 +132,7 @@ void AgbMain() DoSoftReset(); } - if (sub_8087634() == 1) + if (Overworld_SendKeysToLinkIsRunning() == 1) { gLinkTransferringData = TRUE; UpdateLinkAndCallCallbacks(); @@ -143,7 +143,7 @@ void AgbMain() gLinkTransferringData = FALSE; UpdateLinkAndCallCallbacks(); - if (sub_80875C8() == 1) + if (Overworld_RecvKeysFromLinkIsRunning() == 1) { gMain.newKeys = 0; ClearSpriteCopyRequests(); diff --git a/src/menu_helpers.c b/src/menu_helpers.c index b31d84a1e3..edff67ab8d 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -312,7 +312,7 @@ static bool8 sub_81221D0(void) if (!MenuHelpers_LinkSomething()) return FALSE; else - return sub_8087598(); + return Overworld_LinkRecvQueueLengthMoreThan2(); } bool8 MenuHelpers_CallLinkSomething(void) diff --git a/src/overworld.c b/src/overworld.c index 5aa5bb73df..665b840c56 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -125,14 +125,14 @@ static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion); static void GetLinkPlayerCoords(u8 linkPlayerId, u16 *x, u16 *y); static u8 GetLinkPlayerFacingDirection(u8 linkPlayerId); static u8 GetLinkPlayerElevation(u8 linkPlayerId); -static s32 sub_80878E4(u8 linkPlayerId); +static s32 GetLinkPlayerObjectStepTimer(u8 linkPlayerId); static u8 GetLinkPlayerIdAt(s16 x, s16 y); static void SetPlayerFacingDirection(u8 linkPlayerId, u8 a2); static void ZeroObjectEvent(struct ObjectEvent *objEvent); static void SpawnLinkPlayerObjectEvent(u8 linkPlayerId, s16 x, s16 y, u8 a4); static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s16 y); -static void sub_80877DC(u8 linkPlayerId, u8 a2); -static void sub_808780C(u8 linkPlayerId); +static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 a2); +static void DestroyLinkPlayerObject(u8 linkPlayerId); static u8 GetSpriteForLinkedPlayer(u8 linkPlayerId); static void RunTerminateLinkScript(void); static u32 GetLinkSendQueueLength(void); @@ -172,7 +172,7 @@ static u8 sPlayerTradingStates[MAX_LINK_PLAYERS]; // adjusted key code, effectively intercepting the input before anything // can process it. static u16 (*sPlayerKeyInterceptCallback)(u32); -static bool8 sUnknown_03000E18; +static bool8 sReceivingFromLink; static u8 sRfuKeepAliveTimer; // IWRAM common @@ -1626,7 +1626,7 @@ static void CB2_ReturnToFieldLocal(void) static void CB2_ReturnToFieldLink(void) { - if (!sub_8087598() && ReturnToFieldLink(&gMain.state)) + if (!Overworld_LinkRecvQueueLengthMoreThan2() && ReturnToFieldLink(&gMain.state)) SetMainCallback2(CB2_Overworld); } @@ -2823,18 +2823,18 @@ static void RunTerminateLinkScript(void) ScriptContext2_Enable(); } -bool32 sub_8087598(void) +bool32 Overworld_LinkRecvQueueLengthMoreThan2(void) { if (!IsUpdateLinkStateCBActive()) return FALSE; if (GetLinkRecvQueueLength() >= 3) - sUnknown_03000E18 = TRUE; + sReceivingFromLink = TRUE; else - sUnknown_03000E18 = FALSE; - return sUnknown_03000E18; + sReceivingFromLink = FALSE; + return sReceivingFromLink; } -bool32 sub_80875C8(void) +bool32 Overworld_RecvKeysFromLinkIsRunning(void) { u8 temp; @@ -2849,8 +2849,8 @@ bool32 sub_80875C8(void) else if (sPlayerKeyInterceptCallback != KeyInterCB_DeferToEventScript) return FALSE; - temp = sUnknown_03000E18; - sUnknown_03000E18 = FALSE; + temp = sReceivingFromLink; + sReceivingFromLink = FALSE; if (temp == TRUE) return TRUE; @@ -2860,7 +2860,7 @@ bool32 sub_80875C8(void) return FALSE; } -bool32 sub_8087634(void) +bool32 Overworld_SendKeysToLinkIsRunning(void) { if (GetLinkSendQueueLength() < 2) return FALSE; @@ -2874,7 +2874,7 @@ bool32 sub_8087634(void) return FALSE; } -bool32 sub_808766C(void) +bool32 IsSendingKeysOverCable(void) { if (gWirelessCommType != 0) return FALSE; @@ -2923,15 +2923,15 @@ static void SpawnLinkPlayerObjectEvent(u8 linkPlayerId, s16 x, s16 y, u8 gender) ZeroLinkPlayerObjectEvent(linkPlayerObjEvent); ZeroObjectEvent(objEvent); - linkPlayerObjEvent->active = 1; + linkPlayerObjEvent->active = TRUE; linkPlayerObjEvent->linkPlayerId = linkPlayerId; linkPlayerObjEvent->objEventId = objEventId; linkPlayerObjEvent->movementMode = MOVEMENT_MODE_FREE; - objEvent->active = 1; + objEvent->active = TRUE; linkGender(objEvent) = gender; linkDirection(objEvent) = DIR_NORTH; - objEvent->spriteId = 64; + objEvent->spriteId = MAX_SPRITES; InitLinkPlayerObjectEventPos(objEvent, x, y); } @@ -2947,7 +2947,7 @@ static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s1 ObjectEventUpdateZCoord(objEvent); } -static void sub_80877DC(u8 linkPlayerId, u8 dir) +static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 dir) { if (gLinkPlayerObjectEvents[linkPlayerId].active) { @@ -2957,7 +2957,7 @@ static void sub_80877DC(u8 linkPlayerId, u8 dir) } } -static void sub_808780C(u8 linkPlayerId) +static void DestroyLinkPlayerObject(u8 linkPlayerId) { struct LinkPlayerObjectEvent *linkPlayerObjEvent = &gLinkPlayerObjectEvents[linkPlayerId]; u8 objEventId = linkPlayerObjEvent->objEventId; @@ -2998,7 +2998,7 @@ static u8 GetLinkPlayerElevation(u8 linkPlayerId) return objEvent->currentElevation; } -static s32 sub_80878E4(u8 linkPlayerId) +static s32 GetLinkPlayerObjectStepTimer(u8 linkPlayerId) { u8 objEventId = gLinkPlayerObjectEvents[linkPlayerId].objEventId; struct ObjectEvent *objEvent = &gObjectEvents[objEventId]; diff --git a/src/pokenav.c b/src/pokenav.c index eac0c85b4f..881411b9ec 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -288,7 +288,7 @@ static void Task_RunLoopedTask_LinkMode(u8 taskId) s16 *state; u32 action; - if (sub_8087598()) + if (Overworld_LinkRecvQueueLengthMoreThan2()) return; task = (LoopedTask)GetWordTaskArg(taskId, 1); diff --git a/src/trainer_card.c b/src/trainer_card.c index c42c16845a..9e14a7e9cf 100755 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -458,7 +458,7 @@ static void Task_TrainerCard(u8 taskId) } break; case STATE_WAIT_FLIP_TO_BACK: - if (IsCardFlipTaskActive() && sub_8087598() != TRUE) + if (IsCardFlipTaskActive() && Overworld_LinkRecvQueueLengthMoreThan2() != TRUE) { PlaySE(SE_RG_CARD_OPEN); sData->mainState = STATE_HANDLE_INPUT_BACK; @@ -515,7 +515,7 @@ static void Task_TrainerCard(u8 taskId) CloseTrainerCard(taskId); break; case STATE_WAIT_FLIP_TO_FRONT: - if (IsCardFlipTaskActive() && sub_8087598() != TRUE) + if (IsCardFlipTaskActive() && Overworld_LinkRecvQueueLengthMoreThan2() != TRUE) { sData->mainState = STATE_HANDLE_INPUT_FRONT; PlaySE(SE_RG_CARD_OPEN); @@ -1663,7 +1663,7 @@ static bool8 Task_AnimateCardFlipDown(struct Task* task) static bool8 Task_DrawFlippedCardSide(struct Task* task) { sData->allowDMACopy = FALSE; - if (sub_8087598() == TRUE) + if (Overworld_LinkRecvQueueLengthMoreThan2() == TRUE) return FALSE; do From 7198d40ec8dac00e3fc5b0d2ae01741fd12aea0e Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Fri, 19 Mar 2021 18:49:19 -0400 Subject: [PATCH 03/31] port some documentation from FR --- gflib/text.c | 5 ++--- src/overworld.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/gflib/text.c b/gflib/text.c index ffce2cb561..f07a2367ac 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -1280,7 +1280,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) default: return 0; } - case CHAR_DYNAMIC: + case CHAR_SPECIAL_F7: if (bufferPointer == NULL) bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); while (*bufferPointer != EOS) @@ -1398,8 +1398,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) if (lineWidth > width) return lineWidth; - else - return width; + return width; } u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) diff --git a/src/overworld.c b/src/overworld.c index 665b840c56..e7c86b0a4a 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -3048,32 +3048,32 @@ static void SetPlayerFacingDirection(u8 linkPlayerId, u8 facing) } -static u8 MovementEventModeCB_Normal(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3) +static u8 MovementEventModeCB_Normal(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) { - return gLinkPlayerFacingHandlers[a3](linkPlayerObjEvent, objEvent, a3); + return gLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir); } -static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3) +static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) { return FACING_UP; } // Duplicate Function -static u8 MovementEventModeCB_Normal_2(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3) +static u8 MovementEventModeCB_Normal_2(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) { - return gLinkPlayerFacingHandlers[a3](linkPlayerObjEvent, objEvent, a3); + return gLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir); } -static bool8 FacingHandler_DoNothing(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3) +static bool8 FacingHandler_DoNothing(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) { return FALSE; } -static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3) +static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) { s16 x, y; - linkDirection(objEvent) = FlipVerticalAndClearForced(a3, linkDirection(objEvent)); + linkDirection(objEvent) = FlipVerticalAndClearForced(dir, linkDirection(objEvent)); ObjectEventMoveDestCoords(objEvent, linkDirection(objEvent), &x, &y); if (LinkPlayerDetectCollision(linkPlayerObjEvent->objEventId, linkDirection(objEvent), x, y)) @@ -3089,9 +3089,9 @@ static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayer } } -static bool8 FacingHandler_ForcedFacingChange(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3) +static bool8 FacingHandler_ForcedFacingChange(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) { - linkDirection(objEvent) = FlipVerticalAndClearForced(a3, linkDirection(objEvent)); + linkDirection(objEvent) = FlipVerticalAndClearForced(dir, linkDirection(objEvent)); return FALSE; } From 0691632ac61decd53901f4a59a56d2ca79554311 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Fri, 19 Mar 2021 18:52:37 -0400 Subject: [PATCH 04/31] oops --- gflib/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gflib/text.c b/gflib/text.c index f07a2367ac..a4e8d8bd36 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -1280,7 +1280,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) default: return 0; } - case CHAR_SPECIAL_F7: + case CHAR_DYNAMIC: if (bufferPointer == NULL) bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); while (*bufferPointer != EOS) From 6127c6f32e25aec976c290b717a2e4fddffc30d1 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 20 Mar 2021 23:47:08 -0400 Subject: [PATCH 05/31] Misc labels in battle facilities --- include/constants/battle_pike.h | 4 ++-- include/trainer_hill.h | 1 - src/battle_arena.c | 3 ++- src/battle_factory_screen.c | 24 ++++++++++++------------ src/battle_pike.c | 12 ++++++------ src/battle_tower.c | 8 ++------ src/trainer_hill.c | 10 +++++----- 7 files changed, 29 insertions(+), 33 deletions(-) diff --git a/include/constants/battle_pike.h b/include/constants/battle_pike.h index 9187ae28c0..76309436e1 100644 --- a/include/constants/battle_pike.h +++ b/include/constants/battle_pike.h @@ -42,8 +42,8 @@ #define BATTLE_PIKE_FUNC_SET_IN_WILD_MON_ROOM 6 #define BATTLE_PIKE_FUNC_CLEAR_IN_WILD_MON_ROOM 7 #define BATTLE_PIKE_FUNC_SAVE 8 -#define BATTLE_PIKE_FUNC_NULL_9 9 -#define BATTLE_PIKE_FUNC_NULL_10 10 +#define BATTLE_PIKE_FUNC_DUMMY_1 9 +#define BATTLE_PIKE_FUNC_DUMMY_2 10 #define BATTLE_PIKE_FUNC_GET_ROOM_STATUS 11 #define BATTLE_PIKE_FUNC_GET_ROOM_STATUS_MON 12 #define BATTLE_PIKE_FUNC_HEAL_ONE_TWO_MONS 13 diff --git a/include/trainer_hill.h b/include/trainer_hill.h index 94d29a7cad..acf8faccaa 100644 --- a/include/trainer_hill.h +++ b/include/trainer_hill.h @@ -66,7 +66,6 @@ void InitTrainerHillBattleStruct(void); void FreeTrainerHillBattleStruct(void); void CopyTrainerHillTrainerText(u8 which, u16 trainerId); bool8 InTrainerHillChallenge(void); -void nullsub_129(void); void PrintOnTrainerHillRecordsWindow(void); void LoadTrainerHillObjectEventTemplates(void); bool32 LoadTrainerHillFloorObjectEventScripts(void); diff --git a/src/battle_arena.c b/src/battle_arena.c index 0ffba49108..11c918225a 100644 --- a/src/battle_arena.c +++ b/src/battle_arena.c @@ -774,7 +774,8 @@ void BattleArena_DeductMindPoints(u8 battler, u16 stringId) } } -void sub_81A586C(u8 battler) // Unused. +// Unused +static void UpdateHPAtStart(u8 battler) { u16 *hpAtStart = gBattleStruct->arenaStartHp; diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 8c056da1b9..7b0af774a1 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -529,7 +529,7 @@ static const union AnimCmd * const sAnims_Select_Pokeball[] = sAnim_Select_Pokeball_Moving, }; -static const union AffineAnimCmd gUnknown_0861050C[] = +static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Opening[] = { AFFINEANIMCMD_FRAME(5, 5, 0, 0), AFFINEANIMCMD_FRAME(0, 0, 0, 1), @@ -545,7 +545,7 @@ static const union AffineAnimCmd gUnknown_0861050C[] = AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_0861056C[] = +static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Closing[] = { AFFINEANIMCMD_FRAME(128, 5, 0, 0), AFFINEANIMCMD_FRAME(0, 0, 0, 1), @@ -559,7 +559,7 @@ static const union AffineAnimCmd gUnknown_0861056C[] = AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_086105BC[] = +static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Open[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_END, @@ -567,9 +567,9 @@ static const union AffineAnimCmd gUnknown_086105BC[] = static const union AffineAnimCmd * const sAffineAnims_Select_MonPicBgAnim[] = { - gUnknown_0861050C, - gUnknown_0861056C, - gUnknown_086105BC, + sAffineAnim_Select_MonPicBg_Opening, + sAffineAnim_Select_MonPicBg_Closing, + sAffineAnim_Select_MonPicBg_Open, }; static const struct SpriteTemplate sSpriteTemplate_Select_Pokeball = @@ -780,7 +780,7 @@ static const union AnimCmd * const sAnims_Swap_Pokeball[] = sAnim_Swap_Pokeball_Moving, }; -static const union AffineAnimCmd gUnknown_08610768[] = +static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Opening[] = { AFFINEANIMCMD_FRAME(5, 5, 0, 0), AFFINEANIMCMD_FRAME(0, 0, 0, 1), @@ -796,7 +796,7 @@ static const union AffineAnimCmd gUnknown_08610768[] = AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_086107C8[] = +static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Closing[] = { AFFINEANIMCMD_FRAME(128, 5, 0, 0), AFFINEANIMCMD_FRAME(0, 0, 0, 1), @@ -810,7 +810,7 @@ static const union AffineAnimCmd gUnknown_086107C8[] = AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_08610818[] = +static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Open[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_END, @@ -818,9 +818,9 @@ static const union AffineAnimCmd gUnknown_08610818[] = static const union AffineAnimCmd * const sAffineAnims_Swap_MonPicBgAnim[] = { - gUnknown_08610768, - gUnknown_086107C8, - gUnknown_08610818, + sAffineAnim_Swap_MonPicBg_Opening, + sAffineAnim_Swap_MonPicBg_Closing, + sAffineAnim_Swap_MonPicBg_Open, }; static const struct SpriteTemplate sSpriteTemplate_Swap_Pokeball = diff --git a/src/battle_pike.c b/src/battle_pike.c index ccb52fda22..ed89f5ed96 100644 --- a/src/battle_pike.c +++ b/src/battle_pike.c @@ -57,8 +57,8 @@ static void GetRoomType(void); static void SetInWildMonRoom(void); static void ClearInWildMonRoom(void); static void SavePikeChallenge(void); -static void nullsub_76(void); -static void nullsub_124(void); +static void PikeDummy1(void); +static void PikeDummy2(void); static void GetRoomInflictedStatus(void); static void GetRoomInflictedStatusMon(void); static void HealOneOrTwoMons(void); @@ -488,8 +488,8 @@ static void (* const sBattlePikeFunctions[])(void) = [BATTLE_PIKE_FUNC_SET_IN_WILD_MON_ROOM] = SetInWildMonRoom, [BATTLE_PIKE_FUNC_CLEAR_IN_WILD_MON_ROOM] = ClearInWildMonRoom, [BATTLE_PIKE_FUNC_SAVE] = SavePikeChallenge, - [BATTLE_PIKE_FUNC_NULL_9] = nullsub_76, - [BATTLE_PIKE_FUNC_NULL_10] = nullsub_124, + [BATTLE_PIKE_FUNC_DUMMY_1] = PikeDummy1, + [BATTLE_PIKE_FUNC_DUMMY_2] = PikeDummy2, [BATTLE_PIKE_FUNC_GET_ROOM_STATUS] = GetRoomInflictedStatus, [BATTLE_PIKE_FUNC_GET_ROOM_STATUS_MON] = GetRoomInflictedStatusMon, [BATTLE_PIKE_FUNC_HEAL_ONE_TWO_MONS] = HealOneOrTwoMons, @@ -715,12 +715,12 @@ static void SavePikeChallenge(void) TrySavingData(SAVE_LINK); } -static void nullsub_76(void) +static void PikeDummy1(void) { } -static void nullsub_124(void) +static void PikeDummy2(void) { } diff --git a/src/battle_tower.c b/src/battle_tower.c index 1bf4b737c9..b1e5d78172 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -878,12 +878,8 @@ static const u16 sFrontierTrainerIdRangesHard[][2] = {FRONTIER_TRAINER_JAXON, FRONTIER_TRAINER_GRETEL}, // 200 - 299 }; -// Trainer IDs? Don't make sense as part of previous array, min/max relationship reversed and never accessed -static const u16 sUnused_085DFA1A[][2] = -{ - {179, 141}, // FRONTIER_TRAINER_ALISON - FRONTIER_TRAINER_KAYDEN - {200, 183}, // FRONTIER_TRAINER_JAXON - FRONTIER_TRAINER_HUNTER -}; +// Unknown, unused data +static const u16 sUnused[] = { 179, 141, 200, 183 }; static const u8 sBattleTowerPartySizes[FRONTIER_MODE_COUNT] = { diff --git a/src/trainer_hill.c b/src/trainer_hill.c index 18d56723cf..3bc6c970b5 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -74,7 +74,7 @@ static void GetChallengeWon(void); static void TrainerHillSetTag(void); static void SetUpDataStruct(void); static void FreeDataStruct(void); -static void nullsub_2(void); +static void TrainerHillDummy(void); static void SetTimerValue(u32 *dst, u32 val); static u32 GetTimerValue(u32 *src); static void SetTrainerHillMonLevel(struct Pokemon *mon, u8 level); @@ -358,7 +358,7 @@ static void SetUpDataStruct(void) sHillData = AllocZeroed(sizeof(*sHillData)); sHillData->floorId = gMapHeader.mapLayoutId - LAYOUT_TRAINER_HILL_1F; CpuCopy32(sDataPerTag[gSaveBlock1Ptr->trainerHill.tag], &sHillData->tag, sizeof(sHillData->tag) + 4 * sizeof(struct TrHillFloor)); - nullsub_2(); + TrainerHillDummy(); } } @@ -397,7 +397,7 @@ void CopyTrainerHillTrainerText(u8 which, u16 trainerId) static void TrainerHillStartChallenge(void) { - nullsub_2(); + TrainerHillDummy(); if (!ReadTrainerHillAndValidate()) gSaveBlock1Ptr->trainerHill.field_3D6E_0f = 1; else @@ -573,12 +573,12 @@ static void IsTrainerHillChallengeActive(void) gSpecialVar_Result = TRUE; } -void nullsub_129(void) +static void TrainerHillDummy_Unused(void) { } -static void nullsub_2(void) +static void TrainerHillDummy(void) { } From 9773b436d22872e2e7017b7fd733ca48710abab5 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 21 Mar 2021 00:00:16 -0400 Subject: [PATCH 06/31] Clean up shop.c --- src/shop.c | 261 ++++++++++++++++++++++++++--------------------------- 1 file changed, 130 insertions(+), 131 deletions(-) diff --git a/src/shop.c b/src/shop.c index 26bd964c54..dac43c96d1 100755 --- a/src/shop.c +++ b/src/shop.c @@ -40,11 +40,14 @@ #include "constants/songs.h" #include "constants/tv.h" -EWRAM_DATA struct MartInfo gMartInfo = {0}; -EWRAM_DATA struct ShopData *gShopDataPtr = NULL; -EWRAM_DATA struct ListMenuItem *gUnknown_02039F74 = NULL; -EWRAM_DATA u8 (*gUnknown_02039F78)[16] = {0}; -EWRAM_DATA u8 gMartPurchaseHistoryId = 0; +#define TAG_SCROLL_ARROW 2100 +#define TAG_ITEM_ICON_BASE 2110 + +static EWRAM_DATA struct MartInfo sMartInfo = {0}; +static EWRAM_DATA struct ShopData *sShopData = NULL; +static EWRAM_DATA struct ListMenuItem *sListMenuItems = NULL; +static EWRAM_DATA u8 (*sItemNames)[16] = {0}; +static EWRAM_DATA u8 sPurchaseHistoryId = 0; EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3] = {0}; static void Task_ShopMenu(u8 taskId); @@ -276,15 +279,15 @@ static u8 CreateShopMenu(u8 martType) int numMenuItems; ScriptContext2_Enable(); - gMartInfo.martType = martType; + sMartInfo.martType = martType; if (martType == MART_TYPE_NORMAL) { struct WindowTemplate winTemplate; winTemplate = sShopMenuWindowTemplates[0]; winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit)); - gMartInfo.windowId = AddWindow(&winTemplate); - gMartInfo.menuActions = sShopMenuActions_BuySellQuit; + sMartInfo.windowId = AddWindow(&winTemplate); + sMartInfo.menuActions = sShopMenuActions_BuySellQuit; numMenuItems = ARRAY_COUNT(sShopMenuActions_BuySellQuit); } else @@ -292,35 +295,35 @@ static u8 CreateShopMenu(u8 martType) struct WindowTemplate winTemplate; winTemplate = sShopMenuWindowTemplates[1]; winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit)); - gMartInfo.windowId = AddWindow(&winTemplate); - gMartInfo.menuActions = sShopMenuActions_BuyQuit; + sMartInfo.windowId = AddWindow(&winTemplate); + sMartInfo.menuActions = sShopMenuActions_BuyQuit; numMenuItems = ARRAY_COUNT(sShopMenuActions_BuyQuit); } - SetStandardWindowBorderStyle(gMartInfo.windowId, 0); - PrintMenuTable(gMartInfo.windowId, numMenuItems, gMartInfo.menuActions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gMartInfo.windowId, numMenuItems, 0); - PutWindowTilemap(gMartInfo.windowId); - CopyWindowToVram(gMartInfo.windowId, 1); + SetStandardWindowBorderStyle(sMartInfo.windowId, 0); + PrintMenuTable(sMartInfo.windowId, numMenuItems, sMartInfo.menuActions); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sMartInfo.windowId, numMenuItems, 0); + PutWindowTilemap(sMartInfo.windowId); + CopyWindowToVram(sMartInfo.windowId, 1); return CreateTask(Task_ShopMenu, 8); } static void SetShopMenuCallback(void (* callback)(void)) { - gMartInfo.callback = callback; + sMartInfo.callback = callback; } static void SetShopItemsForSale(const u16 *items) { u16 i = 0; - gMartInfo.itemList = items; - gMartInfo.itemCount = 0; + sMartInfo.itemList = items; + sMartInfo.itemCount = 0; - while (gMartInfo.itemList[i]) + while (sMartInfo.itemList[i]) { - gMartInfo.itemCount++; + sMartInfo.itemCount++; i++; } } @@ -337,7 +340,7 @@ static void Task_ShopMenu(u8 taskId) Task_HandleShopMenuQuit(taskId); break; default: - gMartInfo.menuActions[inputCode].func.void_u8(taskId); + sMartInfo.menuActions[inputCode].func.void_u8(taskId); break; } } @@ -368,14 +371,14 @@ void CB2_ExitSellMenu(void) static void Task_HandleShopMenuQuit(u8 taskId) { - ClearStdWindowAndFrameToTransparent(gMartInfo.windowId, 2); - RemoveWindow(gMartInfo.windowId); + ClearStdWindowAndFrameToTransparent(sMartInfo.windowId, 2); + RemoveWindow(sMartInfo.windowId); SaveRecordedItemPurchasesForTVShow(); ScriptContext2_Disable(); DestroyTask(taskId); - if (gMartInfo.callback) - gMartInfo.callback(); + if (sMartInfo.callback) + sMartInfo.callback(); } static void Task_GoToBuyOrSellMenu(u8 taskId) @@ -398,7 +401,7 @@ static void Task_ReturnToShopMenu(u8 taskId) { if (IsWeatherNotFadingIn() == TRUE) { - if (gMartInfo.martType == MART_TYPE_DECOR2) + if (sMartInfo.martType == MART_TYPE_DECOR2) DisplayItemMessageOnField(taskId, gText_CanIHelpWithAnythingElse, ShowShopMenuAfterExitingBuyOrSellMenu); else DisplayItemMessageOnField(taskId, gText_AnythingElseICanHelp, ShowShopMenuAfterExitingBuyOrSellMenu); @@ -407,7 +410,7 @@ static void Task_ReturnToShopMenu(u8 taskId) static void ShowShopMenuAfterExitingBuyOrSellMenu(u8 taskId) { - CreateShopMenu(gMartInfo.martType); + CreateShopMenu(sMartInfo.martType); DestroyTask(taskId); } @@ -447,10 +450,10 @@ static void CB2_InitBuyMenu(void) ResetSpriteData(); ResetTasks(); ClearScheduledBgCopiesToVram(); - gShopDataPtr = AllocZeroed(sizeof(struct ShopData)); - gShopDataPtr->scrollIndicatorsTaskId = TASK_NONE; - gShopDataPtr->itemSpriteIds[0] = SPRITE_NONE; - gShopDataPtr->itemSpriteIds[1] = SPRITE_NONE; + sShopData = AllocZeroed(sizeof(struct ShopData)); + sShopData->scrollIndicatorsTaskId = TASK_NONE; + sShopData->itemSpriteIds[0] = SPRITE_NONE; + sShopData->itemSpriteIds[1] = SPRITE_NONE; BuyMenuBuildListMenuTemplate(); BuyMenuInitBgs(); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); @@ -480,9 +483,9 @@ static void CB2_InitBuyMenu(void) static void BuyMenuFreeMemory(void) { - Free(gShopDataPtr); - Free(gUnknown_02039F74); - Free(gUnknown_02039F78); + Free(sShopData); + Free(sListMenuItems); + Free(sItemNames); FreeAllWindowBuffers(); } @@ -490,29 +493,29 @@ static void BuyMenuBuildListMenuTemplate(void) { u16 i; - gUnknown_02039F74 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F74)); - gUnknown_02039F78 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F78)); - for (i = 0; i < gMartInfo.itemCount; i++) - BuyMenuSetListEntry(&gUnknown_02039F74[i], gMartInfo.itemList[i], gUnknown_02039F78[i]); + sListMenuItems = Alloc((sMartInfo.itemCount + 1) * sizeof(*sListMenuItems)); + sItemNames = Alloc((sMartInfo.itemCount + 1) * sizeof(*sItemNames)); + for (i = 0; i < sMartInfo.itemCount; i++) + BuyMenuSetListEntry(&sListMenuItems[i], sMartInfo.itemList[i], sItemNames[i]); - StringCopy(gUnknown_02039F78[i], gText_Cancel2); - gUnknown_02039F74[i].name = gUnknown_02039F78[i]; - gUnknown_02039F74[i].id = -2; + StringCopy(sItemNames[i], gText_Cancel2); + sListMenuItems[i].name = sItemNames[i]; + sListMenuItems[i].id = LIST_CANCEL; gMultiuseListMenuTemplate = sShopBuyMenuListTemplate; - gMultiuseListMenuTemplate.items = gUnknown_02039F74; - gMultiuseListMenuTemplate.totalItems = gMartInfo.itemCount + 1; + gMultiuseListMenuTemplate.items = sListMenuItems; + gMultiuseListMenuTemplate.totalItems = sMartInfo.itemCount + 1; if (gMultiuseListMenuTemplate.totalItems > 8) gMultiuseListMenuTemplate.maxShowed = 8; else gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems; - gShopDataPtr->itemsShowed = gMultiuseListMenuTemplate.maxShowed; + sShopData->itemsShowed = gMultiuseListMenuTemplate.maxShowed; } static void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *name) { - if (gMartInfo.martType == MART_TYPE_NORMAL) + if (sMartInfo.martType == MART_TYPE_NORMAL) CopyItemName(item, name); else StringCopy(name, gDecorations[item].name); @@ -527,16 +530,16 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s if (onInit != TRUE) PlaySE(SE_SELECT); - if (item != -2) - BuyMenuAddItemIcon(item, gShopDataPtr->iconSlot); + if (item != LIST_CANCEL) + BuyMenuAddItemIcon(item, sShopData->iconSlot); else - BuyMenuAddItemIcon(-1, gShopDataPtr->iconSlot); + BuyMenuAddItemIcon(-1, sShopData->iconSlot); - BuyMenuRemoveItemIcon(item, gShopDataPtr->iconSlot ^ 1); - gShopDataPtr->iconSlot ^= 1; - if (item != -2) + BuyMenuRemoveItemIcon(item, sShopData->iconSlot ^ 1); + sShopData->iconSlot ^= 1; + if (item != LIST_CANCEL) { - if (gMartInfo.martType == MART_TYPE_NORMAL) + if (sMartInfo.martType == MART_TYPE_NORMAL) description = ItemId_GetDescription(item); else description = gDecorations[item].description; @@ -554,9 +557,9 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y) { u8 x; - if (item != -2) + if (item != LIST_CANCEL) { - if (gMartInfo.martType == MART_TYPE_NORMAL) + if (sMartInfo.martType == MART_TYPE_NORMAL) { ConvertIntToDecimalStringN( gStringVar1, @@ -581,26 +584,26 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y) static void BuyMenuAddScrollIndicatorArrows(void) { - if (gShopDataPtr->scrollIndicatorsTaskId == TASK_NONE && gMartInfo.itemCount + 1 > 8) + if (sShopData->scrollIndicatorsTaskId == TASK_NONE && sMartInfo.itemCount + 1 > 8) { - gShopDataPtr->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized( + sShopData->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized( SCROLL_ARROW_UP, - 0xAC, - 0xC, - 0x94, - gMartInfo.itemCount - 7, - 2100, - 2100, - &gShopDataPtr->scrollOffset); + 172, + 12, + 148, + sMartInfo.itemCount - 7, + TAG_SCROLL_ARROW, + TAG_SCROLL_ARROW, + &sShopData->scrollOffset); } } static void BuyMenuRemoveScrollIndicatorArrows(void) { - if (gShopDataPtr->scrollIndicatorsTaskId != TASK_NONE) + if (sShopData->scrollIndicatorsTaskId != TASK_NONE) { - RemoveScrollIndicatorArrowPair(gShopDataPtr->scrollIndicatorsTaskId); - gShopDataPtr->scrollIndicatorsTaskId = TASK_NONE; + RemoveScrollIndicatorArrowPair(sShopData->scrollIndicatorsTaskId); + sShopData->scrollIndicatorsTaskId = TASK_NONE; } } @@ -613,13 +616,13 @@ static void BuyMenuPrintCursor(u8 scrollIndicatorsTaskId, u8 colorSet) static void BuyMenuAddItemIcon(u16 item, u8 iconSlot) { u8 spriteId; - u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot]; + u8 *spriteIdPtr = &sShopData->itemSpriteIds[iconSlot]; if (*spriteIdPtr != SPRITE_NONE) return; - if (gMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF) + if (sMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF) { - spriteId = AddItemIconSprite(iconSlot + 2110, iconSlot + 2110, item); + spriteId = AddItemIconSprite(iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE, item); if (spriteId != MAX_SPRITES) { *spriteIdPtr = spriteId; @@ -629,7 +632,7 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot) } else { - spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + 2110, iconSlot + 2110); + spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE); if (spriteId != MAX_SPRITES) *spriteIdPtr = spriteId; } @@ -637,12 +640,12 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot) static void BuyMenuRemoveItemIcon(u16 item, u8 iconSlot) { - u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot]; + u8 *spriteIdPtr = &sShopData->itemSpriteIds[iconSlot]; if (*spriteIdPtr == SPRITE_NONE) return; - FreeSpriteTilesByTag(iconSlot + 2110); - FreeSpritePaletteByTag(iconSlot + 2110); + FreeSpriteTilesByTag(iconSlot + TAG_ITEM_ICON_BASE); + FreeSpritePaletteByTag(iconSlot + TAG_ITEM_ICON_BASE); DestroySprite(&gSprites[*spriteIdPtr]); *spriteIdPtr = SPRITE_NONE; } @@ -651,9 +654,9 @@ static void BuyMenuInitBgs(void) { ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sShopBuyMenuBgTemplates, ARRAY_COUNT(sShopBuyMenuBgTemplates)); - SetBgTilemapBuffer(1, gShopDataPtr->tilemapBuffers[1]); - SetBgTilemapBuffer(2, gShopDataPtr->tilemapBuffers[3]); - SetBgTilemapBuffer(3, gShopDataPtr->tilemapBuffers[2]); + SetBgTilemapBuffer(1, sShopData->tilemapBuffers[1]); + SetBgTilemapBuffer(2, sShopData->tilemapBuffers[3]); + SetBgTilemapBuffer(3, sShopData->tilemapBuffers[2]); SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0); SetGpuReg(REG_OFFSET_BG1HOFS, 0); @@ -673,7 +676,7 @@ static void BuyMenuInitBgs(void) static void BuyMenuDecompressBgGraphics(void) { DecompressAndCopyTileDataToVram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0); - LZDecompressWram(gBuyMenuFrame_Tilemap, gShopDataPtr->tilemapBuffers[0]); + LZDecompressWram(gBuyMenuFrame_Tilemap, sShopData->tilemapBuffers[0]); LoadCompressedPalette(gMenuMoneyPal, 0xC0, 0x20); } @@ -763,16 +766,16 @@ static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLaye switch (metatileLayerType) { case 0: - BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[3], offset1, offset2, src); - BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[1], offset1, offset2, src + 4); + BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src); + BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4); break; case 1: - BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[2], offset1, offset2, src); - BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[3], offset1, offset2, src + 4); + BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src); + BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src + 4); break; case 2: - BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[2], offset1, offset2, src); - BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[1], offset1, offset2, src + 4); + BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src); + BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4); break; } } @@ -796,7 +799,7 @@ static void BuyMenuCollectObjectEventData(void) GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY); for (y = 0; y < OBJECT_EVENTS_COUNT; y++) - gShopDataPtr->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT; + sShopData->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT; for (y = 0; y < 5; y++) { for (x = 0; x < 7; x++) @@ -805,25 +808,25 @@ static void BuyMenuCollectObjectEventData(void) if (objEventId != OBJECT_EVENTS_COUNT) { - gShopDataPtr->viewportObjects[r8][OBJ_EVENT_ID] = objEventId; - gShopDataPtr->viewportObjects[r8][X_COORD] = x; - gShopDataPtr->viewportObjects[r8][Y_COORD] = y; - gShopDataPtr->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y); + sShopData->viewportObjects[r8][OBJ_EVENT_ID] = objEventId; + sShopData->viewportObjects[r8][X_COORD] = x; + sShopData->viewportObjects[r8][Y_COORD] = y; + sShopData->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y); switch (gObjectEvents[objEventId].facingDirection) { case DIR_SOUTH: - gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 0; + sShopData->viewportObjects[r8][ANIM_NUM] = 0; break; case DIR_NORTH: - gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 1; + sShopData->viewportObjects[r8][ANIM_NUM] = 1; break; case DIR_WEST: - gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 2; + sShopData->viewportObjects[r8][ANIM_NUM] = 2; break; case DIR_EAST: default: - gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 3; + sShopData->viewportObjects[r8][ANIM_NUM] = 3; break; } r8++; @@ -840,25 +843,25 @@ static void BuyMenuDrawObjectEvents(void) for (i = 0; i < OBJECT_EVENTS_COUNT; i++) { - if (gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT) + if (sShopData->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT) continue; - graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId); + graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId); spriteId = AddPseudoObjectEvent( - gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId, + gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId, SpriteCallbackDummy, - (u16)gShopDataPtr->viewportObjects[i][X_COORD] * 16 + 8, - (u16)gShopDataPtr->viewportObjects[i][Y_COORD] * 16 + 48 - graphicsInfo->height / 2, + (u16)sShopData->viewportObjects[i][X_COORD] * 16 + 8, + (u16)sShopData->viewportObjects[i][Y_COORD] * 16 + 48 - graphicsInfo->height / 2, 2); - if (BuyMenuCheckIfObjectEventOverlapsMenuBg(gShopDataPtr->viewportObjects[i]) == TRUE) + if (BuyMenuCheckIfObjectEventOverlapsMenuBg(sShopData->viewportObjects[i]) == TRUE) { gSprites[spriteId].subspriteTableNum = 4; gSprites[spriteId].subspriteMode = SUBSPRITES_ON; } - StartSpriteAnim(&gSprites[spriteId], gShopDataPtr->viewportObjects[i][ANIM_NUM]); + StartSpriteAnim(&gSprites[spriteId], sShopData->viewportObjects[i][ANIM_NUM]); } } @@ -877,8 +880,8 @@ static bool8 BuyMenuCheckIfObjectEventOverlapsMenuBg(s16 *object) static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void) { s16 i; - u16 *dest = gShopDataPtr->tilemapBuffers[1]; - const u16 *src = gShopDataPtr->tilemapBuffers[0]; + u16 *dest = sShopData->tilemapBuffers[1]; + const u16 *src = sShopData->tilemapBuffers[0]; for (i = 0; i < 1024; i++) { @@ -891,7 +894,7 @@ static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void) static bool8 BuyMenuCheckForOverlapWithMenuBg(int x, int y) { - const u16 *metatile = gShopDataPtr->tilemapBuffers[0]; + const u16 *metatile = sShopData->tilemapBuffers[0]; int offset1 = x * 2; int offset2 = y * 64; @@ -913,7 +916,7 @@ static void Task_BuyMenu(u8 taskId) if (!gPaletteFade.active) { s32 itemId = ListMenu_ProcessInput(tListTaskId); - ListMenuGetScrollAndRow(tListTaskId, &gShopDataPtr->scrollOffset, &gShopDataPtr->selectedRow); + ListMenuGetScrollAndRow(tListTaskId, &sShopData->scrollOffset, &sShopData->selectedRow); switch (itemId) { @@ -930,22 +933,22 @@ static void Task_BuyMenu(u8 taskId) BuyMenuRemoveScrollIndicatorArrows(); BuyMenuPrintCursor(tListTaskId, 2); - if (gMartInfo.martType == MART_TYPE_NORMAL) + if (sMartInfo.martType == MART_TYPE_NORMAL) { - gShopDataPtr->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT)); + sShopData->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT)); } else { - gShopDataPtr->totalCost = gDecorations[itemId].price; + sShopData->totalCost = gDecorations[itemId].price; } - if (!IsEnoughMoney(&gSaveBlock1Ptr->money, gShopDataPtr->totalCost)) + if (!IsEnoughMoney(&gSaveBlock1Ptr->money, sShopData->totalCost)) { BuyMenuDisplayMessage(taskId, gText_YouDontHaveMoney, BuyMenuReturnToItemList); } else { - if (gMartInfo.martType == MART_TYPE_NORMAL) + if (sMartInfo.martType == MART_TYPE_NORMAL) { CopyItemName(itemId, gStringVar1); if (ItemId_GetPocket(itemId) == POCKET_TM_HM) @@ -961,9 +964,9 @@ static void Task_BuyMenu(u8 taskId) else { StringCopy(gStringVar1, gDecorations[itemId].name); - ConvertIntToDecimalStringN(gStringVar2, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6); + ConvertIntToDecimalStringN(gStringVar2, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6); - if (gMartInfo.martType == MART_TYPE_DECOR) + if (sMartInfo.martType == MART_TYPE_DECOR) StringExpandPlaceholders(gStringVar4, gText_Var1IsItThatllBeVar2); else // MART_TYPE_DECOR2 StringExpandPlaceholders(gStringVar4, gText_YouWantedVar1ThatllBeVar2); @@ -992,15 +995,15 @@ static void Task_BuyHowManyDialogueInit(u8 taskId) BuyMenuPrintItemQuantityAndPrice(taskId); ScheduleBgCopyTilemapToVram(0); - maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / gShopDataPtr->totalCost; + maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / sShopData->totalCost; if (maxQuantity > MAX_BAG_ITEM_CAPACITY) { - gShopDataPtr->maxQuantity = MAX_BAG_ITEM_CAPACITY; + sShopData->maxQuantity = MAX_BAG_ITEM_CAPACITY; } else { - gShopDataPtr->maxQuantity = maxQuantity; + sShopData->maxQuantity = maxQuantity; } gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput; @@ -1010,9 +1013,9 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (AdjustQuantityAccordingToDPadInput(&tItemCount, gShopDataPtr->maxQuantity) == TRUE) + if (AdjustQuantityAccordingToDPadInput(&tItemCount, sShopData->maxQuantity) == TRUE) { - gShopDataPtr->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount; + sShopData->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount; BuyMenuPrintItemQuantityAndPrice(taskId); } else @@ -1027,7 +1030,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId) PutWindowTilemap(1); CopyItemName(tItemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS); - ConvertIntToDecimalStringN(gStringVar3, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6); + ConvertIntToDecimalStringN(gStringVar3, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6); BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase); } else if (JOY_NEW(B_BUTTON)) @@ -1053,7 +1056,7 @@ static void BuyMenuTryMakePurchase(u8 taskId) PutWindowTilemap(1); - if (gMartInfo.martType == MART_TYPE_NORMAL) + if (sMartInfo.martType == MART_TYPE_NORMAL) { if (AddBagItem(tItemId, tItemCount) == TRUE) { @@ -1069,7 +1072,7 @@ static void BuyMenuTryMakePurchase(u8 taskId) { if (DecorationAdd(tItemId)) { - if (gMartInfo.martType == MART_TYPE_DECOR) + if (sMartInfo.martType == MART_TYPE_DECOR) BuyMenuDisplayMessage(taskId, gText_ThankYouIllSendItHome, BuyMenuSubtractMoney); else // MART_TYPE_DECOR2 BuyMenuDisplayMessage(taskId, gText_ThanksIllSendItHome, BuyMenuSubtractMoney); @@ -1084,11 +1087,11 @@ static void BuyMenuTryMakePurchase(u8 taskId) static void BuyMenuSubtractMoney(u8 taskId) { IncrementGameStat(GAME_STAT_SHOPPED); - RemoveMoney(&gSaveBlock1Ptr->money, gShopDataPtr->totalCost); + RemoveMoney(&gSaveBlock1Ptr->money, sShopData->totalCost); PlaySE(SE_SHOP); PrintMoneyAmountInMoneyBox(0, GetMoney(&gSaveBlock1Ptr->money), 0); - if (gMartInfo.martType == MART_TYPE_NORMAL) + if (sMartInfo.martType == MART_TYPE_NORMAL) { gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase; } @@ -1143,7 +1146,7 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId) s16 *data = gTasks[taskId].data; FillWindowPixelBuffer(4, PIXEL_FILL(1)); - PrintMoneyAmount(4, 38, 1, gShopDataPtr->totalCost, TEXT_SPEED_FF); + PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SPEED_FF); ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS); StringExpandPlaceholders(gStringVar4, gText_xVar1); BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0); @@ -1169,7 +1172,7 @@ static void Task_ExitBuyMenu(u8 taskId) static void ClearItemPurchases(void) { - gMartPurchaseHistoryId = 0; + sPurchaseHistoryId = 0; memset(gMartPurchaseHistory, 0, sizeof(gMartPurchaseHistory)); } @@ -1179,27 +1182,23 @@ static void RecordItemPurchase(u8 taskId) u16 i; - for (i = 0; i < 3; i++) + for (i = 0; i < ARRAY_COUNT(gMartPurchaseHistory); i++) { if (gMartPurchaseHistory[i].itemId == tItemId && gMartPurchaseHistory[i].quantity != 0) { if (gMartPurchaseHistory[i].quantity + tItemCount > 255) - { gMartPurchaseHistory[i].quantity = 255; - } else - { gMartPurchaseHistory[i].quantity += tItemCount; - } return; } } - if (gMartPurchaseHistoryId < 3) + if (sPurchaseHistoryId < ARRAY_COUNT(gMartPurchaseHistory)) { - gMartPurchaseHistory[gMartPurchaseHistoryId].itemId = tItemId; - gMartPurchaseHistory[gMartPurchaseHistoryId].quantity = tItemCount; - gMartPurchaseHistoryId++; + gMartPurchaseHistory[sPurchaseHistoryId].itemId = tItemId; + gMartPurchaseHistory[sPurchaseHistoryId].quantity = tItemCount; + sPurchaseHistoryId++; } } From 4077c533388d38a0ec725baf2f5f4bd858c76897 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 21 Mar 2021 00:54:24 -0400 Subject: [PATCH 07/31] A few labels in party, start, option menus --- src/data/party_menu.h | 6 ++--- src/option_menu.c | 52 ++++++++++++++++++++++++++----------------- src/start_menu.c | 46 +++++++++++++++++++++++++------------- 3 files changed, 66 insertions(+), 38 deletions(-) diff --git a/src/data/party_menu.h b/src/data/party_menu.h index daf3f4f6c7..a4a030e3fd 100644 --- a/src/data/party_menu.h +++ b/src/data/party_menu.h @@ -543,7 +543,7 @@ static const struct WindowTemplate sLevelUpStatsWindowTemplate = .baseBlock = 0x2E9, }; -static const struct WindowTemplate sUnusedWindowTemplate_08615978 = +static const struct WindowTemplate sUnusedWindowTemplate1 = { .bg = 2, .tilemapLeft = 2, @@ -554,7 +554,7 @@ static const struct WindowTemplate sUnusedWindowTemplate_08615978 = .baseBlock = 0x1DF, }; -static const struct WindowTemplate sUnusedWindowTemplate_08615980 = +static const struct WindowTemplate sUnusedWindowTemplate2 = { .bg = 2, .tilemapLeft = 0, @@ -669,7 +669,7 @@ static const u8 *const sDescriptionStringTable[] = [PARTYBOX_DESC_DONT_HAVE] = gText_DontHave, }; -static const u16 sUnused_08615B94[] = +static const u16 sUnusedData[] = { 0x0108, 0x0151, 0x0160, 0x015b, 0x002e, 0x005c, 0x0102, 0x0153, 0x014b, 0x00ed, 0x00f1, 0x010d, 0x003a, 0x003b, 0x003f, 0x0071, 0x00b6, 0x00f0, 0x00ca, 0x00db, 0x00da, 0x004c, 0x00e7, 0x0055, 0x0057, 0x0059, 0x00d8, 0x005b, 0x005e, 0x00f7, 0x0118, 0x0068, diff --git a/src/option_menu.c b/src/option_menu.c index 64e9b6576b..936aff9233 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -75,7 +75,7 @@ static u8 ButtonMode_ProcessInput(u8 selection); static void ButtonMode_DrawChoices(u8 selection); static void DrawTextOption(void); static void DrawOptionMenuTexts(void); -static void sub_80BB154(void); +static void DrawBgWindowFrames(void); EWRAM_DATA static bool8 sArrowPressed = FALSE; @@ -228,7 +228,7 @@ void CB2_InitOptionMenu(void) DrawOptionMenuTexts(); gMain.state++; case 9: - sub_80BB154(); + DrawBgWindowFrames(); gMain.state++; break; case 10: @@ -642,25 +642,37 @@ static void DrawOptionMenuTexts(void) CopyWindowToVram(WIN_OPTIONS, 3); } -static void sub_80BB154(void) +#define TILE_TOP_CORNER_L 0x1A2 +#define TILE_TOP_EDGE 0x1A3 +#define TILE_TOP_CORNER_R 0x1A4 +#define TILE_LEFT_EDGE 0x1A5 +#define TILE_RIGHT_EDGE 0x1A7 +#define TILE_BOT_CORNER_L 0x1A8 +#define TILE_BOT_EDGE 0x1A9 +#define TILE_BOT_CORNER_R 0x1AA + +static void DrawBgWindowFrames(void) { - // bg, tileNum, x, y, width, height, pal - FillBgTilemapBufferRect(1, 0x1A2, 1, 0, 1, 1, 7); - FillBgTilemapBufferRect(1, 0x1A3, 2, 0, 0x1B, 1, 7); - FillBgTilemapBufferRect(1, 0x1A4, 28, 0, 1, 1, 7); - FillBgTilemapBufferRect(1, 0x1A5, 1, 1, 1, 2, 7); - FillBgTilemapBufferRect(1, 0x1A7, 28, 1, 1, 2, 7); - FillBgTilemapBufferRect(1, 0x1A8, 1, 3, 1, 1, 7); - FillBgTilemapBufferRect(1, 0x1A9, 2, 3, 0x1B, 1, 7); - FillBgTilemapBufferRect(1, 0x1AA, 28, 3, 1, 1, 7); - FillBgTilemapBufferRect(1, 0x1A2, 1, 4, 1, 1, 7); - FillBgTilemapBufferRect(1, 0x1A3, 2, 4, 0x1A, 1, 7); - FillBgTilemapBufferRect(1, 0x1A4, 28, 4, 1, 1, 7); - FillBgTilemapBufferRect(1, 0x1A5, 1, 5, 1, 0x12, 7); - FillBgTilemapBufferRect(1, 0x1A7, 28, 5, 1, 0x12, 7); - FillBgTilemapBufferRect(1, 0x1A8, 1, 19, 1, 1, 7); - FillBgTilemapBufferRect(1, 0x1A9, 2, 19, 0x1A, 1, 7); - FillBgTilemapBufferRect(1, 0x1AA, 28, 19, 1, 1, 7); + // bg, tile, x, y, width, height, palNum + // Draw title window frame + FillBgTilemapBufferRect(1, TILE_TOP_CORNER_L, 1, 0, 1, 1, 7); + FillBgTilemapBufferRect(1, TILE_TOP_EDGE, 2, 0, 27, 1, 7); + FillBgTilemapBufferRect(1, TILE_TOP_CORNER_R, 28, 0, 1, 1, 7); + FillBgTilemapBufferRect(1, TILE_LEFT_EDGE, 1, 1, 1, 2, 7); + FillBgTilemapBufferRect(1, TILE_RIGHT_EDGE, 28, 1, 1, 2, 7); + FillBgTilemapBufferRect(1, TILE_BOT_CORNER_L, 1, 3, 1, 1, 7); + FillBgTilemapBufferRect(1, TILE_BOT_EDGE, 2, 3, 27, 1, 7); + FillBgTilemapBufferRect(1, TILE_BOT_CORNER_R, 28, 3, 1, 1, 7); + + // Draw options list window frame + FillBgTilemapBufferRect(1, TILE_TOP_CORNER_L, 1, 4, 1, 1, 7); + FillBgTilemapBufferRect(1, TILE_TOP_EDGE, 2, 4, 26, 1, 7); + FillBgTilemapBufferRect(1, TILE_TOP_CORNER_R, 28, 4, 1, 1, 7); + FillBgTilemapBufferRect(1, TILE_LEFT_EDGE, 1, 5, 1, 18, 7); + FillBgTilemapBufferRect(1, TILE_RIGHT_EDGE, 28, 5, 1, 18, 7); + FillBgTilemapBufferRect(1, TILE_BOT_CORNER_L, 1, 19, 1, 1, 7); + FillBgTilemapBufferRect(1, TILE_BOT_EDGE, 2, 19, 26, 1, 7); + FillBgTilemapBufferRect(1, TILE_BOT_CORNER_R, 28, 19, 1, 1, 7); CopyBgTilemapBufferToVram(1); } diff --git a/src/start_menu.c b/src/start_menu.c index 26a5097a65..2316b85b60 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -170,7 +170,7 @@ static const struct MenuAction sStartMenuItems[] = {gText_MenuBag, {.u8_void = StartMenuBattlePyramidBagCallback}} }; -static const struct BgTemplate sUnknown_085105A8[] = +static const struct BgTemplate sBgTemplates_LinkBattleSave[] = { { .bg = 0, @@ -183,13 +183,29 @@ static const struct BgTemplate sUnknown_085105A8[] = } }; -static const struct WindowTemplate sUnknown_085105AC[] = +static const struct WindowTemplate sWindowTemplates_LinkBattleSave[] = { - {0, 2, 0xF, 0x1A, 4, 0xF, 0x194}, + { + .bg = 0, + .tilemapLeft = 2, + .tilemapTop = 15, + .width = 26, + .height = 4, + .paletteNum = 15, + .baseBlock = 0x194 + }, DUMMY_WIN_TEMPLATE }; -static const struct WindowTemplate sSaveInfoWindowTemplate = {0, 1, 1, 0xE, 0xA, 0xF, 8}; +static const struct WindowTemplate sSaveInfoWindowTemplate = { + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 14, + .height = 10, + .paletteNum = 15, + .baseBlock = 8 +}; // Local functions static void BuildStartMenuActions(void); @@ -211,13 +227,13 @@ static void CreateStartMenuTask(TaskFunc followupFunc); static void InitSave(void); static u8 RunSaveCallback(void); static void ShowSaveMessage(const u8 *message, u8 (*saveCallback)(void)); -static void sub_80A0014(void); +static void HideSaveMessageWindow(void); static void HideSaveInfoWindow(void); static void SaveStartTimer(void); static bool8 SaveSuccesTimer(void); static bool8 SaveErrorTimer(void); static void InitBattlePyramidRetire(void); -static void sub_80A03D8(void); +static void VBlankCB_LinkBattleSave(void); static bool32 InitSaveWindowAfterLinkBattle(u8 *par1); static void CB2_SaveAfterLinkBattle(void); static void ShowSaveInfoWindow(void); @@ -887,7 +903,7 @@ static void SaveGameTask(u8 taskId) EnableBothScriptContexts(); } -static void sub_80A0014(void) +static void HideSaveMessageWindow(void) { ClearDialogWindowAndFrame(0, TRUE); } @@ -982,7 +998,7 @@ static u8 SaveConfirmInputCallback(void) case -1: // B Button case 1: // No HideSaveInfoWindow(); - sub_80A0014(); + HideSaveMessageWindow(); return SAVE_CANCELED; } @@ -1028,7 +1044,7 @@ static u8 SaveOverwriteInputCallback(void) case -1: // B Button case 1: // No HideSaveInfoWindow(); - sub_80A0014(); + HideSaveMessageWindow(); return SAVE_CANCELED; } @@ -1146,14 +1162,14 @@ static u8 BattlePyramidRetireInputCallback(void) return SAVE_CANCELED; case -1: // B Button case 1: // No - sub_80A0014(); + HideSaveMessageWindow(); return SAVE_SUCCESS; } return SAVE_IN_PROGRESS; } -static void sub_80A03D8(void) +static void VBlankCB_LinkBattleSave(void) { TransferPlttBuffer(); } @@ -1167,7 +1183,7 @@ static bool32 InitSaveWindowAfterLinkBattle(u8 *state) SetVBlankCallback(NULL); ScanlineEffect_Stop(); DmaClear16(3, PLTT, PLTT_SIZE); - DmaFillLarge16(3, 0, (void *)(VRAM + 0x0), 0x18000, 0x1000); + DmaFillLarge16(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000); break; case 1: ResetSpriteData(); @@ -1177,15 +1193,15 @@ static bool32 InitSaveWindowAfterLinkBattle(u8 *state) break; case 2: ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sUnknown_085105A8, ARRAY_COUNT(sUnknown_085105A8)); - InitWindows(sUnknown_085105AC); + InitBgsFromTemplates(0, sBgTemplates_LinkBattleSave, ARRAY_COUNT(sBgTemplates_LinkBattleSave)); + InitWindows(sWindowTemplates_LinkBattleSave); LoadUserWindowBorderGfx_(0, 8, 224); Menu_LoadStdPalAt(240); break; case 3: ShowBg(0); BlendPalettes(-1, 16, 0); - SetVBlankCallback(sub_80A03D8); + SetVBlankCallback(VBlankCB_LinkBattleSave); EnableInterrupts(1); break; case 4: From 1cc0a3506f6a3d8e75ed70299f770cdb7a01a74f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 21 Mar 2021 01:22:42 -0400 Subject: [PATCH 08/31] Label misc field effects --- ...{85B2890.pal => cave_transition_enter.pal} | 0 .../{85B28A0.pal => cave_transition_exit.pal} | 0 src/field_door.c | 58 ++++++++++--------- src/field_effect.c | 23 ++++---- src/fldeff_flash.c | 40 ++++++------- 5 files changed, 60 insertions(+), 61 deletions(-) rename graphics/misc/{85B2890.pal => cave_transition_enter.pal} (100%) rename graphics/misc/{85B28A0.pal => cave_transition_exit.pal} (100%) diff --git a/graphics/misc/85B2890.pal b/graphics/misc/cave_transition_enter.pal similarity index 100% rename from graphics/misc/85B2890.pal rename to graphics/misc/cave_transition_enter.pal diff --git a/graphics/misc/85B28A0.pal b/graphics/misc/cave_transition_exit.pal similarity index 100% rename from graphics/misc/85B28A0.pal rename to graphics/misc/cave_transition_exit.pal diff --git a/src/field_door.c b/src/field_door.c index 4dcb07ccae..8aeb1d4914 100644 --- a/src/field_door.c +++ b/src/field_door.c @@ -357,40 +357,42 @@ static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame } } -enum -{ - TD_FRAMELIST = 0, - TD_GFX = 2, - TD_FRAME = 4, - TD_COUNTER, - TD_X, - TD_Y -}; +#define tFramesHi data[0] +#define tFramesLo data[1] +#define tGfxHi data[2] +#define tGfxLo data[3] +#define tFrameId data[4] +#define tCounter data[5] +#define tX data[6] +#define tY data[7] -static bool32 sub_808A5F0(struct DoorGraphics *gfx, struct DoorAnimFrame *frames, s16 *taskData) +// Draws a single frame of the door animation, or skips drawing to wait between frames. +// Returns FALSE when the final frame has been reached +static bool32 AnimateDoorFrame(struct DoorGraphics *gfx, struct DoorAnimFrame *frames, s16 *data) { - if (taskData[TD_COUNTER] == 0) - DrawDoor(gfx, &frames[taskData[TD_FRAME]], taskData[TD_X], taskData[TD_Y]); - if (taskData[TD_COUNTER] == frames[taskData[TD_FRAME]].time) + if (tCounter == 0) + DrawDoor(gfx, &frames[tFrameId], tX, tY); + + if (tCounter == frames[tFrameId].time) { - taskData[TD_COUNTER] = 0; - taskData[TD_FRAME]++; - if (frames[taskData[TD_FRAME]].time == 0) + tCounter = 0; + tFrameId++; + if (frames[tFrameId].time == 0) return FALSE; else return TRUE; } - taskData[TD_COUNTER]++; + tCounter++; return TRUE; } static void Task_AnimateDoor(u8 taskId) { - u16 *taskData = gTasks[taskId].data; - struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(taskData[TD_FRAMELIST] << 16 | taskData[TD_FRAMELIST + 1]); - struct DoorGraphics *gfx = (struct DoorGraphics *)(taskData[TD_GFX] << 16 | taskData[TD_GFX + 1]); + u16 *data = gTasks[taskId].data; + struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(tFramesHi << 16 | tFramesLo); + struct DoorGraphics *gfx = (struct DoorGraphics *)(tGfxHi << 16 | tGfxLo); - if (sub_808A5F0(gfx, frames, taskData) == FALSE) + if (AnimateDoorFrame(gfx, frames, data) == FALSE) DestroyTask(taskId); } @@ -419,16 +421,16 @@ static s8 StartDoorAnimationTask(const struct DoorGraphics *gfx, const struct Do else { u8 taskId = CreateTask(Task_AnimateDoor, 0x50); - s16 *taskData = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; - taskData[TD_X] = x; - taskData[TD_Y] = y; + tX = x; + tY = y; - taskData[TD_FRAMELIST + 1] = (u32)frames; - taskData[TD_FRAMELIST] = (u32)frames >> 16; + tFramesLo = (u32)frames; + tFramesHi = (u32)frames >> 16; - taskData[TD_GFX + 1] = (u32)gfx; - taskData[TD_GFX] = (u32)gfx >> 16; + tGfxLo = (u32)gfx; + tGfxHi = (u32)gfx >> 16; return taskId; } diff --git a/src/field_effect.c b/src/field_effect.c index a70ef2892f..445827390a 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -480,13 +480,13 @@ static const struct Subsprite sSubsprites_HofMonitorBig[] = static const struct SubspriteTable sSubspriteTable_HofMonitorBig = subsprite_table(sSubsprites_HofMonitorBig); -const union AnimCmd gSpriteAnim_855C2CC[] = +const union AnimCmd sAnim_Static[] = { ANIMCMD_FRAME(.imageValue = 0, .duration = 1), ANIMCMD_JUMP(0) }; -const union AnimCmd gSpriteAnim_855C2D4[] = +const union AnimCmd sAnim_Flicker[] = { ANIMCMD_FRAME(.imageValue = 0, .duration = 16), ANIMCMD_FRAME(.imageValue = 1, .duration = 16), @@ -499,15 +499,16 @@ const union AnimCmd gSpriteAnim_855C2D4[] = ANIMCMD_END }; -const union AnimCmd *const gSpriteAnimTable_855C2F8[] = +// Flicker on and off, for the Pokéballs / monitors during the PokéCenter heal effect +const union AnimCmd *const sAnims_Flicker[] = { - gSpriteAnim_855C2CC, - gSpriteAnim_855C2D4 + sAnim_Static, + sAnim_Flicker }; -static const union AnimCmd *const sAnimTable_HofMonitor[] = +static const union AnimCmd *const sAnims_HofMonitor[] = { - gSpriteAnim_855C2CC + sAnim_Static }; static const struct SpriteTemplate sSpriteTemplate_PokeballGlow = @@ -515,7 +516,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokeballGlow = .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_POKEBALL_GLOW, .oam = &sOam_8x8, - .anims = gSpriteAnimTable_855C2F8, + .anims = sAnims_Flicker, .images = sPicTable_PokeballGlow, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_PokeballGlow @@ -526,7 +527,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokecenterMonitor = .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_GENERAL_0, .oam = &sOam_16x16, - .anims = gSpriteAnimTable_855C2F8, + .anims = sAnims_Flicker, .images = sPicTable_PokecenterMonitor, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_PokecenterMonitor @@ -537,7 +538,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorBig = .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR, .oam = &sOam_16x16, - .anims = sAnimTable_HofMonitor, + .anims = sAnims_HofMonitor, .images = sPicTable_HofMonitorBig, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_HallOfFameMonitor @@ -548,7 +549,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorSmall = .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR, .oam = &sOam_32x16, - .anims = sAnimTable_HofMonitor, + .anims = sAnims_HofMonitor, .images = sPicTable_HofMonitorSmall, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_HallOfFameMonitor diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index b2ddf31801..9c166d0085 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -16,7 +16,6 @@ #include "constants/songs.h" #include "constants/map_types.h" -// structures struct FlashStruct { u8 fromType; @@ -26,7 +25,6 @@ struct FlashStruct void (*func)(void); }; -// static functions static void FieldCallback_Flash(void); static void FldEff_UseFlash(void); static bool8 TryDoMapTransition(void); @@ -42,7 +40,6 @@ static void Task_EnterCaveTransition2(u8 taskId); static void Task_EnterCaveTransition3(u8 taskId); static void Task_EnterCaveTransition4(u8 taskId); -// rodata static const struct FlashStruct sTransitionTypes[] = { {MAP_TYPE_TOWN, MAP_TYPE_UNDERGROUND, TRUE, FALSE, DoEnterCaveTransition}, @@ -64,15 +61,14 @@ static const struct FlashStruct sTransitionTypes[] = {}, }; -static const u16 gCaveTransitionPalette_White[] = INCBIN_U16("graphics/misc/cave_transition_white.gbapal"); -static const u16 gCaveTransitionPalette_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal"); +static const u16 sCaveTransitionPalette_White[] = INCBIN_U16("graphics/misc/cave_transition_white.gbapal"); +static const u16 sCaveTransitionPalette_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal"); -static const u16 gUnknown_085B2890[] = INCBIN_U16("graphics/misc/85B2890.gbapal"); -static const u16 gUnknown_085B28A0[] = INCBIN_U16("graphics/misc/85B28A0.gbapal"); -static const u32 gCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz"); -static const u32 gCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz"); +static const u16 sCaveTransitionPalette_Enter[] = INCBIN_U16("graphics/misc/cave_transition_enter.gbapal"); +static const u16 sCaveTransitionPalette_Exit[] = INCBIN_U16("graphics/misc/cave_transition_exit.gbapal"); +static const u32 sCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz"); +static const u32 sCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz"); -// text bool8 SetUpFieldMove_Flash(void) { // In Ruby and Sapphire, Registeel's tomb is opened by using Fly. In Emerald, @@ -220,10 +216,10 @@ static void Task_ExitCaveTransition1(u8 taskId) static void Task_ExitCaveTransition2(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, 0); - LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000)); - LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800)); - LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20); - LoadPalette(gUnknown_085B28A0, 0xE0, 0x10); + LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000)); + LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800)); + LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20); + LoadPalette(sCaveTransitionPalette_Exit, 0xE0, 0x10); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 @@ -274,11 +270,11 @@ static void Task_ExitCaveTransition4(u8 taskId) if (count < 8) { gTasks[taskId].data[2]++; - LoadPalette(&gUnknown_085B28A0[count], 0xE0, 16 - 2 * count); + LoadPalette(&sCaveTransitionPalette_Exit[count], 0xE0, 16 - 2 * count); } else { - LoadPalette(gCaveTransitionPalette_White, 0, 0x20); + LoadPalette(sCaveTransitionPalette_White, 0, 0x20); gTasks[taskId].func = Task_ExitCaveTransition5; gTasks[taskId].data[2] = 8; } @@ -305,8 +301,8 @@ static void Task_EnterCaveTransition1(u8 taskId) static void Task_EnterCaveTransition2(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, 0); - LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000)); - LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800)); + LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000)); + LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800)); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); @@ -319,8 +315,8 @@ static void Task_EnterCaveTransition2(u8 taskId) | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON); - LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20); - LoadPalette(gCaveTransitionPalette_Black, 0, 0x20); + LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20); + LoadPalette(sCaveTransitionPalette_Black, 0, 0x20); gTasks[taskId].func = Task_EnterCaveTransition3; gTasks[taskId].data[0] = 16; gTasks[taskId].data[1] = 0; @@ -335,7 +331,7 @@ static void Task_EnterCaveTransition3(u8 taskId) { gTasks[taskId].data[2]++; gTasks[taskId].data[2]++; - LoadPalette(&gUnknown_085B2890[15 - count], 0xE0, 2 * (count + 1)); + LoadPalette(&sCaveTransitionPalette_Enter[15 - count], 0xE0, 2 * (count + 1)); } else { @@ -363,7 +359,7 @@ static void Task_EnterCaveTransition4(u8 taskId) } else { - LoadPalette(gCaveTransitionPalette_Black, 0, 0x20); + LoadPalette(sCaveTransitionPalette_Black, 0, 0x20); SetMainCallback2(gMain.savedCallback); } } From 2be0c52c173f67aa098ffff3a0bbc70d3437cd24 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 21 Mar 2021 18:19:35 -0400 Subject: [PATCH 09/31] Remaining labels in map_name_popup --- src/map_name_popup.c | 48 +++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 8939edd908..65192fa335 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -197,8 +197,8 @@ static const u8 * const gBattlePyramid_MapHeaderStrings[] = gText_Pyramid, }; -// text -bool8 sub_80D47D4(void) +// Unused +static bool8 StartMenu_ShowMapNamePopup(void) { HideStartMenu(); ShowMapNamePopup(); @@ -333,24 +333,36 @@ static void ShowMapNamePopUpWindow(void) CopyWindowToVram(GetMapNamePopUpWindowId(), 3); } -static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused) +#define TILE_TOP_EDGE_START 0x21D +#define TILE_TOP_EDGE_END 0x228 +#define TILE_LEFT_EDGE_TOP 0x229 +#define TILE_RIGHT_EDGE_TOP 0x22A +#define TILE_LEFT_EDGE_MID 0x22B +#define TILE_RIGHT_EDGE_MID 0x22C +#define TILE_LEFT_EDGE_BOT 0x22D +#define TILE_RIGHT_EDGE_BOT 0x22E +#define TILE_BOT_EDGE_START 0x22F +#define TILE_BOT_EDGE_END 0x23A + +static void DrawMapNamePopUpFrame(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused) { s32 i; - for (i = 0; i < 12; i++) - { - FillBgTilemapBufferRect(bg, 0x21D + i, i - 1 + x, y - 1, 1, 1, 0xE); - } - FillBgTilemapBufferRect(bg, 0x229, x - 1, y, 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22A, deltaX + x, y, 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22B, x - 1, y + 1 , 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22C, deltaX + x, y + 1, 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22D, x - 1, y + 2, 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22E, deltaX + x, y + 2, 1, 1, 0xE); - for (i = 0; i < 12; i++) - { - FillBgTilemapBufferRect(bg, 0x22F + i, i - 1 + x, y + deltaY, 1, 1, 0xE); - } + // Draw top edge + for (i = 0; i < 1 + TILE_TOP_EDGE_END - TILE_TOP_EDGE_START; i++) + FillBgTilemapBufferRect(bg, TILE_TOP_EDGE_START + i, i - 1 + x, y - 1, 1, 1, 14); + + // Draw sides + FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_TOP, x - 1, y, 1, 1, 14); + FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_TOP, deltaX + x, y, 1, 1, 14); + FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_MID, x - 1, y + 1, 1, 1, 14); + FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_MID, deltaX + x, y + 1, 1, 1, 14); + FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_BOT, x - 1, y + 2, 1, 1, 14); + FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_BOT, deltaX + x, y + 2, 1, 1, 14); + + // Draw bottom edge + for (i = 0; i < 1 + TILE_BOT_EDGE_END - TILE_BOT_EDGE_START; i++) + FillBgTilemapBufferRect(bg, TILE_BOT_EDGE_START + i, i - 1 + x, y + deltaY, 1, 1, 14); } static void LoadMapNamePopUpWindowBg(void) @@ -369,7 +381,7 @@ static void LoadMapNamePopUpWindowBg(void) popUpThemeId = gRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId]; LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), gMapPopUp_Outline_Table[popUpThemeId], 0x400, 0x21D); - CallWindowFunction(popupWindowId, sub_80D4A78); + CallWindowFunction(popupWindowId, DrawMapNamePopUpFrame); PutWindowTilemap(popupWindowId); if (gMapHeader.weather == WEATHER_UNDERWATER_BUBBLES) LoadPalette(&gUnknown_0857F444, 0xE0, 0x20); From 0f869fb26630cd7ec65a1873d76d144bdfaf11d4 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 21 Mar 2021 19:54:23 -0400 Subject: [PATCH 10/31] Remaining labels in trainer_card --- .../{unknown_56F18C.pal => unused.pal} | 0 src/trainer_card.c | 147 +++++++++--------- 2 files changed, 73 insertions(+), 74 deletions(-) rename graphics/trainer_card/{unknown_56F18C.pal => unused.pal} (100%) diff --git a/graphics/trainer_card/unknown_56F18C.pal b/graphics/trainer_card/unused.pal similarity index 100% rename from graphics/trainer_card/unknown_56F18C.pal rename to graphics/trainer_card/unused.pal diff --git a/src/trainer_card.c b/src/trainer_card.c index c42c16845a..91a8047df8 100755 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -80,7 +80,7 @@ struct TrainerCardData u8 cardTiles[0x2300]; u16 cardTilemapBuffer[0x1000]; u16 bgTilemapBuffer[0x1000]; - u16 var_7CA8; + u16 cardTop; u8 language; }; @@ -113,7 +113,7 @@ static void SetPlayerCardData(struct TrainerCard*, u8); static void TrainerCard_GenerateCardForLinkPlayer(struct TrainerCard*); static u8 VersionToCardType(u8); static void SetDataFromTrainerCard(void); -static void HandleGpuRegs(void); +static void InitGpuRegs(void); static void ResetGpuRegs(void); static void InitBgsAndWindows(void); static void SetTrainerCardCb2(void); @@ -158,31 +158,30 @@ static bool8 Task_DrawFlippedCardSide(struct Task* task); static bool8 Task_SetCardFlipped(struct Task* task); static bool8 Task_AnimateCardFlipUp(struct Task* task); static bool8 Task_EndCardFlip(struct Task* task); -static void sub_80C32EC(u16); +static void UpdateCardFlipRegs(u16); static void LoadMonIconGfx(void); -// const rom data -static const u32 sTrainerCardStickers_Gfx[] = INCBIN_U32("graphics/trainer_card/stickers_fr.4bpp.lz"); -static const u16 sUnused_0856F18C[] = INCBIN_U16("graphics/trainer_card/unknown_56F18C.gbapal"); -static const u16 sHoennTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star.gbapal"); -static const u16 sKantoTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star_fr.gbapal"); -static const u16 sHoennTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars.gbapal"); -static const u16 sKantoTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars_fr.gbapal"); -static const u16 sHoennTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars.gbapal"); -static const u16 sKantoTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars_fr.gbapal"); -static const u16 sHoennTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars.gbapal"); -static const u16 sKantoTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars_fr.gbapal"); +static const u32 sTrainerCardStickers_Gfx[] = INCBIN_U32("graphics/trainer_card/stickers_fr.4bpp.lz"); +static const u16 sUnused_Pal[] = INCBIN_U16("graphics/trainer_card/unused.gbapal"); +static const u16 sHoennTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star.gbapal"); +static const u16 sKantoTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star_fr.gbapal"); +static const u16 sHoennTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars.gbapal"); +static const u16 sKantoTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars_fr.gbapal"); +static const u16 sHoennTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars.gbapal"); +static const u16 sKantoTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars_fr.gbapal"); +static const u16 sHoennTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars.gbapal"); +static const u16 sKantoTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars_fr.gbapal"); static const u16 sHoennTrainerCardFemaleBg_Pal[] = INCBIN_U16("graphics/trainer_card/female_bg.gbapal"); static const u16 sKantoTrainerCardFemaleBg_Pal[] = INCBIN_U16("graphics/trainer_card/female_bg_fr.gbapal"); -static const u16 sHoennTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges.gbapal"); -static const u16 sKantoTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges_fr.gbapal"); -static const u16 sTrainerCardGold_Pal[] = INCBIN_U16("graphics/trainer_card/gold.gbapal"); -static const u16 sTrainerCardSticker1_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr1.gbapal"); -static const u16 sTrainerCardSticker2_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr2.gbapal"); -static const u16 sTrainerCardSticker3_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr3.gbapal"); -static const u16 sTrainerCardSticker4_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr4.gbapal"); -static const u32 sHoennTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges.4bpp.lz"); -static const u32 sKantoTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges_fr.4bpp.lz"); +static const u16 sHoennTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges.gbapal"); +static const u16 sKantoTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges_fr.gbapal"); +static const u16 sTrainerCardGold_Pal[] = INCBIN_U16("graphics/trainer_card/gold.gbapal"); +static const u16 sTrainerCardSticker1_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr1.gbapal"); +static const u16 sTrainerCardSticker2_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr2.gbapal"); +static const u16 sTrainerCardSticker3_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr3.gbapal"); +static const u16 sTrainerCardSticker4_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr4.gbapal"); +static const u32 sHoennTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges.4bpp.lz"); +static const u32 sKantoTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges_fr.4bpp.lz"); static const struct BgTemplate sTrainerCardBgTemplates[4] = { @@ -321,7 +320,6 @@ static bool8 (*const sTrainerCardFlipTasks[])(struct Task *) = Task_EndCardFlip, }; -// code static void VblankCb_TrainerCard(void) { LoadOam(); @@ -620,7 +618,7 @@ static void CB2_InitTrainerCard(void) gMain.state++; break; case 8: - HandleGpuRegs(); + InitGpuRegs(); gMain.state++; break; case 9: @@ -841,7 +839,7 @@ static void SetDataFromTrainerCard(void) } } -static void HandleGpuRegs(void) +static void InitGpuRegs(void) { SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); @@ -852,24 +850,23 @@ static void HandleGpuRegs(void) SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ); - SetGpuReg(REG_OFFSET_WIN0V, 160); - SetGpuReg(REG_OFFSET_WIN0H, 240); + SetGpuReg(REG_OFFSET_WIN0V, DISPLAY_HEIGHT); + SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH); if (gReceivedRemoteLinkPlayers) EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL); else EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK); } -// Part of animating card flip -static void sub_80C32EC(u16 arg0) +static void UpdateCardFlipRegs(u16 cardTop) { - s8 quotient = (arg0 + 40) / 10; + s8 blendY = (cardTop + 40) / 10; - if (quotient <= 4) - quotient = 0; - sData->flipBlendY = quotient; + if (blendY <= 4) + blendY = 0; + sData->flipBlendY = blendY; SetGpuReg(REG_OFFSET_BLDY, sData->flipBlendY); - SetGpuReg(REG_OFFSET_WIN0V, (sData->var_7CA8 * 256) | (160 - sData->var_7CA8)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(sData->cardTop, DISPLAY_HEIGHT - sData->cardTop)); } static void ResetGpuRegs(void) @@ -1578,6 +1575,7 @@ u8 GetTrainerCardStars(u8 cardId) } #define tFlipState data[0] +#define tCardTop data[1] static void FlipTrainerCard(void) { @@ -1608,41 +1606,43 @@ static bool8 Task_BeginCardFlip(struct Task* task) HideBg(3); ScanlineEffect_Stop(); ScanlineEffect_Clear(); - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[1][i] = 0; task->tFlipState++; return FALSE; } +// Note: Cannot be DISPLAY_HEIGHT / 2, or cardHeight will be 0 +#define CARD_FLIP_Y ((DISPLAY_HEIGHT / 2) - 3) + static bool8 Task_AnimateCardFlipDown(struct Task* task) { - u32 r4, r5, r10, r7, r6, var_24, r9, var; + u32 cardHeight, r5, r10, cardTop, r6, var_24, cardBottom, var; s16 i; sData->allowDMACopy = FALSE; - if (task->data[1] >= 77) - task->data[1] = 77; + if (task->tCardTop >= CARD_FLIP_Y) + task->tCardTop = CARD_FLIP_Y; else - task->data[1] += 7; + task->tCardTop += 7; - sData->var_7CA8 = task->data[1]; - sub_80C32EC(task->data[1]); + sData->cardTop = task->tCardTop; + UpdateCardFlipRegs(task->tCardTop); - // ??? - r7 = task->data[1]; - r9 = 160 - r7; - r4 = r9 - r7; - r6 = -r7 << 16; - r5 = 0xA00000 / r4; - r5 += 0xFFFF0000; + cardTop = task->tCardTop; + cardBottom = DISPLAY_HEIGHT - cardTop; + cardHeight = cardBottom - cardTop; + r6 = -cardTop << 16; + r5 = (DISPLAY_HEIGHT << 16) / cardHeight; + r5 -= 1 << 16; var_24 = r6; - var_24 += r5 * r4; - r10 = r5 / r4; + var_24 += r5 * cardHeight; + r10 = r5 / cardHeight; r5 *= 2; - for (i = 0; i < r7; i++) + for (i = 0; i < cardTop; i++) gScanlineEffectRegBuffers[0][i] = -i; - for (; i < (s16)(r9); i++) + for (; i < (s16)cardBottom; i++) { var = r6 >> 16; r6 += r5; @@ -1650,11 +1650,11 @@ static bool8 Task_AnimateCardFlipDown(struct Task* task) gScanlineEffectRegBuffers[0][i] = var; } var = var_24 >> 16; - for (; i < 160; i++) + for (; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[0][i] = var; sData->allowDMACopy = TRUE; - if (task->data[1] >= 77) + if (task->tCardTop >= CARD_FLIP_Y) task->tFlipState++; return FALSE; @@ -1736,33 +1736,32 @@ static bool8 Task_SetCardFlipped(struct Task* task) static bool8 Task_AnimateCardFlipUp(struct Task* task) { - u32 r4, r5, r10, r7, r6, var_24, r9, var; + u32 cardHeight, r5, r10, cardTop, r6, var_24, cardBottom, var; s16 i; sData->allowDMACopy = FALSE; - if (task->data[1] <= 5) - task->data[1] = 0; + if (task->tCardTop <= 5) + task->tCardTop = 0; else - task->data[1] -= 5; + task->tCardTop -= 5; - sData->var_7CA8 = task->data[1]; - sub_80C32EC(task->data[1]); + sData->cardTop = task->tCardTop; + UpdateCardFlipRegs(task->tCardTop); - // ??? - r7 = task->data[1]; - r9 = 160 - r7; - r4 = r9 - r7; - r6 = -r7 << 16; - r5 = 0xA00000 / r4; - r5 += 0xFFFF0000; + cardTop = task->tCardTop; + cardBottom = DISPLAY_HEIGHT - cardTop; + cardHeight = cardBottom - cardTop; + r6 = -cardTop << 16; + r5 = (DISPLAY_HEIGHT << 16) / cardHeight; + r5 -= 1 << 16; var_24 = r6; - var_24 += r5 * r4; - r10 = r5 / r4; + var_24 += r5 * cardHeight; + r10 = r5 / cardHeight; r5 /= 2; - for (i = 0; i < r7; i++) + for (i = 0; i < cardTop; i++) gScanlineEffectRegBuffers[0][i] = -i; - for (; i < (s16)(r9); i++) + for (; i < (s16)cardBottom; i++) { var = r6 >> 16; r6 += r5; @@ -1770,11 +1769,11 @@ static bool8 Task_AnimateCardFlipUp(struct Task* task) gScanlineEffectRegBuffers[0][i] = var; } var = var_24 >> 16; - for (; i < 160; i++) + for (; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[0][i] = var; sData->allowDMACopy = TRUE; - if (task->data[1] <= 0) + if (task->tCardTop <= 0) task->tFlipState++; return FALSE; From 7a5c6d4d869b314ce748fe2ccff493c468fa0a91 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 25 Mar 2021 13:26:22 -0400 Subject: [PATCH 11/31] Standardize Friendship/Happiness --- asm/macros/battle_script.inc | 2 +- data/battle_scripts_1.s | 2 +- include/constants/hold_effects.h | 2 +- include/constants/vars.h | 2 +- src/battle_script_commands.c | 6 +++--- src/data/items.h | 2 +- src/field_control_avatar.c | 13 +++++++------ src/pokemon.c | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 8f3d9faa54..f3664a1c40 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -941,7 +941,7 @@ .byte 0xb5 .endm - .macro happinesstodamagecalculation + .macro friendshiptodamagecalculation .byte 0xb6 .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6e0476182c..ad9576a624 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1678,7 +1678,7 @@ BattleScript_EffectReturn:: BattleScript_EffectFrustration:: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE - happinesstodamagecalculation + friendshiptodamagecalculation goto BattleScript_HitFromAtkString BattleScript_EffectPresent:: diff --git a/include/constants/hold_effects.h b/include/constants/hold_effects.h index b653f5a92f..5853f17086 100644 --- a/include/constants/hold_effects.h +++ b/include/constants/hold_effects.h @@ -28,7 +28,7 @@ #define HOLD_EFFECT_MACHO_BRACE 24 #define HOLD_EFFECT_EXP_SHARE 25 #define HOLD_EFFECT_QUICK_CLAW 26 -#define HOLD_EFFECT_HAPPINESS_UP 27 +#define HOLD_EFFECT_FRIENDSHIP_UP 27 #define HOLD_EFFECT_CURE_ATTRACT 28 #define HOLD_EFFECT_CHOICE_BAND 29 #define HOLD_EFFECT_FLINCH 30 diff --git a/include/constants/vars.h b/include/constants/vars.h index 625c37aa9c..d3d1aba87d 100644 --- a/include/constants/vars.h +++ b/include/constants/vars.h @@ -56,7 +56,7 @@ #define VAR_CYCLING_ROAD_RECORD_COLLISIONS 0x4027 #define VAR_CYCLING_ROAD_RECORD_TIME_L 0x4028 #define VAR_CYCLING_ROAD_RECORD_TIME_H 0x4029 -#define VAR_HAPPINESS_STEP_COUNTER 0x402A +#define VAR_FRIENDSHIP_STEP_COUNTER 0x402A #define VAR_POISON_STEP_COUNTER 0x402B #define VAR_RESET_RTC_ENABLE 0x402C #define VAR_ENIGMA_BERRY_AVAILABLE 0x402D diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 43c554e888..96c849cbc0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -258,7 +258,7 @@ static void Cmd_trysetperishsong(void); static void Cmd_rolloutdamagecalculation(void); static void Cmd_jumpifconfusedandstatmaxed(void); static void Cmd_furycuttercalc(void); -static void Cmd_happinesstodamagecalculation(void); +static void Cmd_friendshiptodamagecalculation(void); static void Cmd_presentdamagecalculation(void); static void Cmd_setsafeguard(void); static void Cmd_magnitudedamagecalculation(void); @@ -510,7 +510,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_rolloutdamagecalculation, //0xB3 Cmd_jumpifconfusedandstatmaxed, //0xB4 Cmd_furycuttercalc, //0xB5 - Cmd_happinesstodamagecalculation, //0xB6 + Cmd_friendshiptodamagecalculation, //0xB6 Cmd_presentdamagecalculation, //0xB7 Cmd_setsafeguard, //0xB8 Cmd_magnitudedamagecalculation, //0xB9 @@ -8471,7 +8471,7 @@ static void Cmd_furycuttercalc(void) } } -static void Cmd_happinesstodamagecalculation(void) +static void Cmd_friendshiptodamagecalculation(void) { if (gBattleMoves[gCurrentMove].effect == EFFECT_RETURN) gDynamicBasePower = 10 * (gBattleMons[gBattlerAttacker].friendship) / 25; diff --git a/src/data/items.h b/src/data/items.h index e4e7e0fbc7..fc77921860 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -2250,7 +2250,7 @@ const struct Item gItems[] = .name = _("SOOTHE BELL"), .itemId = ITEM_SOOTHE_BELL, .price = 100, - .holdEffect = HOLD_EFFECT_HAPPINESS_UP, + .holdEffect = HOLD_EFFECT_FRIENDSHIP_UP, .description = sSootheBellDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index a811901a9e..6ec280fd0d 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -67,7 +67,7 @@ static bool8 TryStartCoordEventScript(struct MapPosition *); static bool8 TryStartWarpEventScript(struct MapPosition *, u16); static bool8 TryStartMiscWalkingScripts(u16); static bool8 TryStartStepCountScript(u16); -static void UpdateHappinessStepCounter(void); +static void UpdateFriendshipStepCounter(void); static bool8 UpdatePoisonStepCounter(void); void FieldClearPlayerInput(struct FieldInput *input) @@ -542,7 +542,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) } IncrementRematchStepCounter(); - UpdateHappinessStepCounter(); + UpdateFriendshipStepCounter(); UpdateFarawayIslandStepCounter(); if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) @@ -607,14 +607,15 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) return FALSE; } -void Unref_ClearHappinessStepCounter(void) +// Unused +static void ClearFriendshipStepCounter(void) { - VarSet(VAR_HAPPINESS_STEP_COUNTER, 0); + VarSet(VAR_FRIENDSHIP_STEP_COUNTER, 0); } -static void UpdateHappinessStepCounter(void) +static void UpdateFriendshipStepCounter(void) { - u16 *ptr = GetVarPointer(VAR_HAPPINESS_STEP_COUNTER); + u16 *ptr = GetVarPointer(VAR_FRIENDSHIP_STEP_COUNTER); int i; (*ptr)++; diff --git a/src/pokemon.c b/src/pokemon.c index 2abf9cb561..5b683584be 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4649,7 +4649,7 @@ bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 item, u8 partyIndex, { \ friendshipChange = itemEffect[itemEffectParam]; \ friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL); \ - if (friendshipChange > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP) \ + if (friendshipChange > 0 && holdEffect == HOLD_EFFECT_FRIENDSHIP_UP) \ friendship += 150 * friendshipChange / 100; \ else \ friendship += friendshipChange; \ @@ -5828,7 +5828,7 @@ void AdjustFriendship(struct Pokemon *mon, u8 event) && (event != FRIENDSHIP_EVENT_LEAGUE_BATTLE || IS_LEAGUE_BATTLE)) { s8 mod = sFriendshipEventModifiers[event][friendshipLevel]; - if (mod > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP) + if (mod > 0 && holdEffect == HOLD_EFFECT_FRIENDSHIP_UP) mod = (150 * mod) / 100; friendship += mod; if (mod > 0) From 5cb8ec424764845b1cb38871586346a885601b0f Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 25 Mar 2021 09:05:58 -0400 Subject: [PATCH 12/31] Rename IsNotEventLegalMewOrDeoxys --- src/battle_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 2bf06f331b..6e1202bd12 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3949,7 +3949,7 @@ u8 GetMoveTarget(u16 move, u8 setTarget) return targetBattler; } -static bool32 IsNotEventLegalMewOrDeoxys(u8 battlerId) +static bool32 IsMonEventLegal(u8 battlerId) { if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) return TRUE; @@ -3970,7 +3970,7 @@ u8 IsMonDisobedient(void) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return 0; - if (IsNotEventLegalMewOrDeoxys(gBattlerAttacker)) // only if species is Mew or Deoxys + if (IsMonEventLegal(gBattlerAttacker)) // only false if illegal Mew or Deoxys { if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2) return 0; From c86cc8b371efa875446796fb44c7e285c4b26f70 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 5 Mar 2021 15:13:08 -0500 Subject: [PATCH 13/31] Document intro, start intro_credits/credits --- graphics/intro/intro.png | Bin 1113 -> 0 bytes graphics/intro/intro2_bgtrees2.pal | 19 - .../{intro1_bgpal.pal => scene_1/bg.pal} | 0 .../intro/{introgfx.png => scene_1/bg.png} | Bin .../bg0_map.bin} | Bin .../bg1_map.bin} | Bin .../bg2_map.bin} | Bin .../bg3_map.bin} | Bin .../{intro1_drops.pal => scene_1/drops.pal} | 0 graphics/intro/scene_1/drops_logo.png | Bin 0 -> 1064 bytes .../{intro1_flygon.png => scene_1/flygon.png} | Bin .../{intro1_eon.png => scene_1/lati.png} | Bin .../{intro1_gflogo.pal => scene_1/logo.pal} | 0 .../sparkle.png} | Bin .../{intro1_text.pal => scene_1/text.pal} | 0 .../bicycle.png} | Bin .../brendan.png} | Bin .../brendan_credits.png} | Bin .../clouds.png} | Bin .../clouds_afternoon.pal} | 0 .../{85F0CFC.pal => scene_2/clouds_bg.pal} | 0 .../clouds_bg.png} | Bin .../clouds_bg_afternoon.pal} | 0 .../clouds_bg_map.bin} | Bin .../{intro2_flygon.png => scene_2/flygon.png} | Bin .../{intro2_grass.png => scene_2/grass.png} | Bin .../grass_afternoon.pal} | 0 .../grass_map.bin} | Bin .../grass_night.pal} | 0 .../house_silhouette.png} | Bin .../intro/{85F231C.pal => scene_2/houses.pal} | 0 .../houses.png} | Bin .../houses_map.bin} | Bin .../{intro2_latias.png => scene_2/latias.png} | Bin .../{intro2_latios.png => scene_2/latios.png} | Bin .../manectric.png} | Bin .../may.png} | Bin .../may_credits.png} | Bin .../player.pal} | 0 .../torchic.png} | Bin .../{intro2_bgtrees.png => scene_2/trees.png} | Bin .../trees_afternoon.pal} | 0 .../trees_map.bin} | Bin .../trees_small.png} | Bin .../volbeat.png} | Bin graphics/intro/{intro3.pal => scene_3/bg.pal} | 0 .../bubbles.png} | Bin .../{intro3_clouds.png => scene_3/clouds.png} | Bin .../clouds1.bin} | Bin .../clouds2.bin} | Bin .../clouds2.png} | Bin .../clouds3.bin} | Bin .../clouds4.bin} | Bin .../groudon.bin} | Bin .../groudon.png} | Bin .../{intro3_kyogre.bin => scene_3/kyogre.bin} | Bin .../{intro3_kyogre.png => scene_3/kyogre.png} | Bin graphics/intro/{ => scene_3}/legend_bg.png | Bin graphics/intro/{ => scene_3}/legend_bg1.bin | Bin graphics/intro/{ => scene_3}/legend_bg2.bin | 0 .../lightning.png} | Bin .../{intro3_misc.png => scene_3/misc.png} | Bin .../{intro3_misc1.pal => scene_3/misc1.pal} | 0 .../{intro3_misc2.pal => scene_3/misc2.pal} | 0 .../pokeball.png} | Bin .../pokeball_map.bin} | Bin .../rayquaza.bin} | Bin .../rayquaza.png} | Bin .../streaks.png} | Bin .../streaks_map.bin} | Bin include/graphics.h | 16 +- include/intro_credits_graphics.h | 53 +- include/title_screen.h | 2 +- src/battle_anim_rock.c | 30 +- src/credits.c | 1168 ++++---- src/data/graphics/intro_scene.h | 68 +- src/intro.c | 2615 ++++++++++------- src/intro_credits_graphics.c | 717 ++--- src/title_screen.c | 8 +- 79 files changed, 2535 insertions(+), 2161 deletions(-) delete mode 100644 graphics/intro/intro.png delete mode 100644 graphics/intro/intro2_bgtrees2.pal rename graphics/intro/{intro1_bgpal.pal => scene_1/bg.pal} (100%) rename graphics/intro/{introgfx.png => scene_1/bg.png} (100%) rename graphics/intro/{intro1_bg0_map.bin => scene_1/bg0_map.bin} (100%) rename graphics/intro/{intro1_bg1_map.bin => scene_1/bg1_map.bin} (100%) rename graphics/intro/{intro1_bg2_map.bin => scene_1/bg2_map.bin} (100%) rename graphics/intro/{intro1_bg3_map.bin => scene_1/bg3_map.bin} (100%) rename graphics/intro/{intro1_drops.pal => scene_1/drops.pal} (100%) create mode 100644 graphics/intro/scene_1/drops_logo.png rename graphics/intro/{intro1_flygon.png => scene_1/flygon.png} (100%) rename graphics/intro/{intro1_eon.png => scene_1/lati.png} (100%) rename graphics/intro/{intro1_gflogo.pal => scene_1/logo.pal} (100%) rename graphics/intro/{intro1_sparkle.png => scene_1/sparkle.png} (100%) rename graphics/intro/{intro1_text.pal => scene_1/text.pal} (100%) rename graphics/intro/{intro2_bicycle.png => scene_2/bicycle.png} (100%) rename graphics/intro/{intro2_brendan_noturn.png => scene_2/brendan.png} (100%) rename graphics/intro/{intro2_brendan.png => scene_2/brendan_credits.png} (100%) rename graphics/intro/{intro2_bgclouds2.png => scene_2/clouds.png} (100%) rename graphics/intro/{intro2_bgclouds_afternoon.pal => scene_2/clouds_afternoon.pal} (100%) rename graphics/intro/{85F0CFC.pal => scene_2/clouds_bg.pal} (100%) rename graphics/intro/{intro2_bgclouds.png => scene_2/clouds_bg.png} (100%) rename graphics/intro/{85F0D5C.pal => scene_2/clouds_bg_afternoon.pal} (100%) rename graphics/intro/{intro2_bgclouds_map.bin => scene_2/clouds_bg_map.bin} (100%) rename graphics/intro/{intro2_flygon.png => scene_2/flygon.png} (100%) rename graphics/intro/{intro2_grass.png => scene_2/grass.png} (100%) rename graphics/intro/{intro2_grass_afternoon.pal => scene_2/grass_afternoon.pal} (100%) rename graphics/intro/{intro2_grass_map.bin => scene_2/grass_map.bin} (100%) rename graphics/intro/{intro2_grass_night.pal => scene_2/grass_night.pal} (100%) rename graphics/intro/{intro2_night.png => scene_2/house_silhouette.png} (100%) rename graphics/intro/{85F231C.pal => scene_2/houses.pal} (100%) rename graphics/intro/{intro2_bgnight.png => scene_2/houses.png} (100%) rename graphics/intro/{intro2_bgnight_map.bin => scene_2/houses_map.bin} (100%) rename graphics/intro/{intro2_latias.png => scene_2/latias.png} (100%) rename graphics/intro/{intro2_latios.png => scene_2/latios.png} (100%) rename graphics/intro/{intro2_manectric.png => scene_2/manectric.png} (100%) rename graphics/intro/{intro2_may_noturn.png => scene_2/may.png} (100%) rename graphics/intro/{intro2_may.png => scene_2/may_credits.png} (100%) rename graphics/intro/{intro2_brendan_noturn.pal => scene_2/player.pal} (100%) rename graphics/intro/{intro2_torchic.png => scene_2/torchic.png} (100%) rename graphics/intro/{intro2_bgtrees.png => scene_2/trees.png} (100%) rename graphics/intro/{intro2_bgtrees2_afternoon.pal => scene_2/trees_afternoon.pal} (100%) rename graphics/intro/{intro2_bgtrees_map.bin => scene_2/trees_map.bin} (100%) rename graphics/intro/{intro2_bgtreessmall.png => scene_2/trees_small.png} (100%) rename graphics/intro/{intro2_volbeat.png => scene_2/volbeat.png} (100%) rename graphics/intro/{intro3.pal => scene_3/bg.pal} (100%) rename graphics/intro/{intro2_bubbles.png => scene_3/bubbles.png} (100%) rename graphics/intro/{intro3_clouds.png => scene_3/clouds.png} (100%) rename graphics/intro/{intro3_clouds1.bin => scene_3/clouds1.bin} (100%) rename graphics/intro/{intro3_clouds2.bin => scene_3/clouds2.bin} (100%) rename graphics/intro/{intro3_clouds2.png => scene_3/clouds2.png} (100%) rename graphics/intro/{intro3_clouds3.bin => scene_3/clouds3.bin} (100%) rename graphics/intro/{intro3_clouds4.bin => scene_3/clouds4.bin} (100%) rename graphics/intro/{intro3_groudon.bin => scene_3/groudon.bin} (100%) rename graphics/intro/{intro3_groudon.png => scene_3/groudon.png} (100%) rename graphics/intro/{intro3_kyogre.bin => scene_3/kyogre.bin} (100%) rename graphics/intro/{intro3_kyogre.png => scene_3/kyogre.png} (100%) rename graphics/intro/{ => scene_3}/legend_bg.png (100%) rename graphics/intro/{ => scene_3}/legend_bg1.bin (100%) rename graphics/intro/{ => scene_3}/legend_bg2.bin (100%) rename graphics/intro/{intro3_lightning.png => scene_3/lightning.png} (100%) rename graphics/intro/{intro3_misc.png => scene_3/misc.png} (100%) rename graphics/intro/{intro3_misc1.pal => scene_3/misc1.pal} (100%) rename graphics/intro/{intro3_misc2.pal => scene_3/misc2.pal} (100%) rename graphics/intro/{intro3_pokeball.png => scene_3/pokeball.png} (100%) rename graphics/intro/{intro3_pokeball_map.bin => scene_3/pokeball_map.bin} (100%) rename graphics/intro/{intro3_rayquaza.bin => scene_3/rayquaza.bin} (100%) rename graphics/intro/{intro3_rayquaza.png => scene_3/rayquaza.png} (100%) rename graphics/intro/{intro3_streaks.png => scene_3/streaks.png} (100%) rename graphics/intro/{intro3_streaks_map.bin => scene_3/streaks_map.bin} (100%) diff --git a/graphics/intro/intro.png b/graphics/intro/intro.png deleted file mode 100644 index e0f28c8413a9dc7b9488ca83e13819323226ea5d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1113 zcmV-f1g86mP)~Jh|u}?gp2|5T0sL^xr`+i;F&NY)`%)f{~sKKQMsI z$D=_pz4FjHI652uRzQOS-M&65rU0#@vnhH#_&UAejj;^&9ZLpMMpTAY##jdXc|FNG#}01I z+|9}+Gyf+DzXLdTa}E37*757u3{^-Xi1LlCb>w2@YXYB=gft=^QJUv;YimZoPuraS zh<~tVS1kCzK>q#mUHd~=(YX{rOa79J=3A1lPfrq*Yf=QcCWVUhM=~>`sMP=6;`AgJ zDFWxqh2qqxm{ED-7v%h*10f}<%{#nA%}~=6mbMld?Bg0S1zm4rg2EmVkUJ%RzFJLIz+K zq60I(uh;7v=#?QO|78KZ;{H6q9u}d%YUHW}@RtzuJk0@8r(v%5_ng}dRyMbDsH`h> zsolE&>+&f$NICVUHo&H6M6hY=)$luc?T%Olowp?^bH~$_>r{&ebRHVdFLpf_vPN>>DplC@^njA0wV8U7gNL_^6KB*a@Eq;HVRh!sqx4fj?TN)7d%pALakS2TYGa8Sc{& zg1-n(m*@oVpaUU*7{dkwi^-km^|UMN;7k7=yL`7>N%a_HldgH- zGcm~cEQvK(Fm~RnJ8!Xbfs7RhGWM2{NaZ70X53?shECY5rhH2>m?aD?jx=k42_`5L zp5V0(y#|;ja8-gJLSiTlfmQ>u26#yktRSI)43q(YnrygK{vNhKKm_lCrgsjk7lT(P z&FvKOk({*>e{Uh0KML;Gxiep;=7asiPAD)!3W| zb+!j(3Uu_d+(ma*prR+63q+wJphFaL0cjK z0Ts@u{+iLo8EsjGi?St}KaZywAEdnZrbnx4xhyvCwqR8)gqRnbZG0uf)s+y%y-Qe# z+2!R_%x%(fC1#WJ^YK&^cN%?~z0I-Lq5TZzeAb$vA!h1RTY zC#kxL#@B^XJzjh}Gs~TRo-0+pn7udP^>khuU_Boh@I1mn3PegsicF4y927lDa@eFD zNW+kpqD@EJk~Hq~_@Bnj3O@PatOhr5yZNzw`eG$FU-r3pC~p8^##D$xD_@Z)88n%|8o`>oWb@&cGe%3zJ`mwZ?^?aaQ zUwtc z>ZSIPTOXO;u;*h)d~Dws>w~E8^}DmT(e1vpzi#IOeyqz5I{MdvhaDB+K)1^-Aku}K zr%b1)sEbbs=#-9%-o=Lv4*>J#aF4+O272uPpor)3ZzJi2^JviO2Velhk7+58V&LaQ zFb#4NNJ#t~CE4;r^cqR6qBM1$2m1Qo5Rp#c1}l>q4CJD}Z1A?Vps8Zc-8=?);V zo3WyO32lN{4S=mwef+j}Y7l8d zUJEq>&jw?CS1;Ev>A;o8f}Yk->ZXelfAb2sYPe2zy->eX4)k0K1`MZcBl<|wwOCSv izO4q_B_|-2K*%4|6or@?(TqX>0000> 1) & 0x7F, 12); + gIntroCredits_MovingSceneryVOffset = Sin((gTasks[taskIdC].data[TDC_5] >> 1) & 0x7F, 12); gTasks[taskIdC].data[TDC_5]++; break; case 1: - if (gUnknown_0203BD26 != 0) + if (gIntroCredits_MovingSceneryVOffset != 0) { - gUnknown_0203BD26 = Sin((gTasks[taskIdC].data[TDC_5] >> 1) & 0x7F, 12); + gIntroCredits_MovingSceneryVOffset = Sin((gTasks[taskIdC].data[TDC_5] >> 1) & 0x7F, 12); gTasks[taskIdC].data[TDC_5]++; } else @@ -1741,7 +1741,7 @@ static void sub_817624C(u8 taskIdC) if (gTasks[taskIdC].data[TDC_5] < 64) { gTasks[taskIdC].data[TDC_5]++; - gUnknown_0203BD26 = Sin(gTasks[taskIdC].data[TDC_5] & 0x7F, 20); + gIntroCredits_MovingSceneryVOffset = Sin(gTasks[taskIdC].data[TDC_5] & 0x7F, 20); } else { @@ -1769,7 +1769,7 @@ static void sub_817624C(u8 taskIdC) if (gTasks[taskIdC].data[TDC_5] > 0) { gTasks[taskIdC].data[TDC_5]--; - gUnknown_0203BD26 = Sin(gTasks[taskIdC].data[TDC_5] & 0x7F, 20); + gIntroCredits_MovingSceneryVOffset = Sin(gTasks[taskIdC].data[TDC_5] & 0x7F, 20); } else { @@ -1816,10 +1816,10 @@ static void sub_817651C(u8 taskIdE) gTasks[taskIdE].data[TDE_1] = 0x7FFF; } } - sub_817B540(0); + CycleSceneryPalette(0); break; case 1: - sub_817B540(0); + CycleSceneryPalette(0); break; case 2: if (gTasks[taskIdE].data[TDE_1] != 0x7FFF) @@ -1833,7 +1833,7 @@ static void sub_817651C(u8 taskIdE) gTasks[taskIdE].data[TDE_1] = 0x7FFF; } } - sub_817B540(1); + CycleSceneryPalette(1); break; case 3: if (gTasks[taskIdE].data[TDE_1] != 0x7FFF) @@ -1849,17 +1849,17 @@ static void sub_817651C(u8 taskIdE) gTasks[taskIdE].data[TDE_1] += 1; } } - sub_817B540(1); + CycleSceneryPalette(1); break; case 4: - sub_817B540(2); + CycleSceneryPalette(2); break; } } -static void sub_817664C(u8 data, u8 taskIdA) +static void sub_817664C(u8 scene, u8 taskIdA) { - switch (data) + switch (scene) { case 0: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1870,7 +1870,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] = CreateBicycleAnimationTask(0, 0x2000, 0x20, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(0, 0x2000, 0x20, 8); break; case 1: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1881,7 +1881,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] = CreateBicycleAnimationTask(0, 0x2000, 0x20, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(0, 0x2000, 0x20, 8); break; case 2: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1892,7 +1892,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] = CreateBicycleAnimationTask(1, 0x2000, 0x200, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(1, 0x2000, 0x200, 8); break; case 3: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1903,7 +1903,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] = CreateBicycleAnimationTask(1, 0x2000, 0x200, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(1, 0x2000, 0x200, 8); break; case 4: gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; @@ -1914,12 +1914,12 @@ 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] = CreateBicycleAnimationTask(2, 0x2000, 0x200, 8); + gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(2, 0x2000, 0x200, 8); break; } gTasks[taskIdA].data[TDA_TASK_E_ID] = CreateTask(sub_817651C, 0); - gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_0] = data; + gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_0] = scene; gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_1] = 0; gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_TASK_A_ID] = taskIdA; @@ -1930,11 +1930,11 @@ static void sub_817664C(u8 data, u8 taskIdA) gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_3] = gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]; gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_4] = 0; - if (data == 2) + if (scene == 2) gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_5] = 0x45; } -static bool8 sub_8176AB0(u8 data, u8 taskIdA) +static bool8 sub_8176AB0(u8 scene, u8 taskIdA) { u8 spriteId; @@ -1956,42 +1956,42 @@ static bool8 sub_8176AB0(u8 data, u8 taskIdA) gMain.state = 1; break; case 1: - gUnknown_0203BD24 = 34; - gUnknown_0203BD26 = 0; - sub_817B1C8(data); + gIntroCredits_MovingSceneryVBase = 34; + gIntroCredits_MovingSceneryVOffset = 0; + LoadCreditsSceneGraphics(scene); gMain.state += 1; break; case 2: if (gSaveBlock2Ptr->playerGender == MALE) { - LoadCompressedSpriteSheet(gUnknown_085F5334); - LoadCompressedSpriteSheet(gUnknown_085F53BC); - LoadCompressedSpriteSheet(gUnknown_085F5354); - LoadSpritePalettes(gUnknown_085F5384); + LoadCompressedSpriteSheet(gSpriteSheet_CreditsBrendan); + LoadCompressedSpriteSheet(gSpriteSheet_CreditsRivalMay); + LoadCompressedSpriteSheet(gSpriteSheet_CreditsBicycle); + LoadSpritePalettes(gSpritePalettes_Credits); - spriteId = intro_create_brendan_sprite(120, 46); + spriteId = CreateIntroBrendanSprite(120, 46); gTasks[taskIdA].data[TDA_PLAYER_CYCLIST] = spriteId; gSprites[spriteId].callback = sub_8176EE8; gSprites[spriteId].anims = gUnknown_085E6FD0; - spriteId = intro_create_may_sprite(272, 46); + spriteId = CreateIntroMaySprite(272, 46); gTasks[taskIdA].data[TDA_RIVAL_CYCLIST] = spriteId; gSprites[spriteId].callback = sub_8176F90; gSprites[spriteId].anims = gUnknown_085E7010; } else { - LoadCompressedSpriteSheet(gUnknown_085F5344); - LoadCompressedSpriteSheet(gUnknown_085F53AC); - LoadCompressedSpriteSheet(gUnknown_085F5354); - LoadSpritePalettes(gUnknown_085F5384); + LoadCompressedSpriteSheet(gSpriteSheet_CreditsMay); + LoadCompressedSpriteSheet(gSpriteSheet_CreditsRivalBrendan); + LoadCompressedSpriteSheet(gSpriteSheet_CreditsBicycle); + LoadSpritePalettes(gSpritePalettes_Credits); - spriteId = intro_create_may_sprite(120, 46); + spriteId = CreateIntroMaySprite(120, 46); gTasks[taskIdA].data[TDA_PLAYER_CYCLIST] = spriteId; gSprites[spriteId].callback = sub_8176EE8; gSprites[spriteId].anims = gUnknown_085E6FD0; - spriteId = intro_create_brendan_sprite(272, 46); + spriteId = CreateIntroBrendanSprite(272, 46); gTasks[taskIdA].data[TDA_RIVAL_CYCLIST] = spriteId; gSprites[spriteId].callback = sub_8176F90; gSprites[spriteId].anims = gUnknown_085E7010; @@ -1999,8 +1999,8 @@ static bool8 sub_8176AB0(u8 data, u8 taskIdA) gMain.state += 1; break; case 3: - sub_817664C(data, taskIdA); - sub_817B3A8(data); + sub_817664C(scene, taskIdA); + SetCreditsSceneBgCnt(scene); gMain.state = 0; return TRUE; } @@ -2033,7 +2033,7 @@ static void ResetCreditsTasks(u8 taskIdA) gTasks[taskIdA].data[TDA_TASK_D_ID] = 0; } - gUnknown_0203BD28 = 1; + gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_DESTROY; } static void LoadTheEndScreen(u16 arg0, u16 arg1, u16 arg2) @@ -2041,7 +2041,7 @@ static void LoadTheEndScreen(u16 arg0, u16 arg1, u16 arg2) u16 baseTile; u16 i; - LZ77UnCompVram(gCreditsCopyrightEnd_Gfx, (void *)(VRAM + arg0)); + LZ77UnCompVram(sCreditsCopyrightEnd_Gfx, (void *)(VRAM + arg0)); LoadPalette(gIntroCopyright_Pal, arg2, sizeof(gIntroCopyright_Pal)); baseTile = (arg2 / 16) << 12; @@ -2050,22 +2050,22 @@ static void LoadTheEndScreen(u16 arg0, u16 arg1, u16 arg2) ((u16 *) (VRAM + arg1))[i] = baseTile + 1; } -static u16 sub_8176D78(u8 arg0) +static u16 sub_8176D78(u8 baseTiles) { - u16 out = (arg0 & 0x3F) + 80; + u16 out = (baseTiles & 0x3F) + 80; - if (arg0 == 0xFF) + if (baseTiles == 0xFF) return 1; - if (arg0 & (1 << 7)) + if (baseTiles & (1 << 7)) out |= 1 << 11; - if (arg0 & (1 << 6)) + if (baseTiles & (1 << 6)) out |= 1 << 10; return out; } -static void sub_8176DBC(const u8 arg0[], u8 baseX, u8 baseY, u16 arg3, u16 palette) +static void sub_8176DBC(const u8 baseTiles[], u8 baseX, u8 baseY, u16 arg3, u16 palette) { u8 y, x; const u16 tileOffset = (palette / 16) << 12; @@ -2073,7 +2073,7 @@ static void sub_8176DBC(const u8 arg0[], u8 baseX, u8 baseY, u16 arg3, u16 palet for (y = 0; y < 5; y++) { for (x = 0; x < 3; x++) - ((u16 *) (VRAM + arg3 + (baseY + y) * 64))[baseX + x] = tileOffset + sub_8176D78(arg0[y * 3 + x]); + ((u16 *) (VRAM + arg3 + (baseY + y) * 64))[baseX + x] = tileOffset + sub_8176D78(baseTiles[y * 3 + x]); } } @@ -2095,7 +2095,7 @@ static void sub_8176E40(u16 arg0, u16 palette) static void sub_8176EE8(struct Sprite *sprite) { - if (gUnknown_0203BD28 != 0) + if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_MOVING) { DestroySprite(sprite); return; @@ -2132,7 +2132,7 @@ static void sub_8176EE8(struct Sprite *sprite) static void sub_8176F90(struct Sprite *sprite) { - if (gUnknown_0203BD28 != 0) + if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_MOVING) { DestroySprite(sprite); return; @@ -2151,7 +2151,7 @@ static void sub_8176F90(struct Sprite *sprite) StartSpriteAnimIfDifferent(sprite, 2); if (sprite->pos1.x > -32) sprite->pos1.x -= 2; - sprite->pos2.y = -gUnknown_0203BD26; + sprite->pos2.y = -gIntroCredits_MovingSceneryVOffset; break; case 2: sprite->data[7] += 1; @@ -2169,7 +2169,7 @@ static void sub_8176F90(struct Sprite *sprite) static void sub_8177050(struct Sprite *sprite) { - if (gUnknown_0203BD28) + if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_MOVING) { FreeAndDestroyMonPicSprite(sprite->data[6]); return; @@ -2276,7 +2276,7 @@ static u8 MakeMonSprite(u16 nationalDexNum, s16 x, s16 y, u16 position) static void sub_81772B8(struct Sprite *sprite) { - if (gSprites[sprite->data[0]].data[0] == 10 || gUnknown_0203BD28) + if (gSprites[sprite->data[0]].data[0] == 10 || gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_MOVING) { DestroySprite(sprite); return; @@ -2310,7 +2310,7 @@ static void DeterminePokemonToShow(void) // Fill the rest of the array with zeroes for (dexNum = j; dexNum < NATIONAL_DEX_COUNT; dexNum++) - sCreditsData->caughtMonIds[dexNum] = 0; + sCreditsData->caughtMonIds[dexNum] = NATIONAL_DEX_NONE; // Cap the number of pokemon we care about to NUM_MON_SLIDES, the max we show in the credits scene (-1 for the starter) sCreditsData->numCaughtMon = j; @@ -2352,7 +2352,7 @@ static void DeterminePokemonToShow(void) page = 0; } // Ensure the last pokemon is our starter - sCreditsData->monToShow[NUM_MON_SLIDES-1] = starter; + sCreditsData->monToShow[NUM_MON_SLIDES - 1] = starter; } else { @@ -2363,12 +2363,12 @@ static void DeterminePokemonToShow(void) if (dexNum < sCreditsData->numMonToShow - 1) { sCreditsData->monToShow[dexNum] = sCreditsData->monToShow[NUM_MON_SLIDES-1]; - sCreditsData->monToShow[NUM_MON_SLIDES-1] = starter; + sCreditsData->monToShow[NUM_MON_SLIDES - 1] = starter; } else { // Ensure the last pokemon is our starter - sCreditsData->monToShow[NUM_MON_SLIDES-1] = starter; + sCreditsData->monToShow[NUM_MON_SLIDES - 1] = starter; } } sCreditsData->numMonToShow = NUM_MON_SLIDES; diff --git a/src/data/graphics/intro_scene.h b/src/data/graphics/intro_scene.h index ea67c7b0d0..ab1cdcd9c2 100644 --- a/src/data/graphics/intro_scene.h +++ b/src/data/graphics/intro_scene.h @@ -1,48 +1,48 @@ -const u16 gIntro1GameFreakTextFadePal[] = INCBIN_U16("graphics/intro/intro1_text.gbapal"); // game freak text blue fade -const u16 gIntro2BrendanNoTurnPal[] = INCBIN_U16("graphics/intro/intro2_brendan_noturn.gbapal"); -const u16 gIntro3BgPal[] = INCBIN_U16("graphics/intro/intro3.gbapal"); -const u16 gIntro2VolbeatPal[] = INCBIN_U16("graphics/intro/intro2_volbeat.gbapal"); -const u16 gIntro2TorchicPal[] = INCBIN_U16("graphics/intro/intro2_torchic.gbapal"); -const u16 gIntro2ManectricPal[] = INCBIN_U16("graphics/intro/intro2_manectric.gbapal"); -const u16 gIntro2FlygonPal[] = INCBIN_U16("graphics/intro/intro2_flygon.gbapal"); +const u16 gIntro1GameFreakTextFadePal[] = INCBIN_U16("graphics/intro/scene_1/text.gbapal"); // game freak text blue fade +const u16 gIntro2PlayerPal[] = INCBIN_U16("graphics/intro/scene_2/player.gbapal"); +const u16 gIntro3BgPal[] = INCBIN_U16("graphics/intro/scene_3/bg.gbapal"); +const u16 gIntro2VolbeatPal[] = INCBIN_U16("graphics/intro/scene_2/volbeat.gbapal"); +const u16 gIntro2TorchicPal[] = INCBIN_U16("graphics/intro/scene_2/torchic.gbapal"); +const u16 gIntro2ManectricPal[] = INCBIN_U16("graphics/intro/scene_2/manectric.gbapal"); +const u16 gIntro2FlygonPal[] = INCBIN_U16("graphics/intro/scene_2/flygon.gbapal"); -const u32 gIntro2VolbeatGfx[] = INCBIN_U32("graphics/intro/intro2_volbeat.4bpp.lz"); -const u32 gIntro2TorchicGfx[] = INCBIN_U32("graphics/intro/intro2_torchic.4bpp.lz"); -const u32 gIntro2ManectricGfx[] = INCBIN_U32("graphics/intro/intro2_manectric.4bpp.lz"); -const u32 gIntro2FlygonGfx[] = INCBIN_U32("graphics/intro/intro2_flygon.4bpp.lz"); -const u32 gIntro2BrendanNoTurnGfx[] = INCBIN_U32("graphics/intro/intro2_brendan_noturn.4bpp.lz"); -const u32 gIntro2MayNoTurnGfx[] = INCBIN_U32("graphics/intro/intro2_may_noturn.4bpp.lz"); +const u32 gIntro2VolbeatGfx[] = INCBIN_U32("graphics/intro/scene_2/volbeat.4bpp.lz"); +const u32 gIntro2TorchicGfx[] = INCBIN_U32("graphics/intro/scene_2/torchic.4bpp.lz"); +const u32 gIntro2ManectricGfx[] = INCBIN_U32("graphics/intro/scene_2/manectric.4bpp.lz"); +const u32 gIntro2FlygonGfx[] = INCBIN_U32("graphics/intro/scene_2/flygon.4bpp.lz"); +const u32 gIntro2BrendanGfx[] = INCBIN_U32("graphics/intro/scene_2/brendan.4bpp.lz"); +const u32 gIntro2MayGfx[] = INCBIN_U32("graphics/intro/scene_2/may.4bpp.lz"); -const u32 gIntro3GroudonGfx[] = INCBIN_U32("graphics/intro/intro3_groudon.8bpp.lz"); -const u32 gIntro3GroudonTilemap[] = INCBIN_U32("graphics/intro/intro3_groudon.bin.lz"); +const u32 gIntro3GroudonGfx[] = INCBIN_U32("graphics/intro/scene_3/groudon.8bpp.lz"); +const u32 gIntro3GroudonTilemap[] = INCBIN_U32("graphics/intro/scene_3/groudon.bin.lz"); -const u32 gIntro3KyogreGfx[] = INCBIN_U32("graphics/intro/intro3_kyogre.8bpp.lz"); -const u32 gIntro3KyogreTilemap[] = INCBIN_U32("graphics/intro/intro3_kyogre.bin.lz"); +const u32 gIntro3KyogreGfx[] = INCBIN_U32("graphics/intro/scene_3/kyogre.8bpp.lz"); +const u32 gIntro3KyogreTilemap[] = INCBIN_U32("graphics/intro/scene_3/kyogre.bin.lz"); -const u32 gIntro3LegendBgGfx[] = INCBIN_U32("graphics/intro/legend_bg.4bpp.lz"); // groudon/kyogre/bg +const u32 gIntro3LegendBgGfx[] = INCBIN_U32("graphics/intro/scene_3/legend_bg.4bpp.lz"); // groudon/kyogre bg -const u32 gIntro3GroudonBgTilemap[] = INCBIN_U32("graphics/intro/legend_bg1.bin.lz"); -const u32 gIntro3KyogreBgTilemap[] = INCBIN_U32("graphics/intro/legend_bg2.bin.lz"); +const u32 gIntro3GroudonBgTilemap[] = INCBIN_U32("graphics/intro/scene_3/legend_bg1.bin.lz"); +const u32 gIntro3KyogreBgTilemap[] = INCBIN_U32("graphics/intro/scene_3/legend_bg2.bin.lz"); -const u32 gIntro3CloudsGfx[] = INCBIN_U32("graphics/intro/intro3_clouds.4bpp.lz"); -const u32 gIntro3Clouds1Tilemap[] = INCBIN_U32("graphics/intro/intro3_clouds1.bin.lz"); -const u32 gIntro3Clouds2Tilemap[] = INCBIN_U32("graphics/intro/intro3_clouds2.bin.lz"); -const u32 gIntro3Clouds3Tilemap[] = INCBIN_U32("graphics/intro/intro3_clouds3.bin.lz"); +const u32 gIntro3CloudsGfx[] = INCBIN_U32("graphics/intro/scene_3/clouds.4bpp.lz"); +const u32 gIntro3Clouds1Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds1.bin.lz"); +const u32 gIntro3Clouds2Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds2.bin.lz"); +const u32 gIntro3Clouds3Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds3.bin.lz"); -const u32 gIntro3LightningGfx[] = INCBIN_U32("graphics/intro/intro3_lightning.4bpp.lz"); -const u16 gIntro3LightningPal[] = INCBIN_U16("graphics/intro/intro3_lightning.gbapal"); +const u32 gIntro3LightningGfx[] = INCBIN_U32("graphics/intro/scene_3/lightning.4bpp.lz"); +const u16 gIntro3LightningPal[] = INCBIN_U16("graphics/intro/scene_3/lightning.gbapal"); -const u32 gIntro3RayquazaGfx[] = INCBIN_U32("graphics/intro/intro3_rayquaza.4bpp.lz"); -const u32 gIntro3RayquazaTilemap[] = INCBIN_U32("graphics/intro/intro3_rayquaza.bin.lz"); +const u32 gIntro3RayquazaGfx[] = INCBIN_U32("graphics/intro/scene_3/rayquaza.4bpp.lz"); +const u32 gIntro3RayquazaTilemap[] = INCBIN_U32("graphics/intro/scene_3/rayquaza.bin.lz"); const u32 gUnknown_D8C374[] = INCBIN_U32("graphics/unknown/unknown_D8C374.bin.lz"); const u32 gUnknown_D8C5C4[] = INCBIN_U32("graphics/unknown/unknown_D8C5C4.bin.lz"); -const u32 gIntro3Clouds2Gfx[] = INCBIN_U32("graphics/intro/intro3_clouds2.4bpp.lz"); //clouds 2, during the rayquaza flash -const u32 gIntro3Clouds4Tilemap[] = INCBIN_U32("graphics/intro/intro3_clouds4.bin.lz"); +const u32 gIntro3Clouds2Gfx[] = INCBIN_U32("graphics/intro/scene_3/clouds2.4bpp.lz"); // during the rayquaza flash +const u32 gIntro3Clouds4Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds4.bin.lz"); -const u32 gIntro2BubblesGfx[] = INCBIN_U32("graphics/intro/intro2_bubbles.4bpp.lz"); -const u16 gIntro2BubblesPal[] = INCBIN_U16("graphics/intro/intro2_bubbles.gbapal"); +const u32 gIntro3Bubbles_Gfx[] = INCBIN_U32("graphics/intro/scene_3/bubbles.4bpp.lz"); +const u16 gIntro3Bubbles_Pal[] = INCBIN_U16("graphics/intro/scene_3/bubbles.gbapal"); -const u32 gIntro1FlygonGfx[] = INCBIN_U32("graphics/intro/intro1_flygon.4bpp.lz"); -const u32 gIntro1SparkleGfx[] = INCBIN_U32("graphics/intro/intro1_sparkle.4bpp.lz"); +const u32 gIntro1Flygon_Gfx[] = INCBIN_U32("graphics/intro/scene_1/flygon.4bpp.lz"); +const u32 gIntro1Sparkle_Gfx[] = INCBIN_U32("graphics/intro/scene_1/sparkle.4bpp.lz"); diff --git a/src/intro.c b/src/intro.c index 376176fe44..2597e5a9e8 100644 --- a/src/intro.c +++ b/src/intro.c @@ -27,119 +27,193 @@ #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 - */ + The intro is grouped into the following scenes + Scene 0. Copyright screen + Scene 1. GF Logo, pan up over plants, Flygon silhouette goes by + Scene 2. Player biking on path, joined by Pokémon + Scene 3. A fight between Groudon/Kyogre ends with Rayquaza + + After this it progresses to the title screen +*/ + +// Scene 1 main tasks +static void Task_Scene1_Load(u8); +static void Task_Scene1_FadeIn(u8); +static void Task_Scene1_WaterDrops(u8); +static void Task_Scene1_PanUp(u8); +static void Task_Scene1_End(u8); + +// Scene 1 supplemental functions +static void IntroResetGpuRegs(void); +static u8 CreateGameFreakLogoSprites(s16, s16, s16); +static void Task_BlendLogoIn(u8); +static void Task_BlendLogoOut(u8); +static void Task_CreateSparkles(u8); +static u8 CreateWaterDrop(s16, s16, u16, u16, u16, u8); +static void SpriteCB_WaterDrop(struct Sprite *sprite); +static void SpriteCB_WaterDrop_Slide(struct Sprite *); +static void SpriteCB_WaterDrop_ReachLeafEnd(struct Sprite *); +static void SpriteCB_WaterDrop_DangleFromLeaf(struct Sprite *); +static void SpriteCB_WaterDrop_Fall(struct Sprite *); +static void SpriteCB_WaterDrop_Ripple(struct Sprite *); +static void SpriteCB_Sparkle(struct Sprite *sprite); +static void SpriteCB_LogoLetter(struct Sprite *sprite); +static void SpriteCB_GameFreakLogo(struct Sprite *sprite); +static void SpriteCB_FlygonSilhouette(struct Sprite *sprite); + +// Scene 2 main tasks +static void Task_Scene2_Load(u8); +static void Task_Scene2_CreateSprites(u8); +static void Task_Scene2_BikeRide(u8); +static void Task_Scene2_End(u8); + +// Scene 2 supplemental functions +static void SpriteCB_Torchic(struct Sprite *sprite); +static void SpriteCB_Manectric(struct Sprite *sprite); +static void SpriteCB_Volbeat(struct Sprite *sprite); +static void SpriteCB_Flygon(struct Sprite *); +static void SpriteCB_PlayerOnBicycle(struct Sprite *); + +// Scene 3 main tasks +static void Task_Scene3_Load(u8); +static void Task_Scene3_SpinPokeball(u8); +static void Task_Scene3_WaitGroudon(u8); +static void Task_Scene3_LoadGroudon(u8); +static void Task_Scene3_InitGroudonBg(u8); +static void Task_Scene3_NarrowWindow(u8); +static void Task_Scene3_EndNarrowWindow(u8); +static void Task_Scene3_StartGroudon(u8); +static void Task_Scene3_Groudon(u8); +static void Task_Scene3_LoadKyogre(u8); +static void Task_Scene3_Kyogre(u8); +static void Task_Scene3_LoadClouds1(u8); +static void Task_Scene3_LoadClouds2(u8); +static void Task_Scene3_InitClouds(u8); +static void Task_Scene3_Clouds(u8); +static void Task_Scene3_LoadLightning(u8); +static void Task_Scene3_Lightning(u8); +static void Task_Scene3_LoadRayquazaAttack(u8); +static void Task_Scene3_Rayquaza(u8); +static void Task_EndIntroMovie(u8); + +// Scene 3 supplemental functions +static void CreateGroudonRockSprites(u8); +static void CreateKyogreBubbleSprites_Body(u8); +static void CreateKyogreBubbleSprites_Fins(void); +static void Task_RayquazaAttack(u8); +static void SpriteCB_GroudonRocks(struct Sprite *); +static void SpriteCB_KyogreBubbles(struct Sprite *sprite); +static void SpriteCB_Lightning(struct Sprite *sprite); +static void SpriteCB_RayquazaOrb(struct Sprite *sprite); + +static void MainCB2_EndIntro(void); extern const struct CompressedSpriteSheet gBattleAnimPicTable[]; extern const struct CompressedSpritePalette gBattleAnimPaletteTable[]; extern const struct SpriteTemplate gAncientPowerRockSpriteTemplate[]; -//ewram -EWRAM_DATA u16 gIntroCharacterGender = 0; -EWRAM_DATA u16 gUnknown_0203BCCA = 0; -EWRAM_DATA u16 gIntroGraphicsFlygonYOffset = 0; +#define TAG_VOLBEAT 1500 +#define TAG_TORCHIC 1501 +#define TAG_MANECTRIC 1502 +#define TAG_LIGHTNING 1503 +#define TAG_BUBBLES 1504 +#define TAG_SPARKLE 1505 + +#define GFXTAG_DROPS_LOGO 2000 +#define PALTAG_DROPS 2000 +#define PALTAG_LOGO 2001 + +#define TAG_FLYGON_SILHOUETTE 2002 +#define TAG_RAYQUAZA_ORB 2003 + +#define COLOSSEUM_GAME_CODE 0x65366347 // "Gc6e" in ASCII + +// Used by various tasks and sprites +#define tState data[0] +#define sState data[0] + +/* + gIntroFrameCounter is used as a persistent timer throughout the + intro cinematic. At various points it's used to determine when + to trigger actions or progress through the cutscene. + The values for these are defined contiguously below. +*/ +#define TIMER_BIG_DROP_START 76 +#define TIMER_LOGO_APPEAR 128 +#define TIMER_LOGO_LETTERS_COLOR 144 +#define TIMER_BIG_DROP_FALLS 251 +#define TIMER_LOGO_BLEND_OUT 256 +#define TIMER_LOGO_DISAPPEAR 272 +#define TIMER_SMALL_DROP_1 368 +#define TIMER_SMALL_DROP_2 384 +#define TIMER_SPARKLES 560 +#define TIMER_FLYGON_SILHOUETTE_APPEAR 832 +#define TIMER_END_PAN_UP 904 +#define TIMER_END_SCENE_1 1007 +#define TIMER_START_SCENE_2 1026 +#define TIMER_MANECTRIC_ENTER 1088 +#define TIMER_PLAYER_DRIFT_BACK 1109 +#define TIMER_MANECTRIC_RUN_CIRCULAR 1168 +#define TIMER_PLAYER_MOVE_FORWARD 1214 +#define TIMER_TORCHIC_ENTER 1224 +#define TIMER_FLYGON_ENTER 1394 +#define TIMER_PLAYER_MOVE_BACKWARD 1398 +#define TIMER_PLAYER_HOLD_POSITION 1576 +#define TIMER_PLAYER_EXIT 1727 +#define TIMER_TORCHIC_SPEED_UP 1735 +#define TIMER_TORCHIC_EXIT 1856 +#define TIMER_END_SCENE_2 1946 +#define TIMER_START_SCENE_3 2068 +// timer is reset for scene 3 +#define TIMER_POKEBALL_FADE 28 +#define TIMER_START_LEGENDARIES 43 + +static EWRAM_DATA u16 sIntroCharacterGender = 0; +static EWRAM_DATA u16 sUnusedVar = 0; +static EWRAM_DATA u16 sFlygonYOffset = 0; -//iwram u32 gIntroFrameCounter; struct GcmbStruct gMultibootProgramStruct; -//.rodata -static const u16 gIntro1DropsPal[] = INCBIN_U16("graphics/intro/intro1_drops.gbapal"); -static const u16 gIntro1GFLogoPal[] = INCBIN_U16("graphics/intro/intro1_gflogo.gbapal"); -static const u32 gIntroTiles[] = INCBIN_U32("graphics/intro/intro.4bpp.lz"); -static const u16 gIntro1BGPals[16][16] = INCBIN_U16("graphics/intro/intro1_bgpal.gbapal"); -static const u32 gIntro1BG0_Tilemap[] = INCBIN_U32("graphics/intro/intro1_bg0_map.bin.lz"); -static const u32 gIntro1BG1_Tilemap[] = INCBIN_U32("graphics/intro/intro1_bg1_map.bin.lz"); -static const u32 gIntro1BG2_Tilemap[] = INCBIN_U32("graphics/intro/intro1_bg2_map.bin.lz"); -static const u32 gIntro1BG3_Tilemap[] = INCBIN_U32("graphics/intro/intro1_bg3_map.bin.lz"); -static const u32 gIntro1BGLeavesGfx[] = INCBIN_U32("graphics/intro/introgfx.4bpp.lz"); -static const u16 gIntro3PokeballPal[] = INCBIN_U16("graphics/intro/intro3_pokeball.gbapal"); -static const u32 gIntro3Pokeball_Tilemap[] = INCBIN_U32("graphics/intro/intro3_pokeball_map.bin.lz"); -static const u32 gIntro3Pokeball_Gfx[] = INCBIN_U32("graphics/intro/intro3_pokeball.8bpp.lz"); -static const u16 gIntro3Streaks_Pal_Unused[] = INCBIN_U16("graphics/intro/intro3_streaks.gbapal"); -static const u32 gIntro3Streaks_Gfx_Unused[] = INCBIN_U32("graphics/intro/intro3_streaks.4bpp.lz"); -static const u32 gIntro3Streaks_Tilemap_Unused[] = INCBIN_U32("graphics/intro/intro3_streaks_map.bin.lz"); -static const u16 gIntro3Misc1Palette[] = INCBIN_U16("graphics/intro/intro3_misc1.gbapal"); -static const u16 gIntro3Misc2Palette_Unused[] = INCBIN_U16("graphics/intro/intro3_misc2.gbapal"); -static const u32 gIntro3MiscTiles[] = INCBIN_U32("graphics/intro/intro3_misc.4bpp.lz"); -static const u16 gIntro1FlygonPalette[] = INCBIN_U16("graphics/intro/intro1_flygon.gbapal"); -static const u32 gIntro1EonTiles_Unused[] = INCBIN_U32("graphics/intro/intro1_eon.4bpp.lz"); -static const u8 sUnknownBytes[] = { +static const u16 sIntro1DropsPal[] = INCBIN_U16("graphics/intro/scene_1/drops.gbapal"); +static const u16 sIntro1Logo_Pal[] = INCBIN_U16("graphics/intro/scene_1/logo.gbapal"); +static const u32 sIntro1DropsLogo_Gfx[] = INCBIN_U32("graphics/intro/scene_1/drops_logo.4bpp.lz"); +static const u16 sIntro1Bg_Pal[16][16] = INCBIN_U16("graphics/intro/scene_1/bg.gbapal"); +static const u32 sIntro1Bg0_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg0_map.bin.lz"); +static const u32 sIntro1Bg1_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg1_map.bin.lz"); +static const u32 sIntro1Bg2_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg2_map.bin.lz"); +static const u32 sIntro1Bg3_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg3_map.bin.lz"); +static const u32 sIntro1Bg_Gfx[] = INCBIN_U32("graphics/intro/scene_1/bg.4bpp.lz"); +static const u16 sIntro3Pokeball_Pal[] = INCBIN_U16("graphics/intro/scene_3/pokeball.gbapal"); +static const u32 sIntro3Pokeball_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/pokeball_map.bin.lz"); +static const u32 sIntro3Pokeball_Gfx[] = INCBIN_U32("graphics/intro/scene_3/pokeball.8bpp.lz"); +static const u16 sIntro3Streaks_Pal[] = INCBIN_U16("graphics/intro/scene_3/streaks.gbapal"); // Unused +static const u32 sIntro3Streaks_Gfx[] = INCBIN_U32("graphics/intro/scene_3/streaks.4bpp.lz"); // Unused +static const u32 sIntro3Streaks_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/streaks_map.bin.lz"); // Unused +static const u16 sIntro3Misc1_Pal[] = INCBIN_U16("graphics/intro/scene_3/misc1.gbapal"); +static const u16 sIntro3Misc2_Pal[] = INCBIN_U16("graphics/intro/scene_3/misc2.gbapal"); // Unused +static const u32 sIntro3Misc_Gfx[] = INCBIN_U32("graphics/intro/scene_3/misc.4bpp.lz"); +static const u16 sIntro1Flygon_Pal[] = INCBIN_U16("graphics/intro/scene_1/flygon.gbapal"); +static const u32 sIntro1Lati_Gfx[] = INCBIN_U32("graphics/intro/scene_1/lati.4bpp.lz"); // Unused +static const u8 sUnusedData[] = { 0x02, 0x03, 0x04, 0x05, 0x01, 0x01, 0x01, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x02, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x02, 0x0D, 0x0E, 0x0F, 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 gIntroSpriteSheet_Sparkle[] = +static const struct CompressedSpriteSheet sSpriteSheet_Sparkle[] = { - {gIntro1SparkleGfx, 0x400, 1505}, - {NULL}, + {gIntro1Sparkle_Gfx, 0x400, TAG_SPARKLE}, + {}, }; -static const struct SpritePalette gIntroPalette_Lightning[] = +static const struct SpritePalette sSpritePalette_Sparkle[] = { - {gIntro3LightningPal, 1505}, - {NULL}, + {gIntro3LightningPal, TAG_SPARKLE}, // Lightning palette re-used + {}, }; -static const struct OamData gUnknown_085E4A94 = +static const struct OamData sOamData_Sparkle = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -153,7 +227,7 @@ static const struct OamData gUnknown_085E4A94 = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4A9C[] = +static const union AnimCmd sAnim_Sparkle[] = { ANIMCMD_FRAME(0, 2), ANIMCMD_FRAME(4, 2), @@ -162,53 +236,52 @@ static const union AnimCmd gUnknown_085E4A9C[] = ANIMCMD_FRAME(16, 2), ANIMCMD_JUMP(0), }; -static const union AnimCmd *const gUnknown_085E4AB4[] = +static const union AnimCmd *const sAnims_Sparkle[] = { - gUnknown_085E4A9C, + sAnim_Sparkle, }; -static void sub_816D338(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4AB8 = +static const struct SpriteTemplate sSpriteTemplate_Sparkle = { - .tileTag = 1505, - .paletteTag = 1505, - .oam = &gUnknown_085E4A94, - .anims = gUnknown_085E4AB4, + .tileTag = TAG_SPARKLE, + .paletteTag = TAG_SPARKLE, + .oam = &sOamData_Sparkle, + .anims = sAnims_Sparkle, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816D338, + .callback = SpriteCB_Sparkle, }; -static const u8 gUnknown_085E4AD0[][2] = +static const u8 sSparkleCoords[][2] = { - {0x7C, 0x28}, - {0x66, 0x1E}, - {0x4D, 0x1E}, - {0x36, 0x0F}, - {0x94, 0x09}, - {0x3F, 0x1C}, - {0x5D, 0x28}, - {0x94, 0x20}, - {0xAD, 0x29}, - {0x5E, 0x14}, - {0xD0, 0x26}, - {0x00, 0x00}, + {124, 40}, + {102, 30}, + { 77, 30}, + { 54, 15}, + {148, 9}, + { 63, 28}, + { 93, 40}, + {148, 32}, + {173, 41}, + { 94, 20}, + {208, 38}, + {}, }; -static const struct CompressedSpriteSheet gIntroPokemonRunningSpriteSheet[] = +static const struct CompressedSpriteSheet sSpriteSheet_RunningPokemon[] = { - {gIntro2VolbeatGfx, 0x400, 1500}, - {gIntro2TorchicGfx, 0xC00, 1501}, - {gIntro2ManectricGfx, 0x2000, 1502}, - {NULL}, + {gIntro2VolbeatGfx, 0x400, TAG_VOLBEAT}, + {gIntro2TorchicGfx, 0xC00, TAG_TORCHIC}, + {gIntro2ManectricGfx, 0x2000, TAG_MANECTRIC}, + {}, }; -static const struct SpritePalette gIntroPokemonRunningPalette[] = +static const struct SpritePalette sSpritePalettes_RunningPokemon[] = { - {gIntro2VolbeatPal, 1500}, - {gIntro2TorchicPal, 1501}, - {gIntro2ManectricPal, 1502}, - {NULL}, + {gIntro2VolbeatPal, TAG_VOLBEAT}, + {gIntro2TorchicPal, TAG_TORCHIC}, + {gIntro2ManectricPal, TAG_MANECTRIC}, + {}, }; -static const struct OamData gUnknown_085E4B28 = +static const struct OamData sOamData_Volbeat = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -222,30 +295,29 @@ static const struct OamData gUnknown_085E4B28 = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4B30[] = +static const union AnimCmd sAnim_Volbeat[] = { ANIMCMD_FRAME(0, 2), ANIMCMD_FRAME(16, 2), ANIMCMD_JUMP(0), }; -static const union AnimCmd *const gUnknown_085E4B3C[] = +static const union AnimCmd *const sAnims_Volbeat[] = { - gUnknown_085E4B30, + sAnim_Volbeat, }; -static void sub_816D81C(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4B40 = +static const struct SpriteTemplate sSpriteTemplate_Volbeat = { - .tileTag = 1500, - .paletteTag = 1500, - .oam = &gUnknown_085E4B28, - .anims = gUnknown_085E4B3C, + .tileTag = TAG_VOLBEAT, + .paletteTag = TAG_VOLBEAT, + .oam = &sOamData_Volbeat, + .anims = sAnims_Volbeat, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816D81C, + .callback = SpriteCB_Volbeat, }; -static const struct OamData gUnknown_085E4B58 = +static const struct OamData sOamData_Torchic = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -259,7 +331,7 @@ static const struct OamData gUnknown_085E4B58 = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4B60[] = +static const union AnimCmd sAnim_Torchic_Walk[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_FRAME(16, 5), @@ -267,7 +339,7 @@ static const union AnimCmd gUnknown_085E4B60[] = ANIMCMD_FRAME(16, 5), ANIMCMD_JUMP(0), }; -static const union AnimCmd gUnknown_085E4B74[] = +static const union AnimCmd sAnim_Torchic_Run[] = { ANIMCMD_FRAME(0, 3), ANIMCMD_FRAME(16, 3), @@ -275,33 +347,37 @@ static const union AnimCmd gUnknown_085E4B74[] = ANIMCMD_FRAME(16, 3), ANIMCMD_JUMP(0), }; -static const union AnimCmd gUnknown_085E4B88[] = +static const union AnimCmd sAnim_Torchic_Trip[] = { ANIMCMD_FRAME(48, 4), ANIMCMD_FRAME(64, 6), ANIMCMD_FRAME(80, 0), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E4B98[] = -{ - gUnknown_085E4B60, - gUnknown_085E4B74, - gUnknown_085E4B88, +enum { + TORCHIC_ANIM_WALK, + TORCHIC_ANIM_RUN, + TORCHIC_ANIM_TRIP, }; -static void sub_816D9C0(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4BA4 = +static const union AnimCmd *const sAnims_Torchic[] = { - .tileTag = 1501, - .paletteTag = 1501, - .oam = &gUnknown_085E4B58, - .anims = gUnknown_085E4B98, + [TORCHIC_ANIM_WALK] = sAnim_Torchic_Walk, + [TORCHIC_ANIM_RUN] = sAnim_Torchic_Run, + [TORCHIC_ANIM_TRIP] = sAnim_Torchic_Trip, +}; +static const struct SpriteTemplate sSpriteTemplate_Torchic = +{ + .tileTag = TAG_TORCHIC, + .paletteTag = TAG_TORCHIC, + .oam = &sOamData_Torchic, + .anims = sAnims_Torchic, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816D9C0, + .callback = SpriteCB_Torchic, }; -static const struct OamData gUnknown_085E4BBC = +static const struct OamData sOamData_Manectric = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -315,7 +391,7 @@ static const struct OamData gUnknown_085E4BBC = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4BC4[] = +static const union AnimCmd sAnim_Manectric[] = { ANIMCMD_FRAME(0, 4), ANIMCMD_FRAME(64, 4), @@ -323,34 +399,33 @@ static const union AnimCmd gUnknown_085E4BC4[] = ANIMCMD_FRAME(192, 4), ANIMCMD_JUMP(0), }; -static const union AnimCmd *const gUnknown_085E4BD8[] = +static const union AnimCmd *const sAnims_Manectric[] = { - gUnknown_085E4BC4, + sAnim_Manectric, }; -static void sub_816DAE8(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4BDC = +static const struct SpriteTemplate sSpriteTemplate_Manectric = { - .tileTag = 1502, - .paletteTag = 1502, - .oam = &gUnknown_085E4BBC, - .anims = gUnknown_085E4BD8, + .tileTag = TAG_MANECTRIC, + .paletteTag = TAG_MANECTRIC, + .oam = &sOamData_Manectric, + .anims = sAnims_Manectric, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816DAE8, + .callback = SpriteCB_Manectric, }; -static const struct CompressedSpriteSheet gIntroRayquazaLightningSpriteSheet[] = +static const struct CompressedSpriteSheet sSpriteSheet_Lightning[] = { - {gIntro3LightningGfx, 0xC00, 1503}, - {NULL}, + {gIntro3LightningGfx, 0xC00, TAG_LIGHTNING}, + {}, }; -static const struct SpritePalette gIntroRayquazaLightningPalette[] = +static const struct SpritePalette sSpritePalette_Lightning[] = { - {gIntro3LightningPal, 1503}, - {NULL}, + {gIntro3LightningPal, TAG_LIGHTNING}, + {}, }; -static const struct OamData gUnknown_085E4C14 = +static const struct OamData sOamData_Lightning = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -364,78 +439,84 @@ static const struct OamData gUnknown_085E4C14 = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4C1C[] = +static const union AnimCmd sAnim_Lightning_Top[] = { ANIMCMD_FRAME(0, 2), ANIMCMD_FRAME(48, 2), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4C28[] = +static const union AnimCmd sAnim_Lightning_Middle[] = { ANIMCMD_FRAME(16, 2), ANIMCMD_FRAME(64, 2), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4C34[] = +static const union AnimCmd sAnim_Lightning_Bottom[] = { ANIMCMD_FRAME(32, 2), ANIMCMD_FRAME(80, 2), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E4C40[] = +static const union AnimCmd *const sAnims_Lightning[] = { - gUnknown_085E4C1C, - gUnknown_085E4C28, - gUnknown_085E4C34, + sAnim_Lightning_Top, + sAnim_Lightning_Middle, + sAnim_Lightning_Bottom, }; -static void SpriteCB_IntroRayquazaLightning(struct Sprite *sprite); -static const struct SpriteTemplate gIntroLightningSprite = +static const struct SpriteTemplate sSpriteTemplate_Lightning = { - .tileTag = 1503, - .paletteTag = 1503, - .oam = &gUnknown_085E4C14, - .anims = gUnknown_085E4C40, + .tileTag = TAG_LIGHTNING, + .paletteTag = TAG_LIGHTNING, + .oam = &sOamData_Lightning, + .anims = sAnims_Lightning, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_IntroRayquazaLightning, + .callback = SpriteCB_Lightning, }; -static const s16 gIntroGroudonRockData[][3] = +// x coord, anim number, speed +// Smaller anim numbers are larger rocks, and are given slower speeds +static const s16 sGroudonRockData[][3] = { - {0x68, 0x00, 0x0C0}, - {0x8E, 0x03, 0x280}, - {0x53, 0x01, 0x180}, - {0x9B, 0x00, 0x080}, - {0x38, 0x02, 0x200}, - {0xAE, 0x01, 0x100}, + {104, 0, 0x0C0}, + {142, 3, 0x280}, + { 83, 1, 0x180}, + {155, 0, 0x080}, + { 56, 2, 0x200}, + {174, 1, 0x100}, }; -static const struct CompressedSpriteSheet gUnknown_085E4C88[] = +static const struct CompressedSpriteSheet sSpriteSheet_Bubbles[] = { - {gIntro2BubblesGfx, 0x600, 1504}, - {NULL}, + {gIntro3Bubbles_Gfx, 0x600, TAG_BUBBLES}, + {}, }; -static const struct SpritePalette gUnknown_085E4C98[] = +static const struct SpritePalette sSpritePalette_Bubbles[] = { - {gIntro2BubblesPal, 1504}, - {NULL}, + {gIntro3Bubbles_Pal, TAG_BUBBLES}, + {}, }; -static const s16 gIntroKyogreBubbleData[][3] = +#define NUM_BUBBLES_IN_SET 6 +// x coord, y coord, delay before animation +// Can be produced in two different sets depending on the function called to create the sprites +static const s16 sKyogreBubbleData[NUM_BUBBLES_IN_SET * 2][3] = { - {0x42, 0x40, 0x1}, - {0x60, 0x60, 0x8}, - {0x80, 0x40, 0x1}, - {0x90, 0x30, 0x8}, - {0xA0, 0x48, 0x1}, - {0xB0, 0x60, 0x8}, - {0x60, 0x60, 0x4}, - {0x70, 0x68, 0x8}, - {0x80, 0x60, 0x4}, - {0x58, 0x20, 0x4}, - {0x68, 0x18, 0x8}, - {0x78, 0x20, 0x4}, + // Set 1, for Kyogre's body + { 66, 64, 1}, + { 96, 96, 8}, + {128, 64, 1}, + {144, 48, 8}, + {160, 72, 1}, + {176, 96, 8}, + // Set 2, for Kyogre's fins + { 96, 96, 4}, + {112, 104, 8}, + {128, 96, 4}, + { 88, 32, 4}, + {104, 24, 8}, + {120, 32, 4}, }; -static const struct OamData gUnknown_085E4CF0 = +static const struct OamData sOamData_Bubbles = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -449,7 +530,7 @@ static const struct OamData gUnknown_085E4CF0 = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4CF8[] = +static const union AnimCmd sAnim_Bubbles[] = { ANIMCMD_FRAME(0, 4), ANIMCMD_FRAME(8, 4), @@ -458,24 +539,23 @@ static const union AnimCmd gUnknown_085E4CF8[] = ANIMCMD_FRAME(32, 4), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E4D10[] = +static const union AnimCmd *const sAnims_Bubbles[] = { - gUnknown_085E4CF8, + sAnim_Bubbles, }; -static void SpriteCB_IntroKyogreBubbles(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4D14 = +static const struct SpriteTemplate sSpriteTemplate_Bubbles = { - .tileTag = 1504, - .paletteTag = 1504, - .oam = &gUnknown_085E4CF0, - .anims = gUnknown_085E4D10, + .tileTag = TAG_BUBBLES, + .paletteTag = TAG_BUBBLES, + .oam = &sOamData_Bubbles, + .anims = sAnims_Bubbles, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_IntroKyogreBubbles, + .callback = SpriteCB_KyogreBubbles, }; -static const struct OamData gUnknown_085E4D2C = +static const struct OamData sOamData_WaterDrop = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -489,45 +569,50 @@ static const struct OamData gUnknown_085E4D2C = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4D34[] = +enum { + DROP_ANIM_UPPER_HALF, + DROP_ANIM_LOWER_HALF, + DROP_ANIM_REFLECTION, + DROP_ANIM_RIPPLE, +}; +static const union AnimCmd sAnim_WaterDrop_UpperHalf[] = { ANIMCMD_FRAME(16, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4D3C[] = +static const union AnimCmd sAnim_WaterDrop_LowerHalf[] = { ANIMCMD_FRAME(24, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4D44[] = +static const union AnimCmd sAnim_WaterDrop_Reflection[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4D4C[] = +static const union AnimCmd sAnim_WaterDrop_Ripple[] = { ANIMCMD_FRAME(48, 8), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E4D54[] = +static const union AnimCmd *const sAnims_WaterDrop[] = { - gUnknown_085E4D34, - gUnknown_085E4D3C, - gUnknown_085E4D44, - gUnknown_085E4D4C, + [DROP_ANIM_UPPER_HALF] = sAnim_WaterDrop_UpperHalf, + [DROP_ANIM_LOWER_HALF] = sAnim_WaterDrop_LowerHalf, + [DROP_ANIM_REFLECTION] = sAnim_WaterDrop_Reflection, + [DROP_ANIM_RIPPLE] = sAnim_WaterDrop_Ripple, }; -static void sub_816F454(struct Sprite *sprite); -static const struct SpriteTemplate gIntroWaterDropSprite = +static const struct SpriteTemplate sSpriteTemplate_WaterDrop = { - .tileTag = 2000, - .paletteTag = 2000, - .oam = &gUnknown_085E4D2C, - .anims = gUnknown_085E4D54, + .tileTag = GFXTAG_DROPS_LOGO, + .paletteTag = PALTAG_DROPS, + .oam = &sOamData_WaterDrop, + .anims = sAnims_WaterDrop, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816F454, + .callback = SpriteCB_WaterDrop, }; -static const union AnimCmd gUnknown_085E4D7C[] = +static const union AnimCmd sAnim_PlayerBicycle_Fast[] = { ANIMCMD_FRAME(0, 4), ANIMCMD_FRAME(64, 4), @@ -535,7 +620,7 @@ static const union AnimCmd gUnknown_085E4D7C[] = ANIMCMD_FRAME(192, 4), ANIMCMD_JUMP(0), }; -static const union AnimCmd gUnknown_085E4D90[] = +static const union AnimCmd sAnim_PlayerBicycle_Slow[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(64, 8), @@ -543,30 +628,36 @@ static const union AnimCmd gUnknown_085E4D90[] = ANIMCMD_FRAME(192, 8), ANIMCMD_JUMP(0), }; -static const union AnimCmd gUnknown_085E4DA4[] = +// The below two animations appear to be copied from the Credits version +// of the player graphic, where additional frames are present to show +// the player turning around to look at their rival. +// They go unused here, and if they were used they'd overflow beyond +// the player graphics data. +// The above sAnim_PlayerBicycle_Slow, while valid, is likewise unused +static const union AnimCmd sAnim_PlayerBicycle_LookBack[] = { ANIMCMD_FRAME(256, 4), - ANIMCMD_FRAME(0x140, 4), - ANIMCMD_FRAME(0x180, 4), + ANIMCMD_FRAME(320, 4), + ANIMCMD_FRAME(384, 4), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4DB4[] = +static const union AnimCmd sAnim_PlayerBicycle_LookForward[] = { - ANIMCMD_FRAME(0x180, 16), - ANIMCMD_FRAME(0x140, 16), + ANIMCMD_FRAME(384, 16), + ANIMCMD_FRAME(320, 16), ANIMCMD_FRAME(256, 16), ANIMCMD_END, }; -static const union AnimCmd *const gIntroBicycleAnimationCommands[] = +static const union AnimCmd *const sAnims_PlayerBicycle[] = { - gUnknown_085E4D7C, - gUnknown_085E4D90, - gUnknown_085E4DA4, - gUnknown_085E4DB4, + sAnim_PlayerBicycle_Fast, + sAnim_PlayerBicycle_Slow, + sAnim_PlayerBicycle_LookBack, + sAnim_PlayerBicycle_LookForward, }; -static const struct OamData gUnknown_085E4DD4 = +static const struct OamData sOamData_GameFreakLetter = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_DOUBLE, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -580,9 +671,9 @@ static const struct OamData gUnknown_085E4DD4 = .paletteNum = 0, .affineParam = 0, }; -static const struct OamData gUnknown_085E4DDC = +static const struct OamData sOamData_PresentsLetter = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -596,9 +687,9 @@ static const struct OamData gUnknown_085E4DDC = .paletteNum = 0, .affineParam = 0, }; -static const struct OamData gUnknown_085E4DE4 = +static const struct OamData sOamData_GameFreakLogo = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_DOUBLE, .objMode = ST_OAM_OBJ_BLEND, .mosaic = 0, @@ -612,193 +703,232 @@ static const struct OamData gUnknown_085E4DE4 = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4DEC[] = +static const union AnimCmd sAnim_GameFreakLetter_G[] = { ANIMCMD_FRAME(80, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4DF4[] = +static const union AnimCmd sAnim_GameFreakLetter_A[] = { ANIMCMD_FRAME(84, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4DFC[] = +static const union AnimCmd sAnim_GameFreakLetter_M[] = { ANIMCMD_FRAME(88, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E04[] = +static const union AnimCmd sAnim_GameFreakLetter_E[] = { ANIMCMD_FRAME(92, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E0C[] = +static const union AnimCmd sAnim_GameFreakLetter_F[] = { ANIMCMD_FRAME(96, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E14[] = +static const union AnimCmd sAnim_GameFreakLetter_R[] = { ANIMCMD_FRAME(100, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E1C[] = +static const union AnimCmd sAnim_GameFreakLetter_K[] = { ANIMCMD_FRAME(104, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E24[] = +static const union AnimCmd sAnim_PresentsLetter_P[] = { ANIMCMD_FRAME(112, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E2C[] = +static const union AnimCmd sAnim_PresentsLetter_R[] = { ANIMCMD_FRAME(113, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E34[] = +static const union AnimCmd sAnim_PresentsLetter_E[] = { ANIMCMD_FRAME(114, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E3C[] = +static const union AnimCmd sAnim_PresentsLetter_S[] = { ANIMCMD_FRAME(115, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E44[] = +static const union AnimCmd sAnim_PresentsLetter_N[] = { ANIMCMD_FRAME(116, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E4C[] = +static const union AnimCmd sAnim_PresentsLetter_T[] = { ANIMCMD_FRAME(117, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E4E54[] = +static const union AnimCmd sAnim_GameFreakLogo[] = { ANIMCMD_FRAME(128, 8), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E4E5C[] = -{ - gUnknown_085E4DEC, - gUnknown_085E4DF4, - gUnknown_085E4DFC, - gUnknown_085E4E04, - gUnknown_085E4E0C, - gUnknown_085E4E14, - gUnknown_085E4E1C, + +enum { + GAMEFREAK_G, + GAMEFREAK_A, + GAMEFREAK_M, + GAMEFREAK_E, + GAMEFREAK_F, + GAMEFREAK_R, + GAMEFREAK_K, }; -static const union AnimCmd *const gUnknown_085E4E78[] = -{ - gUnknown_085E4E24, - gUnknown_085E4E2C, - gUnknown_085E4E34, - gUnknown_085E4E3C, - gUnknown_085E4E44, - gUnknown_085E4E4C, +enum { + PRESENTS_P, + PRESENTS_R, + PRESENTS_E, + PRESENTS_S, + PRESENTS_N, + PRESENTS_T, }; -static const union AnimCmd *const gUnknown_085E4E90[] = +static const union AnimCmd *const sAnims_GameFreakLetter[] = { - gUnknown_085E4E54, + [GAMEFREAK_G] = sAnim_GameFreakLetter_G, + [GAMEFREAK_A] = sAnim_GameFreakLetter_A, + [GAMEFREAK_M] = sAnim_GameFreakLetter_M, + [GAMEFREAK_E] = sAnim_GameFreakLetter_E, + [GAMEFREAK_F] = sAnim_GameFreakLetter_F, + [GAMEFREAK_R] = sAnim_GameFreakLetter_R, + [GAMEFREAK_K] = sAnim_GameFreakLetter_K, }; -static const s16 gUnknown_085E4E94[][2] = +static const union AnimCmd *const sAnims_PresentsLetter[] = { - {0, -72}, - {1, -56}, - {2, -40}, - {3, -24}, - {4, 8}, - {5, 24}, - {3, 40}, - {1, 56}, - {6, 72}, - {0, -28}, - {1, -20}, - {2, -12}, - {3, -4}, - {2, 4}, - {4, 12}, - {5, 20}, - {3, 28}, + [PRESENTS_P] = sAnim_PresentsLetter_P, + [PRESENTS_R] = sAnim_PresentsLetter_R, + [PRESENTS_E] = sAnim_PresentsLetter_E, + [PRESENTS_S] = sAnim_PresentsLetter_S, + [PRESENTS_N] = sAnim_PresentsLetter_N, + [PRESENTS_T] = sAnim_PresentsLetter_T, }; -static const union AffineAnimCmd gUnknown_085E4ED8[] = +static const union AnimCmd *const sAnims_GameFreakLogo[] = +{ + sAnim_GameFreakLogo, +}; +#define NUM_GF_LETTERS 9 // Letters in "Game Freak" +static const s16 sGameFreakLetterData[NUM_GF_LETTERS][2] = +{ + // Letter, x offset + {GAMEFREAK_G, -72}, + {GAMEFREAK_A, -56}, + {GAMEFREAK_M, -40}, + {GAMEFREAK_E, -24}, + {GAMEFREAK_F, 8}, + {GAMEFREAK_R, 24}, + {GAMEFREAK_E, 40}, + {GAMEFREAK_A, 56}, + {GAMEFREAK_K, 72}, +}; +static const s16 sPresentsLetterData[][2] = +{ + // Letter, x offset + {PRESENTS_P, -28}, + {PRESENTS_R, -20}, + {PRESENTS_E, -12}, + {PRESENTS_S, -4}, + {PRESENTS_E, 4}, + {PRESENTS_N, 12}, + {PRESENTS_T, 20}, + {PRESENTS_S, 28}, +}; +static const union AffineAnimCmd sAffineAnim_GameFreak_Small[] = { AFFINEANIMCMD_FRAME(128, 128, 0, 0), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_085E4EE8[] = +static const union AffineAnimCmd sAffineAnim_GameFreak_GrowAndShrink[] = { AFFINEANIMCMD_FRAME(128, 128, 0, 0), AFFINEANIMCMD_FRAME(16, 16, 0, 16), AFFINEANIMCMD_FRAME(-16, -16, 0, 8), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_085E4F08[] = +static const union AffineAnimCmd sAffineAnim_GameFreak_GrowBig[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_FRAME(8, 8, 0, 48), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_085E4F20[] = +static const union AffineAnimCmd sAffineAnim_GameFreak_GrowMedium[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_FRAME(2, 2, 0, 48), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd *const gUnknown_085E4F38[] = +static const union AffineAnimCmd *const sAffineAnims_GameFreak[] = { - gUnknown_085E4ED8, - gUnknown_085E4EE8, - gUnknown_085E4F08, - gUnknown_085E4F20, + sAffineAnim_GameFreak_Small, // Initialize letters while still invisible + sAffineAnim_GameFreak_GrowAndShrink, // For letters appearing. Logo does this too, but while it's invisible + sAffineAnim_GameFreak_GrowBig, // For letters disappearing + sAffineAnim_GameFreak_GrowMedium, // For logo disappearing }; -static const u16 gUnknown_085E4F48[] = +static const u16 sGameFreakLettersMoveSpeed[NUM_GF_LETTERS] = { - 0x100, 0xC0, 0x80, 0x40, 0x00, 0x40, 0x80, 0xC0, 0x100 + 256, // G + 192, // A + 128, // M + 64, // E + 0, // F + 64, // R + 128, // E + 192, // A + 256 // K }; -static void sub_816FB38(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4F5C = +static const struct SpriteTemplate sSpriteTemplate_GameFreakLetter = { - .tileTag = 2000, - .paletteTag = 2001, - .oam = &gUnknown_085E4DD4, - .anims = gUnknown_085E4E5C, + .tileTag = GFXTAG_DROPS_LOGO, + .paletteTag = PALTAG_LOGO, + .oam = &sOamData_GameFreakLetter, + .anims = sAnims_GameFreakLetter, .images = NULL, - .affineAnims = gUnknown_085E4F38, - .callback = sub_816FB38, + .affineAnims = sAffineAnims_GameFreak, + .callback = SpriteCB_LogoLetter, }; -static const struct SpriteTemplate gUnknown_085E4F74 = +// Unused +static const struct SpriteTemplate sSpriteTemplate_PresentsLetter = { - .tileTag = 2000, - .paletteTag = 2001, - .oam = &gUnknown_085E4DDC, - .anims = gUnknown_085E4E78, + .tileTag = GFXTAG_DROPS_LOGO, + .paletteTag = PALTAG_LOGO, + .oam = &sOamData_PresentsLetter, + .anims = sAnims_PresentsLetter, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816FB38, + .callback = SpriteCB_LogoLetter, }; -static void sub_816FD44(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4F8C = +static const struct SpriteTemplate sSpriteTemplate_GameFreakLogo = { - .tileTag = 2000, - .paletteTag = 2001, - .oam = &gUnknown_085E4DE4, - .anims = gUnknown_085E4E90, + .tileTag = GFXTAG_DROPS_LOGO, + .paletteTag = PALTAG_LOGO, + .oam = &sOamData_GameFreakLogo, + .anims = sAnims_GameFreakLogo, .images = NULL, - .affineAnims = gUnknown_085E4F38, - .callback = sub_816FD44, + .affineAnims = sAffineAnims_GameFreak, + .callback = SpriteCB_GameFreakLogo, }; -static const u8 gUnknown_085E4FA4[] = +static const u8 sGameFreakLetterStartDelays[NUM_GF_LETTERS] = { - 0x00, 0x17, 0x17, 0x31, 0x3E, 0x24, 0x24, 0x0A, 0x0A + 0, // G + 23, // A + 23, // M + 49, // E + 62, // F + 36, // R + 36, // E + 10, // A + 10 // K }; -static const struct OamData gUnknown_085E4FB0 = +static const struct OamData sOamData_FlygonSilhouette = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -812,46 +942,45 @@ static const struct OamData gUnknown_085E4FB0 = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E4FB8[] = +static const union AnimCmd sAnim_FlygonSilhouette[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_JUMP(0), }; -static const union AnimCmd *const gUnknown_085E4FC0[] = +static const union AnimCmd *const sAnims_FlygonSilhouette[] = { - gUnknown_085E4FB8, + sAnim_FlygonSilhouette, }; -static void sub_816FEDC(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085E4FC4 = +static const struct SpriteTemplate sSpriteTemplate_FlygonSilhouette = { - .tileTag = 2002, - .paletteTag = 2002, - .oam = &gUnknown_085E4FB0, - .anims = gUnknown_085E4FC0, + .tileTag = TAG_FLYGON_SILHOUETTE, + .paletteTag = TAG_FLYGON_SILHOUETTE, + .oam = &sOamData_FlygonSilhouette, + .anims = sAnims_FlygonSilhouette, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_816FEDC, + .callback = SpriteCB_FlygonSilhouette, }; -static const struct CompressedSpriteSheet gIntroSpriteSheet_WaterDropAndLogo[] = +static const struct CompressedSpriteSheet sSpriteSheet_WaterDropsAndLogo[] = { - {gIntroTiles, 0x1400, 2000}, - {NULL}, + {sIntro1DropsLogo_Gfx, 0x1400, GFXTAG_DROPS_LOGO}, + {}, }; -static const struct CompressedSpriteSheet gIntroSpriteSheet_Flygon[] = +static const struct CompressedSpriteSheet sSpriteSheet_FlygonSilhouette[] = { - {gIntro1FlygonGfx, 0x400, 2002}, - {NULL}, + {gIntro1Flygon_Gfx, 0x400, TAG_FLYGON_SILHOUETTE}, + {}, }; -static const struct SpritePalette gIntroPalette_DropLogoFlygon[] = +static const struct SpritePalette sSpritePalettes_Intro1[] = { - {gIntro1DropsPal, 2000}, - {gIntro1GFLogoPal, 2001}, - {gIntro1FlygonPalette, 2002}, - {NULL}, + {sIntro1DropsPal, PALTAG_DROPS}, + {sIntro1Logo_Pal, PALTAG_LOGO}, + {sIntro1Flygon_Pal, TAG_FLYGON_SILHOUETTE}, + {}, }; -static const struct OamData gUnknown_085E501C = +static const struct OamData sOamData_RayquazaOrb = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -865,86 +994,36 @@ static const struct OamData gUnknown_085E501C = .paletteNum = 0, .affineParam = 0, }; -static const union AnimCmd gUnknown_085E5024[] = +static const union AnimCmd sAnim_RayquazaOrb[] = { ANIMCMD_FRAME(16, 8), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E502C[] = +static const union AnimCmd *const sAnims_RayquazaOrb[] = { - gUnknown_085E5024, + sAnim_RayquazaOrb, }; -static void SpriteCB_IntroRayquazaHyperbeam(struct Sprite *sprite); -static const struct SpriteTemplate gIntroRayquazaHyperbeamSprite = +static const struct SpriteTemplate sSpriteTemplate_RayquazaOrb = { - .tileTag = 2003, - .paletteTag = 2003, - .oam = &gUnknown_085E501C, - .anims = gUnknown_085E502C, + .tileTag = TAG_RAYQUAZA_ORB, + .paletteTag = TAG_RAYQUAZA_ORB, + .oam = &sOamData_RayquazaOrb, + .anims = sAnims_RayquazaOrb, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_IntroRayquazaHyperbeam, + .callback = SpriteCB_RayquazaOrb, }; -static const struct CompressedSpriteSheet gIntroRayquazaGlowSpriteSheet[] = +static const struct CompressedSpriteSheet sSpriteSheet_RayquazaOrb[] = { - {gIntro3MiscTiles, 0xA00, 2003}, - {NULL}, + {sIntro3Misc_Gfx, 0xA00, TAG_RAYQUAZA_ORB}, + {}, }; -static const struct SpritePalette gIntroRayquazaGlowPalette[] = +static const struct SpritePalette sSpritePalette_RayquazaOrb[] = { - {gIntro3Misc1Palette, 2003}, - {NULL}, + {sIntro3Misc1_Pal, TAG_RAYQUAZA_ORB}, + {}, }; -// this file's functions -static void MainCB2_EndIntro(void); -static void Task_IntroLoadPart1Graphics(u8); -static u8 CreateWaterDrop(s16, s16, u16, u16, u16, u8); -static void Task_IntroFadeIn(u8); -static void intro_reset_and_hide_bgs(void); -static void Task_IntroWaterDrops(u8); -static void Task_IntroWaterDrops_1(u8); -static void Task_IntroWaterDrops_2(u8); -static void Task_IntroWaterDrops_3(u8); -static void Task_IntroScrollDownAndShowFlygon(u8); -static void Task_IntroWaitToSetupPart2(u8); -static void Task_IntroLoadPart2Graphics(u8); -static void Task_IntroStartBikeRide(u8); -static void Task_IntroHandleBikeAndFlygonMovement(u8); -static void Task_IntroWaitToSetupPart3(u8); -static void Task_IntroLoadPart3Graphics(u8); -static void Task_IntroSpinAndZoomPokeball(u8); -static void Task_IntroWaitToSetupPart3LegendsFight(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 SpriteCB_IntroGraphicsBicycle(struct Sprite *); -static void SpriteCB_IntroGraphicsFlygon(struct Sprite *); -static u8 CreatePart1Animations(s16, s16, s16); static void VBlankCB_Intro(void) { @@ -976,7 +1055,7 @@ static void LoadCopyrightGraphics(u16 tilesetAddress, u16 tilemapAddress, u16 pa { LZ77UnCompVram(gIntroCopyright_Gfx, (void *)(VRAM + tilesetAddress)); LZ77UnCompVram(gIntroCopyright_Tilemap, (void *)(VRAM + tilemapAddress)); - LoadPalette(gIntroCopyright_Pal, paletteAddress, 0x20); + LoadPalette(gIntroCopyright_Pal, paletteAddress, 32); } static void SerialCB_CopyrightScreen(void) @@ -993,7 +1072,7 @@ static u8 SetUpCopyrightScreen(void) SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); - *(u16 *)PLTT = 0x7FFF; + *(u16 *)PLTT = RGB_WHITE; SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0); @@ -1006,7 +1085,7 @@ static u8 SetUpCopyrightScreen(void) ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); - BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_WHITEALPHA); + BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_WHITEALPHA); SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) @@ -1026,24 +1105,24 @@ static u8 SetUpCopyrightScreen(void) GameCubeMultiBoot_Main(&gMultibootProgramStruct); if (gMultibootProgramStruct.gcmb_field_2 != 1) { - BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK); + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); gMain.state++; } break; case 141: if (UpdatePaletteFade()) break; - CreateTask(Task_IntroLoadPart1Graphics, 0); + CreateTask(Task_Scene1_Load, 0); SetMainCallback2(MainCB2_Intro); if (gMultibootProgramStruct.gcmb_field_2 != 0) { if (gMultibootProgramStruct.gcmb_field_2 == 2) { // check the multiboot ROM header game code to see if we already did this - if (*(u32 *)(EWRAM_START + 0xAC) == 0x65366347) // "Gc6e" in ASCII + if (*(u32 *)(EWRAM_START + 0xAC) == COLOSSEUM_GAME_CODE) { CpuCopy16(&gMultiBootProgram_PokemonColosseum_Start, (void *)EWRAM_START, sizeof(gMultiBootProgram_PokemonColosseum_Start)); - *(u32 *)(EWRAM_START + 0xAC) = 0x65366347; + *(u32 *)(EWRAM_START + 0xAC) = COLOSSEUM_GAME_CODE; } GameCubeMultiBoot_ExecuteProgram(&gMultibootProgramStruct); } @@ -1079,408 +1158,482 @@ void CB2_InitCopyrightScreenAfterTitleScreen(void) SetUpCopyrightScreen(); } -static void Task_IntroLoadPart1Graphics(u8 taskId) +#define sBigDropSpriteId data[0] + +static void Task_Scene1_Load(u8 taskId) { SetVBlankCallback(NULL); - gIntroCharacterGender = Random() & 1; - intro_reset_and_hide_bgs(); + sIntroCharacterGender = Random() & 1; + IntroResetGpuRegs(); SetGpuReg(REG_OFFSET_BG3VOFS, 0); - SetGpuReg(REG_OFFSET_BG2VOFS, 0x50); - SetGpuReg(REG_OFFSET_BG1VOFS, 0x18); - SetGpuReg(REG_OFFSET_BG0VOFS, 0x28); - LZ77UnCompVram(gIntro1BGLeavesGfx, (void *)VRAM); - LZ77UnCompVram(gIntro1BG0_Tilemap, (void *)(BG_CHAR_ADDR(2))); - DmaClear16(3, BG_SCREEN_ADDR(17), 0x800); - LZ77UnCompVram(gIntro1BG1_Tilemap, (void *)(BG_SCREEN_ADDR(18))); - DmaClear16(3, BG_SCREEN_ADDR(19), 0x800); - LZ77UnCompVram(gIntro1BG2_Tilemap, (void *)(BG_SCREEN_ADDR(20))); - DmaClear16(3, BG_SCREEN_ADDR(21), 0x800); - LZ77UnCompVram(gIntro1BG3_Tilemap, (void *)(BG_SCREEN_ADDR(22))); - DmaClear16(3, BG_SCREEN_ADDR(23), 0x800); - LoadPalette(gIntro1BGPals, 0, sizeof(gIntro1BGPals)); + SetGpuReg(REG_OFFSET_BG2VOFS, 80); + SetGpuReg(REG_OFFSET_BG1VOFS, 24); + SetGpuReg(REG_OFFSET_BG0VOFS, 40); + LZ77UnCompVram(sIntro1Bg_Gfx, (void *)VRAM); + LZ77UnCompVram(sIntro1Bg0_Tilemap, (void *)(BG_CHAR_ADDR(2))); + DmaClear16(3, BG_SCREEN_ADDR(17), BG_SCREEN_SIZE); + LZ77UnCompVram(sIntro1Bg1_Tilemap, (void *)(BG_SCREEN_ADDR(18))); + DmaClear16(3, BG_SCREEN_ADDR(19), BG_SCREEN_SIZE); + LZ77UnCompVram(sIntro1Bg2_Tilemap, (void *)(BG_SCREEN_ADDR(20))); + DmaClear16(3, BG_SCREEN_ADDR(21), BG_SCREEN_SIZE); + LZ77UnCompVram(sIntro1Bg3_Tilemap, (void *)(BG_SCREEN_ADDR(22))); + DmaClear16(3, BG_SCREEN_ADDR(23), BG_SCREEN_SIZE); + LoadPalette(sIntro1Bg_Pal, 0, sizeof(sIntro1Bg_Pal)); SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(22) | BGCNT_16COLOR | BGCNT_TXT256x512); 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(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); - CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1C3, 0x1A); - CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1B4, 0x18); - CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x1A5, 0x16); - CpuCopy16(gPlttBufferUnfaded + 0x100, gPlttBufferUnfaded + 0x196, 0x14); - CreatePart1Animations(0x78, 0x50, 0); - gTasks[taskId].data[0] = CreateWaterDrop(236, -14, 0x200, 1, 0x78, FALSE); - gTasks[taskId].func = Task_IntroFadeIn; + LoadCompressedSpriteSheet(sSpriteSheet_WaterDropsAndLogo); + LoadCompressedSpriteSheet(sSpriteSheet_FlygonSilhouette); + LoadSpritePalettes(sSpritePalettes_Intro1); + LoadCompressedSpriteSheet(sSpriteSheet_Sparkle); + LoadSpritePalettes(sSpritePalette_Sparkle); + CpuCopy16(&gPlttBufferUnfaded[0x100], &gPlttBufferUnfaded[0x1F0], 0x20); + CpuCopy16(&gPlttBufferUnfaded[0x100], &gPlttBufferUnfaded[0x1E1], 0x1E); + CpuCopy16(&gPlttBufferUnfaded[0x100], &gPlttBufferUnfaded[0x1D2], 0x1C); + CpuCopy16(&gPlttBufferUnfaded[0x100], &gPlttBufferUnfaded[0x1C3], 0x1A); + CpuCopy16(&gPlttBufferUnfaded[0x100], &gPlttBufferUnfaded[0x1B4], 0x18); + CpuCopy16(&gPlttBufferUnfaded[0x100], &gPlttBufferUnfaded[0x1A5], 0x16); + CpuCopy16(&gPlttBufferUnfaded[0x100], &gPlttBufferUnfaded[0x196], 0x14); + CreateGameFreakLogoSprites(120, 80, 0); + gTasks[taskId].sBigDropSpriteId = CreateWaterDrop(236, -14, 0x200, 1, 0x78, FALSE); + gTasks[taskId].func = Task_Scene1_FadeIn; } -static void Task_IntroFadeIn(u8 taskId) +static void Task_Scene1_FadeIn(u8 taskId) { BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); SetVBlankCallback(VBlankCB_Intro); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON); - gTasks[taskId].func = Task_IntroWaterDrops; + gTasks[taskId].func = Task_Scene1_WaterDrops; gIntroFrameCounter = 0; m4aSongNumStart(MUS_INTRO); ResetSerial(); } -static void Task_IntroWaterDrops(u8 taskId) +// Task data for Task_Scene1_PanUp +#define tBg2PosHi data[1] +#define tBg2PosLo data[2] +#define tBg1PosHi data[3] +#define tBg1PosLo data[4] +#define tBg3PosHi data[5] +#define tBg3PosLo data[6] + +static void Task_Scene1_WaterDrops(u8 taskId) { - //start moving rock - if (gIntroFrameCounter == 76) - gSprites[gTasks[taskId].data[0]].data[0] = 1; + if (gIntroFrameCounter == TIMER_BIG_DROP_START) + gSprites[gTasks[taskId].sBigDropSpriteId].sState = 1; - if (gIntroFrameCounter == 128) - CreateTask(Task_IntroWaterDrops_1, 0); + if (gIntroFrameCounter == TIMER_LOGO_APPEAR) + CreateTask(Task_BlendLogoIn, 0); - //drop rock - if (gIntroFrameCounter == 251) - gSprites[gTasks[taskId].data[0]].data[0] = 2; + if (gIntroFrameCounter == TIMER_BIG_DROP_FALLS) + gSprites[gTasks[taskId].sBigDropSpriteId].sState = 2; - if (gIntroFrameCounter == 256) - CreateTask(Task_IntroWaterDrops_2, 0); + if (gIntroFrameCounter == TIMER_LOGO_BLEND_OUT) + CreateTask(Task_BlendLogoOut, 0); - if (gIntroFrameCounter == 368) + if (gIntroFrameCounter == TIMER_SMALL_DROP_1) CreateWaterDrop(48, 0, 0x400, 5, 0x70, TRUE); - if (gIntroFrameCounter == 384) + if (gIntroFrameCounter == TIMER_SMALL_DROP_2) CreateWaterDrop(200, 60, 0x400, 9, 0x80, TRUE); - if (gIntroFrameCounter == 560) - CreateTask(Task_IntroWaterDrops_3, 0); + if (gIntroFrameCounter == TIMER_SPARKLES) + CreateTask(Task_CreateSparkles, 0); - if (gIntroFrameCounter > 560) + if (gIntroFrameCounter > TIMER_SPARKLES) { - gTasks[taskId].data[1] = 0x50; - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[3] = 0x18; - gTasks[taskId].data[4] = 0; - gTasks[taskId].data[5] = 0x28; - gTasks[taskId].data[6] = 0; - gTasks[taskId].func = Task_IntroScrollDownAndShowFlygon; + gTasks[taskId].tBg2PosHi = 80; + gTasks[taskId].tBg2PosLo = 0; + gTasks[taskId].tBg1PosHi = 24; + gTasks[taskId].tBg1PosLo = 0; + gTasks[taskId].tBg3PosHi = 40; + gTasks[taskId].tBg3PosLo = 0; + gTasks[taskId].func = Task_Scene1_PanUp; } } -static void Task_IntroWaterDrops_3(u8 taskId) +#define tDelay data[1] +#define tTimer data[2] +#define tTimerSteps data[3] +#define tNumSparkles data[4] + +static void Task_CreateSparkles(u8 taskId) { s16 *data = gTasks[taskId].data; - if (++data[2] & 1) - data[3]++; - switch (data[0]) + if (++tTimer & 1) + tTimerSteps++; + + switch (tState) { case 0: - CreateSprite(&gUnknown_085E4AB8, gUnknown_085E4AD0[data[4]][0], gUnknown_085E4AD0[data[4]][1] + data[3], 0); - data[0]++; - data[1] = 0xC; - data[4]++; + CreateSprite(&sSpriteTemplate_Sparkle, sSparkleCoords[tNumSparkles][0], sSparkleCoords[tNumSparkles][1] + tTimerSteps, 0); + tState++; + tDelay = 12; + tNumSparkles++; break; case 1: - if (!--data[1]) - data[0] = 0; + if (--tDelay == 0) + tState = 0; break; } - if (data[3] > 0x3C) + if (tTimerSteps > 60) DestroyTask(taskId); } -static void sub_816D338(struct Sprite *sprite) +#undef tDelay +#undef tTimer +#undef tTimerSteps +#undef tNumSparkles + +#define sTimer data[0] +static void SpriteCB_Sparkle(struct Sprite *sprite) { - if (++sprite->data[0] == 0xC) + if (++sprite->sTimer == 12) DestroySprite(sprite); } +#undef sTimer -static void Task_IntroScrollDownAndShowFlygon(u8 taskId) +static void Task_Scene1_PanUp(u8 taskId) { - if (gIntroFrameCounter < 904) + if (gIntroFrameCounter < TIMER_END_PAN_UP) { - s32 r2; + s32 offset; - //slide backgrounds downward - r2 = (gTasks[taskId].data[1] << 16) + (u16)gTasks[taskId].data[2]; - r2 -= 0x6000; - gTasks[taskId].data[1] = r2 >> 16; - gTasks[taskId].data[2] = r2; - SetGpuReg(REG_OFFSET_BG2VOFS, gTasks[taskId].data[1]); - r2 = (gTasks[taskId].data[3] << 16) + (u16)gTasks[taskId].data[4]; - r2 -= 0x8000; - gTasks[taskId].data[3] = r2 >> 16; - gTasks[taskId].data[4] = r2; - SetGpuReg(REG_OFFSET_BG1VOFS, gTasks[taskId].data[3]); - r2 = (gTasks[taskId].data[5] << 16) + (u16)gTasks[taskId].data[6]; - r2 -= 0xC000; - gTasks[taskId].data[5] = r2 >> 16; - gTasks[taskId].data[6] = r2; - SetGpuReg(REG_OFFSET_BG0VOFS, gTasks[taskId].data[5]); + // Slide bg 2 downward + offset = (gTasks[taskId].tBg2PosHi << 16) + (u16)gTasks[taskId].tBg2PosLo; + offset -= 0x6000; + gTasks[taskId].tBg2PosHi = offset >> 16; + gTasks[taskId].tBg2PosLo = offset; + SetGpuReg(REG_OFFSET_BG2VOFS, gTasks[taskId].tBg2PosHi); - //show Flygon sprite - if (gIntroFrameCounter == 832) + // Slide bg 1 downward + offset = (gTasks[taskId].tBg1PosHi << 16) + (u16)gTasks[taskId].tBg1PosLo; + offset -= 0x8000; + gTasks[taskId].tBg1PosHi = offset >> 16; + gTasks[taskId].tBg1PosLo = offset; + SetGpuReg(REG_OFFSET_BG1VOFS, gTasks[taskId].tBg1PosHi); + + // Slide bg 3 downward + offset = (gTasks[taskId].tBg3PosHi << 16) + (u16)gTasks[taskId].tBg3PosLo; + offset -= 0xC000; + gTasks[taskId].tBg3PosHi = offset >> 16; + gTasks[taskId].tBg3PosLo = offset; + SetGpuReg(REG_OFFSET_BG0VOFS, gTasks[taskId].tBg3PosHi); + + if (gIntroFrameCounter == TIMER_FLYGON_SILHOUETTE_APPEAR) { - u8 spriteId = CreateSprite(&gUnknown_085E4FC4, 120, 160, 10); + // Show Flygon silhouette + u8 spriteId = CreateSprite(&sSpriteTemplate_FlygonSilhouette, 120, DISPLAY_HEIGHT, 10); gSprites[spriteId].invisible = TRUE; } } else { - //fade to white - if (gIntroFrameCounter > 1007) + if (gIntroFrameCounter > TIMER_END_SCENE_1) { + // Fade to white BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITEALPHA); - gTasks[taskId].func = Task_IntroWaitToSetupPart2; + gTasks[taskId].func = Task_Scene1_End; } } } -static void Task_IntroWaitToSetupPart2(u8 taskId) +static void Task_Scene1_End(u8 taskId) { - if (gIntroFrameCounter > 1026) - gTasks[taskId].func = Task_IntroLoadPart2Graphics; + if (gIntroFrameCounter > TIMER_START_SCENE_2) + gTasks[taskId].func = Task_Scene2_Load; } -static void Task_IntroLoadPart2Graphics(u8 taskId) +static void Task_Scene2_Load(u8 taskId) { - intro_reset_and_hide_bgs(); + IntroResetGpuRegs(); SetVBlankCallback(NULL); ResetSpriteData(); FreeAllSpritePalettes(); - gUnknown_0203BD24 = 0; - gUnknown_0203BD26 = 0; - gIntroGraphicsFlygonYOffset = 0; - load_intro_part2_graphics(1); - gTasks[taskId].func = Task_IntroStartBikeRide; + gIntroCredits_MovingSceneryVBase = 0; + gIntroCredits_MovingSceneryVOffset = 0; + sFlygonYOffset = 0; + LoadIntroPart2Graphics(1); + gTasks[taskId].func = Task_Scene2_CreateSprites; } -static void Task_IntroStartBikeRide(u8 taskId) +#define tBgAnimTaskId data[0] +#define tPlayerSpriteId data[1] +#define tFlygonSpriteId data[2] +#define tFlygonTimer data[3] + +static void Task_Scene2_CreateSprites(u8 taskId) { u8 spriteId; - if (gIntroCharacterGender == 0) - LoadCompressedSpriteSheet(gIntro2BrendanSpriteSheet); + // Load sprite sheets + if (sIntroCharacterGender == MALE) + LoadCompressedSpriteSheet(gSpriteSheet_IntroBrendan); else - LoadCompressedSpriteSheet(gIntro2MaySpriteSheet); + LoadCompressedSpriteSheet(gSpriteSheet_IntroMay); - LoadCompressedSpriteSheet(gIntro2BicycleSpriteSheet); - LoadCompressedSpriteSheet(gIntro2FlygonSpriteSheet); + LoadCompressedSpriteSheet(gSpriteSheet_IntroBicycle); + LoadCompressedSpriteSheet(gSpriteSheet_IntroFlygon); - for (spriteId = 0; spriteId < 3; spriteId++) - { - LoadCompressedSpriteSheet(&gIntroPokemonRunningSpriteSheet[spriteId]); - } + // Load sprite palettes + for (spriteId = 0; spriteId < ARRAY_COUNT(sSpriteSheet_RunningPokemon) - 1; spriteId++) + LoadCompressedSpriteSheet(&sSpriteSheet_RunningPokemon[spriteId]); - LoadSpritePalettes(gIntroBikeAndFlygonPalette); - LoadSpritePalettes(gIntroPokemonRunningPalette); - CreateSprite(&gUnknown_085E4BDC, 0x110, 0x80, 0); - CreateSprite(&gUnknown_085E4BA4, 0x120, 0x6E, 1); + LoadSpritePalettes(gSpritePalettes_IntroPlayerFlygon); + LoadSpritePalettes(sSpritePalettes_RunningPokemon); - if (gIntroCharacterGender == 0) - spriteId = intro_create_brendan_sprite(0x110, 100); + // Create Pokémon and player sprites + CreateSprite(&sSpriteTemplate_Manectric, DISPLAY_WIDTH + 32, 128, 0); + CreateSprite(&sSpriteTemplate_Torchic, DISPLAY_WIDTH + 48, 110, 1); + + if (sIntroCharacterGender == MALE) + spriteId = CreateIntroBrendanSprite(DISPLAY_WIDTH + 32, 100); else - spriteId = intro_create_may_sprite(0x110, 100); + spriteId = CreateIntroMaySprite(DISPLAY_WIDTH + 32, 100); - 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 = SpriteCB_IntroGraphicsFlygon; - gTasks[taskId].data[2] = spriteId; + gSprites[spriteId].callback = SpriteCB_PlayerOnBicycle; + gSprites[spriteId].anims = sAnims_PlayerBicycle; + gTasks[taskId].tPlayerSpriteId = spriteId; + CreateSprite(&sSpriteTemplate_Volbeat, DISPLAY_WIDTH + 32, 80, 4); + spriteId = CreateIntroFlygonSprite(-64, 60); + gSprites[spriteId].callback = SpriteCB_Flygon; + gTasks[taskId].tFlygonSpriteId = spriteId; + + // Fade in and start bike ride BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_WHITEALPHA); SetVBlankCallback(VBlankCB_Intro); - gTasks[taskId].data[0] = CreateBicycleAnimationTask(1, 0x4000, 0x400, 0x10); - sub_817B150(1); - gTasks[taskId].func = Task_IntroHandleBikeAndFlygonMovement; + gTasks[taskId].tBgAnimTaskId = CreateBicycleBgAnimationTask(1, 0x4000, 0x400, 0x10); + SetIntroPart2BgCnt(1); + gTasks[taskId].func = Task_Scene2_BikeRide; } -static void Task_IntroHandleBikeAndFlygonMovement(u8 taskId) +static void Task_Scene2_BikeRide(u8 taskId) { u16 offset; - if (gIntroFrameCounter == 1856) + if (gIntroFrameCounter == TIMER_TORCHIC_EXIT) { - gUnknown_0203BD28 = 2; - // Destroys the CreateBicycleAnimationTask created earlier. - DestroyTask(gTasks[taskId].data[0]); + // Stop the moving scenery/backgrounds, for when the camera fixes on Torchic + gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_FROZEN; + DestroyTask(gTasks[taskId].tBgAnimTaskId); } - if (gIntroFrameCounter > 1946) + + if (gIntroFrameCounter > TIMER_END_SCENE_2) { + // Fade out to next scene BeginNormalPaletteFade(PALETTES_ALL, 8, 0, 16, RGB_WHITEALPHA); - gTasks[taskId].func = Task_IntroWaitToSetupPart3; + gTasks[taskId].func = Task_Scene2_End; } - if (gIntroFrameCounter == 1109) - gSprites[gTasks[taskId].data[1]].data[0] = 1; - if (gIntroFrameCounter == 1214) - gSprites[gTasks[taskId].data[1]].data[0] = 0; - if (gIntroFrameCounter == 1394) - gSprites[gTasks[taskId].data[2]].data[0] = 1; - if (gIntroFrameCounter == 1398) - gSprites[gTasks[taskId].data[1]].data[0] = 2; - if (gIntroFrameCounter == 1576) - gSprites[gTasks[taskId].data[1]].data[0] = 3; - if (gIntroFrameCounter == 1727) - gSprites[gTasks[taskId].data[1]].data[0] = 4; - offset = Sin(gTasks[taskId].data[3] >> 2 & 0x7F, 48); - gIntroGraphicsFlygonYOffset = offset; - if (gTasks[taskId].data[3] < 512) - gTasks[taskId].data[3]++; - sub_817B540(0); + // Check for updates to player/flygon sprites + // These states are for SpriteCB_PlayerOnBicycle and SpriteCB_Flygon respectively + if (gIntroFrameCounter == TIMER_PLAYER_DRIFT_BACK) + gSprites[gTasks[taskId].tPlayerSpriteId].sState = 1; + if (gIntroFrameCounter == TIMER_PLAYER_MOVE_FORWARD) + gSprites[gTasks[taskId].tPlayerSpriteId].sState = 0; + if (gIntroFrameCounter == TIMER_FLYGON_ENTER) + gSprites[gTasks[taskId].tFlygonSpriteId].sState = 1; + if (gIntroFrameCounter == TIMER_PLAYER_MOVE_BACKWARD) + gSprites[gTasks[taskId].tPlayerSpriteId].sState = 2; + if (gIntroFrameCounter == TIMER_PLAYER_HOLD_POSITION) + gSprites[gTasks[taskId].tPlayerSpriteId].sState = 3; + if (gIntroFrameCounter == TIMER_PLAYER_EXIT) + gSprites[gTasks[taskId].tPlayerSpriteId].sState = 4; + + // Handle flygon's y movement + offset = Sin(gTasks[taskId].tFlygonTimer >> 2 & 0x7F, 48); + sFlygonYOffset = offset; + if (gTasks[taskId].tFlygonTimer < 512) + gTasks[taskId].tFlygonTimer++; + + // Alternate colors of the trees + CycleSceneryPalette(0); } -static void Task_IntroWaitToSetupPart3(u8 taskId) +static void Task_Scene2_End(u8 taskId) { - if (gIntroFrameCounter > 2068) - gTasks[taskId].func = Task_IntroLoadPart3Graphics; + if (gIntroFrameCounter > TIMER_START_SCENE_3) + gTasks[taskId].func = Task_Scene3_Load; } -static void sub_816D81C(struct Sprite *sprite) +#define sStateDelay data[1] +#define sNextState data[2] +#define sCosYIdx data[3] +#define sSinXIdx data[4] +#define sSinYIdx data[5] +#define sFig8Loops data[6] + +enum { + VOLBEAT_WAIT_ENTER, + VOLBEAT_ENTER, + VOLBEAT_ZIP_BACKWARD, + VOLBEAT_ZIP_DOWN, + VOLBEAT_ZIP_FORWARD, + VOLBEAT_INIT_FIGURE_8, + VOLBEAT_FIGURE_8, + VOLBEAT_EXIT, + VOLBEAT_WAIT_STATE +}; + +static void SpriteCB_Volbeat(struct Sprite *sprite) { - sprite->data[3] += 4; - switch (sprite->data[0]) + sprite->sCosYIdx += 4; + switch (sprite->sState) { - case 0: - if (++sprite->data[1] < 180) + case VOLBEAT_WAIT_ENTER: + if (++sprite->sStateDelay < 180) break; - ++sprite->data[0]; - case 1: + sprite->sState++; + // fallthrough + case VOLBEAT_ENTER: sprite->pos1.x -= 4; - if (sprite->pos1.x == 0x3C) + if (sprite->pos1.x == 60) { - sprite->data[0] = 8; - sprite->data[1] = 20; - sprite->data[2] = 2; + sprite->sState = VOLBEAT_WAIT_STATE; + sprite->sStateDelay = 20; + sprite->sNextState = VOLBEAT_ZIP_BACKWARD; } break; - case 2: + case VOLBEAT_ZIP_BACKWARD: sprite->pos1.x += 8; sprite->pos1.y -= 2; - if (sprite->pos1.x == 0x7C) + if (sprite->pos1.x == 124) { - sprite->data[0] = 8; - sprite->data[1] = 20; - sprite->data[2] = 3; + sprite->sState = VOLBEAT_WAIT_STATE; + sprite->sStateDelay = 20; + sprite->sNextState = VOLBEAT_ZIP_DOWN; } break; - case 3: + case VOLBEAT_ZIP_DOWN: sprite->pos1.y += 4; - if (sprite->pos1.y == 0x50) + if (sprite->pos1.y == 80) { - sprite->data[0] = 8; - sprite->data[1] = 10; - sprite->data[2] = 4; + sprite->sState = VOLBEAT_WAIT_STATE; + sprite->sStateDelay = 10; + sprite->sNextState = VOLBEAT_ZIP_FORWARD; } break; - case 4: + case VOLBEAT_ZIP_FORWARD: sprite->pos1.x -= 8; sprite->pos1.y -= 2; - if (sprite->pos1.x == 0x3C) + if (sprite->pos1.x == 60) { - sprite->data[0] = 8; - sprite->data[1] = 10; - sprite->data[2] = 5; + sprite->sState = VOLBEAT_WAIT_STATE; + sprite->sStateDelay = 10; + sprite->sNextState = VOLBEAT_INIT_FIGURE_8; } break; - case 5: - sprite->pos1.x += 0x3C; - sprite->data[4] = 0xC0; - sprite->data[5] = 0x80; - sprite->data[6] = 0x3; - sprite->data[0]++; - case 6: - sprite->pos2.x = Sin((u8)sprite->data[4], 0x3C); - sprite->pos2.y = Sin((u8)sprite->data[5], 0x14); - sprite->data[4] += 2; - sprite->data[5] += 4; - if ((sprite->data[4] & 0xFF) == 0x40) + case VOLBEAT_INIT_FIGURE_8: + sprite->pos1.x += 60; + sprite->sSinXIdx = 0xC0; + sprite->sSinYIdx = 0x80; + sprite->sFig8Loops = 3; + sprite->sState++; + // fallthrough + case VOLBEAT_FIGURE_8: + sprite->pos2.x = Sin((u8)sprite->sSinXIdx, 0x3C); + sprite->pos2.y = Sin((u8)sprite->sSinYIdx, 0x14); + sprite->sSinXIdx += 2; + sprite->sSinYIdx += 4; + if ((sprite->sSinXIdx & 0xFF) == 64) { sprite->hFlip = FALSE; - if (!--sprite->data[6]) + if (--sprite->sFig8Loops == 0) { sprite->pos1.x += sprite->pos2.x; sprite->pos2.x = 0; - sprite->data[0]++; + sprite->sState++; } } break; - case 7: + case VOLBEAT_EXIT: sprite->pos1.x -= 2; - sprite->pos2.y = Sin((u8)sprite->data[5], 0x14); - sprite->data[5] += 4; + sprite->pos2.y = Sin((u8)sprite->sSinYIdx, 0x14); + sprite->sSinYIdx += 4; if (sprite->pos1.x < -16) DestroySprite(sprite); break; - case 8: - sprite->pos2.y = Cos((u8)sprite->data[3], 2); - if (!--sprite->data[1]) - sprite->data[0] = sprite->data[2]; + case VOLBEAT_WAIT_STATE: + // Wait for state progression, fly idly until then + sprite->pos2.y = Cos((u8)sprite->sCosYIdx, 2); + if (!--sprite->sStateDelay) + sprite->sState = sprite->sNextState; break; } } -static void sub_816D9C0(struct Sprite *sprite) +#undef sStateDelay +#undef sNextState +#undef sCosYIdx +#undef sSinXIdx +#undef sSinYIdx +#undef sFig8Loops + +#define sMoveTimer data[1] +#define sDelay data[2] + +static void SpriteCB_Torchic(struct Sprite *sprite) { - switch (sprite->data[0]) + switch (sprite->sState) { case 0: - if (gIntroFrameCounter == 1224) + if (gIntroFrameCounter == TIMER_TORCHIC_ENTER) { - StartSpriteAnim(sprite, 1); - sprite->data[0]++; + StartSpriteAnim(sprite, TORCHIC_ANIM_RUN); + sprite->sState++; } break; case 1: - if (gIntroFrameCounter == 1576) + if (gIntroFrameCounter == TIMER_PLAYER_HOLD_POSITION) { - StartSpriteAnim(sprite, 0); - sprite->data[0]++; + StartSpriteAnim(sprite, TORCHIC_ANIM_WALK); + sprite->sState++; } else { - sprite->data[1] += 0x40; - if (sprite->data[1] & 0xFF00) + sprite->sMoveTimer += 64; + if (sprite->sMoveTimer & 0xFF00) { sprite->pos1.x--; - sprite->data[1] &= 0xFF; + sprite->sMoveTimer &= 0xFF; } } break; case 2: - if (gIntroFrameCounter != 1735) + if (gIntroFrameCounter != TIMER_TORCHIC_SPEED_UP) { - sprite->data[1] += 0x20; - if (sprite->data[1] & 0xFF00) + sprite->sMoveTimer += 32; + if (sprite->sMoveTimer & 0xFF00) { sprite->pos1.x++; - sprite->data[1] &= 0xFF; + sprite->sMoveTimer &= 0xFF; } } else { - StartSpriteAnim(sprite, 1); - sprite->data[0]++; - sprite->data[2] = 0x50; + StartSpriteAnim(sprite, TORCHIC_ANIM_RUN); + sprite->sState++; + sprite->sDelay = 80; } break; case 3: - if (--sprite->data[2]) + if (--sprite->sDelay) { - sprite->data[1] += 0x40; - if (sprite->data[1] & 0xFF00) + sprite->sMoveTimer += 64; + if (sprite->sMoveTimer & 0xFF00) { sprite->pos1.x--; - sprite->data[1] &= 0xFF; + sprite->sMoveTimer &= 0xFF; } } else { - StartSpriteAnim(sprite, 2); - sprite->data[0]++; + StartSpriteAnim(sprite, TORCHIC_ANIM_TRIP); + sprite->sState++; } break; case 4: @@ -1489,110 +1642,131 @@ static void sub_816D9C0(struct Sprite *sprite) if (sprite->pos1.x > 336) { - StartSpriteAnim(sprite, 1); - sprite->data[0]++; + StartSpriteAnim(sprite, TORCHIC_ANIM_RUN); + sprite->sState++; } break; case 5: - if (gIntroFrameCounter > 1855) + if (gIntroFrameCounter >= TIMER_TORCHIC_EXIT) sprite->pos1.x -= 2; break; } } -static void sub_816DAE8(struct Sprite *sprite) +#undef sMoveTimer +#undef sDelay + +#define sSinIdx data[1] +#define sCosIdx data[2] + +static void SpriteCB_Manectric(struct Sprite *sprite) { - switch (sprite->data[0]) + switch (sprite->sState) { case 0: - if (gIntroFrameCounter == 1088) - sprite->data[0]++; + if (gIntroFrameCounter == TIMER_MANECTRIC_ENTER) + sprite->sState++; break; case 1: sprite->pos1.x -= 2; - if (gIntroFrameCounter != 1168) + if (gIntroFrameCounter != TIMER_MANECTRIC_RUN_CIRCULAR) break; + + // Initialize circular pattern running sprite->pos1.y -= 12; - sprite->data[1] = 0x80; - sprite->data[2] = 0; - sprite->data[0]++; + sprite->sSinIdx = 0x80; + sprite->sCosIdx = 0; + sprite->sState++; + // fallthrough case 2: - if (sprite->pos1.x + sprite->pos2.x <= -0x20) + if (sprite->pos1.x + sprite->pos2.x <= -32) { + // Manectric is offscreen now, destroy it DestroySprite(sprite); } else { - if ((sprite->data[1] & 0xFF) < 0x40) + // Run in circular pattern + if ((sprite->sSinIdx & 0xFF) < 64) { - sprite->pos2.x = Sin((u8)sprite->data[1], 0x10); + sprite->pos2.x = Sin((u8)sprite->sSinIdx, 16); } else { - if ((sprite->data[1] & 0xFF) == 0x40) - sprite->pos1.x -= 0x30; - sprite->pos2.x = Sin((u8)sprite->data[1], 0x40); + if ((sprite->sSinIdx & 0xFF) == 64) + sprite->pos1.x -= 48; + sprite->pos2.x = Sin((u8)sprite->sSinIdx, 64); } - sprite->data[1]++; - sprite->pos2.y = Cos((u8)sprite->data[2], 0xC); - sprite->data[2]++; + sprite->sSinIdx++; + sprite->pos2.y = Cos((u8)sprite->sCosIdx, 12); + sprite->sCosIdx++; } break; } } -static void Task_IntroLoadPart3Graphics(u8 taskId) +#undef sSinIdx +#undef sCosIdx + +#define tAlpha data[0] +#define tZoomDiv data[1] +#define tZoomDivSpeed data[2] + +static void Task_Scene3_Load(u8 taskId) { - intro_reset_and_hide_bgs(); - LZ77UnCompVram(gIntro3Pokeball_Gfx, (void *)VRAM); - LZ77UnCompVram(gIntro3Pokeball_Tilemap, (void *)(BG_CHAR_ADDR(1))); - LoadPalette(gIntro3PokeballPal, 0, 0x200); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 0; + IntroResetGpuRegs(); + LZ77UnCompVram(sIntro3Pokeball_Gfx, (void *)VRAM); + LZ77UnCompVram(sIntro3Pokeball_Tilemap, (void *)(BG_CHAR_ADDR(1))); + LoadPalette(sIntro3Pokeball_Pal, 0, sizeof(sIntro3Pokeball_Pal)); + gTasks[taskId].tAlpha = 0; + gTasks[taskId].tZoomDiv = 0; + gTasks[taskId].tZoomDivSpeed = 0; gTasks[taskId].data[3] = 0; PanFadeAndZoomScreen(0x78, 0x50, 0, 0); ResetSpriteData(); FreeAllSpritePalettes(); - BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_WHITEALPHA); + BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_WHITEALPHA); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(8) | BGCNT_256COLOR | BGCNT_AFF256x256); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON); - gTasks[taskId].func = Task_IntroSpinAndZoomPokeball; + gTasks[taskId].func = Task_Scene3_SpinPokeball; gIntroFrameCounter = 0; m4aSongNumStart(MUS_INTRO_BATTLE); } - -static void Task_IntroSpinAndZoomPokeball(u8 taskId) +static void Task_Scene3_SpinPokeball(u8 taskId) { - gTasks[taskId].data[0] += 0x400; + gTasks[taskId].tAlpha += 0x400; - if (gTasks[taskId].data[1] <= 0x6BF) + if (gTasks[taskId].tZoomDiv <= 0x6BF) { - gTasks[taskId].data[1] += gTasks[taskId].data[2]; - gTasks[taskId].data[2] += 2; + gTasks[taskId].tZoomDiv += gTasks[taskId].tZoomDivSpeed; + gTasks[taskId].tZoomDivSpeed += 2; } else { - gTasks[taskId].func = Task_IntroWaitToSetupPart3LegendsFight; + gTasks[taskId].func = Task_Scene3_WaitGroudon; } - PanFadeAndZoomScreen(0x78, 0x50, 0x10000 / gTasks[taskId].data[1], gTasks[taskId].data[0]); + PanFadeAndZoomScreen(0x78, 0x50, 0x10000 / gTasks[taskId].tZoomDiv, gTasks[taskId].tAlpha); - if (gIntroFrameCounter == 28) - BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_WHITEALPHA); + if (gIntroFrameCounter == TIMER_POKEBALL_FADE) + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITEALPHA); } -static void Task_IntroWaitToSetupPart3LegendsFight(u8 taskId) +#undef tAlpha +#undef tZoomDiv +#undef tZoomDivSpeed + +static void Task_Scene3_WaitGroudon(u8 taskId) { - if (gIntroFrameCounter > 43) - gTasks[taskId].func = Task_IntroLoadGroudonScene; + if (gIntroFrameCounter > TIMER_START_LEGENDARIES) + gTasks[taskId].func = Task_Scene3_LoadGroudon; } -static void Task_IntroLoadGroudonScene(u8 taskId) +static void Task_Scene3_LoadGroudon(u8 taskId) { if (!gPaletteFade.active) { - intro_reset_and_hide_bgs(); + IntroResetGpuRegs(); ResetSpriteData(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 8; @@ -1603,15 +1777,20 @@ static void Task_IntroLoadGroudonScene(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_IntroLoadPart3Graphics1; + gTasks[taskId].func = Task_Scene3_InitGroudonBg; } } -static void Task_IntroLoadPart3Graphics1(u8 taskId) +#define tWinPos data[0] +#define tScreenX data[1] +#define tScreenY data[2] +#define tZoom data[3] + +static void Task_Scene3_InitGroudonBg(u8 taskId) { - SetGpuReg(REG_OFFSET_WIN0H, 0xF0); - SetGpuReg(REG_OFFSET_WIN0V, 0xA0); - SetGpuReg(REG_OFFSET_WININ, 0x3F); + SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH); + SetGpuReg(REG_OFFSET_WIN0V, DISPLAY_HEIGHT); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_ALL); SetGpuReg(REG_OFFSET_WINOUT, 0); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) @@ -1630,185 +1809,220 @@ static void Task_IntroLoadPart3Graphics1(u8 taskId) | DISPCNT_BG2_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON); - BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_WHITEALPHA); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = 0xFFA0; - gTasks[taskId].data[2] = 0xFF51; - gTasks[taskId].data[3] = 0x100; - PanFadeAndZoomScreen(0xFFA0, 0xFF51, 0x100, 0); - gTasks[taskId].func = Task_IntroLoadPart3Graphics2; + BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_WHITEALPHA); + gTasks[taskId].tWinPos = 0; + gTasks[taskId].tScreenX = 0xFFA0; + gTasks[taskId].tScreenY = 0xFF51; + gTasks[taskId].tZoom = 0x100; + PanFadeAndZoomScreen(gTasks[taskId].tScreenX, gTasks[taskId].tScreenY, gTasks[taskId].tZoom, 0); + gTasks[taskId].func = Task_Scene3_NarrowWindow; } -static void Task_IntroLoadPart3Graphics2(u8 taskId) +// Before the Groudon scene starts, the black top/bottom edges of the screen +// come inward for a more 'cinematic' look +#define NARROW_HEIGHT 32 +static void Task_Scene3_NarrowWindow(u8 taskId) { - if (gTasks[taskId].data[0] != 32) + if (gTasks[taskId].tWinPos != NARROW_HEIGHT) { - gTasks[taskId].data[0] += 4; - SetGpuReg(REG_OFFSET_WIN0V, (gTasks[taskId].data[0] * 256) - (gTasks[taskId].data[0] - 160)); + gTasks[taskId].tWinPos += 4; + SetGpuReg(REG_OFFSET_WIN0V, (gTasks[taskId].tWinPos * 256) - (gTasks[taskId].tWinPos - DISPLAY_HEIGHT)); } else { - SetGpuReg(REG_OFFSET_WIN0V, 0x2080); - gTasks[taskId].func = Task_IntroLoadPart3Graphics3; + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(NARROW_HEIGHT, DISPLAY_HEIGHT - NARROW_HEIGHT)); + gTasks[taskId].func = Task_Scene3_EndNarrowWindow; } } +#undef tWinPos +#undef tScreenX +#undef tScreenY +#undef tZoom -static void Task_IntroLoadPart3Graphics3(u8 taskId) +static void Task_Scene3_EndNarrowWindow(u8 taskId) { - gTasks[taskId].func = Task_IntroLoadPart3Graphics4; + gTasks[taskId].func = Task_Scene3_StartGroudon; } -static void Task_IntroLoadPart3Graphics4(u8 taskId) +static void Task_Scene3_StartGroudon(u8 taskId) { - gTasks[taskId].data[0] = 0; - gTasks[taskId].func = Task_IntroGroudonScene; - ScanlineEffect_InitWave(0, 0xA0, 0x4, 4, 1, 4, 0); + gTasks[taskId].tState = 0; + gTasks[taskId].func = Task_Scene3_Groudon; + ScanlineEffect_InitWave(0, 160, 4, 4, 1, 4, 0); } -static void Task_IntroGroudonScene(u8 taskId) +#define tScreenX data[1] +#define tScreenY data[2] +#define tZoom data[3] +#define tYShake data[4] +#define tTimer data[5] +#define tDelay data[6] +#define tTrigIdx data[6] // Re-used +#define tPalIdx data[7] + +static void Task_Scene3_Groudon(u8 taskId) { s16 *data = gTasks[taskId].data; - data[5]++; - if ((u16)(data[0] - 1) < 7 && data[5] % 2 == 0) - data[4] ^= 3; - PanFadeAndZoomScreen(data[1], data[2] + data[4], data[3], 0); - switch (data[0]) + tTimer++; + if ((u16)(tState - 1) < 7 && tTimer % 2 == 0) + tYShake ^= 3; + PanFadeAndZoomScreen(tScreenX, tScreenY + tYShake, tZoom, 0); + switch (tState) { case 0: - data[1] += 0x10; - if (data[1] == 0xA0) + tScreenX += 16; + if (tScreenX == 160) { - data[0]++; - data[6] = 2; - data[7] = 0x1E2; + tState++; + tDelay = 2; + tPalIdx = 0x1E2; CreateGroudonRockSprites(taskId); } break; case 1: - if (--data[6] == 0) + if (--tDelay == 0) { - data[6] = 2; - CpuCopy16(&gIntro3BgPal[data[7]], &gPlttBufferFaded[31], sizeof(u16)); - data[7] += 2; - if (data[7] == 0x1EC) - data[0]++; + tDelay = 2; + CpuCopy16(&gIntro3BgPal[tPalIdx], &gPlttBufferFaded[31], sizeof(u16)); + tPalIdx += 2; + if (tPalIdx == 0x1EC) + tState++; } break; case 2: - if (--data[6] == 0) + if (--tDelay == 0) { - data[6] = 2; - data[0]++; + tDelay = 2; + tState++; } break; case 3: - if (--data[6] == 0) + if (--tDelay == 0) { - data[6] = 2; - CpuCopy16(&gIntro3BgPal[data[7]], &gPlttBufferFaded[31], sizeof(u16)); - data[7] -= 2; - if (data[7] == 0x1E0) + tDelay = 2; + CpuCopy16(&gIntro3BgPal[tPalIdx], &gPlttBufferFaded[31], sizeof(u16)); + tPalIdx -= 2; + if (tPalIdx == 0x1E0) { - data[6] = 8; - data[0]++; + tDelay = 8; + tState++; } } break; case 4: - if (--data[6] == 0) + if (--tDelay == 0) { - data[1] = -0x60; - data[2] = 0xA9; - data[6] = 3; - data[0]++; + tScreenX = -96; + tScreenY = 169; + tDelay = 3; + tState++; } break; case 5: - if (--data[6] == 0) + if (--tDelay == 0) { - data[1] = 0x50; - data[2] = 0x29; - data[6] = 0x10; + tScreenX = 80; + tScreenY = 41; + tDelay = 16; PlayCryInternal(SPECIES_GROUDON, 0, 100, 10, 0); - data[0]++; + tState++; } break; case 6: - if (--data[6] == 0) + if (--tDelay == 0) { - data[1] = 0x50; - data[2] = 0x28; - data[0]++; + tScreenX = 80; + tScreenY = 40; + tState++; } break; case 7: - data[1] += 4; - data[2] += 4; - data[6] += 0x666; - data[3] = Sin((data[6] & 0xFF00) >> 8, 0x40) + 0x100; - if (data[1] == 0x78) + tScreenX += 4; + tScreenY += 4; + tTrigIdx += 0x666; + tZoom = Sin((tTrigIdx & 0xFF00) >> 8, 64) + 256; + if (tScreenX == 120) { BeginNormalPaletteFade(PALETTES_ALL & ~1, 3, 0, 16, RGB_WHITE); - data[3] = 0x100; - data[4] = 0; - data[0]++; + tZoom = 256; + tYShake = 0; + tState++; } break; case 8: - if (data[3]) - data[3] -= 8; + if (tZoom) + tZoom -= 8; else - data[0]++; + tState++; break; case 9: if (!gPaletteFade.active) { - gTasks[taskId].func = Task_IntroLoadKyogreScene; + gTasks[taskId].func = Task_Scene3_LoadKyogre; gScanlineEffect.state = 3; } break; } } -static void CreateGroudonRockSprites(u8 a0) +#undef tScreenX +#undef tScreenY +#undef tZoom +#undef tYShake +#undef tTimer +#undef tDelay +#undef tTrigIdx +#undef tPalIdx + +#define sRockId data[1] +#define sSpeed data[2] +#define sTimer data[3] +#define sTaskId data[4] + +static void CreateGroudonRockSprites(u8 taskId) { int i; u8 spriteId; - for (i = 0; i < 6; i++) + for (i = 0; i < (int)ARRAY_COUNT(sGroudonRockData); i++) { - spriteId = CreateSprite(gAncientPowerRockSpriteTemplate, gIntroGroudonRockData[i][0], 0xA0, i); - gSprites[spriteId].callback = SpriteCB_IntroGroudonRocks; + spriteId = CreateSprite(gAncientPowerRockSpriteTemplate, sGroudonRockData[i][0], DISPLAY_HEIGHT, i); + gSprites[spriteId].callback = SpriteCB_GroudonRocks; gSprites[spriteId].oam.priority = 0; - gSprites[spriteId].data[1] = i; - gSprites[spriteId].data[4] = a0; - StartSpriteAnim(&gSprites[spriteId], gIntroGroudonRockData[i][1]); + gSprites[spriteId].sRockId = i; + gSprites[spriteId].sTaskId = taskId; + StartSpriteAnim(&gSprites[spriteId], sGroudonRockData[i][1]); } } -static void SpriteCB_IntroGroudonRocks(struct Sprite *sprite) +static void SpriteCB_GroudonRocks(struct Sprite *sprite) { - sprite->data[3]++; - if (sprite->data[3] % 2 == 0) + // Introduce some wobble to the floating + sprite->sTimer++; + if (sprite->sTimer % 2 == 0) sprite->pos2.y ^= 3; - switch(sprite->data[0]) + switch(sprite->sState) { case 0: - 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) - sprite->data[0]++; + // Rock floats up + sprite->sSpeed += sGroudonRockData[sprite->sRockId][2]; + sprite->pos1.y -= (sprite->sSpeed & 0xFF00) >> 8; + sprite->sSpeed &= 0xFF; + + // Check if Groudon scene is ending + if (gTasks[sprite->sTaskId].tState > 7) + sprite->sState++; break; case 1: - if (sprite->pos1.x < 0x78) + // Scene zooms in, move rock offscreen + if (sprite->pos1.x < DISPLAY_WIDTH / 2) sprite->pos1.x -= 2; else sprite->pos1.x += 2; - if (sprite->pos1.y < 0x50) + if (sprite->pos1.y < DISPLAY_HEIGHT / 2) sprite->pos1.y -= 2; else sprite->pos1.y += 2; @@ -1816,237 +2030,294 @@ static void SpriteCB_IntroGroudonRocks(struct Sprite *sprite) } } -static void Task_IntroLoadKyogreScene(u8 taskId) +#undef sRockId +#undef sSpeed +#undef sTimer +#undef sTaskId + +#define tScreenX data[1] +#define tScreenY data[2] +#define tZoom data[3] +#define tDelay data[6] +#define tTrigIdx data[6] // Re-used +#define tPalIdx data[7] + +static void Task_Scene3_LoadKyogre(u8 taskId) { ResetSpriteData(); LZDecompressVram(gIntro3KyogreGfx, (void *)VRAM); LZDecompressVram(gIntro3KyogreTilemap, (void *)(BG_CHAR_ADDR(3))); LZDecompressVram(gIntro3KyogreBgTilemap, (void *)(BG_SCREEN_ADDR(28))); - LoadCompressedSpriteSheet(gUnknown_085E4C88); - LoadSpritePalette(gUnknown_085E4C98); - BeginNormalPaletteFade(PALETTES_ALL & ~1, 0, 0x10, 0, RGB_WHITEALPHA); - 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; - PanFadeAndZoomScreen(0x150, 0x50, 0x100, 0); + LoadCompressedSpriteSheet(sSpriteSheet_Bubbles); + LoadSpritePalette(sSpritePalette_Bubbles); + BeginNormalPaletteFade(PALETTES_ALL & ~1, 0, 16, 0, RGB_WHITEALPHA); + gTasks[taskId].func = Task_Scene3_Kyogre; + gTasks[taskId].tState = 0; + gTasks[taskId].tScreenX = 336; + gTasks[taskId].tScreenY = 80; + gTasks[taskId].tDelay = 16; + gTasks[taskId].tZoom = 256; + PanFadeAndZoomScreen(gTasks[taskId].tScreenX, gTasks[taskId].tScreenY, gTasks[taskId].tZoom, 0); ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, 6, 0); } -static void Task_IntroKyogreScene(u8 taskId) +static void Task_Scene3_Kyogre(u8 taskId) { s16 *data = gTasks[taskId].data; - PanFadeAndZoomScreen(data[1], data[2], data[3], 0); + PanFadeAndZoomScreen(tScreenX, tScreenY, tZoom, 0); - switch (data[0]) + switch (tState) { case 0: - if (--data[6] != 0) + if (--tDelay != 0) break; - data[0]++; + tState++; case 1: - data[6] += 4; - gTasks[taskId].data[1] = 0x158 - Sin(data[6], 0x100); - gTasks[taskId].data[2] = 0x54 - Cos(data[6], 0x40); - if (data[6] == 0x40) + tTrigIdx += 4; + gTasks[taskId].tScreenX = 344 - Sin(tTrigIdx, 0x100); + gTasks[taskId].tScreenY = 84 - Cos(tTrigIdx, 0x40); + if (tTrigIdx == 64) { - data[6] = 0x19; - data[7] = 1; - data[0]++; - CreateKyogreBubbleSprites_0(0); + tDelay = 0x19; + tPalIdx = 1; + tState++; + CreateKyogreBubbleSprites_Body(0); } break; case 2: - if (--data[6] == 0) + if (--tDelay == 0) { - gTasks[taskId].data[1] += 0x100; - gTasks[taskId].data[2] -= 0x102; - data[6] = 8; - data[0]++; - CreateKyogreBubbleSprites_0(0); - CreateKyogreBubbleSprites_1(); + gTasks[taskId].tScreenX += 256; + gTasks[taskId].tScreenY -= 258; + tDelay = 8; + tState++; + CreateKyogreBubbleSprites_Body(0); + CreateKyogreBubbleSprites_Fins(); } break; case 3: - if (--data[6] == 0) + if (--tDelay == 0) { - gTasks[taskId].data[1] -= 0x100; - gTasks[taskId].data[2] += 0x102; - data[6] = 8; - data[0]++; + gTasks[taskId].tScreenX -= 256; + gTasks[taskId].tScreenY += 258; + tDelay = 8; + tState++; } break; case 4: - if (--data[6] == 0) + if (--tDelay == 0) { - gTasks[taskId].data[2] -= 0xFC; - data[6] = 8; - data[0]++; + gTasks[taskId].tScreenY -= 252; + tDelay = 8; + tState++; } break; case 5: - if (--data[6] == 0) + if (--tDelay == 0) { - gTasks[taskId].data[2] += 0xFC; - if (data[7] != 0) + gTasks[taskId].tScreenY += 252; + if (tPalIdx != 0) { - data[6] = 12; - data[7]--; - data[0] = 2; + tDelay = 12; + tPalIdx--; + tState = 2; } else { - data[6] = 1; - data[0]++; + tDelay = 1; + tState++; PlayCryInternal(SPECIES_KYOGRE, 0, 120, 10, 0); } } break; case 6: - if (--data[6] == 0) + if (--tDelay == 0) { - data[6] = 4; - data[7] = 0x1EA; - data[0]++; + tDelay = 4; + tPalIdx = 0x1EA; + tState++; } break; case 7: - if (--data[6] == 0) + if (--tDelay == 0) { - data[6] = 4; - CpuCopy16(&gIntro3BgPal[data[7]], &gPlttBufferFaded[47], sizeof(u16)); - data[7] -= 2; - if (data[7] == 0x1E0) - data[0]++; + tDelay = 4; + CpuCopy16(&gIntro3BgPal[tPalIdx], &gPlttBufferFaded[47], sizeof(u16)); + tPalIdx -= 2; + if (tPalIdx == 0x1E0) + tState++; } break; case 8: - if (--data[6] == 0) + if (--tDelay == 0) { - data[6] = 4; - data[7] = 0x1E2; - data[0]++; + tDelay = 4; + tPalIdx = 0x1E2; + tState++; } break; case 9: - if (--data[6] == 0) + if (--tDelay == 0) { - data[6] = 4; - CpuCopy16(&gIntro3BgPal[data[7]], &gPlttBufferFaded[47], sizeof(u16)); - data[7] += 2; - if (data[7] == 0x1EE) + tDelay = 4; + CpuCopy16(&gIntro3BgPal[tPalIdx], &gPlttBufferFaded[47], sizeof(u16)); + tPalIdx += 2; + if (tPalIdx == 0x1EE) { - data[6] = 0x10; - data[0]++; + tDelay = 16; + tState++; } } break; case 10: - if (--data[6] == 0) + if (--tDelay == 0) { - data[6] = 0; - data[0]++; - CreateKyogreBubbleSprites_0(taskId); + tTrigIdx = 0; + tState++; + CreateKyogreBubbleSprites_Body(taskId); } break; case 11: - data[6] += 4; - data[3] -= 8; - gTasks[taskId].data[1] = Sin(data[6], 0x3C) + 0x58; - if (data[6] == 0x40) + tTrigIdx += 4; + tZoom -= 8; + gTasks[taskId].tScreenX = Sin(tTrigIdx, 0x3C) + 88; + if (tTrigIdx == 64) { BeginNormalPaletteFade(PALETTES_ALL & ~1, 3, 0, 16, RGB_WHITE); - data[0]++; + tState++; } break; case 12: - data[6] += 4; - data[3] -= 8; - gTasks[taskId].data[1] = Sin(data[6], 0x14) + 0x80; - if (data[6] == 0x80) - data[0]++; + tTrigIdx += 4; + tZoom -= 8; + gTasks[taskId].tScreenX = Sin(tTrigIdx, 0x14) + 128; + if (tTrigIdx == 128) + tState++; break; case 13: if (!gPaletteFade.active) { - gTasks[taskId].func = Task_IntroLoadClouds1; + gTasks[taskId].func = Task_Scene3_LoadClouds1; gScanlineEffect.state = 3; } break; } } -static void CreateKyogreBubbleSprites_0(u8 taskId) +#undef tScreenX +#undef tScreenY +#undef tZoom +#undef tDelay +#undef tTrigIdx +#undef tPalIdx + +#define sSinIdx data[1] +#define sBaseY data[2] +#define sTaskId data[5] +#define sDelay data[6] +#define sUnk data[7] // Never read + +// taskId is used inconsistently for these two functions. +// The sprite callback for the bubbles will always read it, unless delay is 0 to +// start (it never is), but the first function is often passed 0 instead of a +// taskId, and the second function doesn't take/assign a taskId at all. +// The only time an actual taskId is given is when it actually needs the +// result of reading it, to zoom in at the end of the scene. + +// Creates bubbles at positions spread across Kyogre's body +static void CreateKyogreBubbleSprites_Body(u8 taskId) { int i; u8 spriteId; - for (i = 0; i < 6; i++) + for (i = 0; i < NUM_BUBBLES_IN_SET; i++) { - spriteId = CreateSprite(&gUnknown_085E4D14, gIntroKyogreBubbleData[i][0], gIntroKyogreBubbleData[i][1], i); + spriteId = CreateSprite(&sSpriteTemplate_Bubbles, + sKyogreBubbleData[i][0], + sKyogreBubbleData[i][1], + i); gSprites[spriteId].invisible = TRUE; - gSprites[spriteId].data[5] = taskId; - gSprites[spriteId].data[6] = gIntroKyogreBubbleData[i][2]; - gSprites[spriteId].data[7] = 0x40; + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sDelay = sKyogreBubbleData[i][2]; + gSprites[spriteId].sUnk = 64; } } -static void CreateKyogreBubbleSprites_1(void) +// Creates bubbles at positions around Kyogre's fins, for when it's moving them +static void CreateKyogreBubbleSprites_Fins(void) { int i; u8 spriteId; - for (i = 0; i < 6; i++) + for (i = 0; i < NUM_BUBBLES_IN_SET; i++) { - spriteId = CreateSprite(&gUnknown_085E4D14, gIntroKyogreBubbleData[i + 6][0], gIntroKyogreBubbleData[i + 6][1], i); + spriteId = CreateSprite(&sSpriteTemplate_Bubbles, + sKyogreBubbleData[i + NUM_BUBBLES_IN_SET][0], + sKyogreBubbleData[i + NUM_BUBBLES_IN_SET][1], + i); gSprites[spriteId].invisible = TRUE; - gSprites[spriteId].data[6] = gIntroKyogreBubbleData[i][2]; - gSprites[spriteId].data[7] = 0x40; +#ifdef BUGFIX + gSprites[spriteId].sDelay = sKyogreBubbleData[i + NUM_BUBBLES_IN_SET][2]; +#else + gSprites[spriteId].sDelay = sKyogreBubbleData[i][2]; // Using the wrong set of delays here +#endif + gSprites[spriteId].sUnk = 64; } } -static void SpriteCB_IntroKyogreBubbles(struct Sprite *sprite) +static void SpriteCB_KyogreBubbles(struct Sprite *sprite) { - switch(sprite->data[0]) + switch(sprite->sState) { case 0: - if (sprite->data[6] == 0) + if (sprite->sDelay == 0) { - sprite->data[1] = (sprite->data[1] + 11) & 0xFF; - sprite->pos2.x = Sin(sprite->data[1], 4); - sprite->data[2] += 0x30; - sprite->pos2.y = -(sprite->data[2] >> 8); + // Animation has started, float bubbles up + sprite->sSinIdx = (sprite->sSinIdx + 11) & 0xFF; + sprite->pos2.x = Sin(sprite->sSinIdx, 4); + sprite->sBaseY += 48; + sprite->pos2.y = -(sprite->sBaseY >> 8); if (sprite->animEnded) DestroySprite(sprite); } - else if (--sprite->data[6] == 0) + else if (--sprite->sDelay == 0) { + // Start bubble animation after delay has finished StartSpriteAnim(sprite, 0); sprite->invisible = FALSE; } - if (gTasks[sprite->data[5]].data[0] > 11) - sprite->data[0]++; + + // Check if Kyogre scene is ending + // For all but the last bubbles, sTaskId isn't actually set + if (gTasks[sprite->sTaskId].tState > 11) + sprite->sState++; break; case 1: - if (sprite->pos1.x < 120) + // Scene zooms in, move bubbles offscreen + if (sprite->pos1.x < DISPLAY_WIDTH / 2) sprite->pos1.x -= 3; else sprite->pos1.x += 3; - if (sprite->pos1.y < 80) + if (sprite->pos1.y < DISPLAY_HEIGHT / 2) sprite->pos1.y -= 3; else sprite->pos1.y += 3; - if ((u16)(sprite->pos1.y - 20) > 140) + + if ((u16)(sprite->pos1.y - 20) > DISPLAY_HEIGHT - 20) DestroySprite(sprite); break; } } -static void Task_IntroLoadClouds1(u8 taskId) +#undef sSinIdx +#undef sBaseY +#undef sTaskId +#undef sDelay +#undef sUnk + +static void Task_Scene3_LoadClouds1(u8 taskId) { SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1 @@ -2085,56 +2356,69 @@ static void Task_IntroLoadClouds1(u8 taskId) LZDecompressVram(gIntro3CloudsGfx, (void *)VRAM); LZDecompressVram(gIntro3CloudsGfx, (void *)(BG_CHAR_ADDR(1))); LZDecompressVram(gIntro3Clouds3Tilemap, (void *)(BG_SCREEN_ADDR(28))); - gTasks[taskId].func = Task_IntroLoadClouds2; + gTasks[taskId].func = Task_Scene3_LoadClouds2; } -static void Task_IntroLoadClouds2(u8 taskId) +static void Task_Scene3_LoadClouds2(u8 taskId) { LZDecompressVram(gIntro3Clouds1Tilemap, (void *)(BG_CHAR_ADDR(3))); LZDecompressVram(gIntro3Clouds2Tilemap, (void *)(BG_SCREEN_ADDR(26))); - gTasks[taskId].func = Task_IntroLoadClouds3; + gTasks[taskId].func = Task_Scene3_InitClouds; } -static void Task_IntroLoadClouds3(u8 taskId) +#define tCloudPos data[6] + +static void Task_Scene3_InitClouds(u8 taskId) { SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); - gTasks[taskId].func = Task_IntroCloudScene; - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[6] = 16; + gTasks[taskId].func = Task_Scene3_Clouds; + gTasks[taskId].tState = 0; + gTasks[taskId].tCloudPos = 16; } -static void Task_IntroCloudScene(u8 taskId) +// Clouds coming in from the sides before Rayquaza appears +static void Task_Scene3_Clouds(u8 taskId) { s16 *data = gTasks[taskId].data; - SetGpuReg(REG_OFFSET_BG0HOFS, (data[6] >> 8)); - SetGpuReg(REG_OFFSET_BG1HOFS, -(data[6] >> 8)); + // Left clouds are on BG0, right clouds are on BG1 + SetGpuReg(REG_OFFSET_BG0HOFS, (tCloudPos >> 8)); + SetGpuReg(REG_OFFSET_BG1HOFS, -(tCloudPos >> 8)); - switch (data[0]) + switch (tState) { case 0: - if (--data[6] == 0) + // Cloud position is used briefly as a delay, before + // the scene has faded in from white + if (--tCloudPos == 0) { + // Start fade in from white, set cloud starting positions BeginNormalPaletteFade(PALETTES_ALL & ~1, 0, 16, 0, RGB_WHITEALPHA); - data[6] = 0x5000; - data[0]++; + tCloudPos = 80 << 8; + tState++; } break; case 1: - if (data[6] == 0x2800) + // Start fading out + if (tCloudPos == 40 << 8) BeginNormalPaletteFade(PALETTES_BG & ~1, 3, 0, 16, RGB(9, 10, 10)); - if (data[6] != 0) - data[6] -= 0x80; + // Move clouds inward toward each other + if (tCloudPos != 0) + tCloudPos -= 128; else if (!gPaletteFade.active) - gTasks[taskId].func = Task_IntroLoadRayquazaLightningScene; + gTasks[taskId].func = Task_Scene3_LoadLightning; break; } } +#undef tCloudPos -static void Task_IntroLoadRayquazaLightningScene(u8 taskId) +#define tDelay data[6] +#define tTimer data[7] + +static void Task_Scene3_LoadLightning(u8 taskId) { LZDecompressVram(gIntro3RayquazaTilemap, (void *)(BG_SCREEN_ADDR(28))); LZDecompressVram(gIntro3Clouds4Tilemap, (void *)(BG_CHAR_ADDR(3))); @@ -2146,119 +2430,129 @@ static void Task_IntroLoadRayquazaLightningScene(u8 taskId) | DISPCNT_BG2_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON); - gTasks[taskId].func = Task_IntroRayquazaLightningScene; - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[6] = 1; - gTasks[taskId].data[7] = 0; - LoadCompressedSpriteSheetUsingHeap(gIntroRayquazaLightningSpriteSheet); - LoadSpritePalettes(gIntroRayquazaLightningPalette); + gTasks[taskId].func = Task_Scene3_Lightning; + gTasks[taskId].tState = 0; + gTasks[taskId].tDelay = 1; + gTasks[taskId].tTimer = 0; + LoadCompressedSpriteSheetUsingHeap(sSpriteSheet_Lightning); + LoadSpritePalettes(sSpritePalette_Lightning); } -static void Task_IntroRayquazaLightningScene(u8 taskId) +static void Task_Scene3_Lightning(u8 taskId) { s16 *data = gTasks[taskId].data; u8 spriteId; - switch (data[0]) + switch (tState) { case 0: - if (--data[6] == 0) + if (--tDelay == 0) { - CreateSprite(&gIntroLightningSprite, 200, 48, 0); - spriteId = CreateSprite(&gIntroLightningSprite, 200, 80, 1); + // Do first lightning bolt + CreateSprite(&sSpriteTemplate_Lightning, 200, 48, 0); + spriteId = CreateSprite(&sSpriteTemplate_Lightning, 200, 80, 1); StartSpriteAnim(&gSprites[spriteId], 1); - spriteId = CreateSprite(&gIntroLightningSprite, 200, 112, 2); + spriteId = CreateSprite(&sSpriteTemplate_Lightning, 200, 112, 2); StartSpriteAnim(&gSprites[spriteId], 2); - data[0]++; - data[6] = 72; + tState++; + tDelay = 72; } break; case 1: - if (--data[6] == 0) + if (--tDelay == 0) { - CreateSprite(&gIntroLightningSprite, 40, 48, 0); - spriteId = CreateSprite(&gIntroLightningSprite, 40, 80, 1); + // Do second lightning bolt + CreateSprite(&sSpriteTemplate_Lightning, 40, 48, 0); + spriteId = CreateSprite(&sSpriteTemplate_Lightning, 40, 80, 1); StartSpriteAnim(&gSprites[spriteId], 1); - spriteId = CreateSprite(&gIntroLightningSprite, 40, 112, 2); + spriteId = CreateSprite(&sSpriteTemplate_Lightning, 40, 112, 2); StartSpriteAnim(&gSprites[spriteId], 2); - data[0]++; - data[6] = 48; + tState++; + tDelay = 48; } break; case 2: - if (--data[6] == 0) - gTasks[taskId].func = Task_IntroLoadRayquazaGlowScene; + if (--tDelay == 0) + gTasks[taskId].func = Task_Scene3_LoadRayquazaAttack; break; } } -static void SpriteCB_IntroRayquazaLightning(struct Sprite *sprite) +#define sPalIdx data[1] +#define sDelay data[2] + +static void SpriteCB_Lightning(struct Sprite *sprite) { if (sprite->animEnded) sprite->invisible = TRUE; - switch(sprite->data[0]) + switch(sprite->sState) { case 0: - sprite->data[1] = 0x1C2; - sprite->data[0]++; + sprite->sPalIdx = 0x1C2; + sprite->sState++; case 1: - CpuCopy16(&gIntro3BgPal[sprite->data[1]], &gPlttBufferFaded[93], 2); - sprite->data[1] += 2; - if (sprite->data[1] != 0x1CE) + CpuCopy16(&gIntro3BgPal[sprite->sPalIdx], &gPlttBufferFaded[93], 2); + sprite->sPalIdx += 2; + if (sprite->sPalIdx != 0x1CE) break; - sprite->data[1] = 0x1CC; - sprite->data[2] = 4; - sprite->data[0]++; + sprite->sPalIdx = 0x1CC; + sprite->sDelay = 4; + sprite->sState++; case 2: - if (--sprite->data[2] == 0) + if (--sprite->sDelay == 0) { - sprite->data[2] = 4; - CpuCopy16(&gIntro3BgPal[sprite->data[1]], &gPlttBufferFaded[93], 2); - sprite->data[1] -= 2; - if (sprite->data[1] == 0x1C0) + sprite->sDelay = 4; + CpuCopy16(&gIntro3BgPal[sprite->sPalIdx], &gPlttBufferFaded[93], 2); + sprite->sPalIdx -= 2; + if (sprite->sPalIdx == 0x1C0) DestroySprite(sprite); } break; } } -static void Task_IntroLoadRayquazaGlowScene(u8 taskId) -{ - u8 newTaskId; +#undef sPalIdx +#undef sDelay - LoadCompressedSpriteSheet(gIntroRayquazaGlowSpriteSheet); - LoadSpritePalettes(gIntroRayquazaGlowPalette); +#define tRayquazaTaskId data[4] + +static void Task_Scene3_LoadRayquazaAttack(u8 taskId) +{ + u8 attackTaskId; + + LoadCompressedSpriteSheet(sSpriteSheet_RayquazaOrb); + LoadSpritePalettes(sSpritePalette_RayquazaOrb); 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_IntroRayquazaGlowScene_0; + gTasks[taskId].func = Task_Scene3_Rayquaza; BeginNormalPaletteFade(PALETTES_BG & ~(0x21), 0, 16, 0, RGB(9, 10, 10)); - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; gTasks[taskId].data[1] = 0xA8; gTasks[taskId].data[2] = -0x10; gTasks[taskId].data[3] = -0x88; gTasks[taskId].data[4] = -0x10; - newTaskId = CreateTask(Task_IntroRayquazaGlowScene_1, 0); - gTasks[newTaskId].data[4] = taskId; + attackTaskId = CreateTask(Task_RayquazaAttack, 0); + gTasks[attackTaskId].tRayquazaTaskId = taskId; } -static void Task_IntroRayquazaGlowScene_0(u8 taskId) +static void Task_Scene3_Rayquaza(u8 taskId) { s16 *data = gTasks[taskId].data; - if (data[7] % 2 == 0) + if (tTimer % 2 == 0) data[6] ^= 2; - data[7]++; + tTimer++; - switch(data[0]) + switch(tState) { case 0: - if ((data[7] & 1) != 0) + if ((tTimer & 1) != 0) { data[1] -= 2; data[2]++; @@ -2267,12 +2561,12 @@ static void Task_IntroRayquazaGlowScene_0(u8 taskId) } if (data[1] == 0x68) { - data[0]++; + tState++; data[5] = 1; } break; case 1: - data[0]++; + tState++; data[5] = 4; break; case 2: @@ -2283,7 +2577,7 @@ static void Task_IntroRayquazaGlowScene_0(u8 taskId) if (!gPaletteFade.active) { data[5] = 0x8C; - data[0]++; + tState++; } break; case 3: @@ -2292,6 +2586,8 @@ static void Task_IntroRayquazaGlowScene_0(u8 taskId) break; } } +#undef tDelay +#undef tTimer static void Task_EndIntroMovie(u8 taskId) { @@ -2299,14 +2595,13 @@ static void Task_EndIntroMovie(u8 taskId) SetMainCallback2(MainCB2_EndIntro); } -static void Task_IntroRayquazaGlowScene_1(u8 taskId) +static void Task_RayquazaAttack(u8 taskId) { - // Note: data[4] contains the taskId of Task_IntroRayquazaGlowScene_0 u8 spriteId; s16 *data = gTasks[taskId].data; data[2]++; - switch(data[0]) + switch(tState) { case 0: if ((data[2] & 1) != 0) @@ -2316,7 +2611,7 @@ static void Task_IntroRayquazaGlowScene_1(u8 taskId) } if (data[1] == 6) { - data[0]++; + tState++; data[1] = 0; data[3] = 10; } @@ -2331,7 +2626,7 @@ static void Task_IntroRayquazaGlowScene_1(u8 taskId) } if (data[1] == 6) { - data[0]++; + tState++; data[3] = 10; } } @@ -2350,11 +2645,11 @@ static void Task_IntroRayquazaGlowScene_1(u8 taskId) } if (data[1] == 6) { - spriteId = CreateSprite(&gIntroRayquazaHyperbeamSprite, 120, 88, 15); + spriteId = CreateSprite(&sSpriteTemplate_RayquazaOrb, 120, 88, 15); PlaySE(SE_INTRO_BLAST); gSprites[spriteId].invisible = TRUE; - gSprites[spriteId].data[3] = data[4]; - data[0]++; + gSprites[spriteId].data[3] = tRayquazaTaskId; + tState++; data[3] = 16; } } @@ -2375,7 +2670,7 @@ static void Task_IntroRayquazaGlowScene_1(u8 taskId) } else { - data[0]++; + tState++; data[3] = 53; } } @@ -2384,7 +2679,7 @@ static void Task_IntroRayquazaGlowScene_1(u8 taskId) if (--data[3] == 0) { BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITE); - data[0]++; + tState++; } break; case 5: @@ -2394,7 +2689,7 @@ static void Task_IntroRayquazaGlowScene_1(u8 taskId) } } -static void intro_reset_and_hide_bgs(void) +static void IntroResetGpuRegs(void) { SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_BG3HOFS, 0); @@ -2410,9 +2705,9 @@ static void intro_reset_and_hide_bgs(void) SetGpuReg(REG_OFFSET_BLDY, 0); } -static void Task_IntroWaterDrops_1(u8 taskId) +static void Task_BlendLogoIn(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: default: @@ -2423,10 +2718,10 @@ static void Task_IntroWaterDrops_1(u8 taskId) | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); - SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropAlphaBlend[31]); + SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[31]); SetGpuReg(REG_OFFSET_BLDY, 0); - gTasks[taskId].data[1] = 0x40; - gTasks[taskId].data[0]++; + gTasks[taskId].data[1] = ARRAY_COUNT(gTitleScreenAlphaBlend); + gTasks[taskId].tState++; break; case 1: if (gTasks[taskId].data[1] != 0) @@ -2435,13 +2730,13 @@ static void Task_IntroWaterDrops_1(u8 taskId) gTasks[taskId].data[1]--; tmp = gTasks[taskId].data[1] / 2; - SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropAlphaBlend[tmp]); + SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[tmp]); } else { - SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropAlphaBlend[0]); - gTasks[taskId].data[1] = 0x10; - gTasks[taskId].data[0]++; + SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[0]); + gTasks[taskId].data[1] = ARRAY_COUNT(gTitleScreenAlphaBlend) / 4; + gTasks[taskId].tState++; } break; case 2: @@ -2453,9 +2748,9 @@ static void Task_IntroWaterDrops_1(u8 taskId) } } -static void Task_IntroWaterDrops_2(u8 taskId) +static void Task_BlendLogoOut(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: default: @@ -2466,25 +2761,25 @@ static void Task_IntroWaterDrops_2(u8 taskId) | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); - SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropAlphaBlend[0]); + SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[0]); SetGpuReg(REG_OFFSET_BLDY, 0); gTasks[taskId].data[1] = 0; - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 1: - if (gTasks[taskId].data[1] < 62) + if (gTasks[taskId].data[1] < (int)ARRAY_COUNT(gTitleScreenAlphaBlend) - 2) { u8 tmp; gTasks[taskId].data[1]++; tmp = gTasks[taskId].data[1] / 2; - SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropAlphaBlend[tmp]); + SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[tmp]); } else { - SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropAlphaBlend[31]); - gTasks[taskId].data[1] = 0x10; - gTasks[taskId].data[0]++; + SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[31]); + gTasks[taskId].data[1] = ARRAY_COUNT(gTitleScreenAlphaBlend) / 4; + gTasks[taskId].tState++; } break; case 2: @@ -2526,9 +2821,9 @@ void PanFadeAndZoomScreen(u16 screenX, u16 screenY, u16 zoom, u16 alpha) SetGpuReg(REG_OFFSET_BG2Y_H, dest.dy >> 16); } -static void sub_816F318(struct Sprite *sprite) +static void SpriteCB_WaterDrop_Ripple(struct Sprite *sprite) { - u8 r0; + u8 palNum; if (sprite->data[2] >= 192) { @@ -2541,10 +2836,10 @@ static void sub_816F318(struct Sprite *sprite) sprite->invisible = FALSE; SetOamMatrix(sprite->data[1], sprite->data[2], 0, 0, sprite->data[2]); sprite->data[2] = (sprite->data[2] * 95) / 100; - r0 = (sprite->data[2] - 192) / 128 + 9; - if (r0 > 15) - r0 = 15; - sprite->oam.paletteNum = r0; + palNum = (sprite->data[2] - 192) / 128 + 9; + if (palNum > 15) + palNum = 15; + sprite->oam.paletteNum = palNum; } } else @@ -2553,17 +2848,17 @@ static void sub_816F318(struct Sprite *sprite) } } -static void sub_816F3A4(struct Sprite *sprite) +static void SpriteCB_WaterDropHalf(struct Sprite *sprite) { if (gSprites[sprite->data[7]].data[7] != 0) { sprite->invisible = TRUE; sprite->pos1.x += sprite->pos2.x; sprite->pos1.y += sprite->pos2.y; - StartSpriteAnim(sprite, 3); + StartSpriteAnim(sprite, DROP_ANIM_RIPPLE); sprite->data[2] = 1024; sprite->data[3] = 8 * (sprite->data[1] & 3); - sprite->callback = sub_816F318; + sprite->callback = SpriteCB_WaterDrop_Ripple; sprite->oam.shape = SPRITE_SHAPE(64x32); sprite->oam.size = SPRITE_SIZE(64x32); CalcCenterToCornerVec(sprite, SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), ST_OAM_AFFINE_ERASE); @@ -2577,13 +2872,14 @@ static void sub_816F3A4(struct Sprite *sprite) } } -static void sub_816F454(struct Sprite *sprite) +static void SpriteCB_WaterDrop(struct Sprite *sprite) { - if (sprite->data[0] != 0) - sprite->callback = sub_816F46C; + // Wait for sState to be modified by Task_Scene1_WaterDrops + if (sprite->sState != 0) + sprite->callback = SpriteCB_WaterDrop_Slide; } -static void sub_816F46C(struct Sprite *sprite) +static void SpriteCB_WaterDrop_Slide(struct Sprite *sprite) { if (sprite->pos1.x <= 116) { @@ -2592,7 +2888,7 @@ static void sub_816F46C(struct Sprite *sprite) sprite->pos1.x += 4; sprite->pos2.x = -4; sprite->data[4] = 128; - sprite->callback = sub_816F5B4; + sprite->callback = SpriteCB_WaterDrop_ReachLeafEnd; } else { @@ -2632,28 +2928,27 @@ static void sub_816F46C(struct Sprite *sprite) } } -static void sub_816F5B4(struct Sprite *sprite) +static void SpriteCB_WaterDrop_ReachLeafEnd(struct Sprite *sprite) { SetOamMatrix(sprite->data[1], sprite->data[6] + 64, 0, 0, sprite->data[6] + 64); SetOamMatrix(sprite->data[1] + 1, sprite->data[6] + 64, 0, 0, sprite->data[6] + 64); SetOamMatrix(sprite->data[1] + 2, sprite->data[6] + 64, 0, 0, sprite->data[6] + 64); if (sprite->data[4] != 64) { - u16 data4; - + u16 sinIdx; sprite->data[4] -= 8; - data4 = sprite->data[4]; - sprite->pos2.x = gSineTable[(u8)(data4 + 64)] / 64; - sprite->pos2.y = gSineTable[(u8)data4] / 64; + sinIdx = sprite->data[4]; + sprite->pos2.x = gSineTable[(u8)(sinIdx + 64)] / 64; + sprite->pos2.y = gSineTable[(u8)sinIdx] / 64; } else { sprite->data[4] = 0; - sprite->callback = sub_816F660; + sprite->callback = SpriteCB_WaterDrop_DangleFromLeaf; } } -static void sub_816F660(struct Sprite *sprite) +static void SpriteCB_WaterDrop_DangleFromLeaf(struct Sprite *sprite) { if (sprite->data[0] != 2) { @@ -2666,11 +2961,11 @@ static void sub_816F660(struct Sprite *sprite) } else { - sprite->callback = SpriteCB_WaterDropFall; + sprite->callback = SpriteCB_WaterDrop_Fall; } } -static void SpriteCB_WaterDropFall(struct Sprite *sprite) +static void SpriteCB_WaterDrop_Fall(struct Sprite *sprite) { if (sprite->pos1.y < sprite->data[5]) { @@ -2682,18 +2977,19 @@ static void SpriteCB_WaterDropFall(struct Sprite *sprite) sprite->invisible = TRUE; sprite->pos1.x += sprite->pos2.x; sprite->pos1.y += sprite->pos2.y; - StartSpriteAnim(sprite, 3); + StartSpriteAnim(sprite, DROP_ANIM_RIPPLE); sprite->data[2] = 1024; sprite->data[3] = 8 * (sprite->data[1] & 3); - sprite->callback = sub_816F318; + sprite->callback = SpriteCB_WaterDrop_Ripple; sprite->oam.shape = SPRITE_SHAPE(64x32); sprite->oam.size = SPRITE_SIZE(64x32); CalcCenterToCornerVec(sprite, SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), ST_OAM_AFFINE_ERASE); } } -//Duplicate function -static void SpriteCB_WaterDropFall_2(struct Sprite *sprite) +// Identical to SpriteCB_WaterDrop_Fall +// Used by the 2nd and 3rd water drops to skip the leaf slide +static void SpriteCB_WaterDropShort(struct Sprite *sprite) { if (sprite->pos1.y < sprite->data[5]) { @@ -2705,10 +3001,10 @@ static void SpriteCB_WaterDropFall_2(struct Sprite *sprite) sprite->invisible = TRUE; sprite->pos1.x += sprite->pos2.x; sprite->pos1.y += sprite->pos2.y; - StartSpriteAnim(sprite, 3); + StartSpriteAnim(sprite, DROP_ANIM_RIPPLE); sprite->data[2] = 1024; sprite->data[3] = 8 * (sprite->data[1] & 3); - sprite->callback = sub_816F318; + sprite->callback = SpriteCB_WaterDrop_Ripple; sprite->oam.shape = SPRITE_SHAPE(64x32); sprite->oam.size = SPRITE_SIZE(64x32); CalcCenterToCornerVec(sprite, SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), ST_OAM_AFFINE_ERASE); @@ -2720,7 +3016,8 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) u8 spriteId; u8 oldSpriteId; - spriteId = CreateSprite(&gIntroWaterDropSprite, x, y, 1); + // Create water drop reflection + spriteId = CreateSprite(&sSpriteTemplate_WaterDrop, x, y, 1); gSprites[spriteId].data[0] = 0; gSprites[spriteId].data[7] = 0; gSprites[spriteId].data[1] = d; @@ -2731,29 +3028,32 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_DOUBLE; gSprites[spriteId].oam.matrixNum = d; CalcCenterToCornerVec(&gSprites[spriteId], SPRITE_SHAPE(32x32), SPRITE_SIZE(32x32), ST_OAM_AFFINE_ERASE); - StartSpriteAnim(&gSprites[spriteId], 2); + StartSpriteAnim(&gSprites[spriteId], DROP_ANIM_REFLECTION); if (!fallImmediately) - gSprites[spriteId].callback = sub_816F454; + gSprites[spriteId].callback = SpriteCB_WaterDrop; // Do full anim, for 1st drop that slides along the leaf else - gSprites[spriteId].callback = SpriteCB_WaterDropFall_2; + gSprites[spriteId].callback = SpriteCB_WaterDropShort; // Skip to drop falling into the water, for 2nd and 3rd drops oldSpriteId = spriteId; - spriteId = CreateSprite(&gIntroWaterDropSprite, x, y, 1); + // Create water drop upper half + // Implicitly anim number 0, DROP_ANIM_UPPER_HALF + spriteId = CreateSprite(&sSpriteTemplate_WaterDrop, x, y, 1); gSprites[spriteId].data[7] = oldSpriteId; gSprites[spriteId].data[1] = d + 1; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_DOUBLE; gSprites[spriteId].oam.matrixNum = d + 1; CalcCenterToCornerVec(&gSprites[spriteId], SPRITE_SHAPE(32x32), SPRITE_SIZE(32x32), ST_OAM_AFFINE_ERASE); - gSprites[spriteId].callback = sub_816F3A4; + gSprites[spriteId].callback = SpriteCB_WaterDropHalf; - spriteId = CreateSprite(&gIntroWaterDropSprite, x, y, 1); + // Create water drop lower half + spriteId = CreateSprite(&sSpriteTemplate_WaterDrop, x, y, 1); gSprites[spriteId].data[7] = oldSpriteId; gSprites[spriteId].data[1] = d + 2; - StartSpriteAnim(&gSprites[spriteId], 1); + StartSpriteAnim(&gSprites[spriteId], DROP_ANIM_LOWER_HALF); gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_DOUBLE; gSprites[spriteId].oam.matrixNum = d + 2; CalcCenterToCornerVec(&gSprites[spriteId], SPRITE_SHAPE(32x32), SPRITE_SIZE(32x32), ST_OAM_AFFINE_ERASE); - gSprites[spriteId].callback = sub_816F3A4; + gSprites[spriteId].callback = SpriteCB_WaterDropHalf; SetOamMatrix(d, c + 32, 0, 0, c + 32); SetOamMatrix(d + 1, c + 32, 0, 0, c + 32); @@ -2762,39 +3062,51 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) return oldSpriteId; } -static void SpriteCB_IntroGraphicsBicycle(struct Sprite *sprite) +// State is handled by Task_Scene2_BikeRide +static void SpriteCB_PlayerOnBicycle(struct Sprite *sprite) { - switch (sprite->data[0]) + // Adjust x position + switch (sprite->sState) { case 0: + // Move forwards StartSpriteAnimIfDifferent(sprite, 0); sprite->pos1.x--; break; case 1: + // Drift backwards slowly StartSpriteAnimIfDifferent(sprite, 0); if (gIntroFrameCounter & 7) return; sprite->pos1.x++; break; case 2: + // Move backwards if (sprite->pos1.x <= 120 || gIntroFrameCounter & 7) sprite->pos1.x++; break; case 3: + // Bike in place break; case 4: + // Exit to the left if (sprite->pos1.x > -32) sprite->pos1.x -= 2; break; } + if (gIntroFrameCounter & 7) return; + + // Adjust y position if (sprite->pos2.y != 0) { + // Return to neutral after wobble sprite->pos2.y = 0; } else { + // Random wobble on y axis switch (Random() & 3) { case 0: @@ -2811,115 +3123,136 @@ static void SpriteCB_IntroGraphicsBicycle(struct Sprite *sprite) } } -static void SpriteCB_IntroGraphicsFlygon(struct Sprite *sprite) +#define sSinIdx data[1] + +// Movement is started by setting state to 1 in Task_Scene2_BikeRide +static void SpriteCB_Flygon(struct Sprite *sprite) { - switch (sprite->data[0]) + switch (sprite->sState) { case 0: break; case 1: - if (sprite->pos2.x + sprite->pos1.x < 304) + if (sprite->pos2.x + sprite->pos1.x < DISPLAY_WIDTH + 64) sprite->pos2.x += 8; else - sprite->data[0] = 2; + sprite->sState = 2; break; case 2: if (sprite->pos2.x + sprite->pos1.x > 120) sprite->pos2.x -= 1; else - sprite->data[0] = 3; + sprite->sState = 3; break; case 3: if (sprite->pos2.x > 0) sprite->pos2.x -= 2; break; } - sprite->pos2.y = Sin((u8)sprite->data[1], 8) - gIntroGraphicsFlygonYOffset; - sprite->data[1] += 4; + sprite->pos2.y = Sin((u8)sprite->sSinIdx, 8) - sFlygonYOffset; + sprite->sSinIdx += 4; } -static void sub_816FB38(struct Sprite *sprite) +#undef sSinIdx + +#define sTimer data[1] +#define sLetterId data[2] +#define sColorDelay data[3] +#define sLetterX data[3] // Re-used + +#define COLOR_CHANGES 9 // Number of stages for changing the letter color + +// For the letters in "Game Freak" +// Also intended for the letters in "Presents", which is never shown +static void SpriteCB_LogoLetter(struct Sprite *sprite) { - switch (sprite->data[0]) + switch (sprite->sState) { case 0: - if (sprite->data[1] != 0) + if (sprite->sTimer != 0) { - sprite->data[1]--; + sprite->sTimer--; } else { + // Start the grow and shrink appearance animation sprite->invisible = FALSE; StartSpriteAffineAnim(sprite, 1); - sprite->data[0]++; + sprite->sState++; } break; case 1: - if (gIntroFrameCounter == 0x90) + if (gIntroFrameCounter == TIMER_LOGO_LETTERS_COLOR) { - sprite->data[0]++; - sprite->data[1] = 9; - sprite->data[3] = 2; + // Initialize color fade + sprite->sState++; + sprite->sTimer = COLOR_CHANGES; + sprite->sColorDelay = 2; } break; case 2: - if (sprite->data[3] == 0) + // Fade letters to blue + if (sprite->sColorDelay == 0) { - sprite->data[3] = 2; - if (sprite->data[1] != 0) + sprite->sColorDelay = 2; + if (sprite->sTimer != 0) { - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1]], &gPlttBufferFaded[0x11F], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1] + 0x10], &gPlttBufferFaded[0x114], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1] + 0x20], &gPlttBufferFaded[0x11A], 2); - sprite->data[1]--; + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); + sprite->sTimer--; } else { - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1]], &gPlttBufferFaded[0x11F], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1] + 0x10], &gPlttBufferFaded[0x114], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1] + 0x20], &gPlttBufferFaded[0x11A], 2); - sprite->data[0]++; + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); + sprite->sState++; } } else { - sprite->data[3]--; + sprite->sColorDelay--; } break; case 3: - if (sprite->data[3] != 0) + // Fade letters back to white + if (sprite->sColorDelay != 0) { - sprite->data[3]--; + sprite->sColorDelay--; } else { - sprite->data[3] = 2; - if (sprite->data[1] < 10) + sprite->sColorDelay = 2; + if (sprite->sTimer <= COLOR_CHANGES) { - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1]], &gPlttBufferFaded[0x11F], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1] + 0x10], &gPlttBufferFaded[0x114], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->data[1] + 0x20], &gPlttBufferFaded[0x11A], 2); - sprite->data[1]++; + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); + CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); + sprite->sTimer++; } else { - sprite->data[0]++; + sprite->sState++; } } break; case 4: - if (gIntroFrameCounter == 0x110) + if (gIntroFrameCounter == TIMER_LOGO_DISAPPEAR) { + // Start the grow disappearance animation StartSpriteAffineAnim(sprite, 2); sprite->oam.objMode = ST_OAM_OBJ_BLEND; - sprite->data[0]++; + sprite->sState++; } break; case 5: - sprite->data[3] += gUnknown_085E4F48[sprite->data[2]]; - sprite->pos2.x = (sprite->data[3] & 0xFF00) >> 8; - if (sprite->data[2] < 4) + // Spread the letters out as they grow + sprite->sLetterX += sGameFreakLettersMoveSpeed[sprite->sLetterId]; + sprite->pos2.x = (sprite->sLetterX & 0xFF00) >> 8; + if (sprite->sLetterId < 4) { + // Is in first 4 letters, i.e. "Game" s16 temp = sprite->pos2.x; sprite->pos2.x = -temp; } @@ -2929,22 +3262,23 @@ static void sub_816FB38(struct Sprite *sprite) } } -static void sub_816FD44(struct Sprite *sprite) +static void SpriteCB_GameFreakLogo(struct Sprite *sprite) { - switch(sprite->data[0]) + switch(sprite->sState) { case 0: - if (gIntroFrameCounter == 0x80) + if (gIntroFrameCounter == TIMER_LOGO_APPEAR) { sprite->invisible = FALSE; - sprite->data[0]++; + sprite->sState++; } break; case 1: - if (gIntroFrameCounter == 0x110) + if (gIntroFrameCounter == TIMER_LOGO_DISAPPEAR) { + // Start the grow disappearance animation StartSpriteAffineAnim(sprite, 3); - sprite->data[0]++; + sprite->sState++; } break; case 2: @@ -2954,35 +3288,45 @@ static void sub_816FD44(struct Sprite *sprite) } } -static u8 CreatePart1Animations(s16 a0, s16 a1, s16 a2) +static u8 CreateGameFreakLogoSprites(s16 x, s16 y, s16 unused) { u16 i; u8 spriteId; - for (i = 0; i < 9; i++) + // Create "Game Freak" letters + for (i = 0; i < NUM_GF_LETTERS; i++) { - spriteId = CreateSprite(&gUnknown_085E4F5C, gUnknown_085E4E94[i][1] + a0, a1 - 4, 0); - gSprites[spriteId].data[0] = 0; - gSprites[spriteId].data[1] = gUnknown_085E4FA4[i]; - gSprites[spriteId].data[2] = i; + spriteId = CreateSprite(&sSpriteTemplate_GameFreakLetter, sGameFreakLetterData[i][1] + x, y - 4, 0); + gSprites[spriteId].sState = 0; + gSprites[spriteId].sTimer = sGameFreakLetterStartDelays[i]; + gSprites[spriteId].sLetterId = i; gSprites[spriteId].invisible = TRUE; gSprites[spriteId].oam.matrixNum = i + 12; - StartSpriteAnim(&gSprites[spriteId], gUnknown_085E4E94[i][0]); + StartSpriteAnim(&gSprites[spriteId], sGameFreakLetterData[i][0]); StartSpriteAffineAnim(&gSprites[spriteId], 0); } - spriteId = CreateSprite(&gUnknown_085E4F8C, 120, a1 - 6, 0); - gSprites[spriteId].data[0] = 0; + + // Create Game Freak logo + spriteId = CreateSprite(&sSpriteTemplate_GameFreakLogo, 120, y - 6, 0); + gSprites[spriteId].sState = 0; gSprites[spriteId].invisible = TRUE; gSprites[spriteId].oam.matrixNum = i + 12; StartSpriteAffineAnim(&gSprites[spriteId], 1); + return spriteId; } -static void sub_816FEDC(struct Sprite *sprite) +#undef sTimer +#undef sLetterId +#undef sColorDelay +#undef sLetterX +#undef COLOR_CHANGES + +static void SpriteCB_FlygonSilhouette(struct Sprite *sprite) { sprite->data[7]++; - if (sprite->data[0] != 0) + if (sprite->sState != 0) { s16 sin1; s16 sin2; @@ -3000,7 +3344,7 @@ static void sub_816FEDC(struct Sprite *sprite) SetOamMatrix(1, a, b, c, d); } - switch (sprite->data[0]) + switch (sprite->sState) { case 0: default: @@ -3008,7 +3352,7 @@ static void sub_816FEDC(struct Sprite *sprite) sprite->oam.matrixNum = 1; CalcCenterToCornerVec(sprite, SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), ST_OAM_AFFINE_DOUBLE); sprite->invisible = FALSE; - sprite->data[0] = 1; + sprite->sState = 1; sprite->data[1] = 0x80; sprite->data[2] = 0; sprite->data[3] = 0; @@ -3021,7 +3365,7 @@ static void sub_816FEDC(struct Sprite *sprite) if (sprite->pos1.x + sprite->pos2.x <= -16) { sprite->oam.priority = 3; - sprite->data[0]++; + sprite->sState++; sprite->pos1.x = 20; sprite->pos1.y = 40; sprite->data[1] = 0x200; @@ -3039,13 +3383,10 @@ static void sub_816FEDC(struct Sprite *sprite) } } -static void SpriteCB_IntroRayquazaHyperbeam(struct Sprite *sprite) +static void SpriteCB_RayquazaOrb(struct Sprite *sprite) { u16 foo; - - //I'm not sure why a switch statement was used here. - //if (sprite->data[0] != 1) would have been more appropriate. - switch (sprite->data[0]) + switch (sprite->sState) { case 0: default: @@ -3054,7 +3395,7 @@ static void SpriteCB_IntroRayquazaHyperbeam(struct Sprite *sprite) sprite->oam.matrixNum = 18; CalcCenterToCornerVec(sprite, SPRITE_SHAPE(64x64), SPRITE_SIZE(64x64), ST_OAM_AFFINE_DOUBLE); sprite->data[1] = 0; - sprite->data[0] = 1; + sprite->sState = 1; //fall through case 1: sprite->data[7]++; diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c index 45cc24e5c8..4cb26a9bf2 100644 --- a/src/intro_credits_graphics.c +++ b/src/intro_credits_graphics.c @@ -6,6 +6,25 @@ #include "task.h" #include "main.h" #include "graphics.h" +#include "constants/rgb.h" + +/* + The graphics here are used by both the second scene of the intro + and the credit sequence, where the player bikes along a grassy path. + + These graphics are placed in graphics/intro/scene_2 to keep + all of the intro graphics files together, though it includes + the related graphics that are used only by the credits. +*/ + +#define TAG_BICYCLE 1001 +#define TAG_BRENDAN 1002 +#define TAG_MAY 1003 +#define TAG_FLYGON_LATIOS 1004 +#define TAG_FLYGON_LATIAS 1005 + +// Used for the Clouds/Trees/Houses sprites that pass by in the background +#define TAG_MOVING_SCENERY 2000 struct IntroCreditsSpriteMetadata { @@ -18,62 +37,62 @@ struct IntroCreditsSpriteMetadata u16 xOff; }; -static const u16 gUnknown_085F06E0[] = INCBIN_U16("graphics/intro/intro2_grass.gbapal"); -static const u16 gUnknown_085F0700[] = INCBIN_U16("graphics/intro/intro2_grass_afternoon.gbapal"); -static const u16 gUnknown_085F0720[] = INCBIN_U16("graphics/intro/intro2_grass_night.gbapal"); -static const u32 gUnknown_085F0740[] = INCBIN_U32("graphics/intro/intro2_grass.4bpp.lz"); -static const u32 gUnknown_085F0BC0[] = INCBIN_U32("graphics/intro/intro2_grass_map.bin.lz"); -static const u16 gUnknown_085F0CFC[] = INCBIN_U16("graphics/intro/85F0CFC.gbapal"); -static const u16 gUnknown_085F0D5C[] = INCBIN_U16("graphics/intro/85F0D5C.gbapal"); -static const u32 gUnknown_085F0DBC[] = INCBIN_U32("graphics/intro/intro2_bgclouds.4bpp.lz"); -static const u32 gUnknown_085F1398[] = INCBIN_U32("graphics/intro/intro2_bgclouds_map.bin.lz"); -static const u16 gUnknown_085F1668[] = INCBIN_U16("graphics/intro/intro2_bgclouds.gbapal"); -static const u16 gUnknown_085F1688[] = INCBIN_U16("graphics/intro/intro2_bgclouds_afternoon.gbapal"); -static const u32 gUnknown_085F16A8[] = INCBIN_U32("graphics/intro/intro2_bgclouds2.4bpp.lz"); -static const u16 gUnknown_085F17E4[] = INCBIN_U16("graphics/intro/intro2_bgtrees2.gbapal"); -static const u16 gUnknown_085F1804[] = INCBIN_U16("graphics/intro/intro2_bgtrees2_afternoon.gbapal"); -static const u32 gUnknown_085F1824[] = INCBIN_U32("graphics/intro/intro2_bgtrees.4bpp.lz"); -static const u32 gUnknown_085F1EAC[] = INCBIN_U32("graphics/intro/intro2_bgtrees_map.bin.lz"); -static const u16 gUnknown_085F21B0[] = INCBIN_U16("graphics/intro/intro2_bgtrees.gbapal"); -static const u32 gIntro2TreeTiles[] = INCBIN_U32("graphics/intro/intro2_bgtreessmall.4bpp.lz"); -static const u16 gUnknown_085F231C[] = INCBIN_U16("graphics/intro/85F231C.gbapal"); -static const u32 gUnknown_085F235C[] = INCBIN_U32("graphics/intro/intro2_bgnight.4bpp.lz"); -static const u16 gUnknown_085F2548[] = INCBIN_U16("graphics/intro/intro2_bgnight.gbapal"); -static const u32 gUnknown_085F2568[] = INCBIN_U32("graphics/intro/intro2_bgnight_map.bin.lz"); -static const u32 gIntro2NightTiles[] = INCBIN_U32("graphics/intro/intro2_night.4bpp.lz"); -static const u16 gIntro2BrendanPalette[] = INCBIN_U16("graphics/intro/intro2_brendan.gbapal"); -static const u32 gIntro2BrendanTiles[] = INCBIN_U32("graphics/intro/intro2_brendan.4bpp.lz"); -static const u16 gIntro2MayPalette[] = INCBIN_U16("graphics/intro/intro2_may.gbapal"); -static const u16 gUnknown_085F3490[0xF0] = {0}; -static const u32 gIntro2MayTiles[] = INCBIN_U32("graphics/intro/intro2_may.4bpp.lz"); -static const u32 gIntro2BicycleTiles[] = INCBIN_U32("graphics/intro/intro2_bicycle.4bpp.lz"); -static const u16 gIntro2LatiosPalette[] = INCBIN_U16("graphics/intro/intro2_latios.gbapal"); -static const u32 gIntro2LatiosTiles[] = INCBIN_U32("graphics/intro/intro2_latios.4bpp.lz"); -static const u16 gIntro2LatiasPalette[] = INCBIN_U16("graphics/intro/intro2_latias.gbapal"); -static const u32 gIntro2LatiasTiles[] = INCBIN_U32("graphics/intro/intro2_latias.4bpp.lz"); +static const u16 sGrass_Pal[] = INCBIN_U16("graphics/intro/scene_2/grass.gbapal"); +static const u16 sGrassAfternoon_Pal[] = INCBIN_U16("graphics/intro/scene_2/grass_afternoon.gbapal"); +static const u16 sGrassNight_Pal[] = INCBIN_U16("graphics/intro/scene_2/grass_night.gbapal"); +static const u32 sGrass_Gfx[] = INCBIN_U32("graphics/intro/scene_2/grass.4bpp.lz"); +static const u32 sGrass_Tilemap[] = INCBIN_U32("graphics/intro/scene_2/grass_map.bin.lz"); +static const u16 sCloudsBg_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds_bg.gbapal"); +static const u16 sCloudsBgAfternoon_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds_bg_afternoon.gbapal"); +static const u32 sCloudsBg_Gfx[] = INCBIN_U32("graphics/intro/scene_2/clouds_bg.4bpp.lz"); +static const u32 sCloudsBg_Tilemap[] = INCBIN_U32("graphics/intro/scene_2/clouds_bg_map.bin.lz"); +static const u16 sClouds_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds.gbapal"); +static const u16 sCloudsAfternoon_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds_afternoon.gbapal"); +static const u32 sClouds_Gfx[] = INCBIN_U32("graphics/intro/scene_2/clouds.4bpp.lz"); +static const u16 sTrees_Pal[] = INCBIN_U16("graphics/intro/scene_2/trees.gbapal"); +static const u16 sTreesAfternoon_Pal[] = INCBIN_U16("graphics/intro/scene_2/trees_afternoon.gbapal"); +static const u32 sTrees_Gfx[] = INCBIN_U32("graphics/intro/scene_2/trees.4bpp.lz"); +static const u32 sTrees_Tilemap[] = INCBIN_U32("graphics/intro/scene_2/trees_map.bin.lz"); +static const u16 sTreesSmall_Pal[] = INCBIN_U16("graphics/intro/scene_2/trees_small.gbapal"); +static const u32 sTreesSmall_Gfx[] = INCBIN_U32("graphics/intro/scene_2/trees_small.4bpp.lz"); +static const u16 sHouses_Pal[] = INCBIN_U16("graphics/intro/scene_2/houses.gbapal"); +static const u32 sHouses_Gfx[] = INCBIN_U32("graphics/intro/scene_2/houses.4bpp.lz"); +static const u16 sHouseSilhouette_Pal[] = INCBIN_U16("graphics/intro/scene_2/house_silhouette.gbapal"); +static const u32 sHouses_Tilemap[] = INCBIN_U32("graphics/intro/scene_2/houses_map.bin.lz"); +static const u32 sHouseSilhouette_Gfx[] = INCBIN_U32("graphics/intro/scene_2/house_silhouette.4bpp.lz"); +static const u16 sBrendanCredits_Pal[] = INCBIN_U16("graphics/intro/scene_2/brendan_credits.gbapal"); +static const u32 sBrendanCredits_Gfx[] = INCBIN_U32("graphics/intro/scene_2/brendan_credits.4bpp.lz"); +static const u16 sMayCredits_Pal[] = INCBIN_U16("graphics/intro/scene_2/may_credits.gbapal"); +static const u16 sUnused[0xF0] = {0}; +static const u32 sMayCredits_Gfx[] = INCBIN_U32("graphics/intro/scene_2/may_credits.4bpp.lz"); +static const u32 sBicycle_Gfx[] = INCBIN_U32("graphics/intro/scene_2/bicycle.4bpp.lz"); +static const u16 sLatios_Pal[] = INCBIN_U16("graphics/intro/scene_2/latios.gbapal"); +static const u32 sLatios_Gfx[] = INCBIN_U32("graphics/intro/scene_2/latios.4bpp.lz"); +static const u16 sLatias_Pal[] = INCBIN_U16("graphics/intro/scene_2/latias.gbapal"); +static const u32 sLatias_Gfx[] = INCBIN_U32("graphics/intro/scene_2/latias.4bpp.lz"); -static void sub_817B62C(struct Sprite *sprite); -static void nullsub_65(struct Sprite *sprite); -static void sub_817B7C4(struct Sprite *sprite); -static void nullsub_66(struct Sprite *sprite); +static void SpriteCB_MovingScenery(struct Sprite *sprite); +static void SpriteCB_Player(struct Sprite *sprite); +static void SpriteCB_Bicycle(struct Sprite *sprite); +static void SpriteCB_FlygonLeftHalf(struct Sprite *sprite); -static const struct SpriteTemplate gUnknown_085F504C = +static const struct SpriteTemplate sSpriteTemplate_MovingScenery = { - .tileTag = 2000, + .tileTag = TAG_MOVING_SCENERY, .paletteTag = 0xFFFF, .oam = &gDummyOamData, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_817B62C + .callback = SpriteCB_MovingScenery }; -static const struct CompressedSpriteSheet gUnknown_085F5064[] = +static const struct CompressedSpriteSheet sSpriteSheet_Clouds[] = { { - .data = gUnknown_085F16A8, + .data = sClouds_Gfx, .size = 0x400, - .tag = 2000 + .tag = TAG_MOVING_SCENERY }, {} }; @@ -102,7 +121,7 @@ static const union AnimCmd gUnknown_085F508C[] = ANIMCMD_END }; -static const union AnimCmd *const gUnknown_085F5094[] = +static const union AnimCmd *const sAnims_Clouds[] = { gUnknown_085F5074, gUnknown_085F507C, @@ -110,7 +129,7 @@ static const union AnimCmd *const gUnknown_085F5094[] = gUnknown_085F508C }; -static const struct IntroCreditsSpriteMetadata gUnknown_085F50A4[] = +static const struct IntroCreditsSpriteMetadata sSpriteMetadata_Clouds[] = { { .animNum = 0, @@ -195,12 +214,12 @@ static const struct IntroCreditsSpriteMetadata gUnknown_085F50A4[] = }, }; -static const struct CompressedSpriteSheet gUnknown_085F50EC[] = +static const struct CompressedSpriteSheet sSpriteSheet_TreesSmall[] = { { - .data = gIntro2TreeTiles, + .data = sTreesSmall_Gfx, .size = 0x400, - .tag = 2000 + .tag = TAG_MOVING_SCENERY }, {} }; @@ -223,14 +242,14 @@ static const union AnimCmd gUnknown_085F510C[] = ANIMCMD_END }; -static const union AnimCmd *const gUnknown_085F5114[] = +static const union AnimCmd *const sAnims_TreesSmall[] = { gUnknown_085F50FC, gUnknown_085F5104, gUnknown_085F510C }; -static const struct IntroCreditsSpriteMetadata gUnknown_085F5120[] = +static const struct IntroCreditsSpriteMetadata sSpriteMetadata_Trees[] = { { .animNum = 0, @@ -342,28 +361,28 @@ static const struct IntroCreditsSpriteMetadata gUnknown_085F5120[] = } }; -static const struct CompressedSpriteSheet gUnknown_085F5180[] = +static const struct CompressedSpriteSheet sSpriteSheet_HouseSilhouette[] = { { - .data = gIntro2NightTiles, + .data = sHouseSilhouette_Gfx, .size = 0x400, - .tag = 2000 + .tag = TAG_MOVING_SCENERY }, {} }; -static const union AnimCmd gUnknown_085F5190[] = +static const union AnimCmd sAnim_HouseSilhouette[] = { ANIMCMD_FRAME(0, 30), ANIMCMD_END }; -static const union AnimCmd *const gUnknown_085F5198[] = +static const union AnimCmd *const sAnims_HouseSilhouette[] = { - gUnknown_085F5190 + sAnim_HouseSilhouette }; -static const struct IntroCreditsSpriteMetadata gUnknown_085F519C[] = +static const struct IntroCreditsSpriteMetadata sSpriteMetadata_HouseSilhouette[] = { { .animNum = 0, @@ -421,7 +440,7 @@ static const struct IntroCreditsSpriteMetadata gUnknown_085F519C[] = } }; -static const struct OamData gOamData_85F51CC = +static const struct OamData sOamData_Player = { .y = 160, .shape = SPRITE_SHAPE(64x64), @@ -429,7 +448,7 @@ static const struct OamData gOamData_85F51CC = .priority = 1 }; -static const union AnimCmd gUnknown_085F51D4[] = +static const union AnimCmd sAnim_Player[] = { ANIMCMD_FRAME( 0, 8), ANIMCMD_FRAME( 64, 8), @@ -438,34 +457,34 @@ static const union AnimCmd gUnknown_085F51D4[] = ANIMCMD_JUMP(0) }; -static const union AnimCmd *const gUnknown_085F51E8[] = +static const union AnimCmd *const sAnims_Player[] = { - gUnknown_085F51D4 + sAnim_Player }; -static const struct SpriteTemplate gUnknown_085F51EC = +static const struct SpriteTemplate sSpriteTemplate_Brendan = { - .tileTag = 1002, - .paletteTag = 1002, - .oam = &gOamData_85F51CC, - .anims = gUnknown_085F51E8, + .tileTag = TAG_BRENDAN, + .paletteTag = TAG_BRENDAN, + .oam = &sOamData_Player, + .anims = sAnims_Player, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = nullsub_65 + .callback = SpriteCB_Player }; -static const struct SpriteTemplate gUnknown_085F5204 = +static const struct SpriteTemplate sSpriteTemplate_May = { - .tileTag = 1003, - .paletteTag = 1003, - .oam = &gOamData_85F51CC, - .anims = gUnknown_085F51E8, + .tileTag = TAG_MAY, + .paletteTag = TAG_MAY, + .oam = &sOamData_Player, + .anims = sAnims_Player, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = nullsub_65 + .callback = SpriteCB_Player }; -static const struct OamData gUnknown_085F521C = +static const struct OamData sOamData_Bicycle = { .y = 160, .shape = SPRITE_SHAPE(64x32), @@ -473,7 +492,7 @@ static const struct OamData gUnknown_085F521C = .priority = 1 }; -static const union AnimCmd gUnknown_085F5224[] = +static const union AnimCmd sAnim_Bicycle[] = { ANIMCMD_FRAME( 0, 8), ANIMCMD_FRAME( 32, 8), @@ -482,34 +501,34 @@ static const union AnimCmd gUnknown_085F5224[] = ANIMCMD_JUMP(0) }; -static const union AnimCmd *const gUnknown_085F5238[] = +static const union AnimCmd *const sAnims_Bicycle[] = { - gUnknown_085F5224 + sAnim_Bicycle }; -static const struct SpriteTemplate gUnknown_085F523C = +static const struct SpriteTemplate sSpriteTemplate_BrendanBicycle = { - .tileTag = 1001, - .paletteTag = 1002, - .oam = &gUnknown_085F521C, - .anims = gUnknown_085F5238, + .tileTag = TAG_BICYCLE, + .paletteTag = TAG_BRENDAN, + .oam = &sOamData_Bicycle, + .anims = sAnims_Bicycle, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_817B7C4 + .callback = SpriteCB_Bicycle }; -static const struct SpriteTemplate gUnknown_085F5254 = +static const struct SpriteTemplate sSpriteTemplate_MayBicycle = { - .tileTag = 1001, - .paletteTag = 1003, - .oam = &gUnknown_085F521C, - .anims = gUnknown_085F5238, + .tileTag = TAG_BICYCLE, + .paletteTag = TAG_MAY, + .oam = &sOamData_Bicycle, + .anims = sAnims_Bicycle, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_817B7C4 + .callback = SpriteCB_Bicycle }; -static const struct OamData gUnknown_085F526C = +static const struct OamData sOamData_Flygon = { .y = 160, .shape = SPRITE_SHAPE(64x64), @@ -517,226 +536,232 @@ static const struct OamData gUnknown_085F526C = .priority = 1 }; -static const union AnimCmd gUnknown_085F5274[] = +static const union AnimCmd sAnim_FlygonLeft[] = { ANIMCMD_FRAME( 0, 16), ANIMCMD_END }; -static const union AnimCmd gUnknown_085F527C[] = +static const union AnimCmd sAnim_FlygonRight[] = { ANIMCMD_FRAME( 64, 16), ANIMCMD_END }; -static const union AnimCmd *const gUnknown_085F5284[] = +static const union AnimCmd *const sAnims_Flygon[] = { - gUnknown_085F5274, - gUnknown_085F527C + sAnim_FlygonLeft, + sAnim_FlygonRight }; -static const struct SpriteTemplate gUnknown_085F528C = +static const struct SpriteTemplate sSpriteTemplate_FlygonLatios = { - .tileTag = 1004, - .paletteTag = 1004, - .oam = &gUnknown_085F526C, - .anims = gUnknown_085F5284, + .tileTag = TAG_FLYGON_LATIOS, + .paletteTag = TAG_FLYGON_LATIOS, + .oam = &sOamData_Flygon, + .anims = sAnims_Flygon, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = nullsub_66 + .callback = SpriteCB_FlygonLeftHalf }; -static const struct SpriteTemplate gUnknown_085F52A4 = +static const struct SpriteTemplate sSpriteTemplate_FlygonLatias = { - .tileTag = 1005, - .paletteTag = 1005, - .oam = &gUnknown_085F526C, - .anims = gUnknown_085F5284, + .tileTag = TAG_FLYGON_LATIAS, + .paletteTag = TAG_FLYGON_LATIAS, + .oam = &sOamData_Flygon, + .anims = sAnims_Flygon, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = nullsub_66 + .callback = SpriteCB_FlygonLeftHalf }; -const struct CompressedSpriteSheet gIntro2BrendanSpriteSheet[] = +const struct CompressedSpriteSheet gSpriteSheet_IntroBrendan[] = { { - .data = gIntro2BrendanNoTurnGfx, + .data = gIntro2BrendanGfx, .size = 0x2000, - .tag = 1002 + .tag = TAG_BRENDAN }, {} }; -const struct CompressedSpriteSheet gIntro2MaySpriteSheet[] = +const struct CompressedSpriteSheet gSpriteSheet_IntroMay[] = { { - .data = gIntro2MayNoTurnGfx, + .data = gIntro2MayGfx, .size = 0x2000, - .tag = 1003 + .tag = TAG_MAY }, {} }; -const struct CompressedSpriteSheet gIntro2BicycleSpriteSheet[] = +const struct CompressedSpriteSheet gSpriteSheet_IntroBicycle[] = { { - .data = gIntro2BicycleTiles, + .data = sBicycle_Gfx, .size = 0x1000, - .tag = 1001 + .tag = TAG_BICYCLE }, {} }; -static const struct CompressedSpriteSheet gUnknown_085F52EC[] = +// In RS these were Latios/Latias. In Emerald both are replaced with Flygon and now only 1 is used +static const struct CompressedSpriteSheet sSpriteSheet_IntroFlygon_Unused[] = { { .data = gIntro2FlygonGfx, .size = 0x1000, - .tag = 1004 + .tag = TAG_FLYGON_LATIOS }, {} }; -const struct CompressedSpriteSheet gIntro2FlygonSpriteSheet[] = +const struct CompressedSpriteSheet gSpriteSheet_IntroFlygon[] = { { .data = gIntro2FlygonGfx, .size = 0x1000, - .tag = 1005 + .tag = TAG_FLYGON_LATIAS }, {} }; -const struct SpritePalette gIntroBikeAndFlygonPalette[] = +const struct SpritePalette gSpritePalettes_IntroPlayerFlygon[] = { - { .data = gIntro2BrendanNoTurnPal, .tag = 1002 }, - { .data = gIntro2BrendanNoTurnPal, .tag = 1003 }, - { .data = gIntro2FlygonPal, .tag = 1004 }, - { .data = gIntro2FlygonPal, .tag = 1005 }, + { .data = gIntro2PlayerPal, .tag = TAG_BRENDAN }, + { .data = gIntro2PlayerPal, .tag = TAG_MAY }, + { .data = gIntro2FlygonPal, .tag = TAG_FLYGON_LATIOS }, + { .data = gIntro2FlygonPal, .tag = TAG_FLYGON_LATIAS }, {} }; -const struct CompressedSpriteSheet gUnknown_085F5334[] = +const struct CompressedSpriteSheet gSpriteSheet_CreditsBrendan[] = { { - .data = gIntro2BrendanTiles, + .data = sBrendanCredits_Gfx, .size = 0x3800, - .tag = 1002 + .tag = TAG_BRENDAN }, {} }; -const struct CompressedSpriteSheet gUnknown_085F5344[] = +const struct CompressedSpriteSheet gSpriteSheet_CreditsMay[] = { { - .data = gIntro2MayTiles, + .data = sMayCredits_Gfx, .size = 0x3800, - .tag = 1003 + .tag = TAG_MAY }, {} }; -const struct CompressedSpriteSheet gUnknown_085F5354[] = +const struct CompressedSpriteSheet gSpriteSheet_CreditsBicycle[] = { { - .data = gIntro2BicycleTiles, + .data = sBicycle_Gfx, .size = 0x1000, - .tag = 1001 + .tag = TAG_BICYCLE }, {} }; -static const struct CompressedSpriteSheet gUnknown_085F5364[] = +// Unused +static const struct CompressedSpriteSheet sSpriteSheet_Latios[] = { { - .data = gIntro2LatiosTiles, + .data = sLatios_Gfx, .size = 0x1000, - .tag = 1004 + .tag = TAG_FLYGON_LATIOS }, {} }; -static const struct CompressedSpriteSheet gUnknown_085F5374[] = +// Unused +static const struct CompressedSpriteSheet sSpriteSheet_Latias[] = { { - .data = gIntro2LatiasTiles, + .data = sLatias_Gfx, .size = 0x1000, - .tag = 1005 + .tag = TAG_FLYGON_LATIAS }, {} }; -const struct SpritePalette gUnknown_085F5384[] = +const struct SpritePalette gSpritePalettes_Credits[] = { - { .data = gIntro2BrendanPalette, .tag = 1002 }, - { .data = gIntro2MayPalette, .tag = 1003 }, - { .data = gIntro2LatiosPalette, .tag = 1004 }, - { .data = gIntro2LatiasPalette, .tag = 1005 }, + { .data = sBrendanCredits_Pal, .tag = TAG_BRENDAN }, + { .data = sMayCredits_Pal, .tag = TAG_MAY }, + { .data = sLatios_Pal, .tag = TAG_FLYGON_LATIOS }, + { .data = sLatias_Pal, .tag = TAG_FLYGON_LATIAS }, {} }; -const struct CompressedSpriteSheet gUnknown_085F53AC[] = +const struct CompressedSpriteSheet gSpriteSheet_CreditsRivalBrendan[] = { { - .data = gIntro2BrendanTiles, + .data = sBrendanCredits_Gfx, .size = 0x2000, - .tag = 1002 + .tag = TAG_BRENDAN }, {} }; -const struct CompressedSpriteSheet gUnknown_085F53BC[] = +const struct CompressedSpriteSheet gSpriteSheet_CreditsRivalMay[] = { { - .data = gIntro2MayTiles, + .data = sMayCredits_Gfx, .size = 0x2000, - .tag = 1003 + .tag = TAG_MAY }, {} }; -EWRAM_DATA u16 gUnknown_0203BD24 = 0; -EWRAM_DATA s16 gUnknown_0203BD26 = 0; -EWRAM_DATA s16 gUnknown_0203BD28 = 0; +EWRAM_DATA u16 gIntroCredits_MovingSceneryVBase = 0; +EWRAM_DATA s16 gIntroCredits_MovingSceneryVOffset = 0; +EWRAM_DATA s16 gIntroCredits_MovingSceneryState = 0; -static void sub_817B76C(void); -static void sub_817B788(void); -static void sub_817B7A4(void); -static void sub_817B458(u8); +static void CreateCloudSprites(void); +static void CreateTreeSprites(void); +static void CreateHouseSprites(void); +static void Task_BicycleBgAnimation(u8); -void load_intro_part2_graphics(u8 a) +void LoadIntroPart2Graphics(u8 scene) { - LZ77UnCompVram(gUnknown_085F0740, (void *)(BG_CHAR_ADDR(1))); - LZ77UnCompVram(gUnknown_085F0BC0, (void *)(BG_SCREEN_ADDR(15))); - LoadPalette(&gUnknown_085F06E0, 240, 32); - switch (a) + LZ77UnCompVram(sGrass_Gfx, (void *)(BG_CHAR_ADDR(1))); + LZ77UnCompVram(sGrass_Tilemap, (void *)(BG_SCREEN_ADDR(15))); + LoadPalette(&sGrass_Pal, 240, sizeof(sGrass_Pal)); + switch (scene) { case 0: default: - LZ77UnCompVram(gUnknown_085F0DBC, (void *)(VRAM)); - LZ77UnCompVram(gUnknown_085F1398, (void *)(BG_SCREEN_ADDR(6))); - LoadPalette(&gUnknown_085F0CFC, 0, 96); - LoadCompressedSpriteSheet(gUnknown_085F5064); - LoadPalette(&gUnknown_085F1668, 256, 32); - sub_817B76C(); + // Never reached, only called with an argument of 1 + // Clouds are never used in this part of the intro + LZ77UnCompVram(sCloudsBg_Gfx, (void *)(VRAM)); + LZ77UnCompVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6))); + LoadPalette(&sCloudsBg_Pal, 0, sizeof(sCloudsBg_Pal)); + LoadCompressedSpriteSheet(sSpriteSheet_Clouds); + LoadPalette(&sClouds_Pal, 256, sizeof(sClouds_Pal)); + CreateCloudSprites(); break; case 1: - LZ77UnCompVram(gUnknown_085F1824, (void *)(VRAM)); - LZ77UnCompVram(gUnknown_085F1EAC, (void *)(BG_SCREEN_ADDR(6))); - LoadPalette(&gUnknown_085F17E4, 0, 32); - LoadCompressedSpriteSheet(gUnknown_085F50EC); - LoadPalette(&gUnknown_085F21B0, 256, 32); - sub_817B788(); + LZ77UnCompVram(sTrees_Gfx, (void *)(VRAM)); + LZ77UnCompVram(sTrees_Tilemap, (void *)(BG_SCREEN_ADDR(6))); + LoadPalette(&sTrees_Pal, 0, sizeof(sTrees_Pal)); + LoadCompressedSpriteSheet(sSpriteSheet_TreesSmall); + LoadPalette(&sTreesSmall_Pal, 256, sizeof(sTreesSmall_Pal)); + CreateTreeSprites(); break; } - gUnknown_0203BD28 = 0; + gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_MOVING; gReservedSpritePaletteCount = 8; } // Note: This is only called with a=1. -void sub_817B150(u8 a) +void SetIntroPart2BgCnt(u8 scene) { - switch (a) + // Only called with scene = 1 + switch (scene) { default: case 0: @@ -811,58 +836,58 @@ void sub_817B150(u8 a) } } -void sub_817B1C8(u8 a) +void LoadCreditsSceneGraphics(u8 scene) { - LZ77UnCompVram(gUnknown_085F0740, (void *)(BG_CHAR_ADDR(1))); - LZ77UnCompVram(gUnknown_085F0BC0, (void *)(BG_SCREEN_ADDR(15))); - switch (a) + LZ77UnCompVram(sGrass_Gfx, (void *)(BG_CHAR_ADDR(1))); + LZ77UnCompVram(sGrass_Tilemap, (void *)(BG_SCREEN_ADDR(15))); + switch (scene) { case 0: default: - LoadPalette(&gUnknown_085F06E0, 240, 32); - LZ77UnCompVram(gUnknown_085F0DBC, (void *)(VRAM)); - LZ77UnCompVram(gUnknown_085F1398, (void *)(BG_SCREEN_ADDR(6))); - LoadPalette(&gUnknown_085F0CFC, 0, 96); - LoadCompressedSpriteSheet(gUnknown_085F5064); - LZ77UnCompVram(gUnknown_085F16A8, (void *)(OBJ_VRAM0)); - LoadPalette(&gUnknown_085F1668, 256, 32); - sub_817B76C(); + LoadPalette(&sGrass_Pal, 240, sizeof(sGrass_Pal)); + LZ77UnCompVram(sCloudsBg_Gfx, (void *)(VRAM)); + LZ77UnCompVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6))); + LoadPalette(&sCloudsBg_Pal, 0, sizeof(sCloudsBg_Pal)); + LoadCompressedSpriteSheet(sSpriteSheet_Clouds); + LZ77UnCompVram(sClouds_Gfx, (void *)(OBJ_VRAM0)); + LoadPalette(&sClouds_Pal, 256, sizeof(sClouds_Pal)); + CreateCloudSprites(); break; case 1: - LoadPalette(&gUnknown_085F0700, 240, 32); - LZ77UnCompVram(gUnknown_085F0DBC, (void *)(VRAM)); - LZ77UnCompVram(gUnknown_085F1398, (void *)(BG_SCREEN_ADDR(6))); - LoadPalette(&gUnknown_085F0D5C, 0, 96); - LoadCompressedSpriteSheet(gUnknown_085F5064); - LZ77UnCompVram(gUnknown_085F16A8, (void *)(OBJ_VRAM0)); - LoadPalette(&gUnknown_085F1688, 256, 32); - sub_817B76C(); + LoadPalette(&sGrassAfternoon_Pal, 240, sizeof(sGrassAfternoon_Pal)); + LZ77UnCompVram(sCloudsBg_Gfx, (void *)(VRAM)); + LZ77UnCompVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6))); + LoadPalette(&sCloudsBgAfternoon_Pal, 0, sizeof(sCloudsBgAfternoon_Pal)); + LoadCompressedSpriteSheet(sSpriteSheet_Clouds); + LZ77UnCompVram(sClouds_Gfx, (void *)(OBJ_VRAM0)); + LoadPalette(&sCloudsAfternoon_Pal, 256, sizeof(sCloudsAfternoon_Pal)); + CreateCloudSprites(); break; case 2: case 3: - LoadPalette(&gUnknown_085F0700, 240, 32); - LZ77UnCompVram(gUnknown_085F1824, (void *)(VRAM)); - LZ77UnCompVram(gUnknown_085F1EAC, (void *)(BG_SCREEN_ADDR(6))); - LoadPalette(&gUnknown_085F1804, 0, 32); - LoadCompressedSpriteSheet(gUnknown_085F50EC); - LoadPalette(&gUnknown_085F1804, 256, 32); - sub_817B788(); + LoadPalette(&sGrassAfternoon_Pal, 240, sizeof(sGrassAfternoon_Pal)); + LZ77UnCompVram(sTrees_Gfx, (void *)(VRAM)); + LZ77UnCompVram(sTrees_Tilemap, (void *)(BG_SCREEN_ADDR(6))); + LoadPalette(&sTreesAfternoon_Pal, 0, sizeof(sTreesAfternoon_Pal)); + LoadCompressedSpriteSheet(sSpriteSheet_TreesSmall); + LoadPalette(&sTreesAfternoon_Pal, 256, sizeof(sTreesAfternoon_Pal)); + CreateTreeSprites(); break; case 4: - LoadPalette(&gUnknown_085F0720, 240, 32); - LZ77UnCompVram(gUnknown_085F235C, (void *)(VRAM)); - LZ77UnCompVram(gUnknown_085F2568, (void *)(BG_SCREEN_ADDR(6))); - LoadPalette(&gUnknown_085F231C, 0, 64); - LoadCompressedSpriteSheet(gUnknown_085F5180); - LoadPalette(&gUnknown_085F2548, 256, 32); - sub_817B7A4(); + LoadPalette(&sGrassNight_Pal, 240, sizeof(sGrassNight_Pal)); + LZ77UnCompVram(sHouses_Gfx, (void *)(VRAM)); + LZ77UnCompVram(sHouses_Tilemap, (void *)(BG_SCREEN_ADDR(6))); + LoadPalette(&sHouses_Pal, 0, sizeof(sHouses_Pal)); + LoadCompressedSpriteSheet(sSpriteSheet_HouseSilhouette); + LoadPalette(&sHouseSilhouette_Pal, 256, sizeof(sHouseSilhouette_Pal)); + CreateHouseSprites(); break; } gReservedSpritePaletteCount = 8; - gUnknown_0203BD28 = 0; + gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_MOVING; } -void sub_817B3A8(u8 a) +void SetCreditsSceneBgCnt(u8 scene) { SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) @@ -885,77 +910,91 @@ void sub_817B3A8(u8 a) | DISPCNT_OBJ_ON); } -u8 CreateBicycleAnimationTask(u8 a, u16 b, u16 c, u16 d) -{ - u8 taskId = CreateTask(&sub_817B458, 0); +#define tMode data[0] // Can be 0-2, but only != 0 matters. Determines vertical movement for bg2 +#define tBg1Speed data[1] +#define tBg1PosHi data[2] +#define tBg1PosLo data[3] +#define tBg2Speed data[4] +#define tBg2PosHi data[5] +#define tBg2PosLo data[6] +#define tBg3Speed data[7] +#define tBg3PosHi data[8] +#define tBg3PosLo data[9] - gTasks[taskId].data[0] = a; - gTasks[taskId].data[1] = b; - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[3] = 0; - gTasks[taskId].data[4] = c; - gTasks[taskId].data[5] = 0; - gTasks[taskId].data[6] = 0; - gTasks[taskId].data[7] = d; - gTasks[taskId].data[8] = 8; - gTasks[taskId].data[9] = 0; - sub_817B458(taskId); +// Create task that manages the moving backgrounds during the bicycle ride +u8 CreateBicycleBgAnimationTask(u8 mode, u16 bg1Speed, u16 bg2Speed, u16 bg3Speed) +{ + u8 taskId = CreateTask(Task_BicycleBgAnimation, 0); + + gTasks[taskId].tMode = mode; + gTasks[taskId].tBg1Speed = bg1Speed; + gTasks[taskId].tBg1PosHi = 0; + gTasks[taskId].tBg1PosLo = 0; + gTasks[taskId].tBg2Speed = bg2Speed; + gTasks[taskId].tBg2PosHi = 0; + gTasks[taskId].tBg2PosLo = 0; + gTasks[taskId].tBg3Speed = bg3Speed; + gTasks[taskId].tBg3PosHi = 8; + gTasks[taskId].tBg3PosLo = 0; + Task_BicycleBgAnimation(taskId); return taskId; } -static void sub_817B458(u8 taskId) +static void Task_BicycleBgAnimation(u8 taskId) { - s16 data1; - s16 data4; - s16 data7; - s32 r2; + s16 bg1Speed; + s16 bg2Speed; + s16 bg3Speed; + s32 offset; - data1 = gTasks[taskId].data[1]; - if (data1 != 0) + // Move BG1 + bg1Speed = gTasks[taskId].tBg1Speed; + if (bg1Speed != 0) { - r2 = (gTasks[taskId].data[2] << 16) + (u16)gTasks[taskId].data[3]; - r2 -= (u16)data1 << 4; - gTasks[taskId].data[2] = r2 >> 16; - gTasks[taskId].data[3] = r2; - SetGpuReg(REG_OFFSET_BG1HOFS, gTasks[taskId].data[2]); - SetGpuReg(REG_OFFSET_BG1VOFS, gUnknown_0203BD24 + gUnknown_0203BD26); + offset = (gTasks[taskId].tBg1PosHi << 16) + (u16)gTasks[taskId].tBg1PosLo; + offset -= (u16)bg1Speed << 4; + gTasks[taskId].tBg1PosHi = offset >> 16; + gTasks[taskId].tBg1PosLo = offset; + SetGpuReg(REG_OFFSET_BG1HOFS, gTasks[taskId].tBg1PosHi); + SetGpuReg(REG_OFFSET_BG1VOFS, gIntroCredits_MovingSceneryVBase + gIntroCredits_MovingSceneryVOffset); } - data4 = gTasks[taskId].data[4]; - if (data4 != 0) + // Move BG2 + bg2Speed = gTasks[taskId].tBg2Speed; + if (bg2Speed != 0) { - r2 = (gTasks[taskId].data[5] << 16) + (u16)gTasks[taskId].data[6]; - r2 -= (u16)data4 << 4; - gTasks[taskId].data[5] = r2 >> 16; - gTasks[taskId].data[6] = r2; - SetGpuReg(REG_OFFSET_BG2HOFS, gTasks[taskId].data[5]); - if (gTasks[taskId].data[0] != 0) - SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_0203BD24 + gUnknown_0203BD26); + offset = (gTasks[taskId].tBg2PosHi << 16) + (u16)gTasks[taskId].tBg2PosLo; + offset -= (u16)bg2Speed << 4; + gTasks[taskId].tBg2PosHi = offset >> 16; + gTasks[taskId].tBg2PosLo = offset; + SetGpuReg(REG_OFFSET_BG2HOFS, gTasks[taskId].tBg2PosHi); + if (gTasks[taskId].tMode != 0) + SetGpuReg(REG_OFFSET_BG2VOFS, gIntroCredits_MovingSceneryVBase + gIntroCredits_MovingSceneryVOffset); else - SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_0203BD24); + SetGpuReg(REG_OFFSET_BG2VOFS, gIntroCredits_MovingSceneryVBase); } - data7 = gTasks[taskId].data[7]; - if (data7 != 0) + // Move BG3 + bg3Speed = gTasks[taskId].tBg3Speed; + if (bg3Speed != 0) { - r2 = (gTasks[taskId].data[8] << 16) + (u16)gTasks[taskId].data[9]; - r2 -= (u16)data7 << 4; - gTasks[taskId].data[8] = r2 >> 16; - gTasks[taskId].data[9] = r2; - SetGpuReg(REG_OFFSET_BG3HOFS, gTasks[taskId].data[8]); - SetGpuReg(REG_OFFSET_BG3VOFS, gUnknown_0203BD24); + offset = (gTasks[taskId].tBg3PosHi << 16) + (u16)gTasks[taskId].tBg3PosLo; + offset -= (u16)bg3Speed << 4; + gTasks[taskId].tBg3PosHi = offset >> 16; + gTasks[taskId].tBg3PosLo = offset; + SetGpuReg(REG_OFFSET_BG3HOFS, gTasks[taskId].tBg3PosHi); + SetGpuReg(REG_OFFSET_BG3VOFS, gIntroCredits_MovingSceneryVBase); } } -void sub_817B540(u8 mode) +void CycleSceneryPalette(u8 scene) { u16 x; u16 y; - switch (mode) + switch (scene) { case 0: default: - /* stuff */ if (gMain.vblankCounter1 & 3 || gPaletteFade.active) break; if (gMain.vblankCounter1 & 4) @@ -968,149 +1007,159 @@ void sub_817B540(u8 mode) x = gPlttBufferUnfaded[10]; y = gPlttBufferUnfaded[9]; } - LoadPalette(&x, 9, 2); - LoadPalette(&y, 10, 2); + LoadPalette(&x, 9, sizeof(x)); + LoadPalette(&y, 10, sizeof(y)); break; case 2: if (gMain.vblankCounter1 & 3 || gPaletteFade.active) break; if (gMain.vblankCounter1 & 4) { - x = 0x3D27; - y = 0x295; + x = RGB(7, 9, 15); + y = RGB(21, 20, 0); } else { - x = 0x31C; - y = 0x3D27; + x = RGB(28, 24, 0); + y = RGB(7, 9, 15); } - LoadPalette(&x, 12, 2); - LoadPalette(&y, 13, 2); + LoadPalette(&x, 12, sizeof(x)); + LoadPalette(&y, 13, sizeof(y)); break; case 1: break; } } -static void sub_817B62C(struct Sprite *sprite) +static void SpriteCB_MovingScenery(struct Sprite *sprite) { - s32 var; - s16 var2 = gUnknown_0203BD28; + s32 x; + s16 state = gIntroCredits_MovingSceneryState; - if (var2 != 2) + if (state != INTROCRED_SCENERY_FROZEN) { - switch (var2) + switch (state) { - default: + default: // INTROCRED_SCENERY_DESTROY DestroySprite(sprite); break; - case 0: - var = ((sprite->pos1.x << 16) | (u16)sprite->data[2]) + (u16)sprite->data[1]; - sprite->pos1.x = var >> 16; - sprite->data[2] = var; + case INTROCRED_SCENERY_MOVING: + x = ((sprite->pos1.x << 16) | (u16)sprite->data[2]) + (u16)sprite->data[1]; + sprite->pos1.x = x >> 16; + sprite->data[2] = x; if (sprite->pos1.x > 0xFF) sprite->pos1.x = -0x20; if (sprite->data[0]) - sprite->pos2.y = -(gUnknown_0203BD24 + gUnknown_0203BD26); + sprite->pos2.y = -(gIntroCredits_MovingSceneryVBase + gIntroCredits_MovingSceneryVOffset); else - sprite->pos2.y = -gUnknown_0203BD24; + sprite->pos2.y = -gIntroCredits_MovingSceneryVBase; break; } } } -static void sub_817B698(u8 a, const struct IntroCreditsSpriteMetadata *b, const union AnimCmd *const *c, u8 d) +static void CreateMovingScenerySprites(bool8 a, const struct IntroCreditsSpriteMetadata *metadata, const union AnimCmd *const *anims, u8 numSprites) { u8 i; - for(i = 0; i < d; i++) + for(i = 0; i < numSprites; i++) { - u8 sprite = CreateSprite(&gUnknown_085F504C, b[i].x, b[i].y, b[i].subpriority); - CalcCenterToCornerVec(&gSprites[sprite], b[i].shape, b[i].size, ST_OAM_AFFINE_OFF); + u8 sprite = CreateSprite(&sSpriteTemplate_MovingScenery, metadata[i].x, metadata[i].y, metadata[i].subpriority); + CalcCenterToCornerVec(&gSprites[sprite], metadata[i].shape, metadata[i].size, ST_OAM_AFFINE_OFF); gSprites[sprite].oam.priority = 3; - gSprites[sprite].oam.shape = b[i].shape; - gSprites[sprite].oam.size = b[i].size; + gSprites[sprite].oam.shape = metadata[i].shape; + gSprites[sprite].oam.size = metadata[i].size; gSprites[sprite].oam.paletteNum = 0; - gSprites[sprite].anims = c; - StartSpriteAnim(&gSprites[sprite], b[i].animNum); + gSprites[sprite].anims = anims; + StartSpriteAnim(&gSprites[sprite], metadata[i].animNum); gSprites[sprite].data[0] = a; - gSprites[sprite].data[1] = b[i].xOff; + gSprites[sprite].data[1] = metadata[i].xOff; gSprites[sprite].data[2] = 0; } } -static void sub_817B76C(void) +static void CreateCloudSprites(void) { - sub_817B698(0, gUnknown_085F50A4, gUnknown_085F5094, 9); + CreateMovingScenerySprites(FALSE, sSpriteMetadata_Clouds, sAnims_Clouds, 9); } -static void sub_817B788(void) +static void CreateTreeSprites(void) { - sub_817B698(1, gUnknown_085F5120, gUnknown_085F5114, 12); + CreateMovingScenerySprites(TRUE, sSpriteMetadata_Trees, sAnims_TreesSmall, 12); } -static void sub_817B7A4(void) +static void CreateHouseSprites(void) { - sub_817B698(1, gUnknown_085F519C, gUnknown_085F5198, 6); + CreateMovingScenerySprites(TRUE, sSpriteMetadata_HouseSilhouette, sAnims_HouseSilhouette, 6); } -static void nullsub_65(struct Sprite *sprite) +static void SpriteCB_Player(struct Sprite *sprite) { } -static void sub_817B7C4(struct Sprite* sprite) +#define sPlayerSpriteId data[0] + +static void SpriteCB_Bicycle(struct Sprite* sprite) { - sprite->invisible = gSprites[sprite->data[0]].invisible; - sprite->pos1.x = gSprites[sprite->data[0]].pos1.x; - sprite->pos1.y = gSprites[sprite->data[0]].pos1.y + 8; - sprite->pos2.x = gSprites[sprite->data[0]].pos2.x; - sprite->pos2.y = gSprites[sprite->data[0]].pos2.y; + sprite->invisible = gSprites[sprite->sPlayerSpriteId].invisible; + sprite->pos1.x = gSprites[sprite->sPlayerSpriteId].pos1.x; + sprite->pos1.y = gSprites[sprite->sPlayerSpriteId].pos1.y + 8; + sprite->pos2.x = gSprites[sprite->sPlayerSpriteId].pos2.x; + sprite->pos2.y = gSprites[sprite->sPlayerSpriteId].pos2.y; } -u8 intro_create_brendan_sprite(s16 a, s16 b) +u8 CreateIntroBrendanSprite(s16 x, s16 y) { - u8 sprite = CreateSprite(&gUnknown_085F51EC, a, b, 2); - u8 brendan = CreateSprite(&gUnknown_085F523C, a, b + 8, 3); - gSprites[brendan].data[0] = sprite; - return sprite; + u8 playerSpriteId = CreateSprite(&sSpriteTemplate_Brendan, x, y, 2); + u8 bicycleSpriteId = CreateSprite(&sSpriteTemplate_BrendanBicycle, x, y + 8, 3); + gSprites[bicycleSpriteId].sPlayerSpriteId = playerSpriteId; + return playerSpriteId; } -u8 intro_create_may_sprite(s16 a, s16 b) +u8 CreateIntroMaySprite(s16 x, s16 y) { - u8 sprite = CreateSprite(&gUnknown_085F5204, a, b, 2); - u8 may = CreateSprite(&gUnknown_085F5254, a, b + 8, 3); - gSprites[may].data[0] = sprite; - return sprite; + u8 playerSpriteId = CreateSprite(&sSpriteTemplate_May, x, y, 2); + u8 bicycleSpriteId = CreateSprite(&sSpriteTemplate_MayBicycle, x, y + 8, 3); + gSprites[bicycleSpriteId].sPlayerSpriteId = playerSpriteId; + return playerSpriteId; } -static void nullsub_66(struct Sprite *sprite) +#undef sPlayerSpriteId + +static void SpriteCB_FlygonLeftHalf(struct Sprite *sprite) { } -static void sub_817B8E8(struct Sprite* sprite) +#define sLeftSpriteId data[0] + +static void SpriteCB_FlygonRightHalf(struct Sprite* sprite) { - sprite->invisible = gSprites[sprite->data[0]].invisible; - sprite->pos1.y = gSprites[sprite->data[0]].pos1.y; - sprite->pos2.x = gSprites[sprite->data[0]].pos2.x; - sprite->pos2.y = gSprites[sprite->data[0]].pos2.y; + sprite->invisible = gSprites[sprite->sLeftSpriteId].invisible; + sprite->pos1.y = gSprites[sprite->sLeftSpriteId].pos1.y; + sprite->pos2.x = gSprites[sprite->sLeftSpriteId].pos2.x; + sprite->pos2.y = gSprites[sprite->sLeftSpriteId].pos2.y; } -static u8 sub_817B948(s16 a, s16 b) +// In RS these were for Latios/Latias. In Emerald both are replaced with Flygon and now only 1 is used +static u8 CreateIntroFlygonSprite_Unused(s16 x, s16 y) { - u8 sprite = CreateSprite(&gUnknown_085F528C, a - 32, b, 5); - u8 latios = CreateSprite(&gUnknown_085F528C, a + 32, b, 6); - gSprites[latios].data[0] = sprite; - StartSpriteAnim(&gSprites[latios], 1); - gSprites[latios].callback = &sub_817B8E8; - return sprite; + u8 leftSpriteId = CreateSprite(&sSpriteTemplate_FlygonLatios, x - 32, y, 5); + u8 rightSpriteId = CreateSprite(&sSpriteTemplate_FlygonLatios, x + 32, y, 6); + gSprites[rightSpriteId].sLeftSpriteId = leftSpriteId; + StartSpriteAnim(&gSprites[rightSpriteId], 1); + gSprites[rightSpriteId].callback = &SpriteCB_FlygonRightHalf; + return leftSpriteId; } -u8 intro_create_flygon_sprite(s16 a, s16 b) + +u8 CreateIntroFlygonSprite(s16 x, s16 y) { - u8 sprite = CreateSprite(&gUnknown_085F52A4, a - 32, b, 5); - u8 flygon = CreateSprite(&gUnknown_085F52A4, a + 32, b, 6); - gSprites[flygon].data[0] = sprite; - StartSpriteAnim(&gSprites[flygon], 1); - gSprites[flygon].callback = &sub_817B8E8; - return sprite; + u8 leftSpriteId = CreateSprite(&sSpriteTemplate_FlygonLatias, x - 32, y, 5); + u8 rightSpriteId = CreateSprite(&sSpriteTemplate_FlygonLatias, x + 32, y, 6); + gSprites[rightSpriteId].sLeftSpriteId = leftSpriteId; + StartSpriteAnim(&gSprites[rightSpriteId], 1); + gSprites[rightSpriteId].callback = &SpriteCB_FlygonRightHalf; + return leftSpriteId; } + +#undef sLeftSpriteId diff --git a/src/title_screen.c b/src/title_screen.c index f86a0b0b3a..f2c609fecc 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -64,7 +64,9 @@ static const u32 sTitleScreenCloudsGfx[] = INCBIN_U32("graphics/title_screen/clo -const u16 gIntroWaterDropAlphaBlend[] = +// Used to blend "Emerald Version" as it passes over over the Pokémon banner. +// Also used by the intro to blend the Game Freak name/logo in and out as they appear and disappear +const u16 gTitleScreenAlphaBlend[64] = { BLDALPHA_BLEND(16, 0), BLDALPHA_BLEND(16, 1), @@ -364,7 +366,7 @@ static void SpriteCB_VersionBannerLeft(struct Sprite *sprite) sprite->pos1.y++; if (sprite->data[0] != 0) sprite->data[0]--; - SetGpuReg(REG_OFFSET_BLDALPHA, gIntroWaterDropAlphaBlend[sprite->data[0]]); + SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[sprite->data[0]]); } } @@ -388,7 +390,7 @@ static void SpriteCB_PressStartCopyrightBanner(struct Sprite *sprite) { sprite->data[1]++; // Alternate between hidden and shown every 16th frame - if (sprite->data[1] & 0x10) + if (sprite->data[1] & 16) sprite->invisible = FALSE; else sprite->invisible = TRUE; From 357c5439f5170ec1ebb1fe52c00d8d934b65c6bc Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 28 Mar 2021 23:56:42 -0400 Subject: [PATCH 14/31] Document some credits --- graphics/credits/credits.pal | 67 ++ graphics/credits/credits_1.pal | 19 - graphics/credits/credits_2.pal | 19 - graphics/credits/credits_3.pal | 19 - graphics/credits/credits_4.pal | 19 - include/credits.h | 4 - include/intro_credits_graphics.h | 2 +- src/credits.c | 1338 +++++++----------------------- src/data/credits.h | 787 ++++++++++++++++++ src/intro_credits_graphics.c | 16 +- 10 files changed, 1152 insertions(+), 1138 deletions(-) create mode 100644 graphics/credits/credits.pal delete mode 100644 graphics/credits/credits_1.pal delete mode 100644 graphics/credits/credits_2.pal delete mode 100644 graphics/credits/credits_3.pal delete mode 100644 graphics/credits/credits_4.pal create mode 100644 src/data/credits.h diff --git a/graphics/credits/credits.pal b/graphics/credits/credits.pal new file mode 100644 index 0000000000..d086095d8b --- /dev/null +++ b/graphics/credits/credits.pal @@ -0,0 +1,67 @@ +JASC-PAL +0100 +64 +0 0 0 +255 255 255 +164 164 164 +255 230 123 +255 82 41 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +255 230 123 +255 82 41 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +131 65 32 +16 0 0 +8 139 65 +8 8 0 +8 8 0 +8 8 0 +148 131 32 +16 8 0 +0 74 65 +16 65 65 +131 131 32 +148 131 65 +8 139 65 +8 139 0 +8 8 32 +148 131 0 +148 65 65 +16 74 65 +0 139 65 +0 131 65 +0 0 0 +0 0 0 +0 0 0 +0 0 0 diff --git a/graphics/credits/credits_1.pal b/graphics/credits/credits_1.pal deleted file mode 100644 index 222be71012..0000000000 --- a/graphics/credits/credits_1.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -0 0 0 -255 255 255 -164 164 164 -255 230 123 -255 82 41 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 diff --git a/graphics/credits/credits_2.pal b/graphics/credits/credits_2.pal deleted file mode 100644 index 7dac48572e..0000000000 --- a/graphics/credits/credits_2.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -0 0 0 -255 230 123 -255 82 41 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 diff --git a/graphics/credits/credits_3.pal b/graphics/credits/credits_3.pal deleted file mode 100644 index cbd66ec0cc..0000000000 --- a/graphics/credits/credits_3.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -131 65 32 -16 0 0 -8 139 65 -8 8 0 -8 8 0 -8 8 0 -148 131 32 -16 8 0 diff --git a/graphics/credits/credits_4.pal b/graphics/credits/credits_4.pal deleted file mode 100644 index 2df49dc85b..0000000000 --- a/graphics/credits/credits_4.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -0 74 65 -16 65 65 -131 131 32 -148 131 65 -8 139 65 -8 139 0 -8 8 32 -148 131 0 -148 65 65 -16 74 65 -0 139 65 -0 131 65 -0 0 0 -0 0 0 -0 0 0 -0 0 0 diff --git a/include/credits.h b/include/credits.h index f7dfa99970..2e8c7e0c3c 100644 --- a/include/credits.h +++ b/include/credits.h @@ -1,12 +1,8 @@ #ifndef GUARD_CREDITS_H #define GUARD_CREDITS_H -// Exported type declarations - -// Exported RAM declarations extern EWRAM_DATA bool8 gHasHallOfFameRecords; -// Exported ROM declarations void CB2_StartCreditsSequence(void); #endif // GUARD_CREDITS_H diff --git a/include/intro_credits_graphics.h b/include/intro_credits_graphics.h index 431446ed24..df3854aef0 100644 --- a/include/intro_credits_graphics.h +++ b/include/intro_credits_graphics.h @@ -3,7 +3,7 @@ // States for gIntroCredits_MovingSceneryState enum { - INTROCRED_SCENERY_MOVING, + INTROCRED_SCENERY_NORMAL, INTROCRED_SCENERY_DESTROY, INTROCRED_SCENERY_FROZEN, }; diff --git a/src/credits.c b/src/credits.c index f39c0ff857..16d71f3e94 100644 --- a/src/credits.c +++ b/src/credits.c @@ -23,71 +23,21 @@ #include "event_data.h" #include "random.h" -enum -{ - PAGE_TITLE, - PAGE_DIRECTOR, - PAGE_ART_DIRECTOR, - PAGE_WORLD_DIRECTOR, - PAGE_LEAD_PROGRAMMER, - PAGE_PROGRAMMERS_1, - PAGE_PROGRAMMERS_2, - PAGE_PROGRAMMERS_3, - PAGE_PROGRAMMERS_4, - PAGE_GRAPHIC_DESIGNERS_1, - PAGE_GRAPHIC_DESIGNERS_2, - PAGE_GRAPHIC_DESIGNERS_3, - PAGE_MUSIC_COMPOSITION, - PAGE_SOUND_EFFECTS, - PAGE_GAME_DESIGNERS_1, - PAGE_GAME_DESIGNERS_2, - PAGE_GAME_DESIGNERS_3, - PAGE_SCENARIO_PLOT, - PAGE_SCENARIO, - PAGE_SCRIPT_DESIGNERS, - PAGE_MAP_DESIGNERS, - PAGE_BATTLE_FRONTIER_DATA, - PAGE_PARAMETRIC_DESIGNERS, - PAGE_POKEDEX_TEXT, - PAGE_ENVIRONMENT_AND_TOOL_PROGRAMS_1, - PAGE_PKMN_DESIGNERS_1, - PAGE_PKMN_DESIGNERS_2, - PAGE_PKMN_DESIGNERS_3, - PAGE_PKMN_DESIGNERS_4, - PAGE_SUPPORT_PROGRAMMERS, - PAGE_NCL_PRODUCT_TESTING, - PAGE_PACKAGE_AND_MANUAL, - PAGE_SPECIAL_THANKS_1, - PAGE_SPECIAL_THANKS_2, - PAGE_SPECIAL_THANKS_3, - PAGE_SPECIAL_THANKS_4, - PAGE_INFORMATION_SUPERVISORS, - PAGE_ARTWORK_1, - PAGE_ARTWORK_2, - PAGE_ARTWORK_3, - PAGE_COORDINATORS, - PAGE_ENGLISH_VERSION, - PAGE_TRANSLATOR, - PAGE_TEXT_EDITOR, - PAGE_NCL_COORDINATOR, - PAGE_PROGRAMMERS_5, - PAGE_GRAPHIC_DESIGNER, - PAGE_ENVIRONMENT_AND_TOOL_PROGRAMS_2, - PAGE_NOA_TESTING, - PAGE_BRAILLE_CODE_CHECK_1, - PAGE_BRAILLE_CODE_CHECK_2, - PAGE_SPECIAL_THANKS_5, - PAGE_TASK_MANAGERS, - PAGE_PRODUCERS, - PAGE_EXECUTIVE_DIRECTOR, - PAGE_EXECUTIVE_PRODUCERS_1, - PAGE_EXECUTIVE_PRODUCERS_2, - PAGE_COUNT -}; - #define COLOR_DARK_GREEN RGB(7, 11, 6) #define COLOR_LIGHT_GREEN RGB(13, 20, 12) +#define TAG_MON_BG 1001 + +// Positions for the Pokémon images +enum { + POS_LEFT, + POS_CENTER, + POS_RIGHT, +}; + +#define tPlayerSpriteId data[5] +#define tRivalSpriteId data[6] + enum { TDA_0 = 0, @@ -142,30 +92,50 @@ struct CreditsData struct CreditsEntry { - u8 var_0; + u8 unk; // Never read bool8 isTitle; const u8 *text; }; -static EWRAM_DATA s16 gUnknown_0203BCE0 = 0; -static EWRAM_DATA u16 gUnknown_0203BCE2 = 0; // TASK A +static EWRAM_DATA s16 sUnkVar = 0; // Never read, only set to 0 +static EWRAM_DATA u16 sSavedTaskId = 0; EWRAM_DATA bool8 gHasHallOfFameRecords = 0; -static EWRAM_DATA u8 gUnknown_0203BCE5 = 0; +static EWRAM_DATA bool8 sUsedSpeedUp = 0; // Never read static EWRAM_DATA struct CreditsData *sCreditsData = {0}; -static const u16 gUnknown_085E56F0[][16] = -{ - INCBIN_U16("graphics/credits/credits_1.gbapal"), - INCBIN_U16("graphics/credits/credits_2.gbapal"), - INCBIN_U16("graphics/credits/credits_3.gbapal"), - INCBIN_U16("graphics/credits/credits_4.gbapal"), -}; - +static const u16 sCredits_Pal[] = INCBIN_U16("graphics/credits/credits.gbapal"); static const u32 sCreditsCopyrightEnd_Gfx[] = INCBIN_U32("graphics/credits/the_end_copyright.4bpp.lz"); -static void sub_81772B8(struct Sprite *sprite); +static void SpriteCB_CreditsMonBg(struct Sprite *); +static void Task_WaitPaletteFade(u8); +static void Task_ProgressCreditTasks(u8); +static void sub_8175808(u8); +static void c2_080C9BFC(u8); +static void Task_CreditsLoadGrassScene(u8); +static void sub_81758A4(u8); +static void Task_CreditsTheEnd1(u8); +static void Task_CreditsTheEnd2(u8); +static void Task_CreditsTheEnd3(u8); +static void Task_CreditsTheEnd4(u8); +static void Task_CreditsTheEnd5(u8); +static void Task_CreditsTheEnd6(u8); +static void Task_CreditsSoftReset(u8); +static void ResetGpuAndVram(void); +static void sub_8175DA0(u8); +static u8 CheckChangeScene(u8, u8); +static void sub_81760FC(u8); +static void sub_817651C(u8); +static void sub_817624C(u8); +static bool8 sub_8176AB0(u8 data, u8); +static void ResetCreditsTasks(u8); +static void LoadTheEndScreen(u16, u16, u16); +static void DrawTheEnd(u16, u16); +static void SpriteCB_PlayerCyclist(struct Sprite *); +static void SpriteCB_RivalCyclist(struct Sprite *); +static u8 CreateCreditsMonSprite(u16, s16, s16, u16); +static void DeterminePokemonToShow(void); -static const u8 sTheEnd_LetterTMap[] = +static const u8 sTheEnd_LetterMap_T[] = { 0, 1, 0, 0xFF, 1, 0xFF, @@ -174,7 +144,7 @@ static const u8 sTheEnd_LetterTMap[] = 0xFF, 1, 0xFF, }; -static const u8 sTheEnd_LetterHMap[] = +static const u8 sTheEnd_LetterMap_H[] = { 1, 0xFF, 1, 1, 0xFF, 1, @@ -183,7 +153,7 @@ static const u8 sTheEnd_LetterHMap[] = 1, 0xFF, 1, }; -static const u8 sTheEnd_LetterEMap[] = +static const u8 sTheEnd_LetterMap_E[] = { 1, 0, 0, 1, 0xFF, 0xFF, @@ -192,7 +162,7 @@ static const u8 sTheEnd_LetterEMap[] = 1, 0x80, 0x80, }; -static const u8 sTheEnd_LetterNMap[] = +static const u8 sTheEnd_LetterMap_N[] = { 1, 3, 1, 1, 4, 1, @@ -201,7 +171,7 @@ static const u8 sTheEnd_LetterNMap[] = 1, 0xC3, 1, }; -static const u8 sTheEnd_LetterDMap[] = +static const u8 sTheEnd_LetterMap_D[] = { 1, 6, 7, 1, 8, 9, @@ -210,729 +180,7 @@ static const u8 sTheEnd_LetterDMap[] = 1, 0x86, 0x87, }; -static const u8 sCreditsText_EmptyString[] = _(""); -static const u8 sCreditsText_PkmnEmeraldVersion[] = _("POKéMON EMERALD VERSION"); -static const u8 sCreditsText_Credits[] = _("Credits"); -static const u8 sCreditsText_ExecutiveDirector[] = _("Executive Director"); -static const u8 sCreditsText_Director[] = _("Director"); -static const u8 sCreditsText_ArtDirector[] = _("Art Director"); -static const u8 sCreditsText_BattleDirector[] = _("Battle Director"); -static const u8 sCreditsText_MainProgrammer[] = _("Main Programmer"); -static const u8 sCreditsText_BattleSystemPgrms[] = _("Battle System Programmers"); -static const u8 sCreditsText_FieldSystemPgrms[] = _("Field System Programmer"); -static const u8 sCreditsText_Programmers[] = _("Programmers"); -static const u8 sCreditsText_MainGraphicDesigner[] = _("Main Graphic Designer"); -static const u8 sCreditsText_GraphicDesigners[] = _("Graphic Designers"); -static const u8 sCreditsText_PkmnDesigners[] = _("POKéMON Designers"); -static const u8 sCreditsText_MusicComposition[] = _("Music Composition"); -static const u8 sCreditsText_SoundEffectsAndPkmnVoices[] = _("Sound Effects & POKéMON Voices"); -static const u8 sCreditsText_GameDesigners[] = _("Game Designers"); -static const u8 sCreditsText_ScenarioPlot[] = _("Scenario Plot"); -static const u8 sCreditsText_Scenario[] = _("Scenario"); -static const u8 sCreditsText_ScriptDesigners[] = _("Script Designers"); -static const u8 sCreditsText_MapDesigners[] = _("Map Designers"); -static const u8 sCreditsText_MapDataDesigners[] = _("Map Data Designers"); -static const u8 sCreditsText_ParametricDesigners[] = _("Parametric Designers"); -static const u8 sCreditsText_PokedexText[] = _("POKéDEX Text"); -static const u8 sCreditsText_EnvAndToolPgrms[] = _("Environment & Tool Programmers"); -static const u8 sCreditsText_NCLProductTesting[] = _("NCL Product Testing"); -static const u8 sCreditsText_SpecialThanks[] = _("Special Thanks"); -static const u8 sCreditsText_Coordinators[] = _("Coordinators"); -static const u8 sCreditsText_Producers[] = _("Producers"); -static const u8 sCreditsText_ExecProducers[] = _("Executive Producers"); -static const u8 sCreditsText_InfoSupervisors[] = _("Information Supervisors"); -static const u8 sCreditsText_TaskManagers[] = _("Task Managers"); -static const u8 sCreditsText_BrailleCodeCheck[] = _("Braille Code Check"); -static const u8 sCreditsText_WorldDirector[] = _("World Director"); -static const u8 sCreditsText_BattleFrontierData[] = _("Battle Frontier Data"); -static const u8 sCreditsText_SupportProgrammers[] = _("Support Programmers"); -static const u8 sCreditsText_Artwork[] = _("Artwork"); -static const u8 sCreditsText_LeadProgrammer[] = _("Lead Programmer"); -static const u8 sCreditsText_LeadGraphicArtist[] = _("Lead Graphic Artist"); -static const u8 sCreditsText_SatoshiTajiri[] = _("Satoshi Tajiri"); -static const u8 sCreditsText_JunichiMasuda[] = _("Junichi Masuda"); -static const u8 sCreditsText_KenSugimori[] = _("Ken Sugimori"); -static const u8 sCreditsText_ShigekiMorimoto[] = _("Shigeki Morimoto"); -static const u8 sCreditsText_TetsuyaWatanabe[] = _("Tetsuya Watanabe"); -static const u8 sCreditsText_HisashiSogabe[] = _("Hisashi Sogabe"); -static const u8 sCreditsText_SosukeTamada[] = _("Sosuke Tamada"); -static const u8 sCreditsText_AkitoMori[] = _("Akito Mori"); -static const u8 sCreditsText_KeitaKagaya[] = _("Keita Kagaya"); -static const u8 sCreditsText_YoshinoriMatsuda[] = _("Yoshinori Matsuda"); -static const u8 sCreditsText_HiroyukiNakamura[] = _("Hiroyuki Nakamura"); -static const u8 sCreditsText_MasaoTaya[] = _("Masao Taya"); -static const u8 sCreditsText_SatoshiNohara[] = _("Satoshi Nohara"); -static const u8 sCreditsText_TomomichiOhta[] = _("Tomomichi Ohta"); -static const u8 sCreditsText_MiyukiIwasawa[] = _("Miyuki Iwasawa"); -static const u8 sCreditsText_TakenoriOhta[] = _("Takenori Ohta"); -static const u8 sCreditsText_HironobuYoshida[] = _("Hironobu Yoshida"); -static const u8 sCreditsText_MotofumiFujiwara[] = _("Motofumi Fujiwara"); -static const u8 sCreditsText_SatoshiOhta[] = _("Satoshi Ohta"); -static const u8 sCreditsText_AsukaIwashita[] = _("Asuka Iwashita"); -static const u8 sCreditsText_AimiTomita[] = _("Aimi Tomita"); -static const u8 sCreditsText_TakaoUnno[] = _("Takao Unno"); -static const u8 sCreditsText_KanakoEo[] = _("Kanako Eo"); -static const u8 sCreditsText_JunOkutani[] = _("Jun Okutani"); -static const u8 sCreditsText_AtsukoNishida[] = _("Atsuko Nishida"); -static const u8 sCreditsText_MuneoSaito[] = _("Muneo Saito"); -static const u8 sCreditsText_RenaYoshikawa[] = _("Rena Yoshikawa"); -static const u8 sCreditsText_GoIchinose[] = _("Go Ichinose"); -static const u8 sCreditsText_MorikazuAoki[] = _("Morikazu Aoki"); -static const u8 sCreditsText_KojiNishino[] = _("Koji Nishino"); -static const u8 sCreditsText_KenjiMatsushima[] = _("Kenji Matsushima"); -static const u8 sCreditsText_TetsujiOhta[] = _("Tetsuji Ohta"); -static const u8 sCreditsText_HitomiSato[] = _("Hitomi Sato"); -static const u8 sCreditsText_TakeshiKawachimaru[] = _("Takeshi Kawachimaru"); -static const u8 sCreditsText_TeruyukiShimoyamada[] = _("Teruyuki Shimoyamada"); -static const u8 sCreditsText_ShigeruOhmori[] = _("Shigeru Ohmori"); -static const u8 sCreditsText_TadashiTakahashi[] = _("Tadashi Takahashi"); -static const u8 sCreditsText_ToshinobuMatsumiya[] = _("Toshinobu Matsumiya"); -static const u8 sCreditsText_AkihitoTomisawa[] = _("Akihito Tomisawa"); -static const u8 sCreditsText_HirokiEnomoto[] = _("Hiroki Enomoto"); -static const u8 sCreditsText_KazuyukiTerada[] = _("Kazuyuki Terada"); -static const u8 sCreditsText_YuriSakurai[] = _("Yuri Sakurai"); -static const u8 sCreditsText_HiromiSagawa[] = _("Hiromi Sagawa"); -static const u8 sCreditsText_KenjiTominaga[] = _("Kenji Tominaga"); -static const u8 sCreditsText_YoshioTajiri[] = _("Yoshio Tajiri"); -static const u8 sCreditsText_TeikoSasaki[] = _("Teiko Sasaki"); -static const u8 sCreditsText_SachikoHamano[] = _("Sachiko Hamano"); -static const u8 sCreditsText_ChieMatsumiya[] = _("Chie Matsumiya"); -static const u8 sCreditsText_AkikoShinozaki[] = _("Akiko Shinozaki"); -static const u8 sCreditsText_AstukoFujii[] = _("Astuko Fujii"); -static const u8 sCreditsText_NozomuSaito[] = _("Nozomu Saito"); -static const u8 sCreditsText_KenkichiToyama[] = _("Kenkichi Toyama"); -static const u8 sCreditsText_SuguruNakatsui[] = _("Suguru Nakatsui"); -static const u8 sCreditsText_YumiFunasaka[] = _("Yumi Funasaka"); -static const u8 sCreditsText_NaokoYanase[] = _("Naoko Yanase"); -static const u8 sCreditsText_NCLSuperMarioClub[] = _("NCL Super Mario Club"); -static const u8 sCreditsText_AtsushiTada[] = _("Atsushi Tada"); -static const u8 sCreditsText_TakahiroOhnishi[] = _("Takahiro Ohnishi"); -static const u8 sCreditsText_NorihideOkamura[] = _("Norihide Okamura"); -static const u8 sCreditsText_HiroNakamura[] = _("Hiro Nakamura"); -static const u8 sCreditsText_HiroyukiUesugi[] = _("Hiroyuki Uesugi"); -static const u8 sCreditsText_TerukiMurakawa[] = _("Teruki Murakawa"); -static const u8 sCreditsText_AkiraKinashi[] = _("Akira Kinashi"); -static const u8 sCreditsText_MichikoTakizawa[] = _("Michiko Takizawa"); -static const u8 sCreditsText_MakikoTakada[] = _("Makiko Takada"); -static const u8 sCreditsText_TakanaoKondo[] = _("Takanao Kondo"); -static const u8 sCreditsText_AiMashima[] = _("Ai Mashima"); -static const u8 sCreditsText_GakujiNomoto[] = _("Gakuji Nomoto"); -static const u8 sCreditsText_TakehiroIzushi[] = _("Takehiro Izushi"); -static const u8 sCreditsText_HitoshiYamagami[] = _("Hitoshi Yamagami"); -static const u8 sCreditsText_KyokoWatanabe[] = _("Kyoko Watanabe"); -static const u8 sCreditsText_TakaoNakano[] = _("Takao Nakano"); -static const u8 sCreditsText_HiroyukiJinnai[] = _("Hiroyuki Jinnai"); -static const u8 sCreditsText_HiroakiTsuru[] = _("Hiroaki Tsuru"); -static const u8 sCreditsText_TsunekazIshihara[] = _("Tsunekaz Ishihara"); -static const u8 sCreditsText_SatoruIwata[] = _("Satoru Iwata"); -static const u8 sCreditsText_KazuyaSuyama[] = _("Kazuya Suyama"); -static const u8 sCreditsText_SatoshiMitsuhara[] = _("Satoshi Mitsuhara"); -static const u8 sCreditsText_JapanBrailleLibrary[] = _("Japan Braille Library"); -static const u8 sCreditsText_TomotakaKomura[] = _("Tomotaka Komura"); -static const u8 sCreditsText_MikikoOhhashi[] = _("Mikiko Ohhashi"); -static const u8 sCreditsText_DaisukeHoshino[] = _("Daisuke Hoshino"); -static const u8 sCreditsText_KenjiroIto[] = _("Kenjiro Ito"); -static const u8 sCreditsText_RuiKawaguchi[] = _("Rui Kawaguchi"); -static const u8 sCreditsText_ShunsukeKohori[] = _("Shunsuke Kohori"); -static const u8 sCreditsText_SachikoNakamichi[] = _("Sachiko Nakamichi"); -static const u8 sCreditsText_FujikoNomura[] = _("Fujiko Nomura"); -static const u8 sCreditsText_KazukiYoshihara[] = _("Kazuki Yoshihara"); -static const u8 sCreditsText_RetsujiNomoto[] = _("Retsuji Nomoto"); -static const u8 sCreditsText_AzusaTajima[] = _("Azusa Tajima"); -static const u8 sCreditsText_ShusakuEgami[] = _("Shusaku Egami"); -static const u8 sCreditsText_PackageAndManual[] = _("Package & Manual Illustration"); -static const u8 sCreditsText_EnglishVersion[] = _("English Version Coordinators"); -static const u8 sCreditsText_Translator[] = _("Translator"); -static const u8 sCreditsText_TextEditor[] = _("Text Editor"); -static const u8 sCreditsText_NCLCoordinator[] = _("NCL Coordinator"); -static const u8 sCreditsText_GraphicDesigner[] = _("Graphic Designer"); -static const u8 sCreditsText_NOAProductTesting[] = _("NOA Product Testing"); -static const u8 sCreditsText_HideyukiNakajima[] = _("Hideyuki Nakajima"); -static const u8 sCreditsText_HidenoriSaeki[] = _("Hidenori Saeki"); -static const u8 sCreditsText_YokoWatanabe[] = _("Yoko Watanabe"); -static const u8 sCreditsText_SakaeKimura[] = _("Sakae Kimura"); -static const u8 sCreditsText_ChiakiShinkai[] = _("Chiaki Shinkai"); -static const u8 sCreditsText_SethMcMahill[] = _("Seth McMahill"); -static const u8 sCreditsText_NobOgasawara[] = _("Nob Ogasawara"); -static const u8 sCreditsText_TeresaLillygren[] = _("Teresa Lillygren"); -static const u8 sCreditsText_KimikoNakamichi[] = _("Kimiko Nakamichi"); -static const u8 sCreditsText_SouichiYamamoto[] = _("Souichi Yamamoto"); -static const u8 sCreditsText_YuichiroIto[] = _("Yuichiro Ito"); -static const u8 sCreditsText_ThomasHertzog[] = _("Thomas Hertzog"); -static const u8 sCreditsText_MikaKurosawa[] = _("Mika Kurosawa"); -static const u8 sCreditsText_NationalFederationBlind[] = _("National Federation of the Blind"); -static const u8 sCreditsText_PatriciaAMaurer[] = _("Patricia A. Maurer"); -static const u8 sCreditsText_EuropeanBlindUnion[] = _("European Blind Union"); -static const u8 sCreditsText_AustralianBrailleAuthority[] = _("Australian Braille Authority"); -static const u8 sCreditsText_RoyalNewZealandFederationBlind[] = _("Royal New Zealand Federation for the Blind"); -static const u8 sCreditsText_MotoyasuTojima[] = _("Motoyasu Tojima"); -static const u8 sCreditsText_NicolaPrattBarlow[] = _("Nicola Pratt-Barlow"); -static const u8 sCreditsText_ShellieDow[] = _("Shellie Dow"); -static const u8 sCreditsText_ErikJohnson[] = _("Erik Johnson"); -static const struct CreditsEntry sCreditsEntry_EmptyString[] = { 0, FALSE, sCreditsText_EmptyString}; -static const struct CreditsEntry sCreditsEntry_PkmnEmeraldVersion[] = { 7, TRUE, sCreditsText_PkmnEmeraldVersion}; -static const struct CreditsEntry sCreditsEntry_Credits[] = {11, TRUE, sCreditsText_Credits}; -static const struct CreditsEntry sCreditsEntry_ExecutiveDirector[] = { 8, TRUE, sCreditsText_ExecutiveDirector}; -static const struct CreditsEntry sCreditsEntry_Director[] = {12, TRUE, sCreditsText_Director}; -static const struct CreditsEntry sCreditsEntry_ArtDirector[] = {10, TRUE, sCreditsText_ArtDirector}; -static const struct CreditsEntry sCreditsEntry_BattleDirector[] = {10, TRUE, sCreditsText_BattleDirector}; -static const struct CreditsEntry sCreditsEntry_MainProgrammer[] = {10, TRUE, sCreditsText_MainProgrammer}; -static const struct CreditsEntry sCreditsEntry_BattleSystemPgrms[] = { 8, TRUE, sCreditsText_BattleSystemPgrms}; -static const struct CreditsEntry sCreditsEntry_FieldSystemPgrms[] = { 7, TRUE, sCreditsText_FieldSystemPgrms}; -static const struct CreditsEntry sCreditsEntry_Programmers[] = {12, TRUE, sCreditsText_Programmers}; -static const struct CreditsEntry sCreditsEntry_MainGraphicDesigner[] = { 7, TRUE, sCreditsText_MainGraphicDesigner}; -static const struct CreditsEntry sCreditsEntry_GraphicDesigners[] = { 9, TRUE, sCreditsText_GraphicDesigners}; -static const struct CreditsEntry sCreditsEntry_PkmnDesigners[] = {10, TRUE, sCreditsText_PkmnDesigners}; -static const struct CreditsEntry sCreditsEntry_MusicComposition[] = {13, TRUE, sCreditsText_MusicComposition}; -static const struct CreditsEntry sCreditsEntry_SoundEffectsAndPkmnVoices[] = { 4, TRUE, sCreditsText_SoundEffectsAndPkmnVoices}; -static const struct CreditsEntry sCreditsEntry_GameDesigners[] = {11, TRUE, sCreditsText_GameDesigners}; -static const struct CreditsEntry sCreditsEntry_ScenarioPlot[] = {11, TRUE, sCreditsText_ScenarioPlot}; -static const struct CreditsEntry sCreditsEntry_Scenario[] = {13, TRUE, sCreditsText_Scenario}; -static const struct CreditsEntry sCreditsEntry_ScriptDesigners[] = {10, TRUE, sCreditsText_ScriptDesigners}; -static const struct CreditsEntry sCreditsEntry_MapDesigners[] = {11, TRUE, sCreditsText_MapDesigners}; -static const struct CreditsEntry sCreditsEntry_MapDataDesigners[] = { 9, TRUE, sCreditsText_MapDataDesigners}; -static const struct CreditsEntry sCreditsEntry_ParametricDesigners[] = { 9, TRUE, sCreditsText_ParametricDesigners}; -static const struct CreditsEntry sCreditsEntry_PokedexText[] = {11, TRUE, sCreditsText_PokedexText}; -static const struct CreditsEntry sCreditsEntry_EnvAndToolPgrms[] = { 6, TRUE, sCreditsText_EnvAndToolPgrms}; -static const struct CreditsEntry sCreditsEntry_NCLProductTesting[] = {11, TRUE, sCreditsText_NCLProductTesting}; -static const struct CreditsEntry sCreditsEntry_SpecialThanks[] = {10, TRUE, sCreditsText_SpecialThanks}; -static const struct CreditsEntry sCreditsEntry_Coordinators[] = {11, TRUE, sCreditsText_Coordinators}; -static const struct CreditsEntry sCreditsEntry_Producers[] = {11, TRUE, sCreditsText_Producers}; -static const struct CreditsEntry sCreditsEntry_ExecProducers[] = { 7, TRUE, sCreditsText_ExecProducers}; -static const struct CreditsEntry sCreditsEntry_InfoSupervisors[] = {10, TRUE, sCreditsText_InfoSupervisors}; -static const struct CreditsEntry sCreditsEntry_TaskManagers[] = { 8, TRUE, sCreditsText_TaskManagers}; -static const struct CreditsEntry sCreditsEntry_BrailleCodeCheck[] = {10, TRUE, sCreditsText_BrailleCodeCheck}; -static const struct CreditsEntry sCreditsEntry_WorldDirector[] = {10, TRUE, sCreditsText_WorldDirector}; -static const struct CreditsEntry sCreditsEntry_BattleFrontierData[] = { 8, TRUE, sCreditsText_BattleFrontierData}; -static const struct CreditsEntry sCreditsEntry_SupportProgrammers[] = {10, TRUE, sCreditsText_SupportProgrammers}; -static const struct CreditsEntry sCreditsEntry_Artwork[] = {12, TRUE, sCreditsText_Artwork}; -static const struct CreditsEntry sCreditsEntry_LeadProgrammer[] = {10, TRUE, sCreditsText_LeadProgrammer}; -static const struct CreditsEntry sCreditsEntry_LeadGraphicArtist[] = { 9, TRUE, sCreditsText_LeadGraphicArtist}; -static const struct CreditsEntry sCreditsEntry_SatoshiTajiri[] = {11, FALSE, sCreditsText_SatoshiTajiri}; -static const struct CreditsEntry sCreditsEntry_JunichiMasuda[] = {11, FALSE, sCreditsText_JunichiMasuda}; -static const struct CreditsEntry sCreditsEntry_KenSugimori[] = {11, FALSE, sCreditsText_KenSugimori}; -static const struct CreditsEntry sCreditsEntry_ShigekiMorimoto[] = {11, FALSE, sCreditsText_ShigekiMorimoto}; -static const struct CreditsEntry sCreditsEntry_TetsuyaWatanabe[] = {11, FALSE, sCreditsText_TetsuyaWatanabe}; -static const struct CreditsEntry sCreditsEntry_HisashiSogabe[] = {11, FALSE, sCreditsText_HisashiSogabe}; -static const struct CreditsEntry sCreditsEntry_SosukeTamada[] = {11, FALSE, sCreditsText_SosukeTamada}; -static const struct CreditsEntry sCreditsEntry_AkitoMori[] = {11, FALSE, sCreditsText_AkitoMori}; -static const struct CreditsEntry sCreditsEntry_KeitaKagaya[] = {11, FALSE, sCreditsText_KeitaKagaya}; -static const struct CreditsEntry sCreditsEntry_YoshinoriMatsuda[] = {11, FALSE, sCreditsText_YoshinoriMatsuda}; -static const struct CreditsEntry sCreditsEntry_HiroyukiNakamura[] = {11, FALSE, sCreditsText_HiroyukiNakamura}; -static const struct CreditsEntry sCreditsEntry_MasaoTaya[] = {11, FALSE, sCreditsText_MasaoTaya}; -static const struct CreditsEntry sCreditsEntry_SatoshiNohara[] = {11, FALSE, sCreditsText_SatoshiNohara}; -static const struct CreditsEntry sCreditsEntry_TomomichiOhta[] = {11, FALSE, sCreditsText_TomomichiOhta}; -static const struct CreditsEntry sCreditsEntry_MiyukiIwasawa[] = {11, FALSE, sCreditsText_MiyukiIwasawa}; -static const struct CreditsEntry sCreditsEntry_TakenoriOhta[] = {11, FALSE, sCreditsText_TakenoriOhta}; -static const struct CreditsEntry sCreditsEntry_HironobuYoshida[] = {11, FALSE, sCreditsText_HironobuYoshida}; -static const struct CreditsEntry sCreditsEntry_MotofumiFujiwara[] = {11, FALSE, sCreditsText_MotofumiFujiwara}; -static const struct CreditsEntry sCreditsEntry_SatoshiOhta[] = {11, FALSE, sCreditsText_SatoshiOhta}; -static const struct CreditsEntry sCreditsEntry_AsukaIwashita[] = {11, FALSE, sCreditsText_AsukaIwashita}; -static const struct CreditsEntry sCreditsEntry_AimiTomita[] = {11, FALSE, sCreditsText_AimiTomita}; -static const struct CreditsEntry sCreditsEntry_TakaoUnno[] = {11, FALSE, sCreditsText_TakaoUnno}; -static const struct CreditsEntry sCreditsEntry_KanakoEo[] = {11, FALSE, sCreditsText_KanakoEo}; -static const struct CreditsEntry sCreditsEntry_JunOkutani[] = {11, FALSE, sCreditsText_JunOkutani}; -static const struct CreditsEntry sCreditsEntry_AtsukoNishida[] = {11, FALSE, sCreditsText_AtsukoNishida}; -static const struct CreditsEntry sCreditsEntry_MuneoSaito[] = {11, FALSE, sCreditsText_MuneoSaito}; -static const struct CreditsEntry sCreditsEntry_RenaYoshikawa[] = {11, FALSE, sCreditsText_RenaYoshikawa}; -static const struct CreditsEntry sCreditsEntry_GoIchinose[] = {11, FALSE, sCreditsText_GoIchinose}; -static const struct CreditsEntry sCreditsEntry_MorikazuAoki[] = {11, FALSE, sCreditsText_MorikazuAoki}; -static const struct CreditsEntry sCreditsEntry_KojiNishino[] = {11, FALSE, sCreditsText_KojiNishino}; -static const struct CreditsEntry sCreditsEntry_KenjiMatsushima[] = {11, FALSE, sCreditsText_KenjiMatsushima}; -static const struct CreditsEntry sCreditsEntry_TetsujiOhta[] = {11, FALSE, sCreditsText_TetsujiOhta}; -static const struct CreditsEntry sCreditsEntry_HitomiSato[] = {11, FALSE, sCreditsText_HitomiSato}; -static const struct CreditsEntry sCreditsEntry_TakeshiKawachimaru[] = {11, FALSE, sCreditsText_TakeshiKawachimaru}; -static const struct CreditsEntry sCreditsEntry_TeruyukiShimoyamada[] = {11, FALSE, sCreditsText_TeruyukiShimoyamada}; -static const struct CreditsEntry sCreditsEntry_ShigeruOhmori[] = {11, FALSE, sCreditsText_ShigeruOhmori}; -static const struct CreditsEntry sCreditsEntry_TadashiTakahashi[] = {11, FALSE, sCreditsText_TadashiTakahashi}; -static const struct CreditsEntry sCreditsEntry_ToshinobuMatsumiya[] = {11, FALSE, sCreditsText_ToshinobuMatsumiya}; -static const struct CreditsEntry sCreditsEntry_AkihitoTomisawa[] = {11, FALSE, sCreditsText_AkihitoTomisawa}; -static const struct CreditsEntry sCreditsEntry_HirokiEnomoto[] = {11, FALSE, sCreditsText_HirokiEnomoto}; -static const struct CreditsEntry sCreditsEntry_KazuyukiTerada[] = {11, FALSE, sCreditsText_KazuyukiTerada}; -static const struct CreditsEntry sCreditsEntry_YuriSakurai[] = {11, FALSE, sCreditsText_YuriSakurai}; -static const struct CreditsEntry sCreditsEntry_HiromiSagawa[] = {11, FALSE, sCreditsText_HiromiSagawa}; -static const struct CreditsEntry sCreditsEntry_KenjiTominaga[] = {11, FALSE, sCreditsText_KenjiTominaga}; -static const struct CreditsEntry sCreditsEntry_YoshioTajiri[] = {11, FALSE, sCreditsText_YoshioTajiri}; -static const struct CreditsEntry sCreditsEntry_TeikoSasaki[] = {11, FALSE, sCreditsText_TeikoSasaki}; -static const struct CreditsEntry sCreditsEntry_SachikoHamano[] = {11, FALSE, sCreditsText_SachikoHamano}; -static const struct CreditsEntry sCreditsEntry_ChieMatsumiya[] = {11, FALSE, sCreditsText_ChieMatsumiya}; -static const struct CreditsEntry sCreditsEntry_AkikoShinozaki[] = {11, FALSE, sCreditsText_AkikoShinozaki}; -static const struct CreditsEntry sCreditsEntry_AstukoFujii[] = {11, FALSE, sCreditsText_AstukoFujii}; -static const struct CreditsEntry sCreditsEntry_NozomuSaito[] = {11, FALSE, sCreditsText_NozomuSaito}; -static const struct CreditsEntry sCreditsEntry_KenkichiToyama[] = {11, FALSE, sCreditsText_KenkichiToyama}; -static const struct CreditsEntry sCreditsEntry_SuguruNakatsui[] = {11, FALSE, sCreditsText_SuguruNakatsui}; -static const struct CreditsEntry sCreditsEntry_YumiFunasaka[] = {11, FALSE, sCreditsText_YumiFunasaka}; -static const struct CreditsEntry sCreditsEntry_NaokoYanase[] = {11, FALSE, sCreditsText_NaokoYanase}; -static const struct CreditsEntry sCreditsEntry_NCLSuperMarioClub[] = {11, FALSE, sCreditsText_NCLSuperMarioClub}; -static const struct CreditsEntry sCreditsEntry_AtsushiTada[] = {11, FALSE, sCreditsText_AtsushiTada}; -static const struct CreditsEntry sCreditsEntry_TakahiroOhnishi[] = {11, FALSE, sCreditsText_TakahiroOhnishi}; -static const struct CreditsEntry sCreditsEntry_NorihideOkamura[] = {11, FALSE, sCreditsText_NorihideOkamura}; -static const struct CreditsEntry sCreditsEntry_HiroNakamura[] = {11, FALSE, sCreditsText_HiroNakamura}; -static const struct CreditsEntry sCreditsEntry_HiroyukiUesugi[] = {11, FALSE, sCreditsText_HiroyukiUesugi}; -static const struct CreditsEntry sCreditsEntry_TerukiMurakawa[] = {11, FALSE, sCreditsText_TerukiMurakawa}; -static const struct CreditsEntry sCreditsEntry_AkiraKinashi[] = {11, FALSE, sCreditsText_AkiraKinashi}; -static const struct CreditsEntry sCreditsEntry_MichikoTakizawa[] = {11, FALSE, sCreditsText_MichikoTakizawa}; -static const struct CreditsEntry sCreditsEntry_MakikoTakada[] = {11, FALSE, sCreditsText_MakikoTakada}; -static const struct CreditsEntry sCreditsEntry_TakanaoKondo[] = {11, FALSE, sCreditsText_TakanaoKondo}; -static const struct CreditsEntry sCreditsEntry_AiMashima[] = {11, FALSE, sCreditsText_AiMashima}; -static const struct CreditsEntry sCreditsEntry_GakujiNomoto[] = {11, FALSE, sCreditsText_GakujiNomoto}; -static const struct CreditsEntry sCreditsEntry_TakehiroIzushi[] = {11, FALSE, sCreditsText_TakehiroIzushi}; -static const struct CreditsEntry sCreditsEntry_HitoshiYamagami[] = {11, FALSE, sCreditsText_HitoshiYamagami}; -static const struct CreditsEntry sCreditsEntry_KyokoWatanabe[] = {11, FALSE, sCreditsText_KyokoWatanabe}; -static const struct CreditsEntry sCreditsEntry_TakaoNakano[] = {11, FALSE, sCreditsText_TakaoNakano}; -static const struct CreditsEntry sCreditsEntry_HiroyukiJinnai[] = {11, FALSE, sCreditsText_HiroyukiJinnai}; -static const struct CreditsEntry sCreditsEntry_HiroakiTsuru[] = {11, FALSE, sCreditsText_HiroakiTsuru}; -static const struct CreditsEntry sCreditsEntry_TsunekazIshihara[] = {11, FALSE, sCreditsText_TsunekazIshihara}; -static const struct CreditsEntry sCreditsEntry_SatoruIwata[] = {11, FALSE, sCreditsText_SatoruIwata}; -static const struct CreditsEntry sCreditsEntry_KazuyaSuyama[] = {11, FALSE, sCreditsText_KazuyaSuyama}; -static const struct CreditsEntry sCreditsEntry_SatoshiMitsuhara[] = {11, FALSE, sCreditsText_SatoshiMitsuhara}; -static const struct CreditsEntry sCreditsEntry_JapanBrailleLibrary[] = { 9, FALSE, sCreditsText_JapanBrailleLibrary}; -static const struct CreditsEntry sCreditsEntry_TomotakaKomura[] = {11, FALSE, sCreditsText_TomotakaKomura}; -static const struct CreditsEntry sCreditsEntry_MikikoOhhashi[] = {11, FALSE, sCreditsText_MikikoOhhashi}; -static const struct CreditsEntry sCreditsEntry_DaisukeHoshino[] = {11, FALSE, sCreditsText_DaisukeHoshino}; -static const struct CreditsEntry sCreditsEntry_KenjiroIto[] = {11, FALSE, sCreditsText_KenjiroIto}; -static const struct CreditsEntry sCreditsEntry_RuiKawaguchi[] = {11, FALSE, sCreditsText_RuiKawaguchi}; -static const struct CreditsEntry sCreditsEntry_ShunsukeKohori[] = {11, FALSE, sCreditsText_ShunsukeKohori}; -static const struct CreditsEntry sCreditsEntry_SachikoNakamichi[] = {11, FALSE, sCreditsText_SachikoNakamichi}; -static const struct CreditsEntry sCreditsEntry_FujikoNomura[] = {11, FALSE, sCreditsText_FujikoNomura}; -static const struct CreditsEntry sCreditsEntry_KazukiYoshihara[] = {11, FALSE, sCreditsText_KazukiYoshihara}; -static const struct CreditsEntry sCreditsEntry_RetsujiNomoto[] = {11, FALSE, sCreditsText_RetsujiNomoto}; -static const struct CreditsEntry sCreditsEntry_AzusaTajima[] = {11, FALSE, sCreditsText_AzusaTajima}; -static const struct CreditsEntry sCreditsEntry_ShusakuEgami[] = {11, FALSE, sCreditsText_ShusakuEgami}; -static const struct CreditsEntry sCreditsEntry_PackageAndManual[] = { 0, TRUE, sCreditsText_PackageAndManual}; -static const struct CreditsEntry sCreditsEntry_EnglishVersion[] = { 0, TRUE, sCreditsText_EnglishVersion}; -static const struct CreditsEntry sCreditsEntry_Translator[] = { 0, TRUE, sCreditsText_Translator}; -static const struct CreditsEntry sCreditsEntry_TextEditor[] = { 0, TRUE, sCreditsText_TextEditor}; -static const struct CreditsEntry sCreditsEntry_NCLCoordinator[] = { 0, TRUE, sCreditsText_NCLCoordinator}; -static const struct CreditsEntry sCreditsEntry_GraphicDesigner[] = { 0, TRUE, sCreditsText_GraphicDesigner}; -static const struct CreditsEntry sCreditsEntry_NOAProductTesting[] = { 0, TRUE, sCreditsText_NOAProductTesting}; -static const struct CreditsEntry sCreditsEntry_HideyukiNakajima[] = { 0, FALSE, sCreditsText_HideyukiNakajima}; -static const struct CreditsEntry sCreditsEntry_HidenoriSaeki[] = { 0, FALSE, sCreditsText_HidenoriSaeki}; -static const struct CreditsEntry sCreditsEntry_YokoWatanabe[] = { 0, FALSE, sCreditsText_YokoWatanabe}; -static const struct CreditsEntry sCreditsEntry_SakaeKimura[] = { 0, FALSE, sCreditsText_SakaeKimura}; -static const struct CreditsEntry sCreditsEntry_ChiakiShinkai[] = { 0, FALSE, sCreditsText_ChiakiShinkai}; -static const struct CreditsEntry sCreditsEntry_SethMcMahill[] = { 0, FALSE, sCreditsText_SethMcMahill}; -static const struct CreditsEntry sCreditsEntry_NobOgasawara[] = { 0, FALSE, sCreditsText_NobOgasawara}; -static const struct CreditsEntry sCreditsEntry_TeresaLillygren[] = { 0, FALSE, sCreditsText_TeresaLillygren}; -static const struct CreditsEntry sCreditsEntry_KimikoNakamichi[] = { 0, FALSE, sCreditsText_KimikoNakamichi}; -static const struct CreditsEntry sCreditsEntry_SouichiYamamoto[] = { 0, FALSE, sCreditsText_SouichiYamamoto}; -static const struct CreditsEntry sCreditsEntry_YuichiroIto[] = { 0, FALSE, sCreditsText_YuichiroIto}; -static const struct CreditsEntry sCreditsEntry_ThomasHertzog[] = { 0, FALSE, sCreditsText_ThomasHertzog}; -static const struct CreditsEntry sCreditsEntry_MikaKurosawa[] = { 0, FALSE, sCreditsText_MikaKurosawa}; -static const struct CreditsEntry sCreditsEntry_NationalFederationBlind[] = { 0, FALSE, sCreditsText_NationalFederationBlind}; -static const struct CreditsEntry sCreditsEntry_PatriciaAMaurer[] = { 0, FALSE, sCreditsText_PatriciaAMaurer}; -static const struct CreditsEntry sCreditsEntry_EuropeanBlindUnion[] = { 0, FALSE, sCreditsText_EuropeanBlindUnion}; -static const struct CreditsEntry sCreditsEntry_AustralianBrailleAuthority[] = { 0, FALSE, sCreditsText_AustralianBrailleAuthority}; -static const struct CreditsEntry sCreditsEntry_RoyalNewZealandFederationBlind[] = { 0, FALSE, sCreditsText_RoyalNewZealandFederationBlind}; -static const struct CreditsEntry sCreditsEntry_MotoyasuTojima[] = { 0, FALSE, sCreditsText_MotoyasuTojima}; -static const struct CreditsEntry sCreditsEntry_NicolaPrattBarlow[] = { 0, FALSE, sCreditsText_NicolaPrattBarlow}; -static const struct CreditsEntry sCreditsEntry_ShellieDow[] = { 0, FALSE, sCreditsText_ShellieDow}; -static const struct CreditsEntry sCreditsEntry_ErikJohnson[] = { 0, FALSE, sCreditsText_ErikJohnson}; - -#define _ sCreditsEntry_EmptyString -static const struct CreditsEntry *const gCreditsEntryPointerTable[][5] = -{ - { - _, - sCreditsEntry_PkmnEmeraldVersion, - sCreditsEntry_Credits, - _, - _ - }, - { - _, - sCreditsEntry_Director, - sCreditsEntry_ShigekiMorimoto, - _, - _, - }, - { - _, - sCreditsEntry_ArtDirector, - sCreditsEntry_KenSugimori, - _, - _, - }, - { - _, - sCreditsEntry_WorldDirector, - sCreditsEntry_JunichiMasuda, - _, - _, - }, - { - sCreditsEntry_LeadProgrammer, - sCreditsEntry_HisashiSogabe, - sCreditsEntry_LeadGraphicArtist, - sCreditsEntry_MotofumiFujiwara, - _, - }, - { - sCreditsEntry_Programmers, - sCreditsEntry_HisashiSogabe, - sCreditsEntry_TomomichiOhta, - sCreditsEntry_NozomuSaito, - sCreditsEntry_EmptyString, - }, - { - sCreditsEntry_Programmers, - sCreditsEntry_AkitoMori, - sCreditsEntry_HiroyukiNakamura, - sCreditsEntry_MasaoTaya, - _, - }, - { - sCreditsEntry_Programmers, - sCreditsEntry_SatoshiNohara, - sCreditsEntry_MiyukiIwasawa, - sCreditsEntry_YoshinoriMatsuda, - sCreditsEntry_KeitaKagaya, - }, - { - sCreditsEntry_Programmers, - sCreditsEntry_TetsuyaWatanabe, - sCreditsEntry_SosukeTamada, - sCreditsEntry_TakenoriOhta, - _, - }, - { - _, - sCreditsEntry_GraphicDesigners, - sCreditsEntry_MotofumiFujiwara, - sCreditsEntry_SatoshiOhta, - _, - }, - { - sCreditsEntry_GraphicDesigners, - sCreditsEntry_KenkichiToyama, - sCreditsEntry_AsukaIwashita, - sCreditsEntry_TakaoUnno, - _, - }, - { - sCreditsEntry_GraphicDesigners, - sCreditsEntry_KenSugimori, - sCreditsEntry_HironobuYoshida, - sCreditsEntry_AimiTomita, - sCreditsEntry_KanakoEo, - }, - { - sCreditsEntry_MusicComposition, - sCreditsEntry_GoIchinose, - sCreditsEntry_JunichiMasuda, - sCreditsEntry_MorikazuAoki, - sCreditsEntry_HitomiSato, - }, - { - _, - sCreditsEntry_SoundEffectsAndPkmnVoices, - sCreditsEntry_GoIchinose, - sCreditsEntry_MorikazuAoki, - _, - }, - { - sCreditsEntry_GameDesigners, - sCreditsEntry_ShigekiMorimoto, - sCreditsEntry_TeruyukiShimoyamada, - sCreditsEntry_TakeshiKawachimaru, - sCreditsEntry_AkihitoTomisawa, - }, - { - sCreditsEntry_GameDesigners, - sCreditsEntry_SuguruNakatsui, - sCreditsEntry_TetsujiOhta, - sCreditsEntry_HitomiSato, - sCreditsEntry_KenjiMatsushima, - }, - { - sCreditsEntry_GameDesigners, - sCreditsEntry_JunichiMasuda, - sCreditsEntry_KojiNishino, - sCreditsEntry_ShigeruOhmori, - sCreditsEntry_TadashiTakahashi, - }, - { - sCreditsEntry_ScenarioPlot, - sCreditsEntry_AkihitoTomisawa, - sCreditsEntry_JunichiMasuda, - sCreditsEntry_KojiNishino, - _, - }, - { - sCreditsEntry_Scenario, - sCreditsEntry_AkihitoTomisawa, - sCreditsEntry_HitomiSato, - sCreditsEntry_ToshinobuMatsumiya, - _, - }, - { - sCreditsEntry_ScriptDesigners, - sCreditsEntry_TomomichiOhta, - sCreditsEntry_SatoshiNohara, - _, - _, - }, - { - sCreditsEntry_MapDesigners, - sCreditsEntry_SuguruNakatsui, - sCreditsEntry_TeruyukiShimoyamada, - sCreditsEntry_ShigeruOhmori, - sCreditsEntry_TetsujiOhta, - }, - { - _, - sCreditsEntry_BattleFrontierData, - sCreditsEntry_TetsujiOhta, - _, - _, - }, - { - sCreditsEntry_ParametricDesigners, - sCreditsEntry_TeruyukiShimoyamada, - sCreditsEntry_ShigekiMorimoto, - sCreditsEntry_TetsujiOhta, - sCreditsEntry_KojiNishino, - }, - { - _, - sCreditsEntry_PokedexText, - sCreditsEntry_KenjiMatsushima, - _, - _, - }, - { - sCreditsEntry_EnvAndToolPgrms, - sCreditsEntry_HisashiSogabe, - sCreditsEntry_SosukeTamada, - sCreditsEntry_HiroyukiNakamura, - sCreditsEntry_AkitoMori, - }, - { - sCreditsEntry_PkmnDesigners, - sCreditsEntry_KenSugimori, - sCreditsEntry_MotofumiFujiwara, - sCreditsEntry_ShigekiMorimoto, - _, - }, - { - sCreditsEntry_PkmnDesigners, - sCreditsEntry_HironobuYoshida, - sCreditsEntry_SatoshiOhta, - sCreditsEntry_AsukaIwashita, - _, - }, - { - sCreditsEntry_PkmnDesigners, - sCreditsEntry_TakaoUnno, - sCreditsEntry_KanakoEo, - sCreditsEntry_AimiTomita, - _, - }, - { - sCreditsEntry_PkmnDesigners, - sCreditsEntry_AtsukoNishida, - sCreditsEntry_MuneoSaito, - sCreditsEntry_RenaYoshikawa, - sCreditsEntry_JunOkutani, - }, - { - _, - sCreditsEntry_SupportProgrammers, - sCreditsEntry_SatoshiMitsuhara, - sCreditsEntry_DaisukeHoshino, - _, - }, - { - _, - sCreditsEntry_NCLProductTesting, - sCreditsEntry_NCLSuperMarioClub, - _, - _, - }, - { - _, - sCreditsEntry_PackageAndManual, - sCreditsEntry_KenSugimori, - _, - _, - }, - { - _, - sCreditsEntry_SpecialThanks, - sCreditsEntry_KenjiTominaga, - sCreditsEntry_HirokiEnomoto, - _, - }, - { - sCreditsEntry_SpecialThanks, - sCreditsEntry_KazuyaSuyama, - sCreditsEntry_KenjiroIto, - sCreditsEntry_MichikoTakizawa, - sCreditsEntry_MakikoTakada, - }, - { - sCreditsEntry_SpecialThanks, - sCreditsEntry_MikikoOhhashi, - sCreditsEntry_TakanaoKondo, - sCreditsEntry_RuiKawaguchi, - _, - }, - { - sCreditsEntry_SpecialThanks, - sCreditsEntry_TakahiroOhnishi, - sCreditsEntry_NorihideOkamura, - sCreditsEntry_ShunsukeKohori, - _, - }, - { - sCreditsEntry_InfoSupervisors, - sCreditsEntry_KazuyukiTerada, - sCreditsEntry_YuriSakurai, - sCreditsEntry_YumiFunasaka, - sCreditsEntry_NaokoYanase, - }, - { - _, - sCreditsEntry_Artwork, - sCreditsEntry_SachikoNakamichi, - sCreditsEntry_FujikoNomura, - _, - }, - { - _, - sCreditsEntry_Artwork, - sCreditsEntry_HideyukiNakajima, - sCreditsEntry_HidenoriSaeki, - _, - }, - { - sCreditsEntry_Artwork, - sCreditsEntry_YokoWatanabe, - sCreditsEntry_SakaeKimura, - sCreditsEntry_ChiakiShinkai, - _, - }, - { - sCreditsEntry_Coordinators, - sCreditsEntry_KazukiYoshihara, - sCreditsEntry_AkiraKinashi, - sCreditsEntry_RetsujiNomoto, - _, - }, - { - _, - sCreditsEntry_EnglishVersion, - sCreditsEntry_HiroNakamura, - sCreditsEntry_SethMcMahill, - _, - }, - { - _, - sCreditsEntry_Translator, - sCreditsEntry_NobOgasawara, - _, - _, - }, - { - _, - sCreditsEntry_TextEditor, - sCreditsEntry_TeresaLillygren, - _, - _, - }, - { - _, - sCreditsEntry_NCLCoordinator, - sCreditsEntry_KimikoNakamichi, - _, - _, - }, - { - sCreditsEntry_Programmers, - sCreditsEntry_TerukiMurakawa, - sCreditsEntry_SouichiYamamoto, - sCreditsEntry_YuichiroIto, - sCreditsEntry_AkiraKinashi, - }, - { - _, - sCreditsEntry_GraphicDesigner, - sCreditsEntry_AkiraKinashi, - _, - _, - }, - { - sCreditsEntry_EnvAndToolPgrms, - sCreditsEntry_TerukiMurakawa, - sCreditsEntry_SouichiYamamoto, - sCreditsEntry_KimikoNakamichi, - _, - }, - { - sCreditsEntry_NOAProductTesting, - sCreditsEntry_ThomasHertzog, - sCreditsEntry_ErikJohnson, - sCreditsEntry_MikaKurosawa, - _, - }, - { - sCreditsEntry_BrailleCodeCheck, - sCreditsEntry_NationalFederationBlind, - sCreditsEntry_PatriciaAMaurer, - sCreditsEntry_JapanBrailleLibrary, - sCreditsEntry_EuropeanBlindUnion, - }, - { - _, - sCreditsEntry_BrailleCodeCheck, - sCreditsEntry_AustralianBrailleAuthority, - sCreditsEntry_RoyalNewZealandFederationBlind, - _, - }, - { - sCreditsEntry_SpecialThanks, - sCreditsEntry_HiroyukiUesugi, - sCreditsEntry_MotoyasuTojima, - sCreditsEntry_NicolaPrattBarlow, - sCreditsEntry_ShellieDow, - }, - { - _, - sCreditsEntry_TaskManagers, - sCreditsEntry_AzusaTajima, - sCreditsEntry_ShusakuEgami, - _, - }, - { - sCreditsEntry_Producers, - sCreditsEntry_HiroyukiJinnai, - sCreditsEntry_HitoshiYamagami, - sCreditsEntry_GakujiNomoto, - sCreditsEntry_HiroakiTsuru, - }, - { - _, - sCreditsEntry_ExecutiveDirector, - sCreditsEntry_SatoshiTajiri, - _, - _, - }, - { - _, - sCreditsEntry_ExecProducers, - sCreditsEntry_SatoruIwata, - _, - _, - }, - { - _, - sCreditsEntry_ExecProducers, - sCreditsEntry_TsunekazIshihara, - _, - _, - }, -}; -#undef _ +#include "data/credits.h" static const struct BgTemplate sBackgroundTemplates[] = { @@ -966,7 +214,7 @@ static const u8 sMonSpritePos[][2] = {136, 36}, }; -static const union AnimCmd gUnknown_085E6F84[] = +static const union AnimCmd sAnim_Player_Slow[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(64, 8), @@ -975,7 +223,7 @@ static const union AnimCmd gUnknown_085E6F84[] = ANIMCMD_JUMP(0), }; -static const union AnimCmd gUnknown_085E6F98[] = +static const union AnimCmd sAnim_Player_Fast[] = { ANIMCMD_FRAME(0, 4), ANIMCMD_FRAME(64, 4), @@ -984,7 +232,7 @@ static const union AnimCmd gUnknown_085E6F98[] = ANIMCMD_JUMP(0), }; -static const union AnimCmd gUnknown_085E6FAC[] = +static const union AnimCmd sAnim_Player_LookBack[] = { ANIMCMD_FRAME(256, 4), ANIMCMD_FRAME(320, 4), @@ -992,7 +240,7 @@ static const union AnimCmd gUnknown_085E6FAC[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E6FBC[] = +static const union AnimCmd sAnim_Player_LookForward[] = { ANIMCMD_FRAME(384, 30), ANIMCMD_FRAME(320, 30), @@ -1001,15 +249,15 @@ static const union AnimCmd gUnknown_085E6FBC[] = ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E6FD0[] = +static const union AnimCmd *const sAnims_Player[] = { - gUnknown_085E6F84, - gUnknown_085E6F98, - gUnknown_085E6FAC, - gUnknown_085E6FBC, + sAnim_Player_Slow, + sAnim_Player_Fast, + sAnim_Player_LookBack, + sAnim_Player_LookForward, }; -static const union AnimCmd gUnknown_085E6FE0[] = +static const union AnimCmd sAnim_Rival_Slow[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(64, 8), @@ -1018,7 +266,7 @@ static const union AnimCmd gUnknown_085E6FE0[] = ANIMCMD_JUMP(0), }; -static const union AnimCmd gUnknown_085E6FF4[] = +static const union AnimCmd sAnim_Rival_Fast[] = { ANIMCMD_FRAME(0, 4), ANIMCMD_FRAME(64, 4), @@ -1027,31 +275,32 @@ static const union AnimCmd gUnknown_085E6FF4[] = ANIMCMD_JUMP(0), }; -static const union AnimCmd gUnknown_085E7008[] = +static const union AnimCmd sAnim_Rival_Still[] = { ANIMCMD_FRAME(0, 4), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E7010[] = +static const union AnimCmd *const sAnims_Rival[] = { - gUnknown_085E6FE0, - gUnknown_085E6FF4, - gUnknown_085E7008, + sAnim_Rival_Slow, + sAnim_Rival_Fast, + sAnim_Rival_Still, }; -static const struct SpriteSheet gUnknown_085E701C[] = { - { gDecompressionBuffer, 6144, 1001 }, - { NULL }, +#define MONBG_OFFSET (0x800 * 3) +static const struct SpriteSheet sSpriteSheet_MonBg[] = { + { gDecompressionBuffer, MONBG_OFFSET, TAG_MON_BG }, + {}, }; -static const struct SpritePalette gUnknown_085E702C[] = { - { (const u16 *)(gDecompressionBuffer + 0x1800), 1001 }, - { NULL }, +static const struct SpritePalette sSpritePalette_MonBg[] = { + { (const u16 *)&gDecompressionBuffer[MONBG_OFFSET], TAG_MON_BG }, + {}, }; -static const struct OamData gUnknown_085E703C = +static const struct OamData sOamData_MonBg = { - .y = 160, + .y = DISPLAY_HEIGHT, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, @@ -1066,90 +315,63 @@ static const struct OamData gUnknown_085E703C = .affineParam = 0, }; -static const union AnimCmd gUnknown_085E7044[] = +static const union AnimCmd sAnim_MonBg_Yellow[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E704C[] = +static const union AnimCmd sAnim_MonBg_Red[] = { ANIMCMD_FRAME(64, 8), ANIMCMD_END, }; -static const union AnimCmd gUnknown_085E7054[] = +static const union AnimCmd sAnim_MonBg_Blue[] = { ANIMCMD_FRAME(128, 8), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_085E705C[] = +static const union AnimCmd *const sAnims_MonBg[] = { - gUnknown_085E7044, - gUnknown_085E704C, - gUnknown_085E7054, + [POS_LEFT] = sAnim_MonBg_Yellow, + [POS_CENTER] = sAnim_MonBg_Red, + [POS_RIGHT] = sAnim_MonBg_Blue, }; -static const struct SpriteTemplate gUnknown_085E7068 = +static const struct SpriteTemplate sSpriteTemplate_CreditsMonBg = { - .tileTag = 1001, - .paletteTag = 1001, - .oam = &gUnknown_085E703C, - .anims = gUnknown_085E705C, + .tileTag = TAG_MON_BG, + .paletteTag = TAG_MON_BG, + .oam = &sOamData_MonBg, + .anims = sAnims_MonBg, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_81772B8, + .callback = SpriteCB_CreditsMonBg, }; -static void Task_WaitPaletteFade(u8 taskIdA); -static void Task_ProgressCreditTasks(u8 taskIdA); -static void sub_8175808(u8 taskIdA); -static void c2_080C9BFC(u8 taskIdA); -static void Task_CreditsLoadGrassScene(u8 taskIdA); -static void sub_81758A4(u8 taskIdA); -static void Task_CreditsTheEnd1(u8 taskIdA); -static void Task_CreditsTheEnd2(u8 taskIdA); -static void Task_CreditsTheEnd3(u8 taskIdA); -static void Task_CreditsTheEnd4(u8 taskIdA); -static void Task_CreditsTheEnd5(u8 taskIdA); -static void Task_CreditsTheEnd6(u8 taskIdA); -static void Task_CreditsSoftReset(u8 taskIdA); -static void ResetGpuAndVram(void); -static void sub_8175DA0(u8 taskIdB); -static u8 CheckChangeScene(u8 page, u8 taskIdA); -static void sub_81760FC(u8 taskIdA); -static void sub_817651C(u8 taskIdA); -static void sub_817624C(u8 taskIdA); -static bool8 sub_8176AB0(u8 data, u8 taskIdA); -static void ResetCreditsTasks(u8 taskIdA); -static void LoadTheEndScreen(u16, u16, u16); -static void sub_8176E40(u16 arg0, u16 palette); -static void sub_8176EE8(struct Sprite *sprite); -static void sub_8176F90(struct Sprite *sprite); -static u8 MakeMonSprite(u16 species, s16 x, s16 y, u16 position); -static void DeterminePokemonToShow(void); - -static void CreditsVBlankCallback(void) +static void VBlankCB_Credits(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -static void CB2_RunCreditsSequence(void) +static void CB2_Credits(void) { RunTasks(); AnimateSprites(); if ((JOY_HELD(B_BUTTON)) - && gHasHallOfFameRecords != 0 - && gTasks[gUnknown_0203BCE2].func == Task_ProgressCreditTasks) + && gHasHallOfFameRecords + && gTasks[sSavedTaskId].func == Task_ProgressCreditTasks) { - CreditsVBlankCallback(); + // Speed up credits + VBlankCB_Credits(); RunTasks(); AnimateSprites(); - gUnknown_0203BCE5 = 1; + sUsedSpeedUp = TRUE; } BuildOamBuffer(); UpdatePaletteFade(); @@ -1160,7 +382,7 @@ static void InitCreditsBgsAndWindows(void) ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBackgroundTemplates, ARRAY_COUNT(sBackgroundTemplates)); SetBgTilemapBuffer(0, AllocZeroed(BG_SCREEN_SIZE)); - LoadPalette(gUnknown_085E56F0, 0x80, 0x40); + LoadPalette(sCredits_Pal, 0x80, 64); InitWindows(sWindowTemplates); DeactivateAllTextPrinters(); PutWindowTilemap(0); @@ -1182,20 +404,20 @@ static void PrintCreditsText(const u8 *string, u8 y, bool8 isTitle) u8 x; u8 color[3]; - color[0] = 0; + color[0] = TEXT_COLOR_TRANSPARENT; if (isTitle == TRUE) { - color[1] = 3; - color[2] = 4; + color[1] = TEXT_COLOR_LIGHT_GREY; + color[2] = TEXT_COLOR_RED; } else { - color[1] = 1; - color[2] = 2; + color[1] = TEXT_COLOR_WHITE; + color[2] = TEXT_COLOR_DARK_GREY; } - x = GetStringCenterAlignXOffsetWithLetterSpacing(1, string, 0xF0, 1); + x = GetStringCenterAlignXOffsetWithLetterSpacing(1, string, DISPLAY_WIDTH, 1); AddTextPrinterParameterized4(0, 1, x, y, 1, 0, color, -1, string); } @@ -1237,19 +459,19 @@ void CB2_StartCreditsSequence(void) BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); EnableInterrupts(INTR_FLAG_VBLANK); - SetVBlankCallback(CreditsVBlankCallback); + SetVBlankCallback(VBlankCB_Credits); m4aSongNumStart(MUS_CREDITS); - SetMainCallback2(CB2_RunCreditsSequence); - gUnknown_0203BCE5 = 0; + SetMainCallback2(CB2_Credits); + sUsedSpeedUp = FALSE; sCreditsData = AllocZeroed(sizeof(struct CreditsData)); DeterminePokemonToShow(); sCreditsData->imgCounter = 0; - sCreditsData->nextImgPos = 0; + sCreditsData->nextImgPos = POS_LEFT; sCreditsData->currShownMon = 0; - gUnknown_0203BCE2 = taskIdA; + sSavedTaskId = taskIdA; } static void Task_WaitPaletteFade(u8 taskIdA) @@ -1274,7 +496,7 @@ static void Task_ProgressCreditTasks(u8 taskIdA) return; } - gUnknown_0203BCE0 = 0; + sUnkVar = 0; data1 = gTasks[taskIdA].data[TDA_11]; if (gTasks[taskIdA].data[TDA_11] == 1) @@ -1311,7 +533,7 @@ static void c2_080C9BFC(u8 taskIdA) { BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); EnableInterrupts(INTR_FLAG_VBLANK); - SetVBlankCallback(CreditsVBlankCallback); + SetVBlankCallback(VBlankCB_Credits); gTasks[taskIdA].func = Task_WaitPaletteFade; } } @@ -1349,18 +571,18 @@ static void Task_CreditsLoadGrassScene(u8 taskIdA) for (i = 0; i < 0x800; i++) (gDecompressionBuffer + 0x800)[i] = 0x22; for (i = 0; i < 0x800; i++) - (gDecompressionBuffer + 0x1000)[i] = 0x33; + (gDecompressionBuffer + 0x800 * 2)[i] = 0x33; - temp = (u16 *)(&gDecompressionBuffer[0x1800]); + temp = (u16 *)(&gDecompressionBuffer[MONBG_OFFSET]); temp[0] = RGB_BLACK; temp[1] = RGB(31, 31, 20); // light yellow temp[2] = RGB(31, 20, 20); // light red temp[3] = RGB(20, 20, 31); // light blue - LoadSpriteSheet(gUnknown_085E701C); - LoadSpritePalette(gUnknown_085E702C); + LoadSpriteSheet(sSpriteSheet_MonBg); + LoadSpritePalette(sSpritePalette_MonBg); - gMain.state += 1; + gMain.state++; break; } case 1: @@ -1384,7 +606,7 @@ static void Task_CreditsLoadGrassScene(u8 taskIdA) | DISPCNT_OBJ_ON); gMain.state = 0; - gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_MOVING; + gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_NORMAL; gTasks[taskIdA].func = Task_WaitPaletteFade; break; } @@ -1394,7 +616,7 @@ static void Task_CreditsTheEnd1(u8 taskIdA) { if (gTasks[taskIdA].data[TDA_12]) { - gTasks[taskIdA].data[TDA_12] -= 1; + gTasks[taskIdA].data[TDA_12]--; return; } @@ -1411,6 +633,8 @@ static void Task_CreditsTheEnd2(u8 taskIdA) } } +#define tDelay data[0] + static void Task_CreditsTheEnd3(u8 taskIdA) { ResetGpuAndVram(); @@ -1430,15 +654,15 @@ static void Task_CreditsTheEnd3(u8 taskIdA) | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON); - gTasks[taskIdA].data[TDA_0] = 235; //set this to 215 to actually show "THE END" in time to the last song beat + gTasks[taskIdA].tDelay = 235; //set this to 215 to actually show "THE END" in time to the last song beat gTasks[taskIdA].func = Task_CreditsTheEnd4; } static void Task_CreditsTheEnd4(u8 taskIdA) { - if (gTasks[taskIdA].data[TDA_0]) + if (gTasks[taskIdA].tDelay) { - gTasks[taskIdA].data[TDA_0] -= 1; + gTasks[taskIdA].tDelay--; return; } @@ -1450,10 +674,10 @@ static void Task_CreditsTheEnd5(u8 taskIdA) { if (!gPaletteFade.active) { - sub_8176E40(0x3800, 0); + DrawTheEnd(0x3800, 0); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0, RGB_BLACK); - gTasks[taskIdA].data[TDA_0] = 7200; + gTasks[taskIdA].tDelay = 7200; gTasks[taskIdA].func = Task_CreditsTheEnd6; } } @@ -1462,7 +686,7 @@ static void Task_CreditsTheEnd6(u8 taskIdA) { if (!gPaletteFade.active) { - if (gTasks[taskIdA].data[TDA_0] == 0 || gMain.newKeys) + if (gTasks[taskIdA].tDelay == 0 || gMain.newKeys) { FadeOutBGM(4); BeginNormalPaletteFade(PALETTES_ALL, 8, 0, 16, RGB_WHITEALPHA); @@ -1470,20 +694,22 @@ static void Task_CreditsTheEnd6(u8 taskIdA) return; } - if (gTasks[taskIdA].data[TDA_0] == 7144) + if (gTasks[taskIdA].tDelay == 7144) FadeOutBGM(8); - if (gTasks[taskIdA].data[TDA_0] == 6840) + if (gTasks[taskIdA].tDelay == 6840) m4aSongNumStart(MUS_END); - gTasks[taskIdA].data[TDA_0] -= 1; + gTasks[taskIdA].tDelay--; } } +#undef tDelay + static void Task_CreditsSoftReset(u8 taskIdA) { if (!gPaletteFade.active) - SoftReset(0xFF); + SoftReset(RESET_ALL); } static void ResetGpuAndVram(void) @@ -1525,32 +751,32 @@ static void sub_8175DA0(u8 taskIdB) gTasks[taskIdB].data[TDB_0] = 1; gTasks[taskIdB].data[TDB_3] = 0x48; gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 0; - gUnknown_0203BCE0 = 0; + sUnkVar = 0; } return; case 1: if (gTasks[taskIdB].data[TDB_3] != 0) { - gTasks[taskIdB].data[TDB_3] -= 1; + gTasks[taskIdB].data[TDB_3]--; return; } - gTasks[taskIdB].data[TDB_0] += 1; + gTasks[taskIdB].data[TDB_0]++; return; case 2: if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].func == Task_ProgressCreditTasks) { if (gTasks[taskIdB].data[TDB_CURRENT_PAGE] < PAGE_COUNT) { - for (i = 0; i < 5; i++) + for (i = 0; i < ENTRIES_PER_PAGE; i++) PrintCreditsText( - gCreditsEntryPointerTable[gTasks[taskIdB].data[TDB_CURRENT_PAGE]][i]->text, + sCreditsEntryPointerTable[gTasks[taskIdB].data[TDB_CURRENT_PAGE]][i]->text, 5 + i * 16, - gCreditsEntryPointerTable[gTasks[taskIdB].data[TDB_CURRENT_PAGE]][i]->isTitle); + sCreditsEntryPointerTable[gTasks[taskIdB].data[TDB_CURRENT_PAGE]][i]->isTitle); CopyWindowToVram(0, 2); - gTasks[taskIdB].data[TDB_CURRENT_PAGE] += 1; - gTasks[taskIdB].data[TDB_0] += 1; + gTasks[taskIdB].data[TDB_CURRENT_PAGE]++; + gTasks[taskIdB].data[TDB_0]++; gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 1; @@ -1569,22 +795,22 @@ static void sub_8175DA0(u8 taskIdB) if (!gPaletteFade.active) { gTasks[taskIdB].data[TDB_3] = 0x73; - gTasks[taskIdB].data[TDB_0] += 1; + gTasks[taskIdB].data[TDB_0]++; } return; case 4: if (gTasks[taskIdB].data[TDB_3] != 0) { - gTasks[taskIdB].data[TDB_3] -= 1; + gTasks[taskIdB].data[TDB_3]--; return; } if (CheckChangeScene((u8)gTasks[taskIdB].data[TDB_CURRENT_PAGE], (u8)gTasks[taskIdB].data[TDB_TASK_A_ID])) { - gTasks[taskIdB].data[TDB_0] += 1; + gTasks[taskIdB].data[TDB_0]++; return; } - gTasks[taskIdB].data[TDB_0] += 1; + gTasks[taskIdB].data[TDB_0]++; if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_13] == 1) BeginNormalPaletteFade(0x00000300, 0, 0, 16, COLOR_LIGHT_GREEN); else @@ -1613,7 +839,7 @@ static u8 CheckChangeScene(u8 page, u8 taskIdA) if (page == 6) { - // Grass patch + // Pokémon interlude gTasks[taskIdA].data[TDA_11] = 2; } @@ -1626,7 +852,7 @@ static u8 CheckChangeScene(u8 page, u8 taskIdA) if (page == 18) { - // Grass patch + // Pokémon interlude gTasks[taskIdA].data[TDA_11] = 2; } @@ -1639,7 +865,7 @@ static u8 CheckChangeScene(u8 page, u8 taskIdA) if (page == 30) { - // Grass patch + // Pokémon interlude gTasks[taskIdA].data[TDA_11] = 2; } @@ -1652,7 +878,7 @@ static u8 CheckChangeScene(u8 page, u8 taskIdA) if (page == 42) { - // Grass patch + // Pokémon interlude gTasks[taskIdA].data[TDA_11] = 2; } @@ -1681,14 +907,17 @@ static void sub_81760FC(u8 taskIdD) case 0: break; case 1: - if (sCreditsData->nextImgPos == 0 && gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] == 0) + if (sCreditsData->nextImgPos == POS_LEFT && gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] == 0) break; gTasks[taskIdD].data[TDD_STATE]++; break; case 2: if (sCreditsData->imgCounter == NUM_MON_SLIDES || gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].func != Task_ProgressCreditTasks) break; - r2 = MakeMonSprite(sCreditsData->monToShow[sCreditsData->currShownMon], sMonSpritePos[sCreditsData->nextImgPos][0], sMonSpritePos[sCreditsData->nextImgPos][1], sCreditsData->nextImgPos); + r2 = CreateCreditsMonSprite(sCreditsData->monToShow[sCreditsData->currShownMon], + sMonSpritePos[sCreditsData->nextImgPos][0], + sMonSpritePos[sCreditsData->nextImgPos][1], + sCreditsData->nextImgPos); if (sCreditsData->currShownMon < sCreditsData->numMonToShow - 1) { sCreditsData->currShownMon++; @@ -1700,10 +929,12 @@ static void sub_81760FC(u8 taskIdD) gSprites[r2].data[3] = 512; } sCreditsData->imgCounter++; - if (sCreditsData->nextImgPos == 2) - sCreditsData->nextImgPos = 0; + + if (sCreditsData->nextImgPos == POS_RIGHT) + sCreditsData->nextImgPos = POS_LEFT; else sCreditsData->nextImgPos++; + gTasks[taskIdD].data[TDD_3] = 50; gTasks[taskIdD].data[TDD_STATE]++; break; @@ -1846,7 +1077,7 @@ static void sub_817651C(u8 taskIdE) } else { - gTasks[taskIdE].data[TDE_1] += 1; + gTasks[taskIdE].data[TDE_1]++; } } CycleSceneryPalette(1); @@ -1857,63 +1088,63 @@ static void sub_817651C(u8 taskIdE) } } -static void sub_817664C(u8 scene, u8 taskIdA) +static void InitCreditsSceneGfx(u8 scene, u8 taskIdA) { switch (scene) { case 0: - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 272; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = 272; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; - 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; + gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 272; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = 272; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(0, 0x2000, 0x20, 8); break; case 1: - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 120; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = 272; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; - 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; + gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 120; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = 272; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(0, 0x2000, 0x20, 8); break; case 2: - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 120; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = 272; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; - 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; + gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 120; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = 272; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(1, 0x2000, 0x200, 8); break; case 3: - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 120; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = -32; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; - 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; + gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 120; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = -32; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(1, 0x2000, 0x200, 8); break; case 4: - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].invisible = FALSE; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.x = 88; - gSprites[gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]].pos1.x = 152; - gSprites[gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]].pos1.y = 46; - 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; + gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 88; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = 152; + gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(2, 0x2000, 0x200, 8); break; } @@ -1926,8 +1157,8 @@ static void sub_817664C(u8 scene, u8 taskIdA) gTasks[taskIdA].data[TDA_TASK_C_ID] = CreateTask(sub_817624C, 0); gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_0] = 0; gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_1] = taskIdA; - gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_2] = gTasks[taskIdA].data[TDA_PLAYER_CYCLIST]; - gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_3] = gTasks[taskIdA].data[TDA_RIVAL_CYCLIST]; + gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_2] = gTasks[taskIdA].tPlayerSpriteId; + gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_3] = gTasks[taskIdA].tRivalSpriteId; gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_4] = 0; if (scene == 2) @@ -1959,7 +1190,7 @@ static bool8 sub_8176AB0(u8 scene, u8 taskIdA) gIntroCredits_MovingSceneryVBase = 34; gIntroCredits_MovingSceneryVOffset = 0; LoadCreditsSceneGraphics(scene); - gMain.state += 1; + gMain.state++; break; case 2: if (gSaveBlock2Ptr->playerGender == MALE) @@ -1970,14 +1201,14 @@ static bool8 sub_8176AB0(u8 scene, u8 taskIdA) LoadSpritePalettes(gSpritePalettes_Credits); spriteId = CreateIntroBrendanSprite(120, 46); - gTasks[taskIdA].data[TDA_PLAYER_CYCLIST] = spriteId; - gSprites[spriteId].callback = sub_8176EE8; - gSprites[spriteId].anims = gUnknown_085E6FD0; + gTasks[taskIdA].tPlayerSpriteId = spriteId; + gSprites[spriteId].callback = SpriteCB_PlayerCyclist; + gSprites[spriteId].anims = sAnims_Player; spriteId = CreateIntroMaySprite(272, 46); - gTasks[taskIdA].data[TDA_RIVAL_CYCLIST] = spriteId; - gSprites[spriteId].callback = sub_8176F90; - gSprites[spriteId].anims = gUnknown_085E7010; + gTasks[taskIdA].tRivalSpriteId = spriteId; + gSprites[spriteId].callback = SpriteCB_RivalCyclist; + gSprites[spriteId].anims = sAnims_Rival; } else { @@ -1987,19 +1218,19 @@ static bool8 sub_8176AB0(u8 scene, u8 taskIdA) LoadSpritePalettes(gSpritePalettes_Credits); spriteId = CreateIntroMaySprite(120, 46); - gTasks[taskIdA].data[TDA_PLAYER_CYCLIST] = spriteId; - gSprites[spriteId].callback = sub_8176EE8; - gSprites[spriteId].anims = gUnknown_085E6FD0; + gTasks[taskIdA].tPlayerSpriteId = spriteId; + gSprites[spriteId].callback = SpriteCB_PlayerCyclist; + gSprites[spriteId].anims = sAnims_Player; spriteId = CreateIntroBrendanSprite(272, 46); - gTasks[taskIdA].data[TDA_RIVAL_CYCLIST] = spriteId; - gSprites[spriteId].callback = sub_8176F90; - gSprites[spriteId].anims = gUnknown_085E7010; + gTasks[taskIdA].tRivalSpriteId = spriteId; + gSprites[spriteId].callback = SpriteCB_RivalCyclist; + gSprites[spriteId].anims = sAnims_Rival; }; - gMain.state += 1; + gMain.state++; break; case 3: - sub_817664C(scene, taskIdA); + InitCreditsSceneGfx(scene, taskIdA); SetCreditsSceneBgCnt(scene); gMain.state = 0; return TRUE; @@ -2036,21 +1267,21 @@ static void ResetCreditsTasks(u8 taskIdA) gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_DESTROY; } -static void LoadTheEndScreen(u16 arg0, u16 arg1, u16 arg2) +static void LoadTheEndScreen(u16 arg0, u16 arg1, u16 palOffset) { u16 baseTile; u16 i; LZ77UnCompVram(sCreditsCopyrightEnd_Gfx, (void *)(VRAM + arg0)); - LoadPalette(gIntroCopyright_Pal, arg2, sizeof(gIntroCopyright_Pal)); + LoadPalette(gIntroCopyright_Pal, palOffset, sizeof(gIntroCopyright_Pal)); - baseTile = (arg2 / 16) << 12; + baseTile = (palOffset / 16) << 12; for (i = 0; i < 32 * 32; i++) ((u16 *) (VRAM + arg1))[i] = baseTile + 1; } -static u16 sub_8176D78(u8 baseTiles) +static u16 GetLetterMapTile(u8 baseTiles) { u16 out = (baseTiles & 0x3F) + 80; @@ -2065,7 +1296,7 @@ static u16 sub_8176D78(u8 baseTiles) return out; } -static void sub_8176DBC(const u8 baseTiles[], u8 baseX, u8 baseY, u16 arg3, u16 palette) +static void DrawLetterMapTiles(const u8 baseTiles[], u8 baseX, u8 baseY, u16 offset, u16 palette) { u8 y, x; const u16 tileOffset = (palette / 16) << 12; @@ -2073,35 +1304,37 @@ static void sub_8176DBC(const u8 baseTiles[], u8 baseX, u8 baseY, u16 arg3, u16 for (y = 0; y < 5; y++) { for (x = 0; x < 3; x++) - ((u16 *) (VRAM + arg3 + (baseY + y) * 64))[baseX + x] = tileOffset + sub_8176D78(baseTiles[y * 3 + x]); + ((u16 *) (VRAM + offset + (baseY + y) * 64))[baseX + x] = tileOffset + GetLetterMapTile(baseTiles[y * 3 + x]); } } -static void sub_8176E40(u16 arg0, u16 palette) +static void DrawTheEnd(u16 offset, u16 palette) { u16 pos; u16 baseTile = (palette / 16) << 12; for (pos = 0; pos < 32 * 32; pos++) - ((u16 *) (VRAM + arg0))[pos] = baseTile + 1; + ((u16 *) (VRAM + offset))[pos] = baseTile + 1; - sub_8176DBC(sTheEnd_LetterTMap, 3, 7, arg0, palette); - sub_8176DBC(sTheEnd_LetterHMap, 7, 7, arg0, palette); - sub_8176DBC(sTheEnd_LetterEMap, 11, 7, arg0, palette); - sub_8176DBC(sTheEnd_LetterEMap, 16, 7, arg0, palette); - sub_8176DBC(sTheEnd_LetterNMap, 20, 7, arg0, palette); - sub_8176DBC(sTheEnd_LetterDMap, 24, 7, arg0, palette); + DrawLetterMapTiles(sTheEnd_LetterMap_T, 3, 7, offset, palette); + DrawLetterMapTiles(sTheEnd_LetterMap_H, 7, 7, offset, palette); + DrawLetterMapTiles(sTheEnd_LetterMap_E, 11, 7, offset, palette); + DrawLetterMapTiles(sTheEnd_LetterMap_E, 16, 7, offset, palette); + DrawLetterMapTiles(sTheEnd_LetterMap_N, 20, 7, offset, palette); + DrawLetterMapTiles(sTheEnd_LetterMap_D, 24, 7, offset, palette); } -static void sub_8176EE8(struct Sprite *sprite) +#define sState data[0] + +static void SpriteCB_PlayerCyclist(struct Sprite *sprite) { - if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_MOVING) + if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_NORMAL) { DestroySprite(sprite); return; } - switch (sprite->data[0]) + switch (sprite->sState) { case 0: StartSpriteAnimIfDifferent(sprite, 0); @@ -2109,7 +1342,7 @@ static void sub_8176EE8(struct Sprite *sprite) case 1: StartSpriteAnimIfDifferent(sprite, 1); if (sprite->pos1.x > -32) - sprite->pos1.x -= 1; + sprite->pos1.x--; break; case 2: StartSpriteAnimIfDifferent(sprite, 2); @@ -2120,25 +1353,25 @@ static void sub_8176EE8(struct Sprite *sprite) case 4: StartSpriteAnimIfDifferent(sprite, 0); if (sprite->pos1.x > 120) - sprite->pos1.x -= 1; + sprite->pos1.x--; break; case 5: StartSpriteAnimIfDifferent(sprite, 0); if (sprite->pos1.x > -32) - sprite->pos1.x -= 1; + sprite->pos1.x--; break; } } -static void sub_8176F90(struct Sprite *sprite) +static void SpriteCB_RivalCyclist(struct Sprite *sprite) { - if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_MOVING) + if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_NORMAL) { DestroySprite(sprite); return; } - switch (sprite->data[0]) + switch (sprite->sState) { case 0: sprite->pos2.y = 0; @@ -2154,29 +1387,32 @@ static void sub_8176F90(struct Sprite *sprite) sprite->pos2.y = -gIntroCredits_MovingSceneryVOffset; break; case 2: - sprite->data[7] += 1; + sprite->data[7]++; StartSpriteAnimIfDifferent(sprite, 0); if ((sprite->data[7] & 3) == 0) - sprite->pos1.x += 1; + sprite->pos1.x++; break; case 3: StartSpriteAnimIfDifferent(sprite, 0); if (sprite->pos1.x > -32) - sprite->pos1.x -= 1; + sprite->pos1.x--; break; } } -static void sub_8177050(struct Sprite *sprite) +#define sPosition data[1] +#define sSpriteId data[6] + +static void SpriteCB_CreditsMon(struct Sprite *sprite) { - if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_MOVING) + if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_NORMAL) { - FreeAndDestroyMonPicSprite(sprite->data[6]); + FreeAndDestroyMonPicSprite(sprite->sSpriteId); return; } - sprite->data[7] += 1; - switch (sprite->data[0]) + sprite->data[7]++; + switch (sprite->sState) { case 0: default: @@ -2185,7 +1421,7 @@ static void sub_8177050(struct Sprite *sprite) sprite->data[2] = 16; SetOamMatrix(sprite->data[1], 0x10000 / sprite->data[2], 0, 0, 0x10000 / sprite->data[2]); sprite->invisible = FALSE; - sprite->data[0] = 1; + sprite->sState = 1; break; case 1: if (sprite->data[2] < 256) @@ -2195,20 +1431,20 @@ static void sub_8177050(struct Sprite *sprite) } else { - sprite->data[0] += 1; + sprite->sState++; } - switch (sprite->data[1]) + switch (sprite->sPosition) { - case 1: + case POS_LEFT + 1: if ((sprite->data[7] & 3) == 0) - sprite->pos1.y += 1; + sprite->pos1.y++; sprite->pos1.x -= 2; break; - case 2: + case POS_CENTER + 1: break; - case 3: + case POS_RIGHT + 1: if ((sprite->data[7] & 3) == 0) - sprite->pos1.y += 1; + sprite->pos1.y++; sprite->pos1.x += 2; break; } @@ -2216,7 +1452,7 @@ static void sub_8177050(struct Sprite *sprite) case 2: if (sprite->data[3] != 0) { - sprite->data[3] -= 1; + sprite->data[3]--; } else { @@ -2224,7 +1460,7 @@ static void sub_8177050(struct Sprite *sprite) SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); sprite->oam.objMode = ST_OAM_OBJ_BLEND; sprite->data[3] = 16; - sprite->data[0] += 1; + sprite->sState++; } break; case 3: @@ -2232,7 +1468,7 @@ static void sub_8177050(struct Sprite *sprite) { int data3; - sprite->data[3] -= 1; + sprite->data[3]--; data3 = 16 - sprite->data[3]; SetGpuReg(REG_OFFSET_BLDALPHA, (data3 << 8) + sprite->data[3]); @@ -2240,11 +1476,11 @@ static void sub_8177050(struct Sprite *sprite) else { sprite->invisible = TRUE; - sprite->data[0] = 9; + sprite->sState = 9; } break; case 9: - sprite->data[0] += 1; + sprite->sState++; break; case 10: SetGpuReg(REG_OFFSET_BLDCNT, 0); @@ -2254,40 +1490,44 @@ static void sub_8177050(struct Sprite *sprite) } } -static u8 MakeMonSprite(u16 nationalDexNum, s16 x, s16 y, u16 position) +#define sMonSpriteId data[0] + +static u8 CreateCreditsMonSprite(u16 nationalDexNum, s16 x, s16 y, u16 position) { - u8 spriteId; - u8 spriteId2; + u8 monSpriteId; + u8 bgSpriteId; - spriteId = CreateMonSpriteFromNationalDexNumber(nationalDexNum, x, y, position); - gSprites[spriteId].oam.priority = 1; - gSprites[spriteId].data[1] = position + 1; - gSprites[spriteId].invisible = TRUE; - gSprites[spriteId].callback = sub_8177050; - gSprites[spriteId].data[6] = spriteId; + monSpriteId = CreateMonSpriteFromNationalDexNumber(nationalDexNum, x, y, position); + gSprites[monSpriteId].oam.priority = 1; + gSprites[monSpriteId].sPosition = position + 1; + gSprites[monSpriteId].invisible = TRUE; + gSprites[monSpriteId].callback = SpriteCB_CreditsMon; + gSprites[monSpriteId].sSpriteId = monSpriteId; - spriteId2 = CreateSprite(&gUnknown_085E7068, gSprites[spriteId].pos1.x, gSprites[spriteId].pos1.y, 1); - gSprites[spriteId2].data[0] = spriteId; + bgSpriteId = CreateSprite(&sSpriteTemplate_CreditsMonBg, gSprites[monSpriteId].pos1.x, gSprites[monSpriteId].pos1.y, 1); + gSprites[bgSpriteId].sMonSpriteId = monSpriteId; - StartSpriteAnimIfDifferent(&gSprites[spriteId2], position); + StartSpriteAnimIfDifferent(&gSprites[bgSpriteId], position); - return spriteId; + return monSpriteId; } -static void sub_81772B8(struct Sprite *sprite) +static void SpriteCB_CreditsMonBg(struct Sprite *sprite) { - if (gSprites[sprite->data[0]].data[0] == 10 || gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_MOVING) + if (gSprites[sprite->sMonSpriteId].data[0] == 10 + || gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_NORMAL) { DestroySprite(sprite); return; } - sprite->invisible = gSprites[sprite->data[0]].invisible; - sprite->oam.objMode = gSprites[sprite->data[0]].oam.objMode; - sprite->oam.affineMode = gSprites[sprite->data[0]].oam.affineMode; - sprite->oam.matrixNum = gSprites[sprite->data[0]].oam.matrixNum; - sprite->pos1.x = gSprites[sprite->data[0]].pos1.x; - sprite->pos1.y = gSprites[sprite->data[0]].pos1.y; + // Copy sprite data from the associated Pokémon + sprite->invisible = gSprites[sprite->sMonSpriteId].invisible; + sprite->oam.objMode = gSprites[sprite->sMonSpriteId].oam.objMode; + sprite->oam.affineMode = gSprites[sprite->sMonSpriteId].oam.affineMode; + sprite->oam.matrixNum = gSprites[sprite->sMonSpriteId].oam.matrixNum; + sprite->pos1.x = gSprites[sprite->sMonSpriteId].pos1.x; + sprite->pos1.y = gSprites[sprite->sMonSpriteId].pos1.y; } static void DeterminePokemonToShow(void) diff --git a/src/data/credits.h b/src/data/credits.h new file mode 100644 index 0000000000..3ae2b1d3be --- /dev/null +++ b/src/data/credits.h @@ -0,0 +1,787 @@ +enum +{ + PAGE_TITLE, + PAGE_DIRECTOR, + PAGE_ART_DIRECTOR, + PAGE_WORLD_DIRECTOR, + PAGE_LEAD_PROGRAMMER, + PAGE_PROGRAMMERS_1, + PAGE_PROGRAMMERS_2, + PAGE_PROGRAMMERS_3, + PAGE_PROGRAMMERS_4, + PAGE_GRAPHIC_DESIGNERS_1, + PAGE_GRAPHIC_DESIGNERS_2, + PAGE_GRAPHIC_DESIGNERS_3, + PAGE_MUSIC_COMPOSITION, + PAGE_SOUND_EFFECTS, + PAGE_GAME_DESIGNERS_1, + PAGE_GAME_DESIGNERS_2, + PAGE_GAME_DESIGNERS_3, + PAGE_SCENARIO_PLOT, + PAGE_SCENARIO, + PAGE_SCRIPT_DESIGNERS, + PAGE_MAP_DESIGNERS, + PAGE_BATTLE_FRONTIER_DATA, + PAGE_PARAMETRIC_DESIGNERS, + PAGE_POKEDEX_TEXT, + PAGE_ENVIRONMENT_AND_TOOL_PROGRAMS_1, + PAGE_PKMN_DESIGNERS_1, + PAGE_PKMN_DESIGNERS_2, + PAGE_PKMN_DESIGNERS_3, + PAGE_PKMN_DESIGNERS_4, + PAGE_SUPPORT_PROGRAMMERS, + PAGE_NCL_PRODUCT_TESTING, + PAGE_PACKAGE_AND_MANUAL, + PAGE_SPECIAL_THANKS_1, + PAGE_SPECIAL_THANKS_2, + PAGE_SPECIAL_THANKS_3, + PAGE_SPECIAL_THANKS_4, + PAGE_INFORMATION_SUPERVISORS, + PAGE_ARTWORK_1, + PAGE_ARTWORK_2, + PAGE_ARTWORK_3, + PAGE_COORDINATORS, + PAGE_ENGLISH_VERSION, + PAGE_TRANSLATOR, + PAGE_TEXT_EDITOR, + PAGE_NCL_COORDINATOR, + PAGE_PROGRAMMERS_5, + PAGE_GRAPHIC_DESIGNER, + PAGE_ENVIRONMENT_AND_TOOL_PROGRAMS_2, + PAGE_NOA_TESTING, + PAGE_BRAILLE_CODE_CHECK_1, + PAGE_BRAILLE_CODE_CHECK_2, + PAGE_SPECIAL_THANKS_5, + PAGE_TASK_MANAGERS, + PAGE_PRODUCERS, + PAGE_EXECUTIVE_DIRECTOR, + PAGE_EXECUTIVE_PRODUCERS_1, + PAGE_EXECUTIVE_PRODUCERS_2, + PAGE_COUNT +}; + +#define ENTRIES_PER_PAGE 5 + +static const u8 sCreditsText_EmptyString[] = _(""); +static const u8 sCreditsText_PkmnEmeraldVersion[] = _("POKéMON EMERALD VERSION"); +static const u8 sCreditsText_Credits[] = _("Credits"); +static const u8 sCreditsText_ExecutiveDirector[] = _("Executive Director"); +static const u8 sCreditsText_Director[] = _("Director"); +static const u8 sCreditsText_ArtDirector[] = _("Art Director"); +static const u8 sCreditsText_BattleDirector[] = _("Battle Director"); +static const u8 sCreditsText_MainProgrammer[] = _("Main Programmer"); +static const u8 sCreditsText_BattleSystemPgrms[] = _("Battle System Programmers"); +static const u8 sCreditsText_FieldSystemPgrms[] = _("Field System Programmer"); +static const u8 sCreditsText_Programmers[] = _("Programmers"); +static const u8 sCreditsText_MainGraphicDesigner[] = _("Main Graphic Designer"); +static const u8 sCreditsText_GraphicDesigners[] = _("Graphic Designers"); +static const u8 sCreditsText_PkmnDesigners[] = _("POKéMON Designers"); +static const u8 sCreditsText_MusicComposition[] = _("Music Composition"); +static const u8 sCreditsText_SoundEffectsAndPkmnVoices[] = _("Sound Effects & POKéMON Voices"); +static const u8 sCreditsText_GameDesigners[] = _("Game Designers"); +static const u8 sCreditsText_ScenarioPlot[] = _("Scenario Plot"); +static const u8 sCreditsText_Scenario[] = _("Scenario"); +static const u8 sCreditsText_ScriptDesigners[] = _("Script Designers"); +static const u8 sCreditsText_MapDesigners[] = _("Map Designers"); +static const u8 sCreditsText_MapDataDesigners[] = _("Map Data Designers"); +static const u8 sCreditsText_ParametricDesigners[] = _("Parametric Designers"); +static const u8 sCreditsText_PokedexText[] = _("POKéDEX Text"); +static const u8 sCreditsText_EnvAndToolPgrms[] = _("Environment & Tool Programmers"); +static const u8 sCreditsText_NCLProductTesting[] = _("NCL Product Testing"); +static const u8 sCreditsText_SpecialThanks[] = _("Special Thanks"); +static const u8 sCreditsText_Coordinators[] = _("Coordinators"); +static const u8 sCreditsText_Producers[] = _("Producers"); +static const u8 sCreditsText_ExecProducers[] = _("Executive Producers"); +static const u8 sCreditsText_InfoSupervisors[] = _("Information Supervisors"); +static const u8 sCreditsText_TaskManagers[] = _("Task Managers"); +static const u8 sCreditsText_BrailleCodeCheck[] = _("Braille Code Check"); +static const u8 sCreditsText_WorldDirector[] = _("World Director"); +static const u8 sCreditsText_BattleFrontierData[] = _("Battle Frontier Data"); +static const u8 sCreditsText_SupportProgrammers[] = _("Support Programmers"); +static const u8 sCreditsText_Artwork[] = _("Artwork"); +static const u8 sCreditsText_LeadProgrammer[] = _("Lead Programmer"); +static const u8 sCreditsText_LeadGraphicArtist[] = _("Lead Graphic Artist"); +static const u8 sCreditsText_SatoshiTajiri[] = _("Satoshi Tajiri"); +static const u8 sCreditsText_JunichiMasuda[] = _("Junichi Masuda"); +static const u8 sCreditsText_KenSugimori[] = _("Ken Sugimori"); +static const u8 sCreditsText_ShigekiMorimoto[] = _("Shigeki Morimoto"); +static const u8 sCreditsText_TetsuyaWatanabe[] = _("Tetsuya Watanabe"); +static const u8 sCreditsText_HisashiSogabe[] = _("Hisashi Sogabe"); +static const u8 sCreditsText_SosukeTamada[] = _("Sosuke Tamada"); +static const u8 sCreditsText_AkitoMori[] = _("Akito Mori"); +static const u8 sCreditsText_KeitaKagaya[] = _("Keita Kagaya"); +static const u8 sCreditsText_YoshinoriMatsuda[] = _("Yoshinori Matsuda"); +static const u8 sCreditsText_HiroyukiNakamura[] = _("Hiroyuki Nakamura"); +static const u8 sCreditsText_MasaoTaya[] = _("Masao Taya"); +static const u8 sCreditsText_SatoshiNohara[] = _("Satoshi Nohara"); +static const u8 sCreditsText_TomomichiOhta[] = _("Tomomichi Ohta"); +static const u8 sCreditsText_MiyukiIwasawa[] = _("Miyuki Iwasawa"); +static const u8 sCreditsText_TakenoriOhta[] = _("Takenori Ohta"); +static const u8 sCreditsText_HironobuYoshida[] = _("Hironobu Yoshida"); +static const u8 sCreditsText_MotofumiFujiwara[] = _("Motofumi Fujiwara"); +static const u8 sCreditsText_SatoshiOhta[] = _("Satoshi Ohta"); +static const u8 sCreditsText_AsukaIwashita[] = _("Asuka Iwashita"); +static const u8 sCreditsText_AimiTomita[] = _("Aimi Tomita"); +static const u8 sCreditsText_TakaoUnno[] = _("Takao Unno"); +static const u8 sCreditsText_KanakoEo[] = _("Kanako Eo"); +static const u8 sCreditsText_JunOkutani[] = _("Jun Okutani"); +static const u8 sCreditsText_AtsukoNishida[] = _("Atsuko Nishida"); +static const u8 sCreditsText_MuneoSaito[] = _("Muneo Saito"); +static const u8 sCreditsText_RenaYoshikawa[] = _("Rena Yoshikawa"); +static const u8 sCreditsText_GoIchinose[] = _("Go Ichinose"); +static const u8 sCreditsText_MorikazuAoki[] = _("Morikazu Aoki"); +static const u8 sCreditsText_KojiNishino[] = _("Koji Nishino"); +static const u8 sCreditsText_KenjiMatsushima[] = _("Kenji Matsushima"); +static const u8 sCreditsText_TetsujiOhta[] = _("Tetsuji Ohta"); +static const u8 sCreditsText_HitomiSato[] = _("Hitomi Sato"); +static const u8 sCreditsText_TakeshiKawachimaru[] = _("Takeshi Kawachimaru"); +static const u8 sCreditsText_TeruyukiShimoyamada[] = _("Teruyuki Shimoyamada"); +static const u8 sCreditsText_ShigeruOhmori[] = _("Shigeru Ohmori"); +static const u8 sCreditsText_TadashiTakahashi[] = _("Tadashi Takahashi"); +static const u8 sCreditsText_ToshinobuMatsumiya[] = _("Toshinobu Matsumiya"); +static const u8 sCreditsText_AkihitoTomisawa[] = _("Akihito Tomisawa"); +static const u8 sCreditsText_HirokiEnomoto[] = _("Hiroki Enomoto"); +static const u8 sCreditsText_KazuyukiTerada[] = _("Kazuyuki Terada"); +static const u8 sCreditsText_YuriSakurai[] = _("Yuri Sakurai"); +static const u8 sCreditsText_HiromiSagawa[] = _("Hiromi Sagawa"); +static const u8 sCreditsText_KenjiTominaga[] = _("Kenji Tominaga"); +static const u8 sCreditsText_YoshioTajiri[] = _("Yoshio Tajiri"); +static const u8 sCreditsText_TeikoSasaki[] = _("Teiko Sasaki"); +static const u8 sCreditsText_SachikoHamano[] = _("Sachiko Hamano"); +static const u8 sCreditsText_ChieMatsumiya[] = _("Chie Matsumiya"); +static const u8 sCreditsText_AkikoShinozaki[] = _("Akiko Shinozaki"); +static const u8 sCreditsText_AstukoFujii[] = _("Astuko Fujii"); +static const u8 sCreditsText_NozomuSaito[] = _("Nozomu Saito"); +static const u8 sCreditsText_KenkichiToyama[] = _("Kenkichi Toyama"); +static const u8 sCreditsText_SuguruNakatsui[] = _("Suguru Nakatsui"); +static const u8 sCreditsText_YumiFunasaka[] = _("Yumi Funasaka"); +static const u8 sCreditsText_NaokoYanase[] = _("Naoko Yanase"); +static const u8 sCreditsText_NCLSuperMarioClub[] = _("NCL Super Mario Club"); +static const u8 sCreditsText_AtsushiTada[] = _("Atsushi Tada"); +static const u8 sCreditsText_TakahiroOhnishi[] = _("Takahiro Ohnishi"); +static const u8 sCreditsText_NorihideOkamura[] = _("Norihide Okamura"); +static const u8 sCreditsText_HiroNakamura[] = _("Hiro Nakamura"); +static const u8 sCreditsText_HiroyukiUesugi[] = _("Hiroyuki Uesugi"); +static const u8 sCreditsText_TerukiMurakawa[] = _("Teruki Murakawa"); +static const u8 sCreditsText_AkiraKinashi[] = _("Akira Kinashi"); +static const u8 sCreditsText_MichikoTakizawa[] = _("Michiko Takizawa"); +static const u8 sCreditsText_MakikoTakada[] = _("Makiko Takada"); +static const u8 sCreditsText_TakanaoKondo[] = _("Takanao Kondo"); +static const u8 sCreditsText_AiMashima[] = _("Ai Mashima"); +static const u8 sCreditsText_GakujiNomoto[] = _("Gakuji Nomoto"); +static const u8 sCreditsText_TakehiroIzushi[] = _("Takehiro Izushi"); +static const u8 sCreditsText_HitoshiYamagami[] = _("Hitoshi Yamagami"); +static const u8 sCreditsText_KyokoWatanabe[] = _("Kyoko Watanabe"); +static const u8 sCreditsText_TakaoNakano[] = _("Takao Nakano"); +static const u8 sCreditsText_HiroyukiJinnai[] = _("Hiroyuki Jinnai"); +static const u8 sCreditsText_HiroakiTsuru[] = _("Hiroaki Tsuru"); +static const u8 sCreditsText_TsunekazIshihara[] = _("Tsunekaz Ishihara"); +static const u8 sCreditsText_SatoruIwata[] = _("Satoru Iwata"); +static const u8 sCreditsText_KazuyaSuyama[] = _("Kazuya Suyama"); +static const u8 sCreditsText_SatoshiMitsuhara[] = _("Satoshi Mitsuhara"); +static const u8 sCreditsText_JapanBrailleLibrary[] = _("Japan Braille Library"); +static const u8 sCreditsText_TomotakaKomura[] = _("Tomotaka Komura"); +static const u8 sCreditsText_MikikoOhhashi[] = _("Mikiko Ohhashi"); +static const u8 sCreditsText_DaisukeHoshino[] = _("Daisuke Hoshino"); +static const u8 sCreditsText_KenjiroIto[] = _("Kenjiro Ito"); +static const u8 sCreditsText_RuiKawaguchi[] = _("Rui Kawaguchi"); +static const u8 sCreditsText_ShunsukeKohori[] = _("Shunsuke Kohori"); +static const u8 sCreditsText_SachikoNakamichi[] = _("Sachiko Nakamichi"); +static const u8 sCreditsText_FujikoNomura[] = _("Fujiko Nomura"); +static const u8 sCreditsText_KazukiYoshihara[] = _("Kazuki Yoshihara"); +static const u8 sCreditsText_RetsujiNomoto[] = _("Retsuji Nomoto"); +static const u8 sCreditsText_AzusaTajima[] = _("Azusa Tajima"); +static const u8 sCreditsText_ShusakuEgami[] = _("Shusaku Egami"); +static const u8 sCreditsText_PackageAndManual[] = _("Package & Manual Illustration"); +static const u8 sCreditsText_EnglishVersion[] = _("English Version Coordinators"); +static const u8 sCreditsText_Translator[] = _("Translator"); +static const u8 sCreditsText_TextEditor[] = _("Text Editor"); +static const u8 sCreditsText_NCLCoordinator[] = _("NCL Coordinator"); +static const u8 sCreditsText_GraphicDesigner[] = _("Graphic Designer"); +static const u8 sCreditsText_NOAProductTesting[] = _("NOA Product Testing"); +static const u8 sCreditsText_HideyukiNakajima[] = _("Hideyuki Nakajima"); +static const u8 sCreditsText_HidenoriSaeki[] = _("Hidenori Saeki"); +static const u8 sCreditsText_YokoWatanabe[] = _("Yoko Watanabe"); +static const u8 sCreditsText_SakaeKimura[] = _("Sakae Kimura"); +static const u8 sCreditsText_ChiakiShinkai[] = _("Chiaki Shinkai"); +static const u8 sCreditsText_SethMcMahill[] = _("Seth McMahill"); +static const u8 sCreditsText_NobOgasawara[] = _("Nob Ogasawara"); +static const u8 sCreditsText_TeresaLillygren[] = _("Teresa Lillygren"); +static const u8 sCreditsText_KimikoNakamichi[] = _("Kimiko Nakamichi"); +static const u8 sCreditsText_SouichiYamamoto[] = _("Souichi Yamamoto"); +static const u8 sCreditsText_YuichiroIto[] = _("Yuichiro Ito"); +static const u8 sCreditsText_ThomasHertzog[] = _("Thomas Hertzog"); +static const u8 sCreditsText_MikaKurosawa[] = _("Mika Kurosawa"); +static const u8 sCreditsText_NationalFederationBlind[] = _("National Federation of the Blind"); +static const u8 sCreditsText_PatriciaAMaurer[] = _("Patricia A. Maurer"); +static const u8 sCreditsText_EuropeanBlindUnion[] = _("European Blind Union"); +static const u8 sCreditsText_AustralianBrailleAuthority[] = _("Australian Braille Authority"); +static const u8 sCreditsText_RoyalNewZealandFederationBlind[] = _("Royal New Zealand Federation for the Blind"); +static const u8 sCreditsText_MotoyasuTojima[] = _("Motoyasu Tojima"); +static const u8 sCreditsText_NicolaPrattBarlow[] = _("Nicola Pratt-Barlow"); +static const u8 sCreditsText_ShellieDow[] = _("Shellie Dow"); +static const u8 sCreditsText_ErikJohnson[] = _("Erik Johnson"); +static const struct CreditsEntry sCreditsEntry_EmptyString[] = { 0, FALSE, sCreditsText_EmptyString}; +static const struct CreditsEntry sCreditsEntry_PkmnEmeraldVersion[] = { 7, TRUE, sCreditsText_PkmnEmeraldVersion}; +static const struct CreditsEntry sCreditsEntry_Credits[] = {11, TRUE, sCreditsText_Credits}; +static const struct CreditsEntry sCreditsEntry_ExecutiveDirector[] = { 8, TRUE, sCreditsText_ExecutiveDirector}; +static const struct CreditsEntry sCreditsEntry_Director[] = {12, TRUE, sCreditsText_Director}; +static const struct CreditsEntry sCreditsEntry_ArtDirector[] = {10, TRUE, sCreditsText_ArtDirector}; +static const struct CreditsEntry sCreditsEntry_BattleDirector[] = {10, TRUE, sCreditsText_BattleDirector}; +static const struct CreditsEntry sCreditsEntry_MainProgrammer[] = {10, TRUE, sCreditsText_MainProgrammer}; +static const struct CreditsEntry sCreditsEntry_BattleSystemPgrms[] = { 8, TRUE, sCreditsText_BattleSystemPgrms}; +static const struct CreditsEntry sCreditsEntry_FieldSystemPgrms[] = { 7, TRUE, sCreditsText_FieldSystemPgrms}; +static const struct CreditsEntry sCreditsEntry_Programmers[] = {12, TRUE, sCreditsText_Programmers}; +static const struct CreditsEntry sCreditsEntry_MainGraphicDesigner[] = { 7, TRUE, sCreditsText_MainGraphicDesigner}; +static const struct CreditsEntry sCreditsEntry_GraphicDesigners[] = { 9, TRUE, sCreditsText_GraphicDesigners}; +static const struct CreditsEntry sCreditsEntry_PkmnDesigners[] = {10, TRUE, sCreditsText_PkmnDesigners}; +static const struct CreditsEntry sCreditsEntry_MusicComposition[] = {13, TRUE, sCreditsText_MusicComposition}; +static const struct CreditsEntry sCreditsEntry_SoundEffectsAndPkmnVoices[] = { 4, TRUE, sCreditsText_SoundEffectsAndPkmnVoices}; +static const struct CreditsEntry sCreditsEntry_GameDesigners[] = {11, TRUE, sCreditsText_GameDesigners}; +static const struct CreditsEntry sCreditsEntry_ScenarioPlot[] = {11, TRUE, sCreditsText_ScenarioPlot}; +static const struct CreditsEntry sCreditsEntry_Scenario[] = {13, TRUE, sCreditsText_Scenario}; +static const struct CreditsEntry sCreditsEntry_ScriptDesigners[] = {10, TRUE, sCreditsText_ScriptDesigners}; +static const struct CreditsEntry sCreditsEntry_MapDesigners[] = {11, TRUE, sCreditsText_MapDesigners}; +static const struct CreditsEntry sCreditsEntry_MapDataDesigners[] = { 9, TRUE, sCreditsText_MapDataDesigners}; +static const struct CreditsEntry sCreditsEntry_ParametricDesigners[] = { 9, TRUE, sCreditsText_ParametricDesigners}; +static const struct CreditsEntry sCreditsEntry_PokedexText[] = {11, TRUE, sCreditsText_PokedexText}; +static const struct CreditsEntry sCreditsEntry_EnvAndToolPgrms[] = { 6, TRUE, sCreditsText_EnvAndToolPgrms}; +static const struct CreditsEntry sCreditsEntry_NCLProductTesting[] = {11, TRUE, sCreditsText_NCLProductTesting}; +static const struct CreditsEntry sCreditsEntry_SpecialThanks[] = {10, TRUE, sCreditsText_SpecialThanks}; +static const struct CreditsEntry sCreditsEntry_Coordinators[] = {11, TRUE, sCreditsText_Coordinators}; +static const struct CreditsEntry sCreditsEntry_Producers[] = {11, TRUE, sCreditsText_Producers}; +static const struct CreditsEntry sCreditsEntry_ExecProducers[] = { 7, TRUE, sCreditsText_ExecProducers}; +static const struct CreditsEntry sCreditsEntry_InfoSupervisors[] = {10, TRUE, sCreditsText_InfoSupervisors}; +static const struct CreditsEntry sCreditsEntry_TaskManagers[] = { 8, TRUE, sCreditsText_TaskManagers}; +static const struct CreditsEntry sCreditsEntry_BrailleCodeCheck[] = {10, TRUE, sCreditsText_BrailleCodeCheck}; +static const struct CreditsEntry sCreditsEntry_WorldDirector[] = {10, TRUE, sCreditsText_WorldDirector}; +static const struct CreditsEntry sCreditsEntry_BattleFrontierData[] = { 8, TRUE, sCreditsText_BattleFrontierData}; +static const struct CreditsEntry sCreditsEntry_SupportProgrammers[] = {10, TRUE, sCreditsText_SupportProgrammers}; +static const struct CreditsEntry sCreditsEntry_Artwork[] = {12, TRUE, sCreditsText_Artwork}; +static const struct CreditsEntry sCreditsEntry_LeadProgrammer[] = {10, TRUE, sCreditsText_LeadProgrammer}; +static const struct CreditsEntry sCreditsEntry_LeadGraphicArtist[] = { 9, TRUE, sCreditsText_LeadGraphicArtist}; +static const struct CreditsEntry sCreditsEntry_SatoshiTajiri[] = {11, FALSE, sCreditsText_SatoshiTajiri}; +static const struct CreditsEntry sCreditsEntry_JunichiMasuda[] = {11, FALSE, sCreditsText_JunichiMasuda}; +static const struct CreditsEntry sCreditsEntry_KenSugimori[] = {11, FALSE, sCreditsText_KenSugimori}; +static const struct CreditsEntry sCreditsEntry_ShigekiMorimoto[] = {11, FALSE, sCreditsText_ShigekiMorimoto}; +static const struct CreditsEntry sCreditsEntry_TetsuyaWatanabe[] = {11, FALSE, sCreditsText_TetsuyaWatanabe}; +static const struct CreditsEntry sCreditsEntry_HisashiSogabe[] = {11, FALSE, sCreditsText_HisashiSogabe}; +static const struct CreditsEntry sCreditsEntry_SosukeTamada[] = {11, FALSE, sCreditsText_SosukeTamada}; +static const struct CreditsEntry sCreditsEntry_AkitoMori[] = {11, FALSE, sCreditsText_AkitoMori}; +static const struct CreditsEntry sCreditsEntry_KeitaKagaya[] = {11, FALSE, sCreditsText_KeitaKagaya}; +static const struct CreditsEntry sCreditsEntry_YoshinoriMatsuda[] = {11, FALSE, sCreditsText_YoshinoriMatsuda}; +static const struct CreditsEntry sCreditsEntry_HiroyukiNakamura[] = {11, FALSE, sCreditsText_HiroyukiNakamura}; +static const struct CreditsEntry sCreditsEntry_MasaoTaya[] = {11, FALSE, sCreditsText_MasaoTaya}; +static const struct CreditsEntry sCreditsEntry_SatoshiNohara[] = {11, FALSE, sCreditsText_SatoshiNohara}; +static const struct CreditsEntry sCreditsEntry_TomomichiOhta[] = {11, FALSE, sCreditsText_TomomichiOhta}; +static const struct CreditsEntry sCreditsEntry_MiyukiIwasawa[] = {11, FALSE, sCreditsText_MiyukiIwasawa}; +static const struct CreditsEntry sCreditsEntry_TakenoriOhta[] = {11, FALSE, sCreditsText_TakenoriOhta}; +static const struct CreditsEntry sCreditsEntry_HironobuYoshida[] = {11, FALSE, sCreditsText_HironobuYoshida}; +static const struct CreditsEntry sCreditsEntry_MotofumiFujiwara[] = {11, FALSE, sCreditsText_MotofumiFujiwara}; +static const struct CreditsEntry sCreditsEntry_SatoshiOhta[] = {11, FALSE, sCreditsText_SatoshiOhta}; +static const struct CreditsEntry sCreditsEntry_AsukaIwashita[] = {11, FALSE, sCreditsText_AsukaIwashita}; +static const struct CreditsEntry sCreditsEntry_AimiTomita[] = {11, FALSE, sCreditsText_AimiTomita}; +static const struct CreditsEntry sCreditsEntry_TakaoUnno[] = {11, FALSE, sCreditsText_TakaoUnno}; +static const struct CreditsEntry sCreditsEntry_KanakoEo[] = {11, FALSE, sCreditsText_KanakoEo}; +static const struct CreditsEntry sCreditsEntry_JunOkutani[] = {11, FALSE, sCreditsText_JunOkutani}; +static const struct CreditsEntry sCreditsEntry_AtsukoNishida[] = {11, FALSE, sCreditsText_AtsukoNishida}; +static const struct CreditsEntry sCreditsEntry_MuneoSaito[] = {11, FALSE, sCreditsText_MuneoSaito}; +static const struct CreditsEntry sCreditsEntry_RenaYoshikawa[] = {11, FALSE, sCreditsText_RenaYoshikawa}; +static const struct CreditsEntry sCreditsEntry_GoIchinose[] = {11, FALSE, sCreditsText_GoIchinose}; +static const struct CreditsEntry sCreditsEntry_MorikazuAoki[] = {11, FALSE, sCreditsText_MorikazuAoki}; +static const struct CreditsEntry sCreditsEntry_KojiNishino[] = {11, FALSE, sCreditsText_KojiNishino}; +static const struct CreditsEntry sCreditsEntry_KenjiMatsushima[] = {11, FALSE, sCreditsText_KenjiMatsushima}; +static const struct CreditsEntry sCreditsEntry_TetsujiOhta[] = {11, FALSE, sCreditsText_TetsujiOhta}; +static const struct CreditsEntry sCreditsEntry_HitomiSato[] = {11, FALSE, sCreditsText_HitomiSato}; +static const struct CreditsEntry sCreditsEntry_TakeshiKawachimaru[] = {11, FALSE, sCreditsText_TakeshiKawachimaru}; +static const struct CreditsEntry sCreditsEntry_TeruyukiShimoyamada[] = {11, FALSE, sCreditsText_TeruyukiShimoyamada}; +static const struct CreditsEntry sCreditsEntry_ShigeruOhmori[] = {11, FALSE, sCreditsText_ShigeruOhmori}; +static const struct CreditsEntry sCreditsEntry_TadashiTakahashi[] = {11, FALSE, sCreditsText_TadashiTakahashi}; +static const struct CreditsEntry sCreditsEntry_ToshinobuMatsumiya[] = {11, FALSE, sCreditsText_ToshinobuMatsumiya}; +static const struct CreditsEntry sCreditsEntry_AkihitoTomisawa[] = {11, FALSE, sCreditsText_AkihitoTomisawa}; +static const struct CreditsEntry sCreditsEntry_HirokiEnomoto[] = {11, FALSE, sCreditsText_HirokiEnomoto}; +static const struct CreditsEntry sCreditsEntry_KazuyukiTerada[] = {11, FALSE, sCreditsText_KazuyukiTerada}; +static const struct CreditsEntry sCreditsEntry_YuriSakurai[] = {11, FALSE, sCreditsText_YuriSakurai}; +static const struct CreditsEntry sCreditsEntry_HiromiSagawa[] = {11, FALSE, sCreditsText_HiromiSagawa}; +static const struct CreditsEntry sCreditsEntry_KenjiTominaga[] = {11, FALSE, sCreditsText_KenjiTominaga}; +static const struct CreditsEntry sCreditsEntry_YoshioTajiri[] = {11, FALSE, sCreditsText_YoshioTajiri}; +static const struct CreditsEntry sCreditsEntry_TeikoSasaki[] = {11, FALSE, sCreditsText_TeikoSasaki}; +static const struct CreditsEntry sCreditsEntry_SachikoHamano[] = {11, FALSE, sCreditsText_SachikoHamano}; +static const struct CreditsEntry sCreditsEntry_ChieMatsumiya[] = {11, FALSE, sCreditsText_ChieMatsumiya}; +static const struct CreditsEntry sCreditsEntry_AkikoShinozaki[] = {11, FALSE, sCreditsText_AkikoShinozaki}; +static const struct CreditsEntry sCreditsEntry_AstukoFujii[] = {11, FALSE, sCreditsText_AstukoFujii}; +static const struct CreditsEntry sCreditsEntry_NozomuSaito[] = {11, FALSE, sCreditsText_NozomuSaito}; +static const struct CreditsEntry sCreditsEntry_KenkichiToyama[] = {11, FALSE, sCreditsText_KenkichiToyama}; +static const struct CreditsEntry sCreditsEntry_SuguruNakatsui[] = {11, FALSE, sCreditsText_SuguruNakatsui}; +static const struct CreditsEntry sCreditsEntry_YumiFunasaka[] = {11, FALSE, sCreditsText_YumiFunasaka}; +static const struct CreditsEntry sCreditsEntry_NaokoYanase[] = {11, FALSE, sCreditsText_NaokoYanase}; +static const struct CreditsEntry sCreditsEntry_NCLSuperMarioClub[] = {11, FALSE, sCreditsText_NCLSuperMarioClub}; +static const struct CreditsEntry sCreditsEntry_AtsushiTada[] = {11, FALSE, sCreditsText_AtsushiTada}; +static const struct CreditsEntry sCreditsEntry_TakahiroOhnishi[] = {11, FALSE, sCreditsText_TakahiroOhnishi}; +static const struct CreditsEntry sCreditsEntry_NorihideOkamura[] = {11, FALSE, sCreditsText_NorihideOkamura}; +static const struct CreditsEntry sCreditsEntry_HiroNakamura[] = {11, FALSE, sCreditsText_HiroNakamura}; +static const struct CreditsEntry sCreditsEntry_HiroyukiUesugi[] = {11, FALSE, sCreditsText_HiroyukiUesugi}; +static const struct CreditsEntry sCreditsEntry_TerukiMurakawa[] = {11, FALSE, sCreditsText_TerukiMurakawa}; +static const struct CreditsEntry sCreditsEntry_AkiraKinashi[] = {11, FALSE, sCreditsText_AkiraKinashi}; +static const struct CreditsEntry sCreditsEntry_MichikoTakizawa[] = {11, FALSE, sCreditsText_MichikoTakizawa}; +static const struct CreditsEntry sCreditsEntry_MakikoTakada[] = {11, FALSE, sCreditsText_MakikoTakada}; +static const struct CreditsEntry sCreditsEntry_TakanaoKondo[] = {11, FALSE, sCreditsText_TakanaoKondo}; +static const struct CreditsEntry sCreditsEntry_AiMashima[] = {11, FALSE, sCreditsText_AiMashima}; +static const struct CreditsEntry sCreditsEntry_GakujiNomoto[] = {11, FALSE, sCreditsText_GakujiNomoto}; +static const struct CreditsEntry sCreditsEntry_TakehiroIzushi[] = {11, FALSE, sCreditsText_TakehiroIzushi}; +static const struct CreditsEntry sCreditsEntry_HitoshiYamagami[] = {11, FALSE, sCreditsText_HitoshiYamagami}; +static const struct CreditsEntry sCreditsEntry_KyokoWatanabe[] = {11, FALSE, sCreditsText_KyokoWatanabe}; +static const struct CreditsEntry sCreditsEntry_TakaoNakano[] = {11, FALSE, sCreditsText_TakaoNakano}; +static const struct CreditsEntry sCreditsEntry_HiroyukiJinnai[] = {11, FALSE, sCreditsText_HiroyukiJinnai}; +static const struct CreditsEntry sCreditsEntry_HiroakiTsuru[] = {11, FALSE, sCreditsText_HiroakiTsuru}; +static const struct CreditsEntry sCreditsEntry_TsunekazIshihara[] = {11, FALSE, sCreditsText_TsunekazIshihara}; +static const struct CreditsEntry sCreditsEntry_SatoruIwata[] = {11, FALSE, sCreditsText_SatoruIwata}; +static const struct CreditsEntry sCreditsEntry_KazuyaSuyama[] = {11, FALSE, sCreditsText_KazuyaSuyama}; +static const struct CreditsEntry sCreditsEntry_SatoshiMitsuhara[] = {11, FALSE, sCreditsText_SatoshiMitsuhara}; +static const struct CreditsEntry sCreditsEntry_JapanBrailleLibrary[] = { 9, FALSE, sCreditsText_JapanBrailleLibrary}; +static const struct CreditsEntry sCreditsEntry_TomotakaKomura[] = {11, FALSE, sCreditsText_TomotakaKomura}; +static const struct CreditsEntry sCreditsEntry_MikikoOhhashi[] = {11, FALSE, sCreditsText_MikikoOhhashi}; +static const struct CreditsEntry sCreditsEntry_DaisukeHoshino[] = {11, FALSE, sCreditsText_DaisukeHoshino}; +static const struct CreditsEntry sCreditsEntry_KenjiroIto[] = {11, FALSE, sCreditsText_KenjiroIto}; +static const struct CreditsEntry sCreditsEntry_RuiKawaguchi[] = {11, FALSE, sCreditsText_RuiKawaguchi}; +static const struct CreditsEntry sCreditsEntry_ShunsukeKohori[] = {11, FALSE, sCreditsText_ShunsukeKohori}; +static const struct CreditsEntry sCreditsEntry_SachikoNakamichi[] = {11, FALSE, sCreditsText_SachikoNakamichi}; +static const struct CreditsEntry sCreditsEntry_FujikoNomura[] = {11, FALSE, sCreditsText_FujikoNomura}; +static const struct CreditsEntry sCreditsEntry_KazukiYoshihara[] = {11, FALSE, sCreditsText_KazukiYoshihara}; +static const struct CreditsEntry sCreditsEntry_RetsujiNomoto[] = {11, FALSE, sCreditsText_RetsujiNomoto}; +static const struct CreditsEntry sCreditsEntry_AzusaTajima[] = {11, FALSE, sCreditsText_AzusaTajima}; +static const struct CreditsEntry sCreditsEntry_ShusakuEgami[] = {11, FALSE, sCreditsText_ShusakuEgami}; +static const struct CreditsEntry sCreditsEntry_PackageAndManual[] = { 0, TRUE, sCreditsText_PackageAndManual}; +static const struct CreditsEntry sCreditsEntry_EnglishVersion[] = { 0, TRUE, sCreditsText_EnglishVersion}; +static const struct CreditsEntry sCreditsEntry_Translator[] = { 0, TRUE, sCreditsText_Translator}; +static const struct CreditsEntry sCreditsEntry_TextEditor[] = { 0, TRUE, sCreditsText_TextEditor}; +static const struct CreditsEntry sCreditsEntry_NCLCoordinator[] = { 0, TRUE, sCreditsText_NCLCoordinator}; +static const struct CreditsEntry sCreditsEntry_GraphicDesigner[] = { 0, TRUE, sCreditsText_GraphicDesigner}; +static const struct CreditsEntry sCreditsEntry_NOAProductTesting[] = { 0, TRUE, sCreditsText_NOAProductTesting}; +static const struct CreditsEntry sCreditsEntry_HideyukiNakajima[] = { 0, FALSE, sCreditsText_HideyukiNakajima}; +static const struct CreditsEntry sCreditsEntry_HidenoriSaeki[] = { 0, FALSE, sCreditsText_HidenoriSaeki}; +static const struct CreditsEntry sCreditsEntry_YokoWatanabe[] = { 0, FALSE, sCreditsText_YokoWatanabe}; +static const struct CreditsEntry sCreditsEntry_SakaeKimura[] = { 0, FALSE, sCreditsText_SakaeKimura}; +static const struct CreditsEntry sCreditsEntry_ChiakiShinkai[] = { 0, FALSE, sCreditsText_ChiakiShinkai}; +static const struct CreditsEntry sCreditsEntry_SethMcMahill[] = { 0, FALSE, sCreditsText_SethMcMahill}; +static const struct CreditsEntry sCreditsEntry_NobOgasawara[] = { 0, FALSE, sCreditsText_NobOgasawara}; +static const struct CreditsEntry sCreditsEntry_TeresaLillygren[] = { 0, FALSE, sCreditsText_TeresaLillygren}; +static const struct CreditsEntry sCreditsEntry_KimikoNakamichi[] = { 0, FALSE, sCreditsText_KimikoNakamichi}; +static const struct CreditsEntry sCreditsEntry_SouichiYamamoto[] = { 0, FALSE, sCreditsText_SouichiYamamoto}; +static const struct CreditsEntry sCreditsEntry_YuichiroIto[] = { 0, FALSE, sCreditsText_YuichiroIto}; +static const struct CreditsEntry sCreditsEntry_ThomasHertzog[] = { 0, FALSE, sCreditsText_ThomasHertzog}; +static const struct CreditsEntry sCreditsEntry_MikaKurosawa[] = { 0, FALSE, sCreditsText_MikaKurosawa}; +static const struct CreditsEntry sCreditsEntry_NationalFederationBlind[] = { 0, FALSE, sCreditsText_NationalFederationBlind}; +static const struct CreditsEntry sCreditsEntry_PatriciaAMaurer[] = { 0, FALSE, sCreditsText_PatriciaAMaurer}; +static const struct CreditsEntry sCreditsEntry_EuropeanBlindUnion[] = { 0, FALSE, sCreditsText_EuropeanBlindUnion}; +static const struct CreditsEntry sCreditsEntry_AustralianBrailleAuthority[] = { 0, FALSE, sCreditsText_AustralianBrailleAuthority}; +static const struct CreditsEntry sCreditsEntry_RoyalNewZealandFederationBlind[] = { 0, FALSE, sCreditsText_RoyalNewZealandFederationBlind}; +static const struct CreditsEntry sCreditsEntry_MotoyasuTojima[] = { 0, FALSE, sCreditsText_MotoyasuTojima}; +static const struct CreditsEntry sCreditsEntry_NicolaPrattBarlow[] = { 0, FALSE, sCreditsText_NicolaPrattBarlow}; +static const struct CreditsEntry sCreditsEntry_ShellieDow[] = { 0, FALSE, sCreditsText_ShellieDow}; +static const struct CreditsEntry sCreditsEntry_ErikJohnson[] = { 0, FALSE, sCreditsText_ErikJohnson}; + +#define _ sCreditsEntry_EmptyString +static const struct CreditsEntry *const sCreditsEntryPointerTable[PAGE_COUNT][ENTRIES_PER_PAGE] = +{ + [PAGE_TITLE] = { + _, + sCreditsEntry_PkmnEmeraldVersion, + sCreditsEntry_Credits, + _, + _ + }, + [PAGE_DIRECTOR] = { + _, + sCreditsEntry_Director, + sCreditsEntry_ShigekiMorimoto, + _, + _, + }, + [PAGE_ART_DIRECTOR] = { + _, + sCreditsEntry_ArtDirector, + sCreditsEntry_KenSugimori, + _, + _, + }, + [PAGE_WORLD_DIRECTOR] = { + _, + sCreditsEntry_WorldDirector, + sCreditsEntry_JunichiMasuda, + _, + _, + }, + [PAGE_LEAD_PROGRAMMER] = { + sCreditsEntry_LeadProgrammer, + sCreditsEntry_HisashiSogabe, + sCreditsEntry_LeadGraphicArtist, + sCreditsEntry_MotofumiFujiwara, + _, + }, + [PAGE_PROGRAMMERS_1] = { + sCreditsEntry_Programmers, + sCreditsEntry_HisashiSogabe, + sCreditsEntry_TomomichiOhta, + sCreditsEntry_NozomuSaito, + sCreditsEntry_EmptyString, + }, + [PAGE_PROGRAMMERS_2] = { + sCreditsEntry_Programmers, + sCreditsEntry_AkitoMori, + sCreditsEntry_HiroyukiNakamura, + sCreditsEntry_MasaoTaya, + _, + }, + [PAGE_PROGRAMMERS_3] = { + sCreditsEntry_Programmers, + sCreditsEntry_SatoshiNohara, + sCreditsEntry_MiyukiIwasawa, + sCreditsEntry_YoshinoriMatsuda, + sCreditsEntry_KeitaKagaya, + }, + [PAGE_PROGRAMMERS_4] = { + sCreditsEntry_Programmers, + sCreditsEntry_TetsuyaWatanabe, + sCreditsEntry_SosukeTamada, + sCreditsEntry_TakenoriOhta, + _, + }, + [PAGE_GRAPHIC_DESIGNERS_1] = { + _, + sCreditsEntry_GraphicDesigners, + sCreditsEntry_MotofumiFujiwara, + sCreditsEntry_SatoshiOhta, + _, + }, + [PAGE_GRAPHIC_DESIGNERS_2] = { + sCreditsEntry_GraphicDesigners, + sCreditsEntry_KenkichiToyama, + sCreditsEntry_AsukaIwashita, + sCreditsEntry_TakaoUnno, + _, + }, + [PAGE_GRAPHIC_DESIGNERS_3] = { + sCreditsEntry_GraphicDesigners, + sCreditsEntry_KenSugimori, + sCreditsEntry_HironobuYoshida, + sCreditsEntry_AimiTomita, + sCreditsEntry_KanakoEo, + }, + [PAGE_MUSIC_COMPOSITION] = { + sCreditsEntry_MusicComposition, + sCreditsEntry_GoIchinose, + sCreditsEntry_JunichiMasuda, + sCreditsEntry_MorikazuAoki, + sCreditsEntry_HitomiSato, + }, + [PAGE_SOUND_EFFECTS] = { + _, + sCreditsEntry_SoundEffectsAndPkmnVoices, + sCreditsEntry_GoIchinose, + sCreditsEntry_MorikazuAoki, + _, + }, + [PAGE_GAME_DESIGNERS_1] = { + sCreditsEntry_GameDesigners, + sCreditsEntry_ShigekiMorimoto, + sCreditsEntry_TeruyukiShimoyamada, + sCreditsEntry_TakeshiKawachimaru, + sCreditsEntry_AkihitoTomisawa, + }, + [PAGE_GAME_DESIGNERS_2] = { + sCreditsEntry_GameDesigners, + sCreditsEntry_SuguruNakatsui, + sCreditsEntry_TetsujiOhta, + sCreditsEntry_HitomiSato, + sCreditsEntry_KenjiMatsushima, + }, + [PAGE_GAME_DESIGNERS_3] = { + sCreditsEntry_GameDesigners, + sCreditsEntry_JunichiMasuda, + sCreditsEntry_KojiNishino, + sCreditsEntry_ShigeruOhmori, + sCreditsEntry_TadashiTakahashi, + }, + [PAGE_SCENARIO_PLOT] = { + sCreditsEntry_ScenarioPlot, + sCreditsEntry_AkihitoTomisawa, + sCreditsEntry_JunichiMasuda, + sCreditsEntry_KojiNishino, + _, + }, + [PAGE_SCENARIO] = { + sCreditsEntry_Scenario, + sCreditsEntry_AkihitoTomisawa, + sCreditsEntry_HitomiSato, + sCreditsEntry_ToshinobuMatsumiya, + _, + }, + [PAGE_SCRIPT_DESIGNERS] = { + sCreditsEntry_ScriptDesigners, + sCreditsEntry_TomomichiOhta, + sCreditsEntry_SatoshiNohara, + _, + _, + }, + [PAGE_MAP_DESIGNERS] = { + sCreditsEntry_MapDesigners, + sCreditsEntry_SuguruNakatsui, + sCreditsEntry_TeruyukiShimoyamada, + sCreditsEntry_ShigeruOhmori, + sCreditsEntry_TetsujiOhta, + }, + [PAGE_BATTLE_FRONTIER_DATA] = { + _, + sCreditsEntry_BattleFrontierData, + sCreditsEntry_TetsujiOhta, + _, + _, + }, + [PAGE_PARAMETRIC_DESIGNERS] = { + sCreditsEntry_ParametricDesigners, + sCreditsEntry_TeruyukiShimoyamada, + sCreditsEntry_ShigekiMorimoto, + sCreditsEntry_TetsujiOhta, + sCreditsEntry_KojiNishino, + }, + [PAGE_POKEDEX_TEXT] = { + _, + sCreditsEntry_PokedexText, + sCreditsEntry_KenjiMatsushima, + _, + _, + }, + [PAGE_ENVIRONMENT_AND_TOOL_PROGRAMS_1] = { + sCreditsEntry_EnvAndToolPgrms, + sCreditsEntry_HisashiSogabe, + sCreditsEntry_SosukeTamada, + sCreditsEntry_HiroyukiNakamura, + sCreditsEntry_AkitoMori, + }, + [PAGE_PKMN_DESIGNERS_1] = { + sCreditsEntry_PkmnDesigners, + sCreditsEntry_KenSugimori, + sCreditsEntry_MotofumiFujiwara, + sCreditsEntry_ShigekiMorimoto, + _, + }, + [PAGE_PKMN_DESIGNERS_2] = { + sCreditsEntry_PkmnDesigners, + sCreditsEntry_HironobuYoshida, + sCreditsEntry_SatoshiOhta, + sCreditsEntry_AsukaIwashita, + _, + }, + [PAGE_PKMN_DESIGNERS_3] = { + sCreditsEntry_PkmnDesigners, + sCreditsEntry_TakaoUnno, + sCreditsEntry_KanakoEo, + sCreditsEntry_AimiTomita, + _, + }, + [PAGE_PKMN_DESIGNERS_4] = { + sCreditsEntry_PkmnDesigners, + sCreditsEntry_AtsukoNishida, + sCreditsEntry_MuneoSaito, + sCreditsEntry_RenaYoshikawa, + sCreditsEntry_JunOkutani, + }, + [PAGE_SUPPORT_PROGRAMMERS] = { + _, + sCreditsEntry_SupportProgrammers, + sCreditsEntry_SatoshiMitsuhara, + sCreditsEntry_DaisukeHoshino, + _, + }, + [PAGE_NCL_PRODUCT_TESTING] = { + _, + sCreditsEntry_NCLProductTesting, + sCreditsEntry_NCLSuperMarioClub, + _, + _, + }, + [PAGE_PACKAGE_AND_MANUAL] = { + _, + sCreditsEntry_PackageAndManual, + sCreditsEntry_KenSugimori, + _, + _, + }, + [PAGE_SPECIAL_THANKS_1] = { + _, + sCreditsEntry_SpecialThanks, + sCreditsEntry_KenjiTominaga, + sCreditsEntry_HirokiEnomoto, + _, + }, + [PAGE_SPECIAL_THANKS_2] = { + sCreditsEntry_SpecialThanks, + sCreditsEntry_KazuyaSuyama, + sCreditsEntry_KenjiroIto, + sCreditsEntry_MichikoTakizawa, + sCreditsEntry_MakikoTakada, + }, + [PAGE_SPECIAL_THANKS_3] = { + sCreditsEntry_SpecialThanks, + sCreditsEntry_MikikoOhhashi, + sCreditsEntry_TakanaoKondo, + sCreditsEntry_RuiKawaguchi, + _, + }, + [PAGE_SPECIAL_THANKS_4] = { + sCreditsEntry_SpecialThanks, + sCreditsEntry_TakahiroOhnishi, + sCreditsEntry_NorihideOkamura, + sCreditsEntry_ShunsukeKohori, + _, + }, + [PAGE_INFORMATION_SUPERVISORS] = { + sCreditsEntry_InfoSupervisors, + sCreditsEntry_KazuyukiTerada, + sCreditsEntry_YuriSakurai, + sCreditsEntry_YumiFunasaka, + sCreditsEntry_NaokoYanase, + }, + [PAGE_ARTWORK_1] = { + _, + sCreditsEntry_Artwork, + sCreditsEntry_SachikoNakamichi, + sCreditsEntry_FujikoNomura, + _, + }, + [PAGE_ARTWORK_2] = { + _, + sCreditsEntry_Artwork, + sCreditsEntry_HideyukiNakajima, + sCreditsEntry_HidenoriSaeki, + _, + }, + [PAGE_ARTWORK_3] = { + sCreditsEntry_Artwork, + sCreditsEntry_YokoWatanabe, + sCreditsEntry_SakaeKimura, + sCreditsEntry_ChiakiShinkai, + _, + }, + [PAGE_COORDINATORS] = { + sCreditsEntry_Coordinators, + sCreditsEntry_KazukiYoshihara, + sCreditsEntry_AkiraKinashi, + sCreditsEntry_RetsujiNomoto, + _, + }, + [PAGE_ENGLISH_VERSION] = { + _, + sCreditsEntry_EnglishVersion, + sCreditsEntry_HiroNakamura, + sCreditsEntry_SethMcMahill, + _, + }, + [PAGE_TRANSLATOR] = { + _, + sCreditsEntry_Translator, + sCreditsEntry_NobOgasawara, + _, + _, + }, + [PAGE_TEXT_EDITOR] = { + _, + sCreditsEntry_TextEditor, + sCreditsEntry_TeresaLillygren, + _, + _, + }, + [PAGE_NCL_COORDINATOR] = { + _, + sCreditsEntry_NCLCoordinator, + sCreditsEntry_KimikoNakamichi, + _, + _, + }, + [PAGE_PROGRAMMERS_5] = { + sCreditsEntry_Programmers, + sCreditsEntry_TerukiMurakawa, + sCreditsEntry_SouichiYamamoto, + sCreditsEntry_YuichiroIto, + sCreditsEntry_AkiraKinashi, + }, + [PAGE_GRAPHIC_DESIGNER] = { + _, + sCreditsEntry_GraphicDesigner, + sCreditsEntry_AkiraKinashi, + _, + _, + }, + [PAGE_ENVIRONMENT_AND_TOOL_PROGRAMS_2] = { + sCreditsEntry_EnvAndToolPgrms, + sCreditsEntry_TerukiMurakawa, + sCreditsEntry_SouichiYamamoto, + sCreditsEntry_KimikoNakamichi, + _, + }, + [PAGE_NOA_TESTING] = { + sCreditsEntry_NOAProductTesting, + sCreditsEntry_ThomasHertzog, + sCreditsEntry_ErikJohnson, + sCreditsEntry_MikaKurosawa, + _, + }, + [PAGE_BRAILLE_CODE_CHECK_1] = { + sCreditsEntry_BrailleCodeCheck, + sCreditsEntry_NationalFederationBlind, + sCreditsEntry_PatriciaAMaurer, + sCreditsEntry_JapanBrailleLibrary, + sCreditsEntry_EuropeanBlindUnion, + }, + [PAGE_BRAILLE_CODE_CHECK_2] = { + _, + sCreditsEntry_BrailleCodeCheck, + sCreditsEntry_AustralianBrailleAuthority, + sCreditsEntry_RoyalNewZealandFederationBlind, + _, + }, + [PAGE_SPECIAL_THANKS_5] = { + sCreditsEntry_SpecialThanks, + sCreditsEntry_HiroyukiUesugi, + sCreditsEntry_MotoyasuTojima, + sCreditsEntry_NicolaPrattBarlow, + sCreditsEntry_ShellieDow, + }, + [PAGE_TASK_MANAGERS] = { + _, + sCreditsEntry_TaskManagers, + sCreditsEntry_AzusaTajima, + sCreditsEntry_ShusakuEgami, + _, + }, + [PAGE_PRODUCERS] = { + sCreditsEntry_Producers, + sCreditsEntry_HiroyukiJinnai, + sCreditsEntry_HitoshiYamagami, + sCreditsEntry_GakujiNomoto, + sCreditsEntry_HiroakiTsuru, + }, + [PAGE_EXECUTIVE_DIRECTOR] = { + _, + sCreditsEntry_ExecutiveDirector, + sCreditsEntry_SatoshiTajiri, + _, + _, + }, + [PAGE_EXECUTIVE_PRODUCERS_1] = { + _, + sCreditsEntry_ExecProducers, + sCreditsEntry_SatoruIwata, + _, + _, + }, + [PAGE_EXECUTIVE_PRODUCERS_2] = { + _, + sCreditsEntry_ExecProducers, + sCreditsEntry_TsunekazIshihara, + _, + _, + }, +}; +#undef _ diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c index 4cb26a9bf2..401d077ef7 100644 --- a/src/intro_credits_graphics.c +++ b/src/intro_credits_graphics.c @@ -442,7 +442,7 @@ static const struct IntroCreditsSpriteMetadata sSpriteMetadata_HouseSilhouette[] static const struct OamData sOamData_Player = { - .y = 160, + .y = DISPLAY_HEIGHT, .shape = SPRITE_SHAPE(64x64), .size = SPRITE_SIZE(64x64), .priority = 1 @@ -486,7 +486,7 @@ static const struct SpriteTemplate sSpriteTemplate_May = static const struct OamData sOamData_Bicycle = { - .y = 160, + .y = DISPLAY_HEIGHT, .shape = SPRITE_SHAPE(64x32), .size = SPRITE_SIZE(64x32), .priority = 1 @@ -530,7 +530,7 @@ static const struct SpriteTemplate sSpriteTemplate_MayBicycle = static const struct OamData sOamData_Flygon = { - .y = 160, + .y = DISPLAY_HEIGHT, .shape = SPRITE_SHAPE(64x64), .size = SPRITE_SIZE(64x64), .priority = 1 @@ -538,13 +538,13 @@ static const struct OamData sOamData_Flygon = static const union AnimCmd sAnim_FlygonLeft[] = { - ANIMCMD_FRAME( 0, 16), + ANIMCMD_FRAME(0, 16), ANIMCMD_END }; static const union AnimCmd sAnim_FlygonRight[] = { - ANIMCMD_FRAME( 64, 16), + ANIMCMD_FRAME(64, 16), ANIMCMD_END }; @@ -753,7 +753,7 @@ void LoadIntroPart2Graphics(u8 scene) CreateTreeSprites(); break; } - gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_MOVING; + gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_NORMAL; gReservedSpritePaletteCount = 8; } @@ -884,7 +884,7 @@ void LoadCreditsSceneGraphics(u8 scene) break; } gReservedSpritePaletteCount = 8; - gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_MOVING; + gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_NORMAL; } void SetCreditsSceneBgCnt(u8 scene) @@ -1043,7 +1043,7 @@ static void SpriteCB_MovingScenery(struct Sprite *sprite) default: // INTROCRED_SCENERY_DESTROY DestroySprite(sprite); break; - case INTROCRED_SCENERY_MOVING: + case INTROCRED_SCENERY_NORMAL: x = ((sprite->pos1.x << 16) | (u16)sprite->data[2]) + (u16)sprite->data[1]; sprite->pos1.x = x >> 16; sprite->data[2] = x; From 62968895ca220cf5b6f7c066e9061cf45fe7913e Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 29 Mar 2021 09:38:19 -0400 Subject: [PATCH 15/31] Add MON_PIC_SIZE constant --- include/constants/pokemon.h | 2 ++ src/battle_anim_effects_3.c | 2 +- src/battle_anim_mons.c | 6 ++-- src/battle_anim_throw.c | 2 +- src/battle_gfx_sfx_util.c | 8 ++--- src/credits.c | 12 ++++---- src/data.c | 36 ++++++++++++---------- src/decompress.c | 2 +- src/menu_specialized.c | 2 +- src/mystery_gift.c | 8 ++--- src/pokemon_jump.c | 4 +-- src/pokemon_storage_system.c | 6 ++-- src/pokenav_conditions_1.c | 2 +- src/pokenav_conditions_2.c | 2 +- src/trade.c | 6 ++-- src/use_pokeblock.c | 2 +- src/wireless_communication_status_screen.c | 4 +-- 17 files changed, 55 insertions(+), 51 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 11a7c7fc59..51ef0c015b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -346,4 +346,6 @@ #define NUM_MALE_LINK_FACILITY_CLASSES 8 #define NUM_FEMALE_LINK_FACILITY_CLASSES 8 +#define MON_PIC_SIZE (64 * 64 / 2) + #endif // GUARD_CONSTANTS_POKEMON_H diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index 81ba475f92..0c56c6bcab 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -2292,7 +2292,7 @@ void AnimTask_TransformMon(u8 taskId) src = gMonSpritesGfxPtr->sprites.ptr[position] + (gBattleMonForms[gBattleAnimAttacker] << 11); dest = animBg.bgTiles; - CpuCopy32(src, dest, 0x800); + CpuCopy32(src, dest, MON_PIC_SIZE); LoadBgTiles(1, animBg.bgTiles, 0x800, animBg.tilesOffset); if (IsContest()) { diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 3f4a35475f..3f8ccad52e 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -107,8 +107,8 @@ static const struct SpriteTemplate sSpriteTemplate_MoveEffectMons[] = static const struct SpriteSheet sSpriteSheet_MoveEffectMons[] = { - { gMiscBlank_Gfx, 0x800, TAG_MOVE_EFFECT_MON_1, }, - { gMiscBlank_Gfx, 0x800, TAG_MOVE_EFFECT_MON_2, }, + { gMiscBlank_Gfx, MON_PIC_SIZE, TAG_MOVE_EFFECT_MON_1, }, + { gMiscBlank_Gfx, MON_PIC_SIZE, TAG_MOVE_EFFECT_MON_2, }, }; u8 GetBattlerSpriteCoord(u8 battlerId, u8 coordType) @@ -2068,7 +2068,7 @@ u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 FALSE); } - RequestDma3Copy(gMonSpritesGfxPtr->buffer, (void *)(OBJ_VRAM0 + (sheet * 0x20)), 0x800, 1); + RequestDma3Copy(gMonSpritesGfxPtr->buffer, (void *)(OBJ_VRAM0 + (sheet * 0x20)), MON_PIC_SIZE, 1); FREE_AND_SET_NULL(gMonSpritesGfxPtr->buffer); if (!isBackpic) diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index 5b355c4bdd..d36f6c3f91 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -2182,7 +2182,7 @@ void AnimTask_SubstituteFadeToInvisible(u8 taskId) break; case 2: spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; - RequestDma3Fill(0, (void *)OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * TILE_SIZE_4BPP, 0x800, 1); + RequestDma3Fill(0, (void *)OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * TILE_SIZE_4BPP, MON_PIC_SIZE, 1); ClearBehindSubstituteBit(gBattleAnimAttacker); DestroyAnimVisualTask(taskId); break; diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index d9e1cdc2f2..ba0cab8146 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -967,7 +967,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform src = gMonSpritesGfxPtr->sprites.ptr[position]; dst = (void *)(OBJ_VRAM0 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32); - DmaCopy32(3, src, dst, 0x800); + DmaCopy32(3, src, dst, MON_PIC_SIZE); paletteOffset = 0x100 + battlerAtk * 16; lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue); LZDecompressWram(lzPaletteData, gDecompressionBuffer); @@ -1014,7 +1014,7 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite) for (i = 1; i < 4; i++) { - Dma3CopyLarge32_(gMonSpritesGfxPtr->sprites.ptr[position], &gMonSpritesGfxPtr->sprites.byte[position][0x800 * i], 0x800); + Dma3CopyLarge32_(gMonSpritesGfxPtr->sprites.ptr[position], &gMonSpritesGfxPtr->sprites.byte[position][MON_PIC_SIZE * i], MON_PIC_SIZE); } palOffset = (battlerId * 16) + 0x100; @@ -1259,8 +1259,8 @@ void AllocateMonSpritesGfx(void) for (j = 0; j < 4; j++) { - gMonSpritesGfxPtr->field_74[i][j].data = gMonSpritesGfxPtr->sprites.ptr[i] + (j * 0x800); - gMonSpritesGfxPtr->field_74[i][j].size = 0x800; + gMonSpritesGfxPtr->field_74[i][j].data = gMonSpritesGfxPtr->sprites.ptr[i] + (j * MON_PIC_SIZE); + gMonSpritesGfxPtr->field_74[i][j].size = MON_PIC_SIZE; } gMonSpritesGfxPtr->templates[i].images = gMonSpritesGfxPtr->field_74[i]; diff --git a/src/credits.c b/src/credits.c index 16d71f3e94..2045d116a5 100644 --- a/src/credits.c +++ b/src/credits.c @@ -288,7 +288,7 @@ static const union AnimCmd *const sAnims_Rival[] = sAnim_Rival_Still, }; -#define MONBG_OFFSET (0x800 * 3) +#define MONBG_OFFSET (MON_PIC_SIZE * 3) static const struct SpriteSheet sSpriteSheet_MonBg[] = { { gDecompressionBuffer, MONBG_OFFSET, TAG_MON_BG }, {}, @@ -566,12 +566,12 @@ static void Task_CreditsLoadGrassScene(u8 taskIdA) LZ77UnCompVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(7))); LoadPalette(gBirchBagGrassPal[0] + 1, 1, 31 * 2); - for (i = 0; i < 0x800; i++) + for (i = 0; i < MON_PIC_SIZE; i++) gDecompressionBuffer[i] = 0x11; - for (i = 0; i < 0x800; i++) - (gDecompressionBuffer + 0x800)[i] = 0x22; - for (i = 0; i < 0x800; i++) - (gDecompressionBuffer + 0x800 * 2)[i] = 0x33; + for (i = 0; i < MON_PIC_SIZE; i++) + (gDecompressionBuffer + MON_PIC_SIZE)[i] = 0x22; + for (i = 0; i < MON_PIC_SIZE; i++) + (gDecompressionBuffer + MON_PIC_SIZE * 2)[i] = 0x33; temp = (u16 *)(&gDecompressionBuffer[MONBG_OFFSET]); temp[0] = RGB_BLACK; diff --git a/src/data.c b/src/data.c index 6a4295440c..30672f7c4f 100644 --- a/src/data.c +++ b/src/data.c @@ -12,36 +12,38 @@ const u16 gMinigameDigits_Pal[] = INCBIN_U16("graphics/link/minigame_digits.gbap const u32 gMinigameDigits_Gfx[] = INCBIN_U32("graphics/link/minigame_digits.4bpp.lz"); static const u32 sMinigameDigitsThin_Gfx[] = INCBIN_U32("graphics/link/minigame_digits2.4bpp.lz"); // Unused +#define BATTLER_OFFSET(i) (gHeap + 0x8000 + MON_PIC_SIZE * (i)) + const struct SpriteFrameImage gBattlerPicTable_PlayerLeft[] = { - gHeap + 0x8000, 0x800, - gHeap + 0x8800, 0x800, - gHeap + 0x9000, 0x800, - gHeap + 0x9800, 0x800, + BATTLER_OFFSET(0), MON_PIC_SIZE, + BATTLER_OFFSET(1), MON_PIC_SIZE, + BATTLER_OFFSET(2), MON_PIC_SIZE, + BATTLER_OFFSET(3), MON_PIC_SIZE, }; const struct SpriteFrameImage gBattlerPicTable_OpponentLeft[] = { - gHeap + 0xA000, 0x800, - gHeap + 0xA800, 0x800, - gHeap + 0xB000, 0x800, - gHeap + 0xB800, 0x800, + BATTLER_OFFSET(4), MON_PIC_SIZE, + BATTLER_OFFSET(5), MON_PIC_SIZE, + BATTLER_OFFSET(6), MON_PIC_SIZE, + BATTLER_OFFSET(7), MON_PIC_SIZE, }; const struct SpriteFrameImage gBattlerPicTable_PlayerRight[] = { - gHeap + 0xC000, 0x800, - gHeap + 0xC800, 0x800, - gHeap + 0xD000, 0x800, - gHeap + 0xD800, 0x800, + BATTLER_OFFSET(8), MON_PIC_SIZE, + BATTLER_OFFSET(9), MON_PIC_SIZE, + BATTLER_OFFSET(10), MON_PIC_SIZE, + BATTLER_OFFSET(11), MON_PIC_SIZE, }; const struct SpriteFrameImage gBattlerPicTable_OpponentRight[] = { - gHeap + 0xE000, 0x800, - gHeap + 0xE800, 0x800, - gHeap + 0xF000, 0x800, - gHeap + 0xF800, 0x800, + BATTLER_OFFSET(12), MON_PIC_SIZE, + BATTLER_OFFSET(13), MON_PIC_SIZE, + BATTLER_OFFSET(14), MON_PIC_SIZE, + BATTLER_OFFSET(15), MON_PIC_SIZE, }; const struct SpriteFrameImage gTrainerBackPicTable_Brendan[] = @@ -290,7 +292,7 @@ const union AnimCmd *const gUnknown_082FF70C[] = gUnknown_082FF704, }; -#define SPECIES_SPRITE(species, sprite) [SPECIES_##species] = {sprite, 0x800, SPECIES_##species} +#define SPECIES_SPRITE(species, sprite) [SPECIES_##species] = {sprite, MON_PIC_SIZE, SPECIES_##species} #define SPECIES_PAL(species, pal) [SPECIES_##species] = {pal, SPECIES_##species} #define SPECIES_SHINY_PAL(species, pal) [SPECIES_##species] = {pal, SPECIES_##species + SPECIES_SHINY_TAG} diff --git a/src/decompress.c b/src/decompress.c index 335699449b..a65f38c2d7 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -390,5 +390,5 @@ void LoadSpecialPokePic_DontHandleDeoxys(const struct CompressedSpriteSheet *src static void DuplicateDeoxysTiles(void *pointer, s32 species) { if (species == SPECIES_DEOXYS) - CpuCopy32(pointer + 0x800, pointer, 0x800); + CpuCopy32(pointer + MON_PIC_SIZE, pointer, MON_PIC_SIZE); } diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 8eda1621e4..6873246121 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -1150,7 +1150,7 @@ static const union AnimCmd *const sAnims_ConditionSelectionIcon[] = // Just loads the generic data, up to the caller to load the actual sheet/pal for the specific mon void LoadConditionMonPicTemplate(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal) { - struct SpriteSheet dataSheet = {NULL, 0x800, TAG_CONDITION_MON}; + struct SpriteSheet dataSheet = {NULL, MON_PIC_SIZE, TAG_CONDITION_MON}; struct SpriteTemplate dataTemplate = { diff --git a/src/mystery_gift.c b/src/mystery_gift.c index a23f159b2d..1e00a5788b 100644 --- a/src/mystery_gift.c +++ b/src/mystery_gift.c @@ -394,10 +394,10 @@ bool32 HandleMysteryGiftOrEReaderSetup(s32 mg_or_ereader) ChangeBgX(3, 0, 0); ChangeBgY(3, 0, 0); - SetBgTilemapBuffer(3, Alloc(0x800)); - SetBgTilemapBuffer(2, Alloc(0x800)); - SetBgTilemapBuffer(1, Alloc(0x800)); - SetBgTilemapBuffer(0, Alloc(0x800)); + SetBgTilemapBuffer(3, Alloc(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(2, Alloc(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(1, Alloc(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(0, Alloc(BG_SCREEN_SIZE)); bgid_upload_textbox_1(3); InitWindows(sMainWindows); diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 4d7efe9ba6..f50a2d042a 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -2713,7 +2713,7 @@ static void CreateJumpMonSprite(struct PokemonJumpGfx *jumpGfx, struct PokemonJu spriteTemplate = sSpriteTemplate_JumpMon; buffer = Alloc(0x2000); - unusedBuffer = Alloc(0x800); + unusedBuffer = Alloc(MON_PIC_SIZE); if (multiplayerId == GetPokeJumpMultiplayerId()) subpriority = 3; else @@ -2729,7 +2729,7 @@ static void CreateJumpMonSprite(struct PokemonJumpGfx *jumpGfx, struct PokemonJu spriteSheet.data = buffer; spriteSheet.tag = multiplayerId; - spriteSheet.size = 0x800; + spriteSheet.size = MON_PIC_SIZE; LoadSpriteSheet(&spriteSheet); spritePalette.data = GetMonSpritePalFromSpeciesAndPersonality(monInfo->species, monInfo->otId, monInfo->personality); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 3d6dc331c1..d249381d85 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -4049,11 +4049,11 @@ static void LoadCursorMonSprite(void) u16 tileStart; u8 palSlot; u8 spriteId; - struct SpriteSheet sheet = {sPSSData->field_22C4, 0x800, TAG_TILE_2}; + struct SpriteSheet sheet = {sPSSData->field_22C4, MON_PIC_SIZE, TAG_TILE_2}; struct SpritePalette palette = {sPSSData->field_2244, TAG_PAL_DAC6}; struct SpriteTemplate template = sSpriteTemplate_CursorMon; - for (i = 0; i < 0x800; i++) + for (i = 0; i < MON_PIC_SIZE; i++) sPSSData->field_22C4[i] = 0; for (i = 0; i < 0x10; i++) sPSSData->field_2244[i] = 0; @@ -4095,7 +4095,7 @@ static void LoadCursorMonGfx(u16 species, u32 pid) { LoadSpecialPokePic(&gMonFrontPicTable[species], sPSSData->field_22C4, species, pid, TRUE); LZ77UnCompWram(sPSSData->cursorMonPalette, sPSSData->field_2244); - CpuCopy32(sPSSData->field_22C4, sPSSData->field_223C, 0x800); + CpuCopy32(sPSSData->field_22C4, sPSSData->field_223C, MON_PIC_SIZE); LoadPalette(sPSSData->field_2244, sPSSData->field_223A, 0x20); sPSSData->cursorMonSprite->invisible = FALSE; } diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c index 0545ff1c17..ebe870f80f 100644 --- a/src/pokenav_conditions_1.c +++ b/src/pokenav_conditions_1.c @@ -17,7 +17,7 @@ struct PokenavSub11 { u32 monPal[3][0x20]; u8 fill[0x180]; - u32 monPicGfx[3][0x800]; + u32 monPicGfx[3][MON_PIC_SIZE]; u8 searchMode; s16 monIndex; u32 (*callback)(struct PokenavSub11 *); diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index 26607926b7..dc07dd44c6 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -828,7 +828,7 @@ void CreateConditionMonPic(u8 id) } else { - DmaCopy16Defvars(3, GetConditionMonPicGfx(id), structPtr->unk181C, 0x800); + DmaCopy16Defvars(3, GetConditionMonPicGfx(id), structPtr->unk181C, MON_PIC_SIZE); LoadPalette(GetConditionMonPal(id), structPtr->monPalIndex, 0x20); } } diff --git a/src/trade.c b/src/trade.c index 436da66b0e..b6646378db 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2893,9 +2893,9 @@ static void InitTradeBgInternal(void) InitBgsFromTemplates(0, sTradeSequenceBgTemplates, ARRAY_COUNT(sTradeSequenceBgTemplates)); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); - SetBgTilemapBuffer(0, Alloc(0x800)); - SetBgTilemapBuffer(1, Alloc(0x800)); - SetBgTilemapBuffer(3, Alloc(0x800)); + SetBgTilemapBuffer(0, Alloc(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(1, Alloc(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(3, Alloc(BG_SCREEN_SIZE)); DeactivateAllTextPrinters(); DecompressAndLoadBgGfxUsingHeap(0, gBattleTextboxTiles, 0, 0, 0); LZDecompressWram(gBattleTextboxTilemap, gDecompressionBuffer); diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 5d8f5ce24c..cfaec6f187 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -1241,7 +1241,7 @@ static void UpdateMonPic(u8 loadId) } else { - Dma3CopyLarge16_(sMenu->partySheets[loadId], sMenu->curMonTileStart, 0x800); + Dma3CopyLarge16_(sMenu->partySheets[loadId], sMenu->curMonTileStart, MON_PIC_SIZE); LoadPalette(sMenu->partyPalettes[loadId], sMenu->curMonPalette, 32); } } diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c index 23d63832fa..72557aefd5 100644 --- a/src/wireless_communication_status_screen.c +++ b/src/wireless_communication_status_screen.c @@ -174,8 +174,8 @@ static void CB2_InitWirelessCommunicationScreen(void) SetVBlankCallback(NULL); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); - SetBgTilemapBuffer(1, Alloc(0x800)); - SetBgTilemapBuffer(0, Alloc(0x800)); + SetBgTilemapBuffer(1, Alloc(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(0, Alloc(BG_SCREEN_SIZE)); DecompressAndLoadBgGfxUsingHeap(1, sBgTiles_Gfx, 0, 0, 0); CopyToBgTilemapBuffer(1, sBgTiles_Tilemap, 0, 0); InitWindows(sWindowTemplates); From 6cceb05cb75f368c924c19fd456c2e09e71426a0 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 29 Mar 2021 11:20:00 -0500 Subject: [PATCH 16/31] Document some text-related things --- common_syms/text.txt | 4 +- gflib/text.c | 232 ++++++++++++++++++++--------------------- gflib/text.h | 12 +-- src/mauville_old_man.c | 18 ++-- src/unk_text_util_2.c | 22 ++-- sym_common.txt | 4 +- 6 files changed, 145 insertions(+), 147 deletions(-) diff --git a/common_syms/text.txt b/common_syms/text.txt index 4406c8bf93..cd8886e5b1 100644 --- a/common_syms/text.txt +++ b/common_syms/text.txt @@ -1,4 +1,4 @@ gFonts -gUnknown_03002F84 -gUnknown_03002F90 +gDisableTextPrinters +gCurGlyph gTextFlags diff --git a/gflib/text.c b/gflib/text.c index ffce2cb561..d75be2fbf3 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -21,8 +21,8 @@ static u16 gLastTextFgColor; static u16 gLastTextShadowColor; const struct FontInfo *gFonts; -u8 gUnknown_03002F84; -struct Struct_03002F90 gUnknown_03002F90; +u8 gDisableTextPrinters; +struct TextGlyph gCurGlyph; TextFlags gTextFlags; const u8 gFontHalfRowOffsets[] = @@ -204,7 +204,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2); gTextPrinters[printerTemplate->windowId].active = 0; } - gUnknown_03002F84 = 0; + gDisableTextPrinters = 0; return TRUE; } @@ -212,7 +212,7 @@ void RunTextPrinters(void) { int i; - if (gUnknown_03002F84 == 0) + if (gDisableTextPrinters == 0) { for (i = 0; i < NUM_TEXT_PRINTERS; ++i) { @@ -461,9 +461,9 @@ u8 GetLastTextColor(u8 colorType) } } -inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *ptr, s32 width, s32 height) +inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *glyphPixels, s32 width, s32 height) { - u32 xAdd, yAdd, r5, bits, toOrr, dummyX; + u32 xAdd, yAdd, pixelData, bits, toOrr, dummyX; u8 *dst; xAdd = j + width; @@ -471,69 +471,69 @@ inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u3 dummyX = j; for (; i < yAdd; i++) { - r5 = *ptr++; + pixelData = *glyphPixels++; for (j = dummyX; j < xAdd; j++) { - if ((toOrr = r5 & 0xF)) + if ((toOrr = pixelData & 0xF)) { dst = windowTiles + ((j / 8) * 32) + ((j % 8) / 2) + ((i / 8) * widthOffset) + ((i % 8) * 4); bits = ((j & 1) * 4); *dst = (toOrr << bits) | (*dst & (0xF0 >> bits)); } - r5 >>= 4; + pixelData >>= 4; } } } void CopyGlyphToWindow(struct TextPrinter *textPrinter) { - struct Window *win; - struct WindowTemplate *winTempl; - u32 *unkStruct; + struct Window *window; + struct WindowTemplate *template; + u32 *glyphPixels; u32 currX, currY, widthOffset; - s32 r4, r0; + s32 glyphWidth, glyphHeight; u8 *windowTiles; - win = &gWindows[textPrinter->printerTemplate.windowId]; - winTempl = &win->window; + window = &gWindows[textPrinter->printerTemplate.windowId]; + template = &window->window; - if ((r4 = (winTempl->width * 8) - textPrinter->printerTemplate.currentX) > gUnknown_03002F90.width) - r4 = gUnknown_03002F90.width; + if ((glyphWidth = (template->width * 8) - textPrinter->printerTemplate.currentX) > gCurGlyph.width) + glyphWidth = gCurGlyph.width; - if ((r0 = (winTempl->height * 8) - textPrinter->printerTemplate.currentY) > gUnknown_03002F90.height) - r0 = gUnknown_03002F90.height; + if ((glyphHeight = (template->height * 8) - textPrinter->printerTemplate.currentY) > gCurGlyph.height) + glyphHeight = gCurGlyph.height; currX = textPrinter->printerTemplate.currentX; currY = textPrinter->printerTemplate.currentY; - unkStruct = (u32 *)&gUnknown_03002F90.unk0; - windowTiles = win->tileData; - widthOffset = winTempl->width * 32; + glyphPixels = gCurGlyph.gfxBufferTop; + windowTiles = window->tileData; + widthOffset = template->width * 32; - if (r4 < 9) + if (glyphWidth < 9) { - if (r0 < 9) + if (glyphHeight < 9) { - GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, r0); + GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, glyphWidth, glyphHeight); } else { - GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, 8); - GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, r4, r0 - 8); + GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, glyphWidth, 8); + GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, glyphPixels + 16, glyphWidth, glyphHeight - 8); } } else { - if (r0 < 9) + if (glyphHeight < 9) { - GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, r0); - GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, r0); + GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, 8, glyphHeight); + GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, glyphPixels + 8, glyphWidth - 8, glyphHeight); } else { - GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, 8); - GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, 8); - GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, 8, r0 - 8); - GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY + 8, unkStruct + 24, r4 - 8, r0 - 8); + GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, 8, 8); + GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, glyphPixels + 8, glyphWidth - 8, 8); + GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, glyphPixels + 16, 8, glyphHeight - 8); + GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY + 8, glyphPixels + 24, glyphWidth - 8, glyphHeight - 8); } } } @@ -542,7 +542,7 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) { struct Window *window; struct Bitmap pixels_data; - struct Struct_03002F90 *gUnk; + struct TextGlyph *glyph; u8* glyphHeight; if (gLastTextBgColor != 0) @@ -552,8 +552,8 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) pixels_data.width = window->window.width << 3; pixels_data.height = window->window.height << 3; - gUnk = &gUnknown_03002F90; - glyphHeight = &gUnk->height; + glyph = &gCurGlyph; + glyphHeight = &glyph->height; FillBitmapRect4Bit( &pixels_data, @@ -1015,8 +1015,8 @@ u16 RenderText(struct TextPrinter *textPrinter) break; case CHAR_KEYPAD_ICON: currChar = *textPrinter->printerTemplate.currentChar++; - gUnknown_03002F90.width = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); - textPrinter->printerTemplate.currentX += gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing; + gCurGlyph.width = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); + textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing; return 0; case EOS: return 1; @@ -1050,8 +1050,8 @@ u16 RenderText(struct TextPrinter *textPrinter) if (textPrinter->minLetterSpacing) { - textPrinter->printerTemplate.currentX += gUnknown_03002F90.width; - width = textPrinter->minLetterSpacing - gUnknown_03002F90.width; + textPrinter->printerTemplate.currentX += gCurGlyph.width; + width = textPrinter->minLetterSpacing - gCurGlyph.width; if (width > 0) { ClearTextSpan(textPrinter, width); @@ -1061,9 +1061,9 @@ u16 RenderText(struct TextPrinter *textPrinter) else { if (textPrinter->japanese) - textPrinter->printerTemplate.currentX += (gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing); + textPrinter->printerTemplate.currentX += (gCurGlyph.width + textPrinter->printerTemplate.letterSpacing); else - textPrinter->printerTemplate.currentX += gUnknown_03002F90.width; + textPrinter->printerTemplate.currentX += gCurGlyph.width; } return 0; case 1: @@ -1499,8 +1499,8 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) DecompressGlyphFont1(temp, 1); break; } - CpuCopy32(gUnknown_03002F90.unk0, pixels, 0x20); - CpuCopy32(gUnknown_03002F90.unk40, pixels + 0x20, 0x20); + CpuCopy32(gCurGlyph.gfxBufferTop, pixels, 0x20); + CpuCopy32(gCurGlyph.gfxBufferBottom, pixels + 0x20, 0x20); pixels += 0x40; break; } @@ -1592,30 +1592,30 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) if (isJapanese == 1) { glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 - gUnknown_03002F90.width = 8; // gGlyphWidth - gUnknown_03002F90.height = 12; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 12; } else { glyphs = gFont0LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont0LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont0LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 13; + gCurGlyph.height = 13; } } @@ -1635,30 +1635,30 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese) { int eff; glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 - gUnknown_03002F90.width = 8; // gGlyphWidth - gUnknown_03002F90.height = 15; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 15; } else { glyphs = gFont7LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont7LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont7LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 15; + gCurGlyph.height = 15; } } @@ -1677,30 +1677,30 @@ void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese) if (isJapanese == TRUE) { glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 - gUnknown_03002F90.width = 8; // gGlyphWidth - gUnknown_03002F90.height = 12; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 12; } else { glyphs = gFont8LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont8LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont8LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 12; + gCurGlyph.height = 12; } } @@ -1719,32 +1719,32 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) if (isJapanese == TRUE) { glyphs = gFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); // gUnknown_03002F90 + 0x40 - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x20 - DecompressGlyphTile(glyphs + 0x88, gUnknown_03002F90.unk60); // gUnknown_03002F90 + 0x60 - gUnknown_03002F90.width = gFont2JapaneseGlyphWidths[glyphId]; // gGlyphWidth - gUnknown_03002F90.height = 14; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); // gCurGlyph + 0x20 + DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8); // gCurGlyph + 0x60 + gCurGlyph.width = gFont2JapaneseGlyphWidths[glyphId]; + gCurGlyph.height = 14; } else { glyphs = gFont2LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont2LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont2LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 14; + gCurGlyph.height = 14; } } @@ -1764,30 +1764,30 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) { int eff; glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 - gUnknown_03002F90.width = 8; // gGlyphWidth - gUnknown_03002F90.height = 15; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 15; } else { glyphs = gFont1LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont1LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont1LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 15; + gCurGlyph.height = 15; } } @@ -1804,8 +1804,8 @@ void DecompressGlyphFont9(u16 glyphId) const u16* glyphs; glyphs = gFont9JapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); - gUnknown_03002F90.width = 8; - gUnknown_03002F90.height = 12; + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 12; } diff --git a/gflib/text.h b/gflib/text.h index 723a2fc0e5..3e9b4f2aed 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -360,20 +360,18 @@ typedef struct { bool8 forceMidTextSpeed:1; } TextFlags; -struct Struct_03002F90 +struct TextGlyph { - u32 unk0[8]; - u32 unk20[8]; - u32 unk40[8]; - u32 unk60[8]; + u32 gfxBufferTop[16]; + u32 gfxBufferBottom[16]; u8 width; u8 height; }; extern TextFlags gTextFlags; -extern u8 gUnknown_03002F84; -extern struct Struct_03002F90 gUnknown_03002F90; +extern u8 gDisableTextPrinters; +extern struct TextGlyph gCurGlyph; void SetFontsPointer(const struct FontInfo *fonts); void DeactivateAllTextPrinters(void); diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index cdcde9b062..2284156283 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -425,21 +425,21 @@ static void StartBardSong(bool8 useTemporaryLyrics) gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; } -static void sub_81206F0(void) +static void EnableTextPrinters(void) { - gUnknown_03002F84 = FALSE; + gDisableTextPrinters = FALSE; } -static void BardSong_TextSubPrinter(struct TextPrinterTemplate * printer, u16 a1) +static void BardSong_DisableTextPrinters(struct TextPrinterTemplate * printer, u16 a1) { - gUnknown_03002F84 = TRUE; + gDisableTextPrinters = TRUE; } static void sub_8120708(const u8 * src) { DrawDialogueFrame(0, 0); - AddTextPrinterParameterized(0, 1, src, 0, 1, 1, BardSong_TextSubPrinter); - gUnknown_03002F84 = TRUE; + AddTextPrinterParameterized(0, 1, src, 0, 1, 1, BardSong_DisableTextPrinters); + gDisableTextPrinters = TRUE; CopyWindowToVram(0, 3); } @@ -620,7 +620,7 @@ static void Task_BardSong(u8 taskId) else if (gStringVar4[task->tCharIndex] == CHAR_SPACE) { - sub_81206F0(); + EnableTextPrinters(); task->tCharIndex++; task->tState = 2; task->data[2] = 0; @@ -640,7 +640,7 @@ static void Task_BardSong(u8 taskId) else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR) { gStringVar4[task->tCharIndex] = CHAR_SPACE; // restore it back to a space - sub_81206F0(); + EnableTextPrinters(); task->tCharIndex++; task->data[2] = 0; } @@ -649,7 +649,7 @@ static void Task_BardSong(u8 taskId) switch (task->data[1]) { case 0: - sub_81206F0(); + EnableTextPrinters(); task->data[1]++; break; case 1: diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c index b92b34fbd2..3459dde858 100644 --- a/src/unk_text_util_2.c +++ b/src/unk_text_util_2.c @@ -5,7 +5,7 @@ #include "sound.h" ALIGNED(4) -static const u8 sUnknown_08616124[] = {1, 2, 4}; +static const u8 sScrollDistances[] = {1, 2, 4}; static const u16 sFont6BrailleGlyphs[] = INCBIN_U16("graphics/fonts/font6.fwjpnfont"); static void DecompressGlyphFont6(u16); @@ -135,7 +135,7 @@ u16 Font6Func(struct TextPrinter *textPrinter) } DecompressGlyphFont6(char_); CopyGlyphToWindow(textPrinter); - textPrinter->printerTemplate.currentX += gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing; + textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing; return 0; case 1: if (TextPrinterWait(textPrinter)) @@ -164,15 +164,15 @@ u16 Font6Func(struct TextPrinter *textPrinter) case 4: if (textPrinter->scrollDistance) { - if (textPrinter->scrollDistance < sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed]) + if (textPrinter->scrollDistance < sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed]) { ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); textPrinter->scrollDistance = 0; } else { - ScrollWindow(textPrinter->printerTemplate.windowId, 0, sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor)); - textPrinter->scrollDistance -= sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed]; + ScrollWindow(textPrinter->printerTemplate.windowId, 0, sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor)); + textPrinter->scrollDistance -= sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed]; } CopyWindowToVram(textPrinter->printerTemplate.windowId, 2); } @@ -206,12 +206,12 @@ static void DecompressGlyphFont6(u16 glyph) const u16 *glyphs; glyphs = sFont6BrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); - DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90.unk60)); - gUnknown_03002F90.width = 0x10; - gUnknown_03002F90.height = 0x10; + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8); + gCurGlyph.width = 0x10; + gCurGlyph.height = 0x10; } u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese) diff --git a/sym_common.txt b/sym_common.txt index 22d70d7063..1525d8aec8 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -16,10 +16,10 @@ gWindowBgTilemapBuffers: gFonts: .space 4 .align 2 -gUnknown_03002F84: +gDisableTextPrinters: .space 1 .align 4 -gUnknown_03002F90: +gCurGlyph: .space 132 .align 2 gTextFlags: From 79a8eb481f08a035d2b357b5f9c9a57cb54e99da Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Mon, 29 Mar 2021 18:32:22 -0400 Subject: [PATCH 17/31] 1 to true --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 75861a3acd..3125716e25 100644 --- a/src/main.c +++ b/src/main.c @@ -132,7 +132,7 @@ void AgbMain() DoSoftReset(); } - if (Overworld_SendKeysToLinkIsRunning() == 1) + if (Overworld_SendKeysToLinkIsRunning() == TRUE) { gLinkTransferringData = TRUE; UpdateLinkAndCallCallbacks(); @@ -143,7 +143,7 @@ void AgbMain() gLinkTransferringData = FALSE; UpdateLinkAndCallCallbacks(); - if (Overworld_RecvKeysFromLinkIsRunning() == 1) + if (Overworld_RecvKeysFromLinkIsRunning() == TRUE) { gMain.newKeys = 0; ClearSpriteCopyRequests(); From 09ff1524b4fd89a3d0b9291f03cb8f0655ed69b7 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 29 Mar 2021 12:39:49 -0400 Subject: [PATCH 18/31] Finish documenting credits --- ..._bg_afternoon.pal => clouds_bg_sunset.pal} | 0 ...clouds_afternoon.pal => clouds_sunset.pal} | 0 .../{grass_afternoon.pal => grass_sunset.pal} | 0 .../{trees_afternoon.pal => trees_sunset.pal} | 0 include/intro_credits_graphics.h | 9 + src/credits.c | 732 +++++++++--------- src/hall_of_fame.c | 6 +- src/intro_credits_graphics.c | 102 +-- 8 files changed, 442 insertions(+), 407 deletions(-) rename graphics/intro/scene_2/{clouds_bg_afternoon.pal => clouds_bg_sunset.pal} (100%) rename graphics/intro/scene_2/{clouds_afternoon.pal => clouds_sunset.pal} (100%) rename graphics/intro/scene_2/{grass_afternoon.pal => grass_sunset.pal} (100%) rename graphics/intro/scene_2/{trees_afternoon.pal => trees_sunset.pal} (100%) diff --git a/graphics/intro/scene_2/clouds_bg_afternoon.pal b/graphics/intro/scene_2/clouds_bg_sunset.pal similarity index 100% rename from graphics/intro/scene_2/clouds_bg_afternoon.pal rename to graphics/intro/scene_2/clouds_bg_sunset.pal diff --git a/graphics/intro/scene_2/clouds_afternoon.pal b/graphics/intro/scene_2/clouds_sunset.pal similarity index 100% rename from graphics/intro/scene_2/clouds_afternoon.pal rename to graphics/intro/scene_2/clouds_sunset.pal diff --git a/graphics/intro/scene_2/grass_afternoon.pal b/graphics/intro/scene_2/grass_sunset.pal similarity index 100% rename from graphics/intro/scene_2/grass_afternoon.pal rename to graphics/intro/scene_2/grass_sunset.pal diff --git a/graphics/intro/scene_2/trees_afternoon.pal b/graphics/intro/scene_2/trees_sunset.pal similarity index 100% rename from graphics/intro/scene_2/trees_afternoon.pal rename to graphics/intro/scene_2/trees_sunset.pal diff --git a/include/intro_credits_graphics.h b/include/intro_credits_graphics.h index df3854aef0..bed30ffe82 100644 --- a/include/intro_credits_graphics.h +++ b/include/intro_credits_graphics.h @@ -8,6 +8,15 @@ enum { INTROCRED_SCENERY_FROZEN, }; +// Scenes for the Credits sequence +enum { + SCENE_OCEAN_MORNING, + SCENE_OCEAN_SUNSET, + SCENE_FOREST_RIVAL_ARRIVE, + SCENE_FOREST_CATCH_RIVAL, + SCENE_CITY_NIGHT, +}; + extern u16 gIntroCredits_MovingSceneryVBase; extern s16 gIntroCredits_MovingSceneryVOffset; extern s16 gIntroCredits_MovingSceneryState; diff --git a/src/credits.c b/src/credits.c index 2045d116a5..f6871aeec3 100644 --- a/src/credits.c +++ b/src/credits.c @@ -35,49 +35,32 @@ enum { POS_RIGHT, }; -#define tPlayerSpriteId data[5] -#define tRivalSpriteId data[6] - -enum -{ - TDA_0 = 0, - TDA_TASK_C_ID = 1, - TDA_TASK_E_ID = 2, - TDA_TASK_D_ID = 3, - TDA_4 = 4, - TDA_PLAYER_CYCLIST = 5, - TDA_RIVAL_CYCLIST = 6, - TDA_7 = 7, // Has something to do with the bike scene - TDA_11 = 11, // Gets set depending on whether the bike or the grass scene should be shown - TDA_12 = 12, - TDA_13 = 13, - TDA_14 = 14, - TDA_TASK_B_ID = 15, - - // Appears to be responsible for text - TDB_0 = 0, - TDB_TASK_A_ID = 1, - TDB_CURRENT_PAGE = 2, - TDB_3 = 3, - - TDC_0 = 0, - TDC_1 = 1, - TDC_2 = 2, - TDC_3 = 3, - TDC_4 = 4, - TDC_5 = 5, - - TDD_STATE = 0, - TDD_TASK_A_ID = 1, - TDD_2 = 2, - TDD_3 = 3, - - TDE_0 = 0, - TDE_1 = 1, - TDE_TASK_A_ID = 2, +enum { + MODE_NONE, + MODE_BIKE_SCENE, + MODE_SHOW_MONS, }; +#define tState data[0] + +// Task data for the main Credits tasks +#define tTaskId_BgScenery data[0] // ID for Task_BicycleBgAnimation (created by CreateBicycleBgAnimationTask) +#define tTaskId_BikeScene data[1] // ID for Task_BikeScene +#define tTaskId_SceneryPal data[2] // ID for Task_CycleSceneryPalette +#define tTaskId_ShowMons data[3] // ID for Task_ShowMons +#define tEndCredits data[4] +#define tPlayerSpriteId data[5] +#define tRivalSpriteId data[6] +#define tSceneNum data[7] +// data[8]-[10] are unused +#define tNextMode data[11] +#define tTheEndDelay data[12] +#define tCurrentMode data[13] +#define tPrintedPage data[14] +#define tTaskId_UpdatePage data[15] + #define NUM_MON_SLIDES 71 + struct CreditsData { u16 monToShow[NUM_MON_SLIDES]; // List of Pokemon species ids that will show during the credits @@ -108,11 +91,11 @@ static const u32 sCreditsCopyrightEnd_Gfx[] = INCBIN_U32("graphics/credits/the_e static void SpriteCB_CreditsMonBg(struct Sprite *); static void Task_WaitPaletteFade(u8); -static void Task_ProgressCreditTasks(u8); -static void sub_8175808(u8); -static void c2_080C9BFC(u8); -static void Task_CreditsLoadGrassScene(u8); -static void sub_81758A4(u8); +static void Task_CreditsMain(u8); +static void Task_ReadyBikeScene(u8); +static void Task_SetBikeScene(u8); +static void Task_LoadShowMons(u8); +static void Task_ReadyShowMons(u8); static void Task_CreditsTheEnd1(u8); static void Task_CreditsTheEnd2(u8); static void Task_CreditsTheEnd3(u8); @@ -121,17 +104,17 @@ static void Task_CreditsTheEnd5(u8); static void Task_CreditsTheEnd6(u8); static void Task_CreditsSoftReset(u8); static void ResetGpuAndVram(void); -static void sub_8175DA0(u8); +static void Task_UpdatePage(u8); static u8 CheckChangeScene(u8, u8); -static void sub_81760FC(u8); -static void sub_817651C(u8); -static void sub_817624C(u8); -static bool8 sub_8176AB0(u8 data, u8); +static void Task_ShowMons(u8); +static void Task_CycleSceneryPalette(u8); +static void Task_BikeScene(u8); +static bool8 LoadBikeScene(u8 data, u8); static void ResetCreditsTasks(u8); static void LoadTheEndScreen(u16, u16, u16); static void DrawTheEnd(u16, u16); -static void SpriteCB_PlayerCyclist(struct Sprite *); -static void SpriteCB_RivalCyclist(struct Sprite *); +static void SpriteCB_Player(struct Sprite *); +static void SpriteCB_Rival(struct Sprite *); static u8 CreateCreditsMonSprite(u16, s16, s16, u16); static void DeterminePokemonToShow(void); @@ -365,7 +348,7 @@ static void CB2_Credits(void) if ((JOY_HELD(B_BUTTON)) && gHasHallOfFameRecords - && gTasks[sSavedTaskId].func == Task_ProgressCreditTasks) + && gTasks[sSavedTaskId].func == Task_CreditsMain) { // Speed up credits VBlankCB_Credits(); @@ -390,7 +373,7 @@ static void InitCreditsBgsAndWindows(void) ShowBg(0); } -static void sub_81755A4(void) +static void FreeCreditsBgsAndWindows(void) { void *ptr; FreeAllWindowBuffers(); @@ -421,11 +404,13 @@ static void PrintCreditsText(const u8 *string, u8 y, bool8 isTitle) AddTextPrinterParameterized4(0, 1, x, y, 1, 0, color, -1, string); } +#define tMainTaskId data[1] + void CB2_StartCreditsSequence(void) { - u8 taskIdA; - s16 taskIdC; - u8 taskIdB; + u8 taskId; + s16 bikeTaskId; + u8 pageTaskId; ResetGpuAndVram(); SetVBlankCallback(NULL); @@ -434,28 +419,28 @@ void CB2_StartCreditsSequence(void) ResetTasks(); InitCreditsBgsAndWindows(); - taskIdA = CreateTask(Task_WaitPaletteFade, 0); + taskId = CreateTask(Task_WaitPaletteFade, 0); - gTasks[taskIdA].data[TDA_4] = 0; - gTasks[taskIdA].data[TDA_7] = 0; - gTasks[taskIdA].data[TDA_11] = 0; - gTasks[taskIdA].data[TDA_13] = 1; + gTasks[taskId].tEndCredits = FALSE; + gTasks[taskId].tSceneNum = SCENE_OCEAN_MORNING; + gTasks[taskId].tNextMode = MODE_NONE; + gTasks[taskId].tCurrentMode = MODE_BIKE_SCENE; while (TRUE) { - if (sub_8176AB0(0, taskIdA)) + if (LoadBikeScene(SCENE_OCEAN_MORNING, taskId)) break; } - taskIdC = gTasks[taskIdA].data[TDA_TASK_C_ID]; - gTasks[taskIdC].data[TDC_0] = 40; + bikeTaskId = gTasks[taskId].tTaskId_BikeScene; + gTasks[bikeTaskId].tState = 40; SetGpuReg(REG_OFFSET_BG0VOFS, 0xFFFC); - taskIdB = CreateTask(sub_8175DA0, 0); + pageTaskId = CreateTask(Task_UpdatePage, 0); - gTasks[taskIdB].data[TDB_TASK_A_ID] = taskIdA; - gTasks[taskIdA].data[TDA_TASK_B_ID] = taskIdB; + gTasks[pageTaskId].tMainTaskId = taskId; + gTasks[taskId].tTaskId_UpdatePage = pageTaskId; BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); EnableInterrupts(INTR_FLAG_VBLANK); @@ -471,84 +456,84 @@ void CB2_StartCreditsSequence(void) sCreditsData->nextImgPos = POS_LEFT; sCreditsData->currShownMon = 0; - sSavedTaskId = taskIdA; + sSavedTaskId = taskId; } -static void Task_WaitPaletteFade(u8 taskIdA) +static void Task_WaitPaletteFade(u8 taskId) { if (!gPaletteFade.active) - gTasks[taskIdA].func = Task_ProgressCreditTasks; + gTasks[taskId].func = Task_CreditsMain; } -static void Task_ProgressCreditTasks(u8 taskIdA) +static void Task_CreditsMain(u8 taskId) { - u16 data1; + u16 mode; - if (gTasks[taskIdA].data[TDA_4]) + if (gTasks[taskId].tEndCredits) { - s16 taskIdC; + s16 bikeTaskId = gTasks[taskId].tTaskId_BikeScene; + gTasks[bikeTaskId].tState = 30; - taskIdC = gTasks[taskIdA].data[TDA_TASK_C_ID]; - gTasks[taskIdC].data[TDC_0] = 30; - - gTasks[taskIdA].data[TDA_12] = 0x100; - gTasks[taskIdA].func = Task_CreditsTheEnd1; + gTasks[taskId].tTheEndDelay = 256; + gTasks[taskId].func = Task_CreditsTheEnd1; return; } sUnkVar = 0; - data1 = gTasks[taskIdA].data[TDA_11]; + mode = gTasks[taskId].tNextMode; - if (gTasks[taskIdA].data[TDA_11] == 1) + if (gTasks[taskId].tNextMode == MODE_BIKE_SCENE) { - gTasks[taskIdA].data[TDA_13] = data1; - gTasks[taskIdA].data[TDA_11] = 0; + // Start a bike cutscene + gTasks[taskId].tCurrentMode = mode; + gTasks[taskId].tNextMode = MODE_NONE; BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); - gTasks[taskIdA].func = sub_8175808; + gTasks[taskId].func = Task_ReadyBikeScene; } - else if (gTasks[taskIdA].data[TDA_11] == 2) + else if (gTasks[taskId].tNextMode == MODE_SHOW_MONS) { - gTasks[taskIdA].data[TDA_13] = data1; - gTasks[taskIdA].data[TDA_11] = 0; + // Start a Pokémon interlude + gTasks[taskId].tCurrentMode = mode; + gTasks[taskId].tNextMode = MODE_NONE; BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); - gTasks[taskIdA].func = sub_81758A4; + gTasks[taskId].func = Task_ReadyShowMons; } } -static void sub_8175808(u8 taskIdA) +static void Task_ReadyBikeScene(u8 taskId) { if (!gPaletteFade.active) { SetGpuReg(REG_OFFSET_DISPCNT, 0); - ResetCreditsTasks(taskIdA); - gTasks[taskIdA].func = c2_080C9BFC; + ResetCreditsTasks(taskId); + gTasks[taskId].func = Task_SetBikeScene; } } -static void c2_080C9BFC(u8 taskIdA) +static void Task_SetBikeScene(u8 taskId) { SetVBlankCallback(NULL); - if (sub_8176AB0(gTasks[taskIdA].data[TDA_7], taskIdA)) + if (LoadBikeScene(gTasks[taskId].tSceneNum, taskId)) { BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); EnableInterrupts(INTR_FLAG_VBLANK); SetVBlankCallback(VBlankCB_Credits); - gTasks[taskIdA].func = Task_WaitPaletteFade; + gTasks[taskId].func = Task_WaitPaletteFade; } } -static void sub_81758A4(u8 taskIdA) +static void Task_ReadyShowMons(u8 taskId) { if (!gPaletteFade.active) { SetGpuReg(REG_OFFSET_DISPCNT, 0); - ResetCreditsTasks(taskIdA); - gTasks[taskIdA].func = Task_CreditsLoadGrassScene; + ResetCreditsTasks(taskId); + gTasks[taskId].func = Task_LoadShowMons; } } -static void Task_CreditsLoadGrassScene(u8 taskIdA) +static void Task_LoadShowMons(u8 taskId) { switch (gMain.state) { @@ -586,10 +571,10 @@ static void Task_CreditsLoadGrassScene(u8 taskIdA) break; } case 1: - gTasks[taskIdA].data[TDA_TASK_D_ID] = CreateTask(sub_81760FC, 0); - gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_STATE] = 1; - gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_TASK_A_ID] = taskIdA; - gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_2] = gTasks[taskIdA].data[TDA_7]; + gTasks[taskId].tTaskId_ShowMons = CreateTask(Task_ShowMons, 0); + gTasks[gTasks[taskId].tTaskId_ShowMons].tState = 1; + gTasks[gTasks[taskId].tTaskId_ShowMons].tMainTaskId = taskId; + gTasks[gTasks[taskId].tTaskId_ShowMons].data[2] = gTasks[taskId].tSceneNum; // data[2] never read BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_BG3HOFS, 0); @@ -607,35 +592,35 @@ static void Task_CreditsLoadGrassScene(u8 taskIdA) gMain.state = 0; gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_NORMAL; - gTasks[taskIdA].func = Task_WaitPaletteFade; + gTasks[taskId].func = Task_WaitPaletteFade; break; } } -static void Task_CreditsTheEnd1(u8 taskIdA) +static void Task_CreditsTheEnd1(u8 taskId) { - if (gTasks[taskIdA].data[TDA_12]) + if (gTasks[taskId].tTheEndDelay) { - gTasks[taskIdA].data[TDA_12]--; + gTasks[taskId].tTheEndDelay--; return; } BeginNormalPaletteFade(PALETTES_ALL, 12, 0, 16, RGB_BLACK); - gTasks[taskIdA].func = Task_CreditsTheEnd2; + gTasks[taskId].func = Task_CreditsTheEnd2; } -static void Task_CreditsTheEnd2(u8 taskIdA) +static void Task_CreditsTheEnd2(u8 taskId) { if (!gPaletteFade.active) { - ResetCreditsTasks(taskIdA); - gTasks[taskIdA].func = Task_CreditsTheEnd3; + ResetCreditsTasks(taskId); + gTasks[taskId].func = Task_CreditsTheEnd3; } } #define tDelay data[0] -static void Task_CreditsTheEnd3(u8 taskIdA) +static void Task_CreditsTheEnd3(u8 taskId) { ResetGpuAndVram(); ResetPaletteFade(); @@ -654,59 +639,59 @@ static void Task_CreditsTheEnd3(u8 taskIdA) | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON); - gTasks[taskIdA].tDelay = 235; //set this to 215 to actually show "THE END" in time to the last song beat - gTasks[taskIdA].func = Task_CreditsTheEnd4; + gTasks[taskId].tDelay = 235; //set this to 215 to actually show "THE END" in time to the last song beat + gTasks[taskId].func = Task_CreditsTheEnd4; } -static void Task_CreditsTheEnd4(u8 taskIdA) +static void Task_CreditsTheEnd4(u8 taskId) { - if (gTasks[taskIdA].tDelay) + if (gTasks[taskId].tDelay) { - gTasks[taskIdA].tDelay--; + gTasks[taskId].tDelay--; return; } BeginNormalPaletteFade(PALETTES_ALL, 6, 0, 16, RGB_BLACK); - gTasks[taskIdA].func = Task_CreditsTheEnd5; + gTasks[taskId].func = Task_CreditsTheEnd5; } -static void Task_CreditsTheEnd5(u8 taskIdA) +static void Task_CreditsTheEnd5(u8 taskId) { if (!gPaletteFade.active) { DrawTheEnd(0x3800, 0); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0, RGB_BLACK); - gTasks[taskIdA].tDelay = 7200; - gTasks[taskIdA].func = Task_CreditsTheEnd6; + gTasks[taskId].tDelay = 7200; + gTasks[taskId].func = Task_CreditsTheEnd6; } } -static void Task_CreditsTheEnd6(u8 taskIdA) +static void Task_CreditsTheEnd6(u8 taskId) { if (!gPaletteFade.active) { - if (gTasks[taskIdA].tDelay == 0 || gMain.newKeys) + if (gTasks[taskId].tDelay == 0 || gMain.newKeys) { FadeOutBGM(4); BeginNormalPaletteFade(PALETTES_ALL, 8, 0, 16, RGB_WHITEALPHA); - gTasks[taskIdA].func = Task_CreditsSoftReset; + gTasks[taskId].func = Task_CreditsSoftReset; return; } - if (gTasks[taskIdA].tDelay == 7144) + if (gTasks[taskId].tDelay == 7144) FadeOutBGM(8); - if (gTasks[taskIdA].tDelay == 6840) + if (gTasks[taskId].tDelay == 6840) m4aSongNumStart(MUS_END); - gTasks[taskIdA].tDelay--; + gTasks[taskId].tDelay--; } } #undef tDelay -static void Task_CreditsSoftReset(u8 taskIdA) +static void Task_CreditsSoftReset(u8 taskId) { if (!gPaletteFade.active) SoftReset(RESET_ALL); @@ -734,11 +719,14 @@ static void ResetGpuAndVram(void) DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); } -static void sub_8175DA0(u8 taskIdB) +#define tCurrentPage data[2] +#define tDelay data[3] + +static void Task_UpdatePage(u8 taskId) { int i; - switch (gTasks[taskIdB].data[TDB_0]) + switch (gTasks[taskId].tState) { case 0: case 6: @@ -748,185 +736,194 @@ static void sub_8175DA0(u8 taskIdB) default: if (!gPaletteFade.active) { - gTasks[taskIdB].data[TDB_0] = 1; - gTasks[taskIdB].data[TDB_3] = 0x48; - gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 0; + gTasks[taskId].tState = 1; + gTasks[taskId].tDelay = 72; + gTasks[gTasks[taskId].tMainTaskId].tPrintedPage = FALSE; sUnkVar = 0; } return; case 1: - if (gTasks[taskIdB].data[TDB_3] != 0) + if (gTasks[taskId].tDelay != 0) { - gTasks[taskIdB].data[TDB_3]--; + gTasks[taskId].tDelay--; return; } - gTasks[taskIdB].data[TDB_0]++; + gTasks[taskId].tState++; return; case 2: - if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].func == Task_ProgressCreditTasks) + if (gTasks[gTasks[taskId].tMainTaskId].func == Task_CreditsMain) { - if (gTasks[taskIdB].data[TDB_CURRENT_PAGE] < PAGE_COUNT) + if (gTasks[taskId].tCurrentPage < PAGE_COUNT) { + // Print text for this Credits page for (i = 0; i < ENTRIES_PER_PAGE; i++) PrintCreditsText( - sCreditsEntryPointerTable[gTasks[taskIdB].data[TDB_CURRENT_PAGE]][i]->text, + sCreditsEntryPointerTable[gTasks[taskId].tCurrentPage][i]->text, 5 + i * 16, - sCreditsEntryPointerTable[gTasks[taskIdB].data[TDB_CURRENT_PAGE]][i]->isTitle); - + sCreditsEntryPointerTable[gTasks[taskId].tCurrentPage][i]->isTitle); CopyWindowToVram(0, 2); - gTasks[taskIdB].data[TDB_CURRENT_PAGE]++; - gTasks[taskIdB].data[TDB_0]++; + gTasks[taskId].tCurrentPage++; + gTasks[taskId].tState++; - gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 1; + gTasks[gTasks[taskId].tMainTaskId].tPrintedPage = TRUE; - if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_13] == 1) - BeginNormalPaletteFade(0x00000300, 0, 16, 0, COLOR_LIGHT_GREEN); - else - BeginNormalPaletteFade(0x00000300, 0, 16, 0, COLOR_DARK_GREEN); + if (gTasks[gTasks[taskId].tMainTaskId].tCurrentMode == MODE_BIKE_SCENE) + BeginNormalPaletteFade(0x300, 0, 16, 0, COLOR_LIGHT_GREEN); + else // MODE_SHOW_MONS + BeginNormalPaletteFade(0x300, 0, 16, 0, COLOR_DARK_GREEN); return; } - gTasks[taskIdB].data[TDB_0] = 10; + + // Reached final page of Credits, end task + gTasks[taskId].tState = 10; return; } - gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 0; + gTasks[gTasks[taskId].tMainTaskId].tPrintedPage = FALSE; return; case 3: if (!gPaletteFade.active) { - gTasks[taskIdB].data[TDB_3] = 0x73; - gTasks[taskIdB].data[TDB_0]++; + gTasks[taskId].tDelay = 115; + gTasks[taskId].tState++; } return; case 4: - if (gTasks[taskIdB].data[TDB_3] != 0) + if (gTasks[taskId].tDelay != 0) { - gTasks[taskIdB].data[TDB_3]--; + gTasks[taskId].tDelay--; return; } - if (CheckChangeScene((u8)gTasks[taskIdB].data[TDB_CURRENT_PAGE], (u8)gTasks[taskIdB].data[TDB_TASK_A_ID])) + if (CheckChangeScene((u8)gTasks[taskId].tCurrentPage, (u8)gTasks[taskId].tMainTaskId)) { - gTasks[taskIdB].data[TDB_0]++; + gTasks[taskId].tState++; return; } - gTasks[taskIdB].data[TDB_0]++; - if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_13] == 1) - BeginNormalPaletteFade(0x00000300, 0, 0, 16, COLOR_LIGHT_GREEN); - else - BeginNormalPaletteFade(0x00000300, 0, 0, 16, COLOR_DARK_GREEN); + gTasks[taskId].tState++; + if (gTasks[gTasks[taskId].tMainTaskId].tCurrentMode == MODE_BIKE_SCENE) + BeginNormalPaletteFade(0x300, 0, 0, 16, COLOR_LIGHT_GREEN); + else // MODE_SHOW_MONS + BeginNormalPaletteFade(0x300, 0, 0, 16, COLOR_DARK_GREEN); return; case 5: if (!gPaletteFade.active) { + // Still more Credits pages to show, return to state 2 to print FillWindowPixelBuffer(0, PIXEL_FILL(0)); CopyWindowToVram(0, 2); - gTasks[taskIdB].data[TDB_0] = 2; + gTasks[taskId].tState = 2; } return; case 10: - gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_4] = 1; - DestroyTask(taskIdB); - sub_81755A4(); + gTasks[gTasks[taskId].tMainTaskId].tEndCredits = TRUE; + DestroyTask(taskId); + FreeCreditsBgsAndWindows(); FREE_AND_SET_NULL(sCreditsData); return; } } -static u8 CheckChangeScene(u8 page, u8 taskIdA) -{ - // Starts with bike + ocean + morning +#undef tDelay - if (page == 6) +#define PAGE_INTERVAL (PAGE_COUNT / 9) // 9 scenes (5 bike scenes, 4 Pokémon interludes) + +static u8 CheckChangeScene(u8 page, u8 taskId) +{ + // Starts with bike + ocean + morning (SCENE_OCEAN_MORNING) + + if (page == PAGE_INTERVAL * 1) { // Pokémon interlude - gTasks[taskIdA].data[TDA_11] = 2; + gTasks[taskId].tNextMode = MODE_SHOW_MONS; } - if (page == 12) + if (page == PAGE_INTERVAL * 2) { // Bike + ocean + sunset - gTasks[taskIdA].data[TDA_7] = 1; - gTasks[taskIdA].data[TDA_11] = 1; + gTasks[taskId].tSceneNum = SCENE_OCEAN_SUNSET; + gTasks[taskId].tNextMode = MODE_BIKE_SCENE; } - if (page == 18) + if (page == PAGE_INTERVAL * 3) { // Pokémon interlude - gTasks[taskIdA].data[TDA_11] = 2; + gTasks[taskId].tNextMode = MODE_SHOW_MONS; } - if (page == 24) + if (page == PAGE_INTERVAL * 4) { // Bike + forest + sunset - gTasks[taskIdA].data[TDA_7] = 2; - gTasks[taskIdA].data[TDA_11] = 1; + gTasks[taskId].tSceneNum = SCENE_FOREST_RIVAL_ARRIVE; + gTasks[taskId].tNextMode = MODE_BIKE_SCENE; } - if (page == 30) + if (page == PAGE_INTERVAL * 5) { // Pokémon interlude - gTasks[taskIdA].data[TDA_11] = 2; + gTasks[taskId].tNextMode = MODE_SHOW_MONS; } - if (page == 36) + if (page == PAGE_INTERVAL * 6) { // Bike + forest + sunset - gTasks[taskIdA].data[TDA_7] = 3; - gTasks[taskIdA].data[TDA_11] = 1; + gTasks[taskId].tSceneNum = SCENE_FOREST_CATCH_RIVAL; + gTasks[taskId].tNextMode = MODE_BIKE_SCENE; } - if (page == 42) + if (page == PAGE_INTERVAL * 7) { // Pokémon interlude - gTasks[taskIdA].data[TDA_11] = 2; + gTasks[taskId].tNextMode = MODE_SHOW_MONS; } - if (page == 48) + if (page == PAGE_INTERVAL * 8) { // Bike + town + night - gTasks[taskIdA].data[TDA_7] = 4; - gTasks[taskIdA].data[TDA_11] = 1; + gTasks[taskId].tSceneNum = SCENE_CITY_NIGHT; + gTasks[taskId].tNextMode = MODE_BIKE_SCENE; } - if (gTasks[taskIdA].data[TDA_11] != 0) + if (gTasks[taskId].tNextMode != MODE_NONE) { - // Returns true if changed? + // Returns true if changed return TRUE; } return FALSE; } -static void sub_81760FC(u8 taskIdD) -{ - u8 r2; +#define tDelay data[3] - switch (gTasks[taskIdD].data[TDD_STATE]) +static void Task_ShowMons(u8 taskId) +{ + u8 spriteId; + + switch (gTasks[taskId].tState) { case 0: break; case 1: - if (sCreditsData->nextImgPos == POS_LEFT && gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] == 0) + if (sCreditsData->nextImgPos == POS_LEFT && gTasks[gTasks[taskId].tMainTaskId].tPrintedPage == FALSE) break; - gTasks[taskIdD].data[TDD_STATE]++; + gTasks[taskId].tState++; break; case 2: - if (sCreditsData->imgCounter == NUM_MON_SLIDES || gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].func != Task_ProgressCreditTasks) + if (sCreditsData->imgCounter == NUM_MON_SLIDES || gTasks[gTasks[taskId].tMainTaskId].func != Task_CreditsMain) break; - r2 = CreateCreditsMonSprite(sCreditsData->monToShow[sCreditsData->currShownMon], + spriteId = CreateCreditsMonSprite(sCreditsData->monToShow[sCreditsData->currShownMon], sMonSpritePos[sCreditsData->nextImgPos][0], sMonSpritePos[sCreditsData->nextImgPos][1], sCreditsData->nextImgPos); if (sCreditsData->currShownMon < sCreditsData->numMonToShow - 1) { sCreditsData->currShownMon++; - gSprites[r2].data[3] = 50; + gSprites[spriteId].data[3] = 50; } else { sCreditsData->currShownMon = 0; - gSprites[r2].data[3] = 512; + gSprites[spriteId].data[3] = 512; } sCreditsData->imgCounter++; @@ -935,237 +932,254 @@ static void sub_81760FC(u8 taskIdD) else sCreditsData->nextImgPos++; - gTasks[taskIdD].data[TDD_3] = 50; - gTasks[taskIdD].data[TDD_STATE]++; + gTasks[taskId].tDelay = 50; + gTasks[taskId].tState++; break; case 3: - if (gTasks[taskIdD].data[TDD_3] != 0) - gTasks[taskIdD].data[TDD_3]--; + if (gTasks[taskId].tDelay != 0) + gTasks[taskId].tDelay--; else - gTasks[taskIdD].data[TDD_STATE] = 1; + gTasks[taskId].tState = 1; break; } } -static void sub_817624C(u8 taskIdC) +#undef tMainTaskId +#undef tDelay + +#define tPlayer data[2] +#define tRival data[3] +#define tDelay data[4] +#define tSinIdx data[5] + +static void Task_BikeScene(u8 taskId) { - switch (gTasks[taskIdC].data[TDC_0]) + switch (gTasks[taskId].tState) { case 0: - gIntroCredits_MovingSceneryVOffset = Sin((gTasks[taskIdC].data[TDC_5] >> 1) & 0x7F, 12); - gTasks[taskIdC].data[TDC_5]++; + gIntroCredits_MovingSceneryVOffset = Sin((gTasks[taskId].tSinIdx >> 1) & 0x7F, 12); + gTasks[taskId].tSinIdx++; break; case 1: if (gIntroCredits_MovingSceneryVOffset != 0) { - gIntroCredits_MovingSceneryVOffset = Sin((gTasks[taskIdC].data[TDC_5] >> 1) & 0x7F, 12); - gTasks[taskIdC].data[TDC_5]++; + gIntroCredits_MovingSceneryVOffset = Sin((gTasks[taskId].tSinIdx >> 1) & 0x7F, 12); + gTasks[taskId].tSinIdx++; } else { - gSprites[gTasks[taskIdC].data[TDC_2]].data[0] = 2; - gTasks[taskIdC].data[TDC_5] = 0; - gTasks[taskIdC].data[TDC_0]++; + gSprites[gTasks[taskId].tPlayer].data[0] = 2; + gTasks[taskId].tSinIdx = 0; + gTasks[taskId].tState++; } break; case 2: - if (gTasks[taskIdC].data[TDC_5] < 64) + if (gTasks[taskId].tSinIdx < 64) { - gTasks[taskIdC].data[TDC_5]++; - gIntroCredits_MovingSceneryVOffset = Sin(gTasks[taskIdC].data[TDC_5] & 0x7F, 20); + gTasks[taskId].tSinIdx++; + gIntroCredits_MovingSceneryVOffset = Sin(gTasks[taskId].tSinIdx & 0x7F, 20); } else { - gTasks[taskIdC].data[TDC_0]++; + gTasks[taskId].tState++; } break; case 3: - gSprites[gTasks[taskIdC].data[TDC_2]].data[0] = 3; - gSprites[gTasks[taskIdC].data[TDC_3]].data[0] = 1; - gTasks[taskIdC].data[TDC_4] = 120; - gTasks[taskIdC].data[TDC_0]++; + gSprites[gTasks[taskId].tPlayer].data[0] = 3; + gSprites[gTasks[taskId].tRival].data[0] = 1; + gTasks[taskId].tDelay = 120; + gTasks[taskId].tState++; break; case 4: - if (gTasks[taskIdC].data[TDC_4] != 0) + if (gTasks[taskId].tDelay != 0) { - gTasks[taskIdC].data[TDC_4]--; + gTasks[taskId].tDelay--; } else { - gTasks[taskIdC].data[TDC_5] = 64; - gTasks[taskIdC].data[TDC_0]++; + gTasks[taskId].tSinIdx = 64; + gTasks[taskId].tState++; } break; case 5: - if (gTasks[taskIdC].data[TDC_5] > 0) + if (gTasks[taskId].tSinIdx > 0) { - gTasks[taskIdC].data[TDC_5]--; - gIntroCredits_MovingSceneryVOffset = Sin(gTasks[taskIdC].data[TDC_5] & 0x7F, 20); + gTasks[taskId].tSinIdx--; + gIntroCredits_MovingSceneryVOffset = Sin(gTasks[taskId].tSinIdx & 0x7F, 20); } else { - gSprites[gTasks[taskIdC].data[TDC_2]].data[0] = 1; - gTasks[taskIdC].data[TDC_0]++; + gSprites[gTasks[taskId].tPlayer].data[0] = 1; + gTasks[taskId].tState++; } break; case 6: - gTasks[taskIdC].data[TDC_0] = 50; + gTasks[taskId].tState = 50; break; case 10: - gSprites[gTasks[taskIdC].data[TDC_3]].data[0] = 2; - gTasks[taskIdC].data[TDC_0] = 50; + gSprites[gTasks[taskId].tRival].data[0] = 2; + gTasks[taskId].tState = 50; break; case 20: - gSprites[gTasks[taskIdC].data[TDC_2]].data[0] = 4; - gTasks[taskIdC].data[TDC_0] = 50; + gSprites[gTasks[taskId].tPlayer].data[0] = 4; + gTasks[taskId].tState = 50; break; case 30: - gSprites[gTasks[taskIdC].data[TDC_2]].data[0] = 5; - gSprites[gTasks[taskIdC].data[TDC_3]].data[0] = 3; - gTasks[taskIdC].data[TDC_0] = 50; + gSprites[gTasks[taskId].tPlayer].data[0] = 5; + gSprites[gTasks[taskId].tRival].data[0] = 3; + gTasks[taskId].tState = 50; break; case 50: - gTasks[taskIdC].data[TDC_0] = 0; + gTasks[taskId].tState = 0; break; } } -static void sub_817651C(u8 taskIdE) -{ - s16 taskIdC; +#define TIMER_STOP 0x7FFF +#define tTimer data[1] +#define tMainTaskId data[2] - switch (gTasks[taskIdE].data[TDE_0]) +static void Task_CycleSceneryPalette(u8 taskId) +{ + s16 bikeTaskId; + + switch (gTasks[taskId].tState) { default: - case 0: - if (gTasks[taskIdE].data[TDE_1] != 0x7FFF) + case SCENE_OCEAN_MORNING: + if (gTasks[taskId].tTimer != TIMER_STOP) { - - if (gTasks[gTasks[gTasks[taskIdE].data[TDE_TASK_A_ID]].data[TDA_TASK_B_ID]].data[TDB_CURRENT_PAGE] == 2) + if (gTasks[gTasks[gTasks[taskId].tMainTaskId].tTaskId_UpdatePage].tCurrentPage == 2) { - gTasks[gTasks[gTasks[taskIdE].data[TDE_TASK_A_ID]].data[TDA_TASK_C_ID]].data[TDC_0] = 20; - gTasks[taskIdE].data[TDE_1] = 0x7FFF; + gTasks[gTasks[gTasks[taskId].tMainTaskId].tTaskId_BikeScene].tState = 20; + gTasks[taskId].tTimer = TIMER_STOP; } } CycleSceneryPalette(0); break; - case 1: + case SCENE_OCEAN_SUNSET: CycleSceneryPalette(0); break; - case 2: - if (gTasks[taskIdE].data[TDE_1] != 0x7FFF) + case SCENE_FOREST_RIVAL_ARRIVE: + if (gTasks[taskId].tTimer != TIMER_STOP) { - taskIdC = gTasks[gTasks[taskIdE].data[TDE_TASK_A_ID]].data[TDA_TASK_C_ID]; + bikeTaskId = gTasks[gTasks[taskId].tMainTaskId].tTaskId_BikeScene; // Floor to multiple of 128 - if ((gTasks[taskIdC].data[TDC_5] & -128) == 640) + if ((gTasks[bikeTaskId].tSinIdx & -128) == 640) { - gTasks[taskIdC].data[TDC_0] = 1; - gTasks[taskIdE].data[TDE_1] = 0x7FFF; + gTasks[bikeTaskId].tState = 1; + gTasks[taskId].tTimer = TIMER_STOP; } } CycleSceneryPalette(1); break; - case 3: - if (gTasks[taskIdE].data[TDE_1] != 0x7FFF) + case SCENE_FOREST_CATCH_RIVAL: + if (gTasks[taskId].tTimer != TIMER_STOP) { - if (gTasks[taskIdE].data[TDE_1] == 0x248) + if (gTasks[taskId].tTimer == 584) { - gTasks[gTasks[gTasks[taskIdE].data[TDE_TASK_A_ID]].data[TDA_TASK_C_ID]].data[TDC_0] = 10; - gTasks[taskIdE].data[TDE_1] = 0x7FFF; + gTasks[gTasks[gTasks[taskId].tMainTaskId].tTaskId_BikeScene].tState = 10; + gTasks[taskId].tTimer = TIMER_STOP; } else { - gTasks[taskIdE].data[TDE_1]++; + gTasks[taskId].tTimer++; } } CycleSceneryPalette(1); break; - case 4: + case SCENE_CITY_NIGHT: CycleSceneryPalette(2); break; } } -static void InitCreditsSceneGfx(u8 scene, u8 taskIdA) +static void SetBikeScene(u8 scene, u8 taskId) { switch (scene) { - case 0: - gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 272; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = 272; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; - gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(0, 0x2000, 0x20, 8); + case SCENE_OCEAN_MORNING: + gSprites[gTasks[taskId].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.x = DISPLAY_WIDTH + 32; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.x = DISPLAY_WIDTH + 32; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskId].tRivalSpriteId].data[0] = 0; + gTasks[taskId].tTaskId_BgScenery = CreateBicycleBgAnimationTask(0, 0x2000, 0x20, 8); break; - case 1: - gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 120; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = 272; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; - gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(0, 0x2000, 0x20, 8); + case SCENE_OCEAN_SUNSET: + gSprites[gTasks[taskId].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.x = 120; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.x = DISPLAY_WIDTH + 32; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskId].tRivalSpriteId].data[0] = 0; + gTasks[taskId].tTaskId_BgScenery = CreateBicycleBgAnimationTask(0, 0x2000, 0x20, 8); break; - case 2: - gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 120; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = 272; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; - gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(1, 0x2000, 0x200, 8); + case SCENE_FOREST_RIVAL_ARRIVE: + gSprites[gTasks[taskId].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.x = 120; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.x = DISPLAY_WIDTH + 32; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskId].tRivalSpriteId].data[0] = 0; + gTasks[taskId].tTaskId_BgScenery = CreateBicycleBgAnimationTask(1, 0x2000, 0x200, 8); break; - case 3: - gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 120; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = -32; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; - gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(1, 0x2000, 0x200, 8); + case SCENE_FOREST_CATCH_RIVAL: + gSprites[gTasks[taskId].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.x = 120; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.x = -32; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskId].tRivalSpriteId].data[0] = 0; + gTasks[taskId].tTaskId_BgScenery = CreateBicycleBgAnimationTask(1, 0x2000, 0x200, 8); break; - case 4: - gSprites[gTasks[taskIdA].tPlayerSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tRivalSpriteId].invisible = FALSE; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.x = 88; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.x = 152; - gSprites[gTasks[taskIdA].tPlayerSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tRivalSpriteId].pos1.y = 46; - gSprites[gTasks[taskIdA].tPlayerSpriteId].data[0] = 0; - gSprites[gTasks[taskIdA].tRivalSpriteId].data[0] = 0; - gTasks[taskIdA].data[TDA_0] = CreateBicycleBgAnimationTask(2, 0x2000, 0x200, 8); + case SCENE_CITY_NIGHT: + gSprites[gTasks[taskId].tPlayerSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tRivalSpriteId].invisible = FALSE; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.x = 88; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.x = 152; + gSprites[gTasks[taskId].tPlayerSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tRivalSpriteId].pos1.y = 46; + gSprites[gTasks[taskId].tPlayerSpriteId].data[0] = 0; + gSprites[gTasks[taskId].tRivalSpriteId].data[0] = 0; + gTasks[taskId].tTaskId_BgScenery = CreateBicycleBgAnimationTask(2, 0x2000, 0x200, 8); break; } - gTasks[taskIdA].data[TDA_TASK_E_ID] = CreateTask(sub_817651C, 0); - gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_0] = scene; - gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_1] = 0; - gTasks[gTasks[taskIdA].data[TDA_TASK_E_ID]].data[TDE_TASK_A_ID] = taskIdA; + gTasks[taskId].tTaskId_SceneryPal = CreateTask(Task_CycleSceneryPalette, 0); + gTasks[gTasks[taskId].tTaskId_SceneryPal].tState = scene; + gTasks[gTasks[taskId].tTaskId_SceneryPal].tTimer = 0; + gTasks[gTasks[taskId].tTaskId_SceneryPal].tMainTaskId = taskId; - gTasks[taskIdA].data[TDA_TASK_C_ID] = CreateTask(sub_817624C, 0); - gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_0] = 0; - gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_1] = taskIdA; - gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_2] = gTasks[taskIdA].tPlayerSpriteId; - gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_3] = gTasks[taskIdA].tRivalSpriteId; - gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_4] = 0; + gTasks[taskId].tTaskId_BikeScene = CreateTask(Task_BikeScene, 0); + gTasks[gTasks[taskId].tTaskId_BikeScene].tState = 0; + gTasks[gTasks[taskId].tTaskId_BikeScene].data[1] = taskId; // data[1] is never read + gTasks[gTasks[taskId].tTaskId_BikeScene].tPlayer = gTasks[taskId].tPlayerSpriteId; + gTasks[gTasks[taskId].tTaskId_BikeScene].tRival = gTasks[taskId].tRivalSpriteId; + gTasks[gTasks[taskId].tTaskId_BikeScene].tDelay = 0; - if (scene == 2) - gTasks[gTasks[taskIdA].data[TDA_TASK_C_ID]].data[TDC_5] = 0x45; + if (scene == SCENE_FOREST_RIVAL_ARRIVE) + gTasks[gTasks[taskId].tTaskId_BikeScene].tSinIdx = 69; } -static bool8 sub_8176AB0(u8 scene, u8 taskIdA) +#undef tTimer +#undef tDelay +#undef tSinIdx +#undef tRival +#undef tPlayer + +static bool8 LoadBikeScene(u8 scene, u8 taskId) { u8 spriteId; @@ -1201,13 +1215,13 @@ static bool8 sub_8176AB0(u8 scene, u8 taskIdA) LoadSpritePalettes(gSpritePalettes_Credits); spriteId = CreateIntroBrendanSprite(120, 46); - gTasks[taskIdA].tPlayerSpriteId = spriteId; - gSprites[spriteId].callback = SpriteCB_PlayerCyclist; + gTasks[taskId].tPlayerSpriteId = spriteId; + gSprites[spriteId].callback = SpriteCB_Player; gSprites[spriteId].anims = sAnims_Player; - spriteId = CreateIntroMaySprite(272, 46); - gTasks[taskIdA].tRivalSpriteId = spriteId; - gSprites[spriteId].callback = SpriteCB_RivalCyclist; + spriteId = CreateIntroMaySprite(DISPLAY_WIDTH + 32, 46); + gTasks[taskId].tRivalSpriteId = spriteId; + gSprites[spriteId].callback = SpriteCB_Rival; gSprites[spriteId].anims = sAnims_Rival; } else @@ -1218,19 +1232,19 @@ static bool8 sub_8176AB0(u8 scene, u8 taskIdA) LoadSpritePalettes(gSpritePalettes_Credits); spriteId = CreateIntroMaySprite(120, 46); - gTasks[taskIdA].tPlayerSpriteId = spriteId; - gSprites[spriteId].callback = SpriteCB_PlayerCyclist; + gTasks[taskId].tPlayerSpriteId = spriteId; + gSprites[spriteId].callback = SpriteCB_Player; gSprites[spriteId].anims = sAnims_Player; - spriteId = CreateIntroBrendanSprite(272, 46); - gTasks[taskIdA].tRivalSpriteId = spriteId; - gSprites[spriteId].callback = SpriteCB_RivalCyclist; + spriteId = CreateIntroBrendanSprite(DISPLAY_WIDTH + 32, 46); + gTasks[taskId].tRivalSpriteId = spriteId; + gSprites[spriteId].callback = SpriteCB_Rival; gSprites[spriteId].anims = sAnims_Rival; }; gMain.state++; break; case 3: - InitCreditsSceneGfx(scene, taskIdA); + SetBikeScene(scene, taskId); SetCreditsSceneBgCnt(scene); gMain.state = 0; return TRUE; @@ -1238,30 +1252,34 @@ static bool8 sub_8176AB0(u8 scene, u8 taskIdA) return FALSE; } -static void ResetCreditsTasks(u8 taskIdA) +static void ResetCreditsTasks(u8 taskId) { - if (gTasks[taskIdA].data[TDA_0] != 0) + // Destroy Task_BicycleBgAnimation, if running + if (gTasks[taskId].tTaskId_BgScenery != 0) { - DestroyTask(gTasks[taskIdA].data[TDA_0]); - gTasks[taskIdA].data[TDA_0] = 0; + DestroyTask(gTasks[taskId].tTaskId_BgScenery); + gTasks[taskId].tTaskId_BgScenery = 0; } - if (gTasks[taskIdA].data[TDA_TASK_C_ID] != 0) + // Destroy Task_BikeScene, if running + if (gTasks[taskId].tTaskId_BikeScene != 0) { - DestroyTask(gTasks[taskIdA].data[TDA_TASK_C_ID]); - gTasks[taskIdA].data[TDA_TASK_C_ID] = 0; + DestroyTask(gTasks[taskId].tTaskId_BikeScene); + gTasks[taskId].tTaskId_BikeScene = 0; } - if (gTasks[taskIdA].data[TDA_TASK_E_ID] != 0) + // Destroy Task_CycleSceneryPalette, if running + if (gTasks[taskId].tTaskId_SceneryPal != 0) { - DestroyTask(gTasks[taskIdA].data[TDA_TASK_E_ID]); - gTasks[taskIdA].data[TDA_TASK_E_ID] = 0; + DestroyTask(gTasks[taskId].tTaskId_SceneryPal); + gTasks[taskId].tTaskId_SceneryPal = 0; } - if (gTasks[taskIdA].data[TDA_TASK_D_ID] != 0) + // Destroy Task_ShowMons, if running + if (gTasks[taskId].tTaskId_ShowMons != 0) { - DestroyTask(gTasks[taskIdA].data[TDA_TASK_D_ID]); - gTasks[taskIdA].data[TDA_TASK_D_ID] = 0; + DestroyTask(gTasks[taskId].tTaskId_ShowMons); + gTasks[taskId].tTaskId_ShowMons = 0; } gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_DESTROY; @@ -1326,7 +1344,7 @@ static void DrawTheEnd(u16 offset, u16 palette) #define sState data[0] -static void SpriteCB_PlayerCyclist(struct Sprite *sprite) +static void SpriteCB_Player(struct Sprite *sprite) { if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_NORMAL) { @@ -1363,7 +1381,7 @@ static void SpriteCB_PlayerCyclist(struct Sprite *sprite) } } -static void SpriteCB_RivalCyclist(struct Sprite *sprite) +static void SpriteCB_Rival(struct Sprite *sprite) { if (gIntroCredits_MovingSceneryState != INTROCRED_SCENERY_NORMAL) { @@ -1417,9 +1435,9 @@ static void SpriteCB_CreditsMon(struct Sprite *sprite) case 0: default: sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL; - sprite->oam.matrixNum = sprite->data[1]; + sprite->oam.matrixNum = sprite->sPosition; sprite->data[2] = 16; - SetOamMatrix(sprite->data[1], 0x10000 / sprite->data[2], 0, 0, 0x10000 / sprite->data[2]); + SetOamMatrix(sprite->sPosition, 0x10000 / sprite->data[2], 0, 0, 0x10000 / sprite->data[2]); sprite->invisible = FALSE; sprite->sState = 1; break; @@ -1427,7 +1445,7 @@ static void SpriteCB_CreditsMon(struct Sprite *sprite) if (sprite->data[2] < 256) { sprite->data[2] += 8; - SetOamMatrix(sprite->data[1], 0x10000 / sprite->data[2], 0, 0, 0x10000 / sprite->data[2]); + SetOamMatrix(sprite->sPosition, 0x10000 / sprite->data[2], 0, 0, 0x10000 / sprite->data[2]); } else { diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 7d3a7f28b0..4461a5e5da 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -71,7 +71,7 @@ static void ClearVramOamPltt_LoadHofPal(void); static void LoadHofGfx(void); static void InitHofBgs(void); static bool8 CreateHofConfettiSprite(void); -static void SetCallback2AfterHallOfFameDisplay(void); +static void StartCredits(void); static bool8 sub_8175024(void); static void Task_Hof_InitMonData(u8 taskId); static void Task_Hof_InitTeamSaveData(u8 taskId); @@ -774,11 +774,11 @@ static void Task_Hof_HandleExit(u8 taskId) if (sHofMonPtr != NULL) FREE_AND_SET_NULL(sHofMonPtr); - SetCallback2AfterHallOfFameDisplay(); + StartCredits(); } } -static void SetCallback2AfterHallOfFameDisplay(void) +static void StartCredits(void) { SetMainCallback2(CB2_StartCreditsSequence); } diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c index 401d077ef7..d19a3deea4 100644 --- a/src/intro_credits_graphics.c +++ b/src/intro_credits_graphics.c @@ -38,19 +38,19 @@ struct IntroCreditsSpriteMetadata }; static const u16 sGrass_Pal[] = INCBIN_U16("graphics/intro/scene_2/grass.gbapal"); -static const u16 sGrassAfternoon_Pal[] = INCBIN_U16("graphics/intro/scene_2/grass_afternoon.gbapal"); +static const u16 sGrassSunset_Pal[] = INCBIN_U16("graphics/intro/scene_2/grass_sunset.gbapal"); static const u16 sGrassNight_Pal[] = INCBIN_U16("graphics/intro/scene_2/grass_night.gbapal"); static const u32 sGrass_Gfx[] = INCBIN_U32("graphics/intro/scene_2/grass.4bpp.lz"); static const u32 sGrass_Tilemap[] = INCBIN_U32("graphics/intro/scene_2/grass_map.bin.lz"); static const u16 sCloudsBg_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds_bg.gbapal"); -static const u16 sCloudsBgAfternoon_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds_bg_afternoon.gbapal"); +static const u16 sCloudsBgSunset_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds_bg_sunset.gbapal"); static const u32 sCloudsBg_Gfx[] = INCBIN_U32("graphics/intro/scene_2/clouds_bg.4bpp.lz"); static const u32 sCloudsBg_Tilemap[] = INCBIN_U32("graphics/intro/scene_2/clouds_bg_map.bin.lz"); static const u16 sClouds_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds.gbapal"); -static const u16 sCloudsAfternoon_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds_afternoon.gbapal"); +static const u16 sCloudsSunset_Pal[] = INCBIN_U16("graphics/intro/scene_2/clouds_sunset.gbapal"); static const u32 sClouds_Gfx[] = INCBIN_U32("graphics/intro/scene_2/clouds.4bpp.lz"); static const u16 sTrees_Pal[] = INCBIN_U16("graphics/intro/scene_2/trees.gbapal"); -static const u16 sTreesAfternoon_Pal[] = INCBIN_U16("graphics/intro/scene_2/trees_afternoon.gbapal"); +static const u16 sTreesSunset_Pal[] = INCBIN_U16("graphics/intro/scene_2/trees_sunset.gbapal"); static const u32 sTrees_Gfx[] = INCBIN_U32("graphics/intro/scene_2/trees.4bpp.lz"); static const u32 sTrees_Tilemap[] = INCBIN_U32("graphics/intro/scene_2/trees_map.bin.lz"); static const u16 sTreesSmall_Pal[] = INCBIN_U16("graphics/intro/scene_2/trees_small.gbapal"); @@ -97,25 +97,25 @@ static const struct CompressedSpriteSheet sSpriteSheet_Clouds[] = {} }; -static const union AnimCmd gUnknown_085F5074[] = +static const union AnimCmd sAnim_Cloud_Largest[] = { ANIMCMD_FRAME( 0, 30), ANIMCMD_END }; -static const union AnimCmd gUnknown_085F507C[] = +static const union AnimCmd sAnim_Cloud_Large[] = { ANIMCMD_FRAME(16, 30), ANIMCMD_END }; -static const union AnimCmd gUnknown_085F5084[] = +static const union AnimCmd sAnim_Cloud_Small[] = { ANIMCMD_FRAME(20, 30), ANIMCMD_END }; -static const union AnimCmd gUnknown_085F508C[] = +static const union AnimCmd sAnim_Cloud_Smallest[] = { ANIMCMD_FRAME(22, 30), ANIMCMD_END @@ -123,10 +123,10 @@ static const union AnimCmd gUnknown_085F508C[] = static const union AnimCmd *const sAnims_Clouds[] = { - gUnknown_085F5074, - gUnknown_085F507C, - gUnknown_085F5084, - gUnknown_085F508C + sAnim_Cloud_Largest, + sAnim_Cloud_Large, + sAnim_Cloud_Small, + sAnim_Cloud_Smallest }; static const struct IntroCreditsSpriteMetadata sSpriteMetadata_Clouds[] = @@ -224,29 +224,29 @@ static const struct CompressedSpriteSheet sSpriteSheet_TreesSmall[] = {} }; -static const union AnimCmd gUnknown_085F50FC[] = +static const union AnimCmd sAnim_Trees_0[] = { ANIMCMD_FRAME( 0, 30), ANIMCMD_END }; -static const union AnimCmd gUnknown_085F5104[] = +static const union AnimCmd sAnim_Trees_1[] = { ANIMCMD_FRAME(16, 30), ANIMCMD_END }; -static const union AnimCmd gUnknown_085F510C[] = +static const union AnimCmd sAnim_Trees_2[] = { ANIMCMD_FRAME(24, 30), ANIMCMD_END }; -static const union AnimCmd *const sAnims_TreesSmall[] = +static const union AnimCmd *const sAnims_Trees[] = { - gUnknown_085F50FC, - gUnknown_085F5104, - gUnknown_085F510C + sAnim_Trees_0, + sAnim_Trees_1, + sAnim_Trees_2 }; static const struct IntroCreditsSpriteMetadata sSpriteMetadata_Trees[] = @@ -726,12 +726,12 @@ static void CreateTreeSprites(void); static void CreateHouseSprites(void); static void Task_BicycleBgAnimation(u8); -void LoadIntroPart2Graphics(u8 scene) +void LoadIntroPart2Graphics(u8 scenery) { LZ77UnCompVram(sGrass_Gfx, (void *)(BG_CHAR_ADDR(1))); LZ77UnCompVram(sGrass_Tilemap, (void *)(BG_SCREEN_ADDR(15))); LoadPalette(&sGrass_Pal, 240, sizeof(sGrass_Pal)); - switch (scene) + switch (scenery) { case 0: default: @@ -758,10 +758,10 @@ void LoadIntroPart2Graphics(u8 scene) } // Note: This is only called with a=1. -void SetIntroPart2BgCnt(u8 scene) +void SetIntroPart2BgCnt(u8 scenery) { - // Only called with scene = 1 - switch (scene) + // Only called with scenery = 1 + switch (scenery) { default: case 0: @@ -842,7 +842,7 @@ void LoadCreditsSceneGraphics(u8 scene) LZ77UnCompVram(sGrass_Tilemap, (void *)(BG_SCREEN_ADDR(15))); switch (scene) { - case 0: + case SCENE_OCEAN_MORNING: default: LoadPalette(&sGrass_Pal, 240, sizeof(sGrass_Pal)); LZ77UnCompVram(sCloudsBg_Gfx, (void *)(VRAM)); @@ -853,27 +853,27 @@ void LoadCreditsSceneGraphics(u8 scene) LoadPalette(&sClouds_Pal, 256, sizeof(sClouds_Pal)); CreateCloudSprites(); break; - case 1: - LoadPalette(&sGrassAfternoon_Pal, 240, sizeof(sGrassAfternoon_Pal)); + case SCENE_OCEAN_SUNSET: + LoadPalette(&sGrassSunset_Pal, 240, sizeof(sGrassSunset_Pal)); LZ77UnCompVram(sCloudsBg_Gfx, (void *)(VRAM)); LZ77UnCompVram(sCloudsBg_Tilemap, (void *)(BG_SCREEN_ADDR(6))); - LoadPalette(&sCloudsBgAfternoon_Pal, 0, sizeof(sCloudsBgAfternoon_Pal)); + LoadPalette(&sCloudsBgSunset_Pal, 0, sizeof(sCloudsBgSunset_Pal)); LoadCompressedSpriteSheet(sSpriteSheet_Clouds); LZ77UnCompVram(sClouds_Gfx, (void *)(OBJ_VRAM0)); - LoadPalette(&sCloudsAfternoon_Pal, 256, sizeof(sCloudsAfternoon_Pal)); + LoadPalette(&sCloudsSunset_Pal, 256, sizeof(sCloudsSunset_Pal)); CreateCloudSprites(); break; - case 2: - case 3: - LoadPalette(&sGrassAfternoon_Pal, 240, sizeof(sGrassAfternoon_Pal)); + case SCENE_FOREST_RIVAL_ARRIVE: + case SCENE_FOREST_CATCH_RIVAL: + LoadPalette(&sGrassSunset_Pal, 240, sizeof(sGrassSunset_Pal)); LZ77UnCompVram(sTrees_Gfx, (void *)(VRAM)); LZ77UnCompVram(sTrees_Tilemap, (void *)(BG_SCREEN_ADDR(6))); - LoadPalette(&sTreesAfternoon_Pal, 0, sizeof(sTreesAfternoon_Pal)); + LoadPalette(&sTreesSunset_Pal, 0, sizeof(sTreesSunset_Pal)); LoadCompressedSpriteSheet(sSpriteSheet_TreesSmall); - LoadPalette(&sTreesAfternoon_Pal, 256, sizeof(sTreesAfternoon_Pal)); + LoadPalette(&sTreesSunset_Pal, 256, sizeof(sTreesSunset_Pal)); CreateTreeSprites(); break; - case 4: + case SCENE_CITY_NIGHT: LoadPalette(&sGrassNight_Pal, 240, sizeof(sGrassNight_Pal)); LZ77UnCompVram(sHouses_Gfx, (void *)(VRAM)); LZ77UnCompVram(sHouses_Tilemap, (void *)(BG_SCREEN_ADDR(6))); @@ -987,11 +987,11 @@ static void Task_BicycleBgAnimation(u8 taskId) } } -void CycleSceneryPalette(u8 scene) +void CycleSceneryPalette(u8 mode) { u16 x; u16 y; - switch (scene) + switch (mode) { case 0: default: @@ -1031,6 +1031,10 @@ void CycleSceneryPalette(u8 scene) } } +#define tHasVerticalMove data[0] +#define tXOffset data[1] +#define tXPos data[2] + static void SpriteCB_MovingScenery(struct Sprite *sprite) { s32 x; @@ -1044,12 +1048,12 @@ static void SpriteCB_MovingScenery(struct Sprite *sprite) DestroySprite(sprite); break; case INTROCRED_SCENERY_NORMAL: - x = ((sprite->pos1.x << 16) | (u16)sprite->data[2]) + (u16)sprite->data[1]; + x = ((sprite->pos1.x << 16) | (u16)sprite->tXPos) + (u16)sprite->tXOffset; sprite->pos1.x = x >> 16; - sprite->data[2] = x; - if (sprite->pos1.x > 0xFF) - sprite->pos1.x = -0x20; - if (sprite->data[0]) + sprite->tXPos = x; + if (sprite->pos1.x > 255) + sprite->pos1.x = -32; + if (sprite->tHasVerticalMove) sprite->pos2.y = -(gIntroCredits_MovingSceneryVBase + gIntroCredits_MovingSceneryVOffset); else sprite->pos2.y = -gIntroCredits_MovingSceneryVBase; @@ -1058,7 +1062,7 @@ static void SpriteCB_MovingScenery(struct Sprite *sprite) } } -static void CreateMovingScenerySprites(bool8 a, const struct IntroCreditsSpriteMetadata *metadata, const union AnimCmd *const *anims, u8 numSprites) +static void CreateMovingScenerySprites(bool8 hasVerticalMove, const struct IntroCreditsSpriteMetadata *metadata, const union AnimCmd *const *anims, u8 numSprites) { u8 i; @@ -1072,12 +1076,16 @@ static void CreateMovingScenerySprites(bool8 a, const struct IntroCreditsSpriteM gSprites[sprite].oam.paletteNum = 0; gSprites[sprite].anims = anims; StartSpriteAnim(&gSprites[sprite], metadata[i].animNum); - gSprites[sprite].data[0] = a; - gSprites[sprite].data[1] = metadata[i].xOff; - gSprites[sprite].data[2] = 0; + gSprites[sprite].tHasVerticalMove = hasVerticalMove; + gSprites[sprite].tXOffset = metadata[i].xOff; + gSprites[sprite].tXPos = 0; } } +#undef tHasVerticalMove +#undef tXOffset +#undef tXPos + static void CreateCloudSprites(void) { CreateMovingScenerySprites(FALSE, sSpriteMetadata_Clouds, sAnims_Clouds, 9); @@ -1085,7 +1093,7 @@ static void CreateCloudSprites(void) static void CreateTreeSprites(void) { - CreateMovingScenerySprites(TRUE, sSpriteMetadata_Trees, sAnims_TreesSmall, 12); + CreateMovingScenerySprites(TRUE, sSpriteMetadata_Trees, sAnims_Trees, 12); } static void CreateHouseSprites(void) From dea07dc8656c8fb32f5b389b9f4f9a30fe26e555 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 29 Mar 2021 20:31:21 -0400 Subject: [PATCH 19/31] Standardize intro gfx names --- .../scene_3/{clouds1.bin => clouds_left.bin} | Bin .../scene_3/{clouds2.bin => clouds_right.bin} | Bin .../scene_3/{clouds3.bin => clouds_sun.bin} | Bin .../{legend_bg1.bin => groudon_bg.bin} | Bin .../scene_3/{legend_bg2.bin => kyogre_bg.bin} | 0 .../intro/scene_3/{misc2.pal => misc.pal} | 0 .../{clouds4.bin => rayquaza_clouds.bin} | Bin .../{clouds2.png => rayquaza_clouds.png} | Bin .../scene_3/{misc1.pal => rayquaza_orb.pal} | 0 .../scene_3/unused_1.bin} | Bin .../scene_3/unused_2.bin} | Bin include/graphics.h | 69 ++++---- src/data/graphics/intro_scene.h | 73 ++++---- src/intro.c | 160 +++++++++--------- src/intro_credits_graphics.c | 16 +- 15 files changed, 158 insertions(+), 160 deletions(-) rename graphics/intro/scene_3/{clouds1.bin => clouds_left.bin} (100%) rename graphics/intro/scene_3/{clouds2.bin => clouds_right.bin} (100%) rename graphics/intro/scene_3/{clouds3.bin => clouds_sun.bin} (100%) rename graphics/intro/scene_3/{legend_bg1.bin => groudon_bg.bin} (100%) rename graphics/intro/scene_3/{legend_bg2.bin => kyogre_bg.bin} (100%) rename graphics/intro/scene_3/{misc2.pal => misc.pal} (100%) rename graphics/intro/scene_3/{clouds4.bin => rayquaza_clouds.bin} (100%) rename graphics/intro/scene_3/{clouds2.png => rayquaza_clouds.png} (100%) rename graphics/intro/scene_3/{misc1.pal => rayquaza_orb.pal} (100%) rename graphics/{unknown/unknown_D8C374.bin => intro/scene_3/unused_1.bin} (100%) rename graphics/{unknown/unknown_D8C5C4.bin => intro/scene_3/unused_2.bin} (100%) diff --git a/graphics/intro/scene_3/clouds1.bin b/graphics/intro/scene_3/clouds_left.bin similarity index 100% rename from graphics/intro/scene_3/clouds1.bin rename to graphics/intro/scene_3/clouds_left.bin diff --git a/graphics/intro/scene_3/clouds2.bin b/graphics/intro/scene_3/clouds_right.bin similarity index 100% rename from graphics/intro/scene_3/clouds2.bin rename to graphics/intro/scene_3/clouds_right.bin diff --git a/graphics/intro/scene_3/clouds3.bin b/graphics/intro/scene_3/clouds_sun.bin similarity index 100% rename from graphics/intro/scene_3/clouds3.bin rename to graphics/intro/scene_3/clouds_sun.bin diff --git a/graphics/intro/scene_3/legend_bg1.bin b/graphics/intro/scene_3/groudon_bg.bin similarity index 100% rename from graphics/intro/scene_3/legend_bg1.bin rename to graphics/intro/scene_3/groudon_bg.bin diff --git a/graphics/intro/scene_3/legend_bg2.bin b/graphics/intro/scene_3/kyogre_bg.bin similarity index 100% rename from graphics/intro/scene_3/legend_bg2.bin rename to graphics/intro/scene_3/kyogre_bg.bin diff --git a/graphics/intro/scene_3/misc2.pal b/graphics/intro/scene_3/misc.pal similarity index 100% rename from graphics/intro/scene_3/misc2.pal rename to graphics/intro/scene_3/misc.pal diff --git a/graphics/intro/scene_3/clouds4.bin b/graphics/intro/scene_3/rayquaza_clouds.bin similarity index 100% rename from graphics/intro/scene_3/clouds4.bin rename to graphics/intro/scene_3/rayquaza_clouds.bin diff --git a/graphics/intro/scene_3/clouds2.png b/graphics/intro/scene_3/rayquaza_clouds.png similarity index 100% rename from graphics/intro/scene_3/clouds2.png rename to graphics/intro/scene_3/rayquaza_clouds.png diff --git a/graphics/intro/scene_3/misc1.pal b/graphics/intro/scene_3/rayquaza_orb.pal similarity index 100% rename from graphics/intro/scene_3/misc1.pal rename to graphics/intro/scene_3/rayquaza_orb.pal diff --git a/graphics/unknown/unknown_D8C374.bin b/graphics/intro/scene_3/unused_1.bin similarity index 100% rename from graphics/unknown/unknown_D8C374.bin rename to graphics/intro/scene_3/unused_1.bin diff --git a/graphics/unknown/unknown_D8C5C4.bin b/graphics/intro/scene_3/unused_2.bin similarity index 100% rename from graphics/unknown/unknown_D8C5C4.bin rename to graphics/intro/scene_3/unused_2.bin diff --git a/include/graphics.h b/include/graphics.h index 9af68a052d..1d39eb1f5e 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -3874,44 +3874,43 @@ extern const u32 gBagPalette[]; extern const u32 gBerryCheckCircle_Gfx[]; //intro graphics -extern const u32 gIntro1Sparkle_Gfx[]; -extern const u32 gIntro1Flygon_Gfx[]; -extern const u16 gIntro3LightningPal[]; +extern const u32 gIntroSparkle_Gfx[]; +extern const u32 gIntroFlygonSilhouette_Gfx[]; +extern const u32 gIntroLightning_Gfx[]; +extern const u16 gIntroLightning_Pal[]; extern const u32 gIntroCopyright_Gfx[]; extern const u32 gIntroCopyright_Tilemap[]; extern const u16 gIntroCopyright_Pal[16]; -extern const u32 gIntro2VolbeatGfx[]; -extern const u32 gIntro2TorchicGfx[]; -extern const u32 gIntro2ManectricGfx[]; -extern const u16 gIntro2VolbeatPal[]; -extern const u16 gIntro2TorchicPal[]; -extern const u16 gIntro2ManectricPal[]; -extern const u32 gIntro3Bubbles_Gfx[]; -extern const u16 gIntro3Bubbles_Pal[]; -extern const u32 gIntro3LightningGfx[]; -extern const u32 gIntro3GroudonGfx[]; -extern const u32 gIntro3GroudonTilemap[]; -extern const u32 gIntro3LegendBgGfx[]; -extern const u32 gIntro3GroudonBgTilemap[]; -extern const u32 gIntro3GroudonBgTilemap[]; -extern const u8 gIntro3BgPal[0x200]; -extern const u32 gIntro3KyogreGfx[]; -extern const u32 gIntro3KyogreTilemap[]; -extern const u32 gIntro3KyogreBgTilemap[]; -extern const u32 gIntro3CloudsGfx[]; -extern const u32 gIntro3Clouds1Tilemap[]; -extern const u32 gIntro3Clouds2Tilemap[]; -extern const u32 gIntro3Clouds3Tilemap[]; -extern const u32 gIntro3Clouds4Tilemap[]; -extern const u32 gIntro3RayquazaTilemap[]; -extern const u32 gIntro3RayquazaGfx[]; -extern const u32 gIntro3Clouds2Gfx[]; -extern const u16 gIntro1GameFreakTextFadePal[]; -extern const u32 gIntro2BrendanGfx[]; -extern const u32 gIntro2MayGfx[]; -extern const u16 gIntro2PlayerPal[]; -extern const u16 gIntro2FlygonPal[]; -extern const u32 gIntro2FlygonGfx[]; +extern const u32 gIntroVolbeat_Gfx[]; +extern const u16 gIntroVolbeat_Pal[]; +extern const u32 gIntroTorchic_Gfx[]; +extern const u16 gIntroTorchic_Pal[]; +extern const u32 gIntroManectric_Gfx[]; +extern const u16 gIntroManectric_Pal[]; +extern const u32 gIntroBubbles_Gfx[]; +extern const u16 gIntroBubbles_Pal[]; +extern const u32 gIntroGroudon_Gfx[]; +extern const u32 gIntroGroudon_Tilemap[]; +extern const u32 gIntroLegendBg_Gfx[]; +extern const u32 gIntroGroudonBg_Tilemap[]; +extern const u8 gIntro3Bg_Pal[0x200]; +extern const u32 gIntroKyogre_Gfx[]; +extern const u32 gIntroKyogre_Tilemap[]; +extern const u32 gIntroKyogreBg_Tilemap[]; +extern const u32 gIntroClouds_Gfx[]; +extern const u32 gIntroCloudsLeft_Tilemap[]; +extern const u32 gIntroCloudsRight_Tilemap[]; +extern const u32 gIntroCloudsSun_Tilemap[]; +extern const u32 gIntroRayquaza_Tilemap[]; +extern const u32 gIntroRayquaza_Gfx[]; +extern const u32 gIntroRayquazaClouds_Gfx[]; +extern const u32 gIntroRayquazaClouds_Tilemap[]; +extern const u16 gIntroGameFreakTextFade_Pal[]; +extern const u32 gIntroBrendan_Gfx[]; +extern const u32 gIntroMay_Gfx[]; +extern const u16 gIntroPlayer_Pal[]; +extern const u16 gIntroFlygon_Pal[]; +extern const u32 gIntroFlygon_Gfx[]; // party menu graphics extern const u32 gPartyMenuBg_Gfx[]; diff --git a/src/data/graphics/intro_scene.h b/src/data/graphics/intro_scene.h index ab1cdcd9c2..cb7706c9a3 100644 --- a/src/data/graphics/intro_scene.h +++ b/src/data/graphics/intro_scene.h @@ -1,48 +1,47 @@ -const u16 gIntro1GameFreakTextFadePal[] = INCBIN_U16("graphics/intro/scene_1/text.gbapal"); // game freak text blue fade -const u16 gIntro2PlayerPal[] = INCBIN_U16("graphics/intro/scene_2/player.gbapal"); -const u16 gIntro3BgPal[] = INCBIN_U16("graphics/intro/scene_3/bg.gbapal"); -const u16 gIntro2VolbeatPal[] = INCBIN_U16("graphics/intro/scene_2/volbeat.gbapal"); -const u16 gIntro2TorchicPal[] = INCBIN_U16("graphics/intro/scene_2/torchic.gbapal"); -const u16 gIntro2ManectricPal[] = INCBIN_U16("graphics/intro/scene_2/manectric.gbapal"); -const u16 gIntro2FlygonPal[] = INCBIN_U16("graphics/intro/scene_2/flygon.gbapal"); +const u16 gIntroGameFreakTextFade_Pal[] = INCBIN_U16("graphics/intro/scene_1/text.gbapal"); // game freak text blue fade +const u16 gIntroPlayer_Pal[] = INCBIN_U16("graphics/intro/scene_2/player.gbapal"); +const u16 gIntro3Bg_Pal[] = INCBIN_U16("graphics/intro/scene_3/bg.gbapal"); +const u16 gIntroVolbeat_Pal[] = INCBIN_U16("graphics/intro/scene_2/volbeat.gbapal"); +const u16 gIntroTorchic_Pal[] = INCBIN_U16("graphics/intro/scene_2/torchic.gbapal"); +const u16 gIntroManectric_Pal[] = INCBIN_U16("graphics/intro/scene_2/manectric.gbapal"); +const u16 gIntroFlygon_Pal[] = INCBIN_U16("graphics/intro/scene_2/flygon.gbapal"); -const u32 gIntro2VolbeatGfx[] = INCBIN_U32("graphics/intro/scene_2/volbeat.4bpp.lz"); -const u32 gIntro2TorchicGfx[] = INCBIN_U32("graphics/intro/scene_2/torchic.4bpp.lz"); -const u32 gIntro2ManectricGfx[] = INCBIN_U32("graphics/intro/scene_2/manectric.4bpp.lz"); -const u32 gIntro2FlygonGfx[] = INCBIN_U32("graphics/intro/scene_2/flygon.4bpp.lz"); -const u32 gIntro2BrendanGfx[] = INCBIN_U32("graphics/intro/scene_2/brendan.4bpp.lz"); -const u32 gIntro2MayGfx[] = INCBIN_U32("graphics/intro/scene_2/may.4bpp.lz"); +const u32 gIntroVolbeat_Gfx[] = INCBIN_U32("graphics/intro/scene_2/volbeat.4bpp.lz"); +const u32 gIntroTorchic_Gfx[] = INCBIN_U32("graphics/intro/scene_2/torchic.4bpp.lz"); +const u32 gIntroManectric_Gfx[] = INCBIN_U32("graphics/intro/scene_2/manectric.4bpp.lz"); +const u32 gIntroFlygon_Gfx[] = INCBIN_U32("graphics/intro/scene_2/flygon.4bpp.lz"); +const u32 gIntroBrendan_Gfx[] = INCBIN_U32("graphics/intro/scene_2/brendan.4bpp.lz"); +const u32 gIntroMay_Gfx[] = INCBIN_U32("graphics/intro/scene_2/may.4bpp.lz"); -const u32 gIntro3GroudonGfx[] = INCBIN_U32("graphics/intro/scene_3/groudon.8bpp.lz"); -const u32 gIntro3GroudonTilemap[] = INCBIN_U32("graphics/intro/scene_3/groudon.bin.lz"); +const u32 gIntroGroudon_Gfx[] = INCBIN_U32("graphics/intro/scene_3/groudon.8bpp.lz"); +const u32 gIntroGroudon_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/groudon.bin.lz"); -const u32 gIntro3KyogreGfx[] = INCBIN_U32("graphics/intro/scene_3/kyogre.8bpp.lz"); -const u32 gIntro3KyogreTilemap[] = INCBIN_U32("graphics/intro/scene_3/kyogre.bin.lz"); +const u32 gIntroKyogre_Gfx[] = INCBIN_U32("graphics/intro/scene_3/kyogre.8bpp.lz"); +const u32 gIntroKyogre_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/kyogre.bin.lz"); -const u32 gIntro3LegendBgGfx[] = INCBIN_U32("graphics/intro/scene_3/legend_bg.4bpp.lz"); // groudon/kyogre bg +const u32 gIntroLegendBg_Gfx[] = INCBIN_U32("graphics/intro/scene_3/legend_bg.4bpp.lz"); // groudon/kyogre bg +const u32 gIntroGroudonBg_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/groudon_bg.bin.lz"); +const u32 gIntroKyogreBg_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/kyogre_bg.bin.lz"); -const u32 gIntro3GroudonBgTilemap[] = INCBIN_U32("graphics/intro/scene_3/legend_bg1.bin.lz"); -const u32 gIntro3KyogreBgTilemap[] = INCBIN_U32("graphics/intro/scene_3/legend_bg2.bin.lz"); +const u32 gIntroClouds_Gfx[] = INCBIN_U32("graphics/intro/scene_3/clouds.4bpp.lz"); +const u32 gIntroCloudsLeft_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds_left.bin.lz"); +const u32 gIntroCloudsRight_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds_right.bin.lz"); +const u32 gIntroCloudsSun_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds_sun.bin.lz"); -const u32 gIntro3CloudsGfx[] = INCBIN_U32("graphics/intro/scene_3/clouds.4bpp.lz"); -const u32 gIntro3Clouds1Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds1.bin.lz"); -const u32 gIntro3Clouds2Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds2.bin.lz"); -const u32 gIntro3Clouds3Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds3.bin.lz"); +const u32 gIntroLightning_Gfx[] = INCBIN_U32("graphics/intro/scene_3/lightning.4bpp.lz"); +const u16 gIntroLightning_Pal[] = INCBIN_U16("graphics/intro/scene_3/lightning.gbapal"); -const u32 gIntro3LightningGfx[] = INCBIN_U32("graphics/intro/scene_3/lightning.4bpp.lz"); -const u16 gIntro3LightningPal[] = INCBIN_U16("graphics/intro/scene_3/lightning.gbapal"); +const u32 gIntroRayquaza_Gfx[] = INCBIN_U32("graphics/intro/scene_3/rayquaza.4bpp.lz"); +const u32 gIntroRayquaza_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/rayquaza.bin.lz"); -const u32 gIntro3RayquazaGfx[] = INCBIN_U32("graphics/intro/scene_3/rayquaza.4bpp.lz"); -const u32 gIntro3RayquazaTilemap[] = INCBIN_U32("graphics/intro/scene_3/rayquaza.bin.lz"); +const u32 gIntroUnused1_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/unused_1.bin.lz"); +const u32 gIntroUnused2_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/unused_2.bin.lz"); -const u32 gUnknown_D8C374[] = INCBIN_U32("graphics/unknown/unknown_D8C374.bin.lz"); -const u32 gUnknown_D8C5C4[] = INCBIN_U32("graphics/unknown/unknown_D8C5C4.bin.lz"); +const u32 gIntroRayquazaClouds_Gfx[] = INCBIN_U32("graphics/intro/scene_3/rayquaza_clouds.4bpp.lz"); +const u32 gIntroRayquazaClouds_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/rayquaza_clouds.bin.lz"); -const u32 gIntro3Clouds2Gfx[] = INCBIN_U32("graphics/intro/scene_3/clouds2.4bpp.lz"); // during the rayquaza flash -const u32 gIntro3Clouds4Tilemap[] = INCBIN_U32("graphics/intro/scene_3/clouds4.bin.lz"); +const u32 gIntroBubbles_Gfx[] = INCBIN_U32("graphics/intro/scene_3/bubbles.4bpp.lz"); +const u16 gIntroBubbles_Pal[] = INCBIN_U16("graphics/intro/scene_3/bubbles.gbapal"); -const u32 gIntro3Bubbles_Gfx[] = INCBIN_U32("graphics/intro/scene_3/bubbles.4bpp.lz"); -const u16 gIntro3Bubbles_Pal[] = INCBIN_U16("graphics/intro/scene_3/bubbles.gbapal"); - -const u32 gIntro1Flygon_Gfx[] = INCBIN_U32("graphics/intro/scene_1/flygon.4bpp.lz"); -const u32 gIntro1Sparkle_Gfx[] = INCBIN_U32("graphics/intro/scene_1/sparkle.4bpp.lz"); +const u32 gIntroFlygonSilhouette_Gfx[] = INCBIN_U32("graphics/intro/scene_1/flygon.4bpp.lz"); +const u32 gIntroSparkle_Gfx[] = INCBIN_U32("graphics/intro/scene_1/sparkle.4bpp.lz"); diff --git a/src/intro.c b/src/intro.c index 2597e5a9e8..a8468d518c 100644 --- a/src/intro.c +++ b/src/intro.c @@ -175,26 +175,26 @@ static EWRAM_DATA u16 sFlygonYOffset = 0; u32 gIntroFrameCounter; struct GcmbStruct gMultibootProgramStruct; -static const u16 sIntro1DropsPal[] = INCBIN_U16("graphics/intro/scene_1/drops.gbapal"); -static const u16 sIntro1Logo_Pal[] = INCBIN_U16("graphics/intro/scene_1/logo.gbapal"); -static const u32 sIntro1DropsLogo_Gfx[] = INCBIN_U32("graphics/intro/scene_1/drops_logo.4bpp.lz"); -static const u16 sIntro1Bg_Pal[16][16] = INCBIN_U16("graphics/intro/scene_1/bg.gbapal"); -static const u32 sIntro1Bg0_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg0_map.bin.lz"); -static const u32 sIntro1Bg1_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg1_map.bin.lz"); -static const u32 sIntro1Bg2_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg2_map.bin.lz"); -static const u32 sIntro1Bg3_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg3_map.bin.lz"); -static const u32 sIntro1Bg_Gfx[] = INCBIN_U32("graphics/intro/scene_1/bg.4bpp.lz"); -static const u16 sIntro3Pokeball_Pal[] = INCBIN_U16("graphics/intro/scene_3/pokeball.gbapal"); -static const u32 sIntro3Pokeball_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/pokeball_map.bin.lz"); -static const u32 sIntro3Pokeball_Gfx[] = INCBIN_U32("graphics/intro/scene_3/pokeball.8bpp.lz"); -static const u16 sIntro3Streaks_Pal[] = INCBIN_U16("graphics/intro/scene_3/streaks.gbapal"); // Unused -static const u32 sIntro3Streaks_Gfx[] = INCBIN_U32("graphics/intro/scene_3/streaks.4bpp.lz"); // Unused -static const u32 sIntro3Streaks_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/streaks_map.bin.lz"); // Unused -static const u16 sIntro3Misc1_Pal[] = INCBIN_U16("graphics/intro/scene_3/misc1.gbapal"); -static const u16 sIntro3Misc2_Pal[] = INCBIN_U16("graphics/intro/scene_3/misc2.gbapal"); // Unused -static const u32 sIntro3Misc_Gfx[] = INCBIN_U32("graphics/intro/scene_3/misc.4bpp.lz"); -static const u16 sIntro1Flygon_Pal[] = INCBIN_U16("graphics/intro/scene_1/flygon.gbapal"); -static const u32 sIntro1Lati_Gfx[] = INCBIN_U32("graphics/intro/scene_1/lati.4bpp.lz"); // Unused +static const u16 sIntroDrops_Pal[] = INCBIN_U16("graphics/intro/scene_1/drops.gbapal"); +static const u16 sIntroLogo_Pal[] = INCBIN_U16("graphics/intro/scene_1/logo.gbapal"); +static const u32 sIntroDropsLogo_Gfx[] = INCBIN_U32("graphics/intro/scene_1/drops_logo.4bpp.lz"); +static const u16 sIntro1Bg_Pal[16][16] = INCBIN_U16("graphics/intro/scene_1/bg.gbapal"); +static const u32 sIntro1Bg0_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg0_map.bin.lz"); +static const u32 sIntro1Bg1_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg1_map.bin.lz"); +static const u32 sIntro1Bg2_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg2_map.bin.lz"); +static const u32 sIntro1Bg3_Tilemap[] = INCBIN_U32("graphics/intro/scene_1/bg3_map.bin.lz"); +static const u32 sIntro1Bg_Gfx[] = INCBIN_U32("graphics/intro/scene_1/bg.4bpp.lz"); +static const u16 sIntroPokeball_Pal[] = INCBIN_U16("graphics/intro/scene_3/pokeball.gbapal"); +static const u32 sIntroPokeball_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/pokeball_map.bin.lz"); +static const u32 sIntroPokeball_Gfx[] = INCBIN_U32("graphics/intro/scene_3/pokeball.8bpp.lz"); +static const u16 sIntroStreaks_Pal[] = INCBIN_U16("graphics/intro/scene_3/streaks.gbapal"); // Unused +static const u32 sIntroStreaks_Gfx[] = INCBIN_U32("graphics/intro/scene_3/streaks.4bpp.lz"); // Unused +static const u32 sIntroStreaks_Tilemap[] = INCBIN_U32("graphics/intro/scene_3/streaks_map.bin.lz"); // Unused +static const u16 sIntroRayquzaOrb_Pal[] = INCBIN_U16("graphics/intro/scene_3/rayquaza_orb.gbapal"); +static const u16 sIntroMisc_Pal[] = INCBIN_U16("graphics/intro/scene_3/misc.gbapal"); // Unused +static const u32 sIntroMisc_Gfx[] = INCBIN_U32("graphics/intro/scene_3/misc.4bpp.lz"); // Rayquza orb, and misc unused gfx +static const u16 sIntroFlygonSilhouette_Pal[] = INCBIN_U16("graphics/intro/scene_1/flygon.gbapal"); +static const u32 sIntroLati_Gfx[] = INCBIN_U32("graphics/intro/scene_1/lati.4bpp.lz"); // Unused static const u8 sUnusedData[] = { 0x02, 0x03, 0x04, 0x05, 0x01, 0x01, 0x01, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x02, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x02, 0x0D, 0x0E, 0x0F, @@ -203,12 +203,12 @@ static const u8 sUnusedData[] = { }; static const struct CompressedSpriteSheet sSpriteSheet_Sparkle[] = { - {gIntro1Sparkle_Gfx, 0x400, TAG_SPARKLE}, + {gIntroSparkle_Gfx, 0x400, TAG_SPARKLE}, {}, }; static const struct SpritePalette sSpritePalette_Sparkle[] = { - {gIntro3LightningPal, TAG_SPARKLE}, // Lightning palette re-used + {gIntroLightning_Pal, TAG_SPARKLE}, // Lightning palette re-used {}, }; static const struct OamData sOamData_Sparkle = @@ -267,16 +267,16 @@ static const u8 sSparkleCoords[][2] = }; static const struct CompressedSpriteSheet sSpriteSheet_RunningPokemon[] = { - {gIntro2VolbeatGfx, 0x400, TAG_VOLBEAT}, - {gIntro2TorchicGfx, 0xC00, TAG_TORCHIC}, - {gIntro2ManectricGfx, 0x2000, TAG_MANECTRIC}, + {gIntroVolbeat_Gfx, 0x400, TAG_VOLBEAT}, + {gIntroTorchic_Gfx, 0xC00, TAG_TORCHIC}, + {gIntroManectric_Gfx, 0x2000, TAG_MANECTRIC}, {}, }; static const struct SpritePalette sSpritePalettes_RunningPokemon[] = { - {gIntro2VolbeatPal, TAG_VOLBEAT}, - {gIntro2TorchicPal, TAG_TORCHIC}, - {gIntro2ManectricPal, TAG_MANECTRIC}, + {gIntroVolbeat_Pal, TAG_VOLBEAT}, + {gIntroTorchic_Pal, TAG_TORCHIC}, + {gIntroManectric_Pal, TAG_MANECTRIC}, {}, }; static const struct OamData sOamData_Volbeat = @@ -415,12 +415,12 @@ static const struct SpriteTemplate sSpriteTemplate_Manectric = }; static const struct CompressedSpriteSheet sSpriteSheet_Lightning[] = { - {gIntro3LightningGfx, 0xC00, TAG_LIGHTNING}, + {gIntroLightning_Gfx, 0xC00, TAG_LIGHTNING}, {}, }; static const struct SpritePalette sSpritePalette_Lightning[] = { - {gIntro3LightningPal, TAG_LIGHTNING}, + {gIntroLightning_Pal, TAG_LIGHTNING}, {}, }; static const struct OamData sOamData_Lightning = @@ -486,12 +486,12 @@ static const s16 sGroudonRockData[][3] = }; static const struct CompressedSpriteSheet sSpriteSheet_Bubbles[] = { - {gIntro3Bubbles_Gfx, 0x600, TAG_BUBBLES}, + {gIntroBubbles_Gfx, 0x600, TAG_BUBBLES}, {}, }; static const struct SpritePalette sSpritePalette_Bubbles[] = { - {gIntro3Bubbles_Pal, TAG_BUBBLES}, + {gIntroBubbles_Pal, TAG_BUBBLES}, {}, }; #define NUM_BUBBLES_IN_SET 6 @@ -963,19 +963,19 @@ static const struct SpriteTemplate sSpriteTemplate_FlygonSilhouette = }; static const struct CompressedSpriteSheet sSpriteSheet_WaterDropsAndLogo[] = { - {sIntro1DropsLogo_Gfx, 0x1400, GFXTAG_DROPS_LOGO}, + {sIntroDropsLogo_Gfx, 0x1400, GFXTAG_DROPS_LOGO}, {}, }; static const struct CompressedSpriteSheet sSpriteSheet_FlygonSilhouette[] = { - {gIntro1Flygon_Gfx, 0x400, TAG_FLYGON_SILHOUETTE}, + {gIntroFlygonSilhouette_Gfx, 0x400, TAG_FLYGON_SILHOUETTE}, {}, }; static const struct SpritePalette sSpritePalettes_Intro1[] = { - {sIntro1DropsPal, PALTAG_DROPS}, - {sIntro1Logo_Pal, PALTAG_LOGO}, - {sIntro1Flygon_Pal, TAG_FLYGON_SILHOUETTE}, + {sIntroDrops_Pal, PALTAG_DROPS}, + {sIntroLogo_Pal, PALTAG_LOGO}, + {sIntroFlygonSilhouette_Pal, TAG_FLYGON_SILHOUETTE}, {}, }; static const struct OamData sOamData_RayquazaOrb = @@ -1015,12 +1015,12 @@ static const struct SpriteTemplate sSpriteTemplate_RayquazaOrb = }; static const struct CompressedSpriteSheet sSpriteSheet_RayquazaOrb[] = { - {sIntro3Misc_Gfx, 0xA00, TAG_RAYQUAZA_ORB}, + {sIntroMisc_Gfx, 0xA00, TAG_RAYQUAZA_ORB}, {}, }; static const struct SpritePalette sSpritePalette_RayquazaOrb[] = { - {sIntro3Misc1_Pal, TAG_RAYQUAZA_ORB}, + {sIntroRayquzaOrb_Pal, TAG_RAYQUAZA_ORB}, {}, }; @@ -1715,9 +1715,9 @@ static void SpriteCB_Manectric(struct Sprite *sprite) static void Task_Scene3_Load(u8 taskId) { IntroResetGpuRegs(); - LZ77UnCompVram(sIntro3Pokeball_Gfx, (void *)VRAM); - LZ77UnCompVram(sIntro3Pokeball_Tilemap, (void *)(BG_CHAR_ADDR(1))); - LoadPalette(sIntro3Pokeball_Pal, 0, sizeof(sIntro3Pokeball_Pal)); + LZ77UnCompVram(sIntroPokeball_Gfx, (void *)VRAM); + LZ77UnCompVram(sIntroPokeball_Tilemap, (void *)(BG_CHAR_ADDR(1))); + LoadPalette(sIntroPokeball_Pal, 0, sizeof(sIntroPokeball_Pal)); gTasks[taskId].tAlpha = 0; gTasks[taskId].tZoomDiv = 0; gTasks[taskId].tZoomDivSpeed = 0; @@ -1770,13 +1770,13 @@ static void Task_Scene3_LoadGroudon(u8 taskId) ResetSpriteData(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 8; - LZDecompressVram(gIntro3GroudonGfx, (void *)VRAM); - LZDecompressVram(gIntro3GroudonTilemap, (void *)(BG_CHAR_ADDR(3))); - LZDecompressVram(gIntro3LegendBgGfx, (void *)(BG_CHAR_ADDR(1))); - LZDecompressVram(gIntro3GroudonBgTilemap, (void *)(BG_SCREEN_ADDR(28))); + LZDecompressVram(gIntroGroudon_Gfx, (void *)VRAM); + LZDecompressVram(gIntroGroudon_Tilemap, (void *)(BG_CHAR_ADDR(3))); + LZDecompressVram(gIntroLegendBg_Gfx, (void *)(BG_CHAR_ADDR(1))); + LZDecompressVram(gIntroGroudonBg_Tilemap, (void *)(BG_SCREEN_ADDR(28))); LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]); LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_ROCKS)]); - CpuCopy16(gIntro3BgPal, gPlttBufferUnfaded, sizeof(gIntro3BgPal)); + CpuCopy16(gIntro3Bg_Pal, gPlttBufferUnfaded, sizeof(gIntro3Bg_Pal)); gTasks[taskId].func = Task_Scene3_InitGroudonBg; } } @@ -1884,7 +1884,7 @@ static void Task_Scene3_Groudon(u8 taskId) if (--tDelay == 0) { tDelay = 2; - CpuCopy16(&gIntro3BgPal[tPalIdx], &gPlttBufferFaded[31], sizeof(u16)); + CpuCopy16(&gIntro3Bg_Pal[tPalIdx], &gPlttBufferFaded[31], sizeof(u16)); tPalIdx += 2; if (tPalIdx == 0x1EC) tState++; @@ -1901,7 +1901,7 @@ static void Task_Scene3_Groudon(u8 taskId) if (--tDelay == 0) { tDelay = 2; - CpuCopy16(&gIntro3BgPal[tPalIdx], &gPlttBufferFaded[31], sizeof(u16)); + CpuCopy16(&gIntro3Bg_Pal[tPalIdx], &gPlttBufferFaded[31], sizeof(u16)); tPalIdx -= 2; if (tPalIdx == 0x1E0) { @@ -2045,9 +2045,9 @@ static void SpriteCB_GroudonRocks(struct Sprite *sprite) static void Task_Scene3_LoadKyogre(u8 taskId) { ResetSpriteData(); - LZDecompressVram(gIntro3KyogreGfx, (void *)VRAM); - LZDecompressVram(gIntro3KyogreTilemap, (void *)(BG_CHAR_ADDR(3))); - LZDecompressVram(gIntro3KyogreBgTilemap, (void *)(BG_SCREEN_ADDR(28))); + LZDecompressVram(gIntroKyogre_Gfx, (void *)VRAM); + LZDecompressVram(gIntroKyogre_Tilemap, (void *)(BG_CHAR_ADDR(3))); + LZDecompressVram(gIntroKyogreBg_Tilemap, (void *)(BG_SCREEN_ADDR(28))); LoadCompressedSpriteSheet(sSpriteSheet_Bubbles); LoadSpritePalette(sSpritePalette_Bubbles); BeginNormalPaletteFade(PALETTES_ALL & ~1, 0, 16, 0, RGB_WHITEALPHA); @@ -2143,7 +2143,7 @@ static void Task_Scene3_Kyogre(u8 taskId) if (--tDelay == 0) { tDelay = 4; - CpuCopy16(&gIntro3BgPal[tPalIdx], &gPlttBufferFaded[47], sizeof(u16)); + CpuCopy16(&gIntro3Bg_Pal[tPalIdx], &gPlttBufferFaded[47], sizeof(u16)); tPalIdx -= 2; if (tPalIdx == 0x1E0) tState++; @@ -2161,7 +2161,7 @@ static void Task_Scene3_Kyogre(u8 taskId) if (--tDelay == 0) { tDelay = 4; - CpuCopy16(&gIntro3BgPal[tPalIdx], &gPlttBufferFaded[47], sizeof(u16)); + CpuCopy16(&gIntro3Bg_Pal[tPalIdx], &gPlttBufferFaded[47], sizeof(u16)); tPalIdx += 2; if (tPalIdx == 0x1EE) { @@ -2353,16 +2353,16 @@ static void Task_Scene3_LoadClouds1(u8 taskId) SetGpuReg(REG_OFFSET_BG1VOFS, 0); SetGpuReg(REG_OFFSET_BG2HOFS, 0); SetGpuReg(REG_OFFSET_BG2VOFS, 0); - LZDecompressVram(gIntro3CloudsGfx, (void *)VRAM); - LZDecompressVram(gIntro3CloudsGfx, (void *)(BG_CHAR_ADDR(1))); - LZDecompressVram(gIntro3Clouds3Tilemap, (void *)(BG_SCREEN_ADDR(28))); + LZDecompressVram(gIntroClouds_Gfx, (void *)VRAM); + LZDecompressVram(gIntroClouds_Gfx, (void *)(BG_CHAR_ADDR(1))); + LZDecompressVram(gIntroCloudsSun_Tilemap, (void *)(BG_SCREEN_ADDR(28))); gTasks[taskId].func = Task_Scene3_LoadClouds2; } static void Task_Scene3_LoadClouds2(u8 taskId) { - LZDecompressVram(gIntro3Clouds1Tilemap, (void *)(BG_CHAR_ADDR(3))); - LZDecompressVram(gIntro3Clouds2Tilemap, (void *)(BG_SCREEN_ADDR(26))); + LZDecompressVram(gIntroCloudsLeft_Tilemap, (void *)(BG_CHAR_ADDR(3))); + LZDecompressVram(gIntroCloudsRight_Tilemap, (void *)(BG_SCREEN_ADDR(26))); gTasks[taskId].func = Task_Scene3_InitClouds; } @@ -2420,10 +2420,10 @@ static void Task_Scene3_Clouds(u8 taskId) static void Task_Scene3_LoadLightning(u8 taskId) { - LZDecompressVram(gIntro3RayquazaTilemap, (void *)(BG_SCREEN_ADDR(28))); - LZDecompressVram(gIntro3Clouds4Tilemap, (void *)(BG_CHAR_ADDR(3))); - LZDecompressVram(gIntro3RayquazaGfx, (void *)(BG_CHAR_ADDR(1))); - LZDecompressVram(gIntro3Clouds2Gfx, (void *)VRAM); + LZDecompressVram(gIntroRayquaza_Tilemap, (void *)(BG_SCREEN_ADDR(28))); + LZDecompressVram(gIntroRayquazaClouds_Tilemap, (void *)(BG_CHAR_ADDR(3))); + LZDecompressVram(gIntroRayquaza_Gfx, (void *)(BG_CHAR_ADDR(1))); + LZDecompressVram(gIntroRayquazaClouds_Gfx, (void *)VRAM); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON @@ -2492,7 +2492,7 @@ static void SpriteCB_Lightning(struct Sprite *sprite) sprite->sPalIdx = 0x1C2; sprite->sState++; case 1: - CpuCopy16(&gIntro3BgPal[sprite->sPalIdx], &gPlttBufferFaded[93], 2); + CpuCopy16(&gIntro3Bg_Pal[sprite->sPalIdx], &gPlttBufferFaded[93], 2); sprite->sPalIdx += 2; if (sprite->sPalIdx != 0x1CE) break; @@ -2503,7 +2503,7 @@ static void SpriteCB_Lightning(struct Sprite *sprite) if (--sprite->sDelay == 0) { sprite->sDelay = 4; - CpuCopy16(&gIntro3BgPal[sprite->sPalIdx], &gPlttBufferFaded[93], 2); + CpuCopy16(&gIntro3Bg_Pal[sprite->sPalIdx], &gPlttBufferFaded[93], 2); sprite->sPalIdx -= 2; if (sprite->sPalIdx == 0x1C0) DestroySprite(sprite); @@ -2606,7 +2606,7 @@ static void Task_RayquazaAttack(u8 taskId) case 0: if ((data[2] & 1) != 0) { - CpuCopy16(&gIntro3BgPal[0x1A2 + data[1] * 2], &gPlttBufferFaded[94], 2); + CpuCopy16(&gIntro3Bg_Pal[0x1A2 + data[1] * 2], &gPlttBufferFaded[94], 2); data[1]++; } if (data[1] == 6) @@ -2621,7 +2621,7 @@ static void Task_RayquazaAttack(u8 taskId) { if ((data[2] & 1) != 0) { - CpuCopy16(&gIntro3BgPal[0x1A2 + data[1] * 2], &gPlttBufferFaded[88], 2); + CpuCopy16(&gIntro3Bg_Pal[0x1A2 + data[1] * 2], &gPlttBufferFaded[88], 2); data[1]++; } if (data[1] == 6) @@ -2640,7 +2640,7 @@ static void Task_RayquazaAttack(u8 taskId) { if ((data[2] & 1) != 0) { - CpuCopy16(&gIntro3BgPal[0x182 + data[1] * 2], &gPlttBufferFaded[92], 2); + CpuCopy16(&gIntro3Bg_Pal[0x182 + data[1] * 2], &gPlttBufferFaded[92], 2); data[1]++; } if (data[1] == 6) @@ -2664,9 +2664,9 @@ static void Task_RayquazaAttack(u8 taskId) if (--data[3] != 0) { BlendPalette(0x50, 16, data[3], RGB(9, 10, 10)); - CpuCopy16(&gIntro3BgPal[0x1AC], &gPlttBufferFaded[94], 2); - CpuCopy16(&gIntro3BgPal[0x1AC], &gPlttBufferFaded[88], 2); - CpuCopy16(&gIntro3BgPal[0x18C], &gPlttBufferFaded[92], 2); + CpuCopy16(&gIntro3Bg_Pal[0x1AC], &gPlttBufferFaded[94], 2); + CpuCopy16(&gIntro3Bg_Pal[0x1AC], &gPlttBufferFaded[88], 2); + CpuCopy16(&gIntro3Bg_Pal[0x18C], &gPlttBufferFaded[92], 2); } else { @@ -3197,16 +3197,16 @@ static void SpriteCB_LogoLetter(struct Sprite *sprite) sprite->sColorDelay = 2; if (sprite->sTimer != 0) { - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); sprite->sTimer--; } else { - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); sprite->sState++; } } @@ -3226,9 +3226,9 @@ static void SpriteCB_LogoLetter(struct Sprite *sprite) sprite->sColorDelay = 2; if (sprite->sTimer <= COLOR_CHANGES) { - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); - CpuCopy16(&gIntro1GameFreakTextFadePal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer], &gPlttBufferFaded[0x11F], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer + 16], &gPlttBufferFaded[0x114], 2); + CpuCopy16(&gIntroGameFreakTextFade_Pal[sprite->sTimer + 32], &gPlttBufferFaded[0x11A], 2); sprite->sTimer++; } else diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c index d19a3deea4..1f196b268d 100644 --- a/src/intro_credits_graphics.c +++ b/src/intro_credits_graphics.c @@ -579,7 +579,7 @@ static const struct SpriteTemplate sSpriteTemplate_FlygonLatias = const struct CompressedSpriteSheet gSpriteSheet_IntroBrendan[] = { { - .data = gIntro2BrendanGfx, + .data = gIntroBrendan_Gfx, .size = 0x2000, .tag = TAG_BRENDAN }, @@ -589,7 +589,7 @@ const struct CompressedSpriteSheet gSpriteSheet_IntroBrendan[] = const struct CompressedSpriteSheet gSpriteSheet_IntroMay[] = { { - .data = gIntro2MayGfx, + .data = gIntroMay_Gfx, .size = 0x2000, .tag = TAG_MAY }, @@ -610,7 +610,7 @@ const struct CompressedSpriteSheet gSpriteSheet_IntroBicycle[] = static const struct CompressedSpriteSheet sSpriteSheet_IntroFlygon_Unused[] = { { - .data = gIntro2FlygonGfx, + .data = gIntroFlygon_Gfx, .size = 0x1000, .tag = TAG_FLYGON_LATIOS }, @@ -620,7 +620,7 @@ static const struct CompressedSpriteSheet sSpriteSheet_IntroFlygon_Unused[] = const struct CompressedSpriteSheet gSpriteSheet_IntroFlygon[] = { { - .data = gIntro2FlygonGfx, + .data = gIntroFlygon_Gfx, .size = 0x1000, .tag = TAG_FLYGON_LATIAS }, @@ -629,10 +629,10 @@ const struct CompressedSpriteSheet gSpriteSheet_IntroFlygon[] = const struct SpritePalette gSpritePalettes_IntroPlayerFlygon[] = { - { .data = gIntro2PlayerPal, .tag = TAG_BRENDAN }, - { .data = gIntro2PlayerPal, .tag = TAG_MAY }, - { .data = gIntro2FlygonPal, .tag = TAG_FLYGON_LATIOS }, - { .data = gIntro2FlygonPal, .tag = TAG_FLYGON_LATIAS }, + { .data = gIntroPlayer_Pal, .tag = TAG_BRENDAN }, + { .data = gIntroPlayer_Pal, .tag = TAG_MAY }, + { .data = gIntroFlygon_Pal, .tag = TAG_FLYGON_LATIOS }, + { .data = gIntroFlygon_Pal, .tag = TAG_FLYGON_LATIAS }, {} }; From d5d1caf96550c91baef4a7f02670a6f1c83f6559 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 30 Mar 2021 15:07:04 -0400 Subject: [PATCH 20/31] Add some uses of OBJ_VRAM/VRAM_SIZE --- src/battle_bg.c | 2 +- src/battle_interface.c | 4 ++-- src/overworld.c | 2 +- src/pokeball.c | 2 +- src/pokenav_main_menu.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/battle_bg.c b/src/battle_bg.c index af0e374e20..571080aea1 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -1126,7 +1126,7 @@ void DrawBattleEntryBackground(void) if (gBattleTypeFlags & BATTLE_TYPE_LINK) { LZDecompressVram(gUnknown_08D778F0, (void*)(BG_CHAR_ADDR(1))); - LZDecompressVram(gVsLettersGfx, (void*)(VRAM + 0x10000)); + LZDecompressVram(gVsLettersGfx, (void*)OBJ_VRAM0); LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20); SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1); SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04); diff --git a/src/battle_interface.c b/src/battle_interface.c index df123630c9..cccc0b9711 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -1935,7 +1935,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon) if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER) { - TextIntoHealthboxObject((void*)(VRAM + 0x10040 + spriteTileNum), windowTileData, 6); + TextIntoHealthboxObject((void*)(OBJ_VRAM0 + 0x40 + spriteTileNum), windowTileData, 6); ptr = (void*)(OBJ_VRAM0); if (!IsDoubleBattle()) ptr += spriteTileNum + 0x800; @@ -1945,7 +1945,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon) } else { - TextIntoHealthboxObject((void*)(VRAM + 0x10020 + spriteTileNum), windowTileData, 7); + TextIntoHealthboxObject((void*)(OBJ_VRAM0 + 0x20 + spriteTileNum), windowTileData, 7); } RemoveWindowOnHealthbox(windowId); diff --git a/src/overworld.c b/src/overworld.c index 5aa5bb73df..63f648fe4a 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -2060,7 +2060,7 @@ static void sub_80867D8(void) ScanlineEffect_Stop(); DmaClear16(3, PLTT + 2, PLTT_SIZE - 2); - DmaFillLarge16(3, 0, (void *)(VRAM + 0x0), 0x18000, 0x1000); + DmaFillLarge16(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000); ResetOamRange(0, 128); LoadOam(); } diff --git a/src/pokeball.c b/src/pokeball.c index 503bae2d28..678b9da33e 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -1272,7 +1272,7 @@ void LoadBallGfx(u8 ballId) break; default: var = GetSpriteTileStartByTag(gBallSpriteSheets[ballId].tag); - LZDecompressVram(gOpenPokeballGfx, (void *)(VRAM + 0x10100 + var * 32)); + LZDecompressVram(gOpenPokeballGfx, (void *)(OBJ_VRAM0 + 0x100 + var * 32)); break; } } diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index e8262ad9a2..07e5242fe5 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -702,7 +702,7 @@ static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId) size = GetDecompressedDataSize(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data); LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(2) * 16) + 0x100, 0x20); LZ77UnCompWram(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data, &gDecompressionBuffer[0x1000]); - RequestDma3Copy(&gDecompressionBuffer[0x1000], (void *)VRAM + 0x10800 + (GetSpriteTileStartByTag(2) * 32), size, 1); + RequestDma3Copy(&gDecompressionBuffer[0x1000], (void *)OBJ_VRAM0 + 0x800 + (GetSpriteTileStartByTag(2) * 32), size, 1); } void ShowLeftHeaderGfx(u32 menuGfxId, bool32 isMain, bool32 isOnRightSide) From 8c6e89e994b312b3c6d36bcda8636343f80e4801 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 30 Mar 2021 17:38:09 -0400 Subject: [PATCH 21/31] Bit shifts from hex to decimal --- src/battle_main.c | 14 +++++++------- src/battle_script_commands.c | 8 ++++---- src/battle_util.c | 4 ++-- src/image_processing_effects.c | 4 ++-- src/load_save.c | 2 +- src/menu.c | 4 ++-- src/new_game.c | 2 +- src/pokeblock.c | 4 ++-- src/pokemon.c | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 3507ff7653..9bb2268a6b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4087,7 +4087,7 @@ static void HandleTurnActionSelectionState(void) } break; case STATE_WAIT_ACTION_CHOSEN: // Try to perform an action. - if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) + if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF << 28) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 12)))) { RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]); gChosenActionByBattler[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; @@ -4266,7 +4266,7 @@ static void HandleTurnActionSelectionState(void) } break; case STATE_WAIT_ACTION_CASE_CHOSEN: - if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) + if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF << 28) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 12)))) { switch (gChosenActionByBattler[gActiveBattler]) { @@ -4375,7 +4375,7 @@ static void HandleTurnActionSelectionState(void) break; case STATE_WAIT_ACTION_CONFIRMED_STANDBY: if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) - | (0xF0000000) + | (0xF << 28) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 12)))) @@ -4400,7 +4400,7 @@ static void HandleTurnActionSelectionState(void) } break; case STATE_WAIT_ACTION_CONFIRMED: - if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) + if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF << 28) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 12)))) { gBattleCommunication[ACTIONS_CONFIRMED_COUNT]++; } @@ -4414,7 +4414,7 @@ static void HandleTurnActionSelectionState(void) { gBattlerAttacker = gActiveBattler; gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBattler]; - if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) + if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF << 28) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 12)))) { gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); } @@ -4422,7 +4422,7 @@ static void HandleTurnActionSelectionState(void) } break; case STATE_WAIT_SET_BEFORE_ACTION: - if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) + if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF << 28) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 12)))) { gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; } @@ -4446,7 +4446,7 @@ static void HandleTurnActionSelectionState(void) { gBattlerAttacker = gActiveBattler; gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBattler]; - if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) + if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF << 28) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 12)))) { gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 96c849cbc0..84f8efaa84 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4855,7 +4855,7 @@ static void Cmd_openpartyscreen(void) { u8 flag40_0, flag40_1, flag40_2, flag40_3; - hitmarkerFaintBits = gHitMarker >> 0x1C; + hitmarkerFaintBits = gHitMarker >> 28; if (gBitTable[0] & hitmarkerFaintBits) { @@ -4984,7 +4984,7 @@ static void Cmd_openpartyscreen(void) { if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - hitmarkerFaintBits = gHitMarker >> 0x1C; + hitmarkerFaintBits = gHitMarker >> 28; if (gBitTable[2] & hitmarkerFaintBits && gBitTable[0] & hitmarkerFaintBits) { gActiveBattler = 2; @@ -5029,7 +5029,7 @@ static void Cmd_openpartyscreen(void) gBattlescriptCurrInstr += 6; } - hitmarkerFaintBits = gHitMarker >> 0x1C; + hitmarkerFaintBits = gHitMarker >> 28; gBattlerFainted = 0; while (!(gBitTable[gBattlerFainted] & hitmarkerFaintBits) @@ -5229,7 +5229,7 @@ static void Cmd_switchineffects(void) if (gBattlescriptCurrInstr[1] == 5) { - u32 hitmarkerFaintBits = gHitMarker >> 0x1C; + u32 hitmarkerFaintBits = gHitMarker >> 28; gBattlerFainted++; while (1) diff --git a/src/battle_util.c b/src/battle_util.c index 6e1202bd12..c0d897707c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -801,7 +801,7 @@ void MarkAllBattlersForControllerExec(void) // unused if (gBattleTypeFlags & BATTLE_TYPE_LINK) { for (i = 0; i < gBattlersCount; i++) - gBattleControllerExecFlags |= gBitTable[i] << 0x1C; + gBattleControllerExecFlags |= gBitTable[i] << (32 - MAX_BATTLERS_COUNT); } else { @@ -813,7 +813,7 @@ void MarkAllBattlersForControllerExec(void) // unused void MarkBattlerForControllerExec(u8 battlerId) { if (gBattleTypeFlags & BATTLE_TYPE_LINK) - gBattleControllerExecFlags |= gBitTable[battlerId] << 0x1C; + gBattleControllerExecFlags |= gBitTable[battlerId] << (32 - MAX_BATTLERS_COUNT); else gBattleControllerExecFlags |= gBitTable[battlerId]; } diff --git a/src/image_processing_effects.c b/src/image_processing_effects.c index 4a56871a4c..fa6867f2c5 100644 --- a/src/image_processing_effects.c +++ b/src/image_processing_effects.c @@ -804,8 +804,8 @@ void ConvertImageProcessingToGBA(struct ImageProcessingContext *context) dest = dest_ + ((i * width + j) << 4) + (k << 1); src = src_ + ((((i << 3) + k) << 3) * width) + (j << 3); - dest[0] = src[0] | (src[1] << 4) | (src[2] << 8) | (src[3] << 0xC); - dest[1] = src[4] | (src[5] << 4) | (src[6] << 8) | (src[7] << 0xC); + dest[0] = src[0] | (src[1] << 4) | (src[2] << 8) | (src[3] << 12); + dest[1] = src[4] | (src[5] << 4) | (src[6] << 8) | (src[7] << 12); } } } diff --git a/src/load_save.c b/src/load_save.c index 8459cd96b3..eec8f91aea 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -130,7 +130,7 @@ void MoveSaveBlocks_ResetHeap(void) gMain.vblankCallback = vblankCB; // create a new encryption key - encryptionKey = (Random() << 0x10) + (Random()); + encryptionKey = (Random() << 16) + (Random()); ApplyNewEncryptionKeyToAllEncryptedData(encryptionKey); gSaveBlock2Ptr->encryptionKey = encryptionKey; } diff --git a/src/menu.c b/src/menu.c index 86e5caac24..9957f72037 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2036,8 +2036,8 @@ void sub_819A080(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 src { for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++) { - pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B); - pixelsDst = (void*) dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + ((( loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 0x1d) >> 0x1B); + pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 29) >> 27); + pixelsDst = (void*) dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + ((( loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 29) >> 27); if ((uintptr_t)pixelsDst & 0x1) { diff --git a/src/new_game.c b/src/new_game.c index c43c6ae9f2..05d86aa8cf 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -87,7 +87,7 @@ void CopyTrainerId(u8 *dst, u8 *src) static void InitPlayerTrainerId(void) { - u32 trainerId = (Random() << 0x10) | GetGeneratedTrainerIdLower(); + u32 trainerId = (Random() << 16) | GetGeneratedTrainerIdLower(); SetTrainerId(trainerId, gSaveBlock2Ptr->playerTrainerId); } diff --git a/src/pokeblock.c b/src/pokeblock.c index ee546deda4..3513e7dd24 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -760,8 +760,8 @@ static void sub_8135FCC(s32 pkblId) { if (GetPokeblockData(pokeblock, PBLOCK_SPICY + i) > 0) { - rectTilemapSrc[0] = (i << 0xC) + 0x17; - rectTilemapSrc[1] = (i << 0xC) + 0x18; + rectTilemapSrc[0] = (i << 12) + 0x17; + rectTilemapSrc[1] = (i << 12) + 0x18; } else { diff --git a/src/pokemon.c b/src/pokemon.c index 5b683584be..e28fba1b48 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -6605,12 +6605,12 @@ const u8 *GetTrainerPartnerName(void) #define READ_PTR_FROM_TASK(taskId, dataId) \ (void*)( \ ((u16)(gTasks[taskId].data[dataId]) | \ - ((u16)(gTasks[taskId].data[dataId + 1]) << 0x10))) + ((u16)(gTasks[taskId].data[dataId + 1]) << 16))) #define STORE_PTR_IN_TASK(ptr, taskId, dataId) \ { \ gTasks[taskId].data[dataId] = (u32)(ptr); \ - gTasks[taskId].data[dataId + 1] = (u32)(ptr) >> 0x10; \ + gTasks[taskId].data[dataId + 1] = (u32)(ptr) >> 16; \ } static void Task_AnimateAfterDelay(u8 taskId) @@ -6897,7 +6897,7 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1) else { for (i = 0; i < structPtr->field_0_0; i++) - structPtr->byteArrays[i] = structPtr->bytes + (structPtr->field_3_0 * (i << 0xD)); + structPtr->byteArrays[i] = structPtr->bytes + (structPtr->field_3_0 * (i << 13)); } structPtr->templates = AllocZeroed(sizeof(struct SpriteTemplate) * structPtr->field_0_0); From f602a9dcbf4534fad68c8ee91b7da58682f62d56 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 31 Mar 2021 00:35:56 -0400 Subject: [PATCH 22/31] Use bool for multichoice ignoreBPress --- asm/macros/event.inc | 50 ++++++++++--------- .../scripts.inc | 12 ++--- .../scripts.inc | 8 +-- .../scripts.inc | 8 +-- .../scripts.inc | 8 +-- .../scripts.inc | 8 +-- .../scripts.inc | 12 ++--- .../scripts.inc | 12 ++--- .../scripts.inc | 8 +-- .../scripts.inc | 6 +-- .../scripts.inc | 2 +- .../scripts.inc | 10 ++-- .../scripts.inc | 12 ++--- .../scripts.inc | 24 ++++----- .../scripts.inc | 16 +++--- .../scripts.inc | 4 +- data/maps/BattleFrontier_Lounge3/scripts.inc | 2 +- .../BattleFrontier_OutsideWest/scripts.inc | 2 +- .../BattleFrontier_ReceptionGate/scripts.inc | 4 +- data/maps/CaveOfOrigin_B1F/scripts.inc | 2 +- data/maps/DewfordTown/scripts.inc | 4 +- .../scripts.inc | 4 +- .../FallarborTown_BattleTentLobby/scripts.inc | 4 +- data/maps/FortreeCity_House2/scripts.inc | 6 +-- .../LilycoveCity_ContestLobby/scripts.inc | 10 ++-- .../scripts.inc | 10 ++-- .../scripts.inc | 2 +- .../scripts.inc | 2 +- data/maps/MauvilleCity_BikeShop/scripts.inc | 6 +-- data/maps/MauvilleCity_GameCorner/scripts.inc | 8 +-- data/maps/Route104_MrBrineysHouse/scripts.inc | 2 +- data/maps/Route109/scripts.inc | 2 +- data/maps/Route110_TrickHouseEnd/scripts.inc | 2 +- .../Route110_TrickHouseEntrance/scripts.inc | 2 +- .../Route110_TrickHousePuzzle5/scripts.inc | 30 +++++------ .../scripts.inc | 30 +++++------ .../RustboroCity_DevonCorp_2F/scripts.inc | 2 +- .../RustboroCity_PokemonSchool/scripts.inc | 2 +- .../scripts.inc | 4 +- .../SlateportCity_BattleTentLobby/scripts.inc | 4 +- data/maps/SlateportCity_Harbor/scripts.inc | 6 +-- data/maps/TrainerHill_Entrance/scripts.inc | 4 +- .../scripts.inc | 4 +- .../scripts.inc | 2 +- data/scripts/berry_blender.inc | 2 +- data/scripts/cable_club.inc | 30 +++++------ data/scripts/contest_hall.inc | 8 +-- data/scripts/interview.inc | 2 +- data/scripts/mystery_event_club.inc | 4 +- data/scripts/players_house.inc | 2 +- data/scripts/shared_secret_base.inc | 6 +-- src/scrcmd.c | 10 ++-- 52 files changed, 214 insertions(+), 212 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 4625f8df6c..84fdd592a7 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -846,38 +846,40 @@ .endm @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. - @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button. - .macro multichoice x:req, y:req, list:req, b:req + @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with multichoiceId. + @ If ignoreBPress is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button. + .macro multichoice x:req, y:req, multichoiceId:req, ignoreBPress:req .byte 0x6f .byte \x .byte \y - .byte \list - .byte \b + .byte \multichoiceId + .byte \ignoreBPress .endm @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. - @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list. The default argument determines - @ the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. - @ If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button. - .macro multichoicedefault x:req, y:req, list:req, default:req, b:req + @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with multichoiceId. + @ The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. + @ If ignoreBPress is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button. + .macro multichoicedefault x:req, y:req, multichoiceId:req, default:req, ignoreBPress:req .byte 0x70 .byte \x .byte \y - .byte \list + .byte \multichoiceId .byte \default - .byte \b + .byte \ignoreBPress .endm @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. - @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list. + @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with multichoiceId. @ The per_row argument determines how many list items will be shown on a single row of the box. - .macro multichoicegrid x:req, y:req, list:req, per_row:req, B:req + @ If ignoreBPress is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button. + .macro multichoicegrid x:req, y:req, multichoiceId:req, per_row:req, ignoreBPress:req .byte 0x71 .byte \x .byte \y - .byte \list + .byte \multichoiceId .byte \per_row - .byte \B + .byte \ignoreBPress .endm @ Nopped in Emerald. @@ -886,21 +888,21 @@ .endm @ Nopped in Emerald, but still consumes parameters. - .macro erasebox byte1:req, byte2:req, byte3:req, byte4:req + .macro erasebox left:req, top:req, right:req, bottom:req .byte 0x73 - .byte \byte1 - .byte \byte2 - .byte \byte3 - .byte \byte4 + .byte \left + .byte \top + .byte \right + .byte \bottom .endm @ Nopped in Emerald, but still consumes parameters. - .macro drawboxtext byte1:req, byte2:req, byte3:req, byte4:req + .macro drawboxtext left:req, top:req, multichoiceId:req, ignoreBPress:req .byte 0x74 - .byte \byte1 - .byte \byte2 - .byte \byte3 - .byte \byte4 + .byte \left + .byte \top + .byte \multichoiceId + .byte \ignoreBPress .endm @ Displays a box containing the front sprite for the specified (species) Pokemon species. diff --git a/data/maps/BattleFrontier_BattleArenaBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleArenaBattleRoom/scripts.inc index 5badc62d07..ac48a45bfd 100644 --- a/data/maps/BattleFrontier_BattleArenaBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleArenaBattleRoom/scripts.inc @@ -155,7 +155,7 @@ BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForOpponent:: @ 82576B0 call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForOpponentNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleArenaBattleRoom_EventScript_ContinueChallenge case 1, BattleFrontier_BattleArenaBattleRoom_EventScript_AskRecordBattle @@ -164,7 +164,7 @@ BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForOpponent:: @ 82576B0 case MULTI_B_PRESSED, BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForOpponent BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForOpponentNoRecord:: @ 8257768 - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleArenaBattleRoom_EventScript_ContinueChallenge case 1, BattleFrontier_BattleArenaBattleRoom_EventScript_AskPauseChallenge @@ -174,7 +174,7 @@ BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForOpponentNoRecord:: @ BattleFrontier_BattleArenaBattleRoom_EventScript_AskRecordBattle:: @ 825779E message BattleFrontier_BattleArenaBattleRoom_Text_RecordLastBattle waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForOpponent case 0, BattleFrontier_BattleArenaBattleRoom_EventScript_RecordBattle @@ -194,7 +194,7 @@ BattleFrontier_BattleArenaBattleRoom_EventScript_AskPauseChallenge:: @ 82577DA BattleFrontier_BattleArenaBattleRoom_EventScript_AskRetireChallenge:: @ 8257808 message BattleFrontier_BattleArenaBattleRoom_Text_RetireFromChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForOpponent case 0, BattleFrontier_BattleArenaBattleRoom_EventScript_WarpToLobbyLost @@ -264,7 +264,7 @@ BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForTycoon:: @ 82578D4 call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForTycoonNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleArenaBattleRoom_EventScript_BattleGreta case 1, BattleFrontier_BattleArenaBattleRoom_EventScript_AskRecordBattle @@ -273,7 +273,7 @@ BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForTycoon:: @ 82578D4 case MULTI_B_PRESSED, BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForTycoon BattleFrontier_BattleArenaBattleRoom_EventScript_AskReadyForTycoonNoRecord:: @ 825792B - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleArenaBattleRoom_EventScript_BattleGreta case 1, BattleFrontier_BattleArenaBattleRoom_EventScript_AskPauseChallenge diff --git a/data/maps/BattleFrontier_BattleArenaLobby/scripts.inc b/data/maps/BattleFrontier_BattleArenaLobby/scripts.inc index a2d785e661..2c82534561 100644 --- a/data/maps/BattleFrontier_BattleArenaLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattleArenaLobby/scripts.inc @@ -84,7 +84,7 @@ BattleFrontier_BattleArenaLobby_EventScript_SaveAfterChallenge:: @ 8255D59 goto_if_eq BattleFrontier_BattleArenaLobby_EventScript_EndSaveAfterChallenge message BattleFrontier_BattleArenaLobby_Text_RecordLastMatch waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleArenaLobby_EventScript_EndSaveAfterChallenge case 0, BattleFrontier_BattleArenaLobby_EventScript_RecordMatch @@ -116,7 +116,7 @@ BattleFrontier_BattleArenaLobby_EventScript_Attendant:: @ 8255DF4 BattleFrontier_BattleArenaLobby_EventScript_AskTakeChallenge:: @ 8255E0B message BattleFrontier_BattleArenaLobby_Text_WishToTakeChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleArenaLobby_EventScript_TryEnterChallenge case 1, BattleFrontier_BattleArenaLobby_EventScript_ExplainChallenge @@ -126,7 +126,7 @@ BattleFrontier_BattleArenaLobby_EventScript_AskTakeChallenge:: @ 8255E0B BattleFrontier_BattleArenaLobby_EventScript_TryEnterChallenge:: @ 8255E47 message BattleFrontier_BattleArenaLobby_Text_WhichLevelMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattleArenaLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattleArenaLobby_EventScript_CancelChallenge @@ -325,7 +325,7 @@ BattleFrontier_BattleArenaLobby_EventScript_RulesBoard:: @ 82560CA BattleFrontier_BattleArenaLobby_EventScript_ReadRulesBoard:: @ 82560D9 message BattleFrontier_BattleArenaLobby_Text_ReadWhichHeading waitmessage - multichoice 17, 2, MULTI_BATTLE_ARENA_RULES, 0 + multichoice 17, 2, MULTI_BATTLE_ARENA_RULES, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleArenaLobby_EventScript_BattleRules case 1, BattleFrontier_BattleArenaLobby_EventScript_MindRules diff --git a/data/maps/BattleFrontier_BattleDomeLobby/scripts.inc b/data/maps/BattleFrontier_BattleDomeLobby/scripts.inc index 328f7bd40b..39bca5a3d3 100644 --- a/data/maps/BattleFrontier_BattleDomeLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattleDomeLobby/scripts.inc @@ -92,7 +92,7 @@ BattleFrontier_BattleDomeLobby_EventScript_AskRecordBattle:: @ 8249991 goto_if_eq BattleFrontier_BattleDomeLobby_EventScript_EndChallenge message BattleFrontier_BattleDomeLobby_Text_RecordLastMatch waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleDomeLobby_EventScript_EndChallenge case 0, BattleFrontier_BattleDomeLobby_EventScript_RecordBattle @@ -147,7 +147,7 @@ BattleFrontier_BattleDomeLobby_EventScript_AskTakeChallenge:: @ 8249A72 compare VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_DOUBLES call_if_eq BattleFrontier_BattleDomeLobby_EventScript_TakeDoublesChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleDomeLobby_EventScript_TryEnterChallenge case 1, BattleFrontier_BattleDomeLobby_EventScript_ExplainChallenge @@ -157,7 +157,7 @@ BattleFrontier_BattleDomeLobby_EventScript_AskTakeChallenge:: @ 8249A72 BattleFrontier_BattleDomeLobby_EventScript_TryEnterChallenge:: @ 8249ABF message BattleFrontier_BattleDomeLobby_Text_WhichLevelMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattleDomeLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattleDomeLobby_EventScript_CancelChallenge @@ -427,7 +427,7 @@ BattleFrontier_BattleDomeLobby_EventScript_RulesBoard:: @ 8249E34 BattleFrontier_BattleDomeLobby_EventScript_ReadRulesBoard:: @ 8249E43 message BattleFrontier_BattleDomeLobby_Text_ReadWhichHeading waitmessage - multichoice 17, 4, MULTI_BATTLE_DOME_RULES, 0 + multichoice 17, 4, MULTI_BATTLE_DOME_RULES, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleDomeLobby_EventScript_RulesMatchup case 1, BattleFrontier_BattleDomeLobby_EventScript_RulesTourneyTree diff --git a/data/maps/BattleFrontier_BattleDomePreBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleDomePreBattleRoom/scripts.inc index 977a0bcae2..4499bda92d 100644 --- a/data/maps/BattleFrontier_BattleDomePreBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleDomePreBattleRoom/scripts.inc @@ -33,7 +33,7 @@ BattleFrontier_BattleDomePreBattleRoom_EventScript_AskReadyForNextRound:: @ 824B call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattleDomePreBattleRoom_EventScript_AskReadyForNextRoundNoRecord - multichoice 16, 0, MULTI_TOURNEY_WITH_RECORD, 1 + multichoice 16, 0, MULTI_TOURNEY_WITH_RECORD, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleDomePreBattleRoom_EventScript_ShowOpponentInfo case 1, BattleFrontier_BattleDomePreBattleRoom_EventScript_ShowTourneyTree @@ -44,7 +44,7 @@ BattleFrontier_BattleDomePreBattleRoom_EventScript_AskReadyForNextRound:: @ 824B case MULTI_B_PRESSED, BattleFrontier_BattleDomePreBattleRoom_EventScript_AskReadyForNextRound BattleFrontier_BattleDomePreBattleRoom_EventScript_AskReadyForNextRoundNoRecord:: @ 824B2C1 - multichoice 16, 2, MULTI_TOURNEY_NO_RECORD, 1 + multichoice 16, 2, MULTI_TOURNEY_NO_RECORD, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleDomePreBattleRoom_EventScript_ShowOpponentInfo case 1, BattleFrontier_BattleDomePreBattleRoom_EventScript_ShowTourneyTree @@ -56,7 +56,7 @@ BattleFrontier_BattleDomePreBattleRoom_EventScript_AskReadyForNextRoundNoRecord: BattleFrontier_BattleDomePreBattleRoom_EventScript_AskRecordBattle:: @ 824B30D message BattleFrontier_BattleDomePreBattleRoom_Text_RecordLastMatch waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleDomePreBattleRoom_EventScript_AskReadyForNextRound case 0, BattleFrontier_BattleDomePreBattleRoom_EventScript_RecordBattle @@ -76,7 +76,7 @@ BattleFrontier_BattleDomePreBattleRoom_EventScript_AskPauseChallenge:: @ 824B349 BattleFrontier_BattleDomePreBattleRoom_EventScript_AskRetireChallenge:: @ 824B377 message BattleFrontier_BattleDomePreBattleRoom_Text_RetireYourChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleDomePreBattleRoom_EventScript_AskReadyForNextRound case 0, BattleFrontier_BattleDomePreBattleRoom_EventScript_RetireChallenge diff --git a/data/maps/BattleFrontier_BattleFactoryLobby/scripts.inc b/data/maps/BattleFrontier_BattleFactoryLobby/scripts.inc index 60d0ae5879..dfdb7c944e 100644 --- a/data/maps/BattleFrontier_BattleFactoryLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattleFactoryLobby/scripts.inc @@ -83,7 +83,7 @@ BattleFrontier_BattleFactoryLobby_EventScript_AskRecordBattle:: @ 825853B goto_if_eq BattleFrontier_BattleFactoryLobby_EventScript_EndRecordBattle message BattleFrontier_BattleFactoryLobby_Text_RecordLastMatch waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleFactoryLobby_EventScript_EndRecordBattle case 0, BattleFrontier_BattleFactoryLobby_EventScript_RecordBattle @@ -136,7 +136,7 @@ BattleFrontier_BattleFactoryLobby_EventScript_AskTakeChallenge:: @ 8258606 compare VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_DOUBLES call_if_eq BattleFrontier_BattleFactoryLobby_EventScript_TakeDoublesChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleFactoryLobby_EventScript_TryEnterChallenge case 1, BattleFrontier_BattleFactoryLobby_EventScript_ExplainChallenge @@ -146,7 +146,7 @@ BattleFrontier_BattleFactoryLobby_EventScript_AskTakeChallenge:: @ 8258606 BattleFrontier_BattleFactoryLobby_EventScript_TryEnterChallenge:: @ 8258653 message BattleFrontier_BattleFactoryLobby_Text_WhichLevelMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattleFactoryLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattleFactoryLobby_EventScript_CancelChallenge @@ -293,7 +293,7 @@ BattleFrontier_BattleFactoryLobby_EventScript_RulesBoard:: @ 8258839 BattleFrontier_BattleFactoryLobby_EventScript_ReadRulesBoard:: @ 8258848 message BattleFrontier_BattleFactoryLobby_Text_ReadWhichHeading waitmessage - multichoice 17, 0, MULTI_BATTLE_FACTORY_RULES, 0 + multichoice 17, 0, MULTI_BATTLE_FACTORY_RULES, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleFactoryLobby_EventScript_RulesBasics case 1, BattleFrontier_BattleFactoryLobby_EventScript_RulesSwapPartner diff --git a/data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc index e856971467..3d3f2faeee 100644 --- a/data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc @@ -105,7 +105,7 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForRegularOpponent call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForOpponentNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskSwapMon case 1, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskRecordBattle @@ -114,7 +114,7 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForRegularOpponent case MULTI_B_PRESSED, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForOpponent BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForOpponentNoRecord:: @ 8259CC6 - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskSwapMon case 1, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskPauseChallenge @@ -124,7 +124,7 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForOpponentNoRecor BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskRecordBattle:: @ 8259CFC message BattleFrontier_BattleFactoryPreBattleRoom_Text_RecordLatestBattle waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForOpponent case 0, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_RecordBattle @@ -144,7 +144,7 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskPauseChallenge:: @ 8259 BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskRetireChallenge:: @ 8259D66 message BattleFrontier_BattleFactoryPreBattleRoom_Text_RetireFromChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForOpponent case 0, BattleFrontier_BattleFactoryBattleRoom_EventScript_WarpToLobbyLost @@ -396,7 +396,7 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForHead:: @ 825A0B call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForHeadNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskSwapBeforeHead case 1, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskRecordBattle @@ -405,7 +405,7 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForHead:: @ 825A0B case MULTI_B_PRESSED, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForHead BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskReadyForHeadNoRecord:: @ 825A110 - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskSwapBeforeHead case 1, BattleFrontier_BattleFactoryPreBattleRoom_EventScript_AskPauseChallenge diff --git a/data/maps/BattleFrontier_BattlePalaceBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattlePalaceBattleRoom/scripts.inc index 43db81321b..0ad0a93773 100644 --- a/data/maps/BattleFrontier_BattlePalaceBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattlePalaceBattleRoom/scripts.inc @@ -113,7 +113,7 @@ BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForOpponent:: @ 824F98 call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForOpponentNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattlePalaceBattleRoom_EventScript_ContinueChallenge case 1, BattleFrontier_BattlePalaceBattleRoom_EventScript_AskRecordBattle @@ -122,7 +122,7 @@ BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForOpponent:: @ 824F98 case MULTI_B_PRESSED, BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForOpponent BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForOpponentNoRecord:: @ 824FA42 - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattlePalaceBattleRoom_EventScript_ContinueChallenge case 1, BattleFrontier_BattlePalaceBattleRoom_EventScript_AskPauseChallenge @@ -132,7 +132,7 @@ BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForOpponentNoRecord:: BattleFrontier_BattlePalaceBattleRoom_EventScript_AskRecordBattle:: @ 824FA78 message BattleFrontier_BattlePalaceBattleRoom_Text_RecordLastMatch waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForOpponent case 0, BattleFrontier_BattlePalaceBattleRoom_EventScript_RecordBattle @@ -152,7 +152,7 @@ BattleFrontier_BattlePalaceBattleRoom_EventScript_AskPauseChallenge:: @ 824FAB4 BattleFrontier_BattlePalaceBattleRoom_EventScript_AskRetireChallenge:: @ 824FAE2 message BattleFrontier_BattlePalaceBattleRoom_Text_WishToQuitChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForOpponent case 0, BattleFrontier_BattlePalaceBattleRoom_EventScript_WarpToLobbyLost @@ -189,7 +189,7 @@ BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForMaven:: @ 824FB79 call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForMavenNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattlePalaceBattleRoom_EventScript_BattleSpenser case 1, BattleFrontier_BattlePalaceBattleRoom_EventScript_AskRecordBattle @@ -198,7 +198,7 @@ BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForMaven:: @ 824FB79 case MULTI_B_PRESSED, BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForMaven BattleFrontier_BattlePalaceBattleRoom_EventScript_AskReadyForMavenNoRecord:: @ 824FBD0 - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattlePalaceBattleRoom_EventScript_BattleSpenser case 1, BattleFrontier_BattlePalaceBattleRoom_EventScript_AskPauseChallenge diff --git a/data/maps/BattleFrontier_BattlePalaceLobby/scripts.inc b/data/maps/BattleFrontier_BattlePalaceLobby/scripts.inc index dc0fe4af1d..4c2a4841e8 100644 --- a/data/maps/BattleFrontier_BattlePalaceLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattlePalaceLobby/scripts.inc @@ -85,7 +85,7 @@ BattleFrontier_BattlePalaceLobby_EventScript_SaveAfterChallenge:: @ 824D8A1 goto_if_eq BattleFrontier_BattlePalaceLobby_EventScript_EndSaveAfterChallenge message BattleFrontier_BattlePalaceLobby_Text_LikeToRecordMatch waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattlePalaceLobby_EventScript_EndSaveAfterChallenge case 0, BattleFrontier_BattlePalaceLobby_EventScript_RecordMatch @@ -139,7 +139,7 @@ BattleFrontier_BattlePalaceLobby_EventScript_AskTakeChallenge:: @ 824D999 compare VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_DOUBLES call_if_eq BattleFrontier_BattlePalaceLobby_EventScript_AskTakeDoubleBattleChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattlePalaceLobby_EventScript_TryEnterChallenge case 1, BattleFrontier_BattlePalaceLobby_EventScript_ExplainChallenge @@ -149,7 +149,7 @@ BattleFrontier_BattlePalaceLobby_EventScript_AskTakeChallenge:: @ 824D999 BattleFrontier_BattlePalaceLobby_EventScript_TryEnterChallenge:: @ 824D9E6 message BattleFrontier_BattlePalaceLobby_Text_WhichChallenge waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattlePalaceLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattlePalaceLobby_EventScript_CancelChallenge @@ -351,7 +351,7 @@ BattleFrontier_BattlePalaceLobby_EventScript_RulesBoard:: @ 824DCA6 BattleFrontier_BattlePalaceLobby_EventScript_ReadRulesBoard:: @ 824DCB5 message BattleFrontier_BattlePalaceLobby_Text_ReadWhichHeading waitmessage - multichoice 16, 0, MULTI_BATTLE_PALACE_RULES, 0 + multichoice 16, 0, MULTI_BATTLE_PALACE_RULES, FALSE switch VAR_RESULT case 0, BattleFrontier_BattlePalaceLobby_EventScript_RulesBasics case 1, BattleFrontier_BattlePalaceLobby_EventScript_RulesNature diff --git a/data/maps/BattleFrontier_BattlePikeLobby/scripts.inc b/data/maps/BattleFrontier_BattlePikeLobby/scripts.inc index 3e6111f427..1bc66bbfa0 100644 --- a/data/maps/BattleFrontier_BattlePikeLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattlePikeLobby/scripts.inc @@ -101,7 +101,7 @@ BattleFrontier_BattlePikeLobby_EventScript_Attendant:: @ 825B868 BattleFrontier_BattlePikeLobby_EventScript_AskTakeChallenge:: @ 825B87F message BattleFrontier_BattlePikeLobby_Text_TakeChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattlePikeLobby_EventScript_TryEnterChallenge case 1, BattleFrontier_BattlePikeLobby_EventScript_ExplainChallenge @@ -111,7 +111,7 @@ BattleFrontier_BattlePikeLobby_EventScript_AskTakeChallenge:: @ 825B87F BattleFrontier_BattlePikeLobby_EventScript_TryEnterChallenge:: @ 825B8BB message BattleFrontier_BattlePikeLobby_Text_WhichChallengeMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattlePikeLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattlePikeLobby_EventScript_CancelChallenge @@ -236,7 +236,7 @@ BattleFrontier_BattlePikeLobby_EventScript_RulesBoard:: @ 825BAC6 BattleFrontier_BattlePikeLobby_EventScript_ReadRulesBoard:: @ 825BAD5 message BattleFrontier_BattlePikeLobby_Text_ReadWhichHeading waitmessage - multichoice 16, 4, MULTI_BATTLE_PIKE_RULES, 0 + multichoice 16, 4, MULTI_BATTLE_PIKE_RULES, FALSE switch VAR_RESULT case 0, BattleFrontier_BattlePikeLobby_EventScript_RulesPokenavBag case 1, BattleFrontier_BattlePikeLobby_EventScript_RulesHeldItems diff --git a/data/maps/BattleFrontier_BattlePikeThreePathRoom/scripts.inc b/data/maps/BattleFrontier_BattlePikeThreePathRoom/scripts.inc index 46edebce68..acdd490204 100644 --- a/data/maps/BattleFrontier_BattlePikeThreePathRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattlePikeThreePathRoom/scripts.inc @@ -143,7 +143,7 @@ BattleFrontier_BattlePikeThreePathRoom_EventScript_AskSaveChallenge:: @ 825CA2A BattleFrontier_BattlePikeThreePathRoom_EventScript_AskRetireChallenge:: @ 825CA5A message BattleFrontier_BattlePikeThreePathRoom_Text_RetireFromChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 0, BattleFrontier_BattlePike_EventScript_Retire release diff --git a/data/maps/BattleFrontier_BattlePyramidLobby/scripts.inc b/data/maps/BattleFrontier_BattlePyramidLobby/scripts.inc index fc33a8c911..175d2c56b7 100644 --- a/data/maps/BattleFrontier_BattlePyramidLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattlePyramidLobby/scripts.inc @@ -115,7 +115,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_Attendant:: @ 82508B1 BattleFrontier_BattlePyramidLobby_EventScript_AskTakeChallenge:: @ 82508C8 message BattleFrontier_BattlePyramidLobby_Text_EmbarkOnChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattlePyramidLobby_EventScript_TryEnterChallenge case 1, BattleFrontier_BattlePyramidLobby_EventScript_ExplainChallenge @@ -125,7 +125,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_AskTakeChallenge:: @ 82508C8 BattleFrontier_BattlePyramidLobby_EventScript_TryEnterChallenge:: @ 8250904 message BattleFrontier_BattlePyramidLobby_Text_WhichLevelMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattlePyramidLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattlePyramidLobby_EventScript_CancelChallenge @@ -218,7 +218,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_HintGiver:: @ 8250ACE end BattleFrontier_BattlePyramidLobby_EventScript_GiveHint:: @ 8250AF0 - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_50, BattleFrontier_BattlePyramidLobby_EventScript_GiveHintLv50 case FRONTIER_LVL_OPEN, BattleFrontier_BattlePyramidLobby_EventScript_GiveHintLvOpen @@ -446,7 +446,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_HeldItemsStoredInPyramidBag:: @ 82 @ When exiting Battle Pyramid with a full pyramid bag and held items the player must select to keep/toss party held items and make room for any kept items by tossing from the pyramid bag BattleFrontier_BattlePyramidLobby_EventScript_PickItemsToKeep:: @ 8250E09 - multichoice 17, 6, MULTI_FRONTIER_ITEM_CHOOSE, 0 + multichoice 17, 6, MULTI_FRONTIER_ITEM_CHOOSE, FALSE switch VAR_RESULT case 0, BattleFrontier_BattlePyramidLobby_EventScript_PickItemsFromBag case 1, BattleFrontier_BattlePyramidLobby_EventScript_PickItemsFromParty @@ -500,7 +500,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_RulesBoard:: @ 8250E95 BattleFrontier_BattlePyramidLobby_EventScript_ReadRulesBoard:: @ 8250EA4 message BattleFrontier_BattlePyramidLobby_Text_ReadWhichHeading waitmessage - multichoice 15, 2, MULTI_BATTLE_PYRAMID_RULES, 0 + multichoice 15, 2, MULTI_BATTLE_PYRAMID_RULES, FALSE switch VAR_RESULT case 0, BattleFrontier_BattlePyramidLobby_EventScript_RulesPokemon case 1, BattleFrontier_BattlePyramidLobby_EventScript_RulesTrainers diff --git a/data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc index cc623e2166..bfe26edb52 100644 --- a/data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc @@ -82,7 +82,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForOpponent:: @ 8241C8F call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForOpponentNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleTowerBattleRoom_EventScript_ContinueChallenge case 1, BattleFrontier_BattleTowerBattleRoom_EventScript_AskRecordBattle @@ -91,7 +91,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForOpponent:: @ 8241C8F case MULTI_B_PRESSED, BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForOpponent BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForOpponentNoRecord:: @ 8241D0A - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleTowerBattleRoom_EventScript_ContinueChallenge case 1, BattleFrontier_BattleTowerBattleRoom_EventScript_AskPauseChallenge @@ -101,7 +101,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForOpponentNoRecord:: @ BattleFrontier_BattleTowerBattleRoom_EventScript_AskRecordBattle:: @ 8241D40 message BattleFrontier_BattleTowerBattleRoom_Text_RecordYourBattle waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForOpponent case 0, BattleFrontier_BattleTowerBattleRoom_EventScript_RecordBattle @@ -121,7 +121,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_AskPauseChallenge:: @ 8241D7C BattleFrontier_BattleTowerBattleRoom_EventScript_AskRetireChallenge:: @ 8241DAA message BattleFrontier_BattleTowerBattleRoom_Text_CancelYourChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForOpponent case 0, BattleFrontier_BattleTowerBattleRoom_EventScript_RetireChallenge @@ -224,7 +224,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForMaiden:: @ 8241F22 call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForMaidenNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleTowerBattleRoom_EventScript_BattleAnabel case 1, BattleFrontier_BattleTowerBattleRoom_EventScript_AskRecordBattle @@ -233,7 +233,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForMaiden:: @ 8241F22 case MULTI_B_PRESSED, BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForMaiden BattleFrontier_BattleTowerBattleRoom_EventScript_AskReadyForMaidenNoRecord:: @ 8241F79 - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleTowerBattleRoom_EventScript_BattleAnabel case 1, BattleFrontier_BattleTowerBattleRoom_EventScript_AskPauseChallenge diff --git a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc index c1174cf066..465b04f78d 100644 --- a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc @@ -135,7 +135,7 @@ BattleFrontier_BattleTowerLobby_EventScript_AskSaveBattle:: @ 823E84D goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_EndSaveBattle message BattleFrontier_BattleTowerLobby_Text_RecordLastMatch waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleTowerLobby_EventScript_EndSaveBattle case 0, BattleFrontier_EventScript_SaveBattle @@ -187,7 +187,7 @@ BattleFrontier_BattleTowerLobby_EventScript_SinglesAttendant:: @ 823E936 BattleFrontier_BattleTowerLobby_EventScript_AskEnterSinglesChallenge:: @ 823E948 message BattleFrontier_BattleTowerLobby_Text_TakeSinglesChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleTowerLobby_EventScript_TryEnterSinglesChallenge case 1, BattleFrontier_BattleTowerLobby_EventScript_ExplainSinglesChallenge @@ -198,7 +198,7 @@ BattleFrontier_BattleTowerLobby_EventScript_TryEnterSinglesChallenge:: @ 823E984 setvar VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_SINGLES message BattleFrontier_BattleTowerLobby_Text_WhichLevelMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge @@ -253,7 +253,7 @@ BattleFrontier_BattleTowerLobby_EventScript_DoublesAttendant:: @ 823EA9F BattleFrontier_BattleTowerLobby_EventScript_AskEnterDoublesChallenge:: @ 823EAB1 message BattleFrontier_BattleTowerLobby_Text_TakeDoublesChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleTowerLobby_EventScript_TryEnterDoublesChallenge case 1, BattleFrontier_BattleTowerLobby_EventScript_ExplainDoublesChallenge @@ -264,7 +264,7 @@ BattleFrontier_BattleTowerLobby_EventScript_TryEnterDoublesChallenge:: @ 823EAED setvar VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_DOUBLES message BattleFrontier_BattleTowerLobby_Text_WhichLevelMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge @@ -320,7 +320,7 @@ BattleFrontier_BattleTowerLobby_EventScript_MultisAttendant:: @ 823EC08 BattleFrontier_BattleTowerLobby_EventScript_AskEnterMultisChallenge:: @ 823EC1D message BattleFrontier_BattleTowerLobby_Text_TakeMultisChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleTowerLobby_EventScript_TryEnterMultisChallenge case 1, BattleFrontier_BattleTowerLobby_EventScript_ExplainMultisChallenge @@ -331,7 +331,7 @@ BattleFrontier_BattleTowerLobby_EventScript_TryEnterMultisChallenge:: @ 823EC59 setvar VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_MULTIS message BattleFrontier_BattleTowerLobby_Text_WhichLevelMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge @@ -386,7 +386,7 @@ BattleFrontier_BattleTowerLobby_EventScript_LinkMultisAttendant:: @ 823ED74 BattleFrontier_BattleTowerLobby_EventScript_AskEnterLinkMultisChallenge:: @ 823ED86 message BattleFrontier_BattleTowerLobby_Text_TakeLinkMultisChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleTowerLobby_EventScript_TryEnterLinkMultisChallenge case 1, BattleFrontier_BattleTowerLobby_EventScript_ExplainLinkMultisChallenge @@ -397,7 +397,7 @@ BattleFrontier_BattleTowerLobby_EventScript_TryEnterLinkMultisChallenge:: @ 823E setvar VAR_FRONTIER_BATTLE_MODE, FRONTIER_MODE_LINK_MULTIS message BattleFrontier_BattleTowerLobby_Text_WhichLevelMode waitmessage - multichoice 17, 6, MULTI_LEVEL_MODE, 0 + multichoice 17, 6, MULTI_LEVEL_MODE, FALSE switch VAR_RESULT case FRONTIER_LVL_TENT, BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge case MULTI_B_PRESSED, BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge @@ -446,7 +446,7 @@ BattleFrontier_BattleTowerLobby_EventScript_FeelingsMan:: @ 823EEE7 faceplayer message BattleFrontier_BattleTowerLobby_Text_DescribeFeelingsAboutBattleTower waitmessage - multichoice 16, 4, MULTI_BATTLE_TOWER_FEELINGS, 0 + multichoice 16, 4, MULTI_BATTLE_TOWER_FEELINGS, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleTowerLobby_EventScript_FeelingsBattleNow case 1, BattleFrontier_BattleTowerLobby_EventScript_FeelingsIWon @@ -879,7 +879,7 @@ BattleFrontier_BattleTowerLobby_EventScript_TryWirelessLink:: @ 823F3E8 BattleFrontier_BattleTowerLobby_EventScript_ChooseLeader:: @ 823F3F3 message CableClub_Text_ChooseGroupLeaderOfTwo waitmessage - multichoice 16, 6, MULTI_LINK_LEADER, 0 + multichoice 16, 6, MULTI_LINK_LEADER, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleTowerLobby_EventScript_TryJoinGroup case 1, BattleFrontier_BattleTowerLobby_EventScript_TryBecomeLeader @@ -935,7 +935,7 @@ BattleFrontier_BattleTowerLobby_EventScript_RulesBoard:: @ 823F4BE BattleFrontier_BattleTowerLobby_EventScript_ReadRulesBoard:: @ 823F4CD message BattleFrontier_BattleTowerLobby_Text_ReadWhichHeading waitmessage - multichoice 17, 2, MULTI_BATTLE_TOWER_RULES, 0 + multichoice 17, 2, MULTI_BATTLE_TOWER_RULES, FALSE switch VAR_RESULT case 0, BattleFrontier_BattleTowerLobby_EventScript_RulesTower case 1, BattleFrontier_BattleTowerLobby_EventScript_RulesMons diff --git a/data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc index dfce6d1550..0e8f5e8cd0 100644 --- a/data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc @@ -155,7 +155,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponents:: @ 8 call BattleFrontier_EventScript_GetCantRecordBattle compare VAR_RESULT, TRUE goto_if_eq BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponentsNoRecord - multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, 1 + multichoice 19, 4, MULTI_GO_ON_RECORD_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ContinueChallenge case 1, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskRecordBattle @@ -164,7 +164,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponents:: @ 8 case MULTI_B_PRESSED, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponents BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponentsNoRecord:: @ 82491B1 - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ContinueChallenge case 1, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskPauseChallenge @@ -174,7 +174,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponentsNoReco BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskRecordBattle:: @ 82491E7 message BattleFrontier_BattleTowerBattleRoom_Text_RecordYourBattle waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponents case 0, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_RecordBattle @@ -194,7 +194,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskPauseChallenge:: @ 8249 BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskRetireChallenge:: @ 8249251 message BattleFrontier_BattleTowerBattleRoom_Text_CancelYourChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponents case 0, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_WarpToLobbyLost @@ -324,7 +324,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_LinkDelayForMsg:: @ 824941 BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponentsLink:: @ 8249417 goto_if_set FLAG_TEMP_2, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponentsLinkNoRecord - multichoice 19, 6, MULTI_GO_ON_RECORD_RETIRE, 1 + multichoice 19, 6, MULTI_GO_ON_RECORD_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ContinueChallengeLink case 1, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskRecordBattleLink @@ -333,7 +333,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponentsLink:: end BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponentsLinkNoRecord:: @ 8249457 - multichoice 20, 8, MULTI_GO_ON_RETIRE, 1 + multichoice 20, 8, MULTI_GO_ON_RETIRE, TRUE switch VAR_RESULT case 0, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ContinueChallengeLink case 1, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskRetireChallengeLink @@ -355,7 +355,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ContinueChallengeLink:: @ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskRecordBattleLink:: @ 82494A8 message BattleFrontier_BattleTowerBattleRoom_Text_RecordYourBattle waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponents case MULTI_B_PRESSED, BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponents @@ -367,7 +367,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskRecordBattleLink:: @ 82 BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskRetireChallengeLink:: @ 82494DD message BattleFrontier_BattleTowerBattleRoom_Text_CancelYourChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE compare VAR_RESULT, 0 goto_if_eq BattleFrontier_BattleTowerMultiBattleRoom_EventScript_RetireChallengeLink goto BattleFrontier_BattleTowerMultiBattleRoom_EventScript_AskReadyForOpponents diff --git a/data/maps/BattleFrontier_BattleTowerMultiPartnerRoom/scripts.inc b/data/maps/BattleFrontier_BattleTowerMultiPartnerRoom/scripts.inc index 71487225ca..297514524a 100644 --- a/data/maps/BattleFrontier_BattleTowerMultiPartnerRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleTowerMultiPartnerRoom/scripts.inc @@ -86,7 +86,7 @@ BattleFrontier_BattleTowerMultiPartnerRoom_EventScript_Attendant:: @ 8243E7A faceplayer message BattleFrontier_BattleTowerMultiPartnerRoom_Text_QuitLookingForPartner waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE compare VAR_RESULT, 0 goto_if_eq BattleFrontier_BattleTowerMultiPartnerRoom_EventScript_QuitChallenge msgbox BattleFrontier_BattleTowerMultiPartnerRoom_Text_PleaseFindPartner2, MSGBOX_DEFAULT @@ -175,7 +175,7 @@ BattleFrontier_BattleTowerMultiPartnerRoom_EventScript_TalkToPotentialPartner:: waitbuttonpress tower_dopartnermsg PARTNER_MSGID_MON2_ASK waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, BattleFrontier_BattleTowerMultiPartnerRoom_EventScript_RejectPartner case MULTI_B_PRESSED, BattleFrontier_BattleTowerMultiPartnerRoom_EventScript_RejectPartner diff --git a/data/maps/BattleFrontier_Lounge3/scripts.inc b/data/maps/BattleFrontier_Lounge3/scripts.inc index bc85d92d0f..d1b8d20245 100644 --- a/data/maps/BattleFrontier_Lounge3/scripts.inc +++ b/data/maps/BattleFrontier_Lounge3/scripts.inc @@ -34,7 +34,7 @@ BattleFrontier_Lounge3_EventScript_AskToEnterChallenge:: @ 8261DAF end BattleFrontier_Lounge3_EventScript_ChooseBetAmount:: @ 8261DE9 - multichoice 20, 4, MULTI_FRONTIER_GAMBLER_BET, 0 + multichoice 20, 4, MULTI_FRONTIER_GAMBLER_BET, FALSE copyvar VAR_FRONTIER_GAMBLER_AMOUNT_BET, VAR_RESULT switch VAR_RESULT case FRONTIER_GAMBLER_BET_5, BattleFrontier_Lounge3_EventScript_Bet5 diff --git a/data/maps/BattleFrontier_OutsideWest/scripts.inc b/data/maps/BattleFrontier_OutsideWest/scripts.inc index 561b4e86a4..9a85593a16 100644 --- a/data/maps/BattleFrontier_OutsideWest/scripts.inc +++ b/data/maps/BattleFrontier_OutsideWest/scripts.inc @@ -29,7 +29,7 @@ BattleFrontier_OutsideWest_EventScript_FerryAttendant:: @ 823D3F0 end BattleFrontier_OutsideWest_EventScript_ChooseFerryDestination:: @ 823D416 - multichoicedefault 18, 6, MULTI_SSTIDAL_BATTLE_FRONTIER, 2, 0 + multichoicedefault 18, 6, MULTI_SSTIDAL_BATTLE_FRONTIER, 2, FALSE switch VAR_RESULT case 0, BattleFrontier_OutsideWest_EventScript_FerryToSlateport case 1, BattleFrontier_OutsideWest_EventScript_FerryToLilycove diff --git a/data/maps/BattleFrontier_ReceptionGate/scripts.inc b/data/maps/BattleFrontier_ReceptionGate/scripts.inc index 28f53de086..904bb52479 100644 --- a/data/maps/BattleFrontier_ReceptionGate/scripts.inc +++ b/data/maps/BattleFrontier_ReceptionGate/scripts.inc @@ -218,7 +218,7 @@ BattleFrontier_ReceptionGate_EventScript_RulesGuide:: @ 8266436 BattleFrontier_ReceptionGate_EventScript_ChooseRuleToLearnAbout:: @ 8266446 message BattleFrontier_ReceptionGate_Text_LearnAboutWhat waitmessage - multichoice 15, 0, MULTI_FRONTIER_RULES, 0 + multichoice 15, 0, MULTI_FRONTIER_RULES, FALSE switch VAR_RESULT case 0, BattleFrontier_ReceptionGate_EventScript_LevelMode case 1, BattleFrontier_ReceptionGate_EventScript_Level50 @@ -269,7 +269,7 @@ BattleFrontier_ReceptionGate_EventScript_FrontierPassGuide:: @ 82664F4 BattleFrontier_ReceptionGate_EventScript_ChooseFrontierPassInfoToLearnAbout:: @ 8266504 message BattleFrontier_ReceptionGate_Text_LearnAboutWhich1 waitmessage - multichoice 16, 4, MULTI_FRONTIER_PASS_INFO, 0 + multichoice 16, 4, MULTI_FRONTIER_PASS_INFO, FALSE switch VAR_RESULT case 0, BattleFrontier_ReceptionGate_EventScript_Symbols case 1, BattleFrontier_ReceptionGate_EventScript_RecordBattle diff --git a/data/maps/CaveOfOrigin_B1F/scripts.inc b/data/maps/CaveOfOrigin_B1F/scripts.inc index db267aaaa3..e9a146f735 100644 --- a/data/maps/CaveOfOrigin_B1F/scripts.inc +++ b/data/maps/CaveOfOrigin_B1F/scripts.inc @@ -24,7 +24,7 @@ CaveOfOrigin_B1F_EventScript_Wallace:: @ 82357A9 goto CaveOfOrigin_B1F_EventScript_WheresRayquaza CaveOfOrigin_B1F_EventScript_WheresRayquaza:: @ 82357F0 - multichoice 0, 0, MULTI_WHERES_RAYQUAZA, 0 + multichoice 0, 0, MULTI_WHERES_RAYQUAZA, FALSE switch VAR_RESULT case 0, CaveOfOrigin_B1F_EventScript_AtCaveOfOrigin case 1, CaveOfOrigin_B1F_EventScript_AtMtPyre diff --git a/data/maps/DewfordTown/scripts.inc b/data/maps/DewfordTown/scripts.inc index 27e82167ce..6298963c2b 100644 --- a/data/maps/DewfordTown/scripts.inc +++ b/data/maps/DewfordTown/scripts.inc @@ -24,7 +24,7 @@ DewfordTown_EventScript_Briney:: @ 81E9511 goto_if_unset FLAG_DELIVERED_STEVEN_LETTER, DewfordTown_EventScript_ReturnToPetalburgPrompt message DewfordTown_Text_WhereAreWeBound waitmessage - multichoicedefault 21, 6, MULTI_BRINEY_ON_DEWFORD, 2, 0 + multichoicedefault 21, 6, MULTI_BRINEY_ON_DEWFORD, 2, FALSE switch VAR_RESULT case 0, DewfordTown_EventScript_ChoosePetalburg case 1, DewfordTown_EventScript_ChooseSlateport @@ -109,7 +109,7 @@ DewfordTown_EventScript_NotGettingItchToFish:: @ 81E9620 DewfordTown_EventScript_HowsFishing:: @ 81E962A message DewfordTown_Text_HowsYourFishing waitmessage - multichoice 20, 8, MULTI_HOWS_FISHING, 1 + multichoice 20, 8, MULTI_HOWS_FISHING, TRUE compare VAR_RESULT, 0 goto_if_eq DewfordTown_EventScript_FishingExcellent compare VAR_RESULT, 1 diff --git a/data/maps/FallarborTown_BattleTentBattleRoom/scripts.inc b/data/maps/FallarborTown_BattleTentBattleRoom/scripts.inc index fd1f278608..83b91ab482 100644 --- a/data/maps/FallarborTown_BattleTentBattleRoom/scripts.inc +++ b/data/maps/FallarborTown_BattleTentBattleRoom/scripts.inc @@ -107,7 +107,7 @@ FallarborTown_BattleTentBattleRoom_EventScript_AskContinueChallenge:: @ 8200A2A call_if_eq FallarborTown_BattleTentBattleRoom_EventScript_ReadyFor2ndOpponent compare VAR_RESULT, 2 call_if_eq FallarborTown_BattleTentBattleRoom_EventScript_ReadyFor3rdOpponent - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, FallarborTown_BattleTentBattleRoom_EventScript_ContinueChallenge case 1, FallarborTown_BattleTentBattleRoom_EventScript_AskPauseChallenge @@ -123,7 +123,7 @@ FallarborTown_BattleTentBattleRoom_EventScript_AskPauseChallenge:: @ 8200A78 FallarborTown_BattleTentBattleRoom_EventScript_AskRetireChallenge:: @ 8200AA6 message BattleFrontier_BattleArenaBattleRoom_Text_RetireFromChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, FallarborTown_BattleTentBattleRoom_EventScript_AskContinueChallenge case 0, FallarborTown_BattleTentBattleRoom_EventScript_WarpToLobbyLost diff --git a/data/maps/FallarborTown_BattleTentLobby/scripts.inc b/data/maps/FallarborTown_BattleTentLobby/scripts.inc index 0a6a4f16cd..29fcb43a5e 100644 --- a/data/maps/FallarborTown_BattleTentLobby/scripts.inc +++ b/data/maps/FallarborTown_BattleTentLobby/scripts.inc @@ -113,7 +113,7 @@ FallarborTown_BattleTentLobby_EventScript_Attendant:: @ 8200001 FallarborTown_BattleTentLobby_EventScript_AskEnterChallenge:: @ 8200021 message FallarborTown_BattleTentLobby_Text_TakeChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, FallarborTown_BattleTentLobby_EventScript_TryEnterChallenge case 1, FallarborTown_BattleTentLobby_EventScript_ExplainChallenge @@ -266,7 +266,7 @@ FallarborTown_BattleTentLobby_EventScript_RulesBoard:: @ 820024F FallarborTown_BattleTentLobby_EventScript_ReadRulesBoard:: @ 820025E message BattleFrontier_BattleArenaLobby_Text_ReadWhichHeading waitmessage - multichoice 17, 0, MULTI_FALLARBOR_TENT_RULES, 0 + multichoice 17, 0, MULTI_FALLARBOR_TENT_RULES, FALSE switch VAR_RESULT case 0, FallarborTown_BattleTentLobby_EventScript_RulesLevel case 1, FallarborTown_BattleTentLobby_EventScript_RulesBattle diff --git a/data/maps/FortreeCity_House2/scripts.inc b/data/maps/FortreeCity_House2/scripts.inc index 98b8272fe7..394ad9ffc2 100644 --- a/data/maps/FortreeCity_House2/scripts.inc +++ b/data/maps/FortreeCity_House2/scripts.inc @@ -7,15 +7,15 @@ FortreeCity_House2_EventScript_HiddenPowerGiver:: @ 82177CB goto_if_set FLAG_RECEIVED_TM10, FortreeCity_House2_EventScript_ExplainHiddenPower call_if_unset FLAG_MET_HIDDEN_POWER_GIVER, FortreeCity_House2_EventScript_Greeting msgbox FortreeCity_House2_Text_CoinInWhichHand, MSGBOX_DEFAULT - multichoice 21, 8, MULTI_RIGHTLEFT, 1 + multichoice 21, 8, MULTI_RIGHTLEFT, TRUE switch VAR_RESULT case 1, FortreeCity_House2_EventScript_WrongGuess msgbox FortreeCity_House2_Text_CorrectTryAgainWhichHand, MSGBOX_DEFAULT - multichoice 21, 8, MULTI_RIGHTLEFT, 1 + multichoice 21, 8, MULTI_RIGHTLEFT, TRUE switch VAR_RESULT case 1, FortreeCity_House2_EventScript_WrongGuess msgbox FortreeCity_House2_Text_CorrectTryAgainWhichHand2, MSGBOX_DEFAULT - multichoice 21, 8, MULTI_RIGHTLEFT, 1 + multichoice 21, 8, MULTI_RIGHTLEFT, TRUE switch VAR_RESULT case 0, FortreeCity_House2_EventScript_WrongGuess msgbox FortreeCity_House2_Text_YourHiddenPowerHasAwoken, MSGBOX_DEFAULT diff --git a/data/maps/LilycoveCity_ContestLobby/scripts.inc b/data/maps/LilycoveCity_ContestLobby/scripts.inc index 3a3b3d86bf..300d4dfab2 100644 --- a/data/maps/LilycoveCity_ContestLobby/scripts.inc +++ b/data/maps/LilycoveCity_ContestLobby/scripts.inc @@ -638,7 +638,7 @@ LilycoveCity_ContestLobby_EventScript_LinkContestReceptionist:: @ 821A806 LilycoveCity_ContestLobby_EventScript_AskEnterLinkContest:: @ 821A819 message LilycoveCity_ContestLobby_Text_EnterContest3 waitmessage - multichoice 0, 0, MULTI_ENTERINFO, 0 + multichoice 0, 0, MULTI_ENTERINFO, FALSE switch VAR_RESULT case 0, LilycoveCity_ContestLobby_EventScript_TryEnterLinkContest case 1, LilycoveCity_ContestLobby_EventScript_LinkContestInfo @@ -656,7 +656,7 @@ LilycoveCity_ContestLobby_EventScript_TryEnterLinkContest:: @ 821A856 message LilycoveCity_ContestLobby_Text_WhichContestMode waitmessage specialvar VAR_TEMP_D, IsWirelessAdapterConnected - multichoice 0, 0, MULTI_LINK_CONTEST_MODE, 0 + multichoice 0, 0, MULTI_LINK_CONTEST_MODE, FALSE switch VAR_RESULT case 0, LilycoveCity_ContestLobby_EventScript_EmeraldMode @ Shortened to E-Mode case 1, LilycoveCity_ContestLobby_EventScript_GlobalMode @ Shortened to G-Mode @@ -679,7 +679,7 @@ LilycoveCity_ContestLobby_EventScript_GlobalMode:: @ 821A8C6 LilycoveCity_ContestLobby_EventScript_ChooseLinkContestType:: @ 821A8DC message LilycoveCity_ContestLobby_Text_EnterWhichContest3 waitmessage - multichoice 0, 0, MULTI_CONTEST_TYPE, 0 + multichoice 0, 0, MULTI_CONTEST_TYPE, FALSE switch VAR_RESULT case CONTEST_CATEGORIES_COUNT, LilycoveCity_ContestLobby_EventScript_CancelLinkContest case MULTI_B_PRESSED, LilycoveCity_ContestLobby_EventScript_CancelLinkContest @@ -690,7 +690,7 @@ LilycoveCity_ContestLobby_EventScript_ChooseLinkContestType:: @ 821A8DC LilycoveCity_ContestLobby_EventScript_LinkContestInfo:: @ 821A90D message LilycoveCity_ContestLobby_Text_WhichTopic2 waitmessage - multichoice 0, 0, MULTI_LINK_CONTEST_INFO, 0 + multichoice 0, 0, MULTI_LINK_CONTEST_INFO, FALSE switch VAR_RESULT case 0, LilycoveCity_ContestLobby_EventScript_ExplainLinkContest case 1, LilycoveCity_ContestLobby_EventScript_ExplainEMode @@ -885,7 +885,7 @@ LilycoveCity_ContestLobby_EventScript_SetLinkGroupToughContest:: @ 821ABA0 LilycoveCity_ContestLobby_EventScript_DecideLinkLeader:: @ 821ABA6 message LilycoveCity_ContestLobby_Text_PleaseDecideLinkLeader waitmessage - multichoice 16, 6, MULTI_LINK_LEADER, 0 + multichoice 16, 6, MULTI_LINK_LEADER, FALSE switch VAR_RESULT case 0, LilycoveCity_ContestLobby_EventScript_TryJoinGroup case 1, LilycoveCity_ContestLobby_EventScript_TryLeadGroup diff --git a/data/maps/LilycoveCity_DepartmentStoreElevator/scripts.inc b/data/maps/LilycoveCity_DepartmentStoreElevator/scripts.inc index b7d6e4a49d..10bd9eee52 100644 --- a/data/maps/LilycoveCity_DepartmentStoreElevator/scripts.inc +++ b/data/maps/LilycoveCity_DepartmentStoreElevator/scripts.inc @@ -22,27 +22,27 @@ LilycoveCity_DepartmentStoreElevator_EventScript_Attendant:: @ 8220624 @ Below scripts ensure the cursor for floor select always starts on the current floor LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloorFrom5th:: @ 8220689 - multichoicedefault 0, 0, MULTI_FLOORS, 0, 0 + multichoicedefault 0, 0, MULTI_FLOORS, 0, FALSE goto LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloor end LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloorFrom4th:: @ 8220695 - multichoicedefault 0, 0, MULTI_FLOORS, 1, 0 + multichoicedefault 0, 0, MULTI_FLOORS, 1, FALSE goto LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloor end LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloorFrom3rd:: @ 82206A1 - multichoicedefault 0, 0, MULTI_FLOORS, 2, 0 + multichoicedefault 0, 0, MULTI_FLOORS, 2, FALSE goto LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloor end LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloorFrom2nd:: @ 82206AD - multichoicedefault 0, 0, MULTI_FLOORS, 3, 0 + multichoicedefault 0, 0, MULTI_FLOORS, 3, FALSE goto LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloor end LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloorFrom1st:: @ 82206B9 - multichoicedefault 0, 0, MULTI_FLOORS, 4, 0 + multichoicedefault 0, 0, MULTI_FLOORS, 4, FALSE goto LilycoveCity_DepartmentStoreElevator_EventScript_ChooseFloor end diff --git a/data/maps/LilycoveCity_DepartmentStoreRooftop/scripts.inc b/data/maps/LilycoveCity_DepartmentStoreRooftop/scripts.inc index 8d7459b3c3..68771a2ddf 100644 --- a/data/maps/LilycoveCity_DepartmentStoreRooftop/scripts.inc +++ b/data/maps/LilycoveCity_DepartmentStoreRooftop/scripts.inc @@ -76,7 +76,7 @@ LilycoveCity_DepartmentStoreRooftop_EventScript_VendingMachine:: @ 8220295 end LilycoveCity_DepartmentStoreRooftop_EventScript_ChooseDrink:: @ 82202A6 - multichoice 16, 0, MULTI_VENDING_MACHINE, 0 + multichoice 16, 0, MULTI_VENDING_MACHINE, FALSE copyvar VAR_TEMP_1, VAR_RESULT switch VAR_TEMP_1 case 0, LilycoveCity_DepartmentStoreRooftop_EventScript_FreshWater diff --git a/data/maps/LilycoveCity_LilycoveMuseum_1F/scripts.inc b/data/maps/LilycoveCity_LilycoveMuseum_1F/scripts.inc index 624e304c83..ded9ed53d8 100644 --- a/data/maps/LilycoveCity_LilycoveMuseum_1F/scripts.inc +++ b/data/maps/LilycoveCity_LilycoveMuseum_1F/scripts.inc @@ -13,7 +13,7 @@ LilycoveCity_LilycoveMuseum_1F_EventScript_Curator:: @ 8218CC2 applymovement LOCALID_CURATOR, Common_Movement_FacePlayer message LilycoveCity_LilycoveMuseum_1F_Text_ImCuratorHaveYouViewedOurPaintings waitmessage - multichoice 20, 8, MULTI_VIEWED_PAINTINGS, 1 + multichoice 20, 8, MULTI_VIEWED_PAINTINGS, TRUE compare VAR_RESULT, 0 goto_if_eq LilycoveCity_LilycoveMuseum_1F_EventScript_SawPaintings compare VAR_RESULT, 1 diff --git a/data/maps/MauvilleCity_BikeShop/scripts.inc b/data/maps/MauvilleCity_BikeShop/scripts.inc index ffde9583b6..6832554e44 100644 --- a/data/maps/MauvilleCity_BikeShop/scripts.inc +++ b/data/maps/MauvilleCity_BikeShop/scripts.inc @@ -25,7 +25,7 @@ MauvilleCity_BikeShop_EventScript_SkipGreeting:: @ 820EBF7 MauvilleCity_BikeShop_EventScript_ChooseBike:: @ 820EC16 message MauvilleCity_BikeShop_Text_ExplainBikesChooseWhichOne waitmessage - multichoice 21, 8, MULTI_BIKE, 1 + multichoice 21, 8, MULTI_BIKE, TRUE switch VAR_RESULT case 0, MauvilleCity_BikeShop_EventScript_GetMachBike case 1, MauvilleCity_BikeShop_EventScript_GetAcroBike @@ -113,7 +113,7 @@ MauvilleCity_BikeShop_EventScript_MachBikeHandbook:: @ 820ED3A end MauvilleCity_BikeShop_EventScript_ChooseMachHandbookPage:: @ 820ED46 - multichoice 0, 0, MULTI_MACH_BIKE_INFO, 0 + multichoice 0, 0, MULTI_MACH_BIKE_INFO, FALSE switch VAR_RESULT case 0, MauvilleCity_BikeShop_EventScript_HowToRide case 1, MauvilleCity_BikeShop_EventScript_HowToTurn @@ -151,7 +151,7 @@ MauvilleCity_BikeShop_EventScript_AcroBikeHandbook:: @ 820EDAE end MauvilleCity_BikeShop_EventScript_ChooseAcroHandbookPage:: @ 820EDBA - multichoice 0, 0, MULTI_ACRO_BIKE_INFO, 0 + multichoice 0, 0, MULTI_ACRO_BIKE_INFO, FALSE switch VAR_RESULT case 0, MauvilleCity_BikeShop_EventScript_Wheelies case 1, MauvilleCity_BikeShop_EventScript_BunnyHops diff --git a/data/maps/MauvilleCity_GameCorner/scripts.inc b/data/maps/MauvilleCity_GameCorner/scripts.inc index ad3f7a407f..f8cf2ea181 100644 --- a/data/maps/MauvilleCity_GameCorner/scripts.inc +++ b/data/maps/MauvilleCity_GameCorner/scripts.inc @@ -26,7 +26,7 @@ MauvilleCity_GameCorner_EventScript_CoinsClerk:: @ 820FBB9 goto MauvilleCity_GameCorner_EventScript_ChooseCoinsDefault50 MauvilleCity_GameCorner_EventScript_ChooseCoinsDefault50:: @ 820FBE5 - multichoicedefault 15, 0, MULTI_GAME_CORNER_COINS, 0, 0 + multichoicedefault 15, 0, MULTI_GAME_CORNER_COINS, 0, FALSE switch VAR_RESULT case 0, MauvilleCity_GameCorner_EventScript_Buy50Coins case 1, MauvilleCity_GameCorner_EventScript_Buy500Coins @@ -35,7 +35,7 @@ MauvilleCity_GameCorner_EventScript_ChooseCoinsDefault50:: @ 820FBE5 @ Unused MauvilleCity_GameCorner_EventScript_ChooseCoinsDefault500:: @ 820FC0C - multichoicedefault 15, 0, MULTI_GAME_CORNER_COINS, 1, 0 + multichoicedefault 15, 0, MULTI_GAME_CORNER_COINS, 1, FALSE switch VAR_RESULT case 0, MauvilleCity_GameCorner_EventScript_Buy50Coins case 1, MauvilleCity_GameCorner_EventScript_Buy500Coins @@ -127,7 +127,7 @@ MauvilleCity_GameCorner_EventScript_ReturnToChooseDollPrize:: @ 820FD20 goto MauvilleCity_GameCorner_EventScript_ChooseDollPrize MauvilleCity_GameCorner_EventScript_ChooseDollPrize:: @ 820FD2B - multichoice 12, 0, MULTI_GAME_CORNER_DOLLS, 0 + multichoice 12, 0, MULTI_GAME_CORNER_DOLLS, FALSE switch VAR_RESULT case 0, MauvilleCity_GameCorner_EventScript_TreeckoDoll case 1, MauvilleCity_GameCorner_EventScript_TorchicDoll @@ -248,7 +248,7 @@ MauvilleCity_GameCorner_EventScript_ReturnToChooseTMPrize:: @ 820FECE goto MauvilleCity_GameCorner_EventScript_ChooseTMPrize MauvilleCity_GameCorner_EventScript_ChooseTMPrize:: @ 820FED9 - multichoice 12, 0, MULTI_GAME_CORNER_TMS, 0 + multichoice 12, 0, MULTI_GAME_CORNER_TMS, FALSE switch VAR_RESULT case 0, MauvilleCity_GameCorner_EventScript_TM32 case 1, MauvilleCity_GameCorner_EventScript_TM29 diff --git a/data/maps/Route104_MrBrineysHouse/scripts.inc b/data/maps/Route104_MrBrineysHouse/scripts.inc index aef3ae80fe..186254d92b 100644 --- a/data/maps/Route104_MrBrineysHouse/scripts.inc +++ b/data/maps/Route104_MrBrineysHouse/scripts.inc @@ -44,7 +44,7 @@ Route104_MrBrineysHouse_EventScript_SailingIntro:: @ 8229D8A Route104_MrBrineysHouse_EventScript_WhereAreWeBound:: @ 8229DAE message Route104_MrBrineysHouse_Text_WhereAreWeBound waitmessage - multichoicedefault 20, 8, MULTI_BRINEY_OFF_DEWFORD, 1, 0 + multichoicedefault 20, 8, MULTI_BRINEY_OFF_DEWFORD, 1, FALSE switch VAR_RESULT case 0, Route104_MrBrineysHouse_EventScript_SailToDewford case 1, Route104_MrBrineysHouse_EventScript_DeclineSailing diff --git a/data/maps/Route109/scripts.inc b/data/maps/Route109/scripts.inc index 26da7f2b59..a88e864591 100644 --- a/data/maps/Route109/scripts.inc +++ b/data/maps/Route109/scripts.inc @@ -290,7 +290,7 @@ Route109_EventScript_HaveNotDeliveredDevonGood:: @ 81EE921 Route109_EventScript_DeliveredDevonGoods:: @ 81EE93F message Route109_Text_BrineyWhereAreWeBound waitmessage - multichoicedefault 21, 8, MULTI_BRINEY_OFF_DEWFORD, 1, 0 + multichoicedefault 21, 8, MULTI_BRINEY_OFF_DEWFORD, 1, FALSE switch VAR_RESULT case 0, Route109_EventScript_SailToDewford case 1, Route109_EventScript_ChoseNotToSail diff --git a/data/maps/Route110_TrickHouseEnd/scripts.inc b/data/maps/Route110_TrickHouseEnd/scripts.inc index 0852b4e334..8e1ffdeb20 100644 --- a/data/maps/Route110_TrickHouseEnd/scripts.inc +++ b/data/maps/Route110_TrickHouseEnd/scripts.inc @@ -178,7 +178,7 @@ Route110_TrickHouseEnd_EventScript_CompletedPuzzle8:: @ 826AF28 end Route110_TrickHouseEnd_EventScript_ChooseTent:: @ 826AFA5 - multichoice 0, 0, MULTI_TENT, 1 + multichoice 0, 0, MULTI_TENT, TRUE switch VAR_RESULT case 0, Route110_TrickHouseEnd_EventScript_GiveRedTent goto Route110_TrickHouseEnd_EventScript_GiveBlueTent diff --git a/data/maps/Route110_TrickHouseEntrance/scripts.inc b/data/maps/Route110_TrickHouseEntrance/scripts.inc index adfcf6bbc4..4df752dc16 100644 --- a/data/maps/Route110_TrickHouseEntrance/scripts.inc +++ b/data/maps/Route110_TrickHouseEntrance/scripts.inc @@ -460,7 +460,7 @@ Route110_TrickHouseEntrance_EventScript_MechadollReward:: @ 826A039 end Route110_TrickHouseEntrance_EventScript_ChooseTent:: @ 826A070 - multichoice 0, 0, MULTI_TENT, 1 + multichoice 0, 0, MULTI_TENT, TRUE switch VAR_RESULT case 0, Route110_TrickHouseEntrance_EventScript_GiveRedTent goto Route110_TrickHouseEntrance_EventScript_GiveBlueTent diff --git a/data/maps/Route110_TrickHousePuzzle5/scripts.inc b/data/maps/Route110_TrickHousePuzzle5/scripts.inc index 36162f42f7..9c66a2c8f9 100644 --- a/data/maps/Route110_TrickHousePuzzle5/scripts.inc +++ b/data/maps/Route110_TrickHousePuzzle5/scripts.inc @@ -334,7 +334,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll5Activate:: @ 826CEF2 Route110_TrickHousePuzzle5_EventScript_Mechadoll1Quiz1:: @ 826CF45 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll1Quiz1, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL1_Q1, 1 + multichoice 0, 0, MULTI_MECHADOLL1_Q1, TRUE switch VAR_RESULT case 2, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -342,7 +342,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll1Quiz1:: @ 826CF45 Route110_TrickHousePuzzle5_EventScript_Mechadoll1Quiz2:: @ 826CF68 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll1Quiz2, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL1_Q2, 1 + multichoice 0, 0, MULTI_MECHADOLL1_Q2, TRUE switch VAR_RESULT case 0, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -350,7 +350,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll1Quiz2:: @ 826CF68 Route110_TrickHousePuzzle5_EventScript_Mechadoll1Quiz3:: @ 826CF8B msgbox Route110_TrickHousePuzzle5_Text_Mechadoll1Quiz3, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL1_Q3, 1 + multichoice 0, 0, MULTI_MECHADOLL1_Q3, TRUE switch VAR_RESULT case 0, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -358,7 +358,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll1Quiz3:: @ 826CF8B Route110_TrickHousePuzzle5_EventScript_Mechadoll2Quiz1:: @ 826CFAE msgbox Route110_TrickHousePuzzle5_Text_Mechadoll2Quiz1, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL2_Q1, 1 + multichoice 0, 0, MULTI_MECHADOLL2_Q1, TRUE switch VAR_RESULT case 1, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -366,7 +366,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll2Quiz1:: @ 826CFAE Route110_TrickHousePuzzle5_EventScript_Mechadoll2Quiz2:: @ 826CFD1 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll2Quiz2, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL2_Q2, 1 + multichoice 0, 0, MULTI_MECHADOLL2_Q2, TRUE switch VAR_RESULT case 2, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -374,7 +374,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll2Quiz2:: @ 826CFD1 Route110_TrickHousePuzzle5_EventScript_Mechadoll2Quiz3:: @ 826CFF4 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll2Quiz3, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL2_Q3, 1 + multichoice 0, 0, MULTI_MECHADOLL2_Q3, TRUE switch VAR_RESULT case 0, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -382,7 +382,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll2Quiz3:: @ 826CFF4 Route110_TrickHousePuzzle5_EventScript_Mechadoll3Quiz1:: @ 826D017 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll3Quiz1, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL3_Q1, 1 + multichoice 0, 0, MULTI_MECHADOLL3_Q1, TRUE switch VAR_RESULT case 0, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -390,7 +390,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll3Quiz1:: @ 826D017 Route110_TrickHousePuzzle5_EventScript_Mechadoll3Quiz2:: @ 826D03A msgbox Route110_TrickHousePuzzle5_Text_Mechadoll3Quiz2, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL3_Q2, 1 + multichoice 0, 0, MULTI_MECHADOLL3_Q2, TRUE switch VAR_RESULT case 2, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -398,7 +398,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll3Quiz2:: @ 826D03A Route110_TrickHousePuzzle5_EventScript_Mechadoll3Quiz3:: @ 826D05D msgbox Route110_TrickHousePuzzle5_Text_Mechadoll3Quiz3, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL3_Q3, 1 + multichoice 0, 0, MULTI_MECHADOLL3_Q3, TRUE switch VAR_RESULT case 1, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -406,7 +406,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll3Quiz3:: @ 826D05D Route110_TrickHousePuzzle5_EventScript_Mechadoll4Quiz1:: @ 826D080 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll4Quiz1, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL4_Q1, 1 + multichoice 0, 0, MULTI_MECHADOLL4_Q1, TRUE switch VAR_RESULT case 0, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -414,7 +414,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll4Quiz1:: @ 826D080 Route110_TrickHousePuzzle5_EventScript_Mechadoll4Quiz2:: @ 826D0A3 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll4Quiz2, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL4_Q2, 1 + multichoice 0, 0, MULTI_MECHADOLL4_Q2, TRUE switch VAR_RESULT case 0, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -422,7 +422,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll4Quiz2:: @ 826D0A3 Route110_TrickHousePuzzle5_EventScript_Mechadoll4Quiz3:: @ 826D0C6 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll4Quiz3, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL4_Q3, 1 + multichoice 0, 0, MULTI_MECHADOLL4_Q3, TRUE switch VAR_RESULT case 1, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -430,7 +430,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll4Quiz3:: @ 826D0C6 Route110_TrickHousePuzzle5_EventScript_Mechadoll5Quiz1:: @ 826D0E9 msgbox Route110_TrickHousePuzzle5_Text_Mechadoll5Quiz1, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL5_Q1, 1 + multichoice 0, 0, MULTI_MECHADOLL5_Q1, TRUE switch VAR_RESULT case 1, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -438,7 +438,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll5Quiz1:: @ 826D0E9 Route110_TrickHousePuzzle5_EventScript_Mechadoll5Quiz2:: @ 826D10C msgbox Route110_TrickHousePuzzle5_Text_Mechadoll5Quiz2, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL5_Q2, 1 + multichoice 0, 0, MULTI_MECHADOLL5_Q2, TRUE switch VAR_RESULT case 0, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer @@ -446,7 +446,7 @@ Route110_TrickHousePuzzle5_EventScript_Mechadoll5Quiz2:: @ 826D10C Route110_TrickHousePuzzle5_EventScript_Mechadoll5Quiz3:: @ 826D12F msgbox Route110_TrickHousePuzzle5_Text_Mechadoll5Quiz3, MSGBOX_DEFAULT - multichoice 0, 0, MULTI_MECHADOLL5_Q3, 1 + multichoice 0, 0, MULTI_MECHADOLL5_Q3, TRUE switch VAR_RESULT case 2, Route110_TrickHousePuzzle5_EventScript_CorrectAnswer goto Route110_TrickHousePuzzle5_EventScript_IncorrectAnswer diff --git a/data/maps/Route124_DivingTreasureHuntersHouse/scripts.inc b/data/maps/Route124_DivingTreasureHuntersHouse/scripts.inc index c5d43799d9..acf53c1eda 100644 --- a/data/maps/Route124_DivingTreasureHuntersHouse/scripts.inc +++ b/data/maps/Route124_DivingTreasureHuntersHouse/scripts.inc @@ -86,7 +86,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShowTradeOptions:: @ 8270ADE end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsR:: @ 8270B8F - multichoice 0, 0, MULTI_SHARDS_R, 0 + multichoice 0, 0, MULTI_SHARDS_R, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeRedShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_DeclineTrade @@ -94,7 +94,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsR:: @ 8270B8F end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsY:: @ 8270BB5 - multichoice 0, 0, MULTI_SHARDS_Y, 0 + multichoice 0, 0, MULTI_SHARDS_Y, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeYellowShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_DeclineTrade @@ -102,7 +102,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsY:: @ 8270BB5 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRY:: @ 8270BDB - multichoice 0, 0, MULTI_SHARDS_RY, 0 + multichoice 0, 0, MULTI_SHARDS_RY, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeRedShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeYellowShard @@ -111,7 +111,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRY:: @ 8270BDB end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsB:: @ 8270C0C - multichoice 0, 0, MULTI_SHARDS_B, 0 + multichoice 0, 0, MULTI_SHARDS_B, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeBlueShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_DeclineTrade @@ -119,7 +119,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsB:: @ 8270C0C end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRB:: @ 8270C32 - multichoice 0, 0, MULTI_SHARDS_RB, 0 + multichoice 0, 0, MULTI_SHARDS_RB, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeRedShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeBlueShard @@ -128,7 +128,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRB:: @ 8270C32 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsYB:: @ 8270C63 - multichoice 0, 0, MULTI_SHARDS_YB, 0 + multichoice 0, 0, MULTI_SHARDS_YB, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeYellowShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeBlueShard @@ -137,7 +137,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsYB:: @ 8270C63 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRYB:: @ 8270C94 - multichoice 0, 0, MULTI_SHARDS_RYB, 0 + multichoice 0, 0, MULTI_SHARDS_RYB, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeRedShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeYellowShard @@ -147,7 +147,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRYB:: @ 8270C94 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsG:: @ 8270CD0 - multichoice 0, 0, MULTI_SHARDS_G, 0 + multichoice 0, 0, MULTI_SHARDS_G, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeGreenShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_DeclineTrade @@ -155,7 +155,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsG:: @ 8270CD0 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRG:: @ 8270CF6 - multichoice 0, 0, MULTI_SHARDS_RG, 0 + multichoice 0, 0, MULTI_SHARDS_RG, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeRedShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeGreenShard @@ -164,7 +164,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRG:: @ 8270CF6 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsYG:: @ 8270D27 - multichoice 0, 0, MULTI_SHARDS_YG, 0 + multichoice 0, 0, MULTI_SHARDS_YG, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeYellowShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeGreenShard @@ -173,7 +173,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsYG:: @ 8270D27 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRYG:: @ 8270D58 - multichoice 0, 0, MULTI_SHARDS_RYG, 0 + multichoice 0, 0, MULTI_SHARDS_RYG, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeRedShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeYellowShard @@ -183,7 +183,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRYG:: @ 8270D58 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsBG:: @ 8270D94 - multichoice 0, 0, MULTI_SHARDS_BG, 0 + multichoice 0, 0, MULTI_SHARDS_BG, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeBlueShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeGreenShard @@ -192,7 +192,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsBG:: @ 8270D94 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRBG:: @ 8270DC5 - multichoice 0, 0, MULTI_SHARDS_RBG, 0 + multichoice 0, 0, MULTI_SHARDS_RBG, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeRedShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeBlueShard @@ -202,7 +202,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRBG:: @ 8270DC5 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsYBG:: @ 8270E01 - multichoice 0, 0, MULTI_SHARDS_YBG, 0 + multichoice 0, 0, MULTI_SHARDS_YBG, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeYellowShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeBlueShard @@ -212,7 +212,7 @@ Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsYBG:: @ 8270E01 end Route124_DivingTreasureHuntersHouse_EventScript_ShardOptionsRYBG:: @ 8270E3D - multichoice 0, 0, MULTI_SHARDS_RYBG, 0 + multichoice 0, 0, MULTI_SHARDS_RYBG, FALSE switch VAR_RESULT case 0, Route124_DivingTreasureHuntersHouse_EventScript_TradeRedShard case 1, Route124_DivingTreasureHuntersHouse_EventScript_TradeYellowShard diff --git a/data/maps/RustboroCity_DevonCorp_2F/scripts.inc b/data/maps/RustboroCity_DevonCorp_2F/scripts.inc index eb22fcc43a..03396cc8fb 100644 --- a/data/maps/RustboroCity_DevonCorp_2F/scripts.inc +++ b/data/maps/RustboroCity_DevonCorp_2F/scripts.inc @@ -259,7 +259,7 @@ RustboroCity_DevonCorp_2F_EventScript_FinishReceivingAnorith:: @ 8211B7A RustboroCity_DevonCorp_2F_EventScript_ChooseFossil:: @ 8211B84 message RustboroCity_DevonCorp_2F_Text_TwoFossilsPickOne waitmessage - multichoice 17, 6, MULTI_FOSSIL, 0 + multichoice 17, 6, MULTI_FOSSIL, FALSE switch VAR_RESULT case 0, RustboroCity_DevonCorp_2F_EventScript_ChooseClawFossil case 1, RustboroCity_DevonCorp_2F_EventScript_ChooseRootFossil diff --git a/data/maps/RustboroCity_PokemonSchool/scripts.inc b/data/maps/RustboroCity_PokemonSchool/scripts.inc index 6e5bf0fced..29c37fe495 100644 --- a/data/maps/RustboroCity_PokemonSchool/scripts.inc +++ b/data/maps/RustboroCity_PokemonSchool/scripts.inc @@ -10,7 +10,7 @@ RustboroCity_PokemonSchool_EventScript_Blackboard:: @ 8213EA9 RustboroCity_PokemonSchool_EventScript_ChooseBlackboardTopic:: @ 8213EB8 message RustboroCity_PokemonSchool_Text_ReadWhichTopic waitmessage - multichoicegrid 8, 1, MULTI_STATUS_INFO, 3, 0 + multichoicegrid 8, 1, MULTI_STATUS_INFO, 3, FALSE switch VAR_RESULT case 0, RustboroCity_PokemonSchool_EventScript_Poison case 1, RustboroCity_PokemonSchool_EventScript_Paralysis diff --git a/data/maps/SlateportCity_BattleTentCorridor/scripts.inc b/data/maps/SlateportCity_BattleTentCorridor/scripts.inc index c018f54b9d..b04b03b99b 100644 --- a/data/maps/SlateportCity_BattleTentCorridor/scripts.inc +++ b/data/maps/SlateportCity_BattleTentCorridor/scripts.inc @@ -69,7 +69,7 @@ SlateportCity_BattleTentCorridor_EventScript_AskReadyForOpponent:: @ 8208F0D call_if_eq SlateportCity_BattleTentCorridor_EventScript_ReadyFor2ndOpponent compare VAR_RESULT, 2 call_if_eq SlateportCity_BattleTentCorridor_EventScript_ReadyFor3rdOpponent - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, SlateportCity_BattleTentCorridor_EventScript_AskSwapMon case 1, SlateportCity_BattleTentCorridor_EventScript_AskPauseChallenge @@ -85,7 +85,7 @@ SlateportCity_BattleTentCorridor_EventScript_AskPauseChallenge:: @ 8208F5B SlateportCity_BattleTentCorridor_EventScript_AskRetireChallenge:: @ 8208F89 message BattleFrontier_BattleFactoryPreBattleRoom_Text_RetireFromChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, SlateportCity_BattleTentCorridor_EventScript_AskReadyForOpponent case 0, SlateportCity_BattleTent_EventScript_WarpToLobbyLost diff --git a/data/maps/SlateportCity_BattleTentLobby/scripts.inc b/data/maps/SlateportCity_BattleTentLobby/scripts.inc index bdc8eb05f9..07758d42d4 100644 --- a/data/maps/SlateportCity_BattleTentLobby/scripts.inc +++ b/data/maps/SlateportCity_BattleTentLobby/scripts.inc @@ -100,7 +100,7 @@ SlateportCity_BattleTentLobby_EventScript_Attendant:: @ 82088AA SlateportCity_BattleTentLobby_EventScript_AskEnterChallenge:: @ 82088CA message SlateportCity_BattleTentLobby_Text_TakeChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, SlateportCity_BattleTentLobby_EventScript_TryEnterChallenge case 1, SlateportCity_BattleTentLobby_EventScript_ExplainChallenge @@ -237,7 +237,7 @@ SlateportCity_BattleTentLobby_EventScript_RulesBoard:: @ 8208A99 SlateportCity_BattleTentLobby_EventScript_ReadRulesBoard:: @ 8208AA8 message BattleFrontier_BattleFactoryLobby_Text_ReadWhichHeading waitmessage - multichoice 17, 0, MULTI_SLATEPORT_TENT_RULES, 0 + multichoice 17, 0, MULTI_SLATEPORT_TENT_RULES, FALSE switch VAR_RESULT case 0, SlateportCity_BattleTentLobby_EventScript_RulesBasics case 1, SlateportCity_BattleTentLobby_EventScript_RulesSwapPartner diff --git a/data/maps/SlateportCity_Harbor/scripts.inc b/data/maps/SlateportCity_Harbor/scripts.inc index 41a224f75d..276ee32f8d 100644 --- a/data/maps/SlateportCity_Harbor/scripts.inc +++ b/data/maps/SlateportCity_Harbor/scripts.inc @@ -182,7 +182,7 @@ SlateportCity_Harbor_EventScript_AskForTicket:: @ 820CB06 SlateportCity_Harbor_EventScript_ChooseDestination:: @ 820CB1A goto_if_set FLAG_MET_SCOTT_ON_SS_TIDAL, SlateportCity_Harbor_EventScript_ChooseDestinationWithBattleFrontier - multichoicedefault 18, 8, MULTI_SSTIDAL_SLATEPORT_NO_BF, 2, 0 + multichoicedefault 18, 8, MULTI_SSTIDAL_SLATEPORT_NO_BF, 2, FALSE switch VAR_RESULT case 0, SlateportCity_Harbor_EventScript_Lilycove case 1, SlateportCity_Harbor_EventScript_CancelDestinationSelect @@ -190,7 +190,7 @@ SlateportCity_Harbor_EventScript_ChooseDestination:: @ 820CB1A end SlateportCity_Harbor_EventScript_ChooseDestinationWithBattleFrontier:: @ 820CB50 - multichoicedefault 17, 6, MULTI_SSTIDAL_SLATEPORT_WITH_BF, 2, 0 + multichoicedefault 17, 6, MULTI_SSTIDAL_SLATEPORT_WITH_BF, 2, FALSE switch VAR_RESULT case 0, SlateportCity_Harbor_EventScript_Lilycove case 1, SlateportCity_Harbor_EventScript_BattleFrontier @@ -352,7 +352,7 @@ SlateportCity_Harbor_EventScript_AskToTradeScanner:: @ 820CD38 end SlateportCity_Harbor_EventScript_ChooseScannerTrade:: @ 820CD44 - multichoice 0, 0, MULTI_STERN_DEEPSEA, 0 + multichoice 0, 0, MULTI_STERN_DEEPSEA, FALSE switch VAR_RESULT case 0, SlateportCity_Harbor_EventScript_DeepSeaTooth case 1, SlateportCity_Harbor_EventScript_DeepSeaScale diff --git a/data/maps/TrainerHill_Entrance/scripts.inc b/data/maps/TrainerHill_Entrance/scripts.inc index b5b0f716ca..7f8178d007 100644 --- a/data/maps/TrainerHill_Entrance/scripts.inc +++ b/data/maps/TrainerHill_Entrance/scripts.inc @@ -145,7 +145,7 @@ TrainerHill_Entrance_EventScript_AllFloorsUsed:: @ 8268275 TrainerHill_Entrance_EventScript_AskChallengeTrainers:: @ 826827D message TrainerHill_Entrance_Text_LikeToChallengeTrainers waitmessage - multichoice 15, 6, MULTI_YESNOINFO, 0 + multichoice 15, 6, MULTI_YESNOINFO, FALSE switch VAR_RESULT case 0, TrainerHill_Entrance_EventScript_ChooseChallenge case 1, TrainerHill_Entrance_EventScript_CancelEntry @@ -159,7 +159,7 @@ TrainerHill_Entrance_EventScript_Info:: @ 82682BA end TrainerHill_Entrance_EventScript_ChooseChallenge:: @ 82682C8 - multichoice 13, 2, MULTI_TAG_MATCH_TYPE, 0 + multichoice 13, 2, MULTI_TAG_MATCH_TYPE, FALSE switch VAR_RESULT case 4, TrainerHill_Entrance_EventScript_CancelEntry case MULTI_B_PRESSED, TrainerHill_Entrance_EventScript_CancelEntry diff --git a/data/maps/VerdanturfTown_BattleTentBattleRoom/scripts.inc b/data/maps/VerdanturfTown_BattleTentBattleRoom/scripts.inc index ad77cdf5fc..f917db9ed4 100644 --- a/data/maps/VerdanturfTown_BattleTentBattleRoom/scripts.inc +++ b/data/maps/VerdanturfTown_BattleTentBattleRoom/scripts.inc @@ -88,7 +88,7 @@ VerdanturfTown_BattleTentBattleRoom_EventScript_AskContinueChallenge:: @ 820243C call_if_eq VerdanturfTown_BattleTentBattleRoom_EventScript_ReadyFor2ndOpponent compare VAR_RESULT, 2 call_if_eq VerdanturfTown_BattleTentBattleRoom_EventScript_ReadyFor3rdOpponent - multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, 1 + multichoice 20, 6, MULTI_GO_ON_REST_RETIRE, TRUE switch VAR_RESULT case 0, VerdanturfTown_BattleTentBattleRoom_EventScript_ContinueChallenge case 1, VerdanturfTown_BattleTentBattleRoom_EventScript_AskPauseChallenge @@ -104,7 +104,7 @@ VerdanturfTown_BattleTentBattleRoom_EventScript_AskPauseChallenge:: @ 820248A VerdanturfTown_BattleTentBattleRoom_EventScript_AskRetireChallenge:: @ 82024B8 message BattleFrontier_BattlePalaceBattleRoom_Text_WishToQuitChallenge waitmessage - multichoicedefault 20, 8, MULTI_YESNO, 1, 0 + multichoicedefault 20, 8, MULTI_YESNO, 1, FALSE switch VAR_RESULT case 1, VerdanturfTown_BattleTentBattleRoom_EventScript_AskContinueChallenge case 0, VerdanturfTown_BattleTentBattleRoom_EventScript_WarpToLobbyLost diff --git a/data/maps/VerdanturfTown_BattleTentLobby/scripts.inc b/data/maps/VerdanturfTown_BattleTentLobby/scripts.inc index f7a03b1ec9..ff2e6b1240 100644 --- a/data/maps/VerdanturfTown_BattleTentLobby/scripts.inc +++ b/data/maps/VerdanturfTown_BattleTentLobby/scripts.inc @@ -114,7 +114,7 @@ VerdanturfTown_BattleTentLobby_EventScript_Attendant:: @ 8201873 VerdanturfTown_BattleTentLobby_EventScript_AskEnterChallenge:: @ 8201893 message VerdanturfTown_BattleTentLobby_Text_TakeChallenge waitmessage - multichoice 17, 6, MULTI_CHALLENGEINFO, 0 + multichoice 17, 6, MULTI_CHALLENGEINFO, FALSE switch VAR_RESULT case 0, VerdanturfTown_BattleTentLobby_EventScript_TryEnterChallenge case 1, VerdanturfTown_BattleTentLobby_EventScript_ExplainChallenge diff --git a/data/scripts/berry_blender.inc b/data/scripts/berry_blender.inc index 7ad8e9e3ae..d8dbe80bdf 100644 --- a/data/scripts/berry_blender.inc +++ b/data/scripts/berry_blender.inc @@ -711,7 +711,7 @@ BerryBlender_EventScript_StartDecideLinkLeader: @ 82941ED BerryBlender_EventScript_DecideLinkLeader: @ 82941F8 message LilycoveCity_ContestLobby_Text_PleaseDecideLinkLeader waitmessage - multichoice 16, 6, MULTI_LINK_LEADER, 0 + multichoice 16, 6, MULTI_LINK_LEADER, FALSE switch VAR_RESULT case 0, BerryBlender_EventScript_TryJoinGroup case 1, BerryBlender_EventScript_TryLeadGroup diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc index b81fbb4d54..189a97b256 100644 --- a/data/scripts/cable_club.inc +++ b/data/scripts/cable_club.inc @@ -277,7 +277,7 @@ CableClub_EventScript_UnusedWelcomeToCableClub:: @ 8276E22 CableClub_EventScript_SelectCableClubRoom:: @ 8276E30 setvar VAR_0x8004, 0 goto_if_set FLAG_VISITED_MAUVILLE_CITY, CableClub_EventScript_CableClubUnlockedRecordCorner - multichoice 0, 0, MULTI_CABLE_CLUB_NO_RECORD_MIX, 0 + multichoice 0, 0, MULTI_CABLE_CLUB_NO_RECORD_MIX, FALSE switch VAR_RESULT case 0, CableClub_EventScript_TradeCenter case 1, CableClub_EventScript_Colosseum @@ -286,7 +286,7 @@ CableClub_EventScript_SelectCableClubRoom:: @ 8276E30 end CableClub_EventScript_CableClubUnlockedRecordCorner:: @ 8276E75 - multichoice 0, 0, MULTI_CABLE_CLUB_WITH_RECORD_MIX, 0 + multichoice 0, 0, MULTI_CABLE_CLUB_WITH_RECORD_MIX, FALSE switch VAR_RESULT case 0, CableClub_EventScript_TradeCenter case 1, CableClub_EventScript_Colosseum @@ -303,7 +303,7 @@ CableClub_EventScript_Colosseum:: @ 8276EB7 CableClub_EventScript_SelectBattleMode:: @ 8276EC2 message CableClub_Text_PlayWhichBattleMode waitmessage - multichoice 0, 0, MULTI_BATTLE_MODE, 0 + multichoice 0, 0, MULTI_BATTLE_MODE, FALSE switch VAR_RESULT case 0, CableClub_EventScript_SingleBattleMode case 1, CableClub_EventScript_DoubleBattleMode @@ -927,7 +927,7 @@ CableClub_EventScript_UnionRoomAttendant:: @ 827751B end CableClub_EventScript_UnionRoomSelect:: @ 827755C - multichoice 17, 6, MULTI_YESNOINFO, 0 + multichoice 17, 6, MULTI_YESNOINFO, FALSE switch VAR_RESULT case 0, CableClub_EventScript_EnterUnionRoom case 1, CableClub_EventScript_AbortLink @@ -1039,7 +1039,7 @@ CableClub_EventScript_DirectCornerSelectService:: @ 82776E3 compare VAR_RESULT, FALSE goto_if_eq CableClub_EventScript_DirectCornerNoBerry goto_if_set FLAG_VISITED_MAUVILLE_CITY, CableClub_EventScript_DirectCornerSelectAllServices - multichoice 0, 0, MULTI_WIRELESS_NO_RECORD, 0 + multichoice 0, 0, MULTI_WIRELESS_NO_RECORD, FALSE switch VAR_RESULT case 0, CableClub_EventScript_WirelessTrade case 1, CableClub_EventScript_WirelessBattleSelect @@ -1049,7 +1049,7 @@ CableClub_EventScript_DirectCornerSelectService:: @ 82776E3 end CableClub_EventScript_DirectCornerSelectAllServices:: @ 827773E - multichoice 0, 0, MULTI_WIRELESS_ALL_SERVICES, 0 + multichoice 0, 0, MULTI_WIRELESS_ALL_SERVICES, FALSE switch VAR_RESULT case 0, CableClub_EventScript_WirelessTrade case 1, CableClub_EventScript_WirelessBattleSelect @@ -1061,7 +1061,7 @@ CableClub_EventScript_DirectCornerSelectAllServices:: @ 827773E CableClub_EventScript_DirectCornerNoBerry:: @ 827778B goto_if_set FLAG_VISITED_MAUVILLE_CITY, CableClub_EventScript_DirectCornerHasRecordMix - multichoice 0, 0, MULTI_WIRELESS_NO_RECORD_BERRY, 0 + multichoice 0, 0, MULTI_WIRELESS_NO_RECORD_BERRY, FALSE switch VAR_RESULT case 0, CableClub_EventScript_WirelessTrade case 1, CableClub_EventScript_WirelessBattleSelect @@ -1070,7 +1070,7 @@ CableClub_EventScript_DirectCornerNoBerry:: @ 827778B end CableClub_EventScript_DirectCornerHasRecordMix:: @ 82777CB - multichoice 0, 0, MULTI_WIRELESS_NO_BERRY, 0 + multichoice 0, 0, MULTI_WIRELESS_NO_BERRY, FALSE switch VAR_RESULT case 0, CableClub_EventScript_WirelessTrade case 1, CableClub_EventScript_WirelessBattleSelect @@ -1093,7 +1093,7 @@ CableClub_EventScript_WirelessTrade:: @ 827780D CableClub_EventScript_WirelessBattleSelect:: @ 827783B message CableClub_Text_PlayWhichBattleMode waitmessage - multichoice 0, 0, MULTI_BATTLE_MODE, 0 + multichoice 0, 0, MULTI_BATTLE_MODE, FALSE switch VAR_RESULT case 0, CableClub_EventScript_WirelessSingleBattle case 1, CableClub_EventScript_WirelessDoubleBattle @@ -1171,7 +1171,7 @@ CableClub_EventScript_SaveAndChooseLinkLeader:: @ 8277931 CableClub_EventScript_ChooseLinkLeaderFrom2:: @ 8277989 message CableClub_Text_ChooseGroupLeaderOfTwo waitmessage - multichoice 16, 6, MULTI_LINK_LEADER, 0 + multichoice 16, 6, MULTI_LINK_LEADER, FALSE switch VAR_RESULT case 0, CableClub_EventScript_TryJoinGroup2Players case 1, CableClub_EventScript_TryLeadGroup2Players @@ -1204,7 +1204,7 @@ CableClub_EventScript_TryJoinGroup2Players:: @ 82779EE CableClub_EventScript_ChooseLinkLeaderFrom4:: @ 8277A16 message CableClub_Text_ChooseGroupLeaderOfFour waitmessage - multichoice 16, 6, MULTI_LINK_LEADER, 0 + multichoice 16, 6, MULTI_LINK_LEADER, FALSE switch VAR_RESULT case 0, CableClub_EventScript_TryJoinGroup4Players case 1, CableClub_EventScript_TryLeadGroup4Players @@ -1237,7 +1237,7 @@ CableClub_EventScript_TryJoinGroup4Players:: @ 8277A7B CableClub_EventScript_ChooseLinkLeader:: @ 8277AA3 message CableClub_Text_ChooseGroupLeader waitmessage - multichoice 16, 6, MULTI_LINK_LEADER, 0 + multichoice 16, 6, MULTI_LINK_LEADER, FALSE switch VAR_RESULT case 0, CableClub_EventScript_TryJoinGroupXPlayers case 1, CableClub_EventScript_TryLeadGroupXPlayers @@ -1360,7 +1360,7 @@ MossdeepCity_GameCorner_1F_EventScript_InfoMan2:: @ 8277C34 faceplayer message MossdeepCity_GameCorner_1F_Text_DescribeWhichGame waitmessage - multichoice 0, 0, MULTI_WIRELESS_MINIGAME, 0 + multichoice 0, 0, MULTI_WIRELESS_MINIGAME, FALSE switch VAR_RESULT case 0, MossdeepCity_GameCorner_1F_EventScript_PokemonJumpInfo case 1, MossdeepCity_GameCorner_1F_EventScript_DodrioBerryPickingInfo @@ -1394,7 +1394,7 @@ MossdeepCity_GameCorner_1F_EventScript_OldMan2:: @ 8277C91 delay 60 message MossdeepCity_GameCorner_1F_Text_PlayWhichGame waitmessage - multichoice 0, 0, MULTI_WIRELESS_MINIGAME, 0 + multichoice 0, 0, MULTI_WIRELESS_MINIGAME, FALSE switch VAR_RESULT case 0, MossdeepCity_GameCorner_1F_EventScript_PlayPokemonJump case 1, MossdeepCity_GameCorner_1F_EventScript_PlayDodrioBerryPicking @@ -1443,7 +1443,7 @@ MossdeepCity_GameCorner_1F_EventScript_PlayDodrioBerryPicking:: @ 8277D35 MossdeepCity_GameCorner_1F_EventScript_ChooseLinkLeader:: @ 8277D81 message CableClub_Text_ChooseGroupLeader waitmessage - multichoice 16, 6, MULTI_LINK_LEADER, 0 + multichoice 16, 6, MULTI_LINK_LEADER, FALSE switch VAR_RESULT case 0, MossdeepCity_GameCorner_1F_EventScript_TryJoinLinkGroup case 1, MossdeepCity_GameCorner_1F_EventScript_TryBecomeLinkLeader diff --git a/data/scripts/contest_hall.inc b/data/scripts/contest_hall.inc index 1ef723c375..51be0027cb 100644 --- a/data/scripts/contest_hall.inc +++ b/data/scripts/contest_hall.inc @@ -60,7 +60,7 @@ LilycoveCity_ContestLobby_EventScript_NoRoomForLuxuryBallAtCounter:: @ 8279D4B LilycoveCity_ContestLobby_EventScript_AskEnterContest:: @ 8279D5A message LilycoveCity_ContestLobby_Text_EnterContest1 waitmessage - multichoice 0, 0, MULTI_ENTERINFO, 0 + multichoice 0, 0, MULTI_ENTERINFO, FALSE switch VAR_RESULT case 0, LilycoveCity_ContestLobby_EventScript_ChooseContestRank case 1, LilycoveCity_ContestLobby_EventScript_ContestInfo @@ -71,7 +71,7 @@ LilycoveCity_ContestLobby_EventScript_AskEnterContest:: @ 8279D5A LilycoveCity_ContestLobby_EventScript_ContestInfo:: @ 8279D97 message LilycoveCity_ContestLobby_Text_WhichTopic1 waitmessage - multichoice 0, 0, MULTI_CONTEST_INFO, 0 + multichoice 0, 0, MULTI_CONTEST_INFO, FALSE switch VAR_RESULT case 0, LilycoveCity_ContestLobby_EventScript_ExplainContests case 1, LilycoveCity_ContestLobby_EventScript_ExplainContestTypes @@ -121,7 +121,7 @@ LilycoveCity_ContestLobby_EventScript_ChooseContestMon:: @ 8279E13 LilycoveCity_ContestLobby_EventScript_ChooseContestRank:: @ 8279E62 message LilycoveCity_ContestLobby_Text_EnterWhichRank waitmessage - multichoice 0, 0, MULTI_CONTEST_RANK, 0 + multichoice 0, 0, MULTI_CONTEST_RANK, FALSE switch VAR_RESULT case 0, LilycoveCity_ContestLobby_EventScript_EnterNormalRank case 1, LilycoveCity_ContestLobby_EventScript_EnterSuperRank @@ -156,7 +156,7 @@ LilycoveCity_ContestLobby_EventScript_EnterMasterRank:: @ 8279ED6 LilycoveCity_ContestLobby_EventScript_ChooseContestType:: @ 8279EE1 message LilycoveCity_ContestLobby_Text_EnterWhichContest1 waitmessage - multichoice 0, 0, MULTI_CONTEST_TYPE, 0 + multichoice 0, 0, MULTI_CONTEST_TYPE, FALSE switch VAR_RESULT case 5, LilycoveCity_ContestLobby_EventScript_CancelEnterContest case MULTI_B_PRESSED, LilycoveCity_ContestLobby_EventScript_CancelEnterContest diff --git a/data/scripts/interview.inc b/data/scripts/interview.inc index 9921aa6031..2d1c081967 100644 --- a/data/scripts/interview.inc +++ b/data/scripts/interview.inc @@ -278,7 +278,7 @@ BattleFrontier_BattleTowerLobby_EventScript_Reporter:: @ 828CB96 BattleFrontier_BattleTowerLobby_EventScript_AcceptInterview:: @ 828CBD8 message BattleFrontier_BattleTowerLobby_Text_HowDidBattleTowerTurnOut waitmessage - multichoice 20, 8, MULTI_SATISFACTION, 1 + multichoice 20, 8, MULTI_SATISFACTION, TRUE copyvar VAR_0x8008, VAR_RESULT compare VAR_RESULT, 0 call_if_eq BattleFrontier_BattleTowerLobby_EventScript_Satisfied diff --git a/data/scripts/mystery_event_club.inc b/data/scripts/mystery_event_club.inc index 16e9a657f2..77d24adf6b 100644 --- a/data/scripts/mystery_event_club.inc +++ b/data/scripts/mystery_event_club.inc @@ -8,7 +8,7 @@ MysteryEventClub_EventScript_Man:: @ 8291539 MysteryEventClub_EventScript_AskToSeeProfile:: @ 8291552 msgbox MysteryEventClub_Text_MayISeeYourProfile, MSGBOX_DEFAULT - multichoice 17, 6, MULTI_YESNOINFO_2, 0 + multichoice 17, 6, MULTI_YESNOINFO_2, FALSE switch VAR_RESULT case 0, MysteryEventClub_EventScript_CreateProfile case 1, MysteryEventClub_EventScript_DeclineShowProfile @@ -60,7 +60,7 @@ MysteryEventClub_EventScript_GivenProfileBefore:: @ 82915F5 MysteryEventClub_EventScript_AskToSeeNewProfile:: @ 8291603 msgbox MysteryEventClub_Text_MayISeeYourNewProfile, MSGBOX_DEFAULT - multichoice 17, 6, MULTI_YESNOINFO_2, 0 + multichoice 17, 6, MULTI_YESNOINFO_2, FALSE switch VAR_RESULT case 0, MysteryEventClub_EventScript_CreateNewProfile case 1, MysteryEventClub_EventScript_DeclineNewProfile diff --git a/data/scripts/players_house.inc b/data/scripts/players_house.inc index 684b27e71e..03b8eaf998 100644 --- a/data/scripts/players_house.inc +++ b/data/scripts/players_house.inc @@ -501,7 +501,7 @@ PlayersHouse_1F_EventScript_GetSSTicketAndSeeLatiTV:: @ 8292AF2 compare VAR_0x8008, FEMALE call_if_eq PlayersHouse_1F_EventScript_MomApproachPlayerAfterTVFemale msgbox PlayersHouse_1F_Text_WhatColorDidTheySay, MSGBOX_DEFAULT - multichoice 22, 8, MULTI_TV_LATI, 1 + multichoice 22, 8, MULTI_TV_LATI, TRUE copyvar VAR_0x8004, VAR_RESULT special InitRoamer copyvar VAR_ROAMER_POKEMON, VAR_RESULT diff --git a/data/scripts/shared_secret_base.inc b/data/scripts/shared_secret_base.inc index 0fa61a214e..9e17598722 100644 --- a/data/scripts/shared_secret_base.inc +++ b/data/scripts/shared_secret_base.inc @@ -48,7 +48,7 @@ SecretBase_EventScript_PCCancel:: @ 823B4E8 end SecretBase_EventScript_PCMainMenuWithRegister:: @ 823B4EF - multichoice 0, 0, MULTI_BASE_PC_WITH_REGISTRY, 0 + multichoice 0, 0, MULTI_BASE_PC_WITH_REGISTRY, FALSE switch VAR_RESULT case 0, SecretBase_EventScript_PCDecorationMenu case 1, SecretBase_EventScript_PCPackUp @@ -58,7 +58,7 @@ SecretBase_EventScript_PCMainMenuWithRegister:: @ 823B4EF end SecretBase_EventScript_PCMainMenuWithoutRegister:: @ 823B531 - multichoice 0, 0, MULTI_BASE_PC_NO_REGISTRY, 0 + multichoice 0, 0, MULTI_BASE_PC_NO_REGISTRY, FALSE switch VAR_RESULT case 0, SecretBase_EventScript_PCDecorationMenu case 1, SecretBase_EventScript_PCPackUp @@ -98,7 +98,7 @@ SecretBase_EventScript_RecordMixingPC:: @ 823B589 SecretBase_EventScript_PCRegisterMenu:: @ 823B5A1 message SecretBase_Text_WhatWouldYouLikeToDo waitmessage - multichoice 0, 0, MULTI_REGISTER_MENU, 0 + multichoice 0, 0, MULTI_REGISTER_MENU, FALSE switch VAR_RESULT case 0, SecretBase_EventScript_PCRegister case 1, SecretBase_EventScript_PCRegistryMenu diff --git a/src/scrcmd.c b/src/scrcmd.c index 7caaa194bc..7dc02b6a8f 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1358,7 +1358,7 @@ bool8 ScrCmd_multichoice(struct ScriptContext *ctx) u8 left = ScriptReadByte(ctx); u8 top = ScriptReadByte(ctx); u8 multichoiceId = ScriptReadByte(ctx); - u8 ignoreBPress = ScriptReadByte(ctx); + bool8 ignoreBPress = ScriptReadByte(ctx); if (ScriptMenu_Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE) { @@ -1377,7 +1377,7 @@ bool8 ScrCmd_multichoicedefault(struct ScriptContext *ctx) u8 top = ScriptReadByte(ctx); u8 multichoiceId = ScriptReadByte(ctx); u8 defaultChoice = ScriptReadByte(ctx); - u8 ignoreBPress = ScriptReadByte(ctx); + bool8 ignoreBPress = ScriptReadByte(ctx); if (ScriptMenu_MultichoiceWithDefault(left, top, multichoiceId, ignoreBPress, defaultChoice) == TRUE) { @@ -1407,7 +1407,7 @@ bool8 ScrCmd_multichoicegrid(struct ScriptContext *ctx) u8 top = ScriptReadByte(ctx); u8 multichoiceId = ScriptReadByte(ctx); u8 numColumns = ScriptReadByte(ctx); - u8 ignoreBPress = ScriptReadByte(ctx); + bool8 ignoreBPress = ScriptReadByte(ctx); if (ScriptMenu_MultichoiceGrid(left, top, multichoiceId, ignoreBPress, numColumns) == TRUE) { @@ -1427,7 +1427,7 @@ bool8 ScrCmd_erasebox(struct ScriptContext *ctx) u8 right = ScriptReadByte(ctx); u8 bottom = ScriptReadByte(ctx); - // MenuZeroFillWindowRect(left, top, right, bottom); + // Menu_EraseWindowRect(left, top, right, bottom); return FALSE; } @@ -1436,7 +1436,7 @@ bool8 ScrCmd_drawboxtext(struct ScriptContext *ctx) u8 left = ScriptReadByte(ctx); u8 top = ScriptReadByte(ctx); u8 multichoiceId = ScriptReadByte(ctx); - u8 ignoreBPress = ScriptReadByte(ctx); + bool8 ignoreBPress = ScriptReadByte(ctx); /*if (Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE) { From 86856098a35b58eabb74db1d41cb9a2853c6746f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 31 Mar 2021 15:53:01 -0400 Subject: [PATCH 23/31] Document Dewford Trend --- data/maps/DewfordTown_Hall/scripts.inc | 2 +- data/specials.inc | 2 +- include/constants/flags.h | 2 +- include/constants/global.h | 1 + include/dewford_trend.h | 5 +- include/global.h | 13 +- include/tv.h | 2 +- src/dewford_trend.c | 455 ++++++++++++++----------- src/easy_chat.c | 6 +- src/field_specials.c | 2 +- src/match_call.c | 6 +- src/record_mixing.c | 18 +- src/tv.c | 2 +- src/wild_encounter.c | 2 +- 14 files changed, 295 insertions(+), 223 deletions(-) diff --git a/data/maps/DewfordTown_Hall/scripts.inc b/data/maps/DewfordTown_Hall/scripts.inc index 72db323178..814392b3de 100644 --- a/data/maps/DewfordTown_Hall/scripts.inc +++ b/data/maps/DewfordTown_Hall/scripts.inc @@ -10,7 +10,7 @@ DewfordTown_Hall_EventScript_Girl:: @ 81FD4D0 lock faceplayer call Common_EventScript_BufferTrendyPhrase - special TrendyPhraseIsOld + special IsTrendyPhraseBoring compare VAR_RESULT, TRUE goto_if_eq DewfordTown_Hall_EventScript_GirlBoredOfTrend msgbox DewfordTown_Hall_Text_CantImagineLifeWithoutTrend, MSGBOX_DEFAULT diff --git a/data/specials.inc b/data/specials.inc index 620fae369b..f672a7b870 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -138,7 +138,7 @@ gSpecials:: @ 81DBA64 def_special BufferMonNickname def_special IsMonOTIDNotPlayers def_special BufferTrendyPhraseString - def_special TrendyPhraseIsOld + def_special IsTrendyPhraseBoring def_special BufferDeepLinkPhrase def_special GetDewfordHallPaintingNameIndex def_special SwapRegisteredBike diff --git a/include/constants/flags.h b/include/constants/flags.h index 21b730de39..798b42d4dd 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1402,7 +1402,7 @@ #define FLAG_SYS_TV_HOME (SYSTEM_FLAGS + 0x30) #define FLAG_SYS_TV_WATCH (SYSTEM_FLAGS + 0x31) #define FLAG_SYS_TV_START (SYSTEM_FLAGS + 0x32) -#define FLAG_SYS_POPWORD_INPUT (SYSTEM_FLAGS + 0x33) +#define FLAG_SYS_CHANGED_DEWFORD_TREND (SYSTEM_FLAGS + 0x33) #define FLAG_SYS_MIX_RECORD (SYSTEM_FLAGS + 0x34) #define FLAG_SYS_CLOCK_SET (SYSTEM_FLAGS + 0x35) #define FLAG_SYS_NATIONAL_DEX (SYSTEM_FLAGS + 0x36) diff --git a/include/constants/global.h b/include/constants/global.h index 213ccca5b5..9b0c46ce40 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -52,6 +52,7 @@ #define NUM_CONTEST_WINNERS 13 #define UNION_ROOM_KB_ROW_COUNT 10 #define GIFT_RIBBONS_COUNT 11 +#define SAVED_TRENDS_COUNT 5 #define PYRAMID_BAG_ITEMS_COUNT 10 #define HALL_FACILITIES_COUNT 9 // 7 facilities for single mode + tower double mode + tower multi mode. diff --git a/include/dewford_trend.h b/include/dewford_trend.h index a7ed006f03..6a31944687 100644 --- a/include/dewford_trend.h +++ b/include/dewford_trend.h @@ -2,10 +2,9 @@ #define GUARD_DEWFORDTREND_H void InitDewfordTrend(void); -void UpdateDewfordTrendPerDay(u16); void UpdateDewfordTrendPerDay(u16 days); -bool8 IsPhraseTrendy(u16 *a); -void ReceiveEasyChatPairsData(struct EasyChatPair *a, size_t b, u8 unused); +bool8 TrySetTrendyPhrase(u16 *phrase); +void ReceiveDewfordTrendData(struct DewfordTrend *linkedTrends, size_t size, u8 unused); #endif // GUARD_DEWFORDTREND_H diff --git a/include/global.h b/include/global.h index 7806c0b59c..497fb40b14 100644 --- a/include/global.h +++ b/include/global.h @@ -587,12 +587,13 @@ struct RamScript struct RamScriptData data; }; -struct EasyChatPair +// See dewford_trend.c +struct DewfordTrend { - u16 unk0_0:7; - u16 unk0_7:7; - u16 unk1_6:1; - u16 unk2; + u16 trendiness:7; + u16 maxTrendiness:7; + u16 gainingTrendiness:1; + u16 rand; u16 words[2]; }; /*size = 0x8*/ @@ -1021,7 +1022,7 @@ struct SaveBlock1 /*0x2BE0*/ struct MailStruct mail[MAIL_COUNT]; /*0x2E20*/ u8 additionalPhrases[8]; // bitfield for 33 additional phrases in easy chat system /*0x2E28*/ OldMan oldMan; - /*0x2e64*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff + /*0x2e64*/ struct DewfordTrend dewfordTrends[SAVED_TRENDS_COUNT]; /*0x2e90*/ struct ContestWinner contestWinners[NUM_CONTEST_WINNERS]; // see CONTEST_WINNER_* /*0x3030*/ struct DayCare daycare; /*0x3150*/ struct LinkBattleRecords linkBattleRecords; diff --git a/include/tv.h b/include/tv.h index 4829094990..f94c5b7e50 100644 --- a/include/tv.h +++ b/include/tv.h @@ -31,7 +31,7 @@ void AlertTVThatPlayerPlayedRoulette(u16 nCoinsSpent); void AlertTVOfNewCoinTotal(u16 nCoinsPaidOut); void TryPutSecretBaseSecretsOnAir(void); void TryPutTodaysRivalTrainerOnAir(void); -void sub_80EDC60(const u16 *words); +void TryPutTrendWatcherOnAir(const u16 *words); void sub_80EDA80(void); void ReceivePokeNewsData(void *src, u32 size, u8 masterIdx); void sub_80F0BB8(void); diff --git a/src/dewford_trend.c b/src/dewford_trend.c index c60797f863..3358334dd6 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -10,311 +10,383 @@ #include "string_util.h" #include "constants/easy_chat.h" -// static functions -static void sub_8122804(struct EasyChatPair *s, u16 b, u8 c); -static bool8 sub_8122A58(struct EasyChatPair *a, struct EasyChatPair *b, u8 c); -static void sub_8122B28(struct EasyChatPair *s); -static bool8 SB1ContainsWords(u16 *a); -static bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2); -static s16 GetEqualEasyChatPairIndex(struct EasyChatPair *s, struct EasyChatPair *a, u16 b); +/* + ## Overview ## + This file handles the "Dewford Trend", a pair of Easy Chat words + repeated by NPCs around Dewford Hall. + + The NPC outside Dewford Hall will ask what the player thinks of the + current trendy phrase, and the player may submit a new pair of words. + If the NPC thinks the submitted phrase is "trendier" than the + current one (see TrySetTrendyPhrase), it becomes the new phrase. + + ## struct DewfordTrend ## + Information about a Dewford trend is stored in a struct DewfordTrend. + In addition to the two easy chat words that make up the trend's phrase, + each trend has a few randomly generated values associated with it. + - rand: + This is a 16 bit value generated once when the phrase is created. + It's used in calculations for Feebas tiles, Slot Machines, and Match Call. + It's also used to determine how much "trendiness" is lost over time (see below). + - trendiness / maxTrendiness: + Initialized as a random value between 30-127 inclusive. This is used to + compare how trendy one phrase is vs another. If a submitted phrase is + less trendy than the current one it won't be accepted. If the trend is + "boring" (see below) it will lose trendiness over time until it reaches 0, + at which point it will stop being boring and gain trendiness until it + reaches maxTrendiness (then it becomes boring again and the cycle repeats). + - gainingTrendiness: + This is a flag that determines whether a phrase should be gaining or losing + trendiness. An NPC in Dewford Hall will comment on whether the current phrase + is "boring" or not, and if it is gaining trendiness (or if it is still trendier + than the last phrase) it is not boring. This field will always be TRUE for any + new phrase submitted after the 1st submission. + + ## Saving trends ## + Each time a new trendy phrase is accepted, the previous Dewford Trend is saved + in gSaveBlock1Ptr->dewfordTrends[]. Up to SAVED_TRENDS_COUNT (5) trends may be + saved at one time. The trends in this array are kept in sorted order from most trendy + to least trendy. The current trendy phrase is always at gSaveBlock1Ptr->dewfordTrends[0]. + If the player mixes records with another player, their own trends are replaced with + their mixing partner's, unless the phrase is the same, in which case the version with + a higher trendiness value is used (see ReceiveDewfordTrendData). + +*/ + +enum { + SORT_MODE_NORMAL, + SORT_MODE_MAX_FIRST, + SORT_MODE_FULL, +}; + +static void SortTrends(struct DewfordTrend *, u16, u8); +static bool8 CompareTrends(struct DewfordTrend *, struct DewfordTrend *, u8); +static void SeedTrendRng(struct DewfordTrend *); +static bool8 IsPhraseInSavedTrends(u16 *); +static bool8 IsEasyChatPairEqual(u16 *, u16 *); +static s16 GetSavedTrendIndex(struct DewfordTrend *, struct DewfordTrend *, u16); -// text void InitDewfordTrend(void) { u16 i; - for (i = 0; i < 5; i++) + for (i = 0; i < SAVED_TRENDS_COUNT; i++) { - gSaveBlock1Ptr->easyChatPairs[i].words[0] = GetRandomEasyChatWordFromGroup(EC_GROUP_CONDITIONS); + gSaveBlock1Ptr->dewfordTrends[i].words[0] = GetRandomEasyChatWordFromGroup(EC_GROUP_CONDITIONS); if (Random() & 1) - gSaveBlock1Ptr->easyChatPairs[i].words[1] = GetRandomEasyChatWordFromGroup(EC_GROUP_LIFESTYLE); + gSaveBlock1Ptr->dewfordTrends[i].words[1] = GetRandomEasyChatWordFromGroup(EC_GROUP_LIFESTYLE); else - gSaveBlock1Ptr->easyChatPairs[i].words[1] = GetRandomEasyChatWordFromGroup(EC_GROUP_HOBBIES); + gSaveBlock1Ptr->dewfordTrends[i].words[1] = GetRandomEasyChatWordFromGroup(EC_GROUP_HOBBIES); - gSaveBlock1Ptr->easyChatPairs[i].unk1_6 = Random() & 1; - sub_8122B28(&(gSaveBlock1Ptr->easyChatPairs[i])); + gSaveBlock1Ptr->dewfordTrends[i].gainingTrendiness = Random() & 1; + SeedTrendRng(&(gSaveBlock1Ptr->dewfordTrends[i])); } - sub_8122804(gSaveBlock1Ptr->easyChatPairs, 5, 0); + SortTrends(gSaveBlock1Ptr->dewfordTrends, SAVED_TRENDS_COUNT, SORT_MODE_NORMAL); } -void UpdateDewfordTrendPerDay(u16 a) +void UpdateDewfordTrendPerDay(u16 days) { u16 i; - if (a != 0) + if (days != 0) { - u32 sp0 = a * 5; + u32 clockRand = days * 5; - for (i = 0; i < 5; i++) + for (i = 0; i < SAVED_TRENDS_COUNT; i++) { - u32 r4; - u32 r2 = sp0; - struct EasyChatPair *r5 = &(gSaveBlock1Ptr->easyChatPairs[i]); + u32 trendiness; + u32 rand = clockRand; + struct DewfordTrend *trend = &gSaveBlock1Ptr->dewfordTrends[i]; - if (r5->unk1_6 == 0) + if (!trend->gainingTrendiness) { - if (r5->unk0_0 >= (u16)r2) + // This trend is "boring" + // Lose trendiness until it becomes 0 + if (trend->trendiness >= (u16)rand) { - r5->unk0_0 -= r2; - if (r5->unk0_0 == 0) - r5->unk1_6 = 1; + trend->trendiness -= rand; + if (trend->trendiness == 0) + trend->gainingTrendiness = TRUE; continue; } - r2 -= r5->unk0_0; - r5->unk0_0 = 0; - r5->unk1_6 = 1; + rand -= trend->trendiness; + trend->trendiness = 0; + trend->gainingTrendiness = TRUE; } - r4 = r5->unk0_0 + r2; - if ((u16)r4 > r5->unk0_7) - { - u32 sp4 = r4 % r5->unk0_7; - r4 = r4 / r5->unk0_7; - r5->unk1_6 = r4 ^ 1; - if (r5->unk1_6) - r5->unk0_0 = sp4; + trendiness = trend->trendiness + rand; + if ((u16)trendiness > trend->maxTrendiness) + { + // Reached limit, reset trendiness + u32 newTrendiness = trendiness % trend->maxTrendiness; + trendiness = trendiness / trend->maxTrendiness; + + trend->gainingTrendiness = trendiness ^ 1; + if (trend->gainingTrendiness) + trend->trendiness = newTrendiness; else - r5->unk0_0 = r5->unk0_7 - sp4; + trend->trendiness = trend->maxTrendiness - newTrendiness; } else { - r5->unk0_0 = r4; + // Increase trendiness + trend->trendiness = trendiness; - if (r5->unk0_0 == r5->unk0_7) - r5->unk1_6 = 0; + // Trend has reached its max, becoming "boring" and start losing trendiness + if (trend->trendiness == trend->maxTrendiness) + trend->gainingTrendiness = FALSE; } } - sub_8122804(gSaveBlock1Ptr->easyChatPairs, 5, 0); + SortTrends(gSaveBlock1Ptr->dewfordTrends, SAVED_TRENDS_COUNT, SORT_MODE_NORMAL); } } - -bool8 IsPhraseTrendy(u16 *a) +// Returns TRUE if the current trendy phrase was successfully changed to the given phrase +// Returns FALSE otherwise +bool8 TrySetTrendyPhrase(u16 *phrase) { - struct EasyChatPair s = {0}; + struct DewfordTrend trend = {0}; u16 i; - if (!SB1ContainsWords(a)) + if (!IsPhraseInSavedTrends(phrase)) { - if (!FlagGet(FLAG_SYS_POPWORD_INPUT)) + if (!FlagGet(FLAG_SYS_CHANGED_DEWFORD_TREND)) { - FlagSet(FLAG_SYS_POPWORD_INPUT); + FlagSet(FLAG_SYS_CHANGED_DEWFORD_TREND); + + // Make sure player couldn't have received this phrase by mixing records if (!FlagGet(FLAG_SYS_MIX_RECORD)) { - gSaveBlock1Ptr->easyChatPairs[0].words[0] = a[0]; - gSaveBlock1Ptr->easyChatPairs[0].words[1] = a[1]; + // This is the first time submitting a phrase + // No need to check saved phrases or reset rng, just set the new words + gSaveBlock1Ptr->dewfordTrends[0].words[0] = phrase[0]; + gSaveBlock1Ptr->dewfordTrends[0].words[1] = phrase[1]; return TRUE; } } - s.words[0] = a[0]; - s.words[1] = a[1]; - s.unk1_6 = 1; - sub_8122B28(&s); + // Initialize DewfordTrend using given phrase + trend.words[0] = phrase[0]; + trend.words[1] = phrase[1]; + trend.gainingTrendiness = TRUE; + SeedTrendRng(&trend); - for (i = 0; i < 5; i++) + for (i = 0; i < SAVED_TRENDS_COUNT; i++) { - if (sub_8122A58(&s, &(gSaveBlock1Ptr->easyChatPairs[i]), 0)) + if (CompareTrends(&trend, &(gSaveBlock1Ptr->dewfordTrends[i]), SORT_MODE_NORMAL)) { - u16 r3 = 4; - - while (r3 > i) + // New trend is "trendier" than dewfordTrend[i] + // Shift other trends back to insert new trend + u16 j = SAVED_TRENDS_COUNT - 1; + while (j > i) { - gSaveBlock1Ptr->easyChatPairs[r3] = gSaveBlock1Ptr->easyChatPairs[r3 - 1]; - r3--; + gSaveBlock1Ptr->dewfordTrends[j] = gSaveBlock1Ptr->dewfordTrends[j - 1]; + j--; } - gSaveBlock1Ptr->easyChatPairs[i] = s; - if(i == 4) - sub_80EDC60(a); + gSaveBlock1Ptr->dewfordTrends[i] = trend; + + if (i == SAVED_TRENDS_COUNT - 1) + TryPutTrendWatcherOnAir(phrase); + + // If i is 0, the given phrase is the new current phrase return (i == 0); } } - gSaveBlock1Ptr->easyChatPairs[4] = s; - sub_80EDC60(a); + + // New trend is less "trendy" than all other saved trends, put it in last + gSaveBlock1Ptr->dewfordTrends[SAVED_TRENDS_COUNT - 1] = trend; + TryPutTrendWatcherOnAir(phrase); } return FALSE; } -static void sub_8122804(struct EasyChatPair *s, u16 b, u8 c) +static void SortTrends(struct DewfordTrend *trends, u16 numTrends, u8 mode) { - u16 h; - - for (h = 0; h < b; h++) + u16 i; + for (i = 0; i < numTrends; i++) { - u16 i; - - for (i = h + 1; i < b; i++) + u16 j; + for (j = i + 1; j < numTrends; j++) { - if (sub_8122A58(&s[i], &s[h], c)) + if (CompareTrends(&trends[j], &trends[i], mode)) { - struct EasyChatPair temp; - - temp = s[i]; - s[i] = s[h]; - s[h] = temp; + struct DewfordTrend temp; + SWAP(trends[j], trends[i], temp); } } } } -void ReceiveEasyChatPairsData(struct EasyChatPair *a, size_t size, u8 unused) -{ - u16 i, j, r3, players; - struct EasyChatPair *buffer1, *buffer2, *src, *dst, *foo_of_buffer2; +#define SAVED_TRENDS_SIZE (sizeof(struct DewfordTrend) * SAVED_TRENDS_COUNT) +#define BUFFER_SIZE (SAVED_TRENDS_SIZE * MAX_LINK_PLAYERS > 0x100 ? SAVED_TRENDS_SIZE * MAX_LINK_PLAYERS : 0x100) // More space was allocated than needed - buffer1 = Alloc(0x100); - if(buffer1 != NULL) +void ReceiveDewfordTrendData(struct DewfordTrend *linkedTrends, size_t size, u8 unused) +{ + u16 i, j, numTrends, players; + struct DewfordTrend *linkedTrendsBuffer, *savedTrendsBuffer, *src, *dst, *temp; + + // Exit if alloc fails + if (!(linkedTrendsBuffer = Alloc(BUFFER_SIZE))) + return; + + // Exit if alloc fails + if (!(savedTrendsBuffer = Alloc(BUFFER_SIZE))) { - buffer2 = Alloc(0x100); - if(buffer2 == NULL) + Free(linkedTrendsBuffer); + return; + } + + // Buffer the new trends being received via Record Mixing + players = GetLinkPlayerCount(); + for (i = 0; i < players; i++) + memcpy(&linkedTrendsBuffer[i * SAVED_TRENDS_COUNT], (u8 *)linkedTrends + i * size, SAVED_TRENDS_SIZE); + + // Determine which of the received trends should be saved. + // savedTrendsBuffer starts empty, and when finished will contain + // which of the linked trends to save in the saveblock. + src = linkedTrendsBuffer; + dst = savedTrendsBuffer; + numTrends = 0; + for (i = 0; i < players; i++) + { + for (j = 0; j < SAVED_TRENDS_COUNT; j++) { - Free(buffer1); - } - else - { - players = GetLinkPlayerCount(); - for (i = 0; i < players; i++) - memcpy(&(buffer1[i * 5]), (u8 *)a + i * size, 40); - src = buffer1; - dst = buffer2; - r3 = 0; - for (i = 0; i < players; i++) + s16 idx = GetSavedTrendIndex(savedTrendsBuffer, src, numTrends); + if (idx < 0) { - for (j = 0; j < 5; j++) + // This phrase is not a currently saved trend, save it + *(dst++) = *src; + numTrends++; + } + else + { + // This phrase already exists as a saved phrase + // Only overwrrite it if it's "trendier" + temp = &savedTrendsBuffer[idx]; + if (temp->trendiness < src->trendiness) { - s16 foo = GetEqualEasyChatPairIndex(buffer2, src, r3); - if (foo < 0) - { - *(dst++) = *src; - r3++; - } - else - { - foo_of_buffer2 = (struct EasyChatPair *)((u32)buffer2 + (foo * 8)); //required to do this to reverse the order of register operands in add ASM statement - if (foo_of_buffer2->unk0_0 < src->unk0_0) - { - *foo_of_buffer2 = *src; - } - } - src++; + *temp = *src; } } - sub_8122804(buffer2, r3, 2); - src = buffer2; - dst = gSaveBlock1Ptr->easyChatPairs; - for (i = 0; i < 5; i++) - *(dst++) = *(src++); - Free(buffer1); - Free(buffer2); + src++; } } + SortTrends(savedTrendsBuffer, numTrends, SORT_MODE_FULL); + + // Overwrite current saved trends with new saved trends + src = savedTrendsBuffer; + dst = gSaveBlock1Ptr->dewfordTrends; + for (i = 0; i < SAVED_TRENDS_COUNT; i++) + *(dst++) = *(src++); + + Free(linkedTrendsBuffer); + Free(savedTrendsBuffer); } void BufferTrendyPhraseString(void) { - struct EasyChatPair *s = &gSaveBlock1Ptr->easyChatPairs[gSpecialVar_0x8004]; - - ConvertEasyChatWordsToString(gStringVar1, s->words, 2, 1); + struct DewfordTrend *trend = &gSaveBlock1Ptr->dewfordTrends[gSpecialVar_0x8004]; + ConvertEasyChatWordsToString(gStringVar1, trend->words, 2, 1); } -void TrendyPhraseIsOld(void) +// Returns TRUE if the current trendy phrase is "boring", FALSE otherwise +// This only influences the comment of an NPC inside the Dewford Town Hall +void IsTrendyPhraseBoring(void) { - u16 result = 0; + bool16 result = FALSE; do { - if (gSaveBlock1Ptr->easyChatPairs[0].unk0_0 - gSaveBlock1Ptr->easyChatPairs[1].unk0_0 > 1) + if (gSaveBlock1Ptr->dewfordTrends[0].trendiness - gSaveBlock1Ptr->dewfordTrends[1].trendiness > 1) break; - if (gSaveBlock1Ptr->easyChatPairs[0].unk1_6) + if (gSaveBlock1Ptr->dewfordTrends[0].gainingTrendiness) break; - if (!gSaveBlock1Ptr->easyChatPairs[1].unk1_6) + if (!gSaveBlock1Ptr->dewfordTrends[1].gainingTrendiness) break; - result = 1; + result = TRUE; } while (0); gSpecialVar_Result = result; } +// A painting hangs on the wall of the Dewford Hall +// When interacted with it says "{trendy phrase}'S {name} is the title" +// {name} is one of 8 pre-set words, depending on the current phrase +// See DewfordTown_Hall_EventScript_Painting void GetDewfordHallPaintingNameIndex(void) { - gSpecialVar_Result = (gSaveBlock1Ptr->easyChatPairs[0].words[0] + gSaveBlock1Ptr->easyChatPairs[0].words[1]) & 7; + gSpecialVar_Result = (gSaveBlock1Ptr->dewfordTrends[0].words[0] + gSaveBlock1Ptr->dewfordTrends[0].words[1]) & 7; } -static bool8 sub_8122A58(struct EasyChatPair *a, struct EasyChatPair *b, u8 c) +// Returns TRUE if a > b (a is "trendier" than b), FALSE if a < b (b is "trendier" than a) +// How one trend is compared to the other depends on the mode +// In SORT_MODE_FULL if the trends are equal then TRUE is always returned, otherwise TRUE or FALSE is returned randomly +static bool8 CompareTrends(struct DewfordTrend *a, struct DewfordTrend *b, u8 mode) { - switch (c) + switch (mode) { - case 0: - if (a->unk0_0 > b->unk0_0) - return 1; - if (a->unk0_0 < b->unk0_0) - return 0; - if (a->unk0_7 > b->unk0_7) - return 1; - if (a->unk0_7 < b->unk0_7) - return 0; + case SORT_MODE_NORMAL: + if (a->trendiness > b->trendiness) return TRUE; + if (a->trendiness < b->trendiness) return FALSE; + + if (a->maxTrendiness > b->maxTrendiness) return TRUE; + if (a->maxTrendiness < b->maxTrendiness) return FALSE; break; - case 1: - if (a->unk0_7 > b->unk0_7) - return 1; - if (a->unk0_7 < b->unk0_7) - return 0; - if (a->unk0_0 > b->unk0_0) - return 1; - if (a->unk0_0 < b->unk0_0) - return 0; + case SORT_MODE_MAX_FIRST: // Unused + if (a->maxTrendiness > b->maxTrendiness) return TRUE; + if (a->maxTrendiness < b->maxTrendiness) return FALSE; + + if (a->trendiness > b->trendiness) return TRUE; + if (a->trendiness < b->trendiness) return FALSE; break; - case 2: - if (a->unk0_0 > b->unk0_0) - return 1; - if (a->unk0_0 < b->unk0_0) - return 0; - if (a->unk0_7 > b->unk0_7) - return 1; - if (a->unk0_7 < b->unk0_7) - return 0; - if (a->unk2 > b->unk2) - return 1; - if (a->unk2 < b->unk2) - return 0; - if (a->words[0] > b->words[0]) - return 1; - if (a->words[0] < b->words[0]) - return 0; - if (a->words[1] > b->words[1]) - return 1; - if (a->words[1] < b->words[1]) - return 0; - return 1; + case SORT_MODE_FULL: + if (a->trendiness > b->trendiness) return TRUE; + if (a->trendiness < b->trendiness) return FALSE; + + if (a->maxTrendiness > b->maxTrendiness) return TRUE; + if (a->maxTrendiness < b->maxTrendiness) return FALSE; + + if (a->rand > b->rand) return TRUE; + if (a->rand < b->rand) return FALSE; + + if (a->words[0] > b->words[0]) return TRUE; + if (a->words[0] < b->words[0]) return FALSE; + + if (a->words[1] > b->words[1]) return TRUE; + if (a->words[1] < b->words[1]) return FALSE; + return TRUE; } + + // Invalid mode given, or trends are equal in SORT_MODE_NORMAL or SORT_MODE_MAX_FIRST + // Randomly pick one of the phrases return Random() & 1; } -static void sub_8122B28(struct EasyChatPair *s) +static void SeedTrendRng(struct DewfordTrend *trend) { - u16 r4; + u16 rand; - r4 = Random() % 98; - if (r4 > 50) + rand = Random() % 98; + if (rand > 50) { - r4 = Random() % 98; - if (r4 > 80) - r4 = Random() % 98; + rand = Random() % 98; + if (rand > 80) + rand = Random() % 98; } - s->unk0_7 = r4 + 30; - s->unk0_0 = (Random() % (r4 + 1)) + 30; - s->unk2 = Random(); + trend->maxTrendiness = rand + 30; + trend->trendiness = (Random() % (rand + 1)) + 30; + trend->rand = Random(); } -static bool8 SB1ContainsWords(u16 *a) +static bool8 IsPhraseInSavedTrends(u16 *phrase) { u16 i; - for (i = 0; i < 5; i++) + for (i = 0; i < SAVED_TRENDS_COUNT; i++) { - if (IsEasyChatPairEqual(a, gSaveBlock1Ptr->easyChatPairs[i].words) != 0) + if (IsEasyChatPairEqual(phrase, gSaveBlock1Ptr->dewfordTrends[i].words)) return TRUE; } return FALSE; @@ -332,15 +404,14 @@ static bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2) return TRUE; } -static s16 GetEqualEasyChatPairIndex(struct EasyChatPair*s, struct EasyChatPair *a, u16 b) +static s16 GetSavedTrendIndex(struct DewfordTrend *savedTrends, struct DewfordTrend *trend, u16 numSaved) { s16 i; - - for (i = 0; i < b; i++) + for (i = 0; i < numSaved; i++) { - if (IsEasyChatPairEqual(a->words, s->words)) + if (IsEasyChatPairEqual(trend->words, savedTrends->words)) return i; - s++; + savedTrends++; } return -1; } diff --git a/src/easy_chat.c b/src/easy_chat.c index a27e1780eb..fcbd1fba38 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -1477,8 +1477,8 @@ void ShowEasyChatScreen(void) break; case EASY_CHAT_TYPE_TRENDY_PHRASE: words = (u16 *)gStringVar3; - words[0] = gSaveBlock1Ptr->easyChatPairs[0].words[0]; - words[1] = gSaveBlock1Ptr->easyChatPairs[0].words[1]; + words[0] = gSaveBlock1Ptr->dewfordTrends[0].words[0]; + words[1] = gSaveBlock1Ptr->dewfordTrends[0].words[1]; break; case EASY_CHAT_TYPE_GABBY_AND_TY: words = gSaveBlock1Ptr->gabbyAndTyData.quote; @@ -2958,7 +2958,7 @@ static void SetSpecialEasyChatResult(void) break; case EASY_CHAT_TYPE_TRENDY_PHRASE: BufferCurrentPhraseToStringVar2(); - gSpecialVar_0x8004 = IsPhraseTrendy(sEasyChatScreen->currentPhrase); + gSpecialVar_0x8004 = TrySetTrendyPhrase(sEasyChatScreen->currentPhrase); break; case EASY_CHAT_TYPE_GOOD_SAYING: gSpecialVar_0x8004 = DidPlayerInputABerryMasterWifePhrase(); diff --git a/src/field_specials.c b/src/field_specials.c index 86be21edac..30503ed8d4 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1336,7 +1336,7 @@ u16 GetSlotMachineId(void) static const u8 sSlotMachineIds[] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5}; static const u8 sSlotMachineServiceDayIds[] = {3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5}; - u32 rnd = gSaveBlock1Ptr->easyChatPairs[0].unk0_0 + gSaveBlock1Ptr->easyChatPairs[0].unk2 + sSlotMachineRandomSeeds[gSpecialVar_0x8004]; + u32 rnd = gSaveBlock1Ptr->dewfordTrends[0].trendiness + gSaveBlock1Ptr->dewfordTrends[0].rand + sSlotMachineRandomSeeds[gSpecialVar_0x8004]; if (GetPriceReduction(POKENEWS_GAME_CORNER)) { return sSlotMachineServiceDayIds[rnd % SLOT_MACHINE_COUNT]; diff --git a/src/match_call.c b/src/match_call.c index fb8ebc98cc..b78441f931 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1773,7 +1773,7 @@ static bool32 sub_8196D74(int matchCallId) { int dayCount; int otId; - u16 easyChatWord; + u16 rand; int numRematchTrainersFought; int var0, var1, var2; @@ -1783,10 +1783,10 @@ static bool32 sub_8196D74(int matchCallId) dayCount = RtcGetLocalDayCount(); otId = GetTrainerId(gSaveBlock2Ptr->playerTrainerId) & 0xFFFF; - easyChatWord = gSaveBlock1Ptr->easyChatPairs[0].unk2; + rand = gSaveBlock1Ptr->dewfordTrends[0].rand; numRematchTrainersFought = GetNumRematchTrainersFought(); var0 = (numRematchTrainersFought * 13) / 10; - var1 = ((dayCount ^ easyChatWord) + (easyChatWord ^ GetGameStat(GAME_STAT_TRAINER_BATTLES))) ^ otId; + var1 = ((dayCount ^ rand) + (rand ^ GetGameStat(GAME_STAT_TRAINER_BATTLES))) ^ otId; var2 = var1 % var0; if (var2 < numRematchTrainersFought) { diff --git a/src/record_mixing.c b/src/record_mixing.c index 2028cc6477..bb19fad743 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -50,7 +50,7 @@ struct PlayerRecordsRS TVShow tvShows[TV_SHOWS_COUNT]; PokeNews pokeNews[POKE_NEWS_COUNT]; OldMan oldMan; - struct EasyChatPair easyChatPairs[5]; + struct DewfordTrend dewfordTrends[SAVED_TRENDS_COUNT]; struct RecordMixingDayCareMail dayCareMail; struct RSBattleTowerRecord battleTowerRecord; u16 giftItem; @@ -63,7 +63,7 @@ struct PlayerRecordsEmerald /* 0x0c80 */ TVShow tvShows[TV_SHOWS_COUNT]; /* 0x1004 */ PokeNews pokeNews[POKE_NEWS_COUNT]; /* 0x1044 */ OldMan oldMan; - /* 0x1084 */ struct EasyChatPair easyChatPairs[5]; + /* 0x1084 */ struct DewfordTrend dewfordTrends[SAVED_TRENDS_COUNT]; /* 0x10ac */ struct RecordMixingDayCareMail dayCareMail; /* 0x1124 */ struct EmeraldBattleTowerRecord battleTowerRecord; /* 0x1210 */ u16 giftItem; @@ -86,7 +86,7 @@ static struct SecretBase *sSecretBasesSave; static TVShow *sTvShowsSave; static PokeNews *sPokeNewsSave; static OldMan *sOldManSave; -static struct EasyChatPair *sEasyChatPairsSave; +static struct DewfordTrend *sDewfordTrendsSave; static struct RecordMixingDayCareMail *gUnknown_03001148; static void *sBattleTowerSave; static LilycoveLady *sLilycoveLadySave; @@ -179,7 +179,7 @@ static void SetSrcLookupPointers(void) sTvShowsSave = gSaveBlock1Ptr->tvShows; sPokeNewsSave = gSaveBlock1Ptr->pokeNews; sOldManSave = &gSaveBlock1Ptr->oldMan; - sEasyChatPairsSave = gSaveBlock1Ptr->easyChatPairs; + sDewfordTrendsSave = gSaveBlock1Ptr->dewfordTrends; gUnknown_03001148 = &gUnknown_02039F9C; sBattleTowerSave = &gSaveBlock2Ptr->frontier.towerPlayer; sLilycoveLadySave = &gSaveBlock1Ptr->lilycoveLady; @@ -194,7 +194,7 @@ static void PrepareUnknownExchangePacket(struct PlayerRecordsRS *dest) sub_80F14F8(dest->tvShows); memcpy(dest->pokeNews, sPokeNewsSave, sizeof(dest->pokeNews)); memcpy(&dest->oldMan, sOldManSave, sizeof(dest->oldMan)); - memcpy(dest->easyChatPairs, sEasyChatPairsSave, sizeof(dest->easyChatPairs)); + memcpy(dest->dewfordTrends, sDewfordTrendsSave, sizeof(dest->dewfordTrends)); sub_80E89F8(&dest->dayCareMail); EmeraldBattleTowerRecordToRuby(sBattleTowerSave, &dest->battleTowerRecord); @@ -211,7 +211,7 @@ static void PrepareExchangePacketForRubySapphire(struct PlayerRecordsRS *dest) memcpy(dest->pokeNews, sPokeNewsSave, sizeof(dest->pokeNews)); memcpy(&dest->oldMan, sOldManSave, sizeof(dest->oldMan)); sub_8120B70(&dest->oldMan); - memcpy(dest->easyChatPairs, sEasyChatPairsSave, sizeof(dest->easyChatPairs)); + memcpy(dest->dewfordTrends, sDewfordTrendsSave, sizeof(dest->dewfordTrends)); sub_80E89F8(&dest->dayCareMail); SanitizeDayCareMailForRuby(&dest->dayCareMail); EmeraldBattleTowerRecordToRuby(sBattleTowerSave, &dest->battleTowerRecord); @@ -241,7 +241,7 @@ static void PrepareExchangePacket(void) memcpy(sSentRecord->emerald.pokeNews, sPokeNewsSave, sizeof(sSentRecord->emerald.pokeNews)); memcpy(&sSentRecord->emerald.oldMan, sOldManSave, sizeof(sSentRecord->emerald.oldMan)); memcpy(&sSentRecord->emerald.lilycoveLady, sLilycoveLadySave, sizeof(sSentRecord->emerald.lilycoveLady)); - memcpy(sSentRecord->emerald.easyChatPairs, sEasyChatPairsSave, sizeof(sSentRecord->emerald.easyChatPairs)); + memcpy(sSentRecord->emerald.dewfordTrends, sDewfordTrendsSave, sizeof(sSentRecord->emerald.dewfordTrends)); sub_80E89F8(&sSentRecord->emerald.dayCareMail); memcpy(&sSentRecord->emerald.battleTowerRecord, sBattleTowerSave, sizeof(sSentRecord->emerald.battleTowerRecord)); SanitizeEmeraldBattleTowerRecord(&sSentRecord->emerald.battleTowerRecord); @@ -266,7 +266,7 @@ static void ReceiveExchangePacket(u32 which) ReceiveTvShowsData(sReceivedRecords->ruby.tvShows, sizeof(struct PlayerRecordsRS), which); ReceivePokeNewsData(sReceivedRecords->ruby.pokeNews, sizeof(struct PlayerRecordsRS), which); ReceiveOldManData(&sReceivedRecords->ruby.oldMan, sizeof(struct PlayerRecordsRS), which); - ReceiveEasyChatPairsData(sReceivedRecords->ruby.easyChatPairs, sizeof(struct PlayerRecordsRS), which); + ReceiveDewfordTrendData(sReceivedRecords->ruby.dewfordTrends, sizeof(struct PlayerRecordsRS), which); ReceiveGiftItem(&sReceivedRecords->ruby.giftItem, which); } else @@ -277,7 +277,7 @@ static void ReceiveExchangePacket(u32 which) ReceiveTvShowsData(sReceivedRecords->emerald.tvShows, sizeof(struct PlayerRecordsEmerald), which); ReceivePokeNewsData(sReceivedRecords->emerald.pokeNews, sizeof(struct PlayerRecordsEmerald), which); ReceiveOldManData(&sReceivedRecords->emerald.oldMan, sizeof(struct PlayerRecordsEmerald), which); - ReceiveEasyChatPairsData(sReceivedRecords->emerald.easyChatPairs, sizeof(struct PlayerRecordsEmerald), which); + ReceiveDewfordTrendData(sReceivedRecords->emerald.dewfordTrends, sizeof(struct PlayerRecordsEmerald), which); ReceiveDaycareMailData(&sReceivedRecords->emerald.dayCareMail, sizeof(struct PlayerRecordsEmerald), which, sReceivedRecords->emerald.tvShows); ReceiveBattleTowerData(&sReceivedRecords->emerald.battleTowerRecord, sizeof(struct PlayerRecordsEmerald), which); ReceiveGiftItem(&sReceivedRecords->emerald.giftItem, which); diff --git a/src/tv.c b/src/tv.c index d499e31a83..7f3aa6aafc 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1972,7 +1972,7 @@ void TryPutTodaysRivalTrainerOnAir(void) } } -void sub_80EDC60(const u16 *words) +void TryPutTrendWatcherOnAir(const u16 *words) { TVShow *show; diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 9f81a3b3ed..767fbe4e7e 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -108,7 +108,7 @@ static bool8 CheckFeebas(void) if (Random() % 100 > 49) // 50% chance of encountering Feebas return FALSE; - FeebasSeedRng(gSaveBlock1Ptr->easyChatPairs[0].unk2); + FeebasSeedRng(gSaveBlock1Ptr->dewfordTrends[0].rand); for (i = 0; i != NUM_FEEBAS_SPOTS;) { feebasSpots[i] = FeebasRandom() % 447; From 771a4347309cd2f486072794d7de2c41b84c9b12 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 31 Mar 2021 16:29:42 -0400 Subject: [PATCH 24/31] Label Trend Watcher TV show texts --- data/text/tv.inc | 16 ++++---- include/constants/tv.h | 9 +++++ include/event_scripts.h | 14 +++---- src/dewford_trend.c | 20 +++++---- src/tv.c | 90 +++++++++++++++++++---------------------- 5 files changed, 79 insertions(+), 70 deletions(-) diff --git a/data/text/tv.inc b/data/text/tv.inc index 444b37f179..72d3910340 100644 --- a/data/text/tv.inc +++ b/data/text/tv.inc @@ -1229,7 +1229,7 @@ gTVTodaysRivalTrainerText06:: @ 082849AE .string "Let's all keep moving forward\n" .string "and ahead of our rivals!$" -gTVDewfordTrendWatcherNetworkText00:: @ 08284A3E +TrendWatcher_Text_Intro:: @ 08284A3E .string "DEWFORD TREND-WATCHER NETWORK!\p" .string "MC: Wassup?\n" .string "We'll keep it real with the latest on\l" @@ -1251,17 +1251,18 @@ gTVDewfordTrendWatcherNetworkText00:: @ 08284A3E .string "MC: Uh, no. What we want to know is\n" .string "what's the in thing of the moment…$" -gTVDewfordTrendWatcherNetworkText01:: @ 08284C55 +@ Identical to below, may have been different in other languages +TrendWatcher_Text_MaleTaughtMePhrase:: @ 08284C55 .string "Old man: {STR_VAR_1} {STR_VAR_2}\n" .string "was what {STR_VAR_3} from LITTLEROOT\l" .string "taught me as being trendy…$" -gTVDewfordTrendWatcherNetworkText02:: @ 08284C9B +TrendWatcher_Text_FemaleTaughtMePhrase:: @ 08284C9B .string "Old man: {STR_VAR_1} {STR_VAR_2}\n" .string "was what {STR_VAR_3} from LITTLEROOT\l" .string "taught me as being trendy…$" -gTVDewfordTrendWatcherNetworkText03:: @ 08284CE1 +TrendWatcher_Text_PhraseWasHopeless:: @ 08284CE1 .string "But it was utterly hopeless.\p" .string "{STR_VAR_1} {STR_VAR_2} festival!\p" .string "{STR_VAR_1} {STR_VAR_2} contest!\p" @@ -1272,17 +1273,18 @@ gTVDewfordTrendWatcherNetworkText03:: @ 08284CE1 .string "MC: Uh, excuse me, compadre, I need\n" .string "to hear about what's in now…$" -gTVDewfordTrendWatcherNetworkText04:: @ 08284DB6 +@ Identical to below, may have been different in other languages +TrendWatcher_Text_MaleTellMeBigger:: @ 08284DB6 .string "Old man: {STR_VAR_3}!\n" .string "Please, tell me something bigger than\l" .string "that {STR_VAR_1} {STR_VAR_2}!$" -gTVDewfordTrendWatcherNetworkText05:: @ 08284DF5 +TrendWatcher_Text_FemaleTellMeBigger:: @ 08284DF5 .string "Old man: {STR_VAR_3}!\n" .string "Please, tell me something bigger than\l" .string "that {STR_VAR_1} {STR_VAR_2}!$" -gTVDewfordTrendWatcherNetworkText06:: @ 08284E34 +TrendWatcher_Text_Outro:: @ 08284E34 .string "MC: …Uh… So, there you have it,\n" .string "all you trendy, hep cats out there!\p" .string "{STR_VAR_1} {STR_VAR_2}…uh…\n" diff --git a/include/constants/tv.h b/include/constants/tv.h index 72eae3f1ca..57da9837b9 100644 --- a/include/constants/tv.h +++ b/include/constants/tv.h @@ -206,4 +206,13 @@ #define SPOTCUTIES_STATE_RIBBON_EFFORT 14 #define SPOTCUTIES_STATE_OUTRO 15 +// TV Show states for Trend Watcher +#define TRENDWATCHER_STATE_INTRO 0 +#define TRENDWATCHER_STATE_TAUGHT_MALE 1 +#define TRENDWATCHER_STATE_TAUGHT_FEMALE 2 +#define TRENDWATCHER_STATE_PHRASE_HOPELESS 3 +#define TRENDWATCHER_STATE_BIGGER_MALE 4 +#define TRENDWATCHER_STATE_BIGGER_FEMALE 5 +#define TRENDWATCHER_STATE_OUTRO 6 + #endif //GUARD_CONSTANTS_TV_H diff --git a/include/event_scripts.h b/include/event_scripts.h index 79ef0ea142..ecb40c2662 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -135,13 +135,13 @@ extern const u8 gTVTodaysRivalTrainerText03[]; extern const u8 gTVTodaysRivalTrainerText04[]; extern const u8 gTVTodaysRivalTrainerText05[]; extern const u8 gTVTodaysRivalTrainerText06[]; -extern const u8 gTVDewfordTrendWatcherNetworkText00[]; -extern const u8 gTVDewfordTrendWatcherNetworkText01[]; -extern const u8 gTVDewfordTrendWatcherNetworkText02[]; -extern const u8 gTVDewfordTrendWatcherNetworkText03[]; -extern const u8 gTVDewfordTrendWatcherNetworkText04[]; -extern const u8 gTVDewfordTrendWatcherNetworkText05[]; -extern const u8 gTVDewfordTrendWatcherNetworkText06[]; +extern const u8 TrendWatcher_Text_Intro[]; +extern const u8 TrendWatcher_Text_MaleTaughtMePhrase[]; +extern const u8 TrendWatcher_Text_FemaleTaughtMePhrase[]; +extern const u8 TrendWatcher_Text_PhraseWasHopeless[]; +extern const u8 TrendWatcher_Text_MaleTellMeBigger[]; +extern const u8 TrendWatcher_Text_FemaleTellMeBigger[]; +extern const u8 TrendWatcher_Text_Outro[]; extern const u8 gTVHoennTreasureInvestigatorsText00[]; extern const u8 gTVHoennTreasureInvestigatorsText01[]; extern const u8 gTVHoennTreasureInvestigatorsText02[]; diff --git a/src/dewford_trend.c b/src/dewford_trend.c index 3358334dd6..5ce2844d47 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -43,13 +43,17 @@ new phrase submitted after the 1st submission. ## Saving trends ## - Each time a new trendy phrase is accepted, the previous Dewford Trend is saved - in gSaveBlock1Ptr->dewfordTrends[]. Up to SAVED_TRENDS_COUNT (5) trends may be - saved at one time. The trends in this array are kept in sorted order from most trendy - to least trendy. The current trendy phrase is always at gSaveBlock1Ptr->dewfordTrends[0]. - If the player mixes records with another player, their own trends are replaced with - their mixing partner's, unless the phrase is the same, in which case the version with - a higher trendiness value is used (see ReceiveDewfordTrendData). + Each time a potential trendy phrase is submitted, it is saved in gSaveBlock1Ptr->dewfordTrends[]. + Up to SAVED_TRENDS_COUNT (5) trends may be saved at one time. The trends in this array are kept + in sorted order from most trendy to least trendy. The current trendy phrase is always at + gSaveBlock1Ptr->dewfordTrends[0]. If the player mixes records with another player, their own + trends are replaced with their mixing partner's, unless the phrase is the same, in which case + the version with a higher trendiness value is used (see ReceiveDewfordTrendData). + + ## TV Show ## + If a submitted phrase is only trendier than 1 or none of the saved trends, it may trigger a + TV Show called Trend Watcher (see TryPutTrendWatcherOnAir) that, ironically, spends the + show talking about how the submitted phrase was not trendy. */ @@ -144,6 +148,8 @@ void UpdateDewfordTrendPerDay(u16 days) // Returns TRUE if the current trendy phrase was successfully changed to the given phrase // Returns FALSE otherwise +// Regardless of whether or not the current trendy phrase was changed, the submitted +// phrase is always saved in gSaveBlock1Ptr->dewfordTrends bool8 TrySetTrendyPhrase(u16 *phrase) { struct DewfordTrend trend = {0}; diff --git a/src/tv.c b/src/tv.c index 7f3aa6aafc..691b343d81 100644 --- a/src/tv.c +++ b/src/tv.c @@ -504,13 +504,13 @@ static const u8 *const sTVTodaysRivalTrainerTextGroup[] = { }; static const u8 *const sTVDewfordTrendWatcherNetworkTextGroup[] = { - gTVDewfordTrendWatcherNetworkText00, - gTVDewfordTrendWatcherNetworkText01, - gTVDewfordTrendWatcherNetworkText02, - gTVDewfordTrendWatcherNetworkText03, - gTVDewfordTrendWatcherNetworkText04, - gTVDewfordTrendWatcherNetworkText05, - gTVDewfordTrendWatcherNetworkText06 + [TRENDWATCHER_STATE_INTRO] = TrendWatcher_Text_Intro, + [TRENDWATCHER_STATE_TAUGHT_MALE] = TrendWatcher_Text_MaleTaughtMePhrase, + [TRENDWATCHER_STATE_TAUGHT_FEMALE] = TrendWatcher_Text_FemaleTaughtMePhrase, + [TRENDWATCHER_STATE_PHRASE_HOPELESS] = TrendWatcher_Text_PhraseWasHopeless, + [TRENDWATCHER_STATE_BIGGER_MALE] = TrendWatcher_Text_MaleTellMeBigger, + [TRENDWATCHER_STATE_BIGGER_FEMALE] = TrendWatcher_Text_FemaleTellMeBigger, + [TRENDWATCHER_STATE_OUTRO] = TrendWatcher_Text_Outro }; static const u8 *const sTVHoennTreasureInvestisatorsTextGroup[] = { @@ -5979,48 +5979,40 @@ static void DoTVShowDewfordTrendWatcherNetwork(void) state = sTVShowState; switch (state) { - case 0: - CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); - CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); - if (show->trendWatcher.gender == MALE) - { - sTVShowState = 1; - } - else - { - sTVShowState = 2; - } - break; - case 1: - case 2: - CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); - CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); - TVShowConvertInternationalString(gStringVar3, show->trendWatcher.playerName, show->trendWatcher.language); - sTVShowState = 3; - break; - case 3: - CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); - CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); - if (show->trendWatcher.gender == MALE) - { - sTVShowState = 4; - } - else - { - sTVShowState = 5; - } - break; - case 4: - case 5: - CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); - CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); - TVShowConvertInternationalString(gStringVar3, show->trendWatcher.playerName, show->trendWatcher.language); - sTVShowState = 6; - break; - case 6: - CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); - CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); - TVShowDone(); + case TRENDWATCHER_STATE_INTRO: + CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); + CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); + if (show->trendWatcher.gender == MALE) + sTVShowState = TRENDWATCHER_STATE_TAUGHT_MALE; + else + sTVShowState = TRENDWATCHER_STATE_TAUGHT_FEMALE; + break; + case TRENDWATCHER_STATE_TAUGHT_MALE: + case TRENDWATCHER_STATE_TAUGHT_FEMALE: + CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); + CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); + TVShowConvertInternationalString(gStringVar3, show->trendWatcher.playerName, show->trendWatcher.language); + sTVShowState = TRENDWATCHER_STATE_PHRASE_HOPELESS; + break; + case TRENDWATCHER_STATE_PHRASE_HOPELESS: + CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); + CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); + if (show->trendWatcher.gender == MALE) + sTVShowState = TRENDWATCHER_STATE_BIGGER_MALE; + else + sTVShowState = TRENDWATCHER_STATE_BIGGER_FEMALE; + break; + case TRENDWATCHER_STATE_BIGGER_MALE: + case TRENDWATCHER_STATE_BIGGER_FEMALE: + CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); + CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); + TVShowConvertInternationalString(gStringVar3, show->trendWatcher.playerName, show->trendWatcher.language); + sTVShowState = TRENDWATCHER_STATE_OUTRO; + break; + case TRENDWATCHER_STATE_OUTRO: + CopyEasyChatWord(gStringVar1, show->trendWatcher.words[0]); + CopyEasyChatWord(gStringVar2, show->trendWatcher.words[1]); + TVShowDone(); } ShowFieldMessage(sTVDewfordTrendWatcherNetworkTextGroup[state]); } From 5ba858d19c7134c6bf40f97b276b819e3ff4261a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 31 Mar 2021 16:56:10 -0400 Subject: [PATCH 25/31] Label missing easy chat symbols --- graphics/{misc => easy_chat}/interview.pal | 0 .../{misc => easy_chat}/interview_frame.png | Bin .../{misc/8597C24.pal => easy_chat/text.pal} | 0 .../8597C1C.pal => easy_chat/title_text.pal} | 0 src/easy_chat.c | 31 ++++++++++-------- 5 files changed, 17 insertions(+), 14 deletions(-) rename graphics/{misc => easy_chat}/interview.pal (100%) rename graphics/{misc => easy_chat}/interview_frame.png (100%) rename graphics/{misc/8597C24.pal => easy_chat/text.pal} (100%) rename graphics/{misc/8597C1C.pal => easy_chat/title_text.pal} (100%) diff --git a/graphics/misc/interview.pal b/graphics/easy_chat/interview.pal similarity index 100% rename from graphics/misc/interview.pal rename to graphics/easy_chat/interview.pal diff --git a/graphics/misc/interview_frame.png b/graphics/easy_chat/interview_frame.png similarity index 100% rename from graphics/misc/interview_frame.png rename to graphics/easy_chat/interview_frame.png diff --git a/graphics/misc/8597C24.pal b/graphics/easy_chat/text.pal similarity index 100% rename from graphics/misc/8597C24.pal rename to graphics/easy_chat/text.pal diff --git a/graphics/misc/8597C1C.pal b/graphics/easy_chat/title_text.pal similarity index 100% rename from graphics/misc/8597C1C.pal rename to graphics/easy_chat/title_text.pal diff --git a/src/easy_chat.c b/src/easy_chat.c index fcbd1fba38..13e89c31f9 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -230,14 +230,14 @@ static void DoQuizSetQuestionEasyChatScreen(void); #define PALTAG_TRIANGLE_CURSOR 0 #define PALTAG_RECTANGLE_CURSOR 1 #define PALTAG_MISC_UI 2 -#define PALTAG_3 3 +#define PALTAG_RS_INTERVIEW_FRAME 3 #define GFXTAG_TRIANGLE_CURSOR 0 #define GFXTAG_RECTANGLE_CURSOR 1 #define GFXTAG_SCROLL_INDICATOR 2 #define GFXTAG_START_SELECT_BUTTONS 3 #define GFXTAG_MODE_WINDOW 4 -#define GFXTAG_5 5 +#define GFXTAG_RS_INTERVIEW_FRAME 5 #define GFXTAG_BUTTON_WINDOW 6 // State values for sEasyChatScreen->inputState @@ -698,13 +698,16 @@ static const u16 sTriangleCursor_Pal[] = INCBIN_U16("graphics/easy_chat/triangle static const u32 sTriangleCursor_Gfx[] = INCBIN_U32("graphics/easy_chat/triangle_cursor.4bpp"); static const u32 sScrollIndicator_Gfx[] = INCBIN_U32("graphics/easy_chat/scroll_indicator.4bpp"); static const u32 sStartSelectButtons_Gfx[] = INCBIN_U32("graphics/easy_chat/start_select_buttons.4bpp"); -static const u16 sUnknown_085979C0[] = INCBIN_U16("graphics/misc/interview_frame.gbapal"); -static const u32 sUnknown_085979E0[] = INCBIN_U32("graphics/misc/interview_frame.4bpp.lz"); +// In Ruby/Sapphire Easy Chat screens had a black background, and when the player & interviewer were present +// on screen the interview_frame gfx was shown behind them. +// In Emerald all Easy Chat screens have a filled background, so these gfx go unused +static const u16 sRSInterviewFrame_Pal[] = INCBIN_U16("graphics/easy_chat/interview_frame.gbapal"); +static const u32 sRSInterviewFrame_Gfx[] = INCBIN_U32("graphics/easy_chat/interview_frame.4bpp.lz"); static const u16 sTextInputFrameOrange_Pal[] = INCBIN_U16("graphics/easy_chat/text_input_frame_orange.gbapal"); static const u16 sTextInputFrameGreen_Pal[] = INCBIN_U16("graphics/easy_chat/text_input_frame_green.gbapal"); static const u32 sTextInputFrame_Gfx[] = INCBIN_U32("graphics/easy_chat/text_input_frame.4bpp.lz"); -static const u16 sUnknown_08597C1C[] = INCBIN_U16("graphics/misc/8597C1C.gbapal"); -static const u16 sUnknown_08597C24[] = INCBIN_U16("graphics/misc/8597C24.gbapal"); +static const u16 sTitleText_Pal[] = INCBIN_U16("graphics/easy_chat/title_text.gbapal"); +static const u16 sText_Pal[] = INCBIN_U16("graphics/easy_chat/text.gbapal"); static const struct EasyChatPhraseFrameDimensions sPhraseFrameDimensions[] = { [FRAMEID_GENERAL_2x2] = { @@ -895,17 +898,17 @@ static const struct SpritePalette sSpritePalettes[] = { .tag = PALTAG_MISC_UI, // The palette is generated from the button window but used for various parts of the UI }, { - .data = sUnknown_085979C0, - .tag = PALTAG_3, + .data = sRSInterviewFrame_Pal, + .tag = PALTAG_RS_INTERVIEW_FRAME, }, {0} }; static const struct CompressedSpriteSheet sCompressedSpriteSheets[] = { { - .data = sUnknown_085979E0, + .data = sRSInterviewFrame_Gfx, .size = 0x800, - .tag = GFXTAG_5, + .tag = GFXTAG_RS_INTERVIEW_FRAME, }, { .data = gEasyChatRectangleCursor_Gfx, @@ -3914,10 +3917,10 @@ static void LoadEasyChatPalettes(void) LoadPalette(gEasyChatMode_Pal, 0, 32); LoadPalette(sTextInputFrameOrange_Pal, 1 * 16, 32); LoadPalette(sTextInputFrameGreen_Pal, 4 * 16, 32); - LoadPalette(sUnknown_08597C1C, 10 * 16, 8); - LoadPalette(sUnknown_08597C24, 11 * 16, 12); - LoadPalette(sUnknown_08597C24, 15 * 16, 12); - LoadPalette(sUnknown_08597C24, 3 * 16, 12); + LoadPalette(sTitleText_Pal, 10 * 16, 8); + LoadPalette(sText_Pal, 11 * 16, 12); + LoadPalette(sText_Pal, 15 * 16, 12); + LoadPalette(sText_Pal, 3 * 16, 12); } static void PrintTitle(void) From 69a6a97468d18d53058a188def1e9c21cd3596b0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 31 Mar 2021 17:29:09 -0400 Subject: [PATCH 26/31] Remove incorrect comment --- src/dewford_trend.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dewford_trend.c b/src/dewford_trend.c index 5ce2844d47..09a8d2afe9 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -27,7 +27,6 @@ - rand: This is a 16 bit value generated once when the phrase is created. It's used in calculations for Feebas tiles, Slot Machines, and Match Call. - It's also used to determine how much "trendiness" is lost over time (see below). - trendiness / maxTrendiness: Initialized as a random value between 30-127 inclusive. This is used to compare how trendy one phrase is vs another. If a submitted phrase is From 038505984ccb5286c49ecca68248b7d71ce799e2 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 1 Apr 2021 02:42:02 -0400 Subject: [PATCH 27/31] Fix bg event macros --- asm/macros/map.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/asm/macros/map.inc b/asm/macros/map.inc index b520eb2167..74ed069179 100644 --- a/asm/macros/map.inc +++ b/asm/macros/map.inc @@ -51,25 +51,25 @@ inc _num_traps .endm - .macro bg_event x, y, elevation, kind, arg6, arg7, arg8 + .macro bg_event x, y, elevation, kind, arg6, arg7 .2byte \x, \y .byte \elevation, \kind .2byte 0 - .if \kind < 5 + .if \kind != BG_EVENT_HIDDEN_ITEM .4byte \arg6 .else .2byte \arg6 - .byte \arg7, \arg8 + .2byte \arg7 .endif inc _num_signs .endm .macro bg_hidden_item_event x, y, height, item, flag - bg_event \x, \y, \height, 7, \item, ((\flag) - FLAG_HIDDEN_ITEMS_START), 0 + bg_event \x, \y, \height, BG_EVENT_HIDDEN_ITEM, \item, ((\flag) - FLAG_HIDDEN_ITEMS_START) .endm .macro bg_secret_base_event x, y, height, secret_base_id - bg_event \x, \y, \height, 8, \secret_base_id, 0, 0 + bg_event \x, \y, \height, BG_EVENT_SECRET_BASE, \secret_base_id .endm .macro map_events npcs, warps, traps, signs From f58465a274fbae2275766c50206be1a364f21abc Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 1 Apr 2021 02:35:14 -0400 Subject: [PATCH 28/31] Document match_call.c --- gflib/string_util.h | 8 +- graphics/interface/menu_border.png | Bin 150 -> 0 bytes graphics/pokenav/match_call_window.png | Bin 0 -> 209 bytes graphics/unknown/unknown_60EA4C.pal | 19 -- include/match_call.h | 4 +- src/match_call.c | 273 ++++++++++++++----------- src/pokenav_match_call_2.c | 6 +- 7 files changed, 165 insertions(+), 145 deletions(-) delete mode 100644 graphics/interface/menu_border.png create mode 100644 graphics/pokenav/match_call_window.png delete mode 100644 graphics/unknown/unknown_60EA4C.pal diff --git a/gflib/string_util.h b/gflib/string_util.h index b921d2391d..229193d52d 100644 --- a/gflib/string_util.h +++ b/gflib/string_util.h @@ -1,10 +1,10 @@ #ifndef GUARD_STRING_UTIL_H #define GUARD_STRING_UTIL_H -extern u8 gStringVar1[]; -extern u8 gStringVar2[]; -extern u8 gStringVar3[]; -extern u8 gStringVar4[]; +extern u8 gStringVar1[0x100]; +extern u8 gStringVar2[0x100]; +extern u8 gStringVar3[0x100]; +extern u8 gStringVar4[0x3E8]; enum StringConvertMode { diff --git a/graphics/interface/menu_border.png b/graphics/interface/menu_border.png deleted file mode 100644 index ba748b169d80ae574c96b36167a2db68e49b928a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^4nWMo0wfq#{`6)7Qn8*cjv*3LefzbA4j6E-?hMXN zjrBj_awRx=vQl>O!d)zCjoaB~MAm&NE)cEU_jgKGp>%}b8ph@eGQy{{C+}Xipnb8L yN5i2btvW#`)D9IY9*8>BJguQ!c;6P5n!U_!3+J}lY%GriS?KBN=d#Wzp$Py({4|^Z diff --git a/graphics/pokenav/match_call_window.png b/graphics/pokenav/match_call_window.png new file mode 100644 index 0000000000000000000000000000000000000000..0541bf1476eab2b74521d8d0ec02ba552b254aac GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^4nWMo!VDyL`#gCAqznRlLR^9L|NsAi0wL1zyiaLx~2FB|F-j96O|)8c*jL6fkOXv@)l#1~7y*JWvo( yFfmk+W)E*j(PiG$oWM0f_FTgo)fr4F>zNtsWfE(5`KsxHZ1i;Xb6Mw<&;$UxPD*|N literal 0 HcmV?d00001 diff --git a/graphics/unknown/unknown_60EA4C.pal b/graphics/unknown/unknown_60EA4C.pal deleted file mode 100644 index 87bb7840e2..0000000000 --- a/graphics/unknown/unknown_60EA4C.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -0 0 0 -255 255 255 -0 0 0 -197 197 205 -32 222 148 -106 238 180 -180 255 213 -213 197 255 -238 230 255 -255 189 180 -255 222 213 -189 148 0 -238 238 230 -0 0 0 -0 0 0 -0 0 0 diff --git a/include/match_call.h b/include/match_call.h index bc5f374bd1..8aebb3bc77 100644 --- a/include/match_call.h +++ b/include/match_call.h @@ -17,7 +17,7 @@ bool32 IsMatchCallTaskActive(void); void StartMatchCallFromScript(const u8 *message); void BufferPokedexRatingForMatchCall(u8 *destStr); bool32 SelectMatchCallMessage(int, u8 *); -void sub_8197184(u32 windowId, u32 destOffset, u32 paletteId); -void sub_81971C4(u32 windowId, u32 tileOffset, u32 paletteId); +void LoadMatchCallWindowGfx(u32 windowId, u32 destOffset, u32 paletteId); +void DrawMatchCallTextBoxBorder(u32 windowId, u32 tileOffset, u32 paletteId); #endif //GUARD_MATCH_CALL_H diff --git a/src/match_call.c b/src/match_call.c index b78441f931..c047ca123e 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -39,7 +39,7 @@ struct MatchCallState u32 minutes; u16 trainerId; u8 stepCounter; - u8 triggeredFromScript; + bool8 triggeredFromScript; }; struct MatchCallTrainerTextInfo @@ -82,27 +82,27 @@ static u16 GetRematchTrainerLocation(int); static bool32 TrainerIsEligibleForRematch(int); static void StartMatchCall(void); static void ExecuteMatchCall(u8); -static void DrawMatchCallTextBoxBorder(u32, u32, u32); -static void sub_8196694(u8); +static void DrawMatchCallTextBoxBorder_Internal(u32, u32, u32); +static void Task_SpinPokenavIcon(u8); static void InitMatchCallTextPrinter(int, const u8 *); -static bool32 ExecuteMatchCallTextPrinter(int); +static bool32 RunMatchCallTextPrinter(int); static const struct MatchCallText *GetSameRouteMatchCallText(int, u8 *); static const struct MatchCallText *GetDifferentRouteMatchCallText(int, u8 *); static const struct MatchCallText *GetBattleMatchCallText(int, u8 *); static const struct MatchCallText *GetGeneralMatchCallText(int, u8 *); -static bool32 sub_8196D74(int); +static bool32 ShouldTrainerRequestBattle(int); static void BuildMatchCallString(int, const struct MatchCallText *, u8 *); static u16 GetFrontierStreakInfo(u16, u32 *); static void PopulateMatchCallStringVars(int, const s8 *); static void PopulateMatchCallStringVar(int, int, u8 *); -static bool32 LoadMatchCallWindowGfx(u8); -static bool32 MoveMatchCallWindowToVram(u8); -static bool32 PrintMatchCallIntroEllipsis(u8); -static bool32 sub_81962B0(u8); -static bool32 sub_81962D8(u8); -static bool32 sub_8196330(u8); -static bool32 sub_8196390(u8); -static bool32 sub_81963F0(u8); +static bool32 MatchCall_LoadGfx(u8); +static bool32 MatchCall_DrawWindow(u8); +static bool32 MatchCall_ReadyIntro(u8); +static bool32 MatchCall_SlideWindowIn(u8); +static bool32 MatchCall_PrintIntro(u8); +static bool32 MatchCall_PrintMessage(u8); +static bool32 MatchCall_SlideWindowOut(u8); +static bool32 MatchCall_EndCall(u8); static void PopulateTrainerName(int, u8 *); static void PopulateMapName(int, u8 *); static void PopulateSpeciesFromTrainerLocation(int, u8 *); @@ -977,7 +977,7 @@ void InitMatchCallCounters(void) static u32 GetCurrentTotalMinutes(struct Time *time) { - return time->days * 1440 + time->hours * 60 + time->minutes; + return time->days * 24 * 60 + time->hours * 60 + time->minutes; } static bool32 UpdateMatchCallMinutesCounter(void) @@ -1041,11 +1041,11 @@ static bool32 SelectMatchCallTrainer(void) { u32 matchCallId; u32 numRegistered = GetNumRegisteredNPCs(); - if (!numRegistered) + if (numRegistered == 0) return FALSE; gMatchCallState.trainerId = GetActiveMatchCallTrainerId(Random() % numRegistered); - gMatchCallState.triggeredFromScript = 0; + gMatchCallState.triggeredFromScript = FALSE; if (gMatchCallState.trainerId == REMATCH_TABLE_ENTRIES) return FALSE; @@ -1085,10 +1085,23 @@ static u32 GetActiveMatchCallTrainerId(u32 activeMatchCallId) return REMATCH_TABLE_ENTRIES; } +/* + From the function calls below, a call can only be triggered... + - If the player has match call + - Every 10th step + - Every 10 minutes + - 1/3 of the time (or 2/3 of the time, if the lead party Pokémon has Lightning Rod) + - If in a valid outdoor map (not Safari Zone, not underwater, not Mt Chimney with Team Magma, not Sootopolis with legendaries) + - If an eligible trainer to call the player is selected +*/ bool32 TryStartMatchCall(void) { - if (FlagGet(FLAG_HAS_MATCH_CALL) && UpdateMatchCallStepCounter() && UpdateMatchCallMinutesCounter() - && CheckMatchCallChance() && MapAllowsMatchCall() && SelectMatchCallTrainer()) + if (FlagGet(FLAG_HAS_MATCH_CALL) + && UpdateMatchCallStepCounter() + && UpdateMatchCallMinutesCounter() + && CheckMatchCallChance() + && MapAllowsMatchCall() + && SelectMatchCallTrainer()) { StartMatchCall(); return TRUE; @@ -1099,7 +1112,7 @@ bool32 TryStartMatchCall(void) void StartMatchCallFromScript(const u8 *message) { - gMatchCallState.triggeredFromScript = 1; + gMatchCallState.triggeredFromScript = TRUE; StartMatchCall(); } @@ -1122,33 +1135,37 @@ static void StartMatchCall(void) CreateTask(ExecuteMatchCall, 1); } -static const u16 sUnknown_0860EA4C[] = INCBIN_U16("graphics/unknown/unknown_60EA4C.gbapal"); -static const u8 sUnknown_0860EA6C[] = INCBIN_U8("graphics/interface/menu_border.4bpp"); -static const u16 sPokeNavIconPalette[] = INCBIN_U16("graphics/pokenav/icon.gbapal"); -static const u32 sPokeNavIconGfx[] = INCBIN_U32("graphics/pokenav/icon.4bpp.lz"); +static const u16 sMatchCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call_window.gbapal"); +static const u8 sMatchCallWindow_Gfx[] = INCBIN_U8("graphics/pokenav/match_call_window.4bpp"); +static const u16 sPokenavIcon_Pal[] = INCBIN_U16("graphics/pokenav/icon.gbapal"); +static const u32 sPokenavIcon_Gfx[] = INCBIN_U32("graphics/pokenav/icon.4bpp.lz"); static const u8 sText_PokenavCallEllipsis[] = _("………………\p"); +#define tState data[0] +#define tWindowId data[2] +#define tIconTaskId data[5] + static bool32 (*const sMatchCallTaskFuncs[])(u8) = { - LoadMatchCallWindowGfx, - MoveMatchCallWindowToVram, - PrintMatchCallIntroEllipsis, - sub_81962B0, - sub_81962D8, - sub_8196330, - sub_8196390, - sub_81963F0, + MatchCall_LoadGfx, + MatchCall_DrawWindow, + MatchCall_ReadyIntro, + MatchCall_SlideWindowIn, + MatchCall_PrintIntro, + MatchCall_PrintMessage, + MatchCall_SlideWindowOut, + MatchCall_EndCall, }; static void ExecuteMatchCall(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - if (sMatchCallTaskFuncs[taskData[0]](taskId)) + s16 *data = gTasks[taskId].data; + if (sMatchCallTaskFuncs[tState](taskId)) { - taskData[0]++; - taskData[1] = 0; - if ((u16)taskData[0] > 7) + tState++; + data[1] = 0; // Never read + if ((u16)tState > 7) DestroyTask(taskId); } } @@ -1164,65 +1181,69 @@ static const struct WindowTemplate sMatchCallTextWindow = .baseBlock = 0x200 }; -static bool32 LoadMatchCallWindowGfx(u8 taskId) +#define TILE_MC_WINDOW 0x270 +#define TILE_POKENAV_ICON 0x279 + +static bool32 MatchCall_LoadGfx(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - taskData[2] = AddWindow(&sMatchCallTextWindow); - if (taskData[2] == WINDOW_NONE) + s16 *data = gTasks[taskId].data; + tWindowId = AddWindow(&sMatchCallTextWindow); + if (tWindowId == WINDOW_NONE) { DestroyTask(taskId); return FALSE; } - if (LoadBgTiles(0, sUnknown_0860EA6C, sizeof(sUnknown_0860EA6C), 0x270) == 0xFFFF) + if (LoadBgTiles(0, sMatchCallWindow_Gfx, sizeof(sMatchCallWindow_Gfx), TILE_MC_WINDOW) == 0xFFFF) { - RemoveWindow(taskData[2]); + RemoveWindow(tWindowId); DestroyTask(taskId); return FALSE; } - if (!DecompressAndCopyTileDataToVram(0, sPokeNavIconGfx, 0, 0x279, 0)) + if (!DecompressAndCopyTileDataToVram(0, sPokenavIcon_Gfx, 0, TILE_POKENAV_ICON, 0)) { - RemoveWindow(taskData[2]); + RemoveWindow(tWindowId); DestroyTask(taskId); return FALSE; } - FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8)); - LoadPalette(sUnknown_0860EA4C, 0xE0, 0x20); - LoadPalette(sPokeNavIconPalette, 0xF0, 0x20); + FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); + LoadPalette(sMatchCallWindow_Pal, 0xE0, sizeof(sMatchCallWindow_Pal)); + LoadPalette(sPokenavIcon_Pal, 0xF0, sizeof(sPokenavIcon_Pal)); ChangeBgY(0, -0x2000, 0); return TRUE; } -static bool32 MoveMatchCallWindowToVram(u8 taskId) +static bool32 MatchCall_DrawWindow(u8 taskId) { - s16 *taskData = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; if (FreeTempTileDataBuffersIfPossible()) return FALSE; - PutWindowTilemap(taskData[2]); - DrawMatchCallTextBoxBorder(taskData[2], 0x270, 14); - WriteSequenceToBgTilemapBuffer(0, 0xF279, 1, 15, 4, 4, 17, 1); - taskData[5] = CreateTask(sub_8196694, 10); - CopyWindowToVram(taskData[2], 2); + PutWindowTilemap(tWindowId); + DrawMatchCallTextBoxBorder_Internal(tWindowId, TILE_MC_WINDOW, 14); + WriteSequenceToBgTilemapBuffer(0, (0xF << 12) | TILE_POKENAV_ICON, 1, 15, 4, 4, 17, 1); + tIconTaskId = CreateTask(Task_SpinPokenavIcon, 10); + CopyWindowToVram(tWindowId, 2); CopyBgTilemapBufferToVram(0); return TRUE; } -static bool32 PrintMatchCallIntroEllipsis(u8 taskId) +static bool32 MatchCall_ReadyIntro(u8 taskId) { - s16 *taskData = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; if (!IsDma3ManagerBusyWithBgCopy()) { - InitMatchCallTextPrinter(taskData[2], sText_PokenavCallEllipsis); + // Note that "..." is not printed yet, just readied + InitMatchCallTextPrinter(tWindowId, sText_PokenavCallEllipsis); return TRUE; } return FALSE; } -static bool32 sub_81962B0(u8 taskId) +static bool32 MatchCall_SlideWindowIn(u8 taskId) { if (ChangeBgY(0, 0x600, 1) >= 0) { @@ -1233,29 +1254,30 @@ static bool32 sub_81962B0(u8 taskId) return FALSE; } -static bool32 sub_81962D8(u8 taskId) +static bool32 MatchCall_PrintIntro(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - if (!ExecuteMatchCallTextPrinter(taskData[2])) + s16 *data = gTasks[taskId].data; + if (!RunMatchCallTextPrinter(tWindowId)) { - FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8)); + FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); + + // Ready the message if (!gMatchCallState.triggeredFromScript) SelectMatchCallMessage(gMatchCallState.trainerId, gStringVar4); - - InitMatchCallTextPrinter(taskData[2], gStringVar4); + InitMatchCallTextPrinter(tWindowId, gStringVar4); return TRUE; } return FALSE; } -static bool32 sub_8196330(u8 taskId) +static bool32 MatchCall_PrintMessage(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - if (!ExecuteMatchCallTextPrinter(taskData[2]) && !IsSEPlaying() && JOY_NEW(A_BUTTON | B_BUTTON)) + s16 *data = gTasks[taskId].data; + if (!RunMatchCallTextPrinter(tWindowId) && !IsSEPlaying() && JOY_NEW(A_BUTTON | B_BUTTON)) { - FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8)); - CopyWindowToVram(taskData[2], 2); + FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); + CopyWindowToVram(tWindowId, 2); PlaySE(SE_POKENAV_HANG_UP); return TRUE; } @@ -1263,14 +1285,14 @@ static bool32 sub_8196330(u8 taskId) return FALSE; } -static bool32 sub_8196390(u8 taskId) +static bool32 MatchCall_SlideWindowOut(u8 taskId) { - s16 *taskData = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; if (ChangeBgY(0, 0x600, 2) <= -0x2000) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 14, 30, 6); - DestroyTask(taskData[5]); - RemoveWindow(taskData[2]); + DestroyTask(tIconTaskId); + RemoveWindow(tWindowId); CopyBgTilemapBufferToVram(0); return TRUE; } @@ -1278,7 +1300,7 @@ static bool32 sub_8196390(u8 taskId) return FALSE; } -static bool32 sub_81963F0(u8 taskId) +static bool32 MatchCall_EndCall(u8 taskId) { u8 playerObjectId; if (!IsDma3ManagerBusyWithBgCopy() && !IsSEPlaying()) @@ -1300,7 +1322,7 @@ static bool32 sub_81963F0(u8 taskId) return FALSE; } -static void DrawMatchCallTextBoxBorder(u32 windowId, u32 tileOffset, u32 paletteId) +static void DrawMatchCallTextBoxBorder_Internal(u32 windowId, u32 tileOffset, u32 paletteId) { int bg, x, y, width, height; int tileNum; @@ -1335,40 +1357,48 @@ static void InitMatchCallTextPrinter(int windowId, const u8 *str) printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; printerTemplate.unk = 0; - printerTemplate.fgColor = 10; - printerTemplate.bgColor = 8; - printerTemplate.shadowColor = 14; - gTextFlags.useAlternateDownArrow = 0; + printerTemplate.fgColor = TEXT_DYNAMIC_COLOR_1; + printerTemplate.bgColor = TEXT_COLOR_BLUE; + printerTemplate.shadowColor = TEXT_DYNAMIC_COLOR_5; + gTextFlags.useAlternateDownArrow = FALSE; AddTextPrinter(&printerTemplate, GetPlayerTextSpeedDelay(), NULL); } -static bool32 ExecuteMatchCallTextPrinter(int windowId) +static bool32 RunMatchCallTextPrinter(int windowId) { if (JOY_HELD(A_BUTTON)) - gTextFlags.canABSpeedUpPrint = 1; + gTextFlags.canABSpeedUpPrint = TRUE; else - gTextFlags.canABSpeedUpPrint = 0; + gTextFlags.canABSpeedUpPrint = FALSE; RunTextPrinters(); return IsTextPrinterActive(windowId); } -static void sub_8196694(u8 taskId) -{ - s16 *taskData = gTasks[taskId].data; - if (++taskData[0] > 8) - { - taskData[0] = 0; - if (++taskData[1] > 7) - taskData[1] = 0; +#define tTimer data[0] +#define tSpinStage data[1] +#define tTileNum data[2] - taskData[2] = (taskData[1] * 16) + 0x279; - WriteSequenceToBgTilemapBuffer(0, taskData[2] | ~0xFFF, 1, 15, 4, 4, 17, 1); +static void Task_SpinPokenavIcon(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if (++tTimer > 8) + { + tTimer = 0; + if (++tSpinStage > 7) + tSpinStage = 0; + + tTileNum = (tSpinStage * 16) + TILE_POKENAV_ICON; + WriteSequenceToBgTilemapBuffer(0, tTileNum | ~0xFFF, 1, 15, 4, 4, 17, 1); CopyBgTilemapBufferToVram(0); } } +#undef tTimer +#undef tSpinStage +#undef tTileNum + static bool32 TrainerIsEligibleForRematch(int matchCallId) { return gSaveBlock1Ptr->trainerRematches[matchCallId] > 0; @@ -1392,7 +1422,10 @@ static u32 GetNumRematchTrainersFought(void) return count; } -static u32 sub_8196774(int arg0) +// Look through the rematch table for trainers that have been defeated once before. +// Return the index into the rematch table of the nth defeated trainer, +// or REMATCH_TABLE_ENTRIES if fewer than n rematch trainers have been defeated. +static u32 GetNthRematchTrainerFought(int n) { u32 i, count; @@ -1400,7 +1433,7 @@ static u32 sub_8196774(int arg0) { if (HasTrainerBeenFought(gRematchTable[i].trainerIds[0])) { - if (count == arg0) + if (count == n) return i; count++; @@ -1418,12 +1451,18 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str) matchCallId = GetTrainerMatchCallId(trainerId); gBattleFrontierStreakInfo.facilityId = 0; + + // If the player is on the same route as the trainer + // and they can be rematched, they will always request a battle if (TrainerIsEligibleForRematch(matchCallId) && GetRematchTrainerLocation(matchCallId) == gMapHeader.regionMapSectionId) { matchCallText = GetSameRouteMatchCallText(matchCallId, str); } - else if (sub_8196D74(matchCallId)) + // If the player is not on the same route as the trainer + // and they can be rematched, there is a random chance for + // the trainer to request a battle + else if (ShouldTrainerRequestBattle(matchCallId)) { matchCallText = GetDifferentRouteMatchCallText(matchCallId, str); retVal = TRUE; @@ -1431,10 +1470,12 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str) } else if (Random() % 3) { + // Message talking about a battle the NPC had matchCallText = GetBattleMatchCallText(matchCallId, str); } else { + // Message talking about something else matchCallText = GetGeneralMatchCallText(matchCallId, str); } @@ -1577,7 +1618,7 @@ static void PopulateTrainerName(int matchCallId, u8 *destStr) { u32 i; u16 trainerId = sMatchCallTrainers[matchCallId].trainerId; - for (i = 0; i < 6; i++) + for (i = 0; i < ARRAY_COUNT(sMultiTrainerMatchCallTexts); i++) { if (sMultiTrainerMatchCallTexts[i].trainerId == trainerId) { @@ -1769,13 +1810,14 @@ static int GetNumOwnedBadges(void) return i; } -static bool32 sub_8196D74(int matchCallId) +// Whether or not a trainer calling the player from a different route should request a battle +static bool32 ShouldTrainerRequestBattle(int matchCallId) { int dayCount; int otId; - u16 rand; + u16 dewfordRand; int numRematchTrainersFought; - int var0, var1, var2; + int max, rand, n; if (GetNumOwnedBadges() < 5) return FALSE; @@ -1783,14 +1825,14 @@ static bool32 sub_8196D74(int matchCallId) dayCount = RtcGetLocalDayCount(); otId = GetTrainerId(gSaveBlock2Ptr->playerTrainerId) & 0xFFFF; - rand = gSaveBlock1Ptr->dewfordTrends[0].rand; + dewfordRand = gSaveBlock1Ptr->dewfordTrends[0].rand; numRematchTrainersFought = GetNumRematchTrainersFought(); - var0 = (numRematchTrainersFought * 13) / 10; - var1 = ((dayCount ^ rand) + (rand ^ GetGameStat(GAME_STAT_TRAINER_BATTLES))) ^ otId; - var2 = var1 % var0; - if (var2 < numRematchTrainersFought) + max = (numRematchTrainersFought * 13) / 10; + rand = ((dayCount ^ dewfordRand) + (dewfordRand ^ GetGameStat(GAME_STAT_TRAINER_BATTLES))) ^ otId; + n = rand % max; + if (n < numRematchTrainersFought) { - if (sub_8196774(var2) == matchCallId) + if (GetNthRematchTrainerFought(n) == matchCallId) return TRUE; } @@ -1971,7 +2013,7 @@ void BufferPokedexRatingForMatchCall(u8 *destStr) u8 *str; u8 dexRatingLevel; - u8 *buffer = Alloc(0x3E8); + u8 *buffer = Alloc(sizeof(gStringVar4)); if (!buffer) { destStr[0] = EOS; @@ -1984,18 +2026,15 @@ void BufferPokedexRatingForMatchCall(u8 *destStr) ConvertIntToDecimalStringN(gStringVar2, numCaught, STR_CONV_MODE_LEFT_ALIGN, 3); dexRatingLevel = GetPokedexRatingLevel(numCaught); str = StringCopy(buffer, gBirchDexRatingText_AreYouCurious); - str[0] = CHAR_PROMPT_CLEAR; - str++; + *(str++) = CHAR_PROMPT_CLEAR; str = StringCopy(str, gBirchDexRatingText_SoYouveSeenAndCaught); - str[0] = CHAR_PROMPT_CLEAR; - str++; + *(str++) = CHAR_PROMPT_CLEAR; StringCopy(str, sBirchDexRatingTexts[dexRatingLevel]); str = StringExpandPlaceholders(destStr, buffer); if (IsNationalPokedexEnabled()) { - str[0] = CHAR_PROMPT_CLEAR; - str++; + *(str++) = CHAR_PROMPT_CLEAR; numSeen = GetNationalPokedexCount(FLAG_GET_SEEN); numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); ConvertIntToDecimalStringN(gStringVar1, numSeen, STR_CONV_MODE_LEFT_ALIGN, 3); @@ -2006,14 +2045,14 @@ void BufferPokedexRatingForMatchCall(u8 *destStr) Free(buffer); } -void sub_8197184(u32 windowId, u32 destOffset, u32 paletteId) +void LoadMatchCallWindowGfx(u32 windowId, u32 destOffset, u32 paletteId) { u8 bg = GetWindowAttribute(windowId, WINDOW_BG); - LoadBgTiles(bg, sUnknown_0860EA6C, 0x100, destOffset); - LoadPalette(sUnknown_0860EA4C, paletteId << 4, 0x20); + LoadBgTiles(bg, sMatchCallWindow_Gfx, 0x100, destOffset); + LoadPalette(sMatchCallWindow_Pal, paletteId << 4, sizeof(sMatchCallWindow_Pal)); } -void sub_81971C4(u32 windowId, u32 tileOffset, u32 paletteId) +void DrawMatchCallTextBoxBorder(u32 windowId, u32 tileOffset, u32 paletteId) { - DrawMatchCallTextBoxBorder(windowId, tileOffset, paletteId); + DrawMatchCallTextBoxBorder_Internal(windowId, tileOffset, paletteId); } diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 593581d0e2..398e174d8f 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -1061,15 +1061,15 @@ static void UpdateWindowsToShowCheckPage(struct Pokenav4Struct *state) static void sub_81CC034(struct Pokenav4Struct *state) { state->msgBoxWindowId = AddWindow(&sCallMsgBoxWindowTemplate); - sub_8197184(state->msgBoxWindowId, 1, 4); + LoadMatchCallWindowGfx(state->msgBoxWindowId, 1, 4); sub_81C7B40(); } static void DrawMsgBoxForMatchCallMsg(struct Pokenav4Struct *state) { struct Sprite *sprite; - sub_8197184(state->msgBoxWindowId, 1, 4); - sub_81971C4(state->msgBoxWindowId, 1, 4); + LoadMatchCallWindowGfx(state->msgBoxWindowId, 1, 4); + DrawMatchCallTextBoxBorder(state->msgBoxWindowId, 1, 4); FillWindowPixelBuffer(state->msgBoxWindowId, PIXEL_FILL(1)); PutWindowTilemap(state->msgBoxWindowId); CopyWindowToVram(state->msgBoxWindowId, 3); From 1ff6aaf57d591c79c845d2fd15509fa4b9f95f91 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 1 Apr 2021 04:21:26 -0400 Subject: [PATCH 29/31] Add constant use for match call text ids --- src/match_call.c | 1078 ++++++++++++++++++++++++---------------------- 1 file changed, 565 insertions(+), 513 deletions(-) diff --git a/src/match_call.c b/src/match_call.c index c047ca123e..fd0db630c4 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -34,6 +34,56 @@ #include "constants/songs.h" #include "constants/trainers.h" +// Each match call message has variables that can be populated randomly or +// dependent on the trainer. The below are IDs for how to populate the vars +// in a given message. +// Each message may have up to 3 vars in it +enum { + STR_TRAINER_NAME, + STR_MAP_NAME, + STR_SPECIES_IN_ROUTE, + STR_SPECIES_IN_PARTY, + STR_FACILITY_NAME, + STR_FRONTIER_STREAK, + STR_NONE = -1, +}; +#define STRS_NORMAL_MSG {STR_TRAINER_NAME, STR_NONE, STR_NONE} +#define STRS_WILD_BATTLE {STR_TRAINER_NAME, STR_SPECIES_IN_ROUTE, STR_NONE} +#define STRS_BATTLE_NEGATIVE {STR_TRAINER_NAME, STR_NONE, STR_NONE} +#define STRS_BATTLE_POSITIVE {STR_TRAINER_NAME, STR_SPECIES_IN_PARTY, STR_NONE} +#define STRS_BATTLE_REQUEST {STR_TRAINER_NAME, STR_MAP_NAME, STR_NONE} +#define STRS_FRONTIER {STR_TRAINER_NAME, STR_FACILITY_NAME, STR_FRONTIER_STREAK} + +#define NUM_STRVARS_IN_MSG 3 + +// Topic IDs for sMatchCallGeneralTopics +enum { + GEN_TOPIC_PERSONAL = 1, + GEN_TOPIC_STREAK, + GEN_TOPIC_STREAK_RECORD, + GEN_TOPIC_B_DOME, + GEN_TOPIC_B_PIKE, + GEN_TOPIC_B_PYRAMID, +}; + +// Topic IDs for sMatchCallBattleTopics +enum { + B_TOPIC_WILD = 1, + B_TOPIC_NEGATIVE, + B_TOPIC_POSITIVE, +}; + +// Each trainer has a text id for 1 of each of the 3 battle topics +// The msgId is the index into the respective topic's message table +// For all but 2 trainers this index is the same for each topic +#define BATTLE_TEXT_IDS(msgId) {TEXT_ID(B_TOPIC_WILD, (msgId)), TEXT_ID(B_TOPIC_NEGATIVE, (msgId)), TEXT_ID(B_TOPIC_POSITIVE, (msgId))} + +// Topic IDs for sMatchCallBattleRequestTopics +enum { + REQ_TOPIC_SAME_ROUTE = 1, + REQ_TOPIC_DIFF_ROUTE, +}; + struct MatchCallState { u32 minutes; @@ -56,7 +106,7 @@ struct MatchCallTrainerTextInfo struct MatchCallText { const u8 *text; - s8 stringVarFuncIds[3]; + s8 stringVarFuncIds[NUM_STRVARS_IN_MSG]; }; struct MultiTrainerMatchCallText @@ -71,8 +121,8 @@ struct BattleFrontierStreakInfo u16 streak; }; -EWRAM_DATA struct MatchCallState gMatchCallState = {0}; -EWRAM_DATA struct BattleFrontierStreakInfo gBattleFrontierStreakInfo = {0}; +static EWRAM_DATA struct MatchCallState sMatchCallState = {0}; +static EWRAM_DATA struct BattleFrontierStreakInfo sBattleFrontierStreakInfo = {0}; static u32 GetCurrentTotalMinutes(struct Time *); static u32 GetNumRegisteredNPCs(void); @@ -117,851 +167,853 @@ static const struct MatchCallTrainerTextInfo sMatchCallTrainers[] = { .trainerId = TRAINER_ROSE_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 8), TEXT_ID(2, 8), TEXT_ID(3, 8) }, - .generalTextId = TEXT_ID(1, 3), + .battleTopicTextIds = BATTLE_TEXT_IDS(8), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 3), .battleFrontierRecordStreakTextIndex = 8, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 8), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 8), }, { .trainerId = TRAINER_ANDRES_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 12), TEXT_ID(2, 12), TEXT_ID(3, 12) }, - .generalTextId = TEXT_ID(1, 62), + .battleTopicTextIds = BATTLE_TEXT_IDS(12), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 62), .battleFrontierRecordStreakTextIndex = 12, - .sameRouteMatchCallTextId = TEXT_ID(1, 12), - .differentRouteMatchCallTextId = TEXT_ID(2, 12), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 12), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 12), }, { .trainerId = TRAINER_DUSTY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 12), TEXT_ID(2, 12), TEXT_ID(3, 12) }, - .generalTextId = TEXT_ID(1, 4), + .battleTopicTextIds = BATTLE_TEXT_IDS(12), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 4), .battleFrontierRecordStreakTextIndex = 12, - .sameRouteMatchCallTextId = TEXT_ID(1, 12), - .differentRouteMatchCallTextId = TEXT_ID(2, 12), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 12), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 12), }, { .trainerId = TRAINER_LOLA_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 2), TEXT_ID(2, 2), TEXT_ID(3, 2) }, - .generalTextId = TEXT_ID(1, 5), + .battleTopicTextIds = BATTLE_TEXT_IDS(2), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 5), .battleFrontierRecordStreakTextIndex = 2, - .sameRouteMatchCallTextId = TEXT_ID(1, 2), - .differentRouteMatchCallTextId = TEXT_ID(2, 2), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 2), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 2), }, { .trainerId = TRAINER_RICKY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 1), TEXT_ID(2, 1), TEXT_ID(3, 1) }, - .generalTextId = TEXT_ID(1, 6), + .battleTopicTextIds = BATTLE_TEXT_IDS(1), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 6), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 1), - .differentRouteMatchCallTextId = TEXT_ID(2, 1), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 1), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 1), }, { .trainerId = TRAINER_LILA_AND_ROY_1, .unused = 4, - .battleTopicTextIds = { TEXT_ID(1, 1), TEXT_ID(2, 1), TEXT_ID(3, 1) }, - .generalTextId = TEXT_ID(1, 61), + .battleTopicTextIds = BATTLE_TEXT_IDS(1), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 61), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 1), - .differentRouteMatchCallTextId = TEXT_ID(2, 1), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 1), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 1), }, { .trainerId = TRAINER_CRISTIN_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 10), TEXT_ID(2, 10), TEXT_ID(3, 10) }, - .generalTextId = TEXT_ID(1, 64), + .battleTopicTextIds = BATTLE_TEXT_IDS(10), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 64), .battleFrontierRecordStreakTextIndex = 10, - .sameRouteMatchCallTextId = TEXT_ID(1, 10), - .differentRouteMatchCallTextId = TEXT_ID(2, 10), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 10), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 10), }, { .trainerId = TRAINER_BROOKE_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 8), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 8), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, { .trainerId = TRAINER_WILTON_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 6), TEXT_ID(2, 6), TEXT_ID(3, 6) }, - .generalTextId = TEXT_ID(1, 7), + .battleTopicTextIds = BATTLE_TEXT_IDS(6), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 7), .battleFrontierRecordStreakTextIndex = 6, - .sameRouteMatchCallTextId = TEXT_ID(1, 6), - .differentRouteMatchCallTextId = TEXT_ID(2, 6), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 6), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 6), }, { .trainerId = TRAINER_VALERIE_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 8), TEXT_ID(2, 8), TEXT_ID(3, 8) }, - .generalTextId = TEXT_ID(1, 9), + .battleTopicTextIds = BATTLE_TEXT_IDS(8), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 9), .battleFrontierRecordStreakTextIndex = 8, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 8), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 8), }, { .trainerId = TRAINER_CINDY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 8), TEXT_ID(2, 8), TEXT_ID(3, 8) }, - .generalTextId = TEXT_ID(1, 10), + .battleTopicTextIds = BATTLE_TEXT_IDS(8), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 10), .battleFrontierRecordStreakTextIndex = 8, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 8), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 8), }, { .trainerId = TRAINER_THALIA_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 8), TEXT_ID(2, 10), TEXT_ID(3, 10) }, - .generalTextId = TEXT_ID(1, 14), + // Thalia and Sawyer are the only ones who use different msg ids for their battle topics + .battleTopicTextIds = { TEXT_ID(B_TOPIC_WILD, 8), TEXT_ID(B_TOPIC_NEGATIVE, 10), TEXT_ID(B_TOPIC_POSITIVE, 10) }, + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 14), .battleFrontierRecordStreakTextIndex = 10, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 10), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 10), }, { .trainerId = TRAINER_JESSICA_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 10), TEXT_ID(2, 10), TEXT_ID(3, 10) }, - .generalTextId = TEXT_ID(1, 11), + .battleTopicTextIds = BATTLE_TEXT_IDS(10), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 11), .battleFrontierRecordStreakTextIndex = 10, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 10), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 10), }, { .trainerId = TRAINER_WINSTON_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 4), TEXT_ID(2, 4), TEXT_ID(3, 4) }, - .generalTextId = TEXT_ID(1, 12), + .battleTopicTextIds = BATTLE_TEXT_IDS(4), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 12), .battleFrontierRecordStreakTextIndex = 4, - .sameRouteMatchCallTextId = TEXT_ID(1, 4), - .differentRouteMatchCallTextId = TEXT_ID(2, 4), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 4), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 4), }, { .trainerId = TRAINER_STEVE_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 7), TEXT_ID(2, 7), TEXT_ID(3, 7) }, - .generalTextId = TEXT_ID(1, 13), + .battleTopicTextIds = BATTLE_TEXT_IDS(7), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 13), .battleFrontierRecordStreakTextIndex = 7, - .sameRouteMatchCallTextId = TEXT_ID(1, 7), - .differentRouteMatchCallTextId = TEXT_ID(2, 7), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 7), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 7), }, { .trainerId = TRAINER_TONY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 5), TEXT_ID(2, 5), TEXT_ID(3, 5) }, - .generalTextId = TEXT_ID(1, 15), + .battleTopicTextIds = BATTLE_TEXT_IDS(5), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 15), .battleFrontierRecordStreakTextIndex = 5, - .sameRouteMatchCallTextId = TEXT_ID(1, 5), - .differentRouteMatchCallTextId = TEXT_ID(2, 5), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 5), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 5), }, { .trainerId = TRAINER_NOB_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 3), TEXT_ID(2, 3), TEXT_ID(3, 3) }, - .generalTextId = TEXT_ID(1, 16), + .battleTopicTextIds = BATTLE_TEXT_IDS(3), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 16), .battleFrontierRecordStreakTextIndex = 3, - .sameRouteMatchCallTextId = TEXT_ID(1, 3), - .differentRouteMatchCallTextId = TEXT_ID(2, 3), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 3), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 3), }, { .trainerId = TRAINER_KOJI_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 3), TEXT_ID(2, 3), TEXT_ID(3, 3) }, - .generalTextId = TEXT_ID(1, 59), + .battleTopicTextIds = BATTLE_TEXT_IDS(3), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 59), .battleFrontierRecordStreakTextIndex = 3, - .sameRouteMatchCallTextId = TEXT_ID(1, 3), - .differentRouteMatchCallTextId = TEXT_ID(2, 3), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 3), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 3), }, { .trainerId = TRAINER_FERNANDO_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 6), TEXT_ID(2, 6), TEXT_ID(3, 6) }, - .generalTextId = TEXT_ID(1, 17), + .battleTopicTextIds = BATTLE_TEXT_IDS(6), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 17), .battleFrontierRecordStreakTextIndex = 6, - .sameRouteMatchCallTextId = TEXT_ID(1, 6), - .differentRouteMatchCallTextId = TEXT_ID(2, 6), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 6), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 6), }, { .trainerId = TRAINER_DALTON_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 4), TEXT_ID(2, 4), TEXT_ID(3, 4) }, - .generalTextId = TEXT_ID(1, 18), + .battleTopicTextIds = BATTLE_TEXT_IDS(4), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 18), .battleFrontierRecordStreakTextIndex = 4, - .sameRouteMatchCallTextId = TEXT_ID(1, 4), - .differentRouteMatchCallTextId = TEXT_ID(2, 4), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 4), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 4), }, { .trainerId = TRAINER_BERNIE_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 11), TEXT_ID(2, 11), TEXT_ID(3, 11) }, - .generalTextId = TEXT_ID(1, 19), + .battleTopicTextIds = BATTLE_TEXT_IDS(11), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 19), .battleFrontierRecordStreakTextIndex = 11, - .sameRouteMatchCallTextId = TEXT_ID(1, 11), - .differentRouteMatchCallTextId = TEXT_ID(2, 11), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 11), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 11), }, { .trainerId = TRAINER_ETHAN_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 1), TEXT_ID(2, 1), TEXT_ID(3, 1) }, - .generalTextId = TEXT_ID(1, 20), + .battleTopicTextIds = BATTLE_TEXT_IDS(1), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 20), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 1), - .differentRouteMatchCallTextId = TEXT_ID(2, 1), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 1), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 1), }, { .trainerId = TRAINER_JOHN_AND_JAY_1, .unused = 3, - .battleTopicTextIds = { TEXT_ID(1, 12), TEXT_ID(2, 12), TEXT_ID(3, 12) }, - .generalTextId = TEXT_ID(1, 60), + .battleTopicTextIds = BATTLE_TEXT_IDS(12), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 60), .battleFrontierRecordStreakTextIndex = 12, - .sameRouteMatchCallTextId = TEXT_ID(1, 12), - .differentRouteMatchCallTextId = TEXT_ID(2, 12), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 12), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 12), }, { .trainerId = TRAINER_JEFFREY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 7), TEXT_ID(2, 7), TEXT_ID(3, 7) }, - .generalTextId = TEXT_ID(1, 21), + .battleTopicTextIds = BATTLE_TEXT_IDS(7), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 21), .battleFrontierRecordStreakTextIndex = 7, - .sameRouteMatchCallTextId = TEXT_ID(1, 7), - .differentRouteMatchCallTextId = TEXT_ID(2, 7), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 7), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 7), }, { .trainerId = TRAINER_CAMERON_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 4), TEXT_ID(2, 4), TEXT_ID(3, 4) }, - .generalTextId = TEXT_ID(1, 22), + .battleTopicTextIds = BATTLE_TEXT_IDS(4), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 22), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 4), - .differentRouteMatchCallTextId = TEXT_ID(2, 4), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 4), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 4), }, { .trainerId = TRAINER_JACKI_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 8), TEXT_ID(2, 8), TEXT_ID(3, 8) }, - .generalTextId = TEXT_ID(1, 23), + .battleTopicTextIds = BATTLE_TEXT_IDS(8), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 23), .battleFrontierRecordStreakTextIndex = 8, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 8), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 8), }, { .trainerId = TRAINER_WALTER_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 12), TEXT_ID(2, 12), TEXT_ID(3, 12) }, - .generalTextId = TEXT_ID(1, 24), + .battleTopicTextIds = BATTLE_TEXT_IDS(12), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 24), .battleFrontierRecordStreakTextIndex = 12, - .sameRouteMatchCallTextId = TEXT_ID(1, 12), - .differentRouteMatchCallTextId = TEXT_ID(2, 12), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 12), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 12), }, { .trainerId = TRAINER_KAREN_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 2), TEXT_ID(2, 2), TEXT_ID(3, 2) }, - .generalTextId = TEXT_ID(1, 26), + .battleTopicTextIds = BATTLE_TEXT_IDS(2), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 26), .battleFrontierRecordStreakTextIndex = 2, - .sameRouteMatchCallTextId = TEXT_ID(1, 2), - .differentRouteMatchCallTextId = TEXT_ID(2, 2), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 2), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 2), }, { .trainerId = TRAINER_JERRY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 1), TEXT_ID(2, 1), TEXT_ID(3, 1) }, - .generalTextId = TEXT_ID(1, 25), + .battleTopicTextIds = BATTLE_TEXT_IDS(1), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 25), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 1), - .differentRouteMatchCallTextId = TEXT_ID(2, 1), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 1), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 1), }, { .trainerId = TRAINER_ANNA_AND_MEG_1, .unused = 6, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 27), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 27), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, { .trainerId = TRAINER_ISABEL_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 14), TEXT_ID(2, 14), TEXT_ID(3, 14) }, - .generalTextId = TEXT_ID(1, 29), + .battleTopicTextIds = BATTLE_TEXT_IDS(14), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 29), .battleFrontierRecordStreakTextIndex = 14, - .sameRouteMatchCallTextId = TEXT_ID(1, 14), - .differentRouteMatchCallTextId = TEXT_ID(2, 14), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 14), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 14), }, { .trainerId = TRAINER_MIGUEL_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 11), TEXT_ID(2, 11), TEXT_ID(3, 11) }, - .generalTextId = TEXT_ID(1, 28), + .battleTopicTextIds = BATTLE_TEXT_IDS(11), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 28), .battleFrontierRecordStreakTextIndex = 11, - .sameRouteMatchCallTextId = TEXT_ID(1, 11), - .differentRouteMatchCallTextId = TEXT_ID(2, 11), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 11), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 11), }, { .trainerId = TRAINER_TIMOTHY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 12), TEXT_ID(2, 12), TEXT_ID(3, 12) }, - .generalTextId = TEXT_ID(1, 30), + .battleTopicTextIds = BATTLE_TEXT_IDS(12), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 30), .battleFrontierRecordStreakTextIndex = 12, - .sameRouteMatchCallTextId = TEXT_ID(1, 12), - .differentRouteMatchCallTextId = TEXT_ID(2, 12), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 12), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 12), }, { .trainerId = TRAINER_SHELBY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 13), TEXT_ID(2, 13), TEXT_ID(3, 13) }, - .generalTextId = TEXT_ID(1, 31), + .battleTopicTextIds = BATTLE_TEXT_IDS(13), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 31), .battleFrontierRecordStreakTextIndex = 13, - .sameRouteMatchCallTextId = TEXT_ID(1, 13), - .differentRouteMatchCallTextId = TEXT_ID(2, 13), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 13), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 13), }, { .trainerId = TRAINER_CALVIN_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 1), TEXT_ID(2, 1), TEXT_ID(3, 1) }, - .generalTextId = TEXT_ID(1, 32), + .battleTopicTextIds = BATTLE_TEXT_IDS(1), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 32), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 1), - .differentRouteMatchCallTextId = TEXT_ID(2, 1), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 1), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 1), }, { .trainerId = TRAINER_ELLIOT_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 3), TEXT_ID(2, 3), TEXT_ID(3, 3) }, - .generalTextId = TEXT_ID(1, 33), + .battleTopicTextIds = BATTLE_TEXT_IDS(3), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 33), .battleFrontierRecordStreakTextIndex = 3, - .sameRouteMatchCallTextId = TEXT_ID(1, 3), - .differentRouteMatchCallTextId = TEXT_ID(2, 3), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 3), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 3), }, { .trainerId = TRAINER_ISAIAH_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 5), TEXT_ID(2, 5), TEXT_ID(3, 5) }, - .generalTextId = TEXT_ID(1, 38), + .battleTopicTextIds = BATTLE_TEXT_IDS(5), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 38), .battleFrontierRecordStreakTextIndex = 5, - .sameRouteMatchCallTextId = TEXT_ID(1, 5), - .differentRouteMatchCallTextId = TEXT_ID(2, 5), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 5), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 5), }, { .trainerId = TRAINER_MARIA_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 37), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 37), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, { .trainerId = TRAINER_ABIGAIL_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 35), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 35), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, { .trainerId = TRAINER_DYLAN_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 5), TEXT_ID(2, 5), TEXT_ID(3, 5) }, - .generalTextId = TEXT_ID(1, 36), + .battleTopicTextIds = BATTLE_TEXT_IDS(5), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 36), .battleFrontierRecordStreakTextIndex = 5, - .sameRouteMatchCallTextId = TEXT_ID(1, 5), - .differentRouteMatchCallTextId = TEXT_ID(2, 5), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 5), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 5), }, { .trainerId = TRAINER_KATELYN_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 40), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 40), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, { .trainerId = TRAINER_BENJAMIN_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 5), TEXT_ID(2, 5), TEXT_ID(3, 5) }, - .generalTextId = TEXT_ID(1, 34), + .battleTopicTextIds = BATTLE_TEXT_IDS(5), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 34), .battleFrontierRecordStreakTextIndex = 5, - .sameRouteMatchCallTextId = TEXT_ID(1, 5), - .differentRouteMatchCallTextId = TEXT_ID(2, 5), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 5), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 5), }, { .trainerId = TRAINER_PABLO_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 5), TEXT_ID(2, 5), TEXT_ID(3, 5) }, - .generalTextId = TEXT_ID(1, 39), + .battleTopicTextIds = BATTLE_TEXT_IDS(5), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 39), .battleFrontierRecordStreakTextIndex = 5, - .sameRouteMatchCallTextId = TEXT_ID(1, 5), - .differentRouteMatchCallTextId = TEXT_ID(2, 5), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 5), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 5), }, { .trainerId = TRAINER_NICOLAS_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 4), TEXT_ID(2, 4), TEXT_ID(3, 4) }, - .generalTextId = TEXT_ID(1, 41), + .battleTopicTextIds = BATTLE_TEXT_IDS(4), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 41), .battleFrontierRecordStreakTextIndex = 4, - .sameRouteMatchCallTextId = TEXT_ID(1, 4), - .differentRouteMatchCallTextId = TEXT_ID(2, 4), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 4), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 4), }, { .trainerId = TRAINER_ROBERT_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 6), TEXT_ID(2, 6), TEXT_ID(3, 6) }, - .generalTextId = TEXT_ID(1, 42), + .battleTopicTextIds = BATTLE_TEXT_IDS(6), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 42), .battleFrontierRecordStreakTextIndex = 6, - .sameRouteMatchCallTextId = TEXT_ID(1, 6), - .differentRouteMatchCallTextId = TEXT_ID(2, 6), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 6), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 6), }, { .trainerId = TRAINER_LAO_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 1), TEXT_ID(2, 1), TEXT_ID(3, 1) }, - .generalTextId = TEXT_ID(1, 43), + .battleTopicTextIds = BATTLE_TEXT_IDS(1), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 43), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 1), - .differentRouteMatchCallTextId = TEXT_ID(2, 1), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 1), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 1), }, { .trainerId = TRAINER_CYNDY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 44), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 44), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, { .trainerId = TRAINER_MADELINE_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 8), TEXT_ID(2, 8), TEXT_ID(3, 8) }, - .generalTextId = TEXT_ID(1, 45), + .battleTopicTextIds = BATTLE_TEXT_IDS(8), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 45), .battleFrontierRecordStreakTextIndex = 8, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 8), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 8), }, { .trainerId = TRAINER_JENNY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 46), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 46), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, { .trainerId = TRAINER_DIANA_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 2), TEXT_ID(2, 2), TEXT_ID(3, 2) }, - .generalTextId = TEXT_ID(1, 47), + .battleTopicTextIds = BATTLE_TEXT_IDS(2), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 47), .battleFrontierRecordStreakTextIndex = 2, - .sameRouteMatchCallTextId = TEXT_ID(1, 2), - .differentRouteMatchCallTextId = TEXT_ID(2, 2), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 2), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 2), }, { .trainerId = TRAINER_AMY_AND_LIV_1, .unused = 2, - .battleTopicTextIds = { TEXT_ID(1, 2), TEXT_ID(2, 2), TEXT_ID(3, 2) }, - .generalTextId = TEXT_ID(1, 48), + .battleTopicTextIds = BATTLE_TEXT_IDS(2), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 48), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 2), - .differentRouteMatchCallTextId = TEXT_ID(2, 2), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 2), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 2), }, { .trainerId = TRAINER_ERNEST_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 3), TEXT_ID(2, 3), TEXT_ID(3, 3) }, - .generalTextId = TEXT_ID(1, 49), + .battleTopicTextIds = BATTLE_TEXT_IDS(3), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 49), .battleFrontierRecordStreakTextIndex = 3, - .sameRouteMatchCallTextId = TEXT_ID(1, 3), - .differentRouteMatchCallTextId = TEXT_ID(2, 3), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 3), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 3), }, { .trainerId = TRAINER_CORY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 3), TEXT_ID(2, 3), TEXT_ID(3, 3) }, - .generalTextId = TEXT_ID(1, 63), + .battleTopicTextIds = BATTLE_TEXT_IDS(3), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 63), .battleFrontierRecordStreakTextIndex = 3, - .sameRouteMatchCallTextId = TEXT_ID(1, 3), - .differentRouteMatchCallTextId = TEXT_ID(2, 3), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 3), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 3), }, { .trainerId = TRAINER_EDWIN_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 7), TEXT_ID(2, 7), TEXT_ID(3, 7) }, - .generalTextId = TEXT_ID(1, 50), + .battleTopicTextIds = BATTLE_TEXT_IDS(7), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 50), .battleFrontierRecordStreakTextIndex = 7, - .sameRouteMatchCallTextId = TEXT_ID(1, 7), - .differentRouteMatchCallTextId = TEXT_ID(2, 7), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 7), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 7), }, { .trainerId = TRAINER_LYDIA_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 8), TEXT_ID(2, 8), TEXT_ID(3, 8) }, - .generalTextId = TEXT_ID(1, 52), + .battleTopicTextIds = BATTLE_TEXT_IDS(8), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 52), .battleFrontierRecordStreakTextIndex = 8, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 8), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 8), }, { .trainerId = TRAINER_ISAAC_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 5), TEXT_ID(2, 5), TEXT_ID(3, 5) }, - .generalTextId = TEXT_ID(1, 51), + .battleTopicTextIds = BATTLE_TEXT_IDS(5), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 51), .battleFrontierRecordStreakTextIndex = 5, - .sameRouteMatchCallTextId = TEXT_ID(1, 5), - .differentRouteMatchCallTextId = TEXT_ID(2, 5), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 5), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 5), }, { .trainerId = TRAINER_GABRIELLE_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 8), TEXT_ID(2, 8), TEXT_ID(3, 8) }, - .generalTextId = TEXT_ID(1, 2), + .battleTopicTextIds = BATTLE_TEXT_IDS(8), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 2), .battleFrontierRecordStreakTextIndex = 8, - .sameRouteMatchCallTextId = TEXT_ID(1, 8), - .differentRouteMatchCallTextId = TEXT_ID(2, 8), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 8), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 8), }, { .trainerId = TRAINER_CATHERINE_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 54), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 54), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, { .trainerId = TRAINER_JACKSON_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 5), TEXT_ID(2, 5), TEXT_ID(3, 5) }, - .generalTextId = TEXT_ID(1, 53), + .battleTopicTextIds = BATTLE_TEXT_IDS(5), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 53), .battleFrontierRecordStreakTextIndex = 5, - .sameRouteMatchCallTextId = TEXT_ID(1, 5), - .differentRouteMatchCallTextId = TEXT_ID(2, 5), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 5), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 5), }, { .trainerId = TRAINER_HALEY_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 2), TEXT_ID(2, 2), TEXT_ID(3, 2) }, - .generalTextId = TEXT_ID(1, 55), + .battleTopicTextIds = BATTLE_TEXT_IDS(2), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 55), .battleFrontierRecordStreakTextIndex = 2, - .sameRouteMatchCallTextId = TEXT_ID(1, 2), - .differentRouteMatchCallTextId = TEXT_ID(2, 2), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 2), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 2), }, { .trainerId = TRAINER_JAMES_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 1), TEXT_ID(2, 1), TEXT_ID(3, 1) }, - .generalTextId = TEXT_ID(1, 56), + .battleTopicTextIds = BATTLE_TEXT_IDS(1), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 56), .battleFrontierRecordStreakTextIndex = 1, - .sameRouteMatchCallTextId = TEXT_ID(1, 1), - .differentRouteMatchCallTextId = TEXT_ID(2, 1), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 1), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 1), }, { .trainerId = TRAINER_TRENT_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 3), TEXT_ID(2, 3), TEXT_ID(3, 3) }, - .generalTextId = TEXT_ID(1, 57), + .battleTopicTextIds = BATTLE_TEXT_IDS(3), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 57), .battleFrontierRecordStreakTextIndex = 3, - .sameRouteMatchCallTextId = TEXT_ID(1, 3), - .differentRouteMatchCallTextId = TEXT_ID(2, 3), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 3), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 3), }, { .trainerId = TRAINER_SAWYER_1, .unused = 0, - .battleTopicTextIds = { TEXT_ID(1, 15), TEXT_ID(2, 3), TEXT_ID(3, 3) }, - .generalTextId = TEXT_ID(1, 1), + // Thalia and Sawyer are the only ones who use different msg ids for their battle topics + .battleTopicTextIds = { TEXT_ID(B_TOPIC_WILD, 15), TEXT_ID(B_TOPIC_NEGATIVE, 3), TEXT_ID(B_TOPIC_POSITIVE, 3) }, + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 1), .battleFrontierRecordStreakTextIndex = 3, - .sameRouteMatchCallTextId = TEXT_ID(1, 3), - .differentRouteMatchCallTextId = TEXT_ID(2, 3), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 3), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 3), }, { .trainerId = TRAINER_KIRA_AND_DAN_1, .unused = 1, - .battleTopicTextIds = { TEXT_ID(1, 9), TEXT_ID(2, 9), TEXT_ID(3, 9) }, - .generalTextId = TEXT_ID(1, 58), + .battleTopicTextIds = BATTLE_TEXT_IDS(9), + .generalTextId = TEXT_ID(GEN_TOPIC_PERSONAL, 58), .battleFrontierRecordStreakTextIndex = 9, - .sameRouteMatchCallTextId = TEXT_ID(1, 9), - .differentRouteMatchCallTextId = TEXT_ID(2, 9), + .sameRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_SAME_ROUTE, 9), + .differentRouteMatchCallTextId = TEXT_ID(REQ_TOPIC_DIFF_ROUTE, 9), }, }; static const struct MatchCallText sMatchCallWildBattleTexts[] = { - { .text = MatchCall_WildBattleText1, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText2, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText3, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText4, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText5, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText6, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText7, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText8, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText9, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText10, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText11, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText12, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText13, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText14, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_WildBattleText15, .stringVarFuncIds = { 0, 2, -1 } }, + { .text = MatchCall_WildBattleText1, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText2, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText3, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText4, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText5, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText6, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText7, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText8, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText9, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText10, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText11, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText12, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText13, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText14, .stringVarFuncIds = STRS_WILD_BATTLE }, + { .text = MatchCall_WildBattleText15, .stringVarFuncIds = STRS_WILD_BATTLE }, }; - static const struct MatchCallText sMatchCallNegativeBattleTexts[] = - { - { .text = MatchCall_NegativeBattleText1, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText2, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText3, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText4, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText5, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText6, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText7, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText8, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText9, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText10, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText11, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText12, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText13, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_NegativeBattleText14, .stringVarFuncIds = { 0, -1, -1 } }, +static const struct MatchCallText sMatchCallNegativeBattleTexts[] = +{ + { .text = MatchCall_NegativeBattleText1, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText2, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText3, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText4, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText5, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText6, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText7, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText8, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText9, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText10, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText11, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText12, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText13, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, + { .text = MatchCall_NegativeBattleText14, .stringVarFuncIds = STRS_BATTLE_NEGATIVE }, }; static const struct MatchCallText sMatchCallPositiveBattleTexts[] = { - { .text = MatchCall_PositiveBattleText1, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText2, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText3, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText4, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText5, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText6, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText7, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText8, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText9, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText10, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText11, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText12, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText13, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PositiveBattleText14, .stringVarFuncIds = { 0, 3, -1 } }, + { .text = MatchCall_PositiveBattleText1, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText2, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText3, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText4, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText5, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText6, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText7, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText8, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText9, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText10, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText11, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText12, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText13, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, + { .text = MatchCall_PositiveBattleText14, .stringVarFuncIds = STRS_BATTLE_POSITIVE }, }; static const struct MatchCallText sMatchCallSameRouteBattleRequestTexts[] = { - { .text = MatchCall_SameRouteBattleRequestText1, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText2, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText3, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText4, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText5, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText6, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText7, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText8, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText9, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText10, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText11, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText12, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText13, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_SameRouteBattleRequestText14, .stringVarFuncIds = { 0, 1, -1 } }, + { .text = MatchCall_SameRouteBattleRequestText1, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText2, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText3, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText4, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText5, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText6, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText7, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText8, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText9, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText10, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText11, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText12, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText13, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_SameRouteBattleRequestText14, .stringVarFuncIds = STRS_BATTLE_REQUEST }, }; static const struct MatchCallText sMatchCallDifferentRouteBattleRequestTexts[] = { - { .text = MatchCall_DifferentRouteBattleRequestText1, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText2, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText3, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText4, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText5, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText6, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText7, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText8, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText9, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText10, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText11, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText12, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText13, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_DifferentRouteBattleRequestText14, .stringVarFuncIds = { 0, 1, -1 } }, + { .text = MatchCall_DifferentRouteBattleRequestText1, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText2, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText3, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText4, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText5, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText6, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText7, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText8, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText9, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText10, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText11, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText12, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText13, .stringVarFuncIds = STRS_BATTLE_REQUEST }, + { .text = MatchCall_DifferentRouteBattleRequestText14, .stringVarFuncIds = STRS_BATTLE_REQUEST }, }; static const struct MatchCallText sMatchCallPersonalizedTexts[] = { - { .text = MatchCall_PersonalizedText1, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_PersonalizedText2, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText3, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText4, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText5, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText6, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText7, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText8, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText9, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText10, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText11, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText12, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText13, .stringVarFuncIds = { 0, 2, -1 } }, - { .text = MatchCall_PersonalizedText14, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText15, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText16, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText17, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText18, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PersonalizedText19, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText20, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText21, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText22, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText23, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText24, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText25, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText26, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText27, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText28, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PersonalizedText29, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PersonalizedText30, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText31, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText32, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText33, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText34, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText35, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText36, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText37, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText38, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText39, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText40, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText41, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText42, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PersonalizedText43, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText44, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PersonalizedText45, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText46, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText47, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText48, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText49, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText50, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText51, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_PersonalizedText52, .stringVarFuncIds = { 0, 3, -1 } }, - { .text = MatchCall_PersonalizedText53, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText54, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText55, .stringVarFuncIds = { 0, 1, -1 } }, - { .text = MatchCall_PersonalizedText56, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText57, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText58, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText59, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText60, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText61, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText62, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText63, .stringVarFuncIds = { 0, -1, -1 } }, - { .text = MatchCall_PersonalizedText64, .stringVarFuncIds = { 0, -1, -1 } }, + { .text = MatchCall_PersonalizedText1, .stringVarFuncIds = { STR_TRAINER_NAME, STR_MAP_NAME, STR_NONE } }, + { .text = MatchCall_PersonalizedText2, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText3, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText4, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText5, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText6, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText7, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText8, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText9, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText10, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText11, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText12, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText13, .stringVarFuncIds = { STR_TRAINER_NAME, STR_SPECIES_IN_ROUTE, STR_NONE } }, + { .text = MatchCall_PersonalizedText14, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText15, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText16, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText17, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText18, .stringVarFuncIds = { STR_TRAINER_NAME, STR_SPECIES_IN_PARTY, STR_NONE } }, + { .text = MatchCall_PersonalizedText19, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText20, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText21, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText22, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText23, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText24, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText25, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText26, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText27, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText28, .stringVarFuncIds = { STR_TRAINER_NAME, STR_SPECIES_IN_PARTY, STR_NONE } }, + { .text = MatchCall_PersonalizedText29, .stringVarFuncIds = { STR_TRAINER_NAME, STR_SPECIES_IN_PARTY, STR_NONE } }, + { .text = MatchCall_PersonalizedText30, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText31, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText32, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText33, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText34, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText35, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText36, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText37, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText38, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText39, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText40, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText41, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText42, .stringVarFuncIds = { STR_TRAINER_NAME, STR_SPECIES_IN_PARTY, STR_NONE } }, + { .text = MatchCall_PersonalizedText43, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText44, .stringVarFuncIds = { STR_TRAINER_NAME, STR_SPECIES_IN_PARTY, STR_NONE } }, + { .text = MatchCall_PersonalizedText45, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText46, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText47, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText48, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText49, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText50, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText51, .stringVarFuncIds = { STR_TRAINER_NAME, STR_MAP_NAME, STR_NONE } }, + { .text = MatchCall_PersonalizedText52, .stringVarFuncIds = { STR_TRAINER_NAME, STR_SPECIES_IN_PARTY, STR_NONE } }, + { .text = MatchCall_PersonalizedText53, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText54, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText55, .stringVarFuncIds = { STR_TRAINER_NAME, STR_MAP_NAME, STR_NONE } }, + { .text = MatchCall_PersonalizedText56, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText57, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText58, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText59, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText60, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText61, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText62, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText63, .stringVarFuncIds = STRS_NORMAL_MSG }, + { .text = MatchCall_PersonalizedText64, .stringVarFuncIds = STRS_NORMAL_MSG }, }; static const struct MatchCallText sMatchCallBattleFrontierStreakTexts[] = { - { .text = MatchCall_BattleFrontierStreakText1, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText2, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText3, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText4, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText5, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText6, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText7, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText8, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText9, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText10, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText11, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText12, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText13, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierStreakText14, .stringVarFuncIds = { 0, 4, 5 } }, + { .text = MatchCall_BattleFrontierStreakText1, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText2, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText3, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText4, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText5, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText6, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText7, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText8, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText9, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText10, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText11, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText12, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText13, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierStreakText14, .stringVarFuncIds = STRS_FRONTIER }, }; static const struct MatchCallText sMatchCallBattleFrontierRecordStreakTexts[] = { - { .text = MatchCall_BattleFrontierRecordStreakText1, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText2, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText3, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText4, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText5, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText6, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText7, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText8, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText9, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText10, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText11, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText12, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText13, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleFrontierRecordStreakText14, .stringVarFuncIds = { 0, 4, 5 } }, + { .text = MatchCall_BattleFrontierRecordStreakText1, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText2, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText3, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText4, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText5, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText6, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText7, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText8, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText9, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText10, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText11, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText12, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText13, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleFrontierRecordStreakText14, .stringVarFuncIds = STRS_FRONTIER }, }; static const struct MatchCallText sMatchCallBattleDomeTexts[] = { - { .text = MatchCall_BattleDomeText1, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText2, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText3, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText4, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText5, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText6, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText7, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText8, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText9, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText10, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText11, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText12, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText13, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattleDomeText14, .stringVarFuncIds = { 0, 4, 5 } }, + { .text = MatchCall_BattleDomeText1, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText2, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText3, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText4, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText5, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText6, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText7, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText8, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText9, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText10, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText11, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText12, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText13, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattleDomeText14, .stringVarFuncIds = STRS_FRONTIER }, }; static const struct MatchCallText sMatchCallBattlePikeTexts[] = { - { .text = MatchCall_BattlePikeText1, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText2, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText3, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText4, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText5, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText6, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText7, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText8, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText9, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText10, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText11, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText12, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText13, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePikeText14, .stringVarFuncIds = { 0, 4, 5 } }, + { .text = MatchCall_BattlePikeText1, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText2, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText3, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText4, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText5, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText6, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText7, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText8, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText9, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText10, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText11, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText12, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText13, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePikeText14, .stringVarFuncIds = STRS_FRONTIER }, }; static const struct MatchCallText sMatchCallBattlePyramidTexts[] = { - { .text = MatchCall_BattlePyramidText1, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText2, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText3, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText4, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText5, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText6, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText7, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText8, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText9, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText10, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText11, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText12, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText13, .stringVarFuncIds = { 0, 4, 5 } }, - { .text = MatchCall_BattlePyramidText14, .stringVarFuncIds = { 0, 4, 5 } }, + { .text = MatchCall_BattlePyramidText1, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText2, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText3, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText4, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText5, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText6, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText7, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText8, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText9, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText10, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText11, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText12, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText13, .stringVarFuncIds = STRS_FRONTIER }, + { .text = MatchCall_BattlePyramidText14, .stringVarFuncIds = STRS_FRONTIER }, }; static const struct MatchCallText *const sMatchCallBattleTopics[] = { - sMatchCallWildBattleTexts, - sMatchCallNegativeBattleTexts, - sMatchCallPositiveBattleTexts, + [B_TOPIC_WILD - 1] = sMatchCallWildBattleTexts, + [B_TOPIC_NEGATIVE - 1] = sMatchCallNegativeBattleTexts, + [B_TOPIC_POSITIVE - 1] = sMatchCallPositiveBattleTexts, }; static const struct MatchCallText *const sMatchCallBattleRequestTopics[] = { - sMatchCallSameRouteBattleRequestTexts, - sMatchCallDifferentRouteBattleRequestTexts, + [REQ_TOPIC_SAME_ROUTE - 1] = sMatchCallSameRouteBattleRequestTexts, + [REQ_TOPIC_DIFF_ROUTE - 1] = sMatchCallDifferentRouteBattleRequestTexts, }; static const struct MatchCallText *const sMatchCallGeneralTopics[] = { - sMatchCallPersonalizedTexts, - sMatchCallBattleFrontierStreakTexts, - sMatchCallBattleFrontierRecordStreakTexts, - sMatchCallBattleDomeTexts, - sMatchCallBattlePikeTexts, - sMatchCallBattlePyramidTexts, + [GEN_TOPIC_PERSONAL - 1] = sMatchCallPersonalizedTexts, + [GEN_TOPIC_STREAK - 1] = sMatchCallBattleFrontierStreakTexts, + [GEN_TOPIC_STREAK_RECORD - 1] = sMatchCallBattleFrontierRecordStreakTexts, + [GEN_TOPIC_B_DOME - 1] = sMatchCallBattleDomeTexts, + [GEN_TOPIC_B_PIKE - 1] = sMatchCallBattlePikeTexts, + [GEN_TOPIC_B_PYRAMID - 1] = sMatchCallBattlePyramidTexts, }; extern const u8 gBirchDexRatingText_AreYouCurious[]; @@ -971,8 +1023,8 @@ extern const u8 gBirchDexRatingText_OnANationwideBasis[]; void InitMatchCallCounters(void) { RtcCalcLocalTime(); - gMatchCallState.minutes = GetCurrentTotalMinutes(&gLocalTime) + 10; - gMatchCallState.stepCounter = 0; + sMatchCallState.minutes = GetCurrentTotalMinutes(&gLocalTime) + 10; + sMatchCallState.stepCounter = 0; } static u32 GetCurrentTotalMinutes(struct Time *time) @@ -985,9 +1037,9 @@ static bool32 UpdateMatchCallMinutesCounter(void) int curMinutes; RtcCalcLocalTime(); curMinutes = GetCurrentTotalMinutes(&gLocalTime); - if (gMatchCallState.minutes > curMinutes || curMinutes - gMatchCallState.minutes > 9) + if (sMatchCallState.minutes > curMinutes || curMinutes - sMatchCallState.minutes > 9) { - gMatchCallState.minutes = curMinutes; + sMatchCallState.minutes = curMinutes; return TRUE; } @@ -1026,9 +1078,9 @@ static bool32 MapAllowsMatchCall(void) static bool32 UpdateMatchCallStepCounter(void) { - if (++gMatchCallState.stepCounter >= 10) + if (++sMatchCallState.stepCounter >= 10) { - gMatchCallState.stepCounter = 0; + sMatchCallState.stepCounter = 0; return TRUE; } else @@ -1044,12 +1096,12 @@ static bool32 SelectMatchCallTrainer(void) if (numRegistered == 0) return FALSE; - gMatchCallState.trainerId = GetActiveMatchCallTrainerId(Random() % numRegistered); - gMatchCallState.triggeredFromScript = FALSE; - if (gMatchCallState.trainerId == REMATCH_TABLE_ENTRIES) + sMatchCallState.trainerId = GetActiveMatchCallTrainerId(Random() % numRegistered); + sMatchCallState.triggeredFromScript = FALSE; + if (sMatchCallState.trainerId == REMATCH_TABLE_ENTRIES) return FALSE; - matchCallId = GetTrainerMatchCallId(gMatchCallState.trainerId); + matchCallId = GetTrainerMatchCallId(sMatchCallState.trainerId); if (GetRematchTrainerLocation(matchCallId) == gMapHeader.regionMapSectionId && !TrainerIsEligibleForRematch(matchCallId)) return FALSE; @@ -1112,7 +1164,7 @@ bool32 TryStartMatchCall(void) void StartMatchCallFromScript(const u8 *message) { - gMatchCallState.triggeredFromScript = TRUE; + sMatchCallState.triggeredFromScript = TRUE; StartMatchCall(); } @@ -1123,7 +1175,7 @@ bool32 IsMatchCallTaskActive(void) static void StartMatchCall(void) { - if (!gMatchCallState.triggeredFromScript) + if (!sMatchCallState.triggeredFromScript) { ScriptContext2_Enable(); FreezeObjectEvents(); @@ -1262,8 +1314,8 @@ static bool32 MatchCall_PrintIntro(u8 taskId) FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); // Ready the message - if (!gMatchCallState.triggeredFromScript) - SelectMatchCallMessage(gMatchCallState.trainerId, gStringVar4); + if (!sMatchCallState.triggeredFromScript) + SelectMatchCallMessage(sMatchCallState.trainerId, gStringVar4); InitMatchCallTextPrinter(tWindowId, gStringVar4); return TRUE; } @@ -1306,7 +1358,7 @@ static bool32 MatchCall_EndCall(u8 taskId) if (!IsDma3ManagerBusyWithBgCopy() && !IsSEPlaying()) { ChangeBgY(0, 0, 0); - if (!gMatchCallState.triggeredFromScript) + if (!sMatchCallState.triggeredFromScript) { LoadMessageBoxAndBorderGfx(); playerObjectId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0); @@ -1450,7 +1502,7 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str) bool32 retVal = FALSE; matchCallId = GetTrainerMatchCallId(trainerId); - gBattleFrontierStreakInfo.facilityId = 0; + sBattleFrontierStreakInfo.facilityId = 0; // If the player is on the same route as the trainer // and they can be rematched, they will always request a battle @@ -1550,8 +1602,8 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 * count = Random() % count; for (i = 0; i < NUM_FRONTIER_FACILITIES; i++) { - gBattleFrontierStreakInfo.streak = GetFrontierStreakInfo(i, &topic); - if (gBattleFrontierStreakInfo.streak < 2) + sBattleFrontierStreakInfo.streak = GetFrontierStreakInfo(i, &topic); + if (sBattleFrontierStreakInfo.streak < 2) continue; if (!count) @@ -1560,7 +1612,7 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 * count--; } - gBattleFrontierStreakInfo.facilityId = i; + sBattleFrontierStreakInfo.facilityId = i; id = sMatchCallTrainers[matchCallId].battleFrontierRecordStreakTextIndex - 1; return &sMatchCallGeneralTopics[topic][id]; } @@ -1582,7 +1634,7 @@ static u8 *const sMatchCallTextStringVars[] = { gStringVar1, gStringVar2, gStrin static void PopulateMatchCallStringVars(int matchCallId, const s8 *stringVarFuncIds) { int i; - for (i = 0; i < 3; i++) + for (i = 0; i < NUM_STRVARS_IN_MSG; i++) { if (stringVarFuncIds[i] >= 0) PopulateMatchCallStringVar(matchCallId, stringVarFuncIds[i], sMatchCallTextStringVars[i]); @@ -1591,12 +1643,12 @@ static void PopulateMatchCallStringVars(int matchCallId, const s8 *stringVarFunc static void (*const sPopulateMatchCallStringVarFuncs[])(int, u8 *) = { - PopulateTrainerName, - PopulateMapName, - PopulateSpeciesFromTrainerLocation, - PopulateSpeciesFromTrainerParty, - PopulateBattleFrontierFacilityName, - PopulateBattleFrontierStreak, + [STR_TRAINER_NAME] = PopulateTrainerName, + [STR_MAP_NAME] = PopulateMapName, + [STR_SPECIES_IN_ROUTE] = PopulateSpeciesFromTrainerLocation, + [STR_SPECIES_IN_PARTY] = PopulateSpeciesFromTrainerParty, + [STR_FACILITY_NAME] = PopulateBattleFrontierFacilityName, + [STR_FRONTIER_STREAK] = PopulateBattleFrontierStreak, }; static void PopulateMatchCallStringVar(int matchCallId, int funcId, u8 *destStr) @@ -1769,20 +1821,20 @@ static const u8 *const sBattleFrontierFacilityNames[] = static void PopulateBattleFrontierFacilityName(int matchCallId, u8 *destStr) { - StringCopy(destStr, sBattleFrontierFacilityNames[gBattleFrontierStreakInfo.facilityId]); + StringCopy(destStr, sBattleFrontierFacilityNames[sBattleFrontierStreakInfo.facilityId]); } static void PopulateBattleFrontierStreak(int matchCallId, u8 *destStr) { int i = 0; - int streak = gBattleFrontierStreakInfo.streak; + int streak = sBattleFrontierStreakInfo.streak; while (streak != 0) { streak /= 10; i++; } - ConvertIntToDecimalStringN(destStr, gBattleFrontierStreakInfo.streak, STR_CONV_MODE_LEFT_ALIGN, i); + ConvertIntToDecimalStringN(destStr, sBattleFrontierStreakInfo.streak, STR_CONV_MODE_LEFT_ALIGN, i); } static const u16 sBadgeFlags[NUM_BADGES] = @@ -1856,7 +1908,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) streak = gSaveBlock2Ptr->frontier.domeRecordWinStreaks[i][j]; } } - *topicTextId = 3; + *topicTextId = GEN_TOPIC_B_DOME - 1; break; #ifdef BUGFIX case FRONTIER_FACILITY_PIKE: @@ -1868,7 +1920,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) if (streak < gSaveBlock2Ptr->frontier.pikeRecordStreaks[i]) streak = gSaveBlock2Ptr->frontier.pikeRecordStreaks[i]; } - *topicTextId = 4; + *topicTextId = GEN_TOPIC_B_PIKE - 1; break; case FRONTIER_FACILITY_TOWER: for (i = 0; i < 4; i++) @@ -1879,7 +1931,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) streak = gSaveBlock2Ptr->frontier.towerRecordWinStreaks[i][j]; } } - *topicTextId = 2; + *topicTextId = GEN_TOPIC_STREAK_RECORD - 1; break; case FRONTIER_FACILITY_PALACE: for (i = 0; i < 2; i++) @@ -1890,7 +1942,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) streak = gSaveBlock2Ptr->frontier.palaceRecordWinStreaks[i][j]; } } - *topicTextId = 2; + *topicTextId = GEN_TOPIC_STREAK_RECORD - 1; break; #ifdef BUGFIX case FRONTIER_FACILITY_FACTORY: @@ -1905,7 +1957,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) streak = gSaveBlock2Ptr->frontier.factoryRecordWinStreaks[i][j]; } } - *topicTextId = 2; + *topicTextId = GEN_TOPIC_STREAK_RECORD - 1; break; case FRONTIER_FACILITY_ARENA: for (i = 0; i < 2; i++) @@ -1913,7 +1965,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) if (streak < gSaveBlock2Ptr->frontier.arenaRecordStreaks[i]) streak = gSaveBlock2Ptr->frontier.arenaRecordStreaks[i]; } - *topicTextId = 2; + *topicTextId = GEN_TOPIC_STREAK_RECORD - 1; break; case FRONTIER_FACILITY_PYRAMID: for (i = 0; i < 2; i++) @@ -1921,7 +1973,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) if (streak < gSaveBlock2Ptr->frontier.pyramidRecordStreaks[i]) streak = gSaveBlock2Ptr->frontier.pyramidRecordStreaks[i]; } - *topicTextId = 5; + *topicTextId = GEN_TOPIC_B_PYRAMID - 1; break; } From 691c680908312c883362d0bbc2aad30e986b665a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 1 Apr 2021 14:32:23 -0400 Subject: [PATCH 30/31] Delete unreferenced palette --- graphics/easy_chat/interview.pal | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 graphics/easy_chat/interview.pal diff --git a/graphics/easy_chat/interview.pal b/graphics/easy_chat/interview.pal deleted file mode 100644 index dfe91b5deb..0000000000 --- a/graphics/easy_chat/interview.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -255 255 148 -255 197 148 -238 139 90 -189 90 41 -255 213 213 -246 180 180 -197 131 131 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -41 49 49 -98 98 98 -180 189 180 -222 213 222 -255 255 255 From 1b8d405b5e39de986954f8c3c7c3e15ea4a4967c Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 2 Apr 2021 12:54:40 -0400 Subject: [PATCH 31/31] Add missing include guard suffixes --- berry_fix/payload/include/gba/defines.h | 6 +++--- include/battle_gfx_sfx_util.h | 6 +++--- include/constants/metatile_behaviors.h | 6 +++--- include/gba/defines.h | 6 +++--- include/item_menu_icons.h | 6 +++--- include/metatile_behavior.h | 6 +++--- include/script_pokemon_util.h | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/berry_fix/payload/include/gba/defines.h b/berry_fix/payload/include/gba/defines.h index 289518cf37..4037af5846 100644 --- a/berry_fix/payload/include/gba/defines.h +++ b/berry_fix/payload/include/gba/defines.h @@ -1,5 +1,5 @@ -#ifndef GUARD_GBA_DEFINES -#define GUARD_GBA_DEFINES +#ifndef GUARD_GBA_DEFINES_H +#define GUARD_GBA_DEFINES_H #include @@ -84,4 +84,4 @@ #define RGB_CYAN RGB(0, 31, 31) #define RGB_WHITEALPHA (RGB_WHITE | 0x8000) -#endif // GUARD_GBA_DEFINES +#endif // GUARD_GBA_DEFINES_H diff --git a/include/battle_gfx_sfx_util.h b/include/battle_gfx_sfx_util.h index e3f549aa90..3288204d12 100644 --- a/include/battle_gfx_sfx_util.h +++ b/include/battle_gfx_sfx_util.h @@ -1,5 +1,5 @@ -#ifndef GUARD_BATTLE_GFX_SFX_UTIL -#define GUARD_BATTLE_GFX_SFX_UTIL +#ifndef GUARD_BATTLE_GFX_SFX_UTIL_H +#define GUARD_BATTLE_GFX_SFX_UTIL_H void AllocateBattleSpritesData(void); void FreeBattleSpritesData(void); @@ -45,4 +45,4 @@ void AllocateMonSpritesGfx(void); void FreeMonSpritesGfx(void); bool32 ShouldPlayNormalMonCry(struct Pokemon *mon); -#endif // GUARD_BATTLE_GFX_SFX_UTIL +#endif // GUARD_BATTLE_GFX_SFX_UTIL_H diff --git a/include/constants/metatile_behaviors.h b/include/constants/metatile_behaviors.h index 94cb0ffcaa..cc069c66cd 100755 --- a/include/constants/metatile_behaviors.h +++ b/include/constants/metatile_behaviors.h @@ -1,5 +1,5 @@ -#ifndef GUARD_METATILE_BEHAVIORS -#define GUARD_METATILE_BEHAVIORS +#ifndef GUARD_METATILE_BEHAVIORS_H +#define GUARD_METATILE_BEHAVIORS_H #define MB_NORMAL 0x00 #define MB_SECRET_BASE_WALL 0x01 @@ -242,4 +242,4 @@ #define MB_UNUSED_EE 0xEE #define MB_UNUSED_EF 0xEF -#endif // GUARD_METATILE_BEHAVIORS +#endif // GUARD_METATILE_BEHAVIORS_H diff --git a/include/gba/defines.h b/include/gba/defines.h index 78c6885939..ad06aaad2d 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -1,5 +1,5 @@ -#ifndef GUARD_GBA_DEFINES -#define GUARD_GBA_DEFINES +#ifndef GUARD_GBA_DEFINES_H +#define GUARD_GBA_DEFINES_H #include @@ -76,4 +76,4 @@ #define TOTAL_OBJ_TILE_COUNT 1024 -#endif // GUARD_GBA_DEFINES +#endif // GUARD_GBA_DEFINES_H diff --git a/include/item_menu_icons.h b/include/item_menu_icons.h index e061149fc5..7ff6ace94b 100644 --- a/include/item_menu_icons.h +++ b/include/item_menu_icons.h @@ -1,5 +1,5 @@ -#ifndef GUARD_ITEM_MENU_ICONS -#define GUARD_ITEM_MENU_ICONS +#ifndef GUARD_ITEM_MENU_ICONS_H +#define GUARD_ITEM_MENU_ICONS_H extern const struct CompressedSpriteSheet gBagMaleSpriteSheet; extern const struct CompressedSpriteSheet gBagFemaleSpriteSheet; @@ -28,4 +28,4 @@ u8 CreateBerryFlavorCircleSprite(s16 x); #define TAG_BERRY_PIC_TILE 0xFFFF #define TAG_BERRY_PIC_PAL 0x7544 -#endif // GUARD_ITEM_MENU_ICONS +#endif // GUARD_ITEM_MENU_ICONS_H diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index d4bd9e6832..584b3e546e 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -1,5 +1,5 @@ -#ifndef GUARD_METATILE_BEHAVIOR -#define GUARD_METATILE_BEHAVIOR +#ifndef GUARD_METATILE_BEHAVIOR_H +#define GUARD_METATILE_BEHAVIOR_H bool8 MetatileBehavior_IsATile(u8); bool8 MetatileBehavior_IsEncounterTile(u8); @@ -146,4 +146,4 @@ bool8 MetatileBehavior_IsLongGrass_Duplicate(u8); bool8 MetatileBehavior_IsLongGrassSouthEdge(u8); bool8 MetatileBehavior_IsTrainerHillTimer(u8); -#endif // GUARD_METATILE_BEHAVIOR +#endif // GUARD_METATILE_BEHAVIOR_H diff --git a/include/script_pokemon_util.h b/include/script_pokemon_util.h index 120c28a637..cae16e40a6 100644 --- a/include/script_pokemon_util.h +++ b/include/script_pokemon_util.h @@ -1,5 +1,5 @@ -#ifndef GUARD_SCRIPT_POKEMON_UTIL -#define GUARD_SCRIPT_POKEMON_UTIL +#ifndef GUARD_SCRIPT_POKEMON_UTIL_H +#define GUARD_SCRIPT_POKEMON_UTIL_H u8 ScriptGiveMon(u16, u8, u16, u32, u32, u8); u8 ScriptGiveEgg(u16); @@ -8,4 +8,4 @@ void ScriptSetMonMoveSlot(u8, u16, u8); void ReducePlayerPartyToSelectedMons(void); void HealPlayerParty(void); -#endif // GUARD_SCRIPT_POKEMON_UTIL +#endif // GUARD_SCRIPT_POKEMON_UTIL_H