PokemonColors:: ; Normal / Shiny
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_ORANGE, PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_ORANGE, PAL_OW_SILVER
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_PURPLE
	dn PAL_OW_GREEN, PAL_OW_YELLOW
	dn PAL_OW_GREEN, PAL_OW_ORANGE
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_YELLOW, PAL_OW_ORANGE
	dn PAL_OW_BLUE, PAL_OW_YELLOW
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_BROWN, PAL_OW_ORANGE ;10
	dn PAL_OW_BROWN, PAL_OW_ORANGE
	dn PAL_OW_BROWN, PAL_OW_ORANGE
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_BROWN, PAL_OW_ORANGE
	dn PAL_OW_BROWN, PAL_OW_ORANGE
	dn PAL_OW_BROWN, PAL_OW_BROWN
	dn PAL_OW_BROWN, PAL_OW_BROWN
	dn PAL_OW_BROWN, PAL_OW_ORANGE
	dn PAL_OW_ORANGE, PAL_OW_BROWN
	dn PAL_OW_BLUE, PAL_OW_YELLOW ;Shinx
	dn PAL_OW_BLUE, PAL_OW_YELLOW
	dn PAL_OW_BLUE, PAL_OW_YELLOW
	dn PAL_OW_GREEN, PAL_OW_BLUE ;Electrike
	dn PAL_OW_BLUE, PAL_OW_SILVER
	dn PAL_OW_RED, PAL_OW_BLUE ;Snorunt 20
	dn PAL_OW_SILVER, PAL_OW_SILVER
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_RED, PAL_OW_PURPLE ;Volbeat
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_RED, PAL_OW_ORANGE ;Vulpix
	dn PAL_OW_YELLOW, PAL_OW_SILVER
	dn PAL_OW_PURPLE, PAL_OW_PURPLE ;Jigglypuff
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_BLUE, PAL_OW_GREEN ;Zubat
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_SILVER, PAL_OW_SILVER ; Aron
	dn PAL_OW_SILVER, PAL_OW_BLUE
	dn PAL_OW_SILVER, PAL_OW_BLUE
	dn PAL_OW_ORANGE, PAL_OW_RED ;Paras
	dn PAL_OW_ORANGE, PAL_OW_RED
	dn PAL_OW_PURPLE, PAL_OW_PURPLE ;Venonat 30
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_GREEN ;Bronzor
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_PURPLE, PAL_OW_RED ;Skorupi
	dn PAL_OW_PURPLE, PAL_OW_RED
	dn PAL_OW_BLUE, PAL_OW_RED
	dn PAL_OW_BLUE, PAL_OW_RED
	dn PAL_OW_SILVER, PAL_OW_SILVER
	dn PAL_OW_SILVER, PAL_OW_SILVER
	dn PAL_OW_ORANGE, PAL_OW_YELLOW ;Growlithe
	dn PAL_OW_ORANGE, PAL_OW_YELLOW
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_YELLOW, PAL_OW_YELLOW
	dn PAL_OW_BROWN, PAL_OW_BROWN ;40
	dn PAL_OW_BROWN, PAL_OW_RED
	dn PAL_OW_SILVER, PAL_OW_BROWN
	dn PAL_OW_SILVER, PAL_OW_BROWN
	dn PAL_OW_SILVER, PAL_OW_BROWN
	dn PAL_OW_GREEN, PAL_OW_YELLOW
	dn PAL_OW_GREEN, PAL_OW_YELLOW
	dn PAL_OW_GREEN, PAL_OW_BROWN
	dn PAL_OW_BLUE, PAL_OW_PURPLE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BROWN, PAL_OW_YELLOW
	dn PAL_OW_BROWN, PAL_OW_ORANGE
	dn PAL_OW_BROWN, PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_BLUE
	dn PAL_OW_RED, PAL_OW_SILVER
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_PURPLE, PAL_OW_BLUE ;50
	dn PAL_OW_SILVER, PAL_OW_SILVER
	dn PAL_OW_SILVER, PAL_OW_SILVER
	dn PAL_OW_SILVER, PAL_OW_SILVER
	dn PAL_OW_PURPLE, PAL_OW_YELLOW
	dn PAL_OW_PURPLE, PAL_OW_YELLOW
	dn PAL_OW_PURPLE, PAL_OW_ORANGE
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_PURPLE, PAL_OW_RED
	dn PAL_OW_PURPLE, PAL_OW_RED
	dn PAL_OW_SILVER, PAL_OW_BLUE
	dn PAL_OW_SILVER, PAL_OW_BLUE
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_SILVER, PAL_OW_BROWN
	dn PAL_OW_YELLOW, PAL_OW_YELLOW ;60
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_GREEN, PAL_OW_RED
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_YELLOW, PAL_OW_RED
	dn PAL_OW_YELLOW, PAL_OW_RED
	dn PAL_OW_PURPLE, PAL_OW_ORANGE
	dn PAL_OW_BROWN, PAL_OW_ORANGE
	dn PAL_OW_GREEN, PAL_OW_ORANGE
	dn PAL_OW_GREEN, PAL_OW_ORANGE
	dn PAL_OW_BROWN, PAL_OW_GREEN
	dn PAL_OW_BROWN, PAL_OW_GREEN
	dn PAL_OW_BROWN, PAL_OW_GREEN
	dn PAL_OW_PURPLE, PAL_OW_SILVER
	dn PAL_OW_PURPLE, PAL_OW_SILVER
	dn PAL_OW_SILVER, PAL_OW_BROWN
	dn PAL_OW_SILVER, PAL_OW_SILVER ;70
	dn PAL_OW_PURPLE, PAL_OW_GREEN
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_BROWN, PAL_OW_BROWN
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_YELLOW, PAL_OW_ORANGE
	dn PAL_OW_ORANGE, PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_BROWN, PAL_OW_BLUE
	dn PAL_OW_YELLOW, PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_RED
	dn PAL_OW_YELLOW , PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_RED ;80
	dn PAL_OW_ORANGE, PAL_OW_YELLOW
	dn PAL_OW_BLUE, PAL_OW_RED
	dn PAL_OW_SILVER, PAL_OW_PURPLE
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_BROWN, PAL_OW_SILVER
	dn PAL_OW_BLUE, PAL_OW_PURPLE
	dn PAL_OW_YELLOW, PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_RED, PAL_OW_RED
	dn PAL_OW_PURPLE, PAL_OW_GREEN
	dn PAL_OW_GREEN, PAL_OW_PURPLE
	dn PAL_OW_SILVER, PAL_OW_SILVER
	dn PAL_OW_PURPLE, PAL_OW_BROWN
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_BLUE ;90
	dn PAL_OW_YELLOW, PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_RED
	dn PAL_OW_BLUE, PAL_OW_SILVER
	dn PAL_OW_BLUE, PAL_OW_SILVER
	dn PAL_OW_BLUE, PAL_OW_SILVER
	dn PAL_OW_PURPLE, PAL_OW_GREEN
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_YELLOW
	dn PAL_OW_GREEN, PAL_OW_YELLOW
	dn PAL_OW_GREEN, PAL_OW_YELLOW
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_BLUE ;A0
	dn PAL_OW_BROWN, PAL_OW_BROWN
	dn PAL_OW_BROWN, PAL_OW_RED
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_RED, PAL_OW_PURPLE
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_PURPLE
	dn PAL_OW_YELLOW, PAL_OW_YELLOW
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_RED, PAL_OW_RED
	dn PAL_OW_RED, PAL_OW_RED ;B0
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_YELLOW, PAL_OW_BROWN
	dn PAL_OW_PURPLE, PAL_OW_BROWN
	dn PAL_OW_YELLOW, PAL_OW_BROWN
	dn PAL_OW_RED, PAL_OW_RED
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_BLUE, PAL_OW_YELLOW
	dn PAL_OW_YELLOW, PAL_OW_BROWN
	dn PAL_OW_RED, PAL_OW_SILVER
	dn PAL_OW_BLUE, PAL_OW_PURPLE
	dn PAL_OW_BLUE, PAL_OW_PURPLE
	dn PAL_OW_BLUE, PAL_OW_SILVER
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_GREEN, PAL_OW_RED
	dn PAL_OW_GREEN, PAL_OW_RED ;C0
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_PURPLE, PAL_OW_GREEN
	dn PAL_OW_YELLOW, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_PURPLE, PAL_OW_ORANGE
	dn PAL_OW_PURPLE, PAL_OW_YELLOW
	dn PAL_OW_BLUE, PAL_OW_YELLOW
	dn PAL_OW_BLUE, PAL_OW_YELLOW
	dn PAL_OW_BLUE, PAL_OW_BROWN
	dn PAL_OW_PURPLE, PAL_OW_BROWN
	dn PAL_OW_RED, PAL_OW_YELLOW
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_SILVER, PAL_OW_BROWN ;D0
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_SILVER
	dn PAL_OW_RED, PAL_OW_YELLOW
	dn PAL_OW_RED, PAL_OW_GREEN
	dn PAL_OW_BLUE, PAL_OW_YELLOW
	dn PAL_OW_BLUE, PAL_OW_YELLOW
	dn PAL_OW_RED, PAL_OW_PURPLE
	dn PAL_OW_BROWN, PAL_OW_GREEN
	dn PAL_OW_BROWN, PAL_OW_GREEN
	dn PAL_OW_RED, PAL_OW_SILVER
	dn PAL_OW_RED, PAL_OW_PURPLE
	dn PAL_OW_BROWN, PAL_OW_SILVER
	dn PAL_OW_BROWN, PAL_OW_YELLOW
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_BLUE ;E0
	dn PAL_OW_BLUE, PAL_OW_GREEN
	dn PAL_OW_SILVER, PAL_OW_GREEN
	dn PAL_OW_RED, PAL_OW_GREEN
	dn PAL_OW_RED, PAL_OW_BLUE
	dn PAL_OW_RED, PAL_OW_BLUE
	dn PAL_OW_BROWN, PAL_OW_BROWN
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_SILVER, PAL_OW_ORANGE
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_BLUE, PAL_OW_PURPLE
	dn PAL_OW_BROWN, PAL_OW_SILVER
	dn PAL_OW_BROWN, PAL_OW_SILVER
	dn PAL_OW_BROWN, PAL_OW_BROWN
	dn PAL_OW_YELLOW, PAL_OW_YELLOW
	dn PAL_OW_RED, PAL_OW_ORANGE ;F0
	dn PAL_OW_PURPLE, PAL_OW_BLUE
	dn PAL_OW_PURPLE, PAL_OW_PURPLE
	dn PAL_OW_RED, PAL_OW_YELLOW
	dn PAL_OW_BLUE, PAL_OW_PURPLE
	dn PAL_OW_GREEN, PAL_OW_SILVER
	dn PAL_OW_GREEN, PAL_OW_GREEN
	dn PAL_OW_BLUE, PAL_OW_BLUE
	dn PAL_OW_GREEN, PAL_OW_BROWN
	dn PAL_OW_SILVER, PAL_OW_RED
	dn PAL_OW_RED, PAL_OW_ORANGE
	dn PAL_OW_SILVER, PAL_OW_SILVER
	dn PAL_OW_PURPLE, PAL_OW_RED
	dn PAL_OW_YELLOW, PAL_OW_YELLOW
	dn PAL_OW_GREEN, PAL_OW_ORANGE

SetPokemonColor:
	push hl
	push de
	push bc
	push af

	ld a, [wd265]
	ld [wCurPartySpecies], a
	call GetPalette
	ld hl, Sprites + 3
	jr ProcessPokemonColor

SetPokemonColor_NoShiny:
	push hl
	push de
	push bc
	push af

	ld a, [wd265]
	ld [wCurPartySpecies], a
	and a
	call GetPalette_PredeterminedShininess
	ld hl, Sprites + 3
	jr ProcessPokemonColor

LoadPartyColors:
	push hl
	push de
	push bc
	push af

	ld a, [wPartyCount]
	sub c
	ld [wCurPartyMon], a
	ld d, 0
	ld e, a
	ld hl, wPartySpecies
	add hl, de
	ld a, [hl]
	ld [wCurPartySpecies], a
	call GetCurPartySpritePalIndex
	push af

	ld hl, Sprites + 3
	ld a, [wCurPartyMon]
	swap a

	ld d, 0
	ld e, a

	add hl, de
	pop af

ProcessPokemonColor:
	ld c, 4
	ld de, 4

.colorIcon
	ld [hl], a
	add hl, de
	dec c
	jr nz, .colorIcon

	pop af
	pop bc
	pop de
	pop hl
	ret

GetCurPartySpritePalIndex:
; Get pals of wCurPartySpecies using wCurPartyMon to get shininess
	ld a, MON_DVS
	call GetPartyParamLocation
GetPalette::
	callba CheckShininessHL
GetPalette_PredeterminedShininess:
	push af
	ld a, [wCurPartySpecies]
	dec a
	ld c, a
	ld b, 0
	ld hl, PokemonColors
	add hl, bc
	ld e, [hl]
	pop af
	ld a, e
	jr c, .shiny
	swap a
.shiny
	and $f
	ld l, a
	ret

LoadPokemonIconFromMem:
	push hl
	push de
	push bc

	ld hl, TempMonDVs
	call SetPokemonColor
	call LoadIcon
	pop bc
	pop de
	pop hl
	ret

LoadPokemonIconMoveMenu:
	push hl
	push de
	push bc
	ld a, MON_DVS
	call GetPartyParamLocation
	call SetPokemonColor
	call LoadIcon
	pop bc
	pop de
	pop hl
	ret

LoadPokemonIcon:
	push hl
	push de
	push bc

	call SetPokemonColor_NoShiny
	call LoadIcon
	pop bc
	pop de
	pop hl
	ret

LoadPartyIcons:
	call LoadPartyColors
	push hl
	push de
	push bc
	call LoadIcon
	pop bc
	pop de
	pop hl
	ret

LoadIcon: ; 8e849
	ld a, e
	jumptable

.Jumptable: ; 8e854 (23:6854)
	dw Function8e8d5 ; init
	dw Function8e961
	dw Function8e97d
	dw Trade_LoadMonIconGFX
	dw Function8e898
	dw NULL ;dummied out
	dw .GetPartyMenuMonIcon


.GetPartyMenuMonIcon: ; 8e862 (23:6862)
	call InitPartyMenuIcon
	call .GetPartyMonItemGFX
	jp SetPartyMonIconAnimSpeed

.GetPartyMonItemGFX: ; 8e86c (23:686c)
	push bc
	ld a, [hObjectStructIndexBuffer]
	ld hl, PartyMon1Item
	ld bc, PARTYMON_STRUCT_LENGTH
	rst AddNTimes
	pop bc
	ld a, [hl]
	and a
	jr z, .no_item
	push hl
	push bc
	ld d, a
	pop bc
	pop hl
.no_item
	ld a, $4
.got_tile
	ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
	add hl, bc
	ld [hl], a
	ret

Function8e898:
	call Function8e8d5
	ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
	add hl, bc
	ld a, $0
	ld [hl], a
	ld hl, SPRITEANIMSTRUCT_XCOORD
	add hl, bc
	ld a, 9 * 8
	ld [hl], a
	ld hl, SPRITEANIMSTRUCT_YCOORD
	add hl, bc
	ld a, 9 * 8
	ld [hl], a
	ret

Function8e8d5:
	call InitPartyMenuIcon
	call .SpawnItemIcon
	jp SetPartyMonIconAnimSpeed

.SpawnItemIcon
	push bc
	ld a, [hObjectStructIndexBuffer]
	ld hl, PartyMon1Item
	ld bc, PARTYMON_STRUCT_LENGTH
	rst AddNTimes
	pop bc
	ld a, [hl]
	and a
	ret z
	ld a, SPRITE_ANIM_FRAMESET_03
	ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
	add hl, bc
	ld [hl], a
	ret

InitPartyMenuIcon:
	ld a, [wCurIconTile]
	push af
	ld a, [hObjectStructIndexBuffer]
	ld hl, wPartySpecies
	ld e, a
	ld d, $0
	add hl, de
	ld a, [hl]
	ld [CurIcon], a
	call GetMemIconGFX
	ld a, [hObjectStructIndexBuffer]
; y coord
	and $f
	swap a
	add $1c
	ld d, a
; x coord
	ld e, $10
; type is partymon icon
	ld a, SPRITE_ANIM_INDEX_00
	call InitSpriteAnimStruct
	pop af
	ld hl, SPRITEANIMSTRUCT_TILE_ID
	add hl, bc
	ld [hl], a
	ret

SetPartyMonIconAnimSpeed:
	push bc
	ld a, [hObjectStructIndexBuffer]
	ld b, a
	call .getspeed
	ld a, d
	rrca
	rrca
	pop bc
	ld hl, SPRITEANIMSTRUCT_DURATIONOFFSET
	add hl, bc
	ld [hl], a
	ld hl, SPRITEANIMSTRUCT_0D
	add hl, bc
	ld [hl], d
	ret

.getspeed
	callba PlacePartymonHPBar
	jp GetHPPal

Function8e961:
	ld a, [wd265]
	ld [CurIcon], a
	xor a
	call GetIconGFX
	depixel 4, 4, 4, 0
	ld a, SPRITE_ANIM_INDEX_00
	call InitSpriteAnimStruct
	ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
	add hl, bc
	ld [hl], $0
	ret

Function8e97d:
	ld a, [wd265]
	ld [CurIcon], a
	xor a
	call GetIconGFX
	depixel 3, 4, 2, 4
	ld a, SPRITE_ANIM_INDEX_00
	call InitSpriteAnimStruct
	ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
	add hl, bc
	ld [hl], SPRITE_ANIM_SEQ_NULL
	ret

Trade_LoadMonIconGFX:
	ld a, [wd265]
	ld [CurIcon], a
	ld a, $62
	ld [wCurIconTile], a
	jp GetMemIconGFX

GetSpeciesIcon:
; Load species icon into VRAM at tile a
	push de
	ld a, [wd265]
	ld [CurIcon], a
	pop de
	ld a, e
	jp GetIconGFX

FlyFunction_GetMonIcon:
	push de
	ld a, [wd265]
	ld [CurIcon], a
	pop de
	ld a, e
	jp GetIcon

GetMemIconGFX:
	ld a, [wCurIconTile]
GetIconGFX:
	call GetIcon
	ld de, $80 ; 8 tiles
	add hl, de
	ld de, HeldItemIcons
	lb bc, BANK(HeldItemIcons), 2
	call Request2bpp
	ld a, [wCurIconTile]
	add 10
	ld [wCurIconTile], a
	ret

HeldItemIcons:
INCBIN "gfx/icon/mail.2bpp"
INCBIN "gfx/icon/item.2bpp"

GetIcon: ; 8ea1b
; Load icon graphics into VRAM starting from tile a.
	swap a
	ld h, a
	and $f0
	ld l, a
	ld a, h
	and $0f
	add vObjTiles >> 8
	ld h, a
	push hl

; The icons are compressed.
	ld a, [CurIcon]
	dec a
	ld e, a
	push hl
	callba GetMonIconPointer
	pop de

	call DecompressRequest2bpp

	pop hl
	ret

FreezeMonIcons: ; 8ea4a
	ld hl, wSpriteAnimationStructs
	ld e, PARTY_LENGTH
	ld a, [wMenuCursorY]
	ld d, a
.loop
	ld a, [hl]
	and a
	jr z, .next
	cp d
	ld a, SPRITE_ANIM_SEQ_NULL
	jr nz, .gotAnimSeq
	ld a, SPRITE_ANIM_SEQ_02
.gotAnimSeq
	push hl
	ld c, l
	ld b, h
	ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
	add hl, bc
	ld [hl], a
	pop hl
.next
	ld bc, $10
	add hl, bc
	dec e
	jr nz, .loop
	ret

UnfreezeMonIcons: ; 8ea71
	ld hl, wSpriteAnimationStructs
	ld e, PARTY_LENGTH
.loop
	ld a, [hl]
	and a
	jr z, .next
	push hl
	ld c, l
	ld b, h
	ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
	add hl, bc
	ld [hl], SPRITE_ANIM_SEQ_01
	pop hl
.next
	ld bc, $10
	add hl, bc
	dec e
	jr nz, .loop
	ret
; 8ea8c (23:6a8c)

HoldSwitchmonIcon: ; 8ea8c
	ld hl, wSpriteAnimationStructs
	ld e, PARTY_LENGTH
	ld a, [wSwitchMon]
	ld d, a
.loop
	ld a, [hl]
	and a
	jr z, .next
	cp d
	jr z, .is_switchmon
	ld a, SPRITE_ANIM_SEQ_03
	jr .join_back

.is_switchmon
	ld a, SPRITE_ANIM_SEQ_02
.join_back
	push hl
	ld c, l
	ld b, h
	ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
	add hl, bc
	ld [hl], a
	pop hl
.next
	ld bc, $10
	add hl, bc
	dec e
	jr nz, .loop
	ret
