Color Pokémon pictures shown in overworld - pret/pokecrystal GitHub Wiki

When starting your Pokémon journey and selecting a starter Pokémon, you must've noticed a Pokémon picture appears, showing you how the species looks like, although in grayscale. This tutorial will teach you how to color this picture, showing the species in all its splendor!

Contents

  1. Create function to load Pokémon colors into a background palette
  2. Use newly created function to apply color to Pokémon picture

1. Create function to load Pokémon colors into a background palette

First of all, we need a way to load the Pokémon's colors into one of the eight background palettes used by the game. For this purpose, we can use the palette slot used by texts to load our Pokémon's palette (don't worry, the correct text palette will be loaded the next time you speak to an NPC or object). For this, let's go to engine/gfx/color.asm and create a new function called LoadPokemonPalette. You can place it at the end of the file.

 LoadPokemonPalette:
	ld a, [wCurPartySpecies]
	; hl = palette
	call GetMonPalettePointer
	; load palette into de (set by caller)
	ld bc, PAL_COLOR_SIZE * 2
	ld a, BANK(wBGPals1)
	jp FarCopyWRAM

This function loads the address of the Pokémon's palette pointer into hl and then proceeds to copy two colors into de, which will contain the address of our desired background palette slot.

2. Use newly created function to apply color to Pokémon picture

Now that we have a function that loads Pokémon palettes, we need to use it. Let's edit both Pokepic and ClosePokepic in engine/events/pokepic.asm:

 Pokepic::
	ld hl, PokepicMenuHeader
	call CopyMenuHeader
	call MenuBox
	call UpdateSprites
	call ApplyTilemap
-	ld b, SCGB_POKEPIC
-	call GetSGBLayout
+	ld de, wBGPals1 palette PAL_BG_TEXT color 1
+	farcall LoadPokemonPalette
+	call UpdateTimePals
	xor a
	ldh [hBGMapMode], a
	ld a, [wCurPartySpecies]
	ld [wCurSpecies], a
	call GetBaseData
	ld de, vTiles1
	predef GetMonFrontpic
	ld a, [wMenuBorderTopCoord]
	inc a
	ld b, a
	ld a, [wMenuBorderLeftCoord]
	inc a
	ld c, a
	call Coord2Tile
	ld a, $80
	ldh [hGraphicStartTile], a
	lb bc, 7, 7
	predef PlaceGraphic
	call WaitBGMap
	ret

 ClosePokepic::
	ld hl, PokepicMenuHeader
	call CopyMenuHeader
	call ClearMenuBoxInterior
	call WaitBGMap
	call GetMemSGBLayout
	xor a
	ldh [hBGMapMode], a
	call OverworldTextModeSwitch
-	call ApplyTilemap
+	call CopyTilemapAtOnce
	call UpdateSprites
	call LoadStandardFont
	ret

Pokepic opens the picture and loads the Pokémon's sprite (and now colors!), while ClosePokePic, as the name suggests, closes it. We've edited Pokepic to load in de the location of the background palette slot we want to use and load the species's colors into it. ClosePokepic only had a small edit to directly use CopyTilemapAtOnce instead of calling ApplyTilemap to avoid a graphical glitch that might happen after closing the picture.

And that's it! Now all Pokémon pictures will feature the normal palette of a Pokémon. If you wish to load shiny palettes, it'll be left as an exercise for the reader.

Cyndaquil Totodile Chikorita