From add1f4910c03ae86ebfb641d93eace374ae609b0 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 17 Sep 2018 22:40:49 +0200 Subject: [PATCH] Add mega trigger png --- graphics/battle_interface/mega_trigger.png | Bin 0 -> 1005 bytes .../battle_interface/mega_trigger_off.pal | 259 ++++++++++++++++++ graphics/battle_interface/mega_trigger_on.pal | 259 ++++++++++++++++++ include/battle_interface.h | 8 + src/battle_controller_player.c | 11 +- src/battle_interface.c | 104 +++++++ 6 files changed, 636 insertions(+), 5 deletions(-) create mode 100644 graphics/battle_interface/mega_trigger.png create mode 100644 graphics/battle_interface/mega_trigger_off.pal create mode 100644 graphics/battle_interface/mega_trigger_on.pal diff --git a/graphics/battle_interface/mega_trigger.png b/graphics/battle_interface/mega_trigger.png new file mode 100644 index 0000000000000000000000000000000000000000..b189e6529db4348808636d4c8cf24a8dda9fc6fb GIT binary patch literal 1005 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabRA=0U}gyL32~jVqoZO%LqJA?f(65e z1r0L-CRhYG+}LoTW5_hnQKz!X+D8FdXkyv)>mJBeSFc=Vs>@WjIU4MUGiCQ db^HIoxT#xNrKeRo^#Gm6;OXk;vd$@?2>_%CYis}j literal 0 HcmV?d00001 diff --git a/graphics/battle_interface/mega_trigger_off.pal b/graphics/battle_interface/mega_trigger_off.pal new file mode 100644 index 0000000000..643b1c3f44 --- /dev/null +++ b/graphics/battle_interface/mega_trigger_off.pal @@ -0,0 +1,259 @@ +JASC-PAL +0100 +256 +152 184 136 +112 136 120 +80 104 96 +32 32 32 +160 160 160 +80 80 80 +48 48 48 +176 176 176 +160 160 160 +200 200 200 +184 184 184 +216 216 216 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0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 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 diff --git a/graphics/battle_interface/mega_trigger_on.pal b/graphics/battle_interface/mega_trigger_on.pal new file mode 100644 index 0000000000..b3239a17e0 --- /dev/null +++ b/graphics/battle_interface/mega_trigger_on.pal @@ -0,0 +1,259 @@ +JASC-PAL +0100 +256 +152 184 136 +120 144 128 +80 104 96 +32 56 0 +240 160 128 +152 80 144 +56 80 64 +216 176 208 +136 184 224 +184 224 240 +184 208 104 +232 232 104 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0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 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 diff --git a/include/battle_interface.h b/include/battle_interface.h index 3145939d0c..c4ee835f02 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -39,11 +39,16 @@ enum #define TAG_STATUS_SUMMARY_BAR_TILE 0xD70C #define TAG_STATUS_SUMMARY_BALLS_TILE 0xD714 +#define TAG_MEGA_TRIGGER_TILE 0xD777 + #define TAG_HEALTHBOX_PAL 0xD6FF #define TAG_HEALTHBAR_PAL 0xD704 #define TAG_STATUS_SUMMARY_BAR_PAL 0xD710 #define TAG_STATUS_SUMMARY_BALLS_PAL 0xD712 +#define TAG_MEGA_TRIGGER_OFF_PAL 0xD777 +#define TAG_MEGA_TRIGGER_ON_PAL 0xD778 + enum { HEALTHBOX_ALL, @@ -71,6 +76,9 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority); void InitBattlerHealthboxCoords(u8 battler); void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent); void SwapHpBarsWithHpText(void); +void SetMegaTriggerSpritePal(u8 spriteId, u8 palId); +void CreateMegaTriggerSprite(u8 battlerId, u8 palId); +void DestroyMegaTriggerSprite(void); u8 CreatePartyStatusSummarySprites(u8 battler, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart); void Task_HidePartyStatusSummary(u8 taskId); void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elementId); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index cf5b266d27..56c4540415 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -391,6 +391,7 @@ static void HandleInputChooseTarget(void) else BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX); + DestroyMegaTriggerSprite(); PlayerBufferExecCompleted(); } else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59) @@ -547,6 +548,7 @@ static void HandleInputChooseMove(void) BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8)); else BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); + DestroyMegaTriggerSprite(); PlayerBufferExecCompleted(); } else @@ -568,6 +570,7 @@ static void HandleInputChooseMove(void) PlaySE(SE_SELECT); gBattleStruct->playerMegaEvoSelect = FALSE; BtlController_EmitTwoReturnValues(1, 10, 0xFFFF); + DestroyMegaTriggerSprite(); PlayerBufferExecCompleted(); } else if (gMain.newKeys & DPAD_LEFT) @@ -641,7 +644,7 @@ static void HandleInputChooseMove(void) if (gBattleStruct->megaEvoTriggerSpriteId != 0xFF) { gBattleStruct->playerMegaEvoSelect ^= 1; - // StartSpriteAnim(&gSprites[gBattleStruct->megaEvoTriggerSpriteId], gBattleStruct->playerMegaEvoSelect); + SetMegaTriggerSpritePal(gBattleStruct->megaEvoTriggerSpriteId, gBattleStruct->playerMegaEvoSelect); PlaySE(SE_SELECT); } } @@ -2645,10 +2648,8 @@ static void PlayerHandleChooseMove(void) InitMoveSelectionsVarsAndStrings(); gBattlerControllerFuncs[gActiveBattler] = HandleChooseMoveAfterDma3; gBattleStruct->playerMegaEvoSelect = FALSE; - if (CanMegaEvolve(gActiveBattler) && gBattleStruct->megaEvoTriggerSpriteId == 0xFF) - gBattleStruct->megaEvoTriggerSpriteId = CreateSprite(&gDummySpriteTemplate, 100, 100, 0); - else - gBattleStruct->megaEvoTriggerSpriteId = 0xFF; + if (CanMegaEvolve(gActiveBattler)) + CreateMegaTriggerSprite(gActiveBattler, 0); } } diff --git a/src/battle_interface.c b/src/battle_interface.c index 07eac0b88b..d47cb69408 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -197,6 +197,8 @@ static void SpriteCB_StatusSummaryBar(struct Sprite *sprite); static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite); static void SpriteCB_StatusSummaryBallsOnSwitchout(struct Sprite *sprite); +static void SpriteCb_MegaTrigger(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); @@ -558,6 +560,51 @@ static const u16 sStatusIconColors[] = static const struct WindowTemplate sHealthboxWindowTemplate = {0, 0, 0, 8, 2, 0, 0}; // width = 8, height = 2 +static const u8 sMegaTriggerGfx[] = INCBIN_U8("graphics/battle_interface/mega_trigger.4bpp"); +static const u16 sMegaTriggerOnPal[] = INCBIN_U16("graphics/battle_interface/mega_trigger_on.gbapal"); +static const u16 sMegaTriggerOffPal[] = INCBIN_U16("graphics/battle_interface/mega_trigger_off.gbapal"); + +static const struct SpriteSheet sSpriteSheet_MegaTrigger = +{ + sMegaTriggerGfx, sizeof(sMegaTriggerGfx), TAG_MEGA_TRIGGER_TILE +}; +static const struct SpritePalette sSpritePalette_MegaTriggerOn = +{ + sMegaTriggerOnPal, TAG_MEGA_TRIGGER_ON_PAL +}; +static const struct SpritePalette sSpritePalette_MegaTriggerOff = +{ + sMegaTriggerOffPal, TAG_MEGA_TRIGGER_OFF_PAL +}; + +static const struct OamData sOamData_MegaTrigger = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = ST_OAM_SQUARE, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; + +static const struct SpriteTemplate sSpriteTemplate_MegaTrigger = +{ + .tileTag = TAG_MEGA_TRIGGER_TILE, + .paletteTag = TAG_MEGA_TRIGGER_ON_PAL, + .oam = &sOamData_MegaTrigger, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCb_MegaTrigger +}; + // code static s32 DummiedOutFunction(s16 unused1, s16 unused2, s32 unused3) @@ -1484,6 +1531,63 @@ void SwapHpBarsWithHpText(void) } } +// Mega Evolution gfx functions. +void SetMegaTriggerSpritePal(u8 spriteId, u8 palId) +{ + switch (palId) + { + case 0: // off + FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_ON_PAL); + LoadSpritePalette(&sSpritePalette_MegaTriggerOff); + if (spriteId != 0xFF) + gSprites[spriteId].oam.paletteNum = IndexOfSpritePaletteTag(TAG_MEGA_TRIGGER_OFF_PAL); + break; + case 1: // on + FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_OFF_PAL); + LoadSpritePalette(&sSpritePalette_MegaTriggerOn); + if (spriteId != 0xFF) + gSprites[spriteId].oam.paletteNum = IndexOfSpritePaletteTag(TAG_MEGA_TRIGGER_ON_PAL); + break; + } +} + +#define MEGA_TRIGGER_POS_X_DIFF 19 +#define MEGA_TRIGGER_POS_Y_DIFF 1 + +void CreateMegaTriggerSprite(u8 battlerId, u8 palId) +{ + if (GetSpriteTileStartByTag(TAG_MEGA_TRIGGER_TILE) == 0xFFFF) + LoadSpriteSheet(&sSpriteSheet_MegaTrigger); + if (gBattleStruct->megaEvoTriggerSpriteId == 0xFF) + { + gBattleStruct->megaEvoTriggerSpriteId = CreateSprite(&sSpriteTemplate_MegaTrigger, + gSprites[gHealthboxSpriteIds[battlerId]].pos1.x - MEGA_TRIGGER_POS_X_DIFF, + gSprites[gHealthboxSpriteIds[battlerId]].pos1.y - MEGA_TRIGGER_POS_Y_DIFF, 0); + gSprites[gBattleStruct->megaEvoTriggerSpriteId].data[0] = battlerId; + } + + SetMegaTriggerSpritePal(gBattleStruct->megaEvoTriggerSpriteId, palId); +} + +static void SpriteCb_MegaTrigger(struct Sprite *sprite) +{ + sprite->pos1.x = gSprites[gHealthboxSpriteIds[sprite->data[0]]].pos1.x - MEGA_TRIGGER_POS_X_DIFF; + sprite->pos1.y = gSprites[gHealthboxSpriteIds[sprite->data[0]]].pos1.y - MEGA_TRIGGER_POS_Y_DIFF; + + sprite->pos2.x = gSprites[gHealthboxSpriteIds[sprite->data[0]]].pos2.x - MEGA_TRIGGER_POS_X_DIFF; + sprite->pos2.y = gSprites[gHealthboxSpriteIds[sprite->data[0]]].pos2.y - MEGA_TRIGGER_POS_Y_DIFF; +} + +void DestroyMegaTriggerSprite(void) +{ + FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_OFF_PAL); + FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_ON_PAL); + FreeSpriteTilesByTag(TAG_MEGA_TRIGGER_TILE); + if (gBattleStruct->megaEvoTriggerSpriteId != 0xFF) + DestroySprite(&gSprites[gBattleStruct->megaEvoTriggerSpriteId]); + gBattleStruct->megaEvoTriggerSpriteId = 0xFF; +} + #define tBattler data[0] #define tSummaryBarSpriteId data[1] #define tBallIconSpriteId(n) data[3 + n]