diff --git a/include/constants/battle.h b/include/constants/battle.h index 2534ade4b..d87a800e2 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -358,4 +358,7 @@ // Flag for BattlePutTextOnWindow. Never set #define B_WIN_COPYTOVRAM (1 << 7) +// Indicator for the party summary bar to display an empty slot. +#define HP_EMPTY_SLOT 0xFFFF + #endif // GUARD_CONSTANTS_BATTLE_H diff --git a/include/strings.h b/include/strings.h index 7317f8aac..845e96a8c 100644 --- a/include/strings.h +++ b/include/strings.h @@ -611,6 +611,10 @@ extern const u8 gText_PlayersBattleResults[]; extern const u8 gText_WinLoseDraw[]; extern const u8 gText_ColorTransparent[]; extern const u8 gText_Slash[]; +extern const u8 gText_HealthboxNickname[]; +extern const u8 gText_HealthboxGender_None[]; +extern const u8 gText_HealthboxGender_Male[]; +extern const u8 gText_HealthboxGender_Female[]; extern const u8 gText_99TimesPlus[]; extern const u8 gText_1MinutePlus[]; diff --git a/src/battle_interface.c b/src/battle_interface.c index 17497cb2f..c1307da76 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -9,7 +9,6 @@ #include "string_util.h" #include "text.h" #include "sound.h" -#include "constants/songs.h" #include "decompress.h" #include "task.h" #include "util.h" @@ -20,10 +19,12 @@ #include "international_string_util.h" #include "safari_zone.h" #include "battle_anim.h" -#include "constants/battle_anim.h" -#include "constants/rgb.h" #include "data.h" #include "pokemon_summary_screen.h" +#include "strings.h" +#include "constants/battle_anim.h" +#include "constants/rgb.h" +#include "constants/songs.h" struct TestingBar { @@ -157,15 +158,6 @@ enum HEALTHBOX_GFX_FRAME_END_BAR, }; -// strings -extern const u8 gText_Slash[]; -extern const u8 gText_HighlightDarkGray[]; -extern const u8 gText_DynColor2[]; -extern const u8 gText_DynColor2Male[]; -extern const u8 gText_DynColor1Female[]; - -// this file's functions - static const u8 *GetHealthboxElementGfxPtr(u8 elementId); static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y, u32 bgColor, u32 *windowId); @@ -178,27 +170,26 @@ static void SafariTextIntoHealthboxObject(void *dest, u8 *windowTileData, u32 wi static void HpTextIntoHealthboxObject(void *dest, u8 *windowTileData, u32 windowWidth); static void FillHealthboxObject(void *dest, u32 arg1, u32 arg2); -static void sub_8073E08(u8 taskId); -static void sub_8073F98(u8 taskId); -static void sub_8073E64(u8 taskId); +static void Task_HidePartyStatusSummary_BattleStart_1(u8 taskId); +static void Task_HidePartyStatusSummary_BattleStart_2(u8 taskId); +static void Task_HidePartyStatusSummary_DuringBattle(u8 taskId); static void SpriteCB_HealthBoxOther(struct Sprite *sprite); static void SpriteCB_HealthBar(struct Sprite *sprite); -static void sub_8074158(struct Sprite *sprite); -static void sub_8074090(struct Sprite *sprite); -static void SpriteCB_StatusSummaryBar(struct Sprite *sprite); -static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite); -static void SpriteCB_StatusSummaryBallsOnSwitchout(struct Sprite *sprite); +static void SpriteCB_StatusSummaryBar_Enter(struct Sprite *sprite); +static void SpriteCB_StatusSummaryBar_Exit(struct Sprite *sprite); +static void SpriteCB_StatusSummaryBalls_Enter(struct Sprite *sprite); +static void SpriteCB_StatusSummaryBalls_Exit(struct Sprite *sprite); +static void SpriteCB_StatusSummaryBalls_OnSwitchout(struct Sprite *sprite); static u8 GetStatusIconForBattlerId(u8 statusElementId, u8 battlerId); static s32 CalcNewBarValue(s32 maxValue, s32 currValue, s32 receivedValue, s32 *arg3, u8 arg4, u16 arg5); static u8 GetScaledExpFraction(s32 currValue, s32 receivedValue, s32 maxValue, u8 scale); static void MoveBattleBarGraphically(u8 battlerId, u8 whichBar); static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *currValue, u8 *arg4, u8 scale); -static void sub_8074F88(struct TestingBar *barInfo, s32 *arg1, u16 *arg2); +static void Debug_TestHealthBar_Helper(struct TestingBar *barInfo, s32 *arg1, u16 *arg2); -// const rom data -static const struct OamData sUnknown_0832C138 = +static const struct OamData sOamData_64x32 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -220,7 +211,7 @@ static const struct SpriteTemplate sHealthboxPlayerSpriteTemplates[2] = { .tileTag = TAG_HEALTHBOX_PLAYER1_TILE, .paletteTag = TAG_HEALTHBOX_PAL, - .oam = &sUnknown_0832C138, + .oam = &sOamData_64x32, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -229,7 +220,7 @@ static const struct SpriteTemplate sHealthboxPlayerSpriteTemplates[2] = { .tileTag = TAG_HEALTHBOX_PLAYER2_TILE, .paletteTag = TAG_HEALTHBOX_PAL, - .oam = &sUnknown_0832C138, + .oam = &sOamData_64x32, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -242,7 +233,7 @@ static const struct SpriteTemplate sHealthboxOpponentSpriteTemplates[2] = { .tileTag = TAG_HEALTHBOX_OPPONENT1_TILE, .paletteTag = TAG_HEALTHBOX_PAL, - .oam = &sUnknown_0832C138, + .oam = &sOamData_64x32, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -251,7 +242,7 @@ static const struct SpriteTemplate sHealthboxOpponentSpriteTemplates[2] = { .tileTag = TAG_HEALTHBOX_OPPONENT2_TILE, .paletteTag = TAG_HEALTHBOX_PAL, - .oam = &sUnknown_0832C138, + .oam = &sOamData_64x32, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -263,7 +254,7 @@ static const struct SpriteTemplate sHealthboxSafariSpriteTemplate = { .tileTag = TAG_HEALTHBOX_SAFARI_TILE, .paletteTag = TAG_HEALTHBOX_PAL, - .oam = &sUnknown_0832C138, + .oam = &sOamData_64x32, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -327,7 +318,7 @@ static const struct SpriteTemplate sHealthbarSpriteTemplates[MAX_BATTLERS_COUNT] } }; -static const struct Subsprite sUnknown_0832C220[] = +static const struct Subsprite sUnused_Subsprites_0[] = { { .x = DISPLAY_WIDTH, @@ -371,7 +362,7 @@ static const struct Subsprite sUnknown_0832C220[] = } }; -static const struct Subsprite sUnknown_0832C234[] = +static const struct Subsprite sUnused_Subsprites_2[] = { { .x = DISPLAY_WIDTH, @@ -415,7 +406,7 @@ static const struct Subsprite sUnknown_0832C234[] = } }; -static const struct Subsprite sUnknown_0832C248[] = +static const struct Subsprite sUnused_Subsprites_1[] = { { .x = DISPLAY_WIDTH, @@ -435,7 +426,7 @@ static const struct Subsprite sUnknown_0832C248[] = } }; -static const struct Subsprite sUnknown_0832C250[] = +static const struct Subsprite sUnused_Subsprites_3[] = { { .x = DISPLAY_WIDTH, @@ -455,7 +446,7 @@ static const struct Subsprite sUnknown_0832C250[] = } }; -static const struct Subsprite sUnknown_0832C258[] = +static const struct Subsprite sHealthBar_Subsprites_Player[] = { { .x = DISPLAY_WIDTH, @@ -475,7 +466,7 @@ static const struct Subsprite sUnknown_0832C258[] = } }; -static const struct Subsprite sUnknown_0832C260[] = +static const struct Subsprite sHealthBar_Subsprites_Opponent[] = { { .x = DISPLAY_WIDTH, @@ -503,25 +494,24 @@ static const struct Subsprite sUnknown_0832C260[] = } }; -// unused subsprite table -static const struct SubspriteTable sUnknown_0832C26C[] = +static const struct SubspriteTable sUnused_SubspriteTable[] = { - {ARRAY_COUNT(sUnknown_0832C220), sUnknown_0832C220}, - {ARRAY_COUNT(sUnknown_0832C248), sUnknown_0832C248}, - {ARRAY_COUNT(sUnknown_0832C234), sUnknown_0832C234}, - {ARRAY_COUNT(sUnknown_0832C250), sUnknown_0832C250} + {ARRAY_COUNT(sUnused_Subsprites_0), sUnused_Subsprites_0}, + {ARRAY_COUNT(sUnused_Subsprites_1), sUnused_Subsprites_1}, + {ARRAY_COUNT(sUnused_Subsprites_2), sUnused_Subsprites_2}, + {ARRAY_COUNT(sUnused_Subsprites_3), sUnused_Subsprites_3} }; -static const struct SubspriteTable sUnknown_0832C28C[] = +static const struct SubspriteTable sHealthBar_SubspriteTables[] = { - {ARRAY_COUNT(sUnknown_0832C258), sUnknown_0832C258}, - {ARRAY_COUNT(sUnknown_0832C260), sUnknown_0832C260} + [B_SIDE_PLAYER] = {ARRAY_COUNT(sHealthBar_Subsprites_Player), sHealthBar_Subsprites_Player}, + [B_SIDE_OPPONENT] = {ARRAY_COUNT(sHealthBar_Subsprites_Opponent), sHealthBar_Subsprites_Opponent} }; -static const struct Subsprite sStatusSummaryBar_Subsprites_0[] = +static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] = { { - .x = 160, + .x = 32 * 5, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -529,7 +519,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_0[] = .priority = 1 }, { - .x = 192, + .x = 32 * 6, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -537,7 +527,7 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_0[] = .priority = 1 }, { - .x = 224, + .x = 32 * 7, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -554,10 +544,10 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_0[] = } }; -static const struct Subsprite sUnknown_0832C2AC[] = +static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] = { { - .x = 160, + .x = 32 * 5, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -565,7 +555,7 @@ static const struct Subsprite sUnknown_0832C2AC[] = .priority = 1 }, { - .x = 192, + .x = 32 * 6, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -573,7 +563,7 @@ static const struct Subsprite sUnknown_0832C2AC[] = .priority = 1 }, { - .x = 224, + .x = 32 * 7, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -581,7 +571,7 @@ static const struct Subsprite sUnknown_0832C2AC[] = .priority = 1 }, { - .x = 0, + .x = 32 * 0, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -589,7 +579,7 @@ static const struct Subsprite sUnknown_0832C2AC[] = .priority = 1 }, { - .x = 32, + .x = 32 * 1, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -597,7 +587,7 @@ static const struct Subsprite sUnknown_0832C2AC[] = .priority = 1 }, { - .x = 64, + .x = 32 * 2, .y = 0, .shape = SPRITE_SHAPE(32x8), .size = SPRITE_SIZE(32x8), @@ -606,14 +596,14 @@ static const struct Subsprite sUnknown_0832C2AC[] = } }; -static const struct SubspriteTable sStatusSummaryBar_SubspriteTable[] = +static const struct SubspriteTable sStatusSummaryBar_SubspriteTable_Enter[] = { - {ARRAY_COUNT(sStatusSummaryBar_Subsprites_0), sStatusSummaryBar_Subsprites_0} + {ARRAY_COUNT(sStatusSummaryBar_Subsprites_Enter), sStatusSummaryBar_Subsprites_Enter} }; -static const struct SubspriteTable sUnknown_0832C2CC[] = +static const struct SubspriteTable sStatusSummaryBar_SubspriteTable_Exit[] = { - {ARRAY_COUNT(sUnknown_0832C2AC), sUnknown_0832C2AC} + {ARRAY_COUNT(sStatusSummaryBar_Subsprites_Exit), sStatusSummaryBar_Subsprites_Exit} }; // unused unknown image @@ -676,23 +666,23 @@ static const struct OamData sOamData_StatusSummaryBalls = static const struct SpriteTemplate sStatusSummaryBarSpriteTemplates[2] = { - { + { // Player .tileTag = TAG_STATUS_SUMMARY_BAR_TILE, .paletteTag = TAG_STATUS_SUMMARY_BAR_PAL, - .oam = &sUnknown_0832C138, + .oam = &sOamData_64x32, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_StatusSummaryBar + .callback = SpriteCB_StatusSummaryBar_Enter }, - { + { // Opponent .tileTag = TAG_STATUS_SUMMARY_BAR_TILE, .paletteTag = TAG_STATUS_SUMMARY_BAR_PAL, - .oam = &sUnknown_0832C138, + .oam = &sOamData_64x32, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_StatusSummaryBar + .callback = SpriteCB_StatusSummaryBar_Enter } }; @@ -705,7 +695,7 @@ static const struct SpriteTemplate sStatusSummaryBallsSpriteTemplates[2] = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_StatusSummaryBallsOnBattleStart + .callback = SpriteCB_StatusSummaryBalls_Enter }, { .tileTag = TAG_STATUS_SUMMARY_BALLS_TILE, @@ -714,7 +704,7 @@ static const struct SpriteTemplate sStatusSummaryBallsSpriteTemplates[2] = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_StatusSummaryBallsOnBattleStart + .callback = SpriteCB_StatusSummaryBalls_Enter } }; @@ -739,23 +729,28 @@ static const u16 sStatusIconColors[] = [PAL_STATUS_BRN] = RGB(28, 14, 10), }; -static const struct WindowTemplate sHealthboxWindowTemplate = {0, 0, 0, 8, 2, 0, 0}; // width = 8, height = 2 - -// code +static const struct WindowTemplate sHealthboxWindowTemplate = { + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 0, + .width = 8, + .height = 2, + .paletteNum = 0, + .baseBlock = 0 +}; static s32 DummiedOutFunction(s16 unused1, s16 unused2, s32 unused3) { return 9; } -void sub_8072308(s16 number, u16 *dest, bool8 unk) + +static void Debug_DrawNumber(s16 number, u16 *dest, bool8 unk) { s8 i, j; u8 buff[4]; for (i = 0; i < 4; i++) - { buff[i] = 0; - } for (i = 3; ; i--) { @@ -767,9 +762,8 @@ void sub_8072308(s16 number, u16 *dest, bool8 unk) else { for (; i > -1; i--) - { buff[i] = 0xFF; - } + if (buff[3] == 0xFF) buff[3] = 0; break; @@ -819,12 +813,12 @@ void sub_8072308(s16 number, u16 *dest, bool8 unk) } } - -void sub_80724A8(s16 arg0, s16 arg1, u16 *arg2) +// Unused +static void Debug_DrawNumberPair(s16 number1, s16 number2, u16 *arg2) { arg2[4] = 0x1E; - sub_8072308(arg1, arg2, 0); - sub_8072308(arg0, arg2 + 5, 1); + Debug_DrawNumber(number2, arg2, 0); + Debug_DrawNumber(number1, arg2 + 5, 1); } // Because the healthbox is too large to fit into one sprite, it is divided into two sprites. @@ -910,7 +904,7 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) healthbarSpriteId = CreateSpriteAtEnd(&sHealthbarSpriteTemplates[gBattlerPositions[battlerId]], 140, 60, 0); healthBarSpritePtr = &gSprites[healthbarSpriteId]; - SetSubspriteTables(healthBarSpritePtr, &sUnknown_0832C28C[GetBattlerSide(battlerId)]); + SetSubspriteTables(healthBarSpritePtr, &sHealthBar_SubspriteTables[GetBattlerSide(battlerId)]); healthBarSpritePtr->subspriteMode = SUBSPRITES_IGNORE_PRIORITY; healthBarSpritePtr->oam.priority = 1; @@ -1299,7 +1293,7 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon) barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBattlerPosition(gSprites[healthboxSpriteId].hMain_Battler) * 384)]; var = 5; nature = GetNature(mon); - StringCopy(text + 6, gNatureNamePointers[nature]); + StringCopy(&text[6], gNatureNamePointers[nature]); RenderTextHandleBold(barFontGfx, FONT_BOLD, text); for (j = 6, i = 0; i < var; i++, j++) @@ -1328,8 +1322,8 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon) } healthBarSpriteId = gSprites[healthboxSpriteId].hMain_HealthBarSpriteId; - ConvertIntToDecimalStringN(text + 6, gBattleStruct->safariCatchFactor, STR_CONV_MODE_RIGHT_ALIGN, 2); - ConvertIntToDecimalStringN(text + 9, gBattleStruct->safariEscapeFactor, STR_CONV_MODE_RIGHT_ALIGN, 2); + ConvertIntToDecimalStringN(&text[6], gBattleStruct->safariCatchFactor, STR_CONV_MODE_RIGHT_ALIGN, 2); + ConvertIntToDecimalStringN(&text[9], gBattleStruct->safariEscapeFactor, STR_CONV_MODE_RIGHT_ALIGN, 2); text[5] = CHAR_SPACE; text[8] = CHAR_SLASH; RenderTextHandleBold(gMonSpritesGfxPtr->barFontGfx, FONT_BOLD, text); @@ -1424,7 +1418,7 @@ void SwapHpBarsWithHpText(void) #define tSummaryBarSpriteId data[1] #define tBallIconSpriteId(n) data[3 + n] #define tIsBattleStart data[10] -#define tData15 data[15] +#define tBlend data[15] u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart) { @@ -1471,7 +1465,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, LoadSpritePalette(&sStatusSummaryBallsSpritePal); summaryBarSpriteId = CreateSprite(&sStatusSummaryBarSpriteTemplates[isOpponent], bar_X, bar_Y, 10); - SetSubspriteTables(&gSprites[summaryBarSpriteId], sStatusSummaryBar_SubspriteTable); + SetSubspriteTables(&gSprites[summaryBarSpriteId], sStatusSummaryBar_SubspriteTable_Enter); gSprites[summaryBarSpriteId].x2 = bar_pos2_X; gSprites[summaryBarSpriteId].data[0] = bar_data0; @@ -1490,7 +1484,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, ballIconSpritesIds[i] = CreateSpriteAtEnd(&sStatusSummaryBallsSpriteTemplates[isOpponent], bar_X, bar_Y - 4, 9); if (!isBattleStart) - gSprites[ballIconSpritesIds[i]].callback = SpriteCB_StatusSummaryBallsOnSwitchout; + gSprites[ballIconSpritesIds[i]].callback = SpriteCB_StatusSummaryBalls_OnSwitchout; if (!isOpponent) { @@ -1522,42 +1516,49 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, { for (i = 0; i < PARTY_SIZE; i++) { - if (partyInfo[i].hp == 0xFFFF) // empty slot or an egg + if (partyInfo[i].hp == HP_EMPTY_SLOT) { + // empty slot or an egg gSprites[ballIconSpritesIds[i]].oam.tileNum += 1; gSprites[ballIconSpritesIds[i]].data[7] = 1; } - else if (partyInfo[i].hp == 0) // fainted mon + else if (partyInfo[i].hp == 0) { + // fainted mon gSprites[ballIconSpritesIds[i]].oam.tileNum += 3; } - else if (partyInfo[i].status != 0) // mon with major status + else if (partyInfo[i].status != 0) { + // mon with major status gSprites[ballIconSpritesIds[i]].oam.tileNum += 2; } } } else { - for (i = 0, var = 5, j = 0; j < PARTY_SIZE; j++) + for (i = 0, var = PARTY_SIZE - 1, j = 0; j < PARTY_SIZE; j++) { - if (partyInfo[j].hp == 0xFFFF) // empty slot or an egg + if (partyInfo[j].hp == HP_EMPTY_SLOT) { + // empty slot or an egg gSprites[ballIconSpritesIds[var]].oam.tileNum += 1; gSprites[ballIconSpritesIds[var]].data[7] = 1; var--; continue; } - else if (partyInfo[j].hp == 0) // fainted mon + else if (partyInfo[j].hp == 0) { + // fainted mon gSprites[ballIconSpritesIds[i]].oam.tileNum += 3; } else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostPlayerMons & gBitTable[j]) { + // fainted arena mon gSprites[ballIconSpritesIds[i]].oam.tileNum += 3; } - else if (partyInfo[j].status != 0) // mon with major status + else if (partyInfo[j].status != 0) { + // mon with primary status gSprites[ballIconSpritesIds[i]].oam.tileNum += 2; } i++; @@ -1568,19 +1569,22 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, { if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS)) { - for (var = 5, i = 0; i < PARTY_SIZE; i++) + for (var = PARTY_SIZE - 1, i = 0; i < PARTY_SIZE; i++) { - if (partyInfo[i].hp == 0xFFFF) // empty slot or an egg + if (partyInfo[i].hp == HP_EMPTY_SLOT) { + // empty slot or an egg gSprites[ballIconSpritesIds[var]].oam.tileNum += 1; gSprites[ballIconSpritesIds[var]].data[7] = 1; } - else if (partyInfo[i].hp == 0) // fainted mon + else if (partyInfo[i].hp == 0) { + // fainted mon gSprites[ballIconSpritesIds[var]].oam.tileNum += 3; } - else if (partyInfo[i].status != 0) // mon with major status + else if (partyInfo[i].status != 0) { + // mon with primary status gSprites[ballIconSpritesIds[var]].oam.tileNum += 2; } var--; @@ -1590,24 +1594,28 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, { for (var = 0, i = 0, j = 0; j < PARTY_SIZE; j++) { - if (partyInfo[j].hp == 0xFFFF) // empty slot or an egg + if (partyInfo[j].hp == HP_EMPTY_SLOT) { + // empty slot or an egg gSprites[ballIconSpritesIds[i]].oam.tileNum += 1; gSprites[ballIconSpritesIds[i]].data[7] = 1; i++; continue; } - else if (partyInfo[j].hp == 0) // fainted mon + else if (partyInfo[j].hp == 0) { - gSprites[ballIconSpritesIds[5 - var]].oam.tileNum += 3; + // fainted mon + gSprites[ballIconSpritesIds[PARTY_SIZE - 1 - var]].oam.tileNum += 3; } - else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostOpponentMons & gBitTable[j]) // hmm...? + else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaLostOpponentMons & gBitTable[j]) { - gSprites[ballIconSpritesIds[5 - var]].oam.tileNum += 3; + // fainted arena mon + gSprites[ballIconSpritesIds[PARTY_SIZE - 1 - var]].oam.tileNum += 3; } - else if (partyInfo[j].status != 0) // mon with major status + else if (partyInfo[j].status != 0) { - gSprites[ballIconSpritesIds[5 - var]].oam.tileNum += 2; + // mon with primary status + gSprites[ballIconSpritesIds[PARTY_SIZE - 1 - var]].oam.tileNum += 2; } var++; } @@ -1632,6 +1640,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, return taskId; } +// Slide the party summary tray back offscreen void Task_HidePartyStatusSummary(u8 taskId) { u8 ballIconSpriteIds[PARTY_SIZE]; @@ -1650,7 +1659,7 @@ void Task_HidePartyStatusSummary(u8 taskId) SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); - gTasks[taskId].tData15 = 16; + gTasks[taskId].tBlend = 16; for (i = 0; i < PARTY_SIZE; i++) gSprites[ballIconSpriteIds[i]].oam.objMode = ST_OAM_OBJ_BLEND; @@ -1663,51 +1672,51 @@ void Task_HidePartyStatusSummary(u8 taskId) { if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) { - gSprites[ballIconSpriteIds[5 - i]].data[1] = 7 * i; - gSprites[ballIconSpriteIds[5 - i]].data[3] = 0; - gSprites[ballIconSpriteIds[5 - i]].data[4] = 0; - gSprites[ballIconSpriteIds[5 - i]].callback = sub_8074158; + gSprites[ballIconSpriteIds[PARTY_SIZE - 1 - i]].data[1] = 7 * i; + gSprites[ballIconSpriteIds[PARTY_SIZE - 1 - i]].data[3] = 0; + gSprites[ballIconSpriteIds[PARTY_SIZE - 1 - i]].data[4] = 0; + gSprites[ballIconSpriteIds[PARTY_SIZE - 1 - i]].callback = SpriteCB_StatusSummaryBalls_Exit; } else { gSprites[ballIconSpriteIds[i]].data[1] = 7 * i; gSprites[ballIconSpriteIds[i]].data[3] = 0; gSprites[ballIconSpriteIds[i]].data[4] = 0; - gSprites[ballIconSpriteIds[i]].callback = sub_8074158; + gSprites[ballIconSpriteIds[i]].callback = SpriteCB_StatusSummaryBalls_Exit; } } gSprites[summaryBarSpriteId].data[0] /= 2; gSprites[summaryBarSpriteId].data[1] = 0; - gSprites[summaryBarSpriteId].callback = sub_8074090; - SetSubspriteTables(&gSprites[summaryBarSpriteId], sUnknown_0832C2CC); - gTasks[taskId].func = sub_8073E08; + gSprites[summaryBarSpriteId].callback = SpriteCB_StatusSummaryBar_Exit; + SetSubspriteTables(&gSprites[summaryBarSpriteId], sStatusSummaryBar_SubspriteTable_Exit); + gTasks[taskId].func = Task_HidePartyStatusSummary_BattleStart_1; } else { - gTasks[taskId].func = sub_8073F98; + gTasks[taskId].func = Task_HidePartyStatusSummary_DuringBattle; } } -static void sub_8073E08(u8 taskId) +static void Task_HidePartyStatusSummary_BattleStart_1(u8 taskId) { if ((gTasks[taskId].data[11]++ % 2) == 0) { - if (--gTasks[taskId].tData15 < 0) + if (--gTasks[taskId].tBlend < 0) return; - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[15], 16 - gTasks[taskId].data[15])); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].tBlend, 16 - gTasks[taskId].tBlend)); } - if (gTasks[taskId].tData15 == 0) - gTasks[taskId].func = sub_8073E64; + if (gTasks[taskId].tBlend == 0) + gTasks[taskId].func = Task_HidePartyStatusSummary_BattleStart_2; } -static void sub_8073E64(u8 taskId) +static void Task_HidePartyStatusSummary_BattleStart_2(u8 taskId) { u8 ballIconSpriteIds[PARTY_SIZE]; s32 i; u8 battlerId = gTasks[taskId].tBattler; - if (--gTasks[taskId].tData15 == -1) + if (--gTasks[taskId].tBlend == -1) { u8 summaryBarSpriteId = gTasks[taskId].tSummaryBarSpriteId; @@ -1731,7 +1740,7 @@ static void sub_8073E64(u8 taskId) for (i = 1; i < PARTY_SIZE; i++) DestroySprite(&gSprites[ballIconSpriteIds[i]]); } - else if (gTasks[taskId].tData15 == -3) + else if (gTasks[taskId].tBlend == -3) { gBattleSpritesDataPtr->healthBoxesData[battlerId].partyStatusSummaryShown = 0; SetGpuReg(REG_OFFSET_BLDCNT, 0); @@ -1740,17 +1749,17 @@ static void sub_8073E64(u8 taskId) } } -static void sub_8073F98(u8 taskId) +static void Task_HidePartyStatusSummary_DuringBattle(u8 taskId) { u8 ballIconSpriteIds[PARTY_SIZE]; s32 i; u8 battlerId = gTasks[taskId].tBattler; - if (--gTasks[taskId].tData15 >= 0) + if (--gTasks[taskId].tBlend >= 0) { - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[15], 16 - gTasks[taskId].data[15])); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].tBlend, 16 - gTasks[taskId].tBlend)); } - else if (gTasks[taskId].tData15 == -1) + else if (gTasks[taskId].tBlend == -1) { u8 summaryBarSpriteId = gTasks[taskId].tSummaryBarSpriteId; @@ -1763,7 +1772,7 @@ static void sub_8073F98(u8 taskId) for (i = 1; i < PARTY_SIZE; i++) DestroySprite(&gSprites[ballIconSpriteIds[i]]); } - else if (gTasks[taskId].tData15 == -3) + else if (gTasks[taskId].tBlend == -3) { gBattleSpritesDataPtr->healthBoxesData[battlerId].partyStatusSummaryShown = 0; SetGpuReg(REG_OFFSET_BLDCNT, 0); @@ -1776,15 +1785,15 @@ static void sub_8073F98(u8 taskId) #undef tSummaryBarSpriteId #undef tBallIconSpriteId #undef tIsBattleStart -#undef tData15 +#undef tBlend -static void SpriteCB_StatusSummaryBar(struct Sprite *sprite) +static void SpriteCB_StatusSummaryBar_Enter(struct Sprite *sprite) { if (sprite->x2 != 0) sprite->x2 += sprite->data[0]; } -static void sub_8074090(struct Sprite *sprite) +static void SpriteCB_StatusSummaryBar_Exit(struct Sprite *sprite) { sprite->data[1] += 32; if (sprite->data[0] > 0) @@ -1794,7 +1803,7 @@ static void sub_8074090(struct Sprite *sprite) sprite->data[1] &= 0xF; } -static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite) +static void SpriteCB_StatusSummaryBalls_Enter(struct Sprite *sprite) { u8 var1; u16 var2; @@ -1839,7 +1848,7 @@ static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite) } } -static void sub_8074158(struct Sprite *sprite) +static void SpriteCB_StatusSummaryBalls_Exit(struct Sprite *sprite) { u8 var1; u16 var2; @@ -1865,7 +1874,7 @@ static void sub_8074158(struct Sprite *sprite) } } -static void SpriteCB_StatusSummaryBallsOnSwitchout(struct Sprite *sprite) +static void SpriteCB_StatusSummaryBalls_OnSwitchout(struct Sprite *sprite) { u8 barSpriteId = sprite->data[0]; @@ -1882,7 +1891,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon) u16 species; u8 gender; - StringCopy(gDisplayedStringBattle, gText_HighlightDarkGray); + StringCopy(gDisplayedStringBattle, gText_HealthboxNickname); GetMonData(mon, MON_DATA_NICKNAME, nickname); StringGetEnd10(nickname); ptr = StringAppend(gDisplayedStringBattle, nickname); @@ -1898,15 +1907,15 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon) switch (gender) { default: - StringCopy(ptr, gText_DynColor2); + StringCopy(ptr, gText_HealthboxGender_None); windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(gDisplayedStringBattle, 0, 3, 2, &windowId); break; case MON_MALE: - StringCopy(ptr, gText_DynColor2Male); + StringCopy(ptr, gText_HealthboxGender_Male); windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(gDisplayedStringBattle, 0, 3, 2, &windowId); break; case MON_FEMALE: - StringCopy(ptr, gText_DynColor1Female); + StringCopy(ptr, gText_HealthboxGender_Female); windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(gDisplayedStringBattle, 0, 3, 2, &windowId); break; } @@ -2422,8 +2431,9 @@ static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 return filledPixels; } +// Unused // These two functions seem as if they were made for testing the health bar. -static s16 sub_8074F28(struct TestingBar *barInfo, s32 *currValue, u16 *arg2, s32 arg3) +static s16 Debug_TestHealthBar(struct TestingBar *barInfo, s32 *currValue, u16 *arg2, s32 arg3) { s16 ret, var; @@ -2431,7 +2441,7 @@ static s16 sub_8074F28(struct TestingBar *barInfo, s32 *currValue, u16 *arg2, s3 barInfo->oldValue, barInfo->receivedValue, currValue, B_HEALTHBAR_PIXELS / 8, 1); - sub_8074F88(barInfo, currValue, arg2); + Debug_TestHealthBar_Helper(barInfo, currValue, arg2); if (barInfo->maxValue < B_HEALTHBAR_PIXELS) var = *currValue >> 8; @@ -2443,7 +2453,7 @@ static s16 sub_8074F28(struct TestingBar *barInfo, s32 *currValue, u16 *arg2, s3 return ret; } -static void sub_8074F88(struct TestingBar *barInfo, s32 *currValue, u16 *arg2) +static void Debug_TestHealthBar_Helper(struct TestingBar *barInfo, s32 *currValue, u16 *arg2) { u8 sp8[6]; u16 sp10[6]; diff --git a/src/battle_main.c b/src/battle_main.c index ec093ecc7..cca992b43 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3492,7 +3492,7 @@ static void BattleIntroDrawPartySummaryScreens(void) if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) { - hpStatus[i].hp = 0xFFFF; + hpStatus[i].hp = HP_EMPTY_SLOT; hpStatus[i].status = 0; } else @@ -3510,7 +3510,7 @@ static void BattleIntroDrawPartySummaryScreens(void) if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) { - hpStatus[i].hp = 0xFFFF; + hpStatus[i].hp = HP_EMPTY_SLOT; hpStatus[i].status = 0; } else @@ -3536,7 +3536,7 @@ static void BattleIntroDrawPartySummaryScreens(void) if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) { - hpStatus[i].hp = 0xFFFF; + hpStatus[i].hp = HP_EMPTY_SLOT; hpStatus[i].status = 0; } else diff --git a/src/strings.c b/src/strings.c index 3785766ce..a77e67a84 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1242,11 +1242,11 @@ const u8 gText_ContestantsMonWon[] = _("{STR_VAR_1}'s {STR_VAR_2} won!"); const u8 gText_CommunicationStandby[] = _("Communication standby…"); const u8 gText_ColorDarkGray[] = _("{COLOR DARK_GRAY}"); const u8 gText_ColorDynamic6WhiteDynamic5[] = _("{COLOR_HIGHLIGHT_SHADOW DYNAMIC_COLOR6 WHITE DYNAMIC_COLOR5}"); // Unused -const u8 gText_HighlightDarkGray[] = _("{HIGHLIGHT DARK_GRAY}"); +const u8 gText_HealthboxNickname[] = _("{HIGHLIGHT DARK_GRAY}"); const u8 gText_EmptySpace2[] = _(" "); // Unused -const u8 gText_DynColor2Male[] = _("{COLOR DYNAMIC_COLOR2}♂"); -const u8 gText_DynColor1Female[] = _("{COLOR DYNAMIC_COLOR1}♀"); -const u8 gText_DynColor2[] = _("{COLOR DYNAMIC_COLOR2}"); +const u8 gText_HealthboxGender_Male[] = _("{COLOR DYNAMIC_COLOR2}♂"); +const u8 gText_HealthboxGender_Female[] = _("{COLOR DYNAMIC_COLOR1}♀"); +const u8 gText_HealthboxGender_None[] = _("{COLOR DYNAMIC_COLOR2}"); const u8 gText_Upper[] = _("UPPER"); const u8 gText_Lower[] = _("lower"); const u8 gText_Others[] = _("OTHERS");