summaryrefslogtreecommitdiff
path: root/src/battle_script_commands.c
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-10-08 16:50:52 -0400
committerGriffinR <griffin.g.richards@gmail.com>2021-10-09 03:01:10 -0400
commitd8e65fc4b669fb0115615299b1255723e9f8397d (patch)
treebdc93d89ccb0b453a1294f3a24e2e8a82030e256 /src/battle_script_commands.c
parent31b501e7eb6ba15602dd13f6a2d728fca9f04ca5 (diff)
More battle doc, add battle window ids
Diffstat (limited to 'src/battle_script_commands.c')
-rw-r--r--src/battle_script_commands.c264
1 files changed, 136 insertions, 128 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 92f976472..b564fe680 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -53,28 +53,29 @@
#include "data.h"
#include "constants/party_menu.h"
-extern struct MusicPlayerInfo gMPlayInfo_BGM;
-
extern const u8* const gBattleScriptsForMoveEffects[];
#define DEFENDER_IS_PROTECTED ((gProtectStructs[gBattlerTarget].protected) && (gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED))
-// this file's functions
+#define LEVEL_UP_BANNER_START 416
+#define LEVEL_UP_BANNER_END 512
+
+#define TAG_LVLUP_BANNER_MON_ICON 55130
+
static bool8 IsTwoTurnsMove(u16 move);
static void TrySetDestinyBondToHappen(void);
static u8 AttacksThisTurn(u8 battlerId, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2.
static void CheckWonderGuardAndLevitate(void);
static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8* BS_ptr);
static bool32 IsMonGettingExpSentOut(void);
-static void sub_804F17C(void);
-static bool8 sub_804F1CC(void);
+static void InitLevelUpBanner(void);
+static bool8 SlideInLevelUpBanner(void);
+static bool8 SlideOutLevelUpBanner(void);
static void DrawLevelUpWindow1(void);
static void DrawLevelUpWindow2(void);
-static bool8 sub_804F344(void);
-static void PutMonIconOnLvlUpBox(void);
-static void PutLevelAndGenderOnLvlUpBox(void);
-
-static void SpriteCB_MonIconOnLvlUpBox(struct Sprite* sprite);
+static void PutMonIconOnLvlUpBanner(void);
+static void DrawLevelUpBannerText(void);
+static void SpriteCB_MonIconOnLvlUpBanner(struct Sprite* sprite);
static void Cmd_attackcanceler(void);
static void Cmd_accuracycheck(void);
@@ -667,10 +668,18 @@ static const u8* const sMoveEffectBS_Ptrs[] =
[MOVE_EFFECT_RECOIL_33] = BattleScript_MoveEffectRecoil,
};
-static const struct WindowTemplate sUnusedWinTemplate = {0, 1, 3, 7, 0xF, 0x1F, 0x3F};
+static const struct WindowTemplate sUnusedWinTemplate = {
+ .bg = 0,
+ .tilemapLeft = 1,
+ .tilemapTop = 3,
+ .width = 7,
+ .height = 15,
+ .paletteNum = 31,
+ .baseBlock = 0x3F
+};
-static const u16 sUnknown_0831C2C8[] = INCBIN_U16("graphics/battle_interface/unk_battlebox.gbapal");
-static const u32 sUnknown_0831C2E8[] = INCBIN_U32("graphics/battle_interface/unk_battlebox.4bpp.lz");
+static const u16 sLevelUpBanner_Pal[] = INCBIN_U16("graphics/battle_interface/level_up_banner.gbapal");
+static const u32 sLevelUpBanner_Gfx[] = INCBIN_U32("graphics/battle_interface/level_up_banner.4bpp.lz");
// unused
static const u8 sRubyLevelUpStatBoxStats[] =
@@ -679,9 +688,7 @@ static const u8 sRubyLevelUpStatBoxStats[] =
MON_DATA_SPDEF, MON_DATA_DEF, MON_DATA_SPEED
};
-#define MON_ICON_LVLUP_BOX_TAG 0xD75A
-
-static const struct OamData sOamData_MonIconOnLvlUpBox =
+static const struct OamData sOamData_MonIconOnLvlUpBanner =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -698,15 +705,15 @@ static const struct OamData sOamData_MonIconOnLvlUpBox =
.affineParam = 0,
};
-static const struct SpriteTemplate sSpriteTemplate_MonIconOnLvlUpBox =
+static const struct SpriteTemplate sSpriteTemplate_MonIconOnLvlUpBanner =
{
- .tileTag = MON_ICON_LVLUP_BOX_TAG,
- .paletteTag = MON_ICON_LVLUP_BOX_TAG,
- .oam = &sOamData_MonIconOnLvlUpBox,
+ .tileTag = TAG_LVLUP_BANNER_MON_ICON,
+ .paletteTag = TAG_LVLUP_BANNER_MON_ICON,
+ .oam = &sOamData_MonIconOnLvlUpBanner,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = SpriteCB_MonIconOnLvlUpBox
+ .callback = SpriteCB_MonIconOnLvlUpBanner
};
static const u16 sProtectSuccessRates[] = {USHRT_MAX, USHRT_MAX / 2, USHRT_MAX / 4, USHRT_MAX / 8};
@@ -2971,13 +2978,13 @@ static void Cmd_tryfaintmon(void)
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
{
gHitMarker |= HITMARKER_PLAYER_FAINTED;
- if (gBattleResults.playerFaintCounter < 0xFF)
+ if (gBattleResults.playerFaintCounter < 255)
gBattleResults.playerFaintCounter++;
AdjustFriendshipOnBattleFaint(gActiveBattler);
}
else
{
- if (gBattleResults.opponentFaintCounter < 0xFF)
+ if (gBattleResults.opponentFaintCounter < 255)
gBattleResults.opponentFaintCounter++;
gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL);
}
@@ -3033,7 +3040,7 @@ static void Cmd_cleareffectsonfaint(void)
if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || gBattleMons[gActiveBattler].hp == 0)
{
gBattleMons[gActiveBattler].status1 = 0;
- BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 0x4, &gBattleMons[gActiveBattler].status1);
+ BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler);
}
@@ -3765,9 +3772,7 @@ static void Cmd_jumpifarraynotequal(void)
for (i = 0; i < size; i++)
{
if (*mem1 == *mem2)
- {
equalBytes++;
- }
mem1++, mem2++;
}
@@ -3807,9 +3812,7 @@ static void Cmd_copyarray(void)
s32 i;
for (i = 0; i < size; i++)
- {
dest[i] = src[i];
- }
gBattlescriptCurrInstr += 10;
}
@@ -3823,9 +3826,7 @@ static void Cmd_copyarraywithindex(void)
s32 i;
for (i = 0; i < size; i++)
- {
dest[i] = src[i + *index];
- }
gBattlescriptCurrInstr += 14;
}
@@ -4591,9 +4592,7 @@ static void Cmd_switchindataupdate(void)
monData = (u8*)(&gBattleMons[gActiveBattler]);
for (i = 0; i < sizeof(struct BattlePokemon); i++)
- {
monData[i] = gBattleBufferB[gActiveBattler][4 + i];
- }
gBattleMons[gActiveBattler].type1 = gBaseStats[gBattleMons[gActiveBattler].species].type1;
gBattleMons[gActiveBattler].type2 = gBaseStats[gBattleMons[gActiveBattler].species].type2;
@@ -4681,9 +4680,9 @@ static void Cmd_jumpifcantswitch(void)
lastMonId = 0;
if (gActiveBattler & 2)
- lastMonId = 3;
+ lastMonId = MULTI_PARTY_SIZE;
- for (i = lastMonId; i < lastMonId + 3; i++)
+ for (i = lastMonId; i < lastMonId + MULTI_PARTY_SIZE; i++)
{
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
@@ -4692,7 +4691,7 @@ static void Cmd_jumpifcantswitch(void)
break;
}
- if (i == lastMonId + 3)
+ if (i == lastMonId + MULTI_PARTY_SIZE)
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
@@ -4707,7 +4706,7 @@ static void Cmd_jumpifcantswitch(void)
lastMonId = 0;
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gActiveBattler)) == TRUE)
- lastMonId = 3;
+ lastMonId = MULTI_PARTY_SIZE;
}
else
{
@@ -4716,7 +4715,7 @@ static void Cmd_jumpifcantswitch(void)
if (gActiveBattler == 1)
lastMonId = 0;
else
- lastMonId = 3;
+ lastMonId = MULTI_PARTY_SIZE;
}
}
else
@@ -4728,10 +4727,10 @@ static void Cmd_jumpifcantswitch(void)
lastMonId = 0;
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gActiveBattler)) == TRUE)
- lastMonId = 3;
+ lastMonId = MULTI_PARTY_SIZE;
}
- for (i = lastMonId; i < lastMonId + 3; i++)
+ for (i = lastMonId; i < lastMonId + MULTI_PARTY_SIZE; i++)
{
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
@@ -4740,7 +4739,7 @@ static void Cmd_jumpifcantswitch(void)
break;
}
- if (i == lastMonId + 3)
+ if (i == lastMonId + MULTI_PARTY_SIZE)
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
@@ -4751,9 +4750,9 @@ static void Cmd_jumpifcantswitch(void)
lastMonId = 0;
if (gActiveBattler == B_POSITION_OPPONENT_RIGHT)
- lastMonId = 3;
+ lastMonId = PARTY_SIZE / 2;
- for (i = lastMonId; i < lastMonId + 3; i++)
+ for (i = lastMonId; i < lastMonId + (PARTY_SIZE / 2); i++)
{
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
@@ -4762,7 +4761,7 @@ static void Cmd_jumpifcantswitch(void)
break;
}
- if (i == lastMonId + 3)
+ if (i == lastMonId + (PARTY_SIZE / 2))
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
@@ -5080,7 +5079,7 @@ static void Cmd_openpartyscreen(void)
gBattlescriptCurrInstr += 6;
- if (GetBattlerPosition(gActiveBattler) == 0 && gBattleResults.playerSwitchesCounter < 0xFF)
+ if (GetBattlerPosition(gActiveBattler) == 0 && gBattleResults.playerSwitchesCounter < 255)
gBattleResults.playerSwitchesCounter++;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
@@ -5120,7 +5119,7 @@ static void Cmd_switchhandleorder(void)
case 0:
for (i = 0; i < gBattlersCount; i++)
{
- if (gBattleBufferB[i][0] == 0x22)
+ if (gBattleBufferB[i][0] == CONTROLLER_CHOSENMONRETURNVALUE)
{
*(gBattleStruct->monToSwitchIntoId + i) = gBattleBufferB[i][1];
if (!(gBattleStruct->field_93 & gBitTable[i]))
@@ -5357,8 +5356,8 @@ static void Cmd_yesnoboxlearnmove(void)
switch (gBattleScripting.learnMoveState)
{
case 0:
- HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
- BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
+ HandleBattleWindow(24, 8, 29, 13, 0);
+ BattlePutTextOnWindow(gText_BattleYesNoChoice, B_WIN_YESNO);
gBattleScripting.learnMoveState++;
gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0);
@@ -5383,8 +5382,8 @@ static void Cmd_yesnoboxlearnmove(void)
PlaySE(SE_SELECT);
if (gBattleCommunication[1] == 0)
{
- HandleBattleWindow(0x18, 0x8, 0x1D, 0xD, WINDOW_CLEAR);
- BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
+ HandleBattleWindow(24, 8, 29, 13, WINDOW_CLEAR);
+ BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
gBattleScripting.learnMoveState++;
}
else
@@ -5457,7 +5456,7 @@ static void Cmd_yesnoboxlearnmove(void)
}
break;
case 5:
- HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
+ HandleBattleWindow(24, 8, 29, 13, WINDOW_CLEAR);
gBattlescriptCurrInstr += 5;
break;
case 6:
@@ -5474,8 +5473,8 @@ static void Cmd_yesnoboxstoplearningmove(void)
switch (gBattleScripting.learnMoveState)
{
case 0:
- HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
- BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
+ HandleBattleWindow(24, 8, 29, 13, 0);
+ BattlePutTextOnWindow(gText_BattleYesNoChoice, B_WIN_YESNO);
gBattleScripting.learnMoveState++;
gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0);
@@ -5504,13 +5503,13 @@ static void Cmd_yesnoboxstoplearningmove(void)
else
gBattlescriptCurrInstr += 5;
- HandleBattleWindow(0x18, 0x8, 0x1D, 0xD, WINDOW_CLEAR);
+ HandleBattleWindow(24, 8, 29, 13, WINDOW_CLEAR);
}
else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
- HandleBattleWindow(0x18, 0x8, 0x1D, 0xD, WINDOW_CLEAR);
+ HandleBattleWindow(24, 8, 29, 13, WINDOW_CLEAR);
}
break;
}
@@ -5769,8 +5768,8 @@ static void Cmd_yesnobox(void)
switch (gBattleCommunication[0])
{
case 0:
- HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
- BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
+ HandleBattleWindow(24, 8, 29, 13, 0);
+ BattlePutTextOnWindow(gText_BattleYesNoChoice, B_WIN_YESNO);
gBattleCommunication[0]++;
gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0);
@@ -5794,13 +5793,13 @@ static void Cmd_yesnobox(void)
{
gBattleCommunication[CURSOR_POSITION] = 1;
PlaySE(SE_SELECT);
- HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
+ HandleBattleWindow(24, 8, 29, 13, WINDOW_CLEAR);
gBattlescriptCurrInstr++;
}
else if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
- HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR);
+ HandleBattleWindow(24, 8, 29, 13, WINDOW_CLEAR);
gBattlescriptCurrInstr++;
}
break;
@@ -5884,6 +5883,9 @@ static void Cmd_drawlvlupbox(void)
{
if (gBattleScripting.drawlvlupboxState == 0)
{
+ // If the Pokémon getting exp is not in-battle then
+ // slide out a banner with their name and icon on it.
+ // Otherwise skip ahead.
if (IsMonGettingExpSentOut())
gBattleScripting.drawlvlupboxState = 3;
else
@@ -5893,34 +5895,38 @@ static void Cmd_drawlvlupbox(void)
switch (gBattleScripting.drawlvlupboxState)
{
case 1:
- gBattle_BG2_Y = 0x60;
+ // Start level up banner
+ gBattle_BG2_Y = 96;
SetBgAttribute(2, BG_ATTR_PRIORITY, 0);
ShowBg(2);
- sub_804F17C();
+ InitLevelUpBanner();
gBattleScripting.drawlvlupboxState = 2;
break;
case 2:
- if (!sub_804F1CC())
+ if (!SlideInLevelUpBanner())
gBattleScripting.drawlvlupboxState = 3;
break;
case 3:
+ // Init level up box
gBattle_BG1_X = 0;
- gBattle_BG1_Y = 0x100;
+ gBattle_BG1_Y = 256;
SetBgAttribute(0, BG_ATTR_PRIORITY, 1);
SetBgAttribute(1, BG_ATTR_PRIORITY, 0);
ShowBg(0);
ShowBg(1);
- HandleBattleWindow(0x12, 7, 0x1D, 0x13, WINDOW_x80);
+ HandleBattleWindow(18, 7, 29, 19, WINDOW_BG1);
gBattleScripting.drawlvlupboxState = 4;
break;
case 4:
+ // Draw page 1 of level up box
DrawLevelUpWindow1();
- PutWindowTilemap(13);
- CopyWindowToVram(13, 3);
+ PutWindowTilemap(B_WIN_LEVEL_UP_BOX);
+ CopyWindowToVram(B_WIN_LEVEL_UP_BOX, 3);
gBattleScripting.drawlvlupboxState++;
break;
case 5:
case 7:
+ // Wait for draw after each page
if (!IsDma3ManagerBusyWithBgCopy())
{
gBattle_BG1_Y = 0;
@@ -5930,28 +5936,30 @@ static void Cmd_drawlvlupbox(void)
case 6:
if (gMain.newKeys != 0)
{
+ // Draw page 2 of level up box
PlaySE(SE_SELECT);
DrawLevelUpWindow2();
- CopyWindowToVram(13, 2);
+ CopyWindowToVram(B_WIN_LEVEL_UP_BOX, 2);
gBattleScripting.drawlvlupboxState++;
}
break;
case 8:
if (gMain.newKeys != 0)
{
+ // Close level up box
PlaySE(SE_SELECT);
- HandleBattleWindow(0x12, 7, 0x1D, 0x13, WINDOW_x80 | WINDOW_CLEAR);
+ HandleBattleWindow(18, 7, 29, 19, WINDOW_BG1 | WINDOW_CLEAR);
gBattleScripting.drawlvlupboxState++;
}
break;
case 9:
- if (!sub_804F344())
+ if (!SlideOutLevelUpBanner())
{
- ClearWindowTilemap(14);
- CopyWindowToVram(14, 1);
+ ClearWindowTilemap(B_WIN_LEVEL_UP_BANNER);
+ CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, 1);
- ClearWindowTilemap(13);
- CopyWindowToVram(13, 1);
+ ClearWindowTilemap(B_WIN_LEVEL_UP_BOX);
+ CopyWindowToVram(B_WIN_LEVEL_UP_BOX, 1);
SetBgAttribute(2, BG_ATTR_PRIORITY, 2);
ShowBg(2);
@@ -5977,7 +5985,7 @@ static void DrawLevelUpWindow1(void)
u16 currStats[NUM_STATS];
GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], currStats);
- DrawLevelUpWindowPg1(0xD, gBattleResources->beforeLvlUp->stats, currStats, TEXT_DYNAMIC_COLOR_5, TEXT_DYNAMIC_COLOR_4, TEXT_DYNAMIC_COLOR_6);
+ DrawLevelUpWindowPg1(B_WIN_LEVEL_UP_BOX, gBattleResources->beforeLvlUp->stats, currStats, TEXT_DYNAMIC_COLOR_5, TEXT_DYNAMIC_COLOR_4, TEXT_DYNAMIC_COLOR_6);
}
static void DrawLevelUpWindow2(void)
@@ -5985,41 +5993,41 @@ static void DrawLevelUpWindow2(void)
u16 currStats[NUM_STATS];
GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], currStats);
- DrawLevelUpWindowPg2(0xD, currStats, TEXT_DYNAMIC_COLOR_5, TEXT_DYNAMIC_COLOR_4, TEXT_DYNAMIC_COLOR_6);
+ DrawLevelUpWindowPg2(B_WIN_LEVEL_UP_BOX, currStats, TEXT_DYNAMIC_COLOR_5, TEXT_DYNAMIC_COLOR_4, TEXT_DYNAMIC_COLOR_6);
}
-static void sub_804F17C(void)
+static void InitLevelUpBanner(void)
{
gBattle_BG2_Y = 0;
- gBattle_BG2_X = 0x1A0;
+ gBattle_BG2_X = LEVEL_UP_BANNER_START;
- LoadPalette(sUnknown_0831C2C8, 0x60, 0x20);
- CopyToWindowPixelBuffer(14, sUnknown_0831C2E8, 0, 0);
- PutWindowTilemap(14);
- CopyWindowToVram(14, 3);
+ LoadPalette(sLevelUpBanner_Pal, 0x60, 0x20);
+ CopyToWindowPixelBuffer(B_WIN_LEVEL_UP_BANNER, sLevelUpBanner_Gfx, 0, 0);
+ PutWindowTilemap(B_WIN_LEVEL_UP_BANNER);
+ CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, 3);
- PutMonIconOnLvlUpBox();
+ PutMonIconOnLvlUpBanner();
}
-static bool8 sub_804F1CC(void)
+static bool8 SlideInLevelUpBanner(void)
{
if (IsDma3ManagerBusyWithBgCopy())
return TRUE;
- if (gBattle_BG2_X == 0x200)
+ if (gBattle_BG2_X == LEVEL_UP_BANNER_END)
return FALSE;
- if (gBattle_BG2_X == 0x1A0)
- PutLevelAndGenderOnLvlUpBox();
+ if (gBattle_BG2_X == LEVEL_UP_BANNER_START)
+ DrawLevelUpBannerText();
gBattle_BG2_X += 8;
- if (gBattle_BG2_X >= 0x200)
- gBattle_BG2_X = 0x200;
+ if (gBattle_BG2_X >= LEVEL_UP_BANNER_END)
+ gBattle_BG2_X = LEVEL_UP_BANNER_END;
- return (gBattle_BG2_X != 0x200);
+ return (gBattle_BG2_X != LEVEL_UP_BANNER_END);
}
-static void PutLevelAndGenderOnLvlUpBox(void)
+static void DrawLevelUpBannerText(void)
{
u16 monLevel;
u8 monGender;
@@ -6032,7 +6040,7 @@ static void PutLevelAndGenderOnLvlUpBox(void)
GetMonNickname(&gPlayerParty[gBattleStruct->expGetterMonId], gStringVar4);
printerTemplate.currentChar = gStringVar4;
- printerTemplate.windowId = 14;
+ printerTemplate.windowId = B_WIN_LEVEL_UP_BANNER;
printerTemplate.fontId = 0;
printerTemplate.x = 32;
printerTemplate.y = 0;
@@ -6045,7 +6053,7 @@ static void PutLevelAndGenderOnLvlUpBox(void)
printerTemplate.bgColor = TEXT_COLOR_TRANSPARENT;
printerTemplate.shadowColor = TEXT_COLOR_DARK_GRAY;
- AddTextPrinter(&printerTemplate, 0xFF, NULL);
+ AddTextPrinter(&printerTemplate, TEXT_SPEED_FF, NULL);
txtPtr = gStringVar4;
*(txtPtr)++ = CHAR_EXTRA_SYMBOL;
@@ -6060,14 +6068,14 @@ static void PutLevelAndGenderOnLvlUpBox(void)
{
if (monGender == MON_MALE)
{
- txtPtr = WriteColorChangeControlCode(txtPtr, 0, 0xC);
- txtPtr = WriteColorChangeControlCode(txtPtr, 1, 0xD);
+ txtPtr = WriteColorChangeControlCode(txtPtr, 0, TEXT_DYNAMIC_COLOR_3);
+ txtPtr = WriteColorChangeControlCode(txtPtr, 1, TEXT_DYNAMIC_COLOR_4);
*(txtPtr++) = CHAR_MALE;
}
else
{
- txtPtr = WriteColorChangeControlCode(txtPtr, 0, 0xE);
- txtPtr = WriteColorChangeControlCode(txtPtr, 1, 0xF);
+ txtPtr = WriteColorChangeControlCode(txtPtr, 0, TEXT_DYNAMIC_COLOR_5);
+ txtPtr = WriteColorChangeControlCode(txtPtr, 1, TEXT_DYNAMIC_COLOR_6);
*(txtPtr++) = CHAR_FEMALE;
}
*(txtPtr++) = EOS;
@@ -6075,28 +6083,28 @@ static void PutLevelAndGenderOnLvlUpBox(void)
printerTemplate.y = 10;
printerTemplate.currentY = 10;
- AddTextPrinter(&printerTemplate, 0xFF, NULL);
+ AddTextPrinter(&printerTemplate, TEXT_SPEED_FF, NULL);
- CopyWindowToVram(14, 2);
+ CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, 2);
}
-static bool8 sub_804F344(void)
+static bool8 SlideOutLevelUpBanner(void)
{
- if (gBattle_BG2_X == 0x1A0)
+ if (gBattle_BG2_X == LEVEL_UP_BANNER_START)
return FALSE;
- if (gBattle_BG2_X - 16 < 0x1A0)
- gBattle_BG2_X = 0x1A0;
+ if (gBattle_BG2_X - 16 < LEVEL_UP_BANNER_START)
+ gBattle_BG2_X = LEVEL_UP_BANNER_START;
else
gBattle_BG2_X -= 16;
- return (gBattle_BG2_X != 0x1A0);
+ return (gBattle_BG2_X != LEVEL_UP_BANNER_START);
}
-#define sDestroy data[0]
-#define sSavedLvlUpBoxXPosition data[1]
+#define sDestroy data[0]
+#define sXOffset data[1]
-static void PutMonIconOnLvlUpBox(void)
+static void PutMonIconOnLvlUpBanner(void)
{
u8 spriteId;
const u16* iconPal;
@@ -6109,23 +6117,23 @@ static void PutMonIconOnLvlUpBox(void)
const u8* iconPtr = GetMonIconPtr(species, personality, 1);
iconSheet.data = iconPtr;
iconSheet.size = 0x200;
- iconSheet.tag = MON_ICON_LVLUP_BOX_TAG;
+ iconSheet.tag = TAG_LVLUP_BANNER_MON_ICON;
iconPal = GetValidMonIconPalettePtr(species);
iconPalSheet.data = iconPal;
- iconPalSheet.tag = MON_ICON_LVLUP_BOX_TAG;
+ iconPalSheet.tag = TAG_LVLUP_BANNER_MON_ICON;
LoadSpriteSheet(&iconSheet);
LoadSpritePalette(&iconPalSheet);
- spriteId = CreateSprite(&sSpriteTemplate_MonIconOnLvlUpBox, 256, 10, 0);
+ spriteId = CreateSprite(&sSpriteTemplate_MonIconOnLvlUpBanner, 256, 10, 0);
gSprites[spriteId].sDestroy = FALSE;
- gSprites[spriteId].sSavedLvlUpBoxXPosition = gBattle_BG2_X;
+ gSprites[spriteId].sXOffset = gBattle_BG2_X;
}
-static void SpriteCB_MonIconOnLvlUpBox(struct Sprite* sprite)
+static void SpriteCB_MonIconOnLvlUpBanner(struct Sprite* sprite)
{
- sprite->x2 = sprite->sSavedLvlUpBoxXPosition - gBattle_BG2_X;
+ sprite->x2 = sprite->sXOffset - gBattle_BG2_X;
if (sprite->x2 != 0)
{
@@ -6134,13 +6142,13 @@ static void SpriteCB_MonIconOnLvlUpBox(struct Sprite* sprite)
else if (sprite->sDestroy)
{
DestroySprite(sprite);
- FreeSpriteTilesByTag(MON_ICON_LVLUP_BOX_TAG);
- FreeSpritePaletteByTag(MON_ICON_LVLUP_BOX_TAG);
+ FreeSpriteTilesByTag(TAG_LVLUP_BANNER_MON_ICON);
+ FreeSpritePaletteByTag(TAG_LVLUP_BANNER_MON_ICON);
}
}
#undef sDestroy
-#undef sSavedLvlUpBoxXPosition
+#undef sXOffset
static bool32 IsMonGettingExpSentOut(void)
{
@@ -6389,10 +6397,10 @@ static void Cmd_various(void)
break;
case VARIOUS_ARENA_JUDGMENT_STRING:
BattleStringExpandPlaceholdersToDisplayedString(gRefereeStringsTable[gBattlescriptCurrInstr[1]]);
- BattlePutTextOnWindow(gDisplayedStringBattle, 22);
+ BattlePutTextOnWindow(gDisplayedStringBattle, ARENA_WIN_JUDGEMENT_TEXT);
break;
case VARIOUS_ARENA_WAIT_STRING:
- if (IsTextPrinterActive(22))
+ if (IsTextPrinterActive(ARENA_WIN_JUDGEMENT_TEXT))
return;
break;
case VARIOUS_WAIT_CRY:
@@ -7828,7 +7836,7 @@ static void Cmd_psywavedamageeffect(void)
{
s32 randDamage;
- while ((randDamage = (Random() & 0xF)) > 10);
+ while ((randDamage = Random() % 16) > 10);
randDamage *= 10;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].level * (randDamage + 50) / 100;
@@ -7966,8 +7974,8 @@ static void Cmd_painsplitdmgcalc(void)
static void Cmd_settypetorandomresistance(void) // conversion 2
{
- if (gLastLandedMoves[gBattlerAttacker] == 0
- || gLastLandedMoves[gBattlerAttacker] == 0xFFFF)
+ if (gLastLandedMoves[gBattlerAttacker] == MOVE_NONE
+ || gLastLandedMoves[gBattlerAttacker] == 0xFFFF)
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
@@ -7982,7 +7990,7 @@ static void Cmd_settypetorandomresistance(void) // conversion 2
for (rands = 0; rands < 1000; rands++)
{
- while (((i = (Random() & 0x7F)) > sizeof(gTypeEffectiveness) / 3));
+ while (((i = Random() % 128) > sizeof(gTypeEffectiveness) / 3));
i *= 3;
@@ -8145,7 +8153,7 @@ static void Cmd_trychoosesleeptalkmove(void)
}
unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~MOVE_LIMITATION_PP);
- if (unusableMovesBits == 0xF) // all 4 moves cannot be chosen
+ if (unusableMovesBits == (1 << MAX_MON_MOVES) - 1) // all 4 moves cannot be chosen
{
gBattlescriptCurrInstr += 5;
}
@@ -8329,7 +8337,7 @@ static void Cmd_healpartystatus(void)
else // Aromatherapy
{
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SOOTHING_AROMA;
- toHeal = 0x3F;
+ toHeal = (1 << PARTY_SIZE) - 1;
gBattleMons[gBattlerAttacker].status1 = 0;
gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE;
@@ -9959,7 +9967,7 @@ static void Cmd_displaydexinfo(void)
switch (gBattleCommunication[0])
{
case 0:
- BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
+ BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
gBattleCommunication[0]++;
break;
case 1:
@@ -9984,13 +9992,13 @@ static void Cmd_displaydexinfo(void)
case 3:
InitBattleBgsVideo();
LoadBattleTextboxAndBackground();
- gBattle_BG3_X = 0x100;
+ gBattle_BG3_X = 256;
gBattleCommunication[0]++;
break;
case 4:
if (!IsDma3ManagerBusyWithBgCopy())
{
- BeginNormalPaletteFade(PALETTES_BG, 0, 0x10, 0, RGB_BLACK);
+ BeginNormalPaletteFade(PALETTES_BG, 0, 16, 0, RGB_BLACK);
ShowBg(0);
ShowBg(3);
gBattleCommunication[0]++;
@@ -10043,7 +10051,7 @@ void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags)
if (flags & WINDOW_CLEAR)
var = 0;
- if (flags & WINDOW_x80)
+ if (flags & WINDOW_BG1)
CopyToBgTilemapBufferRect_ChangePalette(1, &var, destX, destY, 1, 1, 0x11);
else
CopyToBgTilemapBufferRect_ChangePalette(0, &var, destX, destY, 1, 1, 0x11);
@@ -10076,8 +10084,8 @@ static void Cmd_trygivecaughtmonnick(void)
switch (gBattleCommunication[MULTIUSE_STATE])
{
case 0:
- HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0);
- BattlePutTextOnWindow(gText_BattleYesNoChoice, 0xC);
+ HandleBattleWindow(24, 8, 29, 13, 0);
+ BattlePutTextOnWindow(gText_BattleYesNoChoice, B_WIN_YESNO);
gBattleCommunication[MULTIUSE_STATE]++;
gBattleCommunication[CURSOR_POSITION] = 0;
BattleCreateYesNoCursorAt(0);