Skip to content

Colored trainer card badges

FrenchOrange edited this page Feb 12, 2025 · 19 revisions

This one is a simple upgrade.

Contents

  1. Define the colors
  2. Load the colors
  3. Apply the colors to the badges
  4. Per tile palette assignment
  5. Redesign some badge graphics

1. Define the colors

Create gfx/trainer_card/badges.pal:

+	RGB 31,31,31, 21,21,24, 13,13,16, 00,00,00 ; ZEPHYRBADGE
+	RGB 31,31,31, 31,12,12, 29,00,00, 00,00,00 ; HIVEBADGE
+	RGB 31,31,31, 29,29,29, 27,24,00, 00,00,00 ; PLAINBADGE
+	RGB 31,31,31, 23,22,26, 11,10,23, 00,00,00 ; FOGBADGE
+	RGB 31,31,31, 27,16,08, 12,07,04, 00,00,00 ; STORMBADGE
+	RGB 31,31,31, 23,26,29, 15,19,23, 00,00,00 ; MINERALBADGE
+	RGB 31,31,31, 19,27,30, 00,22,26, 00,00,00 ; GLACIERBADGE
+	RGB 31,31,31, 30,09,05, 05,05,06, 00,00,00 ; RISINGBADGE

2. Load the colors

Edit engine/gfx/cgb_layouts.asm:

 _CGB_TrainerCard:
 	...
-	ld a, PREDEFPAL_CGB_BADGE
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
+	ld hl, .BadgePalettes
+	ld bc, 8 palettes
+	ld a, BANK(wOBPals1)
+	call FarCopyWRAM
 	...
 	ret
+
+.BadgePalettes:
+INCLUDE "gfx/trainer_card/badges.pal"

3. Apply the colors to the badges

Edit engine/menus/trainer_card.asm:

 TrainerCard_JohtoBadgesOAM:
 ; Template OAM data for each badge on the trainer card.
 ; Format:
 	; y, x, palette
 	; cycle 1: face tile, in1 tile, in2 tile, in3 tile
 	; cycle 2: face tile, in1 tile, in2 tile, in3 tile

 	dw wJohtoBadges

 	; Zephyrbadge
 	db $68, $18, 0
 	db $00, $20, $24, $20 | (1 << 7)
 	db $00, $20, $24, $20 | (1 << 7)

 	; Hivebadge
-	db $68, $38, 0
+	db $68, $38, 1
 	...

 	; Plainbadge
-	db $68, $58, 0
+	db $68, $58, 2
 	...

 	; Fogbadge
-	db $68, $78, 0
+	db $68, $78, 3
 	...

 	; Mineralbadge
-	db $80, $38, 0
+	db $80, $38, 5
 	...

 	; Stormbadge
-	db $80, $18, 0
+	db $80, $18, 4
 	...

 	; Glacierbadge
-	db $80, $58, 0
+	db $80, $58, 6
 	...

 	; Risingbadge
 	; X-flips on alternate cycles.
-	db $80, $78, 0
+	db $80, $78, 7
 	...

4. Per-tile palette assignment

This optional step allows for each tile of a given badge to load one of the eight loaded palette slots. This is perfect for the Rainbow badge if one chooses to add a third trainer card page for the Kanto badges. The code for this section was adapted from Polished Crystal.

Edit ram/wram.asm:

	NEXTU
	; trainer card badges
	wTrainerCardBadgeFrameCounter:: db
	wTrainerCardBadgeTileID:: db
-	wTrainerCardBadgeAttributes:: db
+	wTrainerCardBadgePaletteAddr:: dw

Then go back to engine/menus/trainer_card.asm:

.InitRAM:
	...
	ld [hli], a ; wJumptableIndex
	ld [hli], a ; wTrainerCardBadgeFrameCounter
	ld [hli], a ; wTrainerCardBadgeTileID
-	ld [hl], a  ; wTrainerCardBadgeAttributes
+	ld [hl], a  ; wTrainerCardBadgePaletteAddr
	ret

	...	

TrainerCard_Page2_3_OAMUpdate:
	...
	ld a, [hli] ; x
	ld c, a
-	ld a, [hli] ; pal
-	ld [wTrainerCardBadgeAttributes], a
+
+	ld a, h
+	ld [wTrainerCardBadgePaletteAddr], a
+	ld a, l
+	ld [wTrainerCardBadgePaletteAddr + 1], a
+rept 4
+	inc hl
+endr
+
	ld a, [wTrainerCardBadgeFrameCounter]
	add l

	...

.skip_badge
-	ld bc, $b ; 3 + 2 * 4
+	ld bc, $e ; 6 + 2 * 4
	add hl, bc
	pop bc
	dec b
	jr nz, .loop
	ret

	...

-	ld a, [wTrainerCardBadgeAttributes]
+	push hl
+	push bc
+	ld a, [wTrainerCardBadgePaletteAddr]
+	ld h, a
+	ld a, [wTrainerCardBadgePaletteAddr + 1]
+	ld l, a
+	ld a, [hli]
+	ld b, a
+	ld a, h
+	ld [wTrainerCardBadgePaletteAddr], a
+	ld a, l
+	ld [wTrainerCardBadgePaletteAddr + 1], a
+	ld a, b
+	pop bc
+	pop hl

	add [hl]
	ld [de], a ; attributes
	inc hl
	inc de
	jr .loop2

	...

TrainerCard_JohtoBadgesOAM:
; Template OAM data for each badge on the trainer card.
; Format:
-	; y, x, palette
+	; y, x, palette1, palette2, palette3, palette4
	; cycle 1: face tile, in1 tile, in2 tile, in3 tile
	; cycle 2: face tile, in1 tile, in2 tile, in3 tile

	dw wJohtoBadges

	; Zephyrbadge
-	db $68, $18, 0
+	db $68, $18, 0, 0, 0, 0
	...

	; Hivebadge
-	db $68, $38, 0
+	db $68, $18, 1, 1, 1, 1
	...

	; Plainbadge
-	db $68, $58, 2
+	db $68, $58, 2, 2, 2, 2
	...

	; Fogbadge
-	db $68, $78, 3
+	db $68, $78, 3, 3, 3, 3
	...

	; Mineralbadge
-	db $80, $38, 5
+	db $80, $38, 5, 5, 5, 5
	...

	; Stormbadge
-	db $80, $18, 4
+	db $80, $18, 4, 4, 4, 4
	...

	; Glacierbadge
-	db $80, $58, 6
+	db $80, $58, 6, 6, 6, 6
	...

	; Risingbadge
	; X-flips on alternate cycles.
-	db $80, $78, 7
+	db $80, $78, 7, 7, 7, 7
	...

5. Redesign some badge graphics

Edit gfx/trainer_card/badges.png:

gfx/trainer_card/badges.png

This changes the Hive Badge, Plain Badge, Fog Badge, and Rising Badge to look better with their new color palettes.

That's it!

Screenshot

Clone this wiki locally