Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Descriptions in battle #4152

Merged
merged 14 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ extern u16 gLastThrownBall;
extern u16 gBallToDisplay;
extern bool8 gLastUsedBallMenuPresent;
extern u8 gPartyCriticalHits[PARTY_SIZE];
extern u8 gCategoryIconSpriteId;

static inline u32 GetBattlerPosition(u32 battler)
{
Expand Down
1 change: 1 addition & 0 deletions include/battle_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,6 @@ void TryAddLastUsedBallItemSprites(void);
void SwapBallToDisplay(bool32 sameBall);
void ArrowsChangeColorLastBallCycle(bool32 showArrows);
void UpdateAbilityPopup(u8 battlerId);
void CategoryIcons_LoadSpritesGfx(void);

#endif // GUARD_BATTLE_INTERFACE_H
1 change: 1 addition & 0 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@
#define B_WIN_VS_OUTCOME_DRAW 21
#define B_WIN_VS_OUTCOME_LEFT 22
#define B_WIN_VS_OUTCOME_RIGHT 23
#define B_WIN_MOVE_DESCRIPTION 24

// The following are duplicate id values for windows that Battle Arena uses differently.
#define ARENA_WIN_PLAYER_NAME 15
Expand Down
2 changes: 2 additions & 0 deletions include/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,8 @@ extern const u32 gSummaryMoveSelect_Gfx[];
extern const u32 gSummaryMoveSelect_Pal[];
extern const u32 gStatusGfx_Icons[];
extern const u32 gStatusPal_Icons[];
extern const u16 gCategoryIcons_Pal[];
extern const u32 gCategoryIcons_Gfx[];

extern const u32 gShopMenu_Gfx[];
extern const u32 gShopMenu_Tilemap[];
Expand Down
4 changes: 3 additions & 1 deletion include/pokemon_summary_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

extern u8 gLastViewedMonIndex;

extern const u8 *const gMoveDescriptionPointers[];
extern const u8 gNotDoneYetDescription[];
extern const struct SpriteTemplate gSpriteTemplate_MoveTypes;
extern const struct CompressedSpriteSheet gSpriteSheet_MoveTypes;
extern const struct CompressedSpriteSheet gSpriteSheet_CategoryIcons;
extern const struct SpritePalette gSpritePal_CategoryIcons;
extern const struct SpriteTemplate gSpriteTemplate_CategoryIcons;

void ShowPokemonSummaryScreen(u8 mode, void *mons, u8 monIndex, u8 maxMonIndex, void (*callback)(void));
void ShowSelectMovePokemonSummaryScreen(struct Pokemon *mons, u8 monIndex, u8 maxMonIndex, void (*callback)(void), u16 newMove);
Expand Down
18 changes: 18 additions & 0 deletions src/battle_bg.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,15 @@ static const struct WindowTemplate sStandardBattleWindowTemplates[] =
.paletteNum = 0,
.baseBlock = 0x00b0,
},
[B_WIN_MOVE_DESCRIPTION] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 47,
.width = 18,
.height = 6,
.paletteNum = 5,
.baseBlock = 0x0350,
},
DUMMY_WIN_TEMPLATE
};

Expand Down Expand Up @@ -583,6 +592,15 @@ static const struct WindowTemplate sBattleArenaWindowTemplates[] =
.paletteNum = 7,
.baseBlock = 0x0090,
},
[B_WIN_MOVE_DESCRIPTION] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 47,
.width = 18,
.height = 6,
.paletteNum = 5,
.baseBlock = 0x0350,
},
DUMMY_WIN_TEMPLATE
};

Expand Down
92 changes: 89 additions & 3 deletions src/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "util.h"
#include "window.h"
#include "constants/battle_anim.h"
#include "constants/battle_move_effects.h"
#include "constants/battle_partner.h"
#include "constants/hold_effects.h"
#include "constants/items.h"
Expand All @@ -40,6 +41,8 @@
#include "constants/trainers.h"
#include "constants/rgb.h"
#include "level_caps.h"
#include "menu.h"
#include "pokemon_summary_screen.h"

static void PlayerBufferExecCompleted(u32 battler);
static void PlayerHandleLoadMonSprite(u32 battler);
Expand Down Expand Up @@ -83,6 +86,7 @@ static void MoveSelectionDisplayPpNumber(u32 battler);
static void MoveSelectionDisplayPpString(u32 battler);
static void MoveSelectionDisplayMoveType(u32 battler);
static void MoveSelectionDisplayMoveNames(u32 battler);
static void MoveSelectionDisplayMoveDescription(u32 battler);
static void HandleMoveSwitching(u32 battler);
static void SwitchIn_HandleSoundAndEnd(u32 battler);
static void WaitForMonSelection(u32 battler);
Expand Down Expand Up @@ -158,6 +162,8 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(u32 battler) =
[CONTROLLER_TERMINATOR_NOP] = BtlController_TerminatorNop
};

static EWRAM_DATA bool8 sDescriptionSubmenu = 0;

static EWRAM_DATA bool8 sAckBallUseBtn = FALSE;
static EWRAM_DATA bool8 sBallSwapped = FALSE;
Comment on lines +165 to 168
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The battle debug menu uses some hack to avoid using an EWARM. Not for this PR but we should explore it at some point. Maybe we will be able to remove those. I'll open an issue once it is merged.


Expand Down Expand Up @@ -690,7 +696,7 @@ static void HandleInputChooseMove(u32 battler)
else
gPlayerDpadHoldFrames = 0;

if (JOY_NEW(A_BUTTON))
if (JOY_NEW(A_BUTTON) && !sDescriptionSubmenu)
{
PlaySE(SE_SELECT);

Expand Down Expand Up @@ -797,7 +803,7 @@ static void HandleInputChooseMove(u32 battler)
break;
}
}
else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59)
else if ((JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) && !sDescriptionSubmenu)
{
PlaySE(SE_SELECT);
if (gBattleStruct->zmove.viewing)
Expand Down Expand Up @@ -826,6 +832,8 @@ static void HandleInputChooseMove(u32 battler)
MoveSelectionCreateCursorAt(gMoveSelectionCursor[battler], 0);
MoveSelectionDisplayPpNumber(battler);
MoveSelectionDisplayMoveType(battler);
if (sDescriptionSubmenu)
MoveSelectionDisplayMoveDescription(battler);
TryChangeZIndicator(battler, gMoveSelectionCursor[battler]);
}
}
Expand All @@ -840,6 +848,8 @@ static void HandleInputChooseMove(u32 battler)
MoveSelectionCreateCursorAt(gMoveSelectionCursor[battler], 0);
MoveSelectionDisplayPpNumber(battler);
MoveSelectionDisplayMoveType(battler);
if (sDescriptionSubmenu)
MoveSelectionDisplayMoveDescription(battler);
TryChangeZIndicator(battler, gMoveSelectionCursor[battler]);
}
}
Expand All @@ -853,6 +863,8 @@ static void HandleInputChooseMove(u32 battler)
MoveSelectionCreateCursorAt(gMoveSelectionCursor[battler], 0);
MoveSelectionDisplayPpNumber(battler);
MoveSelectionDisplayMoveType(battler);
if (sDescriptionSubmenu)
MoveSelectionDisplayMoveDescription(battler);
TryChangeZIndicator(battler, gMoveSelectionCursor[battler]);
}
}
Expand All @@ -867,10 +879,12 @@ static void HandleInputChooseMove(u32 battler)
MoveSelectionCreateCursorAt(gMoveSelectionCursor[battler], 0);
MoveSelectionDisplayPpNumber(battler);
MoveSelectionDisplayMoveType(battler);
if (sDescriptionSubmenu)
MoveSelectionDisplayMoveDescription(battler);
TryChangeZIndicator(battler, gMoveSelectionCursor[battler]);
}
}
else if (JOY_NEW(SELECT_BUTTON) && !gBattleStruct->zmove.viewing)
else if (JOY_NEW(SELECT_BUTTON) && !gBattleStruct->zmove.viewing && !sDescriptionSubmenu)
{
if (gNumberOfMovesToChoose > 1 && !(gBattleTypeFlags & BATTLE_TYPE_LINK))
{
Expand All @@ -886,6 +900,30 @@ static void HandleInputChooseMove(u32 battler)
gBattlerControllerFuncs[battler] = HandleMoveSwitching;
}
}
else if (sDescriptionSubmenu)
{
if (JOY_NEW(L_BUTTON) || JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
{
sDescriptionSubmenu = FALSE;
if (gCategoryIconSpriteId != 0xFF)
{
DestroySprite(&gSprites[gCategoryIconSpriteId]);
gCategoryIconSpriteId = 0xFF;
}

FillWindowPixelBuffer(B_WIN_MOVE_DESCRIPTION, PIXEL_FILL(0));
ClearStdWindowAndFrame(B_WIN_MOVE_DESCRIPTION, FALSE);
CopyWindowToVram(B_WIN_MOVE_DESCRIPTION, COPYWIN_GFX);
PlaySE(SE_SELECT);
MoveSelectionDisplayPpNumber(battler);
MoveSelectionDisplayMoveType(battler);
}
}
else if (JOY_NEW(L_BUTTON))
{
sDescriptionSubmenu = TRUE;
MoveSelectionDisplayMoveDescription(battler);
}
else if (JOY_NEW(START_BUTTON))
{
if (CanMegaEvolve(battler))
Expand Down Expand Up @@ -1772,6 +1810,54 @@ static void MoveSelectionDisplayMoveType(u32 battler)
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_TYPE);
}

static void MoveSelectionDisplayMoveDescription(u32 battler)
{
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[battler][4]);
u16 move = moveInfo->moves[gMoveSelectionCursor[battler]];
u16 pwr = gMovesInfo[move].power;
u16 acc = gMovesInfo[move].accuracy;
u8 cat = gMovesInfo[move].category;

u8 pwr_num[3], acc_num[3];
u8 cat_desc[7] = _("CAT: ");
u8 pwr_desc[7] = _("PWR: ");
u8 acc_desc[7] = _("ACC: ");
u8 cat_start[] = _("{CLEAR_TO 0x03}");
u8 pwr_start[] = _("{CLEAR_TO 0x38}");
u8 acc_start[] = _("{CLEAR_TO 0x6D}");
LoadMessageBoxAndBorderGfx();
DrawStdWindowFrame(B_WIN_MOVE_DESCRIPTION, FALSE);
if (pwr < 2)
StringCopy(pwr_num, gText_BattleSwitchWhich5);
else
ConvertIntToDecimalStringN(pwr_num, pwr, STR_CONV_MODE_LEFT_ALIGN, 3);
if (acc < 2)
StringCopy(acc_num, gText_BattleSwitchWhich5);
else
ConvertIntToDecimalStringN(acc_num, acc, STR_CONV_MODE_LEFT_ALIGN, 3);
StringCopy(gDisplayedStringBattle, cat_start);
StringAppend(gDisplayedStringBattle, cat_desc);
StringAppend(gDisplayedStringBattle, pwr_start);
StringAppend(gDisplayedStringBattle, pwr_desc);
StringAppend(gDisplayedStringBattle, pwr_num);
StringAppend(gDisplayedStringBattle, acc_start);
StringAppend(gDisplayedStringBattle, acc_desc);
StringAppend(gDisplayedStringBattle, acc_num);
StringAppend(gDisplayedStringBattle, gText_NewLine);
if (gMovesInfo[move].effect == EFFECT_PLACEHOLDER)
StringAppend(gDisplayedStringBattle, gNotDoneYetDescription);
else
StringAppend(gDisplayedStringBattle, gMovesInfo[move - 1].description);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_DESCRIPTION);

if (gCategoryIconSpriteId == 0xFF)
gCategoryIconSpriteId = CreateSprite(&gSpriteTemplate_CategoryIcons, 38, 64, 1);

StartSpriteAnim(&gSprites[gCategoryIconSpriteId], cat);

CopyWindowToVram(B_WIN_MOVE_DESCRIPTION, COPYWIN_FULL);
}

void MoveSelectionCreateCursorAt(u8 cursorPosition, u8 baseTileNum)
{
u16 src[2];
Expand Down
1 change: 1 addition & 0 deletions src/battle_gfx_sfx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state)
LoadSpritePalette(&sSpritePalettes_HealthBoxHealthBar[1]);
MegaIndicator_LoadSpritesGfx();
TeraIndicator_LoadSpriteGfx();
CategoryIcons_LoadSpritesGfx();
}
else if (!IsDoubleBattle())
{
Expand Down
6 changes: 6 additions & 0 deletions src/battle_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -3753,3 +3753,9 @@ void ArrowsChangeColorLastBallCycle(bool32 showArrows)
}
#endif
}

void CategoryIcons_LoadSpritesGfx(void)
{
LoadCompressedSpriteSheet(&gSpriteSheet_CategoryIcons);
LoadSpritePalette(&gSpritePal_CategoryIcons);
}
2 changes: 2 additions & 0 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ EWRAM_DATA u16 gBallToDisplay = 0;
EWRAM_DATA bool8 gLastUsedBallMenuPresent = FALSE;
EWRAM_DATA u8 gPartyCriticalHits[PARTY_SIZE] = {0};
EWRAM_DATA static u8 sTriedEvolving = 0;
EWRAM_DATA u8 gCategoryIconSpriteId = 0;

void (*gPreBattleCallback1)(void);
void (*gBattleMainFunc)(void);
Expand Down Expand Up @@ -3416,6 +3417,7 @@ static void BattleStartClearSetData(void)

gBattleStruct->swapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
gSelectedMonPartyId = PARTY_SIZE; // Revival Blessing
gCategoryIconSpriteId = 0xFF;
}

void SwitchInClearSetData(u32 battler)
Expand Down
24 changes: 24 additions & 0 deletions src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,18 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.fgColor = 1,
.shadowColor = 6,
},
[B_WIN_MOVE_DESCRIPTION] = {
.fillValue = PIXEL_FILL(0xE),
.fontId = FONT_NARROW,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = TEXT_DYNAMIC_COLOR_4,
.bgColor = TEXT_DYNAMIC_COLOR_5,
.shadowColor = TEXT_DYNAMIC_COLOR_6,
},
};

static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
Expand Down Expand Up @@ -2725,6 +2737,18 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.bgColor = 1,
.shadowColor = 3,
},
[B_WIN_MOVE_DESCRIPTION] = {
.fillValue = PIXEL_FILL(0xE),
.fontId = FONT_NARROW,
.x = 0,
.y = 1,
.letterSpacing = 0,
.lineSpacing = 0,
.speed = 0,
.fgColor = TEXT_DYNAMIC_COLOR_4,
.bgColor = TEXT_DYNAMIC_COLOR_5,
.shadowColor = TEXT_DYNAMIC_COLOR_6,
},
};

static const struct BattleWindowText *const sBattleTextOnWindowsInfo[] =
Expand Down
3 changes: 3 additions & 0 deletions src/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,9 @@ const u32 gPartyMenuPokeball_Pal[] = INCBIN_U32("graphics/party_menu/pokeball.gb
const u32 gStatusGfx_Icons[] = INCBIN_U32("graphics/interface/status_icons.4bpp.lz");
const u32 gStatusPal_Icons[] = INCBIN_U32("graphics/interface/status_icons.gbapal.lz");

const u16 gCategoryIcons_Pal[] = INCBIN_U16("graphics/interface/category_icons.gbapal");
const u32 gCategoryIcons_Gfx[] = INCBIN_U32("graphics/interface/category_icons.4bpp.lz");

const u32 gMoveTypes_Gfx[] = INCBIN_U32("graphics/types/move_types.4bpp.lz");
const u32 gMoveTypes_Pal[] = INCBIN_U32("graphics/types/move_types.gbapal.lz");

Expand Down
Loading
Loading