Move Descriptions in battle (#4152)

* Port xaman move desc to modern expansion

* Fix modern compiler error

* Fix compliling + EFFECT_PLACEHOLDER support

* Change to L-button to avoid conflict with Mega Evolution

* Reorder and change priority to category

* add sprite for move category icon, declare category icon sprite data extern

* remove static category icon sprite data from hgss dex for global data

* Change to else if

---------

Co-authored-by: Pawkkie <moog272@gmail.com>
Co-authored-by: RavePossum <ravepossum@proton.me>
This commit is contained in:
Bassoonian 2024-05-31 12:10:03 +02:00 committed by GitHub
parent f6e00303b7
commit 52d45674f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 162 additions and 72 deletions

View file

@ -1149,6 +1149,7 @@ extern u16 gLastThrownBall;
extern u16 gBallToDisplay;
extern bool8 gLastUsedBallMenuPresent;
extern u8 gPartyCriticalHits[PARTY_SIZE];
extern u8 gCategoryIconSpriteId;
static inline u32 GetBattlerPosition(u32 battler)
{

View file

@ -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

View file

@ -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

View file

@ -1983,6 +1983,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[];

View file

@ -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);

View file

@ -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
};
@ -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
};

View file

@ -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"
@ -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);
@ -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);
@ -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;
@ -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);
@ -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)
@ -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]);
}
}
@ -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]);
}
}
@ -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]);
}
}
@ -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))
{
@ -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))
@ -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];

View file

@ -707,6 +707,7 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state)
LoadSpritePalette(&sSpritePalettes_HealthBoxHealthBar[1]);
MegaIndicator_LoadSpritesGfx();
TeraIndicator_LoadSpriteGfx();
CategoryIcons_LoadSpritesGfx();
}
else if (!IsDoubleBattle())
{

View file

@ -3753,3 +3753,9 @@ void ArrowsChangeColorLastBallCycle(bool32 showArrows)
}
#endif
}
void CategoryIcons_LoadSpritesGfx(void)
{
LoadCompressedSpriteSheet(&gSpriteSheet_CategoryIcons);
LoadSpritePalette(&gSpritePal_CategoryIcons);
}

View file

@ -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);
@ -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)

View file

@ -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[] =
@ -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[] =

View file

@ -1629,6 +1629,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");

View file

@ -622,60 +622,6 @@ static void DestroyCategoryIcon(void);
static u16 NationalPokedexNumToSpeciesHGSS(u16 nationalNum);
#define TAG_CATEGORY_ICONS 30004
static const u16 sCategoryIcons_Pal[] = INCBIN_U16("graphics/interface/category_icons.gbapal");
static const u32 sCategoryIcons_Gfx[] = INCBIN_U32("graphics/interface/category_icons.4bpp.lz");
static const struct OamData sOamData_CategoryIcons =
{
.size = SPRITE_SIZE(16x16),
.shape = SPRITE_SHAPE(16x16),
.priority = 0,
};
static const struct CompressedSpriteSheet sSpriteSheet_CategoryIcons =
{
.data = sCategoryIcons_Gfx,
.size = 16*16*3/2,
.tag = TAG_CATEGORY_ICONS,
};
static const struct SpritePalette sSpritePal_CategoryIcons =
{
.data = sCategoryIcons_Pal,
.tag = TAG_CATEGORY_ICONS
};
static const union AnimCmd sSpriteAnim_CategoryIcon0[] =
{
ANIMCMD_FRAME(0, 0),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_CategoryIcon1[] =
{
ANIMCMD_FRAME(4, 0),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_CategoryIcon2[] =
{
ANIMCMD_FRAME(8, 0),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_CategoryIcons[] =
{
sSpriteAnim_CategoryIcon0,
sSpriteAnim_CategoryIcon1,
sSpriteAnim_CategoryIcon2,
};
static const struct SpriteTemplate sSpriteTemplate_CategoryIcons =
{
.tileTag = TAG_CATEGORY_ICONS,
.paletteTag = TAG_CATEGORY_ICONS,
.oam = &sOamData_CategoryIcons,
.anims = sSpriteAnimTable_CategoryIcons,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
//Stat bars by DizzyEgg
#define TAG_STAT_BAR 4097
#define TAG_STAT_BAR_BG 4098
@ -4769,7 +4715,7 @@ static void LoadTilesetTilemapHGSS(u8 page)
static u8 ShowCategoryIcon(u32 category)
{
if (sPokedexView->categoryIconSpriteId == 0xFF)
sPokedexView->categoryIconSpriteId = CreateSprite(&sSpriteTemplate_CategoryIcons, 139, 90, 0);
sPokedexView->categoryIconSpriteId = CreateSprite(&gSpriteTemplate_CategoryIcons, 139, 90, 0);
gSprites[sPokedexView->categoryIconSpriteId].invisible = FALSE;
StartSpriteAnim(&gSprites[sPokedexView->categoryIconSpriteId], category);
@ -4912,8 +4858,8 @@ static void Task_LoadStatsScreen(u8 taskId)
CreateTypeIconSprites();
sPokedexView->categoryIconSpriteId = 0xFF;
LoadCompressedPalette(gMoveTypes_Pal, 0x1D0, 0x60);
LoadCompressedSpriteSheet(&sSpriteSheet_CategoryIcons);
LoadSpritePalette(&sSpritePal_CategoryIcons);
LoadCompressedSpriteSheet(&gSpriteSheet_CategoryIcons);
LoadSpritePalette(&gSpritePal_CategoryIcons);
gMain.state++;
break;
case 4:

View file

@ -740,9 +740,6 @@ static const u8 sMovesPPLayout[] = _("{PP}{DYNAMIC 0}/{DYNAMIC 1}");
#define TAG_MON_MARKINGS 30003
#define TAG_CATEGORY_ICONS 30004
static const u16 sCategoryIcons_Pal[] = INCBIN_U16("graphics/interface/category_icons.gbapal");
static const u32 sCategoryIcons_Gfx[] = INCBIN_U32("graphics/interface/category_icons.4bpp.lz");
static const struct OamData sOamData_CategoryIcons =
{
.size = SPRITE_SIZE(16x16),
@ -750,16 +747,16 @@ static const struct OamData sOamData_CategoryIcons =
.priority = 0,
};
static const struct CompressedSpriteSheet sSpriteSheet_CategoryIcons =
const struct CompressedSpriteSheet gSpriteSheet_CategoryIcons =
{
.data = sCategoryIcons_Gfx,
.data = gCategoryIcons_Gfx,
.size = 16*16*3/2,
.tag = TAG_CATEGORY_ICONS,
};
static const struct SpritePalette sSpritePal_CategoryIcons =
const struct SpritePalette gSpritePal_CategoryIcons =
{
.data = sCategoryIcons_Pal,
.data = gCategoryIcons_Pal,
.tag = TAG_CATEGORY_ICONS
};
@ -788,7 +785,7 @@ static const union AnimCmd *const sSpriteAnimTable_CategoryIcons[] =
sSpriteAnim_CategoryIcon2,
};
static const struct SpriteTemplate sSpriteTemplate_CategoryIcons =
const struct SpriteTemplate gSpriteTemplate_CategoryIcons =
{
.tileTag = TAG_CATEGORY_ICONS,
.paletteTag = TAG_CATEGORY_ICONS,
@ -1142,7 +1139,7 @@ static const u16 sMarkings_Pal[] = INCBIN_U16("graphics/summary_screen/markings.
static u8 ShowCategoryIcon(u32 category)
{
if (sMonSummaryScreen->categoryIconSpriteId == 0xFF)
sMonSummaryScreen->categoryIconSpriteId = CreateSprite(&sSpriteTemplate_CategoryIcons, 48, 129, 0);
sMonSummaryScreen->categoryIconSpriteId = CreateSprite(&gSpriteTemplate_CategoryIcons, 48, 129, 0);
gSprites[sMonSummaryScreen->categoryIconSpriteId].invisible = FALSE;
StartSpriteAnim(&gSprites[sMonSummaryScreen->categoryIconSpriteId], category);
@ -1437,8 +1434,8 @@ static bool8 DecompressGraphics(void)
break;
case 12:
LoadCompressedPalette(gMoveTypes_Pal, OBJ_PLTT_ID(13), 3 * PLTT_SIZE_4BPP);
LoadCompressedSpriteSheet(&sSpriteSheet_CategoryIcons);
LoadSpritePalette(&sSpritePal_CategoryIcons);
LoadCompressedSpriteSheet(&gSpriteSheet_CategoryIcons);
LoadSpritePalette(&gSpritePal_CategoryIcons);
sMonSummaryScreen->switchCounter = 0;
return TRUE;
}