diff options
Diffstat (limited to 'src/battle_message.c')
-rw-r--r-- | src/battle_message.c | 837 |
1 files changed, 689 insertions, 148 deletions
diff --git a/src/battle_message.c b/src/battle_message.c index 1f338db92..13502d6f2 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -6,6 +6,7 @@ #include "text.h" #include "string_util.h" #include "constants/items.h" +#include "constants/trainers.h" #include "event_data.h" #include "link.h" #include "item.h" @@ -17,11 +18,23 @@ #include "recorded_battle.h" #include "international_string_util.h" -extern u8 gBattlerAbilities[MAX_BATTLERS_COUNT]; +struct BattleWindowText +{ + u8 fillValue; + u8 fontId; + u8 x; + u8 y; + u8 letterSpacing; + u8 lineSpacing; + u8 speed; + u8 fgColor; + u8 bgColor; + u8 shadowColor; +}; + extern u8 gUnknown_0203C7B4; -extern struct StringInfoBattle *gStringInfo; -extern const u8 gMoveNames[LAST_MOVE_INDEX + 1][13]; +extern const u8 gMoveNames[MOVES_COUNT][13]; extern const u8 gTrainerClassNames[][13]; extern const u16 gUnknown_08D85620[]; @@ -31,12 +44,11 @@ extern const u8 gText_PkmnBoxLanettesPCFull[]; extern const u8 gText_PkmnTransferredSomeonesPC[]; extern const u8 gText_PkmnTransferredLanettesPC[]; -extern u16 sub_8068BB0(void); // pokemon_1 -extern u8 sub_81A4D00(void); // battle_frontier_2 +extern u8 GetFrontierBrainTrainerClass(void); // battle_frontier_2 extern u8 GetFrontierOpponentClass(u16 trainerId); // battle_tower extern u8 sub_81D5530(u16 trainerId); // pokenav extern u8 GetEreaderTrainerClassId(void); // battle_tower -extern void sub_81A4D50(u8 *txtPtr); // battle_frontier_2 +extern void CopyFrontierBrainTrainerName(u8 *txtPtr); // battle_frontier_2 extern void sub_81D5554(u8 *txtPtr, u16 trainerId); // pokenav extern void GetEreaderTrainerName(u8 *txtPtr); extern void sub_81A36D0(u8 arg0, u16 trainerId); // battle_frontier_2 @@ -44,15 +56,13 @@ extern void sub_81D572C(u8 arg0, u16 trainerId); // pokenav extern void GetFrontierTrainerName(u8 *dst, u16 trainerId); // this file's functions -static void sub_814F8F8(u8 *textPtr); -static void sub_814F950(u8 *dst); +static void ChooseMoveUsedParticle(u8 *textPtr); +static void ChooseTypeOfMoveUsedString(u8 *dst); static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst); -// ewram variables -EWRAM_DATA u8 gDisplayedStringBattle[300] = {0}; -EWRAM_DATA u8 gBattleTextBuff1[TEXT_BUFF_ARRAY_COUNT] = {0}; -EWRAM_DATA u8 gBattleTextBuff2[TEXT_BUFF_ARRAY_COUNT] = {0}; -EWRAM_DATA u8 gBattleTextBuff3[TEXT_BUFF_ARRAY_COUNT] = {0}; +// EWRAM vars +static EWRAM_DATA u8 sBattlerAbilities[MAX_BATTLERS_COUNT] = {0}; +EWRAM_DATA struct BattleMsgData *gBattleMsgDataPtr = NULL; // const rom data // todo: make some of those names less vague: attacker/target vs pkmn, etc. @@ -1187,7 +1197,14 @@ const u8 * const gStatNamesTable2[] = }; const u8 gText_SafariBalls[] = _("{HIGHLIGHT DARK_GREY}SAFARI BALLS"); -const u8 gText_SafariBallLeft[] = _("{HIGHLIGHT DARK_GREY}Left: $" "{HIGHLIGHT DARK_GREY}");const u8 gText_Sleep[] = _( "sleep");const u8 gText_Poison[] = _( "poison");const u8 gText_Burn[] = _( "burn");const u8 gText_Paralysis[] = _( "paralysis");const u8 gText_Ice[] = _( "ice");const u8 gText_Confusion[] = _( "confusion");const u8 gText_Love[] = _( "love"); +const u8 gText_SafariBallLeft[] = _("{HIGHLIGHT DARK_GREY}Left: $" "{HIGHLIGHT DARK_GREY}"); +const u8 gText_Sleep[] = _("sleep"); +const u8 gText_Poison[] = _("poison"); +const u8 gText_Burn[] = _("burn"); +const u8 gText_Paralysis[] = _("paralysis"); +const u8 gText_Ice[] = _("ice"); +const u8 gText_Confusion[] = _("confusion"); +const u8 gText_Love[] = _("love"); const u8 gText_SpaceAndSpace[] = _(" and "); const u8 gText_CommaSpace[] = _(", "); const u8 gText_Space2[] = _(" "); @@ -1308,8 +1325,8 @@ static const u8 sText_LinkTrainerWantsToBattlePause[] = _("{B_20}\nwants to batt static const u8 sText_TwoLinkTrainersWantToBattlePause[] = _("{B_20} and {B_21}\nwant to battle!{PAUSE 49}"); // This is four lists of moves which use a different attack string in Japanese -// to the default. See the documentation for sub_814F950 for more detail. -static const u16 sUnknownMoveTable[] = +// to the default. See the documentation for ChooseTypeOfMoveUsedString for more detail. +static const u16 sGrammarMoveUsedTable[] = { MOVE_SWORDS_DANCE, MOVE_STRENGTH, MOVE_GROWTH, MOVE_HARDEN, MOVE_MINIMIZE, MOVE_SMOKESCREEN, @@ -1351,86 +1368,609 @@ static const u16 sUnknownMoveTable[] = static const u8 sDummyWeirdStatusString[] = {EOS, EOS, EOS, EOS, EOS, EOS, EOS, EOS, 0, 0}; -static const u8 sUnknown_085CD42C[] = -{ - 0xFF, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0xF, 0x6, 0x0, 0x0, 0xFF, 0x1, - 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0xF, 0x6, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, - 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, - 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, - 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, - 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, - 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xC, 0xE, 0xB, 0x0, 0x0, - 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, - 0x1, 0x2, 0x1, 0x0, 0x0, 0x0, 0xC, 0xE, 0xB, 0x0, 0x0, 0xEE, 0x7, 0x0, - 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, - 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, - 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, - 0xE, 0xF, 0x0, 0x0, 0x0, 0x1, 0x20, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x2, - 0x0, 0x0, 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, - 0x0, 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, - 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, - 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, - 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0xFF, - 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0x0, 0x1, 0xFF, 0x1, 0x0, - 0x0, 0x0, 0x1, 0x0, 0x6, 0x0, 0x0, 0x0, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, - 0x6, 0x0, 0x0, 0x0, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x6, 0x0, 0x0 +static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = +{ + { // 0 + .fillValue = 0xFF, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 1, + .fgColor = 1, + .bgColor = 15, + .shadowColor = 6, + }, + { // 1 + .fillValue = 0xFF, + .fontId = 1, + .x = 1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 1, + .bgColor = 15, + .shadowColor = 6, + }, + { // 2 + .fillValue = 0xEE, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 3 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 4 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 5 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 6 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 7 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 12, + .bgColor = 14, + .shadowColor = 11, + }, + { // 8 + .fillValue = 0xEE, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 9 + .fillValue = 0xEE, + .fontId = 1, + .x = 2, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 12, + .bgColor = 14, + .shadowColor = 11, + }, + { // 10 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 11 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 12 + .fillValue = 0xEE, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 13 + .fillValue = 0xEE, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 14 + .fillValue = 0x0, + .fontId = 1, + .x = 32, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 1, + .bgColor = 0, + .shadowColor = 2, + }, + { // 15 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 16 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 17 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 18 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 19 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 20 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 21 + .fillValue = 0x0, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 1, + .bgColor = 0, + .shadowColor = 6, + }, + { // 22 + .fillValue = 0x0, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 1, + .bgColor = 0, + .shadowColor = 6, + }, + { // 23 + .fillValue = 0x0, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 1, + .bgColor = 0, + .shadowColor = 6, + }, }; -static const u8 sUnknown_085CD54C[] = -{ - 0xFF, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0xF, 0x6, 0x0, 0x0, 0xFF, 0x1, - 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0xF, 0x6, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, - 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, - 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, - 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, - 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, - 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, 0x0, 0x0, 0xC, 0xE, 0xB, 0x0, 0x0, - 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, - 0x1, 0x2, 0x1, 0x0, 0x0, 0x0, 0xC, 0xE, 0xB, 0x0, 0x0, 0xEE, 0x7, 0x0, - 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x7, 0x0, 0x1, 0x0, - 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, - 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0xD, - 0xE, 0xF, 0x0, 0x0, 0x0, 0x1, 0x20, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x2, - 0x0, 0x0, 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0x1, 0xE, 0xF, 0x0, - 0x0, 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, - 0xEE, 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, - 0x1, 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, - 0xFF, 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0xFF, - 0x1, 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0xEE, 0x1, 0xFF, 0x1, - 0x0, 0x0, 0x0, 0xD, 0xE, 0xF, 0x0, 0x0, 0x11, 0x1, 0x0, 0x1, 0x0, 0x0, - 0x1, 0x2, 0x1, 0x3, 0x0, 0x0 +static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = +{ + { // 0 + .fillValue = 0xFF, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 1, + .fgColor = 1, + .bgColor = 15, + .shadowColor = 6, + }, + { // 1 + .fillValue = 0xFF, + .fontId = 1, + .x = 1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 1, + .bgColor = 15, + .shadowColor = 6, + }, + { // 2 + .fillValue = 0xEE, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 3 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 4 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 5 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 6 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 7 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 12, + .bgColor = 14, + .shadowColor = 11, + }, + { // 8 + .fillValue = 0xEE, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 9 + .fillValue = 0xEE, + .fontId = 1, + .x = 2, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 12, + .bgColor = 14, + .shadowColor = 11, + }, + { // 10 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 11 + .fillValue = 0xEE, + .fontId = 7, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 12 + .fillValue = 0xEE, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 13 + .fillValue = 0xEE, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 14 + .fillValue = 0x0, + .fontId = 1, + .x = 32, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 1, + .bgColor = 0, + .shadowColor = 2, + }, + { // 15 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 1, + .bgColor = 14, + .shadowColor = 15, + }, + { // 16 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 17 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 18 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 19 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 20 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 21 + .fillValue = 0xEE, + .fontId = 1, + .x = -1, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 0, + .fgColor = 13, + .bgColor = 14, + .shadowColor = 15, + }, + { // 22 + .fillValue = 0x11, + .fontId = 1, + .x = 0, + .y = 1, + .letterSpacing = 0, + .lineSpacing = 0, + .speed = 1, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, }; -static const u8 * const gUnknown_085CD660[] = +static const struct BattleWindowText *const sBattleTextOnWindowsInfo[] = { - sUnknown_085CD42C, sUnknown_085CD54C + sTextOnWindowsInfo_Normal, sTextOnWindowsInfo_Arena }; static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0}; +// code void BufferStringBattle(u16 stringID) { s32 i; - const u8* stringPtr = NULL; + const u8 *stringPtr = NULL; - gStringInfo = (struct StringInfoBattle*)(&gBattleBufferA[gActiveBattler][4]); - gLastUsedItem = gStringInfo->lastItem; - gLastUsedAbility = gStringInfo->lastAbility; - gBattleScripting.battler = gStringInfo->scrActive; - *(&gBattleStruct->field_52) = gStringInfo->unk1605E; - *(&gBattleStruct->hpScale) = gStringInfo->hpScale; - gPotentialItemEffectBattler = gStringInfo->StringBank; - *(&gBattleStruct->stringMoveType) = gStringInfo->moveType; + gBattleMsgDataPtr = (struct BattleMsgData*)(&gBattleBufferA[gActiveBattler][4]); + gLastUsedItem = gBattleMsgDataPtr->lastItem; + gLastUsedAbility = gBattleMsgDataPtr->lastAbility; + gBattleScripting.battler = gBattleMsgDataPtr->scrActive; + *(&gBattleStruct->field_52) = gBattleMsgDataPtr->unk1605E; + *(&gBattleStruct->hpScale) = gBattleMsgDataPtr->hpScale; + gPotentialItemEffectBattler = gBattleMsgDataPtr->itemEffectBattler; + *(&gBattleStruct->stringMoveType) = gBattleMsgDataPtr->moveType; for (i = 0; i < MAX_BATTLERS_COUNT; i++) { - gBattlerAbilities[i] = gStringInfo->abilities[i]; + sBattlerAbilities[i] = gBattleMsgDataPtr->abilities[i]; } for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++) { - gBattleTextBuff1[i] = gStringInfo->textBuffs[0][i]; - gBattleTextBuff2[i] = gStringInfo->textBuffs[1][i]; - gBattleTextBuff3[i] = gStringInfo->textBuffs[2][i]; + gBattleTextBuff1[i] = gBattleMsgDataPtr->textBuffs[0][i]; + gBattleTextBuff2[i] = gBattleMsgDataPtr->textBuffs[1][i]; + gBattleTextBuff3[i] = gBattleMsgDataPtr->textBuffs[2][i]; } switch (stringID) @@ -1542,7 +2082,7 @@ void BufferStringBattle(u16 stringID) } else { - if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_800 || gBattleTypeFlags & BATTLE_TYPE_x2000000) + if (gTrainerBattleOpponent_A == TRAINER_LINK_OPPONENT || gBattleTypeFlags & BATTLE_TYPE_x2000000) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI) stringPtr = sText_LinkTrainer2WithdrewPkmn; @@ -1605,14 +2145,14 @@ void BufferStringBattle(u16 stringID) } break; case STRINGID_USEDMOVE: // pokemon used a move msg - sub_814F8F8(gBattleTextBuff1); // buff1 doesn't appear in the string, leftover from japanese move names? + ChooseMoveUsedParticle(gBattleTextBuff1); // buff1 doesn't appear in the string, leftover from japanese move names - if (gStringInfo->currentMove > LAST_MOVE_INDEX) + if (gBattleMsgDataPtr->currentMove >= MOVES_COUNT) StringCopy(gBattleTextBuff2, sATypeMove_Table[*(&gBattleStruct->stringMoveType)]); else - StringCopy(gBattleTextBuff2, gMoveNames[gStringInfo->currentMove]); + StringCopy(gBattleTextBuff2, gMoveNames[gBattleMsgDataPtr->currentMove]); - sub_814F950(gBattleTextBuff2); + ChooseTypeOfMoveUsedString(gBattleTextBuff2); stringPtr = sText_AttackerUsedX; break; case STRINGID_BATTLEEND: // battle end @@ -1843,25 +2383,25 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) toCpy = text; break; case B_TXT_LINK_PLAYER_MON1_NAME: // link first player poke name - GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18]], + GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].id]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_LINK_OPPONENT_MON1_NAME: // link first opponent poke name - GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 1]], + GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].id ^ 1]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_LINK_PLAYER_MON2_NAME: // link second player poke name - GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 2]], + GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].id ^ 2]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_LINK_OPPONENT_MON2_NAME: // link second opponent poke name - GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 3]], + GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].id ^ 3]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; @@ -1895,16 +2435,16 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, gBattlerPartyIndexes[gBattleScripting.battler]) break; case B_TXT_CURRENT_MOVE: // current move name - if (gStringInfo->currentMove > LAST_MOVE_INDEX) + if (gBattleMsgDataPtr->currentMove >= MOVES_COUNT) toCpy = sATypeMove_Table[gBattleStruct->stringMoveType]; else - toCpy = gMoveNames[gStringInfo->currentMove]; + toCpy = gMoveNames[gBattleMsgDataPtr->currentMove]; break; case B_TXT_LAST_MOVE: // originally used move name - if (gStringInfo->originallyUsedMove > LAST_MOVE_INDEX) + if (gBattleMsgDataPtr->originallyUsedMove >= MOVES_COUNT) toCpy = sATypeMove_Table[gBattleStruct->stringMoveType]; else - toCpy = gMoveNames[gStringInfo->originallyUsedMove]; + toCpy = gMoveNames[gBattleMsgDataPtr->originallyUsedMove]; break; case B_TXT_LAST_ITEM: // last used item if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) @@ -1927,7 +2467,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) } else { - if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gPotentialItemEffectBattler) + if (gLinkPlayers[gBattleScripting.multiplayerId].id == gPotentialItemEffectBattler) { StringCopy(text, gEnigmaBerries[gPotentialItemEffectBattler].name); StringAppend(text, sText_BerrySuffix); @@ -1953,24 +2493,24 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) toCpy = gAbilityNames[gLastUsedAbility]; break; case B_TXT_ATK_ABILITY: // attacker ability - toCpy = gAbilityNames[gBattlerAbilities[gBattlerAttacker]]; + toCpy = gAbilityNames[sBattlerAbilities[gBattlerAttacker]]; break; case B_TXT_DEF_ABILITY: // target ability - toCpy = gAbilityNames[gBattlerAbilities[gBattlerTarget]]; + toCpy = gAbilityNames[sBattlerAbilities[gBattlerTarget]]; break; case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability - toCpy = gAbilityNames[gBattlerAbilities[gBattleScripting.battler]]; + toCpy = gAbilityNames[sBattlerAbilities[gBattleScripting.battler]]; break; case B_TXT_EFF_ABILITY: // effect battlerId ability - toCpy = gAbilityNames[gBattlerAbilities[gEffectBattler]]; + toCpy = gAbilityNames[sBattlerAbilities[gEffectBattler]]; break; case B_TXT_TRAINER1_CLASS: // trainer class name if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE) toCpy = gTrainerClassNames[GetSecretBaseTrainerClass()]; else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00) toCpy = gTrainerClassNames[sub_8068BB0()]; - else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) - toCpy = gTrainerClassNames[sub_81A4D00()]; + else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN) + toCpy = gTrainerClassNames[GetFrontierBrainTrainerClass()]; else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) toCpy = gTrainerClassNames[GetFrontierOpponentClass(gTrainerBattleOpponent_A)]; else if (gBattleTypeFlags & BATTLE_TYPE_x4000000) @@ -1993,9 +2533,9 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) { toCpy = gLinkPlayers[multiplayerID ^ BIT_SIDE].name; } - else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) + else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN) { - sub_81A4D50(text); + CopyFrontierBrainTrainerName(text); toCpy = text; } else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) @@ -2022,13 +2562,13 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) toCpy = gLinkPlayers[multiplayerID].name; break; case B_TXT_1F: // link partner name? - toCpy = gLinkPlayers[GetBattlerMultiplayerId(2 ^ gLinkPlayers[multiplayerID].lp_field_18)].name; + toCpy = gLinkPlayers[GetBattlerMultiplayerId(2 ^ gLinkPlayers[multiplayerID].id)].name; break; case B_TXT_20: // link opponent 1 name? - toCpy = gLinkPlayers[GetBattlerMultiplayerId(1 ^ gLinkPlayers[multiplayerID].lp_field_18)].name; + toCpy = gLinkPlayers[GetBattlerMultiplayerId(1 ^ gLinkPlayers[multiplayerID].id)].name; break; case B_TXT_21: // link opponent 2 name? - toCpy = gLinkPlayers[GetBattlerMultiplayerId(3 ^ gLinkPlayers[multiplayerID].lp_field_18)].name; + toCpy = gLinkPlayers[GetBattlerMultiplayerId(3 ^ gLinkPlayers[multiplayerID].id)].name; break; case B_TXT_22: // link scripting active name toCpy = gLinkPlayers[GetBattlerMultiplayerId(gBattleScripting.battler)].name; @@ -2203,10 +2743,6 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) return dstID; } -// TODO: move these to a general header like util.h -#define ByteRead16(ptr) ((ptr)[0] | ((ptr)[1] << 8)) -#define ByteRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) - static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) { u32 srcID = 1; @@ -2220,7 +2756,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) switch (src[srcID]) { case B_BUFF_STRING: // battle string - hword = ByteRead16(&src[srcID + 1]); + hword = T1_READ_16(&src[srcID + 1]); StringAppend(dst, gBattleStringsTable[hword - BATTLESTRINGS_ID_ADDER]); srcID += 3; break; @@ -2231,17 +2767,17 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) value = src[srcID + 3]; break; case 2: - value = ByteRead16(&src[srcID + 3]); + value = T1_READ_16(&src[srcID + 3]); break; case 4: - value = ByteRead32(&src[srcID + 3]); + value = T1_READ_32(&src[srcID + 3]); break; } ConvertIntToDecimalStringN(dst, value, 0, src[srcID + 2]); srcID += src[srcID + 1] + 3; break; case B_BUFF_MOVE: // move name - StringAppend(dst, gMoveNames[ByteRead16(&src[srcID + 1])]); + StringAppend(dst, gMoveNames[T1_READ_16(&src[srcID + 1])]); srcID += 3; break; case B_BUFF_TYPE: // type name @@ -2271,7 +2807,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) srcID += 2; break; case B_BUFF_SPECIES: // species name - GetSpeciesName(dst, ByteRead16(&src[srcID + 1])); + GetSpeciesName(dst, T1_READ_16(&src[srcID + 1])); srcID += 3; break; case B_BUFF_MON_NICK: // poke nick without prefix @@ -2291,24 +2827,30 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) srcID += 2; break; case B_BUFF_ITEM: // item name - hword = ByteRead16(&src[srcID + 1]); + hword = T1_READ_16(&src[srcID + 1]); if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) { if (hword == ITEM_ENIGMA_BERRY) { - if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gPotentialItemEffectBattler) + if (gLinkPlayers[gBattleScripting.multiplayerId].id == gPotentialItemEffectBattler) { StringCopy(dst, gEnigmaBerries[gPotentialItemEffectBattler].name); StringAppend(dst, sText_BerrySuffix); } else + { StringAppend(dst, sText_EnigmaBerry); + } } else + { CopyItemName(hword, dst); + } } else + { CopyItemName(hword, dst); + } srcID += 3; break; } @@ -2317,18 +2859,18 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) // Loads one of two text strings into the provided buffer. This is functionally // unused, since the value loaded into the buffer is not read; it loaded one of -// two particles (either "は" or "の") which works in tandem with sub_814F950 +// two particles (either "は" or "の") which works in tandem with ChooseTypeOfMoveUsedString // below to effect changes in the meaning of the line. -static void sub_814F8F8(u8* textBuff) +static void ChooseMoveUsedParticle(u8* textBuff) { s32 counter = 0; u32 i = 0; while (counter != 4) { - if (sUnknownMoveTable[i] == 0) + if (sGrammarMoveUsedTable[i] == 0) counter++; - if (sUnknownMoveTable[i++] == gStringInfo->currentMove) + if (sGrammarMoveUsedTable[i++] == gBattleMsgDataPtr->currentMove) break; } @@ -2342,7 +2884,7 @@ static void sub_814F8F8(u8* textBuff) } // Appends "!" to the text buffer `dst`. In the original Japanese this looked -// into the table of moves at sUnknownMoveTable and varied the line accordingly. +// into the table of moves at sGrammarMoveUsedTable and varied the line accordingly. // // sText_ExclamationMark was a plain "!", used for any attack not on the list. // It resulted in the translation "<NAME>'s <ATTACK>!". @@ -2359,7 +2901,7 @@ static void sub_814F8F8(u8* textBuff) // // sText_ExclamationMark5 was " こうげき!" This resulted in a translation of // "<NAME>'s <ATTACK> attack!". -static void sub_814F950(u8* dst) +static void ChooseTypeOfMoveUsedString(u8* dst) { s32 counter = 0; s32 i = 0; @@ -2369,9 +2911,9 @@ static void sub_814F950(u8* dst) while (counter != 4) { - if (sUnknownMoveTable[i] == MOVE_NONE) + if (sGrammarMoveUsedTable[i] == MOVE_NONE) counter++; - if (sUnknownMoveTable[i++] == gStringInfo->currentMove) + if (sGrammarMoveUsedTable[i++] == gBattleMsgDataPtr->currentMove) break; } @@ -2395,47 +2937,46 @@ static void sub_814F950(u8* dst) } } -void BattleHandleAddTextPrinter(const u8 *text, u8 arg1) +void BattlePutTextOnWindow(const u8 *text, u8 windowId) { - const u8 *r8 = gUnknown_085CD660[gBattleScripting.field_24]; - bool32 r9; + const struct BattleWindowText *textInfo = sBattleTextOnWindowsInfo[gBattleScripting.windowsType]; + bool32 copyToVram; struct TextSubPrinter textSubPrinter; u8 speed; - if (arg1 & 0x80) + if (windowId & 0x80) { - arg1 &= ~(0x80); - r9 = FALSE; + windowId &= ~(0x80); + copyToVram = FALSE; } else { - FillWindowPixelBuffer(arg1, r8[12 * arg1]); - r9 = TRUE; + FillWindowPixelBuffer(windowId, textInfo[windowId].fillValue); + copyToVram = TRUE; } textSubPrinter.current_text_offset = text; - textSubPrinter.windowId = arg1; - textSubPrinter.fontId = r8[(12 * arg1) + 1]; - textSubPrinter.x = r8[(12 * arg1) + 2]; - textSubPrinter.y = r8[(12 * arg1) + 3]; + textSubPrinter.windowId = windowId; + textSubPrinter.fontId = textInfo[windowId].fontId; + textSubPrinter.x = textInfo[windowId].x; + textSubPrinter.y = textInfo[windowId].y; textSubPrinter.currentX = textSubPrinter.x; textSubPrinter.currentY = textSubPrinter.y; - textSubPrinter.letterSpacing = r8[(12 * arg1) + 4]; - textSubPrinter.lineSpacing = r8[(12 * arg1) + 5]; + textSubPrinter.letterSpacing = textInfo[windowId].letterSpacing; + textSubPrinter.lineSpacing = textInfo[windowId].lineSpacing; textSubPrinter.fontColor_l = 0; - textSubPrinter.fgColor = r8[(12 * arg1) + 7]; - textSubPrinter.bgColor = r8[(12 * arg1) + 8]; - textSubPrinter.shadowColor = r8[(12 * arg1) + 9]; + textSubPrinter.fgColor = textInfo[windowId].fgColor; + textSubPrinter.bgColor = textInfo[windowId].bgColor; + textSubPrinter.shadowColor = textInfo[windowId].shadowColor; if (textSubPrinter.x == 0xFF) { - s32 var2; - u32 var = sub_80397C4(gBattleScripting.field_24, arg1); - var2 = GetStringCenterAlignXOffsetWithLetterSpacing(textSubPrinter.fontId, textSubPrinter.current_text_offset, var, textSubPrinter.letterSpacing); - textSubPrinter.x = textSubPrinter.currentX = var2; + u32 width = sub_80397C4(gBattleScripting.windowsType, windowId); + s32 alignX = GetStringCenterAlignXOffsetWithLetterSpacing(textSubPrinter.fontId, textSubPrinter.current_text_offset, width, textSubPrinter.letterSpacing); + textSubPrinter.x = textSubPrinter.currentX = alignX; } - if (arg1 == 0x16) + if (windowId == 0x16) gTextFlags.flag_1 = 0; else gTextFlags.flag_1 = 1; @@ -2445,7 +2986,7 @@ void BattleHandleAddTextPrinter(const u8 *text, u8 arg1) else gTextFlags.flag_2 = 0; - if (arg1 == 0 || arg1 == 0x16) + if (windowId == 0 || windowId == 0x16) { if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) speed = 1; @@ -2458,16 +2999,16 @@ void BattleHandleAddTextPrinter(const u8 *text, u8 arg1) } else { - speed = r8[(12 * arg1) + 6]; + speed = textInfo[windowId].speed; gTextFlags.flag_0 = 0; } AddTextPrinter(&textSubPrinter, speed, NULL); - if (r9) + if (copyToVram) { - PutWindowTilemap(arg1); - CopyWindowToVram(arg1, 3); + PutWindowTilemap(windowId); + CopyWindowToVram(windowId, 3); } } |