diff --git a/data/battle_anims/ball_colors.asm b/data/battle_anims/ball_colors.asm index 0453c14..7eb8d9a 100644 --- a/data/battle_anims/ball_colors.asm +++ b/data/battle_anims/ball_colors.asm @@ -1,15 +1,29 @@ ; colors of balls thrown in battle BallColors: - db MASTER_BALL, PAL_BATTLE_OB_GREEN - db ULTRA_BALL, PAL_BATTLE_OB_YELLOW - db GREAT_BALL, PAL_BATTLE_OB_BLUE - db POKE_BALL, PAL_BATTLE_OB_RED - db HEAVY_BALL, PAL_BATTLE_OB_GRAY - db LEVEL_BALL, PAL_BATTLE_OB_BROWN - db LURE_BALL, PAL_BATTLE_OB_BLUE - db FAST_BALL, PAL_BATTLE_OB_BLUE - db FRIEND_BALL, PAL_BATTLE_OB_YELLOW - db MOON_BALL, PAL_BATTLE_OB_GRAY - db LOVE_BALL, PAL_BATTLE_OB_RED - db -1, PAL_BATTLE_OB_GRAY + db MASTER_BALL + RGB 31,31,31, 20,08,23 + db ULTRA_BALL + RGB 31,31,31, 11,11,12 + db GREAT_BALL + RGB 31,31,31, 09,13,30 + db POKE_BALL + RGB 31,31,31, 30,08,05 + db HEAVY_BALL + RGB 31,31,31, 06,10,12 + db LEVEL_BALL + RGB 31,31,31, 30,24,00 + db LURE_BALL + RGB 31,31,31, 04,14,30 + db FAST_BALL + RGB 31,31,31, 31,16,04 + db FRIEND_BALL + RGB 31,31,31, 04,17,04 + db MOON_BALL + RGB 31,31,31, 07,07,20 + db LOVE_BALL + RGB 31,31,31, 30,11,22 + db PARK_BALL + RGB 31,31,31, 30,10,04 + db -1 ; end + RGB 31,31,31, 16,16,16 diff --git a/engine/battle_anims/functions.asm b/engine/battle_anims/functions.asm index 6e6af6e..3374342 100644 --- a/engine/battle_anims/functions.asm +++ b/engine/battle_anims/functions.asm @@ -431,33 +431,11 @@ BattleAnimFunction_PokeBallBlocked: ret GetBallAnimPal: - ld hl, BallColors - ldh a, [rSVBK] - push af - ld a, BANK(wCurItem) - ldh [rSVBK], a - ld a, [wCurItem] - ld e, a - pop af - ldh [rSVBK], a -.IsInArray: - ld a, [hli] - cp -1 - jr z, .load - cp e - jr z, .load - inc hl - jr .IsInArray - -.load - ld a, [hl] ld hl, BATTLEANIMSTRUCT_PALETTE add hl, bc - ld [hl], a + ld [hl], PAL_BATTLE_OB_RED ret -INCLUDE "data/battle_anims/ball_colors.asm" - BattleAnimFunction_Ember: call BattleAnim_AnonJumptable .anon_dw diff --git a/engine/battle_anims/helpers.asm b/engine/battle_anims/helpers.asm index 90d9fea..f1100d5 100644 --- a/engine/battle_anims/helpers.asm +++ b/engine/battle_anims/helpers.asm @@ -104,6 +104,8 @@ GetBattleAnimOAMPointer: LoadBattleAnimGFX: push hl + cp ANIM_GFX_POKE_BALL + call z, .LoadBallPalette ld l, a ld h, 0 add hl, hl @@ -123,6 +125,53 @@ LoadBattleAnimGFX: pop bc ret +.LoadBallPalette: + ; save the current WRAM bank + ld a, [rSVBK] + push af + ; switch to the WRAM bank of wCurItem so we can read it + ld a, BANK(wCurItem) + ld [rSVBK], a + ; store the current item in b + ld a, [wCurItem] + ld b, a + ; seek for the BallColors entry matching the current item + ld hl, BallColors +.loop + ld a, [hli] + cp b ; did we find the current ball? + jr z, .done + cp -1 ; did we reach the end of the list? + jr z, .done +rept PAL_COLOR_SIZE * 2 + inc hl ; skip over the two RGB colors to the next entry +endr + jr .loop +.done + ; switch to the WRAM bank of wOBPals2 so we can write to it + ld a, BANK(wOBPals2) + ld [rSVBK], a + ; load the RGB colors into the middle two colors of PAL_BATTLE_OB_RED + ld de, wOBPals2 palette PAL_BATTLE_OB_RED color 1 +rept PAL_COLOR_SIZE * 2 - 1 + ld a, [hli] + ld [de], a + inc de +endr + ld a, [hl] + ld [de], a + ; apply the updated colors to the palette RAM + ld a, $1 + ldh [hCGBPalUpdate], a + ; restore the previous WRAM bank + pop af + ld [rSVBK], a + ; restore the graphics index to be loaded + ld a, ANIM_GFX_POKE_BALL + ret + +INCLUDE "data/battle_anims/ball_colors.asm" + INCLUDE "data/battle_anims/framesets.asm" INCLUDE "data/battle_anims/oam.asm"