shithub: pokecrystal

Download patch

ref: 94722aa8f08ceaef8233d73a87f534b6c3f0475f
parent: 2b6dd505c1674e0d99d649515a8efe868035db09
author: Remy Oukaour <[email protected]>
date: Fri Dec 15 07:31:18 EST 2017

Move predef/ files into engine/
Get rid of single-file engine/ subdirectories
Move tilesets/ palettes unrelated to individual tilesets into data/palettes/ (more from engine/colors.asm can be moved here too)

--- a/constants/cgb_constants.asm
+++ b/constants/cgb_constants.asm
@@ -1,4 +1,4 @@
-; GetSGBLayout arguments (see predef/cgb.asm and predef/sgb.asm)
+; GetSGBLayout arguments (see engine/cgb_layouts.asm and engine/sgb_layouts.asm)
 	const_def
 	const SCGB_BATTLE_GRAYSCALE
 	const SCGB_BATTLE_COLORS
--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -19,3 +19,6 @@
 HP_BAR_LENGTH_PX EQU HP_BAR_LENGTH * TILE_WIDTH ; pixels
 EXP_BAR_LENGTH EQU 8 ; tiles
 EXP_BAR_LENGTH_PX EQU EXP_BAR_LENGTH * TILE_WIDTH ; pixels
+
+
+PALPACKET_LENGTH EQU $10
--- /dev/null
+++ b/data/palettes/bg.pal
@@ -1,0 +1,227 @@
+; morn
+
+; gray
+	RGB 28, 31, 16
+	RGB 21, 21, 21
+	RGB 13, 13, 13
+	RGB 07, 07, 07
+; red
+	RGB 28, 31, 16
+	RGB 31, 19, 24
+	RGB 30, 10, 06
+	RGB 07, 07, 07
+; green
+	RGB 22, 31, 10
+	RGB 12, 25, 01
+	RGB 05, 14, 00
+	RGB 07, 07, 07
+; water
+	RGB 31, 31, 31
+	RGB 08, 12, 31
+	RGB 01, 04, 31
+	RGB 07, 07, 07
+; yellow
+	RGB 28, 31, 16
+	RGB 31, 31, 07
+	RGB 31, 16, 01
+	RGB 07, 07, 07
+; brown
+	RGB 28, 31, 16
+	RGB 24, 18, 07
+	RGB 20, 15, 03
+	RGB 07, 07, 07
+; roof
+	RGB 28, 31, 16
+	RGB 15, 31, 31
+	RGB 05, 17, 31
+	RGB 07, 07, 07
+; text
+	RGB 31, 31, 16
+	RGB 31, 31, 16
+	RGB 14, 09, 00
+	RGB 00, 00, 00
+
+; day
+
+; gray
+	RGB 27, 31, 27
+	RGB 21, 21, 21
+	RGB 13, 13, 13
+	RGB 07, 07, 07
+; red
+	RGB 27, 31, 27
+	RGB 31, 19, 24
+	RGB 30, 10, 06
+	RGB 07, 07, 07
+; green
+	RGB 22, 31, 10
+	RGB 12, 25, 01
+	RGB 05, 14, 00
+	RGB 07, 07, 07
+; water
+	RGB 31, 31, 31
+	RGB 08, 12, 31
+	RGB 01, 04, 31
+	RGB 07, 07, 07
+; yellow
+	RGB 27, 31, 27
+	RGB 31, 31, 07
+	RGB 31, 16, 01
+	RGB 07, 07, 07
+; brown
+	RGB 27, 31, 27
+	RGB 24, 18, 07
+	RGB 20, 15, 03
+	RGB 07, 07, 07
+; roof
+	RGB 27, 31, 27
+	RGB 15, 31, 31
+	RGB 05, 17, 31
+	RGB 07, 07, 07
+; text
+	RGB 31, 31, 16
+	RGB 31, 31, 16
+	RGB 14, 09, 00
+	RGB 00, 00, 00
+
+; nite
+
+; gray
+	RGB 15, 14, 24
+	RGB 11, 11, 19
+	RGB 07, 07, 12
+	RGB 00, 00, 00
+; red
+	RGB 15, 14, 24
+	RGB 14, 07, 17
+	RGB 13, 00, 08
+	RGB 00, 00, 00
+; green
+	RGB 15, 14, 24
+	RGB 08, 13, 19
+	RGB 00, 11, 13
+	RGB 00, 00, 00
+; water
+	RGB 15, 14, 24
+	RGB 05, 05, 17
+	RGB 03, 03, 10
+	RGB 00, 00, 00
+; yellow
+	RGB 30, 30, 11
+	RGB 16, 14, 18
+	RGB 16, 14, 10
+	RGB 00, 00, 00
+; brown
+	RGB 15, 14, 24
+	RGB 12, 09, 15
+	RGB 08, 04, 05
+	RGB 00, 00, 00
+; roof
+	RGB 15, 14, 24
+	RGB 13, 12, 23
+	RGB 11, 09, 20
+	RGB 00, 00, 00
+; text
+	RGB 31, 31, 16
+	RGB 31, 31, 16
+	RGB 14, 09, 00
+	RGB 00, 00, 00
+
+; dark
+
+; gray
+	RGB 01, 01, 02
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+; red
+	RGB 01, 01, 02
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+; green
+	RGB 01, 01, 02
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+; water
+	RGB 01, 01, 02
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+; yellow
+	RGB 30, 30, 11
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+; brown
+	RGB 01, 01, 02
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+; roof
+	RGB 01, 01, 02
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+; text
+	RGB 31, 31, 16
+	RGB 31, 31, 16
+	RGB 14, 09, 00
+	RGB 00, 00, 00
+
+; indoor
+
+; gray
+	RGB 30, 28, 26
+	RGB 19, 19, 19
+	RGB 13, 13, 13
+	RGB 07, 07, 07
+; red
+	RGB 30, 28, 26
+	RGB 31, 19, 24
+	RGB 30, 10, 06
+	RGB 07, 07, 07
+; green
+	RGB 18, 24, 09
+	RGB 15, 20, 01
+	RGB 09, 13, 00
+	RGB 07, 07, 07
+; water
+	RGB 30, 28, 26
+	RGB 15, 16, 31
+	RGB 09, 09, 31
+	RGB 07, 07, 07
+; yellow
+	RGB 30, 28, 26
+	RGB 31, 31, 07
+	RGB 31, 16, 01
+	RGB 07, 07, 07
+; brown
+	RGB 26, 24, 17
+	RGB 21, 17, 07
+	RGB 16, 13, 03
+	RGB 07, 07, 07
+; roof
+	RGB 30, 28, 26
+	RGB 17, 19, 31
+	RGB 14, 16, 31
+	RGB 07, 07, 07
+; text
+	RGB 31, 31, 16
+	RGB 31, 31, 16
+	RGB 14, 09, 00
+	RGB 00, 00, 00
+
+; overworld water
+
+; morn/day
+	RGB 23, 23, 31
+	RGB 18, 19, 31
+	RGB 13, 12, 31
+	RGB 07, 07, 07
+; nite
+	RGB 15, 13, 27
+	RGB 10, 09, 20
+	RGB 04, 03, 18
+	RGB 00, 00, 00
--- /dev/null
+++ b/data/palettes/ob.pal
@@ -1,0 +1,39 @@
+	; morn
+	RGB 28,31,16, 31,19,10, 31,07,01, 00,00,00 ; red
+	RGB 28,31,16, 31,19,10, 10,09,31, 00,00,00 ; blue
+	RGB 28,31,16, 31,19,10, 07,23,03, 00,00,00 ; green
+	RGB 28,31,16, 31,19,10, 15,10,03, 00,00,00 ; brown
+	RGB 28,31,16, 31,19,10, 30,10,06, 00,00,00 ; pink
+	RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver
+	RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree
+	RGB 28,31,16, 24,18,07, 20,15,03, 07,07,07 ; rock
+
+	; day
+	RGB 27,31,27, 31,19,10, 31,07,01, 00,00,00 ; red
+	RGB 27,31,27, 31,19,10, 10,09,31, 00,00,00 ; blue
+	RGB 27,31,27, 31,19,10, 07,23,03, 00,00,00 ; green
+	RGB 27,31,27, 31,19,10, 15,10,03, 00,00,00 ; brown
+	RGB 27,31,27, 31,19,10, 30,10,06, 00,00,00 ; pink
+	RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver
+	RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree
+	RGB 27,31,27, 24,18,07, 20,15,03, 07,07,07 ; rock
+
+	; nite
+	RGB 15,14,24, 31,19,10, 31,07,01, 00,00,00 ; red
+	RGB 15,14,24, 31,19,10, 10,09,31, 00,00,00 ; blue
+	RGB 15,14,24, 31,19,10, 07,23,03, 00,00,00 ; green
+	RGB 15,14,24, 31,19,10, 15,10,03, 00,00,00 ; brown
+	RGB 15,14,24, 31,19,10, 30,10,06, 00,00,00 ; pink
+	RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver
+	RGB 15,14,24, 08,13,19, 00,11,13, 00,00,00 ; tree
+	RGB 15,14,24, 12,09,15, 08,04,05, 00,00,00 ; rock
+
+	; dark
+	RGB 01,01,02, 31,19,10, 31,07,01, 00,00,00 ; red
+	RGB 01,01,02, 31,19,10, 10,09,31, 00,00,00 ; blue
+	RGB 01,01,02, 31,19,10, 07,23,03, 00,00,00 ; green
+	RGB 01,01,02, 31,19,10, 15,10,03, 00,00,00 ; brown
+	RGB 01,01,02, 31,19,10, 30,10,06, 00,00,00 ; pink
+	RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver
+	RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; tree
+	RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; rock
--- /dev/null
+++ b/data/palettes/roof.pal
@@ -1,0 +1,161 @@
+; group 0 (unused)
+	RGB 21, 21, 21
+	RGB 11, 11, 11
+	RGB 21, 21, 21
+	RGB 11, 11, 11
+
+; group 1 (Olivine)
+	RGB 14, 17, 31
+	RGB 07, 11, 15
+	RGB 09, 09, 17
+	RGB 05, 07, 13
+
+; group 2 (Mahogany)
+	RGB 12, 19, 00
+	RGB 06, 10, 00
+	RGB 06, 09, 07
+	RGB 04, 05, 06
+
+; group 3
+	RGB 21, 21, 21
+	RGB 11, 11, 11
+	RGB 21, 21, 21
+	RGB 17, 08, 07
+
+; group 4 (Ecruteak)
+	RGB 31, 19, 00
+	RGB 27, 10, 05
+	RGB 15, 07, 02
+	RGB 11, 04, 02
+
+; group 5 (Blackthorn)
+	RGB 11, 10, 16
+	RGB 05, 06, 07
+	RGB 03, 04, 08
+	RGB 00, 00, 00
+
+; group 6 (Cinnabar)
+	RGB 31, 10, 00
+	RGB 18, 06, 00
+	RGB 18, 05, 09
+	RGB 17, 08, 07
+
+; group 7 (Cerulean)
+	RGB 17, 27, 31
+	RGB 05, 15, 31
+	RGB 07, 08, 22
+	RGB 07, 07, 16
+
+; group 8 (Azalea)
+	RGB 22, 20, 10
+	RGB 17, 14, 03
+	RGB 11, 11, 05
+	RGB 10, 09, 07
+
+; group 9 (Lake of Rage)
+	RGB 31, 08, 04
+	RGB 09, 09, 08
+	RGB 18, 05, 09
+	RGB 09, 09, 08
+
+; group 10 (Violet)
+	RGB 24, 14, 31
+	RGB 13, 07, 21
+	RGB 12, 03, 18
+	RGB 09, 03, 15
+
+; group 11 (Goldenrod)
+	RGB 25, 25, 00
+	RGB 20, 17, 08
+	RGB 12, 12, 00
+	RGB 10, 09, 05
+
+; group 12 (Vermilion)
+	RGB 27, 23, 01
+	RGB 23, 11, 00
+	RGB 15, 11, 01
+	RGB 11, 10, 01
+
+; group 13 (Pallet)
+	RGB 27, 28, 31
+	RGB 17, 19, 22
+	RGB 14, 14, 18
+	RGB 10, 09, 13
+
+; group 14 (Pewter)
+	RGB 19, 19, 16
+	RGB 10, 12, 15
+	RGB 09, 09, 11
+	RGB 04, 05, 07
+
+; group 15 (Mount Moon Square)
+	RGB 14, 17, 31
+	RGB 07, 11, 15
+	RGB 09, 13, 19
+	RGB 07, 07, 16
+
+; group 16 (Route 23)
+	RGB 21, 21, 21
+	RGB 13, 13, 13
+	RGB 11, 11, 19
+	RGB 07, 07, 12
+
+; group 17 (Fuchsia)
+	RGB 31, 18, 29
+	RGB 17, 13, 20
+	RGB 14, 06, 12
+	RGB 11, 03, 10
+
+; group 18 (Lavender)
+	RGB 23, 15, 31
+	RGB 16, 05, 31
+	RGB 12, 07, 17
+	RGB 08, 06, 10
+
+; group 19 (Route 28)
+	RGB 21, 21, 25
+	RGB 16, 16, 16
+	RGB 13, 13, 13
+	RGB 07, 07, 07
+
+; group 20
+	RGB 21, 21, 21
+	RGB 11, 11, 11
+	RGB 21, 21, 21
+	RGB 11, 11, 11
+
+; group 21 (Celadon)
+	RGB 19, 31, 15
+	RGB 31, 22, 02
+	RGB 12, 13, 09
+	RGB 09, 12, 03
+
+; group 22 (Cianwood)
+	RGB 15, 10, 31
+	RGB 07, 05, 15
+	RGB 06, 05, 17
+	RGB 02, 02, 08
+
+; group 23 (Viridian)
+	RGB 21, 31, 07
+	RGB 13, 25, 04
+	RGB 09, 14, 08
+	RGB 06, 10, 04
+
+; group 24 (New Bark)
+	RGB 20, 31, 14
+	RGB 11, 23, 05
+	RGB 09, 13, 08
+	RGB 06, 09, 04
+
+; group 25 (Saffron)
+	RGB 31, 26, 00
+	RGB 31, 15, 00
+	RGB 13, 13, 01
+	RGB 08, 08, 01
+
+; group 26 (Cherrygrove)
+	RGB 31, 14, 28
+	RGB 31, 05, 21
+	RGB 14, 07, 17
+	RGB 13, 00, 08
--- /dev/null
+++ b/engine/breeding.asm
@@ -1,0 +1,993 @@
+CheckBreedmonCompatibility: ; 16e1d
+	call .CheckBreedingGroupCompatibility
+	ld c, $0
+	jp nc, .done
+	ld a, [wBreedMon1Species]
+	ld [CurPartySpecies], a
+	ld a, [wBreedMon1DVs]
+	ld [TempMonDVs], a
+	ld a, [wBreedMon1DVs + 1]
+	ld [TempMonDVs + 1], a
+	ld a, TEMPMON
+	ld [MonType], a
+	predef GetGender
+	jr c, .genderless
+	ld b, $1
+	jr nz, .breedmon2
+	inc b
+
+.breedmon2
+	push bc
+	ld a, [wBreedMon2Species]
+	ld [CurPartySpecies], a
+	ld a, [wBreedMon2DVs]
+	ld [TempMonDVs], a
+	ld a, [wBreedMon2DVs + 1]
+	ld [TempMonDVs + 1], a
+	ld a, $3
+	ld [MonType], a
+	predef GetGender
+	pop bc
+	jr c, .genderless
+	ld a, $1
+	jr nz, .compare_gender
+	inc a
+
+.compare_gender
+	cp b
+	jr nz, .compute
+
+.genderless
+	ld c, $0
+	ld a, [wBreedMon1Species]
+	cp DITTO
+	jr z, .ditto1
+	ld a, [wBreedMon2Species]
+	cp DITTO
+	jr nz, .done
+	jr .compute
+
+.ditto1
+	ld a, [wBreedMon2Species]
+	cp DITTO
+	jr z, .done
+
+.compute
+	call .CheckDVs
+	ld c, 255
+	jp z, .done
+	ld a, [wBreedMon2Species]
+	ld b, a
+	ld a, [wBreedMon1Species]
+	cp b
+	ld c, 254
+	jr z, .compare_ids
+	ld c, 128
+.compare_ids
+	; Speed up
+	ld a, [wBreedMon1ID]
+	ld b, a
+	ld a, [wBreedMon2ID]
+	cp b
+	jr nz, .done
+	ld a, [wBreedMon1ID + 1]
+	ld b, a
+	ld a, [wBreedMon2ID + 1]
+	cp b
+	jr nz, .done
+	ld a, c
+	sub 77
+	ld c, a
+
+.done
+	ld a, c
+	ld [wd265], a
+	ret
+; 16ebc
+
+
+.CheckDVs: ; 16ebc (5:6ebc)
+; If Defense DVs match and the lower 3 bits of the Special DVs match,
+; avoid breeding
+	ld a, [wBreedMon1DVs]
+	and %1111
+	ld b, a
+	ld a, [wBreedMon2DVs]
+	and %1111
+	cp b
+	ret nz
+	ld a, [wBreedMon1DVs + 1]
+	and %111
+	ld b, a
+	ld a, [wBreedMon2DVs + 1]
+	and %111
+	cp b
+	ret
+; 16ed6
+
+.CheckBreedingGroupCompatibility: ; 16ed6
+; If either mon is in the No Eggs group,
+; they are not compatible.
+	ld a, [wBreedMon2Species]
+	ld [CurSpecies], a
+	call GetBaseData
+	ld a, [BaseEggGroups]
+	cp NO_EGGS * $11
+	jr z, .Incompatible
+
+	ld a, [wBreedMon1Species]
+	ld [CurSpecies], a
+	call GetBaseData
+	ld a, [BaseEggGroups]
+	cp NO_EGGS * $11
+	jr z, .Incompatible
+
+; Ditto is automatically compatible with everything.
+; If not Ditto, load the breeding groups into b/c and d/e.
+	ld a, [wBreedMon2Species]
+	cp DITTO
+	jr z, .Compatible
+	ld [CurSpecies], a
+	call GetBaseData
+	ld a, [BaseEggGroups]
+	push af
+	and $f
+	ld b, a
+	pop af
+	and $f0
+	swap a
+	ld c, a
+
+	ld a, [wBreedMon1Species]
+	cp DITTO
+	jr z, .Compatible
+	ld [CurSpecies], a
+	push bc
+	call GetBaseData
+	pop bc
+	ld a, [BaseEggGroups]
+	push af
+	and $f
+	ld d, a
+	pop af
+	and $f0
+	swap a
+	ld e, a
+
+	ld a, d
+	cp b
+	jr z, .Compatible
+	cp c
+	jr z, .Compatible
+
+	ld a, e
+	cp b
+	jr z, .Compatible
+	cp c
+	jr z, .Compatible
+
+.Incompatible:
+	and a
+	ret
+
+.Compatible:
+	scf
+	ret
+; 16f3e
+
+DoEggStep:: ; 16f3e
+	ld de, PartySpecies
+	ld hl, PartyMon1Happiness
+	ld c, 0
+.loop
+	ld a, [de]
+	inc de
+	cp -1
+	ret z
+	cp EGG
+	jr nz, .next
+	dec [hl]
+	jr nz, .next
+	ld a, 1
+	and a
+	ret
+
+.next
+	push de
+	ld de, PARTYMON_STRUCT_LENGTH
+	add hl, de
+	pop de
+	jr .loop
+; 16f5e
+
+OverworldHatchEgg:: ; 16f5e
+	call RefreshScreen
+	call LoadStandardMenuDataHeader
+	call HatchEggs
+	call ExitAllMenus
+	call RestartMapMusic
+	jp CloseText
+; 16f70
+
+HatchEggs: ; 16f70 (5:6f70)
+	ld de, PartySpecies
+	ld hl, PartyMon1Happiness
+	xor a
+	ld [CurPartyMon], a
+
+.loop ; 16f7a (5:6f7a)
+	ld a, [de]
+	inc de
+	cp -1
+	jp z, .done
+	push de
+	push hl
+	cp EGG
+	jp nz, .next
+	ld a, [hl]
+	and a
+	jp nz, .next
+	ld [hl], $78
+
+	push de
+
+	callba SetEggMonCaughtData
+	callba TrainerRankings_EggsHatched
+	ld a, [CurPartyMon]
+	ld hl, PartyMon1Species
+	ld bc, PARTYMON_STRUCT_LENGTH
+	call AddNTimes
+	ld a, [hl]
+	ld [CurPartySpecies], a
+	dec a
+	call SetSeenAndCaughtMon
+
+	ld a, [CurPartySpecies]
+	cp TOGEPI
+	jr nz, .nottogepi
+	; set the event flag for hatching togepi
+	ld de, EVENT_TOGEPI_HATCHED
+	ld b, SET_FLAG
+	call EventFlagAction
+.nottogepi
+
+	pop de
+
+	ld a, [CurPartySpecies]
+	dec de
+	ld [de], a
+	ld [wd265], a
+	ld [CurSpecies], a
+	call GetPokemonName
+	xor a
+	ld [wd26b], a
+	call GetBaseData
+	ld a, [CurPartyMon]
+	ld hl, PartyMon1
+	ld bc, PARTYMON_STRUCT_LENGTH
+	call AddNTimes
+	push hl
+	ld bc, MON_MAXHP
+	add hl, bc
+	ld d, h
+	ld e, l
+	pop hl
+	push hl
+	ld bc, MON_LEVEL
+	add hl, bc
+	ld a, [hl]
+	ld [CurPartyLevel], a
+	pop hl
+	push hl
+	ld bc, MON_STATUS
+	add hl, bc
+	xor a
+	ld [hli], a
+	ld [hl], a
+	pop hl
+	push hl
+	ld bc, MON_STAT_EXP - 1
+	add hl, bc
+	ld b, $0
+	predef CalcPkmnStats
+	pop bc
+	ld hl, MON_MAXHP
+	add hl, bc
+	ld d, h
+	ld e, l
+	ld hl, MON_HP
+	add hl, bc
+	ld a, [de]
+	inc de
+	ld [hli], a
+	ld a, [de]
+	ld [hl], a
+	ld hl, MON_ID
+	add hl, bc
+	ld a, [PlayerID]
+	ld [hli], a
+	ld a, [PlayerID + 1]
+	ld [hl], a
+	ld a, [CurPartyMon]
+	ld hl, PartyMonOT
+	ld bc, NAME_LENGTH
+	call AddNTimes
+	ld d, h
+	ld e, l
+	ld hl, PlayerName
+	call CopyBytes
+	ld hl, .Text_HatchEgg
+	call PrintText
+	ld a, [CurPartyMon]
+	ld hl, PartyMonNicknames
+	ld bc, PKMN_NAME_LENGTH
+	call AddNTimes
+	ld d, h
+	ld e, l
+	push de
+	ld hl, .Text_NicknameHatchling
+	call PrintText
+	call YesNoBox
+	pop de
+	jr c, .nonickname
+
+	ld a, $1
+	ld [wd26b], a
+	xor a
+	ld [MonType], a
+	push de
+	ld b, $0
+	callba NamingScreen
+	pop hl
+	ld de, StringBuffer1
+	call InitName
+	jr .next
+
+.nonickname
+	ld hl, StringBuffer1
+	ld bc, PKMN_NAME_LENGTH
+	call CopyBytes
+
+.next ; 1707d (5:707d)
+	ld hl, CurPartyMon
+	inc [hl]
+	pop hl
+	ld de, PARTYMON_STRUCT_LENGTH
+	add hl, de
+	pop de
+	jp .loop
+
+.done ; 1708a (5:708a)
+	ret
+; 1708b (5:708b)
+
+.Text_HatchEgg: ; 0x1708b
+	; Huh? @ @
+	text_jump UnknownText_0x1c0db0
+	start_asm
+	ld hl, VramState
+	res 0, [hl]
+	push hl
+	push de
+	push bc
+	ld a, [CurPartySpecies]
+	push af
+	call EggHatch_AnimationSequence
+	ld hl, .ClearTextbox
+	call PrintText
+	pop af
+	ld [CurPartySpecies], a
+	pop bc
+	pop de
+	pop hl
+	ld hl, .CameOutOfItsEgg
+	ret
+; 170b0 (5:70b0)
+
+.ClearTextbox: ; 0x170b0
+	;
+	text_jump UnknownText_0x1c0db8
+	db "@"
+; 0x170b5
+
+.CameOutOfItsEgg: ; 0x170b5
+	; came out of its EGG!@ @
+	text_jump UnknownText_0x1c0dba
+	db "@"
+; 0x170ba
+
+.Text_NicknameHatchling: ; 0x170ba
+	; Give a nickname to @ ?
+	text_jump UnknownText_0x1c0dd8
+	db "@"
+; 0x170bf
+
+InitEggMoves: ; 170bf
+	call GetHeritableMoves
+	ld d, h
+	ld e, l
+	ld b, NUM_MOVES
+.loop
+	ld a, [de]
+	and a
+	jr z, .done
+	ld hl, wEggMonMoves
+	ld c, NUM_MOVES
+.next
+	ld a, [de]
+	cp [hl]
+	jr z, .skip
+	inc hl
+	dec c
+	jr nz, .next
+	call GetEggMove
+	jr nc, .skip
+	call LoadEggMove
+
+.skip
+	inc de
+	dec b
+	jr nz, .loop
+
+.done
+	ret
+; 170e4
+
+GetEggMove: ; 170e4
+GLOBAL EggMoves
+
+	push bc
+	ld a, [wEggMonSpecies]
+	dec a
+	ld c, a
+	ld b, 0
+	ld hl, EggMovePointers
+	add hl, bc
+	add hl, bc
+	ld a, BANK(EggMovePointers)
+	call GetFarHalfword
+.loop
+	ld a, BANK(EggMoves)
+	call GetFarByte
+	cp -1
+	jr z, .reached_end
+	ld b, a
+	ld a, [de]
+	cp b
+	jr z, .done_carry
+	inc hl
+	jr .loop
+
+.reached_end
+	call GetBreedmonMovePointer
+	ld b, NUM_MOVES
+.loop2
+	ld a, [de]
+	cp [hl]
+	jr z, .found_eggmove
+	inc hl
+	dec b
+	jr z, .inherit_tmhm
+	jr .loop2
+
+.found_eggmove
+	ld a, [wEggMonSpecies]
+	dec a
+	ld c, a
+	ld b, 0
+	ld hl, EvosAttacksPointers
+	add hl, bc
+	add hl, bc
+	ld a, BANK(EvosAttacksPointers)
+	call GetFarHalfword
+.loop3
+	ld a, BANK(EvosAttacks)
+	call GetFarByte
+	inc hl
+	and a
+	jr nz, .loop3
+.loop4
+	ld a, BANK(EvosAttacks)
+	call GetFarByte
+	and a
+	jr z, .inherit_tmhm
+	inc hl
+	ld a, BANK(EvosAttacks)
+	call GetFarByte
+	ld b, a
+	ld a, [de]
+	cp b
+	jr z, .done_carry
+	inc hl
+	jr .loop4
+
+.inherit_tmhm
+	ld hl, TMHMMoves
+.loop5
+	ld a, BANK(TMHMMoves)
+	call GetFarByte
+	inc hl
+	and a
+	jr z, .done
+	ld b, a
+	ld a, [de]
+	cp b
+	jr nz, .loop5
+	ld [wPutativeTMHMMove], a
+	predef CanLearnTMHMMove
+	ld a, c
+	and a
+	jr z, .done
+
+.done_carry
+	pop bc
+	scf
+	ret
+
+.done
+	pop bc
+	and a
+	ret
+; 17169
+
+LoadEggMove: ; 17169
+	push de
+	push bc
+	ld a, [de]
+	ld b, a
+	ld hl, wEggMonMoves
+	ld c, NUM_MOVES
+.loop
+	ld a, [hli]
+	and a
+	jr z, .done
+	dec c
+	jr nz, .loop
+	ld de, wEggMonMoves
+	ld hl, wEggMonMoves + 1
+	ld a, [hli]
+	ld [de], a
+	inc de
+	ld a, [hli]
+	ld [de], a
+	inc de
+	ld a, [hli]
+	ld [de], a
+
+.done
+	dec hl
+	ld [hl], b
+	ld hl, wEggMonMoves
+	ld de, wEggMonPP
+	predef FillPP
+	pop bc
+	pop de
+	ret
+; 17197
+
+GetHeritableMoves: ; 17197
+	ld hl, wBreedMon2Moves
+	ld a, [wBreedMon1Species]
+	cp DITTO
+	jr z, .ditto1
+	ld a, [wBreedMon2Species]
+	cp DITTO
+	jr z, .ditto2
+	ld a, [wBreedMotherOrNonDitto]
+	and a
+	ret z
+	ld hl, wBreedMon1Moves
+	ret
+
+.ditto1
+	ld a, [CurPartySpecies]
+	push af
+	ld a, [wBreedMon2Species]
+	ld [CurPartySpecies], a
+	ld a, [wBreedMon2DVs]
+	ld [TempMonDVs], a
+	ld a, [wBreedMon2DVs + 1]
+	ld [TempMonDVs + 1], a
+	ld a, TEMPMON
+	ld [MonType], a
+	predef GetGender
+	jr c, .inherit_mon2_moves
+	jr nz, .inherit_mon2_moves
+	jr .inherit_mon1_moves
+
+.ditto2
+	ld a, [CurPartySpecies]
+	push af
+	ld a, [wBreedMon1Species]
+	ld [CurPartySpecies], a
+	ld a, [wBreedMon1DVs]
+	ld [TempMonDVs], a
+	ld a, [wBreedMon1DVs + 1]
+	ld [TempMonDVs + 1], a
+	ld a, TEMPMON
+	ld [MonType], a
+	predef GetGender
+	jr c, .inherit_mon1_moves
+	jr nz, .inherit_mon1_moves
+
+.inherit_mon2_moves
+	ld hl, wBreedMon2Moves
+	pop af
+	ld [CurPartySpecies], a
+	ret
+
+.inherit_mon1_moves
+	ld hl, wBreedMon1Moves
+	pop af
+	ld [CurPartySpecies], a
+	ret
+; 1720b
+
+GetBreedmonMovePointer: ; 1720b
+	ld hl, wBreedMon1Moves
+	ld a, [wBreedMon1Species]
+	cp DITTO
+	ret z
+	ld a, [wBreedMon2Species]
+	cp DITTO
+	jr z, .ditto
+	ld a, [wBreedMotherOrNonDitto]
+	and a
+	ret z
+
+.ditto
+	ld hl, wBreedMon2Moves
+	ret
+; 17224
+
+
+GetEggFrontpic: ; 17224 (5:7224)
+	push de
+	ld [CurPartySpecies], a
+	ld [CurSpecies], a
+	call GetBaseData
+	ld hl, BattleMonDVs
+	predef GetUnownLetter
+	pop de
+	predef_jump GetFrontpic
+
+GetHatchlingFrontpic: ; 1723c (5:723c)
+	push de
+	ld [CurPartySpecies], a
+	ld [CurSpecies], a
+	call GetBaseData
+	ld hl, BattleMonDVs
+	predef GetUnownLetter
+	pop de
+	predef_jump FrontpicPredef
+
+Hatch_UpdateFrontpicBGMapCenter: ; 17254 (5:7254)
+	push af
+	call WaitTop
+	push hl
+	push bc
+	hlcoord 0, 0
+	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+	ld a, " "
+	call ByteFill
+	pop bc
+	pop hl
+	ld a, b
+	ld [hBGMapAddress + 1], a
+	ld a, c
+	ld [hGraphicStartTile], a
+	lb bc, 7, 7
+	predef PlaceGraphic
+	pop af
+	call Hatch_LoadFrontpicPal
+	call SetPalettes
+	jp WaitBGMap
+
+EggHatch_DoAnimFrame: ; 1727f (5:727f)
+	push hl
+	push de
+	push bc
+	callab PlaySpriteAnimations
+	call DelayFrame
+	pop bc
+	pop de
+	pop hl
+	ret
+
+EggHatch_AnimationSequence: ; 1728f (5:728f)
+	ld a, [wd265]
+	ld [wJumptableIndex], a
+	ld a, [CurSpecies]
+	push af
+	ld de, MUSIC_NONE
+	call PlayMusic
+	callba BlankScreen
+	call DisableLCD
+	ld hl, EggHatchGFX
+	ld de, VTiles0 tile $00
+	ld bc, $20
+	ld a, BANK(EggHatchGFX)
+	call FarCopyBytes
+	callba ClearSpriteAnims
+	ld de, VTiles2 tile $00
+	ld a, [wJumptableIndex]
+	call GetHatchlingFrontpic
+	ld de, VTiles2 tile $31
+	ld a, EGG
+	call GetEggFrontpic
+	ld de, MUSIC_EVOLUTION
+	call PlayMusic
+	call EnableLCD
+	hlcoord 7, 4
+	ld b, VBGMap0 / $100
+	ld c, $31 ; Egg tiles start here
+	ld a, EGG
+	call Hatch_UpdateFrontpicBGMapCenter
+	ld c, 80
+	call DelayFrames
+	xor a
+	ld [wcf64], a
+	ld a, [hSCX]
+	ld b, a
+.outerloop
+	ld hl, wcf64
+	ld a, [hl]
+	inc [hl]
+	cp 8
+	jr nc, .done
+	ld e, [hl]
+.loop
+; wobble e times
+	ld a, 2
+	ld [hSCX], a
+	ld a, -2
+	ld [wGlobalAnimXOffset], a
+	call EggHatch_DoAnimFrame
+	ld c, 2
+	call DelayFrames
+	ld a, -2
+	ld [hSCX], a
+	ld a, 2
+	ld [wGlobalAnimXOffset], a
+	call EggHatch_DoAnimFrame
+	ld c, 2
+	call DelayFrames
+	dec e
+	jr nz, .loop
+	ld c, 16
+	call DelayFrames
+	call EggHatch_CrackShell
+	jr .outerloop
+
+.done
+	ld de, SFX_EGG_HATCH
+	call PlaySFX
+	xor a
+	ld [hSCX], a
+	ld [wGlobalAnimXOffset], a
+	call ClearSprites
+	call Hatch_InitShellFragments
+	hlcoord 6, 3
+	ld b, VBGMap0 / $100
+	ld c, $00 ; Hatchling tiles start here
+	ld a, [wJumptableIndex]
+	call Hatch_UpdateFrontpicBGMapCenter
+	call Hatch_ShellFragmentLoop
+	call WaitSFX
+	ld a, [wJumptableIndex]
+	ld [CurPartySpecies], a
+	hlcoord 6, 3
+	ld d, $0
+	ld e, ANIM_MON_HATCH
+	predef AnimateFrontpic
+	pop af
+	ld [CurSpecies], a
+	ret
+
+Hatch_LoadFrontpicPal: ; 17363 (5:7363)
+	ld [PlayerHPPal], a
+	ld b, SCGB_EVOLUTION
+	ld c, $0
+	jp GetSGBLayout
+
+EggHatch_CrackShell: ; 1736d (5:736d)
+	ld a, [wcf64]
+	dec a
+	and $7
+	cp $7
+	ret z
+	srl a
+	ret nc
+	swap a
+	srl a
+	add 9 * 8 + 4
+	ld d, a
+	ld e, 11 * 8
+	ld a, SPRITE_ANIM_INDEX_EGG_CRACK
+	call _InitSpriteAnimStruct
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
+	add hl, bc
+	ld [hl], $0
+	ld de, SFX_EGG_CRACK
+	jp PlaySFX
+; 17393 (5:7393)
+
+EggHatchGFX: ; 17393
+INCBIN "gfx/evo/egg_hatch.2bpp"
+; 173b3
+
+Hatch_InitShellFragments: ; 173b3 (5:73b3)
+	callba ClearSpriteAnims
+	ld hl, .SpriteData
+.loop
+	ld a, [hli]
+	cp -1
+	jr z, .done
+	ld e, a
+	ld a, [hli]
+	ld d, a
+	ld a, [hli]
+	ld c, a
+	ld a, [hli]
+	ld b, a
+	push hl
+	push bc
+
+	ld a, SPRITE_ANIM_INDEX_EGG_HATCH
+	call _InitSpriteAnimStruct
+
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
+	add hl, bc
+	ld [hl], $0
+
+	pop de
+	ld a, e
+	ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
+	add hl, bc
+	add [hl]
+	ld [hl], a
+
+	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
+	add hl, bc
+	ld [hl], d
+
+	pop hl
+	jr .loop
+.done
+	ld de, SFX_EGG_HATCH
+	call PlaySFX
+	call EggHatch_DoAnimFrame
+	ret
+; 173ef (5:73ef)
+
+.SpriteData: ; 173ef
+; Probably OAM.
+	dsprite 10, 4,  9, 0, $00, $3c
+	dsprite 11, 4,  9, 0, $01, $04
+	dsprite 10, 4, 10, 0, $00, $30
+	dsprite 11, 4, 10, 0, $01, $10
+	dsprite 10, 4, 11, 0, $02, $24
+	dsprite 11, 4, 11, 0, $03, $1c
+	dsprite 10, 0,  9, 4, $00, $36
+	dsprite 12, 0,  9, 4, $01, $0a
+	dsprite 10, 0, 10, 4, $02, $2a
+	dsprite 12, 0, 10, 4, $03, $16
+	db -1
+; 17418
+
+Hatch_ShellFragmentLoop: ; 17418 (5:7418)
+	ld c, 129
+.loop
+	call EggHatch_DoAnimFrame
+	dec c
+	jr nz, .loop
+	ret
+
+Special_DayCareMon1: ; 17421
+	ld hl, DayCareMon1Text
+	call PrintText
+	ld a, [wBreedMon1Species]
+	call PlayCry
+	ld a, [wDayCareLady]
+	bit 0, a
+	jr z, DayCareMonCursor
+	call ButtonSound
+	ld hl, wBreedMon2Nick
+	call DayCareMonCompatibilityText
+	jp PrintText
+
+Special_DayCareMon2: ; 17440
+	ld hl, DayCareMon2Text
+	call PrintText
+	ld a, [wBreedMon2Species]
+	call PlayCry
+	ld a, [wDayCareMan]
+	bit 0, a
+	jr z, DayCareMonCursor
+	call ButtonSound
+	ld hl, wBreedMon1Nick
+	call DayCareMonCompatibilityText
+	jp PrintText
+
+DayCareMonCursor: ; 1745f
+	jp WaitPressAorB_BlinkCursor
+; 17462
+
+DayCareMon2Text: ; 0x17462
+	; It's @ that was left with the DAY-CARE LADY.
+	text_jump UnknownText_0x1c0df3
+	db "@"
+; 0x17467
+
+DayCareMon1Text: ; 0x17467
+	; It's @ that was left with the DAY-CARE MAN.
+	text_jump UnknownText_0x1c0e24
+	db "@"
+; 0x1746c
+
+DayCareMonCompatibilityText: ; 1746c
+	push bc
+	ld de, StringBuffer1
+	ld bc, NAME_LENGTH
+	call CopyBytes
+	call CheckBreedmonCompatibility
+	pop bc
+	ld a, [wd265]
+	ld hl, .AllAlone
+	cp -1
+	jr z, .done
+	ld hl, .Incompatible
+	and a
+	jr z, .done
+	ld hl, .HighCompatibility
+	cp 230
+	jr nc, .done
+	cp 70
+	ld hl, .ModerateCompatibility
+	jr nc, .done
+	ld hl, .SlightCompatibility
+
+.done
+	ret
+; 1749c
+
+.AllAlone: ; 0x1749c
+	; It's brimming with energy.
+	text_jump UnknownText_0x1c0e54
+	db "@"
+; 0x174a1
+
+.Incompatible: ; 0x174a1
+	; It has no interest in @ .
+	text_jump UnknownText_0x1c0e6f
+	db "@"
+; 0x174a6
+
+.HighCompatibility: ; 0x174a6
+	; It appears to care for @ .
+	text_jump UnknownText_0x1c0e8d
+	db "@"
+; 0x174ab
+
+.ModerateCompatibility: ; 0x174ab
+	; It's friendly with @ .
+	text_jump UnknownText_0x1c0eac
+	db "@"
+; 0x174b0
+
+.SlightCompatibility: ; 0x174b0
+	; It shows interest in @ .
+	text_jump UnknownText_0x1c0ec6
+	db "@"
+; 0x174b5
+
+DayCareMonPrintEmptyString: ; 174b5
+; unreferenced
+	ld hl, .string
+	ret
+; 174b9
+
+.string ; 174b9
+	db "@"
+; 174ba
+
--- a/engine/breeding/egg.asm
+++ /dev/null
@@ -1,993 +1,0 @@
-CheckBreedmonCompatibility: ; 16e1d
-	call .CheckBreedingGroupCompatibility
-	ld c, $0
-	jp nc, .done
-	ld a, [wBreedMon1Species]
-	ld [CurPartySpecies], a
-	ld a, [wBreedMon1DVs]
-	ld [TempMonDVs], a
-	ld a, [wBreedMon1DVs + 1]
-	ld [TempMonDVs + 1], a
-	ld a, TEMPMON
-	ld [MonType], a
-	predef GetGender
-	jr c, .genderless
-	ld b, $1
-	jr nz, .breedmon2
-	inc b
-
-.breedmon2
-	push bc
-	ld a, [wBreedMon2Species]
-	ld [CurPartySpecies], a
-	ld a, [wBreedMon2DVs]
-	ld [TempMonDVs], a
-	ld a, [wBreedMon2DVs + 1]
-	ld [TempMonDVs + 1], a
-	ld a, $3
-	ld [MonType], a
-	predef GetGender
-	pop bc
-	jr c, .genderless
-	ld a, $1
-	jr nz, .compare_gender
-	inc a
-
-.compare_gender
-	cp b
-	jr nz, .compute
-
-.genderless
-	ld c, $0
-	ld a, [wBreedMon1Species]
-	cp DITTO
-	jr z, .ditto1
-	ld a, [wBreedMon2Species]
-	cp DITTO
-	jr nz, .done
-	jr .compute
-
-.ditto1
-	ld a, [wBreedMon2Species]
-	cp DITTO
-	jr z, .done
-
-.compute
-	call .CheckDVs
-	ld c, 255
-	jp z, .done
-	ld a, [wBreedMon2Species]
-	ld b, a
-	ld a, [wBreedMon1Species]
-	cp b
-	ld c, 254
-	jr z, .compare_ids
-	ld c, 128
-.compare_ids
-	; Speed up
-	ld a, [wBreedMon1ID]
-	ld b, a
-	ld a, [wBreedMon2ID]
-	cp b
-	jr nz, .done
-	ld a, [wBreedMon1ID + 1]
-	ld b, a
-	ld a, [wBreedMon2ID + 1]
-	cp b
-	jr nz, .done
-	ld a, c
-	sub 77
-	ld c, a
-
-.done
-	ld a, c
-	ld [wd265], a
-	ret
-; 16ebc
-
-
-.CheckDVs: ; 16ebc (5:6ebc)
-; If Defense DVs match and the lower 3 bits of the Special DVs match,
-; avoid breeding
-	ld a, [wBreedMon1DVs]
-	and %1111
-	ld b, a
-	ld a, [wBreedMon2DVs]
-	and %1111
-	cp b
-	ret nz
-	ld a, [wBreedMon1DVs + 1]
-	and %111
-	ld b, a
-	ld a, [wBreedMon2DVs + 1]
-	and %111
-	cp b
-	ret
-; 16ed6
-
-.CheckBreedingGroupCompatibility: ; 16ed6
-; If either mon is in the No Eggs group,
-; they are not compatible.
-	ld a, [wBreedMon2Species]
-	ld [CurSpecies], a
-	call GetBaseData
-	ld a, [BaseEggGroups]
-	cp NO_EGGS * $11
-	jr z, .Incompatible
-
-	ld a, [wBreedMon1Species]
-	ld [CurSpecies], a
-	call GetBaseData
-	ld a, [BaseEggGroups]
-	cp NO_EGGS * $11
-	jr z, .Incompatible
-
-; Ditto is automatically compatible with everything.
-; If not Ditto, load the breeding groups into b/c and d/e.
-	ld a, [wBreedMon2Species]
-	cp DITTO
-	jr z, .Compatible
-	ld [CurSpecies], a
-	call GetBaseData
-	ld a, [BaseEggGroups]
-	push af
-	and $f
-	ld b, a
-	pop af
-	and $f0
-	swap a
-	ld c, a
-
-	ld a, [wBreedMon1Species]
-	cp DITTO
-	jr z, .Compatible
-	ld [CurSpecies], a
-	push bc
-	call GetBaseData
-	pop bc
-	ld a, [BaseEggGroups]
-	push af
-	and $f
-	ld d, a
-	pop af
-	and $f0
-	swap a
-	ld e, a
-
-	ld a, d
-	cp b
-	jr z, .Compatible
-	cp c
-	jr z, .Compatible
-
-	ld a, e
-	cp b
-	jr z, .Compatible
-	cp c
-	jr z, .Compatible
-
-.Incompatible:
-	and a
-	ret
-
-.Compatible:
-	scf
-	ret
-; 16f3e
-
-DoEggStep:: ; 16f3e
-	ld de, PartySpecies
-	ld hl, PartyMon1Happiness
-	ld c, 0
-.loop
-	ld a, [de]
-	inc de
-	cp -1
-	ret z
-	cp EGG
-	jr nz, .next
-	dec [hl]
-	jr nz, .next
-	ld a, 1
-	and a
-	ret
-
-.next
-	push de
-	ld de, PARTYMON_STRUCT_LENGTH
-	add hl, de
-	pop de
-	jr .loop
-; 16f5e
-
-OverworldHatchEgg:: ; 16f5e
-	call RefreshScreen
-	call LoadStandardMenuDataHeader
-	call HatchEggs
-	call ExitAllMenus
-	call RestartMapMusic
-	jp CloseText
-; 16f70
-
-HatchEggs: ; 16f70 (5:6f70)
-	ld de, PartySpecies
-	ld hl, PartyMon1Happiness
-	xor a
-	ld [CurPartyMon], a
-
-.loop ; 16f7a (5:6f7a)
-	ld a, [de]
-	inc de
-	cp -1
-	jp z, .done
-	push de
-	push hl
-	cp EGG
-	jp nz, .next
-	ld a, [hl]
-	and a
-	jp nz, .next
-	ld [hl], $78
-
-	push de
-
-	callba SetEggMonCaughtData
-	callba TrainerRankings_EggsHatched
-	ld a, [CurPartyMon]
-	ld hl, PartyMon1Species
-	ld bc, PARTYMON_STRUCT_LENGTH
-	call AddNTimes
-	ld a, [hl]
-	ld [CurPartySpecies], a
-	dec a
-	call SetSeenAndCaughtMon
-
-	ld a, [CurPartySpecies]
-	cp TOGEPI
-	jr nz, .nottogepi
-	; set the event flag for hatching togepi
-	ld de, EVENT_TOGEPI_HATCHED
-	ld b, SET_FLAG
-	call EventFlagAction
-.nottogepi
-
-	pop de
-
-	ld a, [CurPartySpecies]
-	dec de
-	ld [de], a
-	ld [wd265], a
-	ld [CurSpecies], a
-	call GetPokemonName
-	xor a
-	ld [wd26b], a
-	call GetBaseData
-	ld a, [CurPartyMon]
-	ld hl, PartyMon1
-	ld bc, PARTYMON_STRUCT_LENGTH
-	call AddNTimes
-	push hl
-	ld bc, MON_MAXHP
-	add hl, bc
-	ld d, h
-	ld e, l
-	pop hl
-	push hl
-	ld bc, MON_LEVEL
-	add hl, bc
-	ld a, [hl]
-	ld [CurPartyLevel], a
-	pop hl
-	push hl
-	ld bc, MON_STATUS
-	add hl, bc
-	xor a
-	ld [hli], a
-	ld [hl], a
-	pop hl
-	push hl
-	ld bc, MON_STAT_EXP - 1
-	add hl, bc
-	ld b, $0
-	predef CalcPkmnStats
-	pop bc
-	ld hl, MON_MAXHP
-	add hl, bc
-	ld d, h
-	ld e, l
-	ld hl, MON_HP
-	add hl, bc
-	ld a, [de]
-	inc de
-	ld [hli], a
-	ld a, [de]
-	ld [hl], a
-	ld hl, MON_ID
-	add hl, bc
-	ld a, [PlayerID]
-	ld [hli], a
-	ld a, [PlayerID + 1]
-	ld [hl], a
-	ld a, [CurPartyMon]
-	ld hl, PartyMonOT
-	ld bc, NAME_LENGTH
-	call AddNTimes
-	ld d, h
-	ld e, l
-	ld hl, PlayerName
-	call CopyBytes
-	ld hl, .Text_HatchEgg
-	call PrintText
-	ld a, [CurPartyMon]
-	ld hl, PartyMonNicknames
-	ld bc, PKMN_NAME_LENGTH
-	call AddNTimes
-	ld d, h
-	ld e, l
-	push de
-	ld hl, .Text_NicknameHatchling
-	call PrintText
-	call YesNoBox
-	pop de
-	jr c, .nonickname
-
-	ld a, $1
-	ld [wd26b], a
-	xor a
-	ld [MonType], a
-	push de
-	ld b, $0
-	callba NamingScreen
-	pop hl
-	ld de, StringBuffer1
-	call InitName
-	jr .next
-
-.nonickname
-	ld hl, StringBuffer1
-	ld bc, PKMN_NAME_LENGTH
-	call CopyBytes
-
-.next ; 1707d (5:707d)
-	ld hl, CurPartyMon
-	inc [hl]
-	pop hl
-	ld de, PARTYMON_STRUCT_LENGTH
-	add hl, de
-	pop de
-	jp .loop
-
-.done ; 1708a (5:708a)
-	ret
-; 1708b (5:708b)
-
-.Text_HatchEgg: ; 0x1708b
-	; Huh? @ @
-	text_jump UnknownText_0x1c0db0
-	start_asm
-	ld hl, VramState
-	res 0, [hl]
-	push hl
-	push de
-	push bc
-	ld a, [CurPartySpecies]
-	push af
-	call EggHatch_AnimationSequence
-	ld hl, .ClearTextbox
-	call PrintText
-	pop af
-	ld [CurPartySpecies], a
-	pop bc
-	pop de
-	pop hl
-	ld hl, .CameOutOfItsEgg
-	ret
-; 170b0 (5:70b0)
-
-.ClearTextbox: ; 0x170b0
-	;
-	text_jump UnknownText_0x1c0db8
-	db "@"
-; 0x170b5
-
-.CameOutOfItsEgg: ; 0x170b5
-	; came out of its EGG!@ @
-	text_jump UnknownText_0x1c0dba
-	db "@"
-; 0x170ba
-
-.Text_NicknameHatchling: ; 0x170ba
-	; Give a nickname to @ ?
-	text_jump UnknownText_0x1c0dd8
-	db "@"
-; 0x170bf
-
-InitEggMoves: ; 170bf
-	call GetHeritableMoves
-	ld d, h
-	ld e, l
-	ld b, NUM_MOVES
-.loop
-	ld a, [de]
-	and a
-	jr z, .done
-	ld hl, wEggMonMoves
-	ld c, NUM_MOVES
-.next
-	ld a, [de]
-	cp [hl]
-	jr z, .skip
-	inc hl
-	dec c
-	jr nz, .next
-	call GetEggMove
-	jr nc, .skip
-	call LoadEggMove
-
-.skip
-	inc de
-	dec b
-	jr nz, .loop
-
-.done
-	ret
-; 170e4
-
-GetEggMove: ; 170e4
-GLOBAL EggMoves
-
-	push bc
-	ld a, [wEggMonSpecies]
-	dec a
-	ld c, a
-	ld b, 0
-	ld hl, EggMovePointers
-	add hl, bc
-	add hl, bc
-	ld a, BANK(EggMovePointers)
-	call GetFarHalfword
-.loop
-	ld a, BANK(EggMoves)
-	call GetFarByte
-	cp -1
-	jr z, .reached_end
-	ld b, a
-	ld a, [de]
-	cp b
-	jr z, .done_carry
-	inc hl
-	jr .loop
-
-.reached_end
-	call GetBreedmonMovePointer
-	ld b, NUM_MOVES
-.loop2
-	ld a, [de]
-	cp [hl]
-	jr z, .found_eggmove
-	inc hl
-	dec b
-	jr z, .inherit_tmhm
-	jr .loop2
-
-.found_eggmove
-	ld a, [wEggMonSpecies]
-	dec a
-	ld c, a
-	ld b, 0
-	ld hl, EvosAttacksPointers
-	add hl, bc
-	add hl, bc
-	ld a, BANK(EvosAttacksPointers)
-	call GetFarHalfword
-.loop3
-	ld a, BANK(EvosAttacks)
-	call GetFarByte
-	inc hl
-	and a
-	jr nz, .loop3
-.loop4
-	ld a, BANK(EvosAttacks)
-	call GetFarByte
-	and a
-	jr z, .inherit_tmhm
-	inc hl
-	ld a, BANK(EvosAttacks)
-	call GetFarByte
-	ld b, a
-	ld a, [de]
-	cp b
-	jr z, .done_carry
-	inc hl
-	jr .loop4
-
-.inherit_tmhm
-	ld hl, TMHMMoves
-.loop5
-	ld a, BANK(TMHMMoves)
-	call GetFarByte
-	inc hl
-	and a
-	jr z, .done
-	ld b, a
-	ld a, [de]
-	cp b
-	jr nz, .loop5
-	ld [wPutativeTMHMMove], a
-	predef CanLearnTMHMMove
-	ld a, c
-	and a
-	jr z, .done
-
-.done_carry
-	pop bc
-	scf
-	ret
-
-.done
-	pop bc
-	and a
-	ret
-; 17169
-
-LoadEggMove: ; 17169
-	push de
-	push bc
-	ld a, [de]
-	ld b, a
-	ld hl, wEggMonMoves
-	ld c, NUM_MOVES
-.loop
-	ld a, [hli]
-	and a
-	jr z, .done
-	dec c
-	jr nz, .loop
-	ld de, wEggMonMoves
-	ld hl, wEggMonMoves + 1
-	ld a, [hli]
-	ld [de], a
-	inc de
-	ld a, [hli]
-	ld [de], a
-	inc de
-	ld a, [hli]
-	ld [de], a
-
-.done
-	dec hl
-	ld [hl], b
-	ld hl, wEggMonMoves
-	ld de, wEggMonPP
-	predef FillPP
-	pop bc
-	pop de
-	ret
-; 17197
-
-GetHeritableMoves: ; 17197
-	ld hl, wBreedMon2Moves
-	ld a, [wBreedMon1Species]
-	cp DITTO
-	jr z, .ditto1
-	ld a, [wBreedMon2Species]
-	cp DITTO
-	jr z, .ditto2
-	ld a, [wBreedMotherOrNonDitto]
-	and a
-	ret z
-	ld hl, wBreedMon1Moves
-	ret
-
-.ditto1
-	ld a, [CurPartySpecies]
-	push af
-	ld a, [wBreedMon2Species]
-	ld [CurPartySpecies], a
-	ld a, [wBreedMon2DVs]
-	ld [TempMonDVs], a
-	ld a, [wBreedMon2DVs + 1]
-	ld [TempMonDVs + 1], a
-	ld a, TEMPMON
-	ld [MonType], a
-	predef GetGender
-	jr c, .inherit_mon2_moves
-	jr nz, .inherit_mon2_moves
-	jr .inherit_mon1_moves
-
-.ditto2
-	ld a, [CurPartySpecies]
-	push af
-	ld a, [wBreedMon1Species]
-	ld [CurPartySpecies], a
-	ld a, [wBreedMon1DVs]
-	ld [TempMonDVs], a
-	ld a, [wBreedMon1DVs + 1]
-	ld [TempMonDVs + 1], a
-	ld a, TEMPMON
-	ld [MonType], a
-	predef GetGender
-	jr c, .inherit_mon1_moves
-	jr nz, .inherit_mon1_moves
-
-.inherit_mon2_moves
-	ld hl, wBreedMon2Moves
-	pop af
-	ld [CurPartySpecies], a
-	ret
-
-.inherit_mon1_moves
-	ld hl, wBreedMon1Moves
-	pop af
-	ld [CurPartySpecies], a
-	ret
-; 1720b
-
-GetBreedmonMovePointer: ; 1720b
-	ld hl, wBreedMon1Moves
-	ld a, [wBreedMon1Species]
-	cp DITTO
-	ret z
-	ld a, [wBreedMon2Species]
-	cp DITTO
-	jr z, .ditto
-	ld a, [wBreedMotherOrNonDitto]
-	and a
-	ret z
-
-.ditto
-	ld hl, wBreedMon2Moves
-	ret
-; 17224
-
-
-GetEggFrontpic: ; 17224 (5:7224)
-	push de
-	ld [CurPartySpecies], a
-	ld [CurSpecies], a
-	call GetBaseData
-	ld hl, BattleMonDVs
-	predef GetUnownLetter
-	pop de
-	predef_jump GetFrontpic
-
-GetHatchlingFrontpic: ; 1723c (5:723c)
-	push de
-	ld [CurPartySpecies], a
-	ld [CurSpecies], a
-	call GetBaseData
-	ld hl, BattleMonDVs
-	predef GetUnownLetter
-	pop de
-	predef_jump FrontpicPredef
-
-Hatch_UpdateFrontpicBGMapCenter: ; 17254 (5:7254)
-	push af
-	call WaitTop
-	push hl
-	push bc
-	hlcoord 0, 0
-	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
-	ld a, " "
-	call ByteFill
-	pop bc
-	pop hl
-	ld a, b
-	ld [hBGMapAddress + 1], a
-	ld a, c
-	ld [hGraphicStartTile], a
-	lb bc, 7, 7
-	predef PlaceGraphic
-	pop af
-	call Hatch_LoadFrontpicPal
-	call SetPalettes
-	jp WaitBGMap
-
-EggHatch_DoAnimFrame: ; 1727f (5:727f)
-	push hl
-	push de
-	push bc
-	callab PlaySpriteAnimations
-	call DelayFrame
-	pop bc
-	pop de
-	pop hl
-	ret
-
-EggHatch_AnimationSequence: ; 1728f (5:728f)
-	ld a, [wd265]
-	ld [wJumptableIndex], a
-	ld a, [CurSpecies]
-	push af
-	ld de, MUSIC_NONE
-	call PlayMusic
-	callba BlankScreen
-	call DisableLCD
-	ld hl, EggHatchGFX
-	ld de, VTiles0 tile $00
-	ld bc, $20
-	ld a, BANK(EggHatchGFX)
-	call FarCopyBytes
-	callba ClearSpriteAnims
-	ld de, VTiles2 tile $00
-	ld a, [wJumptableIndex]
-	call GetHatchlingFrontpic
-	ld de, VTiles2 tile $31
-	ld a, EGG
-	call GetEggFrontpic
-	ld de, MUSIC_EVOLUTION
-	call PlayMusic
-	call EnableLCD
-	hlcoord 7, 4
-	ld b, VBGMap0 / $100
-	ld c, $31 ; Egg tiles start here
-	ld a, EGG
-	call Hatch_UpdateFrontpicBGMapCenter
-	ld c, 80
-	call DelayFrames
-	xor a
-	ld [wcf64], a
-	ld a, [hSCX]
-	ld b, a
-.outerloop
-	ld hl, wcf64
-	ld a, [hl]
-	inc [hl]
-	cp 8
-	jr nc, .done
-	ld e, [hl]
-.loop
-; wobble e times
-	ld a, 2
-	ld [hSCX], a
-	ld a, -2
-	ld [wGlobalAnimXOffset], a
-	call EggHatch_DoAnimFrame
-	ld c, 2
-	call DelayFrames
-	ld a, -2
-	ld [hSCX], a
-	ld a, 2
-	ld [wGlobalAnimXOffset], a
-	call EggHatch_DoAnimFrame
-	ld c, 2
-	call DelayFrames
-	dec e
-	jr nz, .loop
-	ld c, 16
-	call DelayFrames
-	call EggHatch_CrackShell
-	jr .outerloop
-
-.done
-	ld de, SFX_EGG_HATCH
-	call PlaySFX
-	xor a
-	ld [hSCX], a
-	ld [wGlobalAnimXOffset], a
-	call ClearSprites
-	call Hatch_InitShellFragments
-	hlcoord 6, 3
-	ld b, VBGMap0 / $100
-	ld c, $00 ; Hatchling tiles start here
-	ld a, [wJumptableIndex]
-	call Hatch_UpdateFrontpicBGMapCenter
-	call Hatch_ShellFragmentLoop
-	call WaitSFX
-	ld a, [wJumptableIndex]
-	ld [CurPartySpecies], a
-	hlcoord 6, 3
-	ld d, $0
-	ld e, ANIM_MON_HATCH
-	predef AnimateFrontpic
-	pop af
-	ld [CurSpecies], a
-	ret
-
-Hatch_LoadFrontpicPal: ; 17363 (5:7363)
-	ld [PlayerHPPal], a
-	ld b, SCGB_EVOLUTION
-	ld c, $0
-	jp GetSGBLayout
-
-EggHatch_CrackShell: ; 1736d (5:736d)
-	ld a, [wcf64]
-	dec a
-	and $7
-	cp $7
-	ret z
-	srl a
-	ret nc
-	swap a
-	srl a
-	add 9 * 8 + 4
-	ld d, a
-	ld e, 11 * 8
-	ld a, SPRITE_ANIM_INDEX_EGG_CRACK
-	call _InitSpriteAnimStruct
-	ld hl, SPRITEANIMSTRUCT_TILE_ID
-	add hl, bc
-	ld [hl], $0
-	ld de, SFX_EGG_CRACK
-	jp PlaySFX
-; 17393 (5:7393)
-
-EggHatchGFX: ; 17393
-INCBIN "gfx/evo/egg_hatch.2bpp"
-; 173b3
-
-Hatch_InitShellFragments: ; 173b3 (5:73b3)
-	callba ClearSpriteAnims
-	ld hl, .SpriteData
-.loop
-	ld a, [hli]
-	cp -1
-	jr z, .done
-	ld e, a
-	ld a, [hli]
-	ld d, a
-	ld a, [hli]
-	ld c, a
-	ld a, [hli]
-	ld b, a
-	push hl
-	push bc
-
-	ld a, SPRITE_ANIM_INDEX_EGG_HATCH
-	call _InitSpriteAnimStruct
-
-	ld hl, SPRITEANIMSTRUCT_TILE_ID
-	add hl, bc
-	ld [hl], $0
-
-	pop de
-	ld a, e
-	ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
-	add hl, bc
-	add [hl]
-	ld [hl], a
-
-	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
-	add hl, bc
-	ld [hl], d
-
-	pop hl
-	jr .loop
-.done
-	ld de, SFX_EGG_HATCH
-	call PlaySFX
-	call EggHatch_DoAnimFrame
-	ret
-; 173ef (5:73ef)
-
-.SpriteData: ; 173ef
-; Probably OAM.
-	dsprite 10, 4,  9, 0, $00, $3c
-	dsprite 11, 4,  9, 0, $01, $04
-	dsprite 10, 4, 10, 0, $00, $30
-	dsprite 11, 4, 10, 0, $01, $10
-	dsprite 10, 4, 11, 0, $02, $24
-	dsprite 11, 4, 11, 0, $03, $1c
-	dsprite 10, 0,  9, 4, $00, $36
-	dsprite 12, 0,  9, 4, $01, $0a
-	dsprite 10, 0, 10, 4, $02, $2a
-	dsprite 12, 0, 10, 4, $03, $16
-	db -1
-; 17418
-
-Hatch_ShellFragmentLoop: ; 17418 (5:7418)
-	ld c, 129
-.loop
-	call EggHatch_DoAnimFrame
-	dec c
-	jr nz, .loop
-	ret
-
-Special_DayCareMon1: ; 17421
-	ld hl, DayCareMon1Text
-	call PrintText
-	ld a, [wBreedMon1Species]
-	call PlayCry
-	ld a, [wDayCareLady]
-	bit 0, a
-	jr z, DayCareMonCursor
-	call ButtonSound
-	ld hl, wBreedMon2Nick
-	call DayCareMonCompatibilityText
-	jp PrintText
-
-Special_DayCareMon2: ; 17440
-	ld hl, DayCareMon2Text
-	call PrintText
-	ld a, [wBreedMon2Species]
-	call PlayCry
-	ld a, [wDayCareMan]
-	bit 0, a
-	jr z, DayCareMonCursor
-	call ButtonSound
-	ld hl, wBreedMon1Nick
-	call DayCareMonCompatibilityText
-	jp PrintText
-
-DayCareMonCursor: ; 1745f
-	jp WaitPressAorB_BlinkCursor
-; 17462
-
-DayCareMon2Text: ; 0x17462
-	; It's @ that was left with the DAY-CARE LADY.
-	text_jump UnknownText_0x1c0df3
-	db "@"
-; 0x17467
-
-DayCareMon1Text: ; 0x17467
-	; It's @ that was left with the DAY-CARE MAN.
-	text_jump UnknownText_0x1c0e24
-	db "@"
-; 0x1746c
-
-DayCareMonCompatibilityText: ; 1746c
-	push bc
-	ld de, StringBuffer1
-	ld bc, NAME_LENGTH
-	call CopyBytes
-	call CheckBreedmonCompatibility
-	pop bc
-	ld a, [wd265]
-	ld hl, .AllAlone
-	cp -1
-	jr z, .done
-	ld hl, .Incompatible
-	and a
-	jr z, .done
-	ld hl, .HighCompatibility
-	cp 230
-	jr nc, .done
-	cp 70
-	ld hl, .ModerateCompatibility
-	jr nc, .done
-	ld hl, .SlightCompatibility
-
-.done
-	ret
-; 1749c
-
-.AllAlone: ; 0x1749c
-	; It's brimming with energy.
-	text_jump UnknownText_0x1c0e54
-	db "@"
-; 0x174a1
-
-.Incompatible: ; 0x174a1
-	; It has no interest in @ .
-	text_jump UnknownText_0x1c0e6f
-	db "@"
-; 0x174a6
-
-.HighCompatibility: ; 0x174a6
-	; It appears to care for @ .
-	text_jump UnknownText_0x1c0e8d
-	db "@"
-; 0x174ab
-
-.ModerateCompatibility: ; 0x174ab
-	; It's friendly with @ .
-	text_jump UnknownText_0x1c0eac
-	db "@"
-; 0x174b0
-
-.SlightCompatibility: ; 0x174b0
-	; It shows interest in @ .
-	text_jump UnknownText_0x1c0ec6
-	db "@"
-; 0x174b5
-
-DayCareMonPrintEmptyString: ; 174b5
-; unreferenced
-	ld hl, .string
-	ret
-; 174b9
-
-.string ; 174b9
-	db "@"
-; 174ba
-
--- /dev/null
+++ b/engine/cgb_layouts.asm
@@ -1,0 +1,1127 @@
+; Replaces the functionality of sgb.asm to work with CGB hardware.
+
+CheckCGB: ; 8d55
+	ld a, [hCGB]
+	and a
+	ret
+; 8d59
+
+Predef_LoadSGBLayoutCGB: ; 8d59
+	ld a, b
+	cp SCGB_RAM
+	jr nz, .not_ram
+	ld a, [SGBPredef]
+.not_ram
+	cp SCGB_PARTY_MENU_HP_PALS
+	jp z, CGB_ApplyPartyMenuHPPals
+	call ResetBGPals
+	ld l, a
+	ld h, 0
+	add hl, hl
+	ld de, .dw
+	add hl, de
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	ld de, .ReturnFromJumpTable
+	push de
+	jp hl
+; 8d79
+
+.ReturnFromJumpTable: ; 8d79
+	ret
+; 8d7a
+
+.dw ; 8d7a
+	dw _CGB_BattleGrayscale
+	dw _CGB_BattleColors
+	dw _CGB_PokegearPals
+	dw _CGB_StatsScreenHPPals
+	dw _CGB_Pokedex
+	dw _CGB_SlotMachine
+	dw _CGB06
+	dw _CGB07
+	dw _CGB_Diploma
+	dw _CGB_MapPals
+	dw _CGB_PartyMenu
+	dw _CGB_Evolution
+	dw _CGB0c
+	dw _CGB0d
+	dw _CGB_MoveList
+	dw _CGB0f
+	dw _CGB_PokedexSearchOption
+	dw _CGB11
+	dw _CGB_Pokepic
+	dw _CGB13
+	dw _CGB_PackPals
+	dw _CGB_TrainerCard
+	dw _CGB_PokedexUnownMode
+	dw _CGB_BillsPC
+	dw _CGB_UnownPuzzle
+	dw _CGB_GamefreakLogo ; called before copyright
+	dw _CGB_PlayerOrMonFrontpicPals
+	dw _CGB_TradeTube
+	dw _CGB_TrainerOrMonFrontpicPals
+	dw _CGB_MysteryGift
+	dw _CGB1e
+; 8db8
+
+_CGB_BattleGrayscale: ; 8db8
+	ld hl, PalPacket_9c66 + 1
+	ld de, UnknBGPals
+	ld c, 4
+	call CopyPalettes
+	ld hl, PalPacket_9c66 + 1
+	ld de, UnknBGPals palette PAL_BATTLE_BG_EXP
+	ld c, 4
+	call CopyPalettes
+	ld hl, PalPacket_9c66 + 1
+	ld de, UnknOBPals
+	ld c, 2
+	call CopyPalettes
+	jr _CGB_FinishBattleScreenLayout
+
+_CGB_BattleColors: ; 8ddb
+	ld de, UnknBGPals
+	call GetBattlemonBackpicPalettePointer
+	push hl
+	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_PLAYER
+	call GetEnemyFrontpicPalettePointer
+	push hl
+	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_ENEMY
+	ld a, [EnemyHPPal]
+	ld l, a
+	ld h, $0
+	add hl, hl
+	add hl, hl
+	ld bc, Palettes_a8be
+	add hl, bc
+	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_ENEMY_HP
+	ld a, [PlayerHPPal]
+	ld l, a
+	ld h, $0
+	add hl, hl
+	add hl, hl
+	ld bc, Palettes_a8be
+	add hl, bc
+	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_PLAYER_HP
+	ld hl, Palettes_a8ca
+	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_EXP
+	ld de, UnknOBPals
+	pop hl
+	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_OB_ENEMY
+	pop hl
+	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_OB_PLAYER
+	ld a, SCGB_BATTLE_COLORS
+	ld [SGBPredef], a
+	call ApplyPals
+_CGB_FinishBattleScreenLayout: ; 8e23
+	call InitPartyMenuBGPal7
+	hlcoord 0, 0, AttrMap
+	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+	ld a, PAL_BATTLE_BG_ENEMY_HP
+	call ByteFill
+	hlcoord 0, 4, AttrMap
+	lb bc, 8, 10
+	ld a, PAL_BATTLE_BG_PLAYER
+	call FillBoxCGB
+	hlcoord 10, 0, AttrMap
+	lb bc, 7, 10
+	ld a, PAL_BATTLE_BG_ENEMY
+	call FillBoxCGB
+	hlcoord 0, 0, AttrMap
+	lb bc, 4, 10
+	ld a, PAL_BATTLE_BG_ENEMY_HP
+	call FillBoxCGB
+	hlcoord 10, 7, AttrMap
+	lb bc, 5, 10
+	ld a, PAL_BATTLE_BG_PLAYER_HP
+	call FillBoxCGB
+	hlcoord 10, 11, AttrMap
+	lb bc, 1, 9
+	ld a, PAL_BATTLE_BG_EXP
+	call FillBoxCGB
+	hlcoord 0, 12, AttrMap
+	ld bc, 6 * SCREEN_WIDTH
+	ld a, PAL_BATTLE_BG_TEXT
+	call ByteFill
+	ld hl, Palettes_979c
+	ld de, UnknOBPals palette PAL_BATTLE_OB_GRAY
+	ld bc, 6 palettes
+	ld a, $5
+	call FarCopyWRAM
+	call ApplyAttrMap
+	ret
+; 8e85
+
+
+InitPartyMenuBGPal7: ; 8e85
+	callba Function100dc0
+Mobile_InitPartyMenuBGPal7: ; 8e8b
+	ld hl, Palette_b311
+	jr nc, .not_mobile
+	ld hl, Palette_b309
+.not_mobile
+	ld de, UnknBGPals palette 7
+	ld bc, 1 palettes
+	ld a, $5
+	call FarCopyWRAM
+	ret
+; 8e9f
+
+InitPartyMenuBGPal0: ; 8e9f
+	callba Function100dc0
+	ld hl, Palette_b311
+	jr nc, .not_mobile
+	ld hl, Palette_b309
+.not_mobile
+	ld de, UnknBGPals palette 0
+	ld bc, 1 palettes
+	ld a, $5
+	call FarCopyWRAM
+	ret
+; 8eb9
+
+_CGB_PokegearPals: ; 8eb9
+	ld a, [PlayerGender]
+	bit 0, a
+	jr z, .male
+	ld hl, FemalePokegearPals
+	jr .got_pals
+
+.male
+	ld hl, MalePokegearPals
+.got_pals
+	ld de, UnknBGPals
+	ld bc, 6 palettes
+	ld a, $5
+	call FarCopyWRAM
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 8edb
+
+_CGB_StatsScreenHPPals: ; 8edb
+	ld de, UnknBGPals
+	ld a, [wCurHPPal]
+	ld l, a
+	ld h, $0
+	add hl, hl
+	add hl, hl
+	ld bc, Palettes_a8be
+	add hl, bc
+	call LoadPalette_White_Col1_Col2_Black ; hp palette
+	ld a, [CurPartySpecies]
+	ld bc, TempMonDVs
+	call GetPlayerOrMonPalettePointer
+	call LoadPalette_White_Col1_Col2_Black ; mon palette
+	ld hl, Palettes_a8ca
+	call LoadPalette_White_Col1_Col2_Black ; exp palette
+	ld hl, StatsScreenPagePals
+	ld de, UnknBGPals palette 3
+	ld bc, 3 palettes ; pink, green, and blue page palettes
+	ld a, $5
+	call FarCopyWRAM
+	call WipeAttrMap
+
+	hlcoord 0, 0, AttrMap
+	lb bc, 8, SCREEN_WIDTH
+	ld a, $1 ; mon palette
+	call FillBoxCGB
+
+	hlcoord 10, 16, AttrMap
+	ld bc, 10
+	ld a, $2 ; exp palette
+	call ByteFill
+
+	hlcoord 13, 5, AttrMap
+	lb bc, 2, 2
+	ld a, $3 ; pink page palette
+	call FillBoxCGB
+
+	hlcoord 15, 5, AttrMap
+	lb bc, 2, 2
+	ld a, $4 ; green page palette
+	call FillBoxCGB
+
+	hlcoord 17, 5, AttrMap
+	lb bc, 2, 2
+	ld a, $5 ; blue page palette
+	call FillBoxCGB
+
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 8f52
+
+StatsScreenPagePals: ; 8f52
+; pink
+	RGB 31, 31, 31
+	RGB 31, 19, 31
+	RGB 31, 15, 31
+	RGB 00, 00, 00
+; green
+	RGB 31, 31, 31
+	RGB 21, 31, 14
+	RGB 17, 31, 00
+	RGB 00, 00, 00
+; blue
+	RGB 31, 31, 31
+	RGB 17, 31, 31
+	RGB 17, 31, 31
+	RGB 00, 00, 00
+; 8f6a
+
+StatsScreenPals: ; 8f6a
+; pink
+	RGB 31, 19, 31
+; green
+	RGB 21, 31, 14
+; blue
+	RGB 17, 31, 31
+; 8f70
+
+_CGB_Pokedex: ; 8f70
+	ld de, UnknBGPals
+	ld a, $1d
+	call GetPredefPal
+	call LoadHLPaletteIntoDE ; dex interface palette
+	ld a, [CurPartySpecies]
+	cp $ff
+	jr nz, .is_pokemon
+	ld hl, .PokedexQuestionMarkPalette
+	call LoadHLPaletteIntoDE ; green question mark palette
+	jr .got_palette
+
+.is_pokemon
+	call GetMonPalettePointer_
+	call LoadPalette_White_Col1_Col2_Black ; mon palette
+.got_palette
+	call WipeAttrMap
+	hlcoord 1, 1, AttrMap
+	lb bc, 7, 7
+	ld a, $1 ; green question mark palette
+	call FillBoxCGB
+	call InitPartyMenuOBPals
+	ld hl, .PokedexCursorPalette
+	ld de, UnknOBPals palette 7 ; green cursor palette
+	ld bc, 1 palettes
+	ld a, $5
+	call FarCopyWRAM
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 8fba
+
+.PokedexQuestionMarkPalette: ; 8fba
+	RGB 11, 23, 00
+	RGB 07, 17, 00
+	RGB 06, 16, 03
+	RGB 05, 12, 01
+
+.PokedexCursorPalette: ; 8fc2
+	RGB 00, 00, 00
+	RGB 11, 23, 00
+	RGB 07, 17, 00
+	RGB 00, 00, 00
+; 8fca
+
+_CGB_BillsPC: ; 8fca
+	ld de, UnknBGPals
+	ld a, $1d
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	ld a, [CurPartySpecies]
+	cp $ff
+	jr nz, .GetMonPalette
+	ld hl, .BillsPCOrangePalette
+	call LoadHLPaletteIntoDE
+	jr .Resume
+
+.GetMonPalette:
+	ld bc, TempMonDVs
+	call GetPlayerOrMonPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+.Resume:
+	call WipeAttrMap
+	hlcoord 1, 4, AttrMap
+	lb bc, 7, 7
+	ld a, $1
+	call FillBoxCGB
+	call InitPartyMenuOBPals
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 9009
+
+.Function9009: ; 9009
+	ld hl, .BillsPCOrangePalette
+	call LoadHLPaletteIntoDE
+	jr .asm_901a
+
+.unused
+	ld bc, TempMonDVs
+	call GetPlayerOrMonPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+.asm_901a
+	call WipeAttrMap
+	hlcoord 1, 1, AttrMap
+	lb bc, 7, 7
+	ld a, $1
+	call FillBoxCGB
+	call InitPartyMenuOBPals
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 9036
+
+.BillsPCOrangePalette: ; 9036
+	RGB 31, 15, 00
+	RGB 23, 12, 00
+	RGB 15, 07, 00
+	RGB 00, 00, 00
+; 903e
+
+_CGB_PokedexUnownMode: ; 903e
+	ld de, UnknBGPals
+	ld a, $1d
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	ld a, [CurPartySpecies]
+	call GetMonPalettePointer_
+	call LoadPalette_White_Col1_Col2_Black
+	call WipeAttrMap
+	hlcoord 7, 5, AttrMap
+	lb bc, 7, 7
+	ld a, $1
+	call FillBoxCGB
+	call InitPartyMenuOBPals
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 906e
+
+_CGB_SlotMachine: ; 906e
+	ld hl, SlotMachinePals
+	ld de, UnknBGPals
+	ld bc, 16 palettes
+	ld a, $5
+	call FarCopyWRAM
+	call WipeAttrMap
+	hlcoord 0, 2, AttrMap
+	lb bc, 10, 3
+	ld a, $2
+	call FillBoxCGB
+	hlcoord 17, 2, AttrMap
+	lb bc, 10, 3
+	ld a, $2
+	call FillBoxCGB
+	hlcoord 0, 4, AttrMap
+	lb bc, 6, 3
+	ld a, $3
+	call FillBoxCGB
+	hlcoord 17, 4, AttrMap
+	lb bc, 6, 3
+	ld a, $3
+	call FillBoxCGB
+	hlcoord 0, 6, AttrMap
+	lb bc, 2, 3
+	ld a, $4
+	call FillBoxCGB
+	hlcoord 17, 6, AttrMap
+	lb bc, 2, 3
+	ld a, $4
+	call FillBoxCGB
+	hlcoord 4, 2, AttrMap
+	lb bc, 2, 12
+	ld a, $1
+	call FillBoxCGB
+	hlcoord 3, 2, AttrMap
+	lb bc, 10, 1
+	ld a, $1
+	call FillBoxCGB
+	hlcoord 16, 2, AttrMap
+	lb bc, 10, 1
+	ld a, $1
+	call FillBoxCGB
+	hlcoord 0, 12, AttrMap
+	ld bc, $78
+	ld a, $7
+	call ByteFill
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 90f8
+
+_CGB06: ; 90f8
+	ld hl, PalPacket_9ca6 + 1
+	call CopyFourPalettes
+	call WipeAttrMap
+	ld de, UnknOBPals
+	ld a, $3c
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	hlcoord 0, 6, AttrMap
+	lb bc, 12, SCREEN_WIDTH
+	ld a, $1
+	call FillBoxCGB
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 9122
+
+_CGB07: ; 9122
+	ld b, 0
+	ld hl, .Jumptable
+	add hl, bc
+	add hl, bc
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	jp hl
+; 912d
+
+.Jumptable: ; 912d
+	dw .Function9133
+	dw .Function9166
+	dw .Function9180
+; 9133
+
+.Function9133: ; 9133
+	ld hl, .Palette_914e
+	ld de, UnknBGPals
+	call LoadHLPaletteIntoDE
+	ld hl, .Palette_9156
+	ld de, UnknOBPals
+	ld bc, 2 palettes
+	ld a, $5
+	call FarCopyWRAM
+	call WipeAttrMap
+	ret
+; 914e
+
+.Palette_914e: ; 914e
+	RGB 19, 31, 19
+	RGB 18, 23, 31
+	RGB 11, 21, 28
+	RGB 04, 16, 24
+
+.Palette_9156: ; 9156
+	RGB 29, 29, 29
+	RGB 20, 19, 20
+	RGB 19, 06, 04
+	RGB 03, 04, 06
+
+	RGB 31, 31, 31
+	RGB 31, 31, 31
+	RGB 31, 00, 00
+	RGB 03, 04, 06
+; 9166
+
+.Function9166: ; 9166
+	ld de, UnknBGPals
+	ld a, $38
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+
+	ld de, UnknOBPals
+	ld a, $39
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	call WipeAttrMap
+	ret
+; 9180
+
+.Function9180: ; 9180
+	ld hl, PalPacket_9c36 + 1
+	call CopyFourPalettes
+	ld de, UnknOBPals
+	ld a, $3a
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	call WipeAttrMap
+	ret
+; 9195
+
+_CGB11: ; 9195
+	ld hl, Palettes_b789
+	ld de, UnknBGPals
+	ld bc, 5 palettes
+	ld a, $5
+	call FarCopyWRAM
+	call ApplyPals
+	call WipeAttrMap
+	call ApplyAttrMap
+	ret
+; 91ad
+
+_CGB_Diploma: ; 91ad
+	ld hl, DiplomaPalettes
+	ld de, UnknBGPals
+	ld bc, 16 palettes
+	ld a, $5
+	call FarCopyWRAM
+
+	ld hl, PalPacket_9cb6 + 1
+	call CopyFourPalettes
+	call WipeAttrMap
+	call ApplyAttrMap
+	ret
+; 91c8
+
+_CGB_MapPals: ; 91c8
+	call LoadMapPals
+	ld a, SCGB_MAPPALS
+	ld [SGBPredef], a
+	ret
+; 91d1
+
+_CGB_PartyMenu: ; 91d1
+	ld hl, PalPacket_9c56 + 1
+	call CopyFourPalettes
+	call InitPartyMenuBGPal0
+	call InitPartyMenuBGPal7
+	call InitPartyMenuOBPals
+	call ApplyAttrMap
+	ret
+; 91e4
+
+_CGB_Evolution: ; 91e4
+	ld de, UnknBGPals
+	ld a, c
+	and a
+	jr z, .pokemon
+	ld a, $1a
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	jr .got_palette
+
+.pokemon
+	ld hl, PartyMon1DVs
+	ld bc, PARTYMON_STRUCT_LENGTH
+	ld a, [CurPartyMon]
+	call AddNTimes
+	ld c, l
+	ld b, h
+	ld a, [PlayerHPPal]
+	call GetPlayerOrMonPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld hl, Palettes_979c
+	ld de, UnknOBPals palette 2
+	ld bc, 6 palettes
+	ld a, $5
+	call FarCopyWRAM
+
+.got_palette
+	call WipeAttrMap
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 9228
+
+_CGB0c: ; 9228
+	ld hl, Palettes_b6f1
+	ld de, UnknBGPals
+	ld bc, 5 palettes
+	ld a, $5
+	call FarCopyWRAM
+	ld hl, Palettes_b719
+	ld de, UnknOBPals
+	ld bc, 2 palettes
+	ld a, $5
+	call FarCopyWRAM
+	ld a, SCGB_DIPLOMA
+	ld [SGBPredef], a
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 9251
+
+_CGB0d: ; 9251
+	ld hl, PalPacket_9cb6 + 1
+	call CopyFourPalettes
+	call WipeAttrMap
+	call ApplyAttrMap
+	ret
+; 925e
+
+_CGB_UnownPuzzle: ; 925e
+	ld hl, PalPacket_9bc6 + 1
+	call CopyFourPalettes
+	ld de, UnknOBPals
+	ld a, $4c
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	ld a, [rSVBK]
+	push af
+	ld a, $5
+	ld [rSVBK], a
+	ld hl, UnknOBPals
+	ld a, $1f
+	ld [hli], a
+	ld a, $0
+	ld [hl], a
+	pop af
+	ld [rSVBK], a
+	call WipeAttrMap
+	call ApplyAttrMap
+	ret
+; 9289
+
+_CGB_TrainerCard: ; 9289
+	ld de, UnknBGPals
+	xor a ; CHRIS
+	call GetTrainerPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld a, FALKNER ; KRIS
+	call GetTrainerPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld a, BUGSY
+	call GetTrainerPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld a, WHITNEY
+	call GetTrainerPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld a, MORTY
+	call GetTrainerPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld a, CHUCK
+	call GetTrainerPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld a, JASMINE
+	call GetTrainerPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld a, PRYCE
+	call GetTrainerPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	ld a, $24
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+
+	; fill screen with opposite-gender palette for the card border
+	hlcoord 0, 0, AttrMap
+	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+	ld a, [PlayerGender]
+	and a
+	ld a, $1 ; kris
+	jr z, .got_gender
+	ld a, $0 ; chris
+.got_gender
+	call ByteFill
+	; fill trainer sprite area with same-gender palette
+	hlcoord 14, 1, AttrMap
+	lb bc, 7, 5
+	ld a, [PlayerGender]
+	and a
+	ld a, $0 ; chris
+	jr z, .got_gender2
+	ld a, $1 ; kris
+.got_gender2
+	call FillBoxCGB
+	; top-right corner still uses the border's palette
+	hlcoord 18, 1, AttrMap
+	ld [hl], $1
+	hlcoord 2, 11, AttrMap
+	lb bc, 2, 4
+	ld a, $1 ; falkner
+	call FillBoxCGB
+	hlcoord 6, 11, AttrMap
+	lb bc, 2, 4
+	ld a, $2 ; bugsy
+	call FillBoxCGB
+	hlcoord 10, 11, AttrMap
+	lb bc, 2, 4
+	ld a, $3 ; whitney
+	call FillBoxCGB
+	hlcoord 14, 11, AttrMap
+	lb bc, 2, 4
+	ld a, $4 ; morty
+	call FillBoxCGB
+	hlcoord 2, 14, AttrMap
+	lb bc, 2, 4
+	ld a, $5 ; chuck
+	call FillBoxCGB
+	hlcoord 6, 14, AttrMap
+	lb bc, 2, 4
+	ld a, $6 ; jasmine
+	call FillBoxCGB
+	hlcoord 10, 14, AttrMap
+	lb bc, 2, 4
+	ld a, $7 ; pryce
+	call FillBoxCGB
+	; clair uses kris's palette
+	ld a, [PlayerGender]
+	and a
+	push af
+	jr z, .got_gender3
+	hlcoord 14, 14, AttrMap
+	lb bc, 2, 4
+	ld a, $1
+	call FillBoxCGB
+.got_gender3
+	pop af
+	ld c, $0
+	jr nz, .got_gender4
+	inc c
+.got_gender4
+	ld a, c
+	hlcoord 18, 1, AttrMap
+	ld [hl], a
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 9373
+
+_CGB_MoveList: ; 9373
+	ld de, UnknBGPals
+	ld a, $10
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	ld a, [PlayerHPPal]
+	ld l, a
+	ld h, 0
+	add hl, hl
+	add hl, hl
+	ld bc, Palettes_a8be
+	add hl, bc
+	call LoadPalette_White_Col1_Col2_Black
+	call WipeAttrMap
+	hlcoord 11, 1, AttrMap
+	lb bc, 2, 9
+	ld a, $1
+	call FillBoxCGB
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 93a6
+
+_CGB0f: ; 93a6
+	ld hl, PalPacket_9c46 + 1
+	call CopyFourPalettes
+	call WipeAttrMap
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 93ba
+
+_CGB_PokedexSearchOption: ; 93ba
+	ld de, UnknBGPals
+	ld a, $1d
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	call WipeAttrMap
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 93d3
+
+_CGB_PackPals: ; 93d3
+; pack pals
+	ld a, [BattleType]
+	cp BATTLETYPE_TUTORIAL
+	jr z, .tutorial_male
+
+	ld a, [PlayerGender]
+	bit 0, a
+	jr z, .tutorial_male
+
+	ld hl, .KrisPackPals
+	jr .got_gender
+
+.tutorial_male
+	ld hl, .ChrisPackPals
+
+.got_gender
+	ld de, UnknBGPals
+	ld bc, 8 palettes ; 6 palettes?
+	ld a, $5
+	call FarCopyWRAM
+	call WipeAttrMap
+	hlcoord 0, 0, AttrMap
+	lb bc, 1, 10
+	ld a, $1
+	call FillBoxCGB
+	hlcoord 10, 0, AttrMap
+	lb bc, 1, 10
+	ld a, $2
+	call FillBoxCGB
+	hlcoord 7, 2, AttrMap
+	lb bc, 9, 1
+	ld a, $3
+	call FillBoxCGB
+	hlcoord 0, 7, AttrMap
+	lb bc, 3, 5
+	ld a, $4
+	call FillBoxCGB
+	hlcoord 0, 3, AttrMap
+	lb bc, 3, 5
+	ld a, $5
+	call FillBoxCGB
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 9439
+
+.ChrisPackPals: ; 9439
+	RGB 31, 31, 31
+	RGB 15, 15, 31
+	RGB 00, 00, 31
+	RGB 00, 00, 00
+
+	RGB 31, 31, 31
+	RGB 15, 15, 31
+	RGB 00, 00, 31
+	RGB 00, 00, 00
+
+	RGB 31, 11, 31
+	RGB 15, 15, 31
+	RGB 00, 00, 31
+	RGB 00, 00, 00
+
+	RGB 31, 31, 31
+	RGB 15, 15, 31
+	RGB 00, 00, 31
+	RGB 31, 00, 00
+
+	RGB 31, 31, 31
+	RGB 15, 15, 31
+	RGB 31, 00, 00
+	RGB 00, 00, 00
+
+	RGB 31, 31, 31
+	RGB 07, 19, 07
+	RGB 07, 19, 07
+	RGB 00, 00, 00
+; 9469
+
+.KrisPackPals: ; 9469
+	RGB 31, 31, 31
+	RGB 31, 14, 31
+	RGB 31, 07, 31
+	RGB 00, 00, 00
+
+	RGB 31, 31, 31
+	RGB 31, 14, 31
+	RGB 31, 07, 31
+	RGB 00, 00, 00
+
+	RGB 15, 15, 31
+	RGB 31, 14, 31
+	RGB 31, 07, 31
+	RGB 00, 00, 00
+
+	RGB 31, 31, 31
+	RGB 31, 14, 31
+	RGB 31, 07, 31
+	RGB 31, 00, 00
+
+	RGB 31, 31, 31
+	RGB 31, 14, 31
+	RGB 31, 00, 00
+	RGB 00, 00, 00
+
+	RGB 31, 31, 31
+	RGB 07, 19, 07
+	RGB 07, 19, 07
+	RGB 00, 00, 00
+; 9499
+
+_CGB_Pokepic: ; 9499
+	call _CGB_MapPals
+	ld de, SCREEN_WIDTH
+	hlcoord 0, 0, AttrMap
+	ld a, [wMenuBorderTopCoord]
+.loop
+	and a
+	jr z, .found_top
+	dec a
+	add hl, de
+	jr .loop
+
+.found_top
+	ld a, [wMenuBorderLeftCoord]
+	ld e, a
+	ld d, $0
+	add hl, de
+	ld a, [wMenuBorderTopCoord]
+	ld b, a
+	ld a, [wMenuBorderBottomCoord]
+	inc a
+	sub b
+	ld b, a
+	ld a, [wMenuBorderLeftCoord]
+	ld c, a
+	ld a, [wMenuBorderRightCoord]
+	sub c
+	inc a
+	ld c, a
+	ld a, $0
+	call FillBoxCGB
+	call ApplyAttrMap
+	ret
+; 94d0
+
+_CGB13: ; 94d0
+	ld hl, PalPacket_9ba6 + 1
+	call CopyFourPalettes
+	call WipeAttrMap
+	hlcoord 0, 4, AttrMap
+	lb bc, 10, SCREEN_WIDTH
+	ld a, $2
+	call FillBoxCGB
+	hlcoord 0, 6, AttrMap
+	lb bc, 6, SCREEN_WIDTH
+	ld a, $1
+	call FillBoxCGB
+	call ApplyAttrMap
+	call ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 94fa
+
+_CGB_GamefreakLogo: ; 94fa
+	ld de, UnknBGPals
+	ld a, $4e
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	ld hl, .Palette
+	ld de, UnknOBPals
+	call LoadHLPaletteIntoDE
+	ld hl, .Palette
+	ld de, UnknOBPals palette 1
+	call LoadHLPaletteIntoDE
+	call WipeAttrMap
+	call ApplyAttrMap
+	call ApplyPals
+	ret
+; 9521
+
+.Palette: ; 9521
+	RGB 31, 31, 31
+	RGB 13, 11, 00
+	RGB 23, 12, 28
+	RGB 00, 00, 00
+; 9529
+
+_CGB_PlayerOrMonFrontpicPals: ; 9529
+	ld de, UnknBGPals
+	ld a, [CurPartySpecies]
+	ld bc, TempMonDVs
+	call GetPlayerOrMonPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	call WipeAttrMap
+	call ApplyAttrMap
+	call ApplyPals
+	ret
+; 9542
+
+_CGB1e: ; 9542
+	ld de, UnknBGPals
+	ld a, [CurPartySpecies]
+	call GetMonPalettePointer_
+	call LoadPalette_White_Col1_Col2_Black
+	call WipeAttrMap
+	call ApplyAttrMap
+	ret
+; 9555
+
+_CGB_TradeTube: ; 9555
+	ld hl, PalPacket_9cc6 + 1
+	call CopyFourPalettes
+	ld hl, Palettes_b681
+	ld de, UnknOBPals
+	ld bc, 1 palettes
+	ld a, $5
+	call FarCopyWRAM
+	ld de, UnknOBPals palette 7
+	ld a, $1c
+	call GetPredefPal
+	call LoadHLPaletteIntoDE
+	call WipeAttrMap
+	ret
+; 9578
+
+_CGB_TrainerOrMonFrontpicPals: ; 9578
+	ld de, UnknBGPals
+	ld a, [CurPartySpecies]
+	ld bc, TempMonDVs
+	call GetFrontpicPalettePointer
+	call LoadPalette_White_Col1_Col2_Black
+	call WipeAttrMap
+	call ApplyAttrMap
+	call ApplyPals
+	ret
+; 9591
+
+_CGB_MysteryGift: ; 9591
+	ld hl, .Palettes
+	ld de, UnknBGPals
+	ld bc, 2 palettes
+	ld a, $5
+	call FarCopyWRAM
+	call ApplyPals
+	call WipeAttrMap
+	hlcoord 3, 7, AttrMap
+	lb bc, 8, 14
+	ld a, $1
+	call FillBoxCGB
+	hlcoord 1, 5, AttrMap
+	lb bc, 1, 18
+	ld a, $1
+	call FillBoxCGB
+	hlcoord 1, 16, AttrMap
+	lb bc, 1, 18
+	ld a, $1
+	call FillBoxCGB
+	hlcoord 0, 0, AttrMap
+	lb bc, 17, 2
+	ld a, $1
+	call FillBoxCGB
+	hlcoord 18, 5, AttrMap
+	lb bc, 12, 1
+	ld a, $1
+	call FillBoxCGB
+	call ApplyAttrMap
+	ret
+; 95e0
+
+.Palettes: ; 95e0
+	RGB 31, 31, 31
+	RGB 16, 31, 14
+	RGB 05, 14, 21
+	RGB 05, 13, 10
+
+	RGB 31, 31, 31
+	RGB 11, 21, 25
+	RGB 05, 14, 21
+	RGB 00, 03, 19
+; 95f0
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -1,5 +1,4 @@
-PALPACKET_LENGTH EQU $10
-INCLUDE "predef/sgb.asm"
+INCLUDE "engine/sgb_layouts.asm"
 
 SHINY_ATK_BIT EQU 5
 SHINY_DEF_VAL EQU 10
@@ -500,7 +499,7 @@
 	RGB 00, 21, 00
 	RGB 00, 00, 00
 
-INCLUDE "predef/cgb.asm"
+INCLUDE "engine/cgb_layouts.asm"
 
 Function95f0:
 ; XXX
@@ -2027,13 +2026,13 @@
 	RGB 00, 00, 00
 
 TilesetBGPalette:
-INCLUDE "tilesets/bg.pal"
+INCLUDE "data/palettes/bg.pal"
 
 MapObjectPals::
-INCLUDE "tilesets/ob.pal"
+INCLUDE "data/palettes/ob.pal"
 
 RoofPals:
-INCLUDE "tilesets/roof.pal"
+INCLUDE "data/palettes/roof.pal"
 
 DiplomaPalettes:
 	RGB 27, 31, 27
--- /dev/null
+++ b/engine/crystal_colors.asm
@@ -1,0 +1,614 @@
+GetMysteryGift_MobileAdapterLayout: ; 4930f (mobile)
+	ld a, b
+	cp SCGB_RAM
+	jr nz, .not_ram
+	ld a, [SGBPredef]
+.not_ram
+	push af
+	callba ResetBGPals
+	pop af
+	ld l, a
+	ld h, 0
+	add hl, hl
+	ld de, .dw
+	add hl, de
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	ld de, .done
+	push de
+	jp hl
+.done
+	ret
+; 49330 (12:5330)
+
+.dw ; 49330
+
+	dw MG_Mobile_Layout00
+	dw MG_Mobile_Layout01
+	dw MG_Mobile_Layout02
+; 49336
+
+MG_Mobile_Layout_FillBox: ; 49336
+.row
+	push bc
+	push hl
+.col
+	ld [hli], a
+	dec c
+	jr nz, .col
+	pop hl
+	ld bc, SCREEN_WIDTH
+	add hl, bc
+	pop bc
+	dec b
+	jr nz, .row
+	ret
+; 49346
+
+MG_Mobile_Layout_WipeAttrMap: ; 49346 (12:5346)
+	hlcoord 0, 0, AttrMap
+	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+	xor a
+	call ByteFill
+	ret
+
+MG_Mobile_Layout_LoadPals: ; 49351 (12:5351)
+	ld de, UnknBGPals
+	ld hl, Palette_493e1
+	ld bc, 5 palettes
+	ld a, $5 ; BANK(UnknBGPals)
+	call FarCopyWRAM
+	ld de, UnknBGPals + 7 palettes
+	ld hl, Palette_TextBG7
+	ld bc, 1 palettes
+	ld a, $5 ; BANK(UnknBGPals)
+	call FarCopyWRAM
+	ret
+
+MG_Mobile_Layout00: ; 4936e (12:536e)
+	call MG_Mobile_Layout_LoadPals
+	call MG_Mobile_Layout_WipeAttrMap
+	call MG_Mobile_Layout_CreatePalBoxes
+	callba ApplyAttrMap
+	callba ApplyPals
+	ret
+
+MG_Mobile_Layout_CreatePalBoxes: ; 49384 (12:5384)
+	hlcoord 0, 0, AttrMap
+	lb bc, 4, 1
+	ld a, $1
+	call MG_Mobile_Layout_FillBox
+	lb bc, 2, 1
+	ld a, $2
+	call MG_Mobile_Layout_FillBox
+	lb bc, 6, 1
+	ld a, $3
+	call MG_Mobile_Layout_FillBox
+	hlcoord 1, 0, AttrMap
+	ld a, $1
+	lb bc, 3, 18
+	call MG_Mobile_Layout_FillBox
+	lb bc, 2, 18
+	ld a, $2
+	call MG_Mobile_Layout_FillBox
+	lb bc, 12, 18
+	ld a, $3
+	call MG_Mobile_Layout_FillBox
+	hlcoord 19, 0, AttrMap
+	lb bc, 4, 1
+	ld a, $1
+	call MG_Mobile_Layout_FillBox
+	lb bc, 2, 1
+	ld a, $2
+	call MG_Mobile_Layout_FillBox
+	lb bc, 6, 1
+	ld a, $3
+	call MG_Mobile_Layout_FillBox
+	hlcoord 0, 12, AttrMap
+	ld bc, 6 * SCREEN_WIDTH
+	ld a, $7
+	call ByteFill
+	ret
+; 493e1 (12:53e1)
+
+Palette_493e1: ; 493e1
+	RGB 03, 07, 09
+	RGB 26, 31, 00
+	RGB 20, 16, 03
+	RGB 31, 31, 31
+
+	RGB 13, 24, 29
+	RGB 11, 16, 30
+	RGB 07, 11, 22
+	RGB 05, 06, 18
+
+	RGB 31, 31, 31
+	RGB 20, 26, 31
+	RGB 13, 24, 29
+	RGB 11, 16, 30
+
+	RGB 31, 31, 31
+	RGB 20, 26, 31
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+
+	RGB 31, 31, 31
+	RGB 20, 16, 08
+	RGB 31, 00, 00
+	RGB 00, 00, 00
+; 49409
+
+LoadOW_BGPal7:: ; 49409
+	ld hl, Palette_TextBG7
+	ld de, UnknBGPals + 8 * 7
+	ld bc, 8
+	ld a, $5
+	call FarCopyWRAM
+	ret
+; 49418
+
+Palette_TextBG7: ; 49418
+	RGB 31, 31, 31
+	RGB 08, 19, 28
+	RGB 05, 05, 16
+	RGB 00, 00, 00
+; 49420
+
+Function49420:: ; 49420 (12:5420)
+	ld hl, MansionPalette4
+	ld de, UnknBGPals + $30
+	ld bc, $8
+	ld a, $5 ; BANK(UnknBGPals)
+	call FarCopyWRAM
+	ret
+; 4942f (12:542f)
+
+MG_Mobile_Layout01: ; 4942f
+	call MG_Mobile_Layout_LoadPals
+	ld de, UnknBGPals + $38
+	ld hl, Palette_49478
+	ld bc, $8
+	ld a, $5 ; BANK(UnknBGPals)
+	call FarCopyWRAM
+	call MG_Mobile_Layout_WipeAttrMap
+	hlcoord 0, 0, AttrMap
+	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+	xor a
+	call ByteFill
+	hlcoord 0, 14, AttrMap
+	ld bc, 4 * SCREEN_WIDTH
+	ld a, $7
+	call ByteFill
+	ld a, [wd002]
+	bit 6, a
+	jr z, .asm_49464
+	call Function49480
+	jr .asm_49467
+
+.asm_49464
+	call Function49496
+
+.asm_49467
+	callba ApplyAttrMap
+	callba ApplyPals
+	ld a, $1
+	ld [hCGBPalUpdate], a
+	ret
+; 49478
+
+Palette_49478: ; 49478
+	RGB 31, 31, 31
+	RGB 26, 31, 00
+	RGB 20, 16, 03
+	RGB 00, 00, 00
+; 49480
+
+Function49480: ; 49480
+	hlcoord 0, 0, AttrMap
+	lb bc, 4, SCREEN_WIDTH
+	ld a, $7
+	call MG_Mobile_Layout_FillBox
+	hlcoord 0, 2, AttrMap
+	ld a, $4
+	ld [hl], a
+	hlcoord 19, 2, AttrMap
+	ld [hl], a
+	ret
+; 49496
+
+Function49496: ; 49496
+	hlcoord 0, 0, AttrMap
+	lb bc, 2, SCREEN_WIDTH
+	ld a, $7
+	call MG_Mobile_Layout_FillBox
+	hlcoord 0, 1, AttrMap
+	ld a, $4
+	ld [hl], a
+	hlcoord 19, 1, AttrMap
+	ld [hl], a
+	ret
+; 494ac
+
+LoadSpecialMapPalette: ; 494ac
+	ld a, [wTileset]
+	cp TILESET_POKECOM_CENTER
+	jr z, .pokecom_2f
+	cp TILESET_BATTLE_TOWER
+	jr z, .battle_tower
+	cp TILESET_ICE_PATH
+	jr z, .ice_path
+	cp TILESET_HOUSE_1
+	jr z, .house
+	cp TILESET_RADIO_TOWER
+	jr z, .radio_tower
+	cp TILESET_CELADON_MANSION
+	jr z, .mansion_mobile
+	jr .do_nothing
+
+.pokecom_2f
+	call LoadPokeComPalette
+	scf
+	ret
+
+.battle_tower
+	call LoadBattleTowerPalette
+	scf
+	ret
+
+.ice_path
+	ld a, [wPermission] ; permission
+	and 7
+	cp 3 ; Hall of Fame
+	jr z, .do_nothing
+	call LoadIcePathPalette
+	scf
+	ret
+
+.house
+	call LoadHousePalette
+	scf
+	ret
+
+.radio_tower
+	call LoadRadioTowerPalette
+	scf
+	ret
+
+.mansion_mobile
+	call LoadMansionPalette
+	scf
+	ret
+
+.do_nothing
+	and a
+	ret
+; 494f2
+
+LoadPokeComPalette: ; 494f2
+	ld a, $5
+	ld de, UnknBGPals
+	ld hl, PokeComPalette
+	ld bc, 8 palettes
+	call FarCopyWRAM
+	ret
+; 49501
+
+PokeComPalette: ; 49501
+INCLUDE "tilesets/pokecom_center.pal"
+; 49541
+
+LoadBattleTowerPalette: ; 49541
+	ld a, $5
+	ld de, UnknBGPals
+	ld hl, BattleTowerPalette
+	ld bc, 8 palettes
+	call FarCopyWRAM
+	ret
+; 49550
+
+BattleTowerPalette: ; 49550
+INCLUDE "tilesets/battle_tower.pal"
+; 49590
+
+LoadIcePathPalette: ; 49590
+	ld a, $5
+	ld de, UnknBGPals
+	ld hl, IcePathPalette
+	ld bc, 8 palettes
+	call FarCopyWRAM
+	ret
+; 4959f
+
+IcePathPalette: ; 4959f
+INCLUDE "tilesets/ice_path.pal"
+; 495df
+
+LoadHousePalette: ; 495df
+	ld a, $5
+	ld de, UnknBGPals
+	ld hl, HousePalette
+	ld bc, 8 palettes
+	call FarCopyWRAM
+	ret
+; 495ee
+
+HousePalette: ; 495ee
+INCLUDE "tilesets/house_1.pal"
+; 4962e
+
+LoadRadioTowerPalette: ; 4962e
+	ld a, $5
+	ld de, UnknBGPals
+	ld hl, RadioTowerPalette
+	ld bc, 8 palettes
+	call FarCopyWRAM
+	ret
+; 4963d
+
+RadioTowerPalette: ; 4963d
+INCLUDE "tilesets/radio_tower.pal"
+; 4967d
+
+MansionPalette1: ; 4967d
+	RGB 30, 28, 26
+	RGB 19, 19, 19
+	RGB 13, 13, 13
+	RGB 07, 07, 07
+
+	RGB 30, 28, 26
+	RGB 31, 19, 24
+	RGB 30, 10, 06
+	RGB 07, 07, 07
+
+	RGB 18, 24, 09
+	RGB 15, 20, 01
+	RGB 09, 13, 00
+	RGB 07, 07, 07
+
+	RGB 30, 28, 26
+	RGB 15, 16, 31
+	RGB 09, 09, 31
+	RGB 07, 07, 07
+
+	RGB 30, 28, 26
+	RGB 31, 31, 07
+	RGB 31, 16, 01
+	RGB 07, 07, 07
+
+	RGB 26, 24, 17
+	RGB 21, 17, 07
+	RGB 16, 13, 03
+	RGB 07, 07, 07
+
+MansionPalette3: ; 496ad
+	RGB 30, 28, 26
+	RGB 17, 19, 31
+	RGB 14, 16, 31
+	RGB 07, 07, 07
+
+	RGB 31, 31, 16
+	RGB 31, 31, 16
+	RGB 14, 09, 00
+	RGB 00, 00, 00
+; 496bd
+
+MansionPalette4: ; 496bd
+	RGB 05, 05, 16
+	RGB 08, 19, 28
+	RGB 00, 00, 00
+	RGB 31, 31, 31
+; 496c5
+
+LoadMansionPalette: ; 496c5
+	ld a, $5
+	ld de, UnknBGPals
+	ld hl, MansionPalette1
+	ld bc, 8 palettes
+	call FarCopyWRAM
+	ld a, $5
+	ld de, UnknBGPals + 4 palettes
+	ld hl, MansionPalette2
+	ld bc, 1 palettes
+	call FarCopyWRAM
+	ld a, $5
+	ld de, UnknBGPals + 3 palettes
+	ld hl, MansionPalette3
+	ld bc, 1 palettes
+	call FarCopyWRAM
+	ld a, $5
+	ld de, UnknBGPals + 6 palettes
+	ld hl, MansionPalette4
+	ld bc, 1 palettes
+	call FarCopyWRAM
+	ret
+; 496fe
+
+MansionPalette2: ; 496fe
+	RGB 25, 24, 23
+	RGB 20, 19, 19
+	RGB 14, 16, 31
+	RGB 07, 07, 07
+; 49706
+
+MG_Mobile_Layout02: ; 49706
+	ld hl, Palette_49732
+	ld de, UnknBGPals
+	ld bc, 1 palettes
+	ld a, $5
+	call FarCopyWRAM
+	callba ApplyPals
+	call MG_Mobile_Layout_WipeAttrMap
+	callba ApplyAttrMap
+	ld hl, Palette_4973a
+	ld de, UnknOBPals
+	ld bc, 1 palettes
+	ld a, $5
+	call FarCopyWRAM
+	ret
+; 49732
+
+Palette_49732: ; 49732
+	RGB 31, 31, 31
+	RGB 23, 16, 07
+	RGB 23, 07, 07
+	RGB 03, 07, 20
+; 4973a
+
+Palette_4973a: ; 4973a
+	RGB 00, 00, 00
+	RGB 07, 05, 31
+	RGB 14, 18, 31
+	RGB 31, 31, 31
+; 49742
+
+Function49742: ; 49742
+	ld hl, Palette_49757
+	ld de, UnknBGPals
+	ld bc, $40
+	ld a, $5
+	call FarCopyWRAM
+	callba ApplyPals
+	ret
+; 49757
+
+Palette_49757: ; 49757
+	RGB 31, 31, 63
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+
+	RGB 31, 31, 63
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+	RGB 00, 00, 00
+
+	RGB 04, 02, 15
+	RGB 21, 00, 21
+	RGB 31, 00, 00
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 21, 00, 21
+	RGB 30, 16, 26
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 21, 00, 21
+	RGB 16, 16, 16
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 21, 00, 21
+	RGB 31, 12, 12
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 21, 00, 21
+	RGB 07, 08, 31
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 21, 00, 21
+	RGB 29, 28, 09
+	RGB 31, 31, 31
+; 49797
+
+_InitMG_Mobile_LinkTradePalMap: ; 49797
+	hlcoord 0, 0, AttrMap
+	lb bc, 16, 2
+	ld a, $4
+	call MG_Mobile_Layout_FillBox
+	ld a, $3
+	ldcoord_a 0, 1, AttrMap
+	ldcoord_a 0, 14, AttrMap
+	hlcoord 2, 0, AttrMap
+	lb bc, 8, 18
+	ld a, $5
+	call MG_Mobile_Layout_FillBox
+	hlcoord 2, 8, AttrMap
+	lb bc, 8, 18
+	ld a, $6
+	call MG_Mobile_Layout_FillBox
+	hlcoord 0, 16, AttrMap
+	lb bc, 2, SCREEN_WIDTH
+	ld a, $4
+	call MG_Mobile_Layout_FillBox
+	ld a, $3
+	lb bc, 6, 1
+	hlcoord 6, 1, AttrMap
+	call MG_Mobile_Layout_FillBox
+	ld a, $3
+	lb bc, 6, 1
+	hlcoord 17, 1, AttrMap
+	call MG_Mobile_Layout_FillBox
+	ld a, $3
+	lb bc, 6, 1
+	hlcoord 6, 9, AttrMap
+	call MG_Mobile_Layout_FillBox
+	ld a, $3
+	lb bc, 6, 1
+	hlcoord 17, 9, AttrMap
+	call MG_Mobile_Layout_FillBox
+	ld a, $2
+	hlcoord 2, 16, AttrMap
+	ld [hli], a
+	ld a, $7
+	ld [hli], a
+	ld [hli], a
+	ld [hli], a
+	ld a, $2
+	ld [hl], a
+	hlcoord 2, 17, AttrMap
+	ld a, $3
+	ld bc, 6
+	call ByteFill
+	ret
+; 49811
+
+LoadTradeRoomBGPals: ; 49811
+	ld hl, Palette_49826
+	ld de, UnknBGPals + $10
+	ld bc, $30
+	ld a, $5
+	call FarCopyWRAM
+	callba ApplyPals
+	ret
+; 49826
+
+Palette_49826: ; 49826
+	RGB 04, 02, 15
+	RGB 07, 09, 31
+	RGB 31, 00, 00
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 07, 09, 31
+	RGB 15, 23, 30
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 07, 09, 31
+	RGB 16, 16, 16
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 07, 09, 31
+	RGB 25, 07, 04
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 07, 09, 31
+	RGB 03, 22, 08
+	RGB 31, 31, 31
+
+	RGB 04, 02, 15
+	RGB 07, 09, 31
+	RGB 29, 28, 09
+	RGB 31, 31, 31
+; 49856
+
+InitMG_Mobile_LinkTradePalMap: ; 49856
+	call _InitMG_Mobile_LinkTradePalMap
+	ret
+; 4985a
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -2034,7 +2034,7 @@
 	ret
 ; 28f24
 
-INCLUDE "engine/trade/animation.asm"
+INCLUDE "engine/trade_animation.asm"
 
 Special_CheckTimeCapsuleCompatibility: ; 29bfb
 ; Checks to see if your Party is compatible with the generation 1 games.  Returns the following in ScriptVar:
--- a/engine/printer.asm
+++ b/engine/printer.asm
@@ -1,4 +1,4 @@
-INCLUDE "engine/printer/serial.asm"
+INCLUDE "engine/printer_serial.asm"
 
 SendScreenToPrinter: ; 843f0
 .loop
--- a/engine/printer/serial.asm
+++ /dev/null
@@ -1,645 +1,0 @@
-Printer_StartTransmission: ; 84000
-	ld hl, wGameboyPrinterRAM
-	ld bc, wGameboyPrinterRAMEnd - wGameboyPrinterRAM
-	xor a
-	call Printer_ByteFill
-	xor a
-	ld [rSB], a
-	ld [rSC], a
-	ld [wPrinterOpcode], a
-	ld hl, wPrinterConnectionOpen
-	set 0, [hl]
-	ld a, [GBPrinter]
-	ld [wGBPrinterSettings], a
-	xor a
-	ld [wJumptableIndex], a
-	ret
-; 84022
-
-PrinterJumptableIteration: ; 84022
-	ld a, [wJumptableIndex]
-	ld e, a
-	ld d, 0
-	ld hl, .Jumptable
-	add hl, de
-	add hl, de
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	jp hl
-; 84031
-
-
-.Jumptable: ; 84031 (21:4031)
-
-	dw Print_InitPrinterHandshake ; 00
-	dw Printer_CheckConnectionStatus ; 01
-	dw Printer_WaitSerial ; 02
-	dw Printer_StartTransmittingTilemap ; 03
-	dw Printer_TransmissionLoop ; 04
-	dw Printer_WaitSerialAndLoopBack2 ; 05
-
-	dw Printer_EndTilemapTransmission ; 06
-	dw Printer_TransmissionLoop ; 07
-	dw Printer_WaitSerial ; 08
-	dw Printer_SignalSendHeader ; 09
-	dw Printer_TransmissionLoop ; 0a
-	dw Printer_WaitSerial ; 0b
-	dw Printer_WaitUntilFinished ; 0c
-	dw Printer_Quit ; 0d
-
-	dw Printer_NextSection_ ; 0e
-	dw Printer_WaitSerial ; 0f
-	dw Printer_SignalLoopBack ; 10
-	dw Printer_SectionOne ; 11
-	dw Printer_WaitLoopBack ; 12
-	dw Printer_WaitLoopBack_ ; 13
-
-
-Printer_NextSection: ; 84059 (21:4059)
-	ld hl, wJumptableIndex
-	inc [hl]
-	ret
-
-Printer_PrevSection: ; 8405e (21:405e)
-	ld hl, wJumptableIndex
-	dec [hl]
-	ret
-
-Printer_Quit: ; 84063 (21:4063)
-	xor a
-	ld [wPrinterStatusFlags], a
-	ld hl, wJumptableIndex
-	set 7, [hl]
-	ret
-
-Printer_NextSection_: ; 8406d (21:406d)
-	call Printer_NextSection
-	ret
-
-Printer_SectionOne: ; 84071 (21:4071)
-	ld a, $1
-	ld [wJumptableIndex], a
-	ret
-
-Print_InitPrinterHandshake: ; 84077 (21:4077)
-	call Printer_ResetData
-	ld hl, PrinterDataPacket1
-	call Printer_CopyPacket
-	xor a
-	ld [wPrinterSendByteCounter], a
-	ld [wPrinterSendByteCounter + 1], a
-	ld a, [wPrinterQueueLength]
-	ld [wPrinterRowIndex], a
-	call Printer_NextSection
-	call Printer_WaitHandshake
-	ld a, PRINTER_STATUS_CHECKING
-	ld [wPrinterStatus], a
-	ret
-
-Printer_StartTransmittingTilemap: ; 84099 (21:4099)
-	call Printer_ResetData
-	; check ???
-	ld hl, wPrinterRowIndex
-	ld a, [hl]
-	and a
-	jr z, Printer_EndTilemapTransmission
-	; send packet 3
-	ld hl, PrinterDataPacket3 ; signal start of transmission
-	call Printer_CopyPacket
-	; prepare to send 40 tiles
-	call Printer_Convert2RowsTo2bpp
-	ld a, (40 tiles) % $100
-	ld [wPrinterSendByteCounter], a
-	ld a, (40 tiles) / $100
-	ld [wPrinterSendByteCounter + 1], a
-	; compute the checksum
-	call Printer_ComputeChecksum
-	call Printer_NextSection
-	call Printer_WaitHandshake
-	ld a, PRINTER_STATUS_TRANSMITTING
-	ld [wPrinterStatus], a
-	ret
-
-Printer_EndTilemapTransmission: ; 840c5 (21:40c5)
-	; ensure that we go from here to routine 7
-	ld a, $6
-	ld [wJumptableIndex], a
-	; send packet 4
-	ld hl, PrinterDataPacket4 ; signal no transmission
-	call Printer_CopyPacket
-	; send no tile data
-	xor a
-	ld [wPrinterSendByteCounter], a
-	ld [wPrinterSendByteCounter + 1], a
-	call Printer_NextSection
-	call Printer_WaitHandshake
-	ret
-
-Printer_SignalSendHeader: ; 840de (21:40de)
-	call Printer_ResetData
-	ld hl, PrinterDataPacket2 ; signal request print
-	call Printer_CopyPacket
-	; prepare to send 1 tile
-	call Printer_StageHeaderForSend
-	ld a, 4 % $100
-	ld [wPrinterSendByteCounter], a
-	ld a, 4 / $100
-	ld [wPrinterSendByteCounter + 1], a
-	; compute the checksum
-	call Printer_ComputeChecksum
-	call Printer_NextSection
-	call Printer_WaitHandshake
-	ld a, PRINTER_STATUS_PRINTING
-	ld [wPrinterStatus], a
-	ret
-
-Printer_SignalLoopBack: ; 84103 (21:4103)
-	call Printer_ResetData
-	; send packet 1
-	ld hl, PrinterDataPacket1 ; signal no transmission
-	call Printer_CopyPacket
-	; send no tile data
-	xor a
-	ld [wPrinterSendByteCounter], a
-	ld [wPrinterSendByteCounter + 1], a
-	ld a, [wPrinterQueueLength]
-	ld [wPrinterRowIndex], a
-	call Printer_NextSection
-	call Printer_WaitHandshake
-	ret
-
-Printer_WaitSerial: ; 84120 (21:4120)
-	ld hl, wPrinterSerialFrameDelay
-	inc [hl]
-	ld a, [hl]
-	cp $6
-	ret c
-	xor a
-	ld [hl], a
-	call Printer_NextSection
-	ret
-
-Printer_WaitSerialAndLoopBack2: ; 8412e (21:412e)
-	ld hl, wPrinterSerialFrameDelay
-	inc [hl]
-	ld a, [hl]
-	cp $6
-	ret c
-	xor a
-	ld [hl], a
-	ld hl, wPrinterRowIndex
-	dec [hl]
-	call Printer_PrevSection
-	call Printer_PrevSection
-	ret
-
-Printer_CheckConnectionStatus: ; 84143 (21:4143)
-	ld a, [wPrinterOpcode]
-	and a
-	ret nz
-	ld a, [wPrinterHandshake]
-	cp $ff
-	jr nz, .printer_connected
-	ld a, [wPrinterStatusFlags]
-	cp $ff
-	jr z, .printer_error
-
-.printer_connected
-	ld a, [wPrinterHandshake]
-	cp $81
-	jr nz, .printer_error
-	ld a, [wPrinterStatusFlags]
-	cp $0
-	jr nz, .printer_error
-	ld hl, wPrinterConnectionOpen
-	set 1, [hl]
-	ld a, $5
-	ld [wHandshakeFrameDelay], a
-	call Printer_NextSection
-	ret
-
-.printer_error
-	ld a, $ff
-	ld [wPrinterHandshake], a
-	ld [wPrinterStatusFlags], a
-	ld a, $e
-	ld [wJumptableIndex], a
-	ret
-
-Printer_TransmissionLoop: ; 84180 (21:4180)
-	ld a, [wPrinterOpcode]
-	and a
-	ret nz
-	ld a, [wPrinterStatusFlags]
-	and $f0
-	jr nz, .enter_wait_loop
-	ld a, [wPrinterStatusFlags]
-	and $1
-	jr nz, .cycle_back
-	call Printer_NextSection
-	ret
-
-.cycle_back
-	call Printer_PrevSection
-	ret
-
-.enter_wait_loop
-	ld a, $12 ; Printer_WaitLoopBack
-	ld [wJumptableIndex], a
-	ret
-
-Printer_WaitUntilFinished: ; 841a1 (21:41a1)
-	ld a, [wPrinterOpcode]
-	and a
-	ret nz
-	ld a, [wPrinterStatusFlags]
-	and $f3
-	ret nz
-	call Printer_NextSection
-	ret
-
-Printer_WaitLoopBack: ; 841b0 (21:41b0)
-	call Printer_NextSection
-Printer_WaitLoopBack_: ; 841b3 (21:41b3)
-	ld a, [wPrinterOpcode]
-	and a
-	ret nz
-	ld a, [wPrinterStatusFlags]
-	and $f0
-	ret nz
-	xor a
-	ld [wJumptableIndex], a
-	ret
-
-Printer_WaitHandshake: ; 841c3 (21:41c3)
-.loop
-	ld a, [wPrinterOpcode]
-	and a
-	jr nz, .loop
-	xor a
-	ld [wPrinterSendByteOffset], a
-	ld [wPrinterSendByteOffset + 1], a
-	ld a, $1
-	ld [wPrinterOpcode], a
-	ld a, $88
-	ld [rSB], a
-	ld a, $1
-	ld [rSC], a
-	ld a, $81
-	ld [rSC], a
-	ret
-
-Printer_CopyPacket: ; 841e2 (21:41e2)
-	ld a, [hli]
-	ld [wPrinterData], a
-	ld a, [hli]
-	ld [wPrinterData + 1], a
-	ld a, [hli]
-	ld [wPrinterData + 2], a
-	ld a, [hli]
-	ld [wPrinterData + 3], a
-	ld a, [hli]
-	ld [wPrinterChecksum], a
-	ld a, [hl]
-	ld [wPrinterChecksum + 1], a
-	ret
-
-Printer_ResetData: ; 841fb (21:41fb)
-	xor a
-	ld hl, wPrinterData
-	ld [hli], a
-	ld [hli], a
-	ld [hli], a
-	ld [hl], a
-	ld hl, wPrinterChecksum
-	ld [hli], a
-	ld [hl], a
-	xor a
-	ld [wPrinterSendByteCounter], a
-	ld [wPrinterSendByteCounter + 1], a
-	ld hl, wGameboyPrinterRAM
-	ld bc, wGameboyPrinter2bppSourceEnd - wGameboyPrinter2bppSource
-	call Printer_ByteFill
-	ret
-
-Printer_ComputeChecksum: ; 84219 (21:4219)
-	ld hl, 0
-	ld bc, 4
-	ld de, wPrinterData
-	call .ComputeChecksum
-	ld a, [wPrinterSendByteCounter]
-	ld c, a
-	ld a, [wPrinterSendByteCounter + 1]
-	ld b, a
-	ld de, wGameboyPrinterRAM
-	call .ComputeChecksum
-	ld a, l
-	ld [wPrinterChecksum], a
-	ld a, h
-	ld [wPrinterChecksum + 1], a
-	ret
-
-.ComputeChecksum: ; 8423c (21:423c)
-.loop
-	ld a, [de]
-	inc de
-	add l
-	jr nc, .no_overflow
-	inc h
-.no_overflow
-	ld l, a
-	dec bc
-	ld a, c
-	or b
-	jr nz, .loop
-	ret
-
-Printer_StageHeaderForSend: ; 84249 (21:4249)
-	ld a, $1
-	ld [wGameboyPrinter2bppSource + 0], a
-	ld a, [wcbfa]
-	ld [wGameboyPrinter2bppSource + 1], a
-	ld a, %11100100
-	ld [wGameboyPrinter2bppSource + 2], a
-	ld a, [wGBPrinterSettings]
-	ld [wGameboyPrinter2bppSource + 3], a
-	ret
-
-Printer_Convert2RowsTo2bpp: ; 84260 (21:4260)
-	; de = wPrinterTileMapBuffer + 2 * SCREEN_WIDTH * ([wPrinterQueueLength] - [wPrinterRowIndex])
-	ld a, [wPrinterRowIndex]
-	xor $ff
-	ld d, a
-	ld a, [wPrinterQueueLength]
-	inc a
-	add d
-	ld hl, wPrinterTileMapBuffer
-	ld de, 2 * SCREEN_WIDTH
-.loop1
-	and a
-	jr z, .okay1
-	add hl, de
-	dec a
-	jr .loop1
-.okay1
-	ld e, l
-	ld d, h
-	ld hl, wGameboyPrinter2bppSource
-	ld c, 2 * SCREEN_WIDTH
-.loop2
-	ld a, [de]
-	inc de
-	push bc
-	push de
-	push hl
-	; convert tile index to vram address
-	swap a
-	ld d, a
-	and $f0
-	ld e, a
-	ld a, d
-	and $f
-	ld d, a
-	and $8
-	ld a, d
-	jr nz, .vtiles_8xxx
-	or $90
-	jr .got_vtile_addr
-
-.vtiles_8xxx
-	or $80
-.got_vtile_addr
-	ld d, a
-	; copy 1 vtile to hl
-	lb bc, BANK(Printer_Convert2RowsTo2bpp), 1
-	call Request2bpp
-	pop hl
-	ld de, 1 tiles
-	add hl, de
-	pop de
-	pop bc
-	dec c
-	jr nz, .loop2
-	ret
-
-Printer_ByteFill: ; 842ab
-	push de
-	ld e, a
-.loop
-	ld [hl], e
-	inc hl
-	dec bc
-	ld a, c
-	or b
-	jr nz, .loop
-	ld a, e
-	pop de
-	ret
-; 842b7
-
-PrinterDataPacket1:
-	db  1, 0, $00, 0
-	dw 1
-PrinterDataPacket2:
-	db  2, 0, $04, 0
-	dw 0
-PrinterDataPacket3:
-	db  4, 0, $80, 2
-	dw 0
-PrinterDataPacket4:
-	db  4, 0, $00, 0
-	dw 4
-PrinterDataPacket5: ; unused
-	db  8, 0, $00, 0
-	dw 8
-PrinterDataPacket6: ; unused
-	db 15, 0, $00, 0
-	dw 15
-; 842db
-
-_PrinterReceive:: ; 842db
-	ld a, [wPrinterOpcode]
-	add a
-	ld e, a
-	ld d, 0
-	ld hl, .Jumptable
-	add hl, de
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	jp hl
-; 842ea
-
-
-.Jumptable: ; 842ea (21:42ea)
-	dw Printer_DoNothing ; 00
-
-	dw Printer_Send0x33 ; 01
-	dw Printer_SendPrinterData1 ; 02
-	dw Printer_SendPrinterData2 ; 03
-	dw Printer_SendPrinterData3 ; 04
-	dw Printer_SendPrinterData4 ; 05
-	dw Printer_SendNextByte ; 06
-	dw Printer_SendwPrinterChecksumLo ; 07
-	dw Printer_SendwPrinterChecksumHi ; 08
-	dw Printer_Send0x00 ; 09
-	dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 0a
-	dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop ; 0b
-
-	dw Printer_Send0x33 ; 0c triggered by AskSerial
-	dw Printer_Send0x0f ; 0d
-	dw Printer_Send0x00_ ; 0e
-	dw Printer_Send0x00_ ; 0f
-	dw Printer_Send0x00_ ; 10
-	dw Printer_Send0x0f ; 11
-	dw Printer_Send0x00_ ; 12
-	dw Printer_Send0x00 ; 13
-	dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 14
-	dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop_ ; 15
-
-	dw Printer_Send0x33 ; 16 triggered by pressing B
-	dw Printer_Send0x08 ; 17
-	dw Printer_Send0x00_ ; 18
-	dw Printer_Send0x00_ ; 19
-	dw Printer_Send0x00_ ; 1a
-	dw Printer_Send0x08 ; 1b
-	dw Printer_Send0x00_ ; 1c
-	dw Printer_Send0x00 ; 1d
-	dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 1e
-	dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop ; 1f
-
-
-Printer_NextInstruction: ; 8432a (21:432a)
-	ld hl, wPrinterOpcode
-	inc [hl]
-	ret
-
-Printer_DoNothing: ; 8432f (21:432f)
-	ret
-
-Printer_Send0x33: ; 84330 (21:4330)
-	ld a, $33
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_SendPrinterData1: ; 84339 (21:4339)
-	ld a, [wPrinterData]
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_SendPrinterData2: ; 84343 (21:4343)
-	ld a, [wPrinterData + 1]
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_SendPrinterData3: ; 8434d (21:434d)
-	ld a, [wPrinterData + 2]
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_SendPrinterData4: ; 84357 (21:4357)
-	ld a, [wPrinterData + 3]
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_SendNextByte: ; 84361 (21:4361)
-	; decrement 16-bit counter
-	ld hl, wPrinterSendByteCounter
-	ld a, [hli]
-	ld d, [hl]
-	ld e, a
-	or d
-	jr z, .done
-	dec de
-	ld [hl], d
-	dec hl
-	ld [hl], e
-
-	ld a, [wPrinterSendByteOffset]
-	ld e, a
-	ld a, [wPrinterSendByteOffset + 1]
-	ld d, a
-	ld hl, wGameboyPrinterRAM
-	add hl, de
-	inc de
-	ld a, e
-	ld [wPrinterSendByteOffset], a
-	ld a, d
-	ld [wPrinterSendByteOffset + 1], a
-	ld a, [hl]
-	call Printer_SerialSend
-	ret
-
-.done
-	call Printer_NextInstruction
-Printer_SendwPrinterChecksumLo: ; 8438b (21:438b)
-	ld a, [wPrinterChecksum]
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_SendwPrinterChecksumHi: ; 84395 (21:4395)
-	ld a, [wPrinterChecksum + 1]
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_Send0x00: ; 8439f (21:439f)
-	ld a, $0
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_ReceiveTowPrinterHandshakeAndSend0x00: ; 843a8 (21:43a8)
-	ld a, [rSB]
-	ld [wPrinterHandshake], a
-	ld a, $0
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop: ; 843b6 (21:43b6)
-	ld a, [rSB]
-	ld [wPrinterStatusFlags], a
-	xor a
-	ld [wPrinterOpcode], a
-	ret
-
-Printer_Send0x0f: ; 843c0 (21:43c0)
-	ld a, $f
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_Send0x00_: ; 843c9 (21:43c9)
-	ld a, $0
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_Send0x08: ; 843d2 (21:43d2)
-	ld a, $8
-	call Printer_SerialSend
-	call Printer_NextInstruction
-	ret
-
-Printer_SerialSend: ; 843db (21:43db)
-	ld [rSB], a
-	ld a, $1 ; switch to internal clock
-	ld [rSC], a
-	ld a, $81 ; start transfer
-	ld [rSC], a
-	ret
-
-Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop_: ; 843e6 (21:43e6)
-	ld a, [rSB]
-	ld [wPrinterStatusFlags], a
-	xor a
-	ld [wPrinterOpcode], a
-	ret
--- /dev/null
+++ b/engine/printer_serial.asm
@@ -1,0 +1,645 @@
+Printer_StartTransmission: ; 84000
+	ld hl, wGameboyPrinterRAM
+	ld bc, wGameboyPrinterRAMEnd - wGameboyPrinterRAM
+	xor a
+	call Printer_ByteFill
+	xor a
+	ld [rSB], a
+	ld [rSC], a
+	ld [wPrinterOpcode], a
+	ld hl, wPrinterConnectionOpen
+	set 0, [hl]
+	ld a, [GBPrinter]
+	ld [wGBPrinterSettings], a
+	xor a
+	ld [wJumptableIndex], a
+	ret
+; 84022
+
+PrinterJumptableIteration: ; 84022
+	ld a, [wJumptableIndex]
+	ld e, a
+	ld d, 0
+	ld hl, .Jumptable
+	add hl, de
+	add hl, de
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	jp hl
+; 84031
+
+
+.Jumptable: ; 84031 (21:4031)
+
+	dw Print_InitPrinterHandshake ; 00
+	dw Printer_CheckConnectionStatus ; 01
+	dw Printer_WaitSerial ; 02
+	dw Printer_StartTransmittingTilemap ; 03
+	dw Printer_TransmissionLoop ; 04
+	dw Printer_WaitSerialAndLoopBack2 ; 05
+
+	dw Printer_EndTilemapTransmission ; 06
+	dw Printer_TransmissionLoop ; 07
+	dw Printer_WaitSerial ; 08
+	dw Printer_SignalSendHeader ; 09
+	dw Printer_TransmissionLoop ; 0a
+	dw Printer_WaitSerial ; 0b
+	dw Printer_WaitUntilFinished ; 0c
+	dw Printer_Quit ; 0d
+
+	dw Printer_NextSection_ ; 0e
+	dw Printer_WaitSerial ; 0f
+	dw Printer_SignalLoopBack ; 10
+	dw Printer_SectionOne ; 11
+	dw Printer_WaitLoopBack ; 12
+	dw Printer_WaitLoopBack_ ; 13
+
+
+Printer_NextSection: ; 84059 (21:4059)
+	ld hl, wJumptableIndex
+	inc [hl]
+	ret
+
+Printer_PrevSection: ; 8405e (21:405e)
+	ld hl, wJumptableIndex
+	dec [hl]
+	ret
+
+Printer_Quit: ; 84063 (21:4063)
+	xor a
+	ld [wPrinterStatusFlags], a
+	ld hl, wJumptableIndex
+	set 7, [hl]
+	ret
+
+Printer_NextSection_: ; 8406d (21:406d)
+	call Printer_NextSection
+	ret
+
+Printer_SectionOne: ; 84071 (21:4071)
+	ld a, $1
+	ld [wJumptableIndex], a
+	ret
+
+Print_InitPrinterHandshake: ; 84077 (21:4077)
+	call Printer_ResetData
+	ld hl, PrinterDataPacket1
+	call Printer_CopyPacket
+	xor a
+	ld [wPrinterSendByteCounter], a
+	ld [wPrinterSendByteCounter + 1], a
+	ld a, [wPrinterQueueLength]
+	ld [wPrinterRowIndex], a
+	call Printer_NextSection
+	call Printer_WaitHandshake
+	ld a, PRINTER_STATUS_CHECKING
+	ld [wPrinterStatus], a
+	ret
+
+Printer_StartTransmittingTilemap: ; 84099 (21:4099)
+	call Printer_ResetData
+	; check ???
+	ld hl, wPrinterRowIndex
+	ld a, [hl]
+	and a
+	jr z, Printer_EndTilemapTransmission
+	; send packet 3
+	ld hl, PrinterDataPacket3 ; signal start of transmission
+	call Printer_CopyPacket
+	; prepare to send 40 tiles
+	call Printer_Convert2RowsTo2bpp
+	ld a, (40 tiles) % $100
+	ld [wPrinterSendByteCounter], a
+	ld a, (40 tiles) / $100
+	ld [wPrinterSendByteCounter + 1], a
+	; compute the checksum
+	call Printer_ComputeChecksum
+	call Printer_NextSection
+	call Printer_WaitHandshake
+	ld a, PRINTER_STATUS_TRANSMITTING
+	ld [wPrinterStatus], a
+	ret
+
+Printer_EndTilemapTransmission: ; 840c5 (21:40c5)
+	; ensure that we go from here to routine 7
+	ld a, $6
+	ld [wJumptableIndex], a
+	; send packet 4
+	ld hl, PrinterDataPacket4 ; signal no transmission
+	call Printer_CopyPacket
+	; send no tile data
+	xor a
+	ld [wPrinterSendByteCounter], a
+	ld [wPrinterSendByteCounter + 1], a
+	call Printer_NextSection
+	call Printer_WaitHandshake
+	ret
+
+Printer_SignalSendHeader: ; 840de (21:40de)
+	call Printer_ResetData
+	ld hl, PrinterDataPacket2 ; signal request print
+	call Printer_CopyPacket
+	; prepare to send 1 tile
+	call Printer_StageHeaderForSend
+	ld a, 4 % $100
+	ld [wPrinterSendByteCounter], a
+	ld a, 4 / $100
+	ld [wPrinterSendByteCounter + 1], a
+	; compute the checksum
+	call Printer_ComputeChecksum
+	call Printer_NextSection
+	call Printer_WaitHandshake
+	ld a, PRINTER_STATUS_PRINTING
+	ld [wPrinterStatus], a
+	ret
+
+Printer_SignalLoopBack: ; 84103 (21:4103)
+	call Printer_ResetData
+	; send packet 1
+	ld hl, PrinterDataPacket1 ; signal no transmission
+	call Printer_CopyPacket
+	; send no tile data
+	xor a
+	ld [wPrinterSendByteCounter], a
+	ld [wPrinterSendByteCounter + 1], a
+	ld a, [wPrinterQueueLength]
+	ld [wPrinterRowIndex], a
+	call Printer_NextSection
+	call Printer_WaitHandshake
+	ret
+
+Printer_WaitSerial: ; 84120 (21:4120)
+	ld hl, wPrinterSerialFrameDelay
+	inc [hl]
+	ld a, [hl]
+	cp $6
+	ret c
+	xor a
+	ld [hl], a
+	call Printer_NextSection
+	ret
+
+Printer_WaitSerialAndLoopBack2: ; 8412e (21:412e)
+	ld hl, wPrinterSerialFrameDelay
+	inc [hl]
+	ld a, [hl]
+	cp $6
+	ret c
+	xor a
+	ld [hl], a
+	ld hl, wPrinterRowIndex
+	dec [hl]
+	call Printer_PrevSection
+	call Printer_PrevSection
+	ret
+
+Printer_CheckConnectionStatus: ; 84143 (21:4143)
+	ld a, [wPrinterOpcode]
+	and a
+	ret nz
+	ld a, [wPrinterHandshake]
+	cp $ff
+	jr nz, .printer_connected
+	ld a, [wPrinterStatusFlags]
+	cp $ff
+	jr z, .printer_error
+
+.printer_connected
+	ld a, [wPrinterHandshake]
+	cp $81
+	jr nz, .printer_error
+	ld a, [wPrinterStatusFlags]
+	cp $0
+	jr nz, .printer_error
+	ld hl, wPrinterConnectionOpen
+	set 1, [hl]
+	ld a, $5
+	ld [wHandshakeFrameDelay], a
+	call Printer_NextSection
+	ret
+
+.printer_error
+	ld a, $ff
+	ld [wPrinterHandshake], a
+	ld [wPrinterStatusFlags], a
+	ld a, $e
+	ld [wJumptableIndex], a
+	ret
+
+Printer_TransmissionLoop: ; 84180 (21:4180)
+	ld a, [wPrinterOpcode]
+	and a
+	ret nz
+	ld a, [wPrinterStatusFlags]
+	and $f0
+	jr nz, .enter_wait_loop
+	ld a, [wPrinterStatusFlags]
+	and $1
+	jr nz, .cycle_back
+	call Printer_NextSection
+	ret
+
+.cycle_back
+	call Printer_PrevSection
+	ret
+
+.enter_wait_loop
+	ld a, $12 ; Printer_WaitLoopBack
+	ld [wJumptableIndex], a
+	ret
+
+Printer_WaitUntilFinished: ; 841a1 (21:41a1)
+	ld a, [wPrinterOpcode]
+	and a
+	ret nz
+	ld a, [wPrinterStatusFlags]
+	and $f3
+	ret nz
+	call Printer_NextSection
+	ret
+
+Printer_WaitLoopBack: ; 841b0 (21:41b0)
+	call Printer_NextSection
+Printer_WaitLoopBack_: ; 841b3 (21:41b3)
+	ld a, [wPrinterOpcode]
+	and a
+	ret nz
+	ld a, [wPrinterStatusFlags]
+	and $f0
+	ret nz
+	xor a
+	ld [wJumptableIndex], a
+	ret
+
+Printer_WaitHandshake: ; 841c3 (21:41c3)
+.loop
+	ld a, [wPrinterOpcode]
+	and a
+	jr nz, .loop
+	xor a
+	ld [wPrinterSendByteOffset], a
+	ld [wPrinterSendByteOffset + 1], a
+	ld a, $1
+	ld [wPrinterOpcode], a
+	ld a, $88
+	ld [rSB], a
+	ld a, $1
+	ld [rSC], a
+	ld a, $81
+	ld [rSC], a
+	ret
+
+Printer_CopyPacket: ; 841e2 (21:41e2)
+	ld a, [hli]
+	ld [wPrinterData], a
+	ld a, [hli]
+	ld [wPrinterData + 1], a
+	ld a, [hli]
+	ld [wPrinterData + 2], a
+	ld a, [hli]
+	ld [wPrinterData + 3], a
+	ld a, [hli]
+	ld [wPrinterChecksum], a
+	ld a, [hl]
+	ld [wPrinterChecksum + 1], a
+	ret
+
+Printer_ResetData: ; 841fb (21:41fb)
+	xor a
+	ld hl, wPrinterData
+	ld [hli], a
+	ld [hli], a
+	ld [hli], a
+	ld [hl], a
+	ld hl, wPrinterChecksum
+	ld [hli], a
+	ld [hl], a
+	xor a
+	ld [wPrinterSendByteCounter], a
+	ld [wPrinterSendByteCounter + 1], a
+	ld hl, wGameboyPrinterRAM
+	ld bc, wGameboyPrinter2bppSourceEnd - wGameboyPrinter2bppSource
+	call Printer_ByteFill
+	ret
+
+Printer_ComputeChecksum: ; 84219 (21:4219)
+	ld hl, 0
+	ld bc, 4
+	ld de, wPrinterData
+	call .ComputeChecksum
+	ld a, [wPrinterSendByteCounter]
+	ld c, a
+	ld a, [wPrinterSendByteCounter + 1]
+	ld b, a
+	ld de, wGameboyPrinterRAM
+	call .ComputeChecksum
+	ld a, l
+	ld [wPrinterChecksum], a
+	ld a, h
+	ld [wPrinterChecksum + 1], a
+	ret
+
+.ComputeChecksum: ; 8423c (21:423c)
+.loop
+	ld a, [de]
+	inc de
+	add l
+	jr nc, .no_overflow
+	inc h
+.no_overflow
+	ld l, a
+	dec bc
+	ld a, c
+	or b
+	jr nz, .loop
+	ret
+
+Printer_StageHeaderForSend: ; 84249 (21:4249)
+	ld a, $1
+	ld [wGameboyPrinter2bppSource + 0], a
+	ld a, [wcbfa]
+	ld [wGameboyPrinter2bppSource + 1], a
+	ld a, %11100100
+	ld [wGameboyPrinter2bppSource + 2], a
+	ld a, [wGBPrinterSettings]
+	ld [wGameboyPrinter2bppSource + 3], a
+	ret
+
+Printer_Convert2RowsTo2bpp: ; 84260 (21:4260)
+	; de = wPrinterTileMapBuffer + 2 * SCREEN_WIDTH * ([wPrinterQueueLength] - [wPrinterRowIndex])
+	ld a, [wPrinterRowIndex]
+	xor $ff
+	ld d, a
+	ld a, [wPrinterQueueLength]
+	inc a
+	add d
+	ld hl, wPrinterTileMapBuffer
+	ld de, 2 * SCREEN_WIDTH
+.loop1
+	and a
+	jr z, .okay1
+	add hl, de
+	dec a
+	jr .loop1
+.okay1
+	ld e, l
+	ld d, h
+	ld hl, wGameboyPrinter2bppSource
+	ld c, 2 * SCREEN_WIDTH
+.loop2
+	ld a, [de]
+	inc de
+	push bc
+	push de
+	push hl
+	; convert tile index to vram address
+	swap a
+	ld d, a
+	and $f0
+	ld e, a
+	ld a, d
+	and $f
+	ld d, a
+	and $8
+	ld a, d
+	jr nz, .vtiles_8xxx
+	or $90
+	jr .got_vtile_addr
+
+.vtiles_8xxx
+	or $80
+.got_vtile_addr
+	ld d, a
+	; copy 1 vtile to hl
+	lb bc, BANK(Printer_Convert2RowsTo2bpp), 1
+	call Request2bpp
+	pop hl
+	ld de, 1 tiles
+	add hl, de
+	pop de
+	pop bc
+	dec c
+	jr nz, .loop2
+	ret
+
+Printer_ByteFill: ; 842ab
+	push de
+	ld e, a
+.loop
+	ld [hl], e
+	inc hl
+	dec bc
+	ld a, c
+	or b
+	jr nz, .loop
+	ld a, e
+	pop de
+	ret
+; 842b7
+
+PrinterDataPacket1:
+	db  1, 0, $00, 0
+	dw 1
+PrinterDataPacket2:
+	db  2, 0, $04, 0
+	dw 0
+PrinterDataPacket3:
+	db  4, 0, $80, 2
+	dw 0
+PrinterDataPacket4:
+	db  4, 0, $00, 0
+	dw 4
+PrinterDataPacket5: ; unused
+	db  8, 0, $00, 0
+	dw 8
+PrinterDataPacket6: ; unused
+	db 15, 0, $00, 0
+	dw 15
+; 842db
+
+_PrinterReceive:: ; 842db
+	ld a, [wPrinterOpcode]
+	add a
+	ld e, a
+	ld d, 0
+	ld hl, .Jumptable
+	add hl, de
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	jp hl
+; 842ea
+
+
+.Jumptable: ; 842ea (21:42ea)
+	dw Printer_DoNothing ; 00
+
+	dw Printer_Send0x33 ; 01
+	dw Printer_SendPrinterData1 ; 02
+	dw Printer_SendPrinterData2 ; 03
+	dw Printer_SendPrinterData3 ; 04
+	dw Printer_SendPrinterData4 ; 05
+	dw Printer_SendNextByte ; 06
+	dw Printer_SendwPrinterChecksumLo ; 07
+	dw Printer_SendwPrinterChecksumHi ; 08
+	dw Printer_Send0x00 ; 09
+	dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 0a
+	dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop ; 0b
+
+	dw Printer_Send0x33 ; 0c triggered by AskSerial
+	dw Printer_Send0x0f ; 0d
+	dw Printer_Send0x00_ ; 0e
+	dw Printer_Send0x00_ ; 0f
+	dw Printer_Send0x00_ ; 10
+	dw Printer_Send0x0f ; 11
+	dw Printer_Send0x00_ ; 12
+	dw Printer_Send0x00 ; 13
+	dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 14
+	dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop_ ; 15
+
+	dw Printer_Send0x33 ; 16 triggered by pressing B
+	dw Printer_Send0x08 ; 17
+	dw Printer_Send0x00_ ; 18
+	dw Printer_Send0x00_ ; 19
+	dw Printer_Send0x00_ ; 1a
+	dw Printer_Send0x08 ; 1b
+	dw Printer_Send0x00_ ; 1c
+	dw Printer_Send0x00 ; 1d
+	dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 1e
+	dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop ; 1f
+
+
+Printer_NextInstruction: ; 8432a (21:432a)
+	ld hl, wPrinterOpcode
+	inc [hl]
+	ret
+
+Printer_DoNothing: ; 8432f (21:432f)
+	ret
+
+Printer_Send0x33: ; 84330 (21:4330)
+	ld a, $33
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_SendPrinterData1: ; 84339 (21:4339)
+	ld a, [wPrinterData]
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_SendPrinterData2: ; 84343 (21:4343)
+	ld a, [wPrinterData + 1]
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_SendPrinterData3: ; 8434d (21:434d)
+	ld a, [wPrinterData + 2]
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_SendPrinterData4: ; 84357 (21:4357)
+	ld a, [wPrinterData + 3]
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_SendNextByte: ; 84361 (21:4361)
+	; decrement 16-bit counter
+	ld hl, wPrinterSendByteCounter
+	ld a, [hli]
+	ld d, [hl]
+	ld e, a
+	or d
+	jr z, .done
+	dec de
+	ld [hl], d
+	dec hl
+	ld [hl], e
+
+	ld a, [wPrinterSendByteOffset]
+	ld e, a
+	ld a, [wPrinterSendByteOffset + 1]
+	ld d, a
+	ld hl, wGameboyPrinterRAM
+	add hl, de
+	inc de
+	ld a, e
+	ld [wPrinterSendByteOffset], a
+	ld a, d
+	ld [wPrinterSendByteOffset + 1], a
+	ld a, [hl]
+	call Printer_SerialSend
+	ret
+
+.done
+	call Printer_NextInstruction
+Printer_SendwPrinterChecksumLo: ; 8438b (21:438b)
+	ld a, [wPrinterChecksum]
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_SendwPrinterChecksumHi: ; 84395 (21:4395)
+	ld a, [wPrinterChecksum + 1]
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_Send0x00: ; 8439f (21:439f)
+	ld a, $0
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_ReceiveTowPrinterHandshakeAndSend0x00: ; 843a8 (21:43a8)
+	ld a, [rSB]
+	ld [wPrinterHandshake], a
+	ld a, $0
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop: ; 843b6 (21:43b6)
+	ld a, [rSB]
+	ld [wPrinterStatusFlags], a
+	xor a
+	ld [wPrinterOpcode], a
+	ret
+
+Printer_Send0x0f: ; 843c0 (21:43c0)
+	ld a, $f
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_Send0x00_: ; 843c9 (21:43c9)
+	ld a, $0
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_Send0x08: ; 843d2 (21:43d2)
+	ld a, $8
+	call Printer_SerialSend
+	call Printer_NextInstruction
+	ret
+
+Printer_SerialSend: ; 843db (21:43db)
+	ld [rSB], a
+	ld a, $1 ; switch to internal clock
+	ld [rSC], a
+	ld a, $81 ; start transfer
+	ld [rSC], a
+	ret
+
+Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop_: ; 843e6 (21:43e6)
+	ld a, [rSB]
+	ld [wPrinterStatusFlags], a
+	xor a
+	ld [wPrinterOpcode], a
+	ret
--- /dev/null
+++ b/engine/sgb_layouts.asm
@@ -1,0 +1,636 @@
+Predef_LoadSGBLayout: ; 864c
+; LoadSGBLayout
+	call CheckCGB
+	jp nz, Predef_LoadSGBLayoutCGB
+
+	ld a, b
+	cp SCGB_RAM
+	jr nz, .not_ram
+	ld a, [SGBPredef]
+.not_ram
+	cp SCGB_PARTY_MENU_HP_PALS
+	jp z, SGB_ApplyPartyMenuHPPals
+	ld l, a
+	ld h, 0
+	add hl, hl
+	ld de, .Jumptable
+	add hl, de
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	ld de, .Finish
+	push de
+	jp hl
+; 866f
+
+.Jumptable: ; 866f
+	dw .SGB_BattleGrayscale
+	dw .SGB_BattleColors
+	dw .SGB_PokegearPals
+	dw .SGB_StatsScreenHPPals
+	dw .SGB_Pokedex
+	dw .SGB_SlotMachine
+	dw .SGB06
+	dw .SGB07
+	dw .SGB_Diploma
+	dw .SGB_MapPals
+	dw .SGB_PartyMenu
+	dw .SGB_Evolution
+	dw .SGB0c
+	dw .SGB0d
+	dw .SGB_MoveList
+	dw .SGB0f
+	dw .SGB_PokedexSearchOption
+	dw .SGB11
+	dw .SGB12
+	dw .SGB13
+	dw .SGB_PackPals
+	dw .SGB_TrainerCard
+	dw .SGB_PokedexUnownMode
+	dw .SGB_BillsPC
+	dw .SGB_UnownPuzzle
+	dw .SGB19
+	dw .SGB_PlayerOrMonFrontpicPals
+	dw .SGB_TradeTube
+	dw .SGB_TrainerOrMonFrontpicPals
+	dw .SGB_MysteryGift
+	dw .SGB1e
+; 86ad
+
+.SGB_BattleGrayscale: ; 86ad
+	ld hl, PalPacket_9c66
+	ld de, BlkPacket_9aa6
+	ret
+; 86b4
+
+.SGB_BattleColors: ; 86b4
+	ld hl, BlkPacket_9aa6
+	call PushSGBPals_
+
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+
+	ld a, [PlayerHPPal]
+	ld l, a
+	ld h, 0
+	add hl, hl
+	add hl, hl
+	ld de, Palettes_a8be
+	add hl, de
+
+	ld a, [hli]
+	ld [wSGBPals + 3], a
+	ld a, [hli]
+	ld [wSGBPals + 4], a
+	ld a, [hli]
+	ld [wSGBPals + 5], a
+	ld a, [hl]
+	ld [wSGBPals + 6], a
+
+	ld a, [EnemyHPPal]
+	ld l, a
+	ld h, 0
+	add hl, hl
+	add hl, hl
+
+	ld de, Palettes_a8be
+	add hl, de
+	ld a, [hli]
+	ld [wSGBPals + 9], a
+	ld a, [hli]
+	ld [wSGBPals + 10], a
+	ld a, [hli]
+	ld [wSGBPals + 11], a
+	ld a, [hl]
+	ld [wSGBPals + 12], a
+
+	ld hl, PalPacket_9cf6
+	ld de, wSGBPals + $10
+	ld bc, $10
+	call CopyBytes
+
+	call GetBattlemonBackpicPalettePointer
+
+	ld a, [hli]
+	ld [wSGBPals + $13], a
+	ld a, [hli]
+	ld [wSGBPals + $14], a
+	ld a, [hli]
+	ld [wSGBPals + $15], a
+	ld a, [hl]
+	ld [wSGBPals + $16], a
+	call GetEnemyFrontpicPalettePointer
+	ld a, [hli]
+	ld [wSGBPals + $19], a
+	ld a, [hli]
+	ld [wSGBPals + $1a], a
+	ld a, [hli]
+	ld [wSGBPals + $1b], a
+	ld a, [hl]
+	ld [wSGBPals + $1c], a
+
+	ld hl, wSGBPals
+	ld de, wSGBPals + $10
+	ld a, SCGB_BATTLE_COLORS
+	ld [SGBPredef], a
+	ret
+; 873c
+
+.SGB_MoveList: ; 873c
+	ld hl, PalPacket_9bd6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+
+	ld hl, wSGBPals + 1
+	ld [hl], $10
+	inc hl
+	inc hl
+
+	ld a, [PlayerHPPal]
+	add $2f
+	ld [hl], a
+	ld hl, wSGBPals
+	ld de, BlkPacket_9ad6
+	ret
+; 875c
+
+.SGB_PokegearPals: ; 875c
+	ld hl, PalPacket_9c76
+	ld de, BlkPacket_9a86
+	ret
+; 8763
+
+.SGB_StatsScreenHPPals: ; 8763
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	ld a, [wCurHPPal]
+	ld l, a
+	ld h, 0
+	add hl, hl
+	add hl, hl
+	ld de, Palettes_a8be
+	add hl, de
+	ld a, [hli]
+	ld [wSGBPals + 3], a
+	ld a, [hli]
+	ld [wSGBPals + 4], a
+	ld a, [hli]
+	ld [wSGBPals + 5], a
+	ld a, [hl]
+	ld [wSGBPals + 6], a
+	ld a, [CurPartySpecies]
+	ld bc, TempMonDVs
+	call GetPlayerOrMonPalettePointer
+	ld a, [hli]
+	ld [wSGBPals + 9], a
+	ld a, [hli]
+	ld [wSGBPals + 10], a
+	ld a, [hli]
+	ld [wSGBPals + 11], a
+	ld a, [hl]
+	ld [wSGBPals + 12], a
+	ld hl, wSGBPals
+	ld de, BlkPacket_9ac6
+	ret
+; 87ab
+
+.SGB_PartyMenu: ; 87ab
+	ld hl, PalPacket_9c56
+	ld de, wSGBPals + 1
+	ret
+; 87b2
+
+.SGB_Pokedex: ; 87b2
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	ld hl, wSGBPals + 3
+	ld [hl], $9f
+	inc hl
+	ld [hl], $2a
+	inc hl
+	ld [hl], $5a
+	inc hl
+	ld [hl], $19
+	ld a, [CurPartySpecies]
+	call GetMonPalettePointer_
+	ld a, [hli]
+	ld [wSGBPals + 9], a
+	ld a, [hli]
+	ld [wSGBPals + 10], a
+	ld a, [hli]
+	ld [wSGBPals + 11], a
+	ld a, [hl]
+	ld [wSGBPals + 12], a
+	ld hl, wSGBPals
+	ld de, BlkPacket_9ae6
+	ret
+; 87e9
+
+.SGB_BillsPC: ; 87e9
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	ld hl, wSGBPals + 3
+	ld [hl], $9f
+	inc hl
+	ld [hl], $2a
+	inc hl
+	ld [hl], $5a
+	inc hl
+	ld [hl], $19
+	ld a, [CurPartySpecies]
+	ld bc, TempMonDVs
+	call GetPlayerOrMonPalettePointer
+	ld a, [hli]
+	ld [wSGBPals + 9], a
+	ld a, [hli]
+	ld [wSGBPals + 10], a
+	ld a, [hli]
+	ld [wSGBPals + 11], a
+	ld a, [hl]
+	ld [wSGBPals + 12], a
+	ld hl, wSGBPals
+	ld de, BlkPacket_9ae6
+	ret
+; 8823
+
+.SGB_PokedexUnownMode: ; 8823
+	call .SGB_Pokedex
+	ld de, BlkPacket_9af6
+	ret
+; 882a
+
+.SGB_PokedexSearchOption: ; 882a
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	ld hl, wSGBPals + 3
+	ld [hl], $9f
+	inc hl
+	ld [hl], $2a
+	inc hl
+	ld [hl], $5a
+	inc hl
+	ld [hl], $19
+	ld hl, wSGBPals
+	ld de, BlkPacket_9a86
+	ret
+; 884b
+
+.SGB_PackPals: ; 884b
+	ld hl, PalPacket_9c36
+	ld de, BlkPacket_9a86
+	ret
+; 8852
+
+.SGB_SlotMachine: ; 8852
+	ld hl, PalPacket_9c96
+	ld de, BlkPacket_9b06
+	ret
+; 8859
+
+.SGB06: ; 8859
+	ld hl, PalPacket_9ca6
+	ld de, BlkPacket_9b76
+	ret
+; 8860
+
+.SGB_Diploma:
+.SGB_MysteryGift: ; 8860
+	ld hl, PalPacket_9cb6
+	ld de, BlkPacket_9a86
+	ret
+; 8867
+
+.SGB07: ; 8867
+	ld b, 0
+	ld hl, .BlkPacketTable_SGB07
+rept 4
+	add hl, bc
+endr
+	ld e, [hl]
+	inc hl
+	ld d, [hl]
+	inc hl
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	ret
+; 8878
+
+.BlkPacketTable_SGB07: ; 8878
+	dw BlkPacket_9a86, PalPacket_9be6
+	dw BlkPacket_9a96, PalPacket_9c06
+	dw BlkPacket_9a86, PalPacket_9c16
+; 8884
+
+.SGB0c: ; 8884
+	ld hl, PalPacket_9b96
+	ld de, BlkPacket_9b56
+	ld a, SCGB_DIPLOMA
+	ld [SGBPredef], a
+	ret
+; 8890
+
+.SGB13: ; 8890
+	ld hl, PalPacket_9ba6
+	ld de, BlkPacket_9b86
+	ret
+; 8897
+
+.SGB0f: ; 8897
+	ld hl, PalPacket_9c46
+	ld de, BlkPacket_9a86
+	ret
+; 889e
+
+.SGB11: ; 889e
+	ld hl, BlkPacket_9a86
+	ld de, PlayerLightScreenCount
+	ld bc, $10
+	call CopyBytes
+	ld hl, PalPacket_9bb6
+	ld de, BlkPacket_9a86
+	ret
+; 88b1
+
+.SGB_MapPals: ; 88b1
+	ld hl, PalPacket_9bd6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	call .GetMapPalsIndex
+	ld hl, wSGBPals + 1
+	ld [hld], a
+	ld de, BlkPacket_9a86
+	ld a, SCGB_MAPPALS
+	ld [SGBPredef], a
+	ret
+; 88cd
+
+.SGB_Evolution: ; 88cd
+	push bc
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	pop bc
+	ld a, c
+	and a
+	jr z, .partymon
+	; Egg
+	ld hl, wSGBPals + 3
+	; RGB 7, 7, 7
+	ld [hl], $e7
+	inc hl
+	ld [hl], $1c
+	inc hl
+	; RGB 2, 3, 3
+	ld [hl], $62
+	inc hl
+	ld [hl], $c
+	jr .done
+
+.partymon
+	ld hl, PartyMon1DVs
+	ld bc, PARTYMON_STRUCT_LENGTH
+	ld a, [CurPartyMon]
+	call AddNTimes
+	ld c, l
+	ld b, h
+	ld a, [PlayerHPPal]
+	call GetPlayerOrMonPalettePointer
+	ld a, [hli]
+	ld [wSGBPals + 3], a
+	ld a, [hli]
+	ld [wSGBPals + 4], a
+	ld a, [hli]
+	ld [wSGBPals + 5], a
+	ld a, [hl]
+	ld [wSGBPals + 6], a
+
+.done
+	ld hl, wSGBPals
+	ld de, BlkPacket_9a86
+	ret
+; 891a
+
+.SGB0d:
+.SGB_TrainerCard: ; 891a
+	ld hl, PalPacket_9cb6
+	ld de, BlkPacket_9a86
+	ret
+; 8921
+
+.SGB_UnownPuzzle: ; 8921
+	ld hl, PalPacket_9bc6
+	ld de, BlkPacket_9a86
+	ret
+; 8928
+
+.SGB12: ; 8928
+	ld hl, PalPacket_9bd6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	ld hl, BlkPacket_9a86
+	ld de, wSGBPals + $10
+	ld bc, $10
+	call CopyBytes
+	call .GetMapPalsIndex
+	ld hl, wSGBPals + 1
+	ld [hl], a
+	ld hl, wSGBPals + 3
+	ld [hl], $2e
+	ld hl, wSGBPals + $13
+	ld a, 5
+	ld [hli], a
+	ld a, [wMenuBorderLeftCoord]
+	ld [hli], a
+	ld a, [wMenuBorderTopCoord]
+	ld [hli], a
+	ld a, [wMenuBorderRightCoord]
+	ld [hli], a
+	ld a, [wMenuBorderBottomCoord]
+	ld [hl], a
+	ld hl, wSGBPals
+	ld de, wSGBPals + $10
+	ret
+; 8969
+
+.SGB1e: ; 8969
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	ld a, [CurPartySpecies]
+	ld l, a
+	ld h, 0
+	add hl, hl
+	add hl, hl
+	add hl, hl
+	ld de, PokemonPalettes
+	add hl, de
+	ld a, [wcf65]
+	and 3
+	sla a
+	sla a
+	ld c, a
+	ld b, 0
+	add hl, bc
+	ld a, [hli]
+	ld [wSGBPals + 3], a
+	ld a, [hli]
+	ld [wSGBPals + 4], a
+	ld a, [hli]
+	ld [wSGBPals + 5], a
+	ld a, [hl]
+	ld [wSGBPals + 6], a
+	ld hl, wSGBPals
+	ld de, BlkPacket_9a86
+	ret
+; 89a6
+
+.SGB19: ; 89a6
+	ld hl, PalPacket_9cd6
+	ld de, BlkPacket_9a86
+	ret
+; 89ad
+
+.SGB_PlayerOrMonFrontpicPals: ; 89ad
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	ld a, [CurPartySpecies]
+	ld bc, TempMonDVs
+	call GetPlayerOrMonPalettePointer
+	ld a, [hli]
+	ld [wSGBPals + 3], a
+	ld a, [hli]
+	ld [wSGBPals + 4], a
+	ld a, [hli]
+	ld [wSGBPals + 5], a
+	ld a, [hl]
+	ld [wSGBPals + 6], a
+	ld hl, wSGBPals
+	ld de, BlkPacket_9a86
+	ret
+; 89d9
+
+.SGB_TradeTube: ; 89d9
+	ld hl, PalPacket_9cc6
+	ld de, BlkPacket_9a86
+	ret
+; 89e0
+
+.SGB_TrainerOrMonFrontpicPals: ; 89e0
+	ld hl, PalPacket_9ce6
+	ld de, wSGBPals
+	ld bc, $10
+	call CopyBytes
+	ld a, [CurPartySpecies]
+	ld bc, TempMonDVs
+	call GetFrontpicPalettePointer
+	ld a, [hli]
+	ld [wSGBPals + 3], a
+	ld a, [hli]
+	ld [wSGBPals + 4], a
+	ld a, [hli]
+	ld [wSGBPals + 5], a
+	ld a, [hl]
+	ld [wSGBPals + 6], a
+	ld hl, wSGBPals
+	ld de, BlkPacket_9a86
+	ret
+; 8a0c
+
+.GetMapPalsIndex: ; 8a0c
+	ld a, [TimeOfDayPal]
+	cp NITE_F
+	jr c, .morn_day
+	ld a, $19
+	ret
+
+.morn_day
+	ld a, [wPermission]
+	cp ROUTE
+	jr z, .route
+	cp CAVE
+	jr z, .cave
+	cp DUNGEON
+	jr z, .cave
+	cp PERM_5
+	jr z, .perm5
+	cp GATE
+	jr z, .gate
+	ld a, [MapGroup]
+	ld e, a
+	ld d, 0
+	ld hl, .SGBRoofPalInds
+	add hl, de
+	ld a, [hl]
+	ret
+
+.route
+	ld a, $00
+	ret
+
+.cave
+	ld a, $18
+	ret
+
+.perm5
+	ld a, $06
+	ret
+
+.gate
+	ld a, $03
+	ret
+; 8a45
+
+.SGBRoofPalInds: ; 8a45
+	db $00 ; Unused
+	db $12 ; Olivine
+	db $14 ; Mahogany
+	db $18 ; Various Dungeons
+	db $11 ; Ecruteak
+	db $15 ; Blackthorn
+	db $09 ; Cinnabar
+	db $04 ; Cerulean
+	db $0f ; Azalea
+	db $16 ; Lake Of Rage
+	db $0e ; Violet
+	db $10 ; Goldenrod
+	db $06 ; Vermilion
+	db $01 ; Palette
+	db $03 ; Pewter
+	db $06 ; Fast Ship
+	db $0b ; Indigo Plateau
+	db $08 ; Fuchsia
+	db $05 ; Lavender
+	db $17 ; Silver Cave Outside
+	db $08 ; Pokemon Center 2F
+	db $07 ; Celadon
+	db $13 ; Cianwood
+	db $02 ; Viridian
+	db $0c ; New Bark
+	db $0a ; Saffron
+	db $0d ; Cherrygrove
+; 8a60
+
+.Finish: ; 8a60
+	push de
+	call PushSGBPals_
+	pop hl
+	jp PushSGBPals_
+; 8a68
--- /dev/null
+++ b/engine/time_capsule.asm
@@ -1,0 +1,277 @@
+; These functions seem to be related to backwards compatibility
+
+ValidateOTTrademon: ; fb57e
+	ld a, [wd003]
+	ld hl, OTPartyMon1Species
+	call GetPartyLocation
+	push hl
+	ld a, [wd003]
+	inc a
+	ld c, a
+	ld b, 0
+	ld hl, OTPartyCount
+	add hl, bc
+	ld a, [hl]
+	pop hl
+	cp EGG
+	jr z, .matching_or_egg
+	cp [hl]
+	jr nz, .abnormal
+
+.matching_or_egg
+	ld b, h
+	ld c, l
+	ld hl, MON_LEVEL
+	add hl, bc
+	ld a, [hl]
+	cp MAX_LEVEL + 1
+	jr nc, .abnormal
+	ld a, [wLinkMode]
+	cp LINK_TIMECAPSULE
+	jr nz, .normal
+	ld hl, OTPartySpecies
+	ld a, [wd003]
+	ld c, a
+	ld b, 0
+	add hl, bc
+	ld a, [hl]
+
+	; Magnemite and Magneton's types changed
+	; from Electric to Electric/Steel.
+	cp MAGNEMITE
+	jr z, .normal
+	cp MAGNETON
+	jr z, .normal
+
+	ld [CurSpecies], a
+	call GetBaseData
+	ld hl, wLinkOTPartyMonTypes
+	add hl, bc
+	add hl, bc
+	ld a, [BaseType1]
+	cp [hl]
+	jr nz, .abnormal
+	inc hl
+	ld a, [BaseType2]
+	cp [hl]
+	jr nz, .abnormal
+
+.normal
+	and a
+	ret
+
+.abnormal
+	scf
+	ret
+; fb5dd
+
+Functionfb5dd: ; fb5dd
+	ld a, [wd002]
+	ld d, a
+	ld a, [PartyCount]
+	ld b, a
+	ld c, $0
+.loop
+	ld a, c
+	cp d
+	jr z, .next
+	push bc
+	ld a, c
+	ld hl, PartyMon1HP
+	call GetPartyLocation
+	pop bc
+	ld a, [hli]
+	or [hl]
+	jr nz, .done
+
+.next
+	inc c
+	dec b
+	jr nz, .loop
+	ld a, [wd003]
+	ld hl, OTPartyMon1HP
+	call GetPartyLocation
+	ld a, [hli]
+	or [hl]
+	jr nz, .done
+	scf
+	ret
+
+.done
+	and a
+	ret
+; fb60d
+
+PlaceTradePartnerNamesAndParty: ; fb60d
+	hlcoord 4, 0
+	ld de, PlayerName
+	call PlaceString
+	ld a, $14
+	ld [bc], a
+	hlcoord 4, 8
+	ld de, OTPlayerName
+	call PlaceString
+	ld a, $14
+	ld [bc], a
+	hlcoord 7, 1
+	ld de, PartySpecies
+	call .PlaceSpeciesNames
+	hlcoord 7, 9
+	ld de, OTPartySpecies
+.PlaceSpeciesNames: ; fb634
+	ld c, $0
+.loop
+	ld a, [de]
+	cp -1
+	ret z
+	ld [wd265], a
+	push bc
+	push hl
+	push de
+	push hl
+	ld a, c
+	ld [hProduct], a
+	call GetPokemonName
+	pop hl
+	call PlaceString
+	pop de
+	inc de
+	pop hl
+	ld bc, SCREEN_WIDTH
+	add hl, bc
+	pop bc
+	inc c
+	jr .loop
+; fb656
+
+
+INCLUDE "data/time_capsule/special_stats.asm"
+
+
+INCLUDE "event/name_rater.asm"
+
+
+PlaySlowCry: ; fb841
+	ld a, [ScriptVar]
+	call LoadCryHeader
+	jr c, .done
+
+	ld hl, CryPitch
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	ld bc, -$140
+	add hl, bc
+	ld a, l
+	ld [CryPitch], a
+	ld a, h
+	ld [CryPitch + 1], a
+	ld hl, CryLength
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	ld bc, $60
+	add hl, bc
+	ld a, l
+	ld [CryLength], a
+	ld a, h
+	ld [CryLength + 1], a
+	callba _PlayCryHeader
+	call WaitSFX
+
+.done
+	ret
+; fb877
+
+NewPokedexEntry: ; fb877
+	ld a, [hMapAnims]
+	push af
+	xor a
+	ld [hMapAnims], a
+	call LowVolume
+	call ClearBGPalettes
+	call ClearTileMap
+	call UpdateSprites
+	call ClearSprites
+	ld a, [wPokedexStatus]
+	push af
+	ld a, [hSCX]
+	add $5
+	ld [hSCX], a
+	xor a
+	ld [wPokedexStatus], a
+	callba _NewPokedexEntry
+	call WaitPressAorB_BlinkCursor
+	ld a, $1
+	ld [wPokedexStatus], a
+	callba DisplayDexEntry
+	call WaitPressAorB_BlinkCursor
+	pop af
+	ld [wPokedexStatus], a
+	call MaxVolume
+	call RotateThreePalettesRight
+	ld a, [hSCX]
+	add -5 ; 251 ; NUM_POKEMON
+	ld [hSCX], a
+	call .ReturnFromDexRegistration
+	pop af
+	ld [hMapAnims], a
+	ret
+; fb8c8
+
+.ReturnFromDexRegistration: ; fb8c8
+	call ClearTileMap
+	call LoadFontsExtra
+	call LoadStandardFont
+	callba Pokedex_PlaceFrontpicTopLeftCorner
+	call WaitBGMap2
+	callba GetEnemyMonDVs
+	ld a, [hli]
+	ld [TempMonDVs], a
+	ld a, [hl]
+	ld [TempMonDVs + 1], a
+	ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS
+	call GetSGBLayout
+	call SetPalettes
+	ret
+; fb8f1
+
+ConvertMon_2to1: ; fb8f1
+; Takes the Gen-2 Pokemon number stored in wd265, finds it in the Pokered_MonIndices table, and returns its index in wd265.
+	push bc
+	push hl
+	ld a, [wd265]
+	ld b, a
+	ld c, 0
+	ld hl, Pokered_MonIndices
+.loop
+	inc c
+	ld a, [hli]
+	cp b
+	jr nz, .loop
+	ld a, c
+	ld [wd265], a
+	pop hl
+	pop bc
+	ret
+; fb908
+
+ConvertMon_1to2: ; fb908
+; Takes the Gen-1 Pokemon number stored in wd265 and returns the corresponding value from Pokered_MonIndices in wd265.
+	push bc
+	push hl
+	ld a, [wd265]
+	dec a
+	ld hl, Pokered_MonIndices
+	ld b, 0
+	ld c, a
+	add hl, bc
+	ld a, [hl]
+	ld [wd265], a
+	pop hl
+	pop bc
+	ret
+; fb91c
+
+
+INCLUDE "data/time_capsule/mon_order.asm"
--- a/engine/time_capsule/conversion.asm
+++ /dev/null
@@ -1,277 +1,0 @@
-; These functions seem to be related to backwards compatibility
-
-ValidateOTTrademon: ; fb57e
-	ld a, [wd003]
-	ld hl, OTPartyMon1Species
-	call GetPartyLocation
-	push hl
-	ld a, [wd003]
-	inc a
-	ld c, a
-	ld b, 0
-	ld hl, OTPartyCount
-	add hl, bc
-	ld a, [hl]
-	pop hl
-	cp EGG
-	jr z, .matching_or_egg
-	cp [hl]
-	jr nz, .abnormal
-
-.matching_or_egg
-	ld b, h
-	ld c, l
-	ld hl, MON_LEVEL
-	add hl, bc
-	ld a, [hl]
-	cp MAX_LEVEL + 1
-	jr nc, .abnormal
-	ld a, [wLinkMode]
-	cp LINK_TIMECAPSULE
-	jr nz, .normal
-	ld hl, OTPartySpecies
-	ld a, [wd003]
-	ld c, a
-	ld b, 0
-	add hl, bc
-	ld a, [hl]
-
-	; Magnemite and Magneton's types changed
-	; from Electric to Electric/Steel.
-	cp MAGNEMITE
-	jr z, .normal
-	cp MAGNETON
-	jr z, .normal
-
-	ld [CurSpecies], a
-	call GetBaseData
-	ld hl, wLinkOTPartyMonTypes
-	add hl, bc
-	add hl, bc
-	ld a, [BaseType1]
-	cp [hl]
-	jr nz, .abnormal
-	inc hl
-	ld a, [BaseType2]
-	cp [hl]
-	jr nz, .abnormal
-
-.normal
-	and a
-	ret
-
-.abnormal
-	scf
-	ret
-; fb5dd
-
-Functionfb5dd: ; fb5dd
-	ld a, [wd002]
-	ld d, a
-	ld a, [PartyCount]
-	ld b, a
-	ld c, $0
-.loop
-	ld a, c
-	cp d
-	jr z, .next
-	push bc
-	ld a, c
-	ld hl, PartyMon1HP
-	call GetPartyLocation
-	pop bc
-	ld a, [hli]
-	or [hl]
-	jr nz, .done
-
-.next
-	inc c
-	dec b
-	jr nz, .loop
-	ld a, [wd003]
-	ld hl, OTPartyMon1HP
-	call GetPartyLocation
-	ld a, [hli]
-	or [hl]
-	jr nz, .done
-	scf
-	ret
-
-.done
-	and a
-	ret
-; fb60d
-
-PlaceTradePartnerNamesAndParty: ; fb60d
-	hlcoord 4, 0
-	ld de, PlayerName
-	call PlaceString
-	ld a, $14
-	ld [bc], a
-	hlcoord 4, 8
-	ld de, OTPlayerName
-	call PlaceString
-	ld a, $14
-	ld [bc], a
-	hlcoord 7, 1
-	ld de, PartySpecies
-	call .PlaceSpeciesNames
-	hlcoord 7, 9
-	ld de, OTPartySpecies
-.PlaceSpeciesNames: ; fb634
-	ld c, $0
-.loop
-	ld a, [de]
-	cp -1
-	ret z
-	ld [wd265], a
-	push bc
-	push hl
-	push de
-	push hl
-	ld a, c
-	ld [hProduct], a
-	call GetPokemonName
-	pop hl
-	call PlaceString
-	pop de
-	inc de
-	pop hl
-	ld bc, SCREEN_WIDTH
-	add hl, bc
-	pop bc
-	inc c
-	jr .loop
-; fb656
-
-
-INCLUDE "data/time_capsule/special_stats.asm"
-
-
-INCLUDE "event/name_rater.asm"
-
-
-PlaySlowCry: ; fb841
-	ld a, [ScriptVar]
-	call LoadCryHeader
-	jr c, .done
-
-	ld hl, CryPitch
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	ld bc, -$140
-	add hl, bc
-	ld a, l
-	ld [CryPitch], a
-	ld a, h
-	ld [CryPitch + 1], a
-	ld hl, CryLength
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	ld bc, $60
-	add hl, bc
-	ld a, l
-	ld [CryLength], a
-	ld a, h
-	ld [CryLength + 1], a
-	callba _PlayCryHeader
-	call WaitSFX
-
-.done
-	ret
-; fb877
-
-NewPokedexEntry: ; fb877
-	ld a, [hMapAnims]
-	push af
-	xor a
-	ld [hMapAnims], a
-	call LowVolume
-	call ClearBGPalettes
-	call ClearTileMap
-	call UpdateSprites
-	call ClearSprites
-	ld a, [wPokedexStatus]
-	push af
-	ld a, [hSCX]
-	add $5
-	ld [hSCX], a
-	xor a
-	ld [wPokedexStatus], a
-	callba _NewPokedexEntry
-	call WaitPressAorB_BlinkCursor
-	ld a, $1
-	ld [wPokedexStatus], a
-	callba DisplayDexEntry
-	call WaitPressAorB_BlinkCursor
-	pop af
-	ld [wPokedexStatus], a
-	call MaxVolume
-	call RotateThreePalettesRight
-	ld a, [hSCX]
-	add -5 ; 251 ; NUM_POKEMON
-	ld [hSCX], a
-	call .ReturnFromDexRegistration
-	pop af
-	ld [hMapAnims], a
-	ret
-; fb8c8
-
-.ReturnFromDexRegistration: ; fb8c8
-	call ClearTileMap
-	call LoadFontsExtra
-	call LoadStandardFont
-	callba Pokedex_PlaceFrontpicTopLeftCorner
-	call WaitBGMap2
-	callba GetEnemyMonDVs
-	ld a, [hli]
-	ld [TempMonDVs], a
-	ld a, [hl]
-	ld [TempMonDVs + 1], a
-	ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS
-	call GetSGBLayout
-	call SetPalettes
-	ret
-; fb8f1
-
-ConvertMon_2to1: ; fb8f1
-; Takes the Gen-2 Pokemon number stored in wd265, finds it in the Pokered_MonIndices table, and returns its index in wd265.
-	push bc
-	push hl
-	ld a, [wd265]
-	ld b, a
-	ld c, 0
-	ld hl, Pokered_MonIndices
-.loop
-	inc c
-	ld a, [hli]
-	cp b
-	jr nz, .loop
-	ld a, c
-	ld [wd265], a
-	pop hl
-	pop bc
-	ret
-; fb908
-
-ConvertMon_1to2: ; fb908
-; Takes the Gen-1 Pokemon number stored in wd265 and returns the corresponding value from Pokered_MonIndices in wd265.
-	push bc
-	push hl
-	ld a, [wd265]
-	dec a
-	ld hl, Pokered_MonIndices
-	ld b, 0
-	ld c, a
-	add hl, bc
-	ld a, [hl]
-	ld [wd265], a
-	pop hl
-	pop bc
-	ret
-; fb91c
-
-
-INCLUDE "data/time_capsule/mon_order.asm"
--- a/engine/trade/animation.asm
+++ /dev/null
@@ -1,1628 +1,0 @@
-TradeAnimation: ; 28f24
-	xor a
-	ld [wcf66], a
-	ld hl, wPlayerTrademonSenderName
-	ld de, wOTTrademonSenderName
-	call LinkTradeAnim_LoadTradePlayerNames
-	ld hl, wPlayerTrademonSpecies
-	ld de, wOTTrademonSpecies
-	call LinkTradeAnim_LoadTradeMonSpecies
-	ld de, .script
-	jr RunTradeAnimScript
-
-.script
-	tradeanim_setup_givemon_scroll
-	tradeanim_show_givemon_data
-	tradeanim_do_givemon_scroll
-	tradeanim_wait_80
-	tradeanim_wait_96
-	tradeanim_poof
-	tradeanim_rocking_ball
-	tradeanim_enter_link_tube
-	tradeanim_wait_anim
-	tradeanim_bulge_through_tube
-	tradeanim_wait_anim
-	tradeanim_textbox_scroll
-	tradeanim_give_trademon_sfx
-	tradeanim_tube_to_ot
-	tradeanim_sent_to_ot_text
-	tradeanim_scroll_out_right
-
-	tradeanim_ot_sends_text_1
-	tradeanim_ot_bids_farewell
-	tradeanim_wait_40
-	tradeanim_scroll_out_right
-	tradeanim_get_trademon_sfx
-	tradeanim_tube_to_player
-	tradeanim_enter_link_tube
-	tradeanim_drop_ball
-	tradeanim_exit_link_tube
-	tradeanim_wait_anim
-	tradeanim_show_getmon_data
-	tradeanim_poof
-	tradeanim_wait_anim
-	tradeanim_frontpic_scroll
-	tradeanim_animate_frontpic
-	tradeanim_wait_80_if_ot_egg
-	tradeanim_textbox_scroll
-	tradeanim_take_care_of_text
-	tradeanim_scroll_out_right
-	tradeanim_end
-
-TradeAnimationPlayer2: ; 28f63
-	xor a
-	ld [wcf66], a
-	ld hl, wOTTrademonSenderName
-	ld de, wPlayerTrademonSenderName
-	call LinkTradeAnim_LoadTradePlayerNames
-	ld hl, wOTTrademonSpecies
-	ld de, wPlayerTrademonSpecies
-	call LinkTradeAnim_LoadTradeMonSpecies
-	ld de, .script
-	jr RunTradeAnimScript
-
-.script
-	tradeanim_ot_sends_text_2
-	tradeanim_ot_bids_farewell
-	tradeanim_wait_40
-	tradeanim_scroll_out_right
-	tradeanim_get_trademon_sfx
-	tradeanim_tube_to_ot
-	tradeanim_enter_link_tube
-	tradeanim_drop_ball
-	tradeanim_exit_link_tube
-	tradeanim_wait_anim
-	tradeanim_show_getmon_data
-	tradeanim_poof
-	tradeanim_wait_anim
-	tradeanim_frontpic_scroll
-	tradeanim_animate_frontpic
-	tradeanim_wait_180_if_ot_egg
-	tradeanim_textbox_scroll
-	tradeanim_take_care_of_text
-	tradeanim_scroll_out_right
-
-	tradeanim_setup_givemon_scroll
-	tradeanim_show_givemon_data
-	tradeanim_do_givemon_scroll
-	tradeanim_wait_40
-	tradeanim_poof
-	tradeanim_rocking_ball
-	tradeanim_enter_link_tube
-	tradeanim_wait_anim
-	tradeanim_bulge_through_tube
-	tradeanim_wait_anim
-	tradeanim_textbox_scroll
-	tradeanim_give_trademon_sfx
-	tradeanim_tube_to_player
-	tradeanim_sent_to_ot_text
-	tradeanim_scroll_out_right
-	tradeanim_end
-
-RunTradeAnimScript: ; 28fa1
-	ld hl, wTradeAnimAddress
-	ld [hl], e
-	inc hl
-	ld [hl], d
-	ld a, [hMapAnims]
-	push af
-	xor a
-	ld [hMapAnims], a
-	ld hl, VramState
-	ld a, [hl]
-	push af
-	res 0, [hl]
-	ld hl, Options
-	ld a, [hl]
-	push af
-	set 4, [hl]
-	call .TradeAnimLayout
-	ld a, [wcf66]
-	and a
-	jr nz, .anim_loop
-	ld de, MUSIC_EVOLUTION
-	call PlayMusic2
-.anim_loop
-	call DoTradeAnimation
-	jr nc, .anim_loop
-	pop af
-	ld [Options], a
-	pop af
-	ld [VramState], a
-	pop af
-	ld [hMapAnims], a
-	ret
-
-; 28fdb
-
-.TradeAnimLayout: ; 28fdb
-	xor a
-	ld [wJumptableIndex], a
-	call ClearBGPalettes
-	call ClearSprites
-	call ClearTileMap
-	call DisableLCD
-	call LoadFontsBattleExtra
-	callab ClearSpriteAnims
-	ld a, [hCGB]
-	and a
-	jr z, .NotCGB
-	ld a, $1
-	ld [rVBK], a
-	ld hl, VTiles0
-	ld bc, sScratch - VTiles0
-	xor a
-	call ByteFill
-	ld a, $0
-	ld [rVBK], a
-
-.NotCGB:
-	hlbgcoord 0, 0
-	ld bc, sScratch - VBGMap0
-	ld a, " "
-	call ByteFill
-	ld hl, TradeGameBoyLZ
-	ld de, VTiles2 tile $31
-	call Decompress
-	ld hl, TradeArrowGFX
-	ld de, VTiles1 tile $6d
-	ld bc, $10
-	ld a, BANK(TradeArrowGFX)
-	call FarCopyBytes
-	ld hl, TradeArrowGFX + $10
-	ld de, VTiles1 tile $6e
-	ld bc, $10
-	ld a, BANK(TradeArrowGFX)
-	call FarCopyBytes
-	xor a
-	ld [hSCX], a
-	ld [hSCY], a
-	ld a, $7
-	ld [hWX], a
-	ld a, $90
-	ld [hWY], a
-	callba GetTrademonFrontpic
-	call EnableLCD
-	call LoadTradeBallAndCableGFX
-	ld a, [wPlayerTrademonSpecies]
-	ld hl, wPlayerTrademonDVs
-	ld de, VTiles0
-	call TradeAnim_GetFrontpic
-	ld a, [wOTTrademonSpecies]
-	ld hl, wOTTrademonDVs
-	ld de, VTiles0 tile $31
-	call TradeAnim_GetFrontpic
-	ld a, [wPlayerTrademonSpecies]
-	ld de, wPlayerTrademonSpeciesName
-	call TradeAnim_GetNickname
-	ld a, [wOTTrademonSpecies]
-	ld de, wOTTrademonSpeciesName
-	call TradeAnim_GetNickname
-	call TradeAnim_NormalPals
-	ret
-
-; 29082
-
-DoTradeAnimation: ; 29082
-	ld a, [wJumptableIndex]
-	bit 7, a
-	jr nz, .finished
-	call .DoTradeAnimCommand
-	callab PlaySpriteAnimations
-	ld hl, wcf65
-	inc [hl]
-	call DelayFrame
-	and a
-	ret
-
-.finished
-	call LoadStandardFont
-	scf
-	ret
-
-; 290a0
-
-.DoTradeAnimCommand: ; 290a0
-	ld a, [wJumptableIndex]
-	ld e, a
-	ld d, 0
-	ld hl, .JumpTable
-	add hl, de
-	add hl, de
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	jp hl
-; 290af
-
-.JumpTable: ; 290af
-; entries correspond to macros/trade_anim.asm enumeration
-	dw TradeAnim_AdvanceScriptPointer ; 00
-	dw TradeAnim_ShowGivemonData      ; 01
-	dw TradeAnim_ShowGetmonData       ; 02
-	dw TradeAnim_EnterLinkTube1       ; 03
-	dw TradeAnim_EnterLinkTube2       ; 04
-	dw TradeAnim_ExitLinkTube         ; 05
-	dw TradeAnim_TubeToOT1            ; 06
-	dw TradeAnim_TubeToOT2            ; 07
-	dw TradeAnim_TubeToOT3            ; 08
-	dw TradeAnim_TubeToOT4            ; 09
-	dw TradeAnim_TubeToOT5            ; 0a
-	dw TradeAnim_TubeToOT6            ; 0b
-	dw TradeAnim_TubeToOT7            ; 0c
-	dw TradeAnim_TubeToOT8            ; 0d
-	dw TradeAnim_TubeToPlayer1        ; 0e
-	dw TradeAnim_TubeToPlayer2        ; 0f
-	dw TradeAnim_TubeToPlayer3        ; 10
-	dw TradeAnim_TubeToPlayer4        ; 11
-	dw TradeAnim_TubeToPlayer5        ; 12
-	dw TradeAnim_TubeToPlayer6        ; 13
-	dw TradeAnim_TubeToPlayer7        ; 14
-	dw TradeAnim_TubeToPlayer8        ; 15
-	dw TradeAnim_SentToOTText         ; 16
-	dw TradeAnim_OTBidsFarewell       ; 17
-	dw TradeAnim_TakeCareOfText       ; 18
-	dw TradeAnim_OTSendsText1         ; 19
-	dw TradeAnim_OTSendsText2         ; 1a
-	dw TradeAnim_SetupGivemonScroll   ; 1b
-	dw TradeAnim_DoGivemonScroll      ; 1c
-	dw TradeAnim_FrontpicScrollStart  ; 1d
-	dw TradeAnim_TextboxScrollStart   ; 1e
-	dw TradeAnim_ScrollOutRight       ; 1f
-	dw TradeAnim_ScrollOutRight2      ; 20
-	dw TraideAnim_Wait80              ; 21
-	dw TraideAnim_Wait40              ; 22
-	dw TradeAnim_RockingBall          ; 23
-	dw TradeAnim_DropBall             ; 24
-	dw TradeAnim_WaitAnim             ; 25
-	dw TradeAnim_WaitAnim2            ; 26
-	dw TradeAnim_Poof                 ; 27
-	dw TradeAnim_BulgeThroughTube     ; 28
-	dw TradeAnim_GiveTrademonSFX      ; 29
-	dw TradeAnim_GetTrademonSFX       ; 2a
-	dw TradeAnim_End                  ; 2b
-	dw TradeAnim_AnimateFrontpic      ; 2c
-	dw TraideAnim_Wait96              ; 2d
-	dw TraideAnim_Wait80IfOTEgg       ; 2e
-	dw TraideAnim_Wait180IfOTEgg      ; 2f
-; 2910f
-
-TradeAnim_IncrementJumptableIndex: ; 2910f
-	ld hl, wJumptableIndex
-	inc [hl]
-	ret
-
-; 29114
-
-TradeAnim_AdvanceScriptPointer: ; 29114
-	ld hl, wTradeAnimAddress
-	ld e, [hl]
-	inc hl
-	ld d, [hl]
-	ld a, [de]
-	ld [wJumptableIndex], a
-	inc de
-	ld [hl], d
-	dec hl
-	ld [hl], e
-	ret
-
-; 29123
-
-TradeAnim_End: ; 29123
-	ld hl, wJumptableIndex
-	set 7, [hl]
-	ret
-
-; 29129
-
-TradeAnim_TubeToOT1: ; 29129
-	ld a, $ed ; >>>>>>>>
-	call TradeAnim_PlaceTrademonStatsOnTubeAnim
-	ld a, [wLinkTradeSendmonSpecies]
-	ld [wd265], a
-	xor a
-	depixel 5, 11, 4, 0
-	ld b, $0
-	jr TradeAnim_InitTubeAnim
-
-TradeAnim_TubeToPlayer1: ; 2913c
-	ld a, $ee ; <<<<<<<<
-	call TradeAnim_PlaceTrademonStatsOnTubeAnim
-	ld a, [wLinkTradeGetmonSpecies]
-	ld [wd265], a
-	ld a, $2
-	depixel 9, 18, 4, 4
-	ld b, $4
-TradeAnim_InitTubeAnim: ; 2914e
-	push bc
-	push de
-	push bc
-	push de
-
-	push af
-	call DisableLCD
-	callab ClearSpriteAnims
-	hlbgcoord 20, 3
-	ld bc, 12
-	ld a, $60
-	call ByteFill
-	pop af
-
-	call TradeAnim_TubeAnimJumptable
-
-	xor a
-	ld [hSCX], a
-	ld a, $7
-	ld [hWX], a
-	ld a, $70
-	ld [hWY], a
-	call EnableLCD
-	call LoadTradeBubbleGFX
-
-	pop de
-	ld a, SPRITE_ANIM_INDEX_TRADEMON_ICON
-	call _InitSpriteAnimStruct
-
-	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
-	add hl, bc
-	pop bc
-	ld [hl], b
-
-	pop de
-	ld a, SPRITE_ANIM_INDEX_TRADEMON_BUBBLE
-	call _InitSpriteAnimStruct
-
-	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
-	add hl, bc
-	pop bc
-	ld [hl], b
-
-	call WaitBGMap
-	ld b, SCGB_TRADE_TUBE
-	call GetSGBLayout
-	ld a, %11100100 ; 3,2,1,0
-	call DmgToCgbBGPals
-	ld a, %11010000
-	call DmgToCgbObjPal0
-
-	call TradeAnim_IncrementJumptableIndex
-	ld a, $5c
-	ld [wcf64], a
-	ret
-
-; 291af
-
-TradeAnim_TubeToOT2: ; 291af
-	call TradeAnim_FlashBGPals
-	ld a, [hSCX]
-	add $2
-	ld [hSCX], a
-	cp $50
-	ret nz
-	ld a, $1
-	call TradeAnim_TubeAnimJumptable
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 291c4
-
-TradeAnim_TubeToOT3: ; 291c4
-	call TradeAnim_FlashBGPals
-	ld a, [hSCX]
-	add $2
-	ld [hSCX], a
-	cp $a0
-	ret nz
-	ld a, $2
-	call TradeAnim_TubeAnimJumptable
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 291d9
-
-TradeAnim_TubeToOT4: ; 291d9
-	call TradeAnim_FlashBGPals
-	ld a, [hSCX]
-	add $2
-	ld [hSCX], a
-	and a
-	ret nz
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 291e8
-
-TradeAnim_TubeToPlayer3: ; 291e8
-	call TradeAnim_FlashBGPals
-	ld a, [hSCX]
-	sub $2
-	ld [hSCX], a
-	cp $b0
-	ret nz
-	ld a, $1
-	call TradeAnim_TubeAnimJumptable
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 291fd
-
-TradeAnim_TubeToPlayer4: ; 291fd
-	call TradeAnim_FlashBGPals
-	ld a, [hSCX]
-	sub $2
-	ld [hSCX], a
-	cp $60
-	ret nz
-	xor a
-	call TradeAnim_TubeAnimJumptable
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 29211
-
-TradeAnim_TubeToPlayer5: ; 29211
-	call TradeAnim_FlashBGPals
-	ld a, [hSCX]
-	sub $2
-	ld [hSCX], a
-	and a
-	ret nz
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 29220
-
-TradeAnim_TubeToOT6:
-TradeAnim_TubeToPlayer6: ; 29220
-	ld a, $80
-	ld [wcf64], a
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 29229
-
-TradeAnim_TubeToOT8:
-TradeAnim_TubeToPlayer8: ; 29229
-	call ClearBGPalettes
-	call ClearTileMap
-	call ClearSprites
-	call DisableLCD
-	callab ClearSpriteAnims
-	hlbgcoord 0, 0
-	ld bc, sScratch - VBGMap0
-	ld a, " "
-	call ByteFill
-	xor a
-	ld [hSCX], a
-	ld a, $90
-	ld [hWY], a
-	call EnableLCD
-	call LoadTradeBallAndCableGFX
-	call WaitBGMap
-	call TradeAnim_NormalPals
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 2925d
-
-TradeAnim_TubeToOT5:
-TradeAnim_TubeToOT7:
-TradeAnim_TubeToPlayer2:
-TradeAnim_TubeToPlayer7: ; 2925d
-	call TradeAnim_FlashBGPals
-	ld hl, wcf64
-	ld a, [hl]
-	and a
-	jr z, .done
-	dec [hl]
-	ret
-
-.done
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 2926d
-
-TradeAnim_GiveTrademonSFX: ; 2926d
-	call TradeAnim_AdvanceScriptPointer
-	ld de, SFX_GIVE_TRADEMON
-	call PlaySFX
-	ret
-
-; 29277
-
-TradeAnim_GetTrademonSFX: ; 29277
-	call TradeAnim_AdvanceScriptPointer
-	ld de, SFX_GET_TRADEMON
-	call PlaySFX
-	ret
-
-; 29281
-
-TradeAnim_TubeAnimJumptable: ; 29281
-	and 3
-	ld e, a
-	ld d, 0
-	ld hl, .Jumptable
-	add hl, de
-	add hl, de
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	jp hl
-; 2928f
-
-.Jumptable: ; 2928f
-	dw .Zero
-	dw .One
-	dw .Two
-	dw .Three
-; 29297
-
-.Zero: ; 29297
-.Three: ; 29297
-	call TradeAnim_BlankTileMap
-	hlcoord 9, 3
-	ld [hl], $5b
-	inc hl
-	ld bc, 10
-	ld a, $60
-	call ByteFill
-	hlcoord 3, 2
-	call TradeAnim_CopyTradeGameBoyTilemap
-	ret
-
-; 292af
-
-.One: ; 292af
-	call TradeAnim_BlankTileMap
-	hlcoord 0, 3
-	ld bc, SCREEN_WIDTH
-	ld a, $60
-	call ByteFill
-	ret
-
-; 292be
-
-.Two: ; 292be
-	call TradeAnim_BlankTileMap
-	hlcoord 0, 3
-	ld bc, $11
-	ld a, $60
-	call ByteFill
-	hlcoord 17, 3
-	ld a, $5d
-	ld [hl], a
-
-	ld a, $61
-	ld de, SCREEN_WIDTH
-	ld c, $3
-.loop
-	add hl, de
-	ld [hl], a
-	dec c
-	jr nz, .loop
-
-	add hl, de
-	ld a, $5f
-	ld [hld], a
-	ld a, $5b
-	ld [hl], a
-	hlcoord 10, 6
-	call TradeAnim_CopyTradeGameBoyTilemap
-	ret
-
-; 292ec
-
-TradeAnim_CopyTradeGameBoyTilemap: ; 292ec
-	ld de, TradeGameBoyTilemap
-	lb bc, 8, 6
-	call TradeAnim_CopyBoxFromDEtoHL
-	ret
-
-; 292f6
-
-TradeAnim_PlaceTrademonStatsOnTubeAnim: ; 292f6
-	push af
-	call ClearBGPalettes
-	call WaitTop
-	ld a, VBGMap1 / $100
-	ld [hBGMapAddress + 1], a
-	call ClearTileMap
-	hlcoord 0, 0
-	ld bc, SCREEN_WIDTH
-	ld a, "─"
-	call ByteFill
-	hlcoord 0, 1
-	ld de, wLinkPlayer1Name
-	call PlaceString
-	ld hl, wLinkPlayer2Name
-	ld de, 0
-.find_name_end_loop
-	ld a, [hli]
-	cp "@"
-	jr z, .done
-	dec de
-	jr .find_name_end_loop
-
-.done
-	hlcoord 0, 4
-	add hl, de
-	ld de, wLinkPlayer2Name
-	call PlaceString
-	hlcoord 7, 2
-	ld bc, 6
-	pop af
-	call ByteFill
-	call WaitBGMap
-	call WaitTop
-	ld a, VBGMap0 / $100
-	ld [hBGMapAddress + 1], a
-	call ClearTileMap
-	ret
-
-; 29348
-
-TradeAnim_EnterLinkTube1: ; 29348
-	call ClearTileMap
-	call WaitTop
-	ld a, $a0
-	ld [hSCX], a
-	call DelayFrame
-	hlcoord 8, 2
-	ld de, TradeLinkTubeTilemap
-	lb bc, 3, 12
-	call TradeAnim_CopyBoxFromDEtoHL
-	call WaitBGMap
-	ld b, SCGB_TRADE_TUBE
-	call GetSGBLayout
-	ld a, %11100100 ; 3,2,1,0
-	call DmgToCgbBGPals
-	lb de, %11100100, %11100100 ; 3,2,1,0, 3,2,1,0
-	call DmgToCgbObjPals
-	ld de, SFX_POTION
-	call PlaySFX
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 2937e
-
-TradeAnim_EnterLinkTube2: ; 2937e
-	ld a, [hSCX]
-	and a
-	jr z, .done
-	add $4
-	ld [hSCX], a
-	ret
-
-.done
-	ld c, 80
-	call DelayFrames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29391
-
-TradeAnim_ExitLinkTube: ; 29391
-	ld a, [hSCX]
-	cp $a0
-	jr z, .done
-	sub $4
-	ld [hSCX], a
-	ret
-
-.done
-	call ClearTileMap
-	xor a
-	ld [hSCX], a
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 293a6
-
-TradeAnim_SetupGivemonScroll: ; 293a6
-	ld a, $8f
-	ld [hWX], a
-	ld a, $88
-	ld [hSCX], a
-	ld a, $50
-	ld [hWY], a
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 293b6
-
-TradeAnim_DoGivemonScroll: ; 293b6
-	ld a, [hWX]
-	cp $7
-	jr z, .done
-	sub $4
-	ld [hWX], a
-	ld a, [hSCX]
-	sub $4
-	ld [hSCX], a
-	ret
-
-.done
-	ld a, $7
-	ld [hWX], a
-	xor a
-	ld [hSCX], a
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 293d2
-
-TradeAnim_FrontpicScrollStart: ; 293d2
-	ld a, $7
-	ld [hWX], a
-	ld a, $50
-	ld [hWY], a
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 293de
-
-TradeAnim_TextboxScrollStart: ; 293de
-	ld a, $7
-	ld [hWX], a
-	ld a, $90
-	ld [hWY], a
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 293ea
-
-TradeAnim_ScrollOutRight: ; 293ea
-	call WaitTop
-	ld a, VBGMap1 / $100
-	ld [hBGMapAddress + 1], a
-	call WaitBGMap
-	ld a, $7
-	ld [hWX], a
-	xor a
-	ld [hWY], a
-	call DelayFrame
-	call WaitTop
-	ld a, VBGMap0 / $100
-	ld [hBGMapAddress + 1], a
-	call ClearTileMap
-	call TradeAnim_IncrementJumptableIndex
-	ret
-
-; 2940c
-
-TradeAnim_ScrollOutRight2: ; 2940c
-	ld a, [hWX]
-	cp $a1
-	jr nc, .done
-	add $4
-	ld [hWX], a
-	ret
-
-.done
-	ld a, VBGMap1 / $100
-	ld [hBGMapAddress + 1], a
-	call WaitBGMap
-	ld a, $7
-	ld [hWX], a
-	ld a, $90
-	ld [hWY], a
-	ld a, VBGMap0 / $100
-	ld [hBGMapAddress + 1], a
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 2942e
-
-TradeAnim_ShowGivemonData: ; 2942e
-	call ShowPlayerTrademonStats
-	ld a, [wPlayerTrademonSpecies]
-	ld [CurPartySpecies], a
-	ld a, [wPlayerTrademonDVs]
-	ld [TempMonDVs], a
-	ld a, [wPlayerTrademonDVs + 1]
-	ld [TempMonDVs + 1], a
-	ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
-	call GetSGBLayout
-	ld a, %11100100 ; 3,2,1,0
-	call DmgToCgbBGPals
-	call TradeAnim_ShowGivemonFrontpic
-
-	ld a, [wPlayerTrademonSpecies]
-	call GetCryIndex
-	jr c, .skip_cry
-	ld e, c
-	ld d, b
-	call PlayCryHeader
-.skip_cry
-
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29461
-
-TradeAnim_ShowGetmonData: ; 29461
-	call ShowOTTrademonStats
-	ld a, [wOTTrademonSpecies]
-	ld [CurPartySpecies], a
-	ld a, [wOTTrademonDVs]
-	ld [TempMonDVs], a
-	ld a, [wOTTrademonDVs + 1]
-	ld [TempMonDVs + 1], a
-	ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
-	call GetSGBLayout
-	ld a, %11100100 ; 3,2,1,0
-	call DmgToCgbBGPals
-	call TradeAnim_ShowGetmonFrontpic
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29487
-
-TradeAnim_AnimateFrontpic: ; 29487
-	callba AnimateTrademonFrontpic
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29491
-
-TradeAnim_GetFrontpic: ; 29491
-	push de
-	push af
-	predef GetUnownLetter
-	pop af
-	ld [CurPartySpecies], a
-	ld [CurSpecies], a
-	call GetBaseData
-	pop de
-	predef GetFrontpic
-	ret
-
-; 294a9
-
-TradeAnim_GetNickname: ; 294a9
-	push de
-	ld [wd265], a
-	call GetPokemonName
-	ld hl, StringBuffer1
-	pop de
-	ld bc, NAME_LENGTH
-	call CopyBytes
-	ret
-
-; 294bb
-
-TradeAnim_ShowGivemonFrontpic: ; 294bb
-	ld de, VTiles0
-	jr TradeAnim_ShowFrontpic
-
-TradeAnim_ShowGetmonFrontpic: ; 294c0
-	ld de, VTiles0 tile $31
-TradeAnim_ShowFrontpic: ; 294c3
-	call DelayFrame
-	ld hl, VTiles2
-	lb bc, 10, $31
-	call Request2bpp
-	call WaitTop
-	call TradeAnim_BlankTileMap
-	hlcoord 7, 2
-	xor a
-	ld [hGraphicStartTile], a
-	lb bc, 7, 7
-	predef PlaceGraphic
-	call WaitBGMap
-	ret
-
-; 294e7
-
-TraideAnim_Wait80: ; 294e7
-	ld c, 80
-	call DelayFrames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 294f0
-
-TraideAnim_Wait40: ; 294f0
-	ld c, 40
-	call DelayFrames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 294f9
-
-TraideAnim_Wait96: ; 294f9
-	ld c, 96
-	call DelayFrames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29502
-
-TraideAnim_Wait80IfOTEgg: ; 29502
-	call IsOTTrademonEgg
-	ret nz
-	ld c, 80
-	call DelayFrames
-	ret
-
-; 2950c
-
-TraideAnim_Wait180IfOTEgg: ; 2950c
-	call IsOTTrademonEgg
-	ret nz
-	ld c, 180
-	call DelayFrames
-	ret
-
-; 29516
-
-IsOTTrademonEgg: ; 29516
-	call TradeAnim_AdvanceScriptPointer
-	ld a, [wOTTrademonSpecies]
-	cp EGG
-	ret
-
-; 2951f
-ShowPlayerTrademonStats: ; 2951f
-	ld de, wPlayerTrademonSpecies
-	ld a, [de]
-	cp EGG
-	jr z, TrademonStats_Egg
-	call TrademonStats_MonTemplate
-	ld de, wPlayerTrademonSpecies
-	call TrademonStats_PrintSpeciesNumber
-	ld de, wPlayerTrademonSpeciesName
-	call TrademonStats_PrintSpeciesName
-	ld a, [wPlayerTrademonCaughtData]
-	ld de, wPlayerTrademonOTName
-	call TrademonStats_PrintOTName
-	ld de, wPlayerTrademonID
-	call TrademonStats_PrintTrademonID
-	call TrademonStats_WaitBGMap
-	ret
-
-; 29549
-
-ShowOTTrademonStats: ; 29549
-	ld de, wOTTrademonSpecies
-	ld a, [de]
-	cp EGG
-	jr z, TrademonStats_Egg
-	call TrademonStats_MonTemplate
-	ld de, wOTTrademonSpecies
-	call TrademonStats_PrintSpeciesNumber
-	ld de, wOTTrademonSpeciesName
-	call TrademonStats_PrintSpeciesName
-	ld a, [wOTTrademonCaughtData]
-	ld de, wOTTrademonOTName
-	call TrademonStats_PrintOTName
-	ld de, wOTTrademonID
-	call TrademonStats_PrintTrademonID
-	call TrademonStats_WaitBGMap
-	ret
-
-; 29573
-
-TrademonStats_MonTemplate: ; 29573
-	call WaitTop
-	call TradeAnim_BlankTileMap
-	ld a, VBGMap1 / $100
-	ld [hBGMapAddress + 1], a
-	hlcoord 3, 0
-	ld b, $6
-	ld c, $d
-	call TextBox
-	hlcoord 4, 0
-	ld de, .OTMonData
-	call PlaceString
-	ret
-
-; 29591
-
-.OTMonData: ; 29591
-	db   "─── №."
-	next ""
-	next "OT/"
-	next "<ID>№.@"
-; 295a1
-
-TrademonStats_Egg: ; 295a1
-	call WaitTop
-	call TradeAnim_BlankTileMap
-	ld a, VBGMap1 / $100
-	ld [hBGMapAddress + 1], a
-	hlcoord 3, 0
-	ld b, 6
-	ld c, 13
-	call TextBox
-	hlcoord 4, 2
-	ld de, .EggData
-	call PlaceString
-	call TrademonStats_WaitBGMap
-	ret
-
-; 295c2
-
-.EggData: ; 295c2
-	db   "EGG"
-	next "OT/?????"
-	next "<ID>№.?????@"
-; 295d8
-
-TrademonStats_WaitBGMap: ; 295d8
-	call WaitBGMap
-	call WaitTop
-	ld a, VBGMap0 / $100
-	ld [hBGMapAddress + 1], a
-	ret
-
-; 295e3
-
-TrademonStats_PrintSpeciesNumber: ; 295e3
-	hlcoord 10, 0
-	lb bc, PRINTNUM_LEADINGZEROS | 1, 3
-	call PrintNum
-	ld [hl], " "
-	ret
-
-; 295ef
-
-TrademonStats_PrintSpeciesName: ; 295ef
-	hlcoord 4, 2
-	call PlaceString
-	ret
-
-; 295f6
-
-TrademonStats_PrintOTName: ; 295f6
-	cp 3
-	jr c, .caught_gender_okay
-	xor a
-.caught_gender_okay
-	push af
-	hlcoord 7, 4
-	call PlaceString
-	inc bc
-	pop af
-	ld hl, .Gender
-	ld d, 0
-	ld e, a
-	add hl, de
-	ld a, [hl]
-	ld [bc], a
-	ret
-
-; 2960e
-
-.Gender: ; 2960e
-	db " ", "♂", "♀"
-; 29611
-
-TrademonStats_PrintTrademonID: ; 29611
-	hlcoord 7, 6
-	lb bc, PRINTNUM_LEADINGZEROS | 2, 5
-	call PrintNum
-	ret
-
-; 2961b
-
-TradeAnim_RockingBall: ; 2961b
-	depixel 10, 11, 4, 0
-	ld a, SPRITE_ANIM_INDEX_TRADE_POKE_BALL
-	call _InitSpriteAnimStruct
-	call TradeAnim_AdvanceScriptPointer
-	ld a, $20
-	ld [wcf64], a
-	ret
-
-; 2962c
-
-TradeAnim_DropBall: ; 2962c
-	depixel 10, 11, 4, 0
-	ld a, SPRITE_ANIM_INDEX_TRADE_POKE_BALL
-	call _InitSpriteAnimStruct
-	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
-	add hl, bc
-	ld [hl], $1
-	ld hl, SPRITEANIMSTRUCT_YOFFSET
-	add hl, bc
-	ld [hl], $dc
-	call TradeAnim_AdvanceScriptPointer
-	ld a, $38
-	ld [wcf64], a
-	ret
-
-; 29649
-
-TradeAnim_Poof: ; 29649
-	depixel 10, 11, 4, 0
-	ld a, SPRITE_ANIM_INDEX_TRADE_POOF
-	call _InitSpriteAnimStruct
-	call TradeAnim_AdvanceScriptPointer
-	ld a, $10
-	ld [wcf64], a
-	ld de, SFX_BALL_POOF
-	call PlaySFX
-	ret
-
-; 29660
-
-TradeAnim_BulgeThroughTube: ; 29660
-	ld a, %11100100 ; 3,2,1,0
-	call DmgToCgbObjPal0
-	depixel 5, 11
-	ld a, SPRITE_ANIM_INDEX_TRADE_TUBE_BULGE
-	call _InitSpriteAnimStruct
-	call TradeAnim_AdvanceScriptPointer
-	ld a, $40
-	ld [wcf64], a
-	ret
-
-; 29676
-
-TradeAnim_AnimateTrademonInTube: ; 29676 (a:5676)
-	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
-	add hl, bc
-	ld e, [hl]
-	ld d, 0
-	ld hl, .Jumptable
-	add hl, de
-	add hl, de
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	jp hl
-; 29686
-
-.Jumptable: ; 29686 (a:5686)
-	dw .InitTimer
-	dw .WaitTimer1
-	dw .MoveRight
-	dw .MoveDown
-	dw .MoveUp
-	dw .MoveLeft
-	dw .WaitTimer2
-; 2969a
-
-.JumptableNext: ; 29694 (a:5694)
-	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
-	add hl, bc
-	inc [hl]
-	ret
-
-.InitTimer: ; 2969a (a:569a)
-	call .JumptableNext
-	ld hl, SPRITEANIMSTRUCT_0C
-	add hl, bc
-	ld [hl], $80
-	ret
-
-.WaitTimer1: ; 296a4 (a:56a4)
-	ld hl, SPRITEANIMSTRUCT_0C
-	add hl, bc
-	ld a, [hl]
-	dec [hl]
-	and a
-	ret nz
-	call .JumptableNext
-
-.MoveRight: ; 296af (a:56af)
-	ld hl, SPRITEANIMSTRUCT_XCOORD
-	add hl, bc
-	ld a, [hl]
-	cp $94
-	jr nc, .done_move_right
-	inc [hl]
-	ret
-
-.done_move_right
-	call .JumptableNext
-
-.MoveDown: ; 296bd (a:56bd)
-	ld hl, SPRITEANIMSTRUCT_YCOORD
-	add hl, bc
-	ld a, [hl]
-	cp $4c
-	jr nc, .done_move_down
-	inc [hl]
-	ret
-
-.done_move_down
-	ld hl, SPRITEANIMSTRUCT_INDEX
-	add hl, bc
-	ld [hl], $0
-	ret
-
-.MoveUp: ; 296cf (a:56cf)
-	ld hl, SPRITEANIMSTRUCT_YCOORD
-	add hl, bc
-	ld a, [hl]
-	cp $2c
-	jr z, .done_move_up
-	dec [hl]
-	ret
-
-.done_move_up
-	call .JumptableNext
-
-.MoveLeft: ; 296dd (a:56dd)
-	ld hl, SPRITEANIMSTRUCT_XCOORD
-	add hl, bc
-	ld a, [hl]
-	cp $58
-	jr z, .done_move_left
-	dec [hl]
-	ret
-
-.done_move_left
-	call .JumptableNext
-	ld hl, SPRITEANIMSTRUCT_0C
-	add hl, bc
-	ld [hl], $80
-	ret
-
-.WaitTimer2: ; 296f2 (a:56f2)
-	ld hl, SPRITEANIMSTRUCT_0C
-	add hl, bc
-	ld a, [hl]
-	dec [hl]
-	and a
-	ret nz
-	ld hl, SPRITEANIMSTRUCT_INDEX
-	add hl, bc
-	ld [hl], $0
-	ret
-
-; 29701 (a:5701)
-
-TradeAnim_SentToOTText: ; 29701
-	ld a, [wLinkMode]
-	cp LINK_TIMECAPSULE
-	jr z, .time_capsule
-	ld hl, .Text_MonName
-	call PrintText
-	ld c, 189
-	call DelayFrames
-	ld hl, .Text_WasSentTo
-	call PrintText
-	call TradeAnim_Wait80Frames
-	ld c, 128
-	call DelayFrames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-.time_capsule
-	ld hl, .Text_WasSentTo
-	call PrintText
-	call TradeAnim_Wait80Frames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29732
-
-.Text_WasSentTo: ; 0x29732
-	; was sent to @ .
-	text_jump UnknownText_0x1bc6e9
-	db "@"
-; 0x29737
-
-.Text_MonName: ; 0x29737
-	;
-	text_jump UnknownText_0x1bc701
-	db "@"
-; 0x2973c
-
-TradeAnim_OTBidsFarewell: ; 2973c
-	ld hl, .Text_BidsFarewellToMon
-	call PrintText
-	call TradeAnim_Wait80Frames
-	ld hl, .Text_MonName
-	call PrintText
-	call TradeAnim_Wait80Frames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29752
-
-.Text_BidsFarewellToMon: ; 0x29752
-	; bids farewell to
-	text_jump UnknownText_0x1bc703
-	db "@"
-; 0x29757
-
-.Text_MonName: ; 0x29757
-	; .
-	text_jump UnknownText_0x1bc719
-	db "@"
-; 0x2975c
-
-TradeAnim_TakeCareOfText: ; 2975c
-	call WaitTop
-	hlcoord 0, 10
-	ld bc, 8 * SCREEN_WIDTH
-	ld a, " "
-	call ByteFill
-	call WaitBGMap
-	ld hl, .Text_TakeGoodCareOfMon
-	call PrintText
-	call TradeAnim_Wait80Frames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 2977a
-
-.Text_TakeGoodCareOfMon: ; 0x2977a
-	; Take good care of @ .
-	text_jump UnknownText_0x1bc71f
-	db "@"
-; 0x2977f
-
-TradeAnim_OTSendsText1: ; 2977f
-	ld hl, .Text_ForYourMon
-	call PrintText
-	call TradeAnim_Wait80Frames
-	ld hl, .Text_OTSends
-	call PrintText
-	call TradeAnim_Wait80Frames
-	ld c, 14
-	call DelayFrames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 2979a
-
-.Text_ForYourMon: ; 0x2979a
-	; For @ 's @ ,
-	text_jump UnknownText_0x1bc739
-	db "@"
-; 0x2979f
-
-.Text_OTSends: ; 0x2979f
-	; sends @ .
-	text_jump UnknownText_0x1bc74c
-	db "@"
-; 0x297a4
-
-TradeAnim_OTSendsText2: ; 297a4
-	ld hl, .Text_WillTrade
-	call PrintText
-	call TradeAnim_Wait80Frames
-	ld hl, .Text_ForYourMon
-	call PrintText
-	call TradeAnim_Wait80Frames
-	ld c, 14
-	call DelayFrames
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 297bf
-
-.Text_WillTrade: ; 0x297bf
-	; will trade @ @
-	text_jump UnknownText_0x1bc75e
-	db "@"
-; 0x297c4
-
-.Text_ForYourMon: ; 0x297c4
-	; for @ 's @ .
-	text_jump UnknownText_0x1bc774
-	db "@"
-; 0x297c9
-
-TradeAnim_Wait80Frames: ; 297c9
-	ld c, 80
-	call DelayFrames
-	ret
-
-; 297cf
-
-TradeAnim_BlankTileMap: ; 297cf
-	hlcoord 0, 0
-	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
-	ld a, " "
-	call ByteFill
-	ret
-
-; 297db
-
-TradeAnim_CopyBoxFromDEtoHL: ; 297db
-.row
-	push bc
-	push hl
-.col
-	ld a, [de]
-	inc de
-	ld [hli], a
-	dec c
-	jr nz, .col
-	pop hl
-	ld bc, SCREEN_WIDTH
-	add hl, bc
-	pop bc
-	dec b
-	jr nz, .row
-	ret
-
-; 297ed
-
-TradeAnim_NormalPals: ; 297ed
-	ld a, [hSGB]
-	and a
-	ld a, %11100100 ; 3,2,1,0
-	jr z, .not_sgb
-	ld a, $f0
-
-.not_sgb
-	call DmgToCgbObjPal0
-	ld a, %11100100 ; 3,2,1,0
-	call DmgToCgbBGPals
-	ret
-
-; 297ff
-
-LinkTradeAnim_LoadTradePlayerNames: ; 297ff
-	push de
-	ld de, wLinkPlayer1Name
-	ld bc, NAME_LENGTH
-	call CopyBytes
-	pop hl
-	ld de, wLinkPlayer2Name
-	ld bc, NAME_LENGTH
-	call CopyBytes
-	ret
-
-; 29814
-
-LinkTradeAnim_LoadTradeMonSpecies: ; 29814
-	ld a, [hl]
-	ld [wLinkTradeSendmonSpecies], a
-	ld a, [de]
-	ld [wLinkTradeGetmonSpecies], a
-	ret
-
-; 2981d
-
-TradeAnim_FlashBGPals: ; 2981d
-	ld a, [wcf65]
-	and $7
-	ret nz
-	ld a, [rBGP]
-	xor %00111100
-	call DmgToCgbBGPals
-	ret
-
-; 2982b
-
-LoadTradeBallAndCableGFX: ; 2982b
-	call DelayFrame
-	ld de, TradeBallGFX
-	ld hl, VTiles0 tile $62
-	lb bc, BANK(TradeBallGFX), $6
-	call Request2bpp
-	ld de, TradePoofGFX
-	ld hl, VTiles0 tile $68
-	lb bc, BANK(TradePoofGFX), $c
-	call Request2bpp
-	ld de, TradeCableGFX
-	ld hl, VTiles0 tile $74
-	lb bc, BANK(TradeCableGFX), $4
-	call Request2bpp
-	xor a
-	ld hl, wSpriteAnimDict
-	ld [hli], a
-	ld [hl], $62
-	ret
-
-; 2985a
-
-LoadTradeBubbleGFX: ; 2985a
-	call DelayFrame
-	ld e, $3
-	callab LoadMenuMonIcon
-	ld de, TradeBubbleGFX
-	ld hl, VTiles0 tile $72
-	lb bc, BANK(TradeBubbleGFX), $4
-	call Request2bpp
-	xor a
-	ld hl, wSpriteAnimDict
-	ld [hli], a
-	ld [hl], $62
-	ret
-
-; 29879
-
-TradeAnim_WaitAnim: ; 29879
-	ld hl, wcf64
-	ld a, [hl]
-	and a
-	jr z, .done
-	dec [hl]
-	ret
-
-.done
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29886
-
-TradeAnim_WaitAnim2: ; 29886
-	ld hl, wcf64
-	ld a, [hl]
-	and a
-	jr z, .done
-	dec [hl]
-	ret
-
-.done
-	call TradeAnim_AdvanceScriptPointer
-	ret
-
-; 29893
-
-
-DebugTrade: ; 29893
-; This function is unreferenced.
-; It was meant for use in Japanese versions, so the
-; constant used for copy length was changed by accident.
-
-	ld hl, .DebugTradeData
-
-	ld a, [hli]
-	ld [wPlayerTrademonSpecies], a
-	ld de, wPlayerTrademonSenderName
-	ld c, 11 + 2 ; jp: 6 + 2
-.loop1
-	ld a, [hli]
-	ld [de], a
-	inc de
-	dec c
-	jr nz, .loop1
-
-	ld a, [hli]
-	ld [wOTTrademonSpecies], a
-	ld de, wOTTrademonSenderName
-	ld c, 11 + 2 ; jp: 6 + 2
-.loop2
-	ld a, [hli]
-	ld [de], a
-	inc de
-	dec c
-	jr nz, .loop2
-	ret
-
-; 298b5
-
-.DebugTradeData: ; 298b5
-	db VENUSAUR, "ゲーフり@@", $23, $01 ; GAME FREAK
-	db CHARIZARD, "クりーチャ@", $56, $04 ; Creatures Inc.
-; 298c7
-
-
-TradeGameBoyTilemap: ; 298c7
-; 6x8
-	db $31, $32, $32, $32, $32, $33
-	db $34, $35, $36, $36, $37, $38
-	db $34, $39, $3a, $3a, $3b, $38
-	db $3c, $3d, $3e, $3e, $3f, $40
-	db $41, $42, $43, $43, $44, $45
-	db $46, $47, $43, $48, $49, $4a
-	db $41, $43, $4b, $4c, $4d, $4e
-	db $4f, $50, $50, $50, $51, $52
-; 297f7
-
-TradeLinkTubeTilemap: ; 297f7
-; 12x3
-	db $43, $55, $56, $53, $53, $53, $53, $53, $53, $53, $53, $53
-	db $43, $57, $58, $54, $54, $54, $54, $54, $54, $54, $54, $54
-	db $43, $59, $5a, $43, $43, $43, $43, $43, $43, $43, $43, $43
-; 2991b
-
-TradeArrowGFX:  INCBIN "gfx/trade/arrow.2bpp"
-TradeCableGFX:  INCBIN "gfx/trade/cable.2bpp"
-TradeBubbleGFX: INCBIN "gfx/trade/bubble.2bpp"
-TradeGameBoyLZ: INCBIN "gfx/trade/game_boy.2bpp.lz"
-TradeBallGFX:   INCBIN "gfx/trade/ball.2bpp"
-TradePoofGFX:   INCBIN "gfx/trade/poof.2bpp"
--- /dev/null
+++ b/engine/trade_animation.asm
@@ -1,0 +1,1628 @@
+TradeAnimation: ; 28f24
+	xor a
+	ld [wcf66], a
+	ld hl, wPlayerTrademonSenderName
+	ld de, wOTTrademonSenderName
+	call LinkTradeAnim_LoadTradePlayerNames
+	ld hl, wPlayerTrademonSpecies
+	ld de, wOTTrademonSpecies
+	call LinkTradeAnim_LoadTradeMonSpecies
+	ld de, .script
+	jr RunTradeAnimScript
+
+.script
+	tradeanim_setup_givemon_scroll
+	tradeanim_show_givemon_data
+	tradeanim_do_givemon_scroll
+	tradeanim_wait_80
+	tradeanim_wait_96
+	tradeanim_poof
+	tradeanim_rocking_ball
+	tradeanim_enter_link_tube
+	tradeanim_wait_anim
+	tradeanim_bulge_through_tube
+	tradeanim_wait_anim
+	tradeanim_textbox_scroll
+	tradeanim_give_trademon_sfx
+	tradeanim_tube_to_ot
+	tradeanim_sent_to_ot_text
+	tradeanim_scroll_out_right
+
+	tradeanim_ot_sends_text_1
+	tradeanim_ot_bids_farewell
+	tradeanim_wait_40
+	tradeanim_scroll_out_right
+	tradeanim_get_trademon_sfx
+	tradeanim_tube_to_player
+	tradeanim_enter_link_tube
+	tradeanim_drop_ball
+	tradeanim_exit_link_tube
+	tradeanim_wait_anim
+	tradeanim_show_getmon_data
+	tradeanim_poof
+	tradeanim_wait_anim
+	tradeanim_frontpic_scroll
+	tradeanim_animate_frontpic
+	tradeanim_wait_80_if_ot_egg
+	tradeanim_textbox_scroll
+	tradeanim_take_care_of_text
+	tradeanim_scroll_out_right
+	tradeanim_end
+
+TradeAnimationPlayer2: ; 28f63
+	xor a
+	ld [wcf66], a
+	ld hl, wOTTrademonSenderName
+	ld de, wPlayerTrademonSenderName
+	call LinkTradeAnim_LoadTradePlayerNames
+	ld hl, wOTTrademonSpecies
+	ld de, wPlayerTrademonSpecies
+	call LinkTradeAnim_LoadTradeMonSpecies
+	ld de, .script
+	jr RunTradeAnimScript
+
+.script
+	tradeanim_ot_sends_text_2
+	tradeanim_ot_bids_farewell
+	tradeanim_wait_40
+	tradeanim_scroll_out_right
+	tradeanim_get_trademon_sfx
+	tradeanim_tube_to_ot
+	tradeanim_enter_link_tube
+	tradeanim_drop_ball
+	tradeanim_exit_link_tube
+	tradeanim_wait_anim
+	tradeanim_show_getmon_data
+	tradeanim_poof
+	tradeanim_wait_anim
+	tradeanim_frontpic_scroll
+	tradeanim_animate_frontpic
+	tradeanim_wait_180_if_ot_egg
+	tradeanim_textbox_scroll
+	tradeanim_take_care_of_text
+	tradeanim_scroll_out_right
+
+	tradeanim_setup_givemon_scroll
+	tradeanim_show_givemon_data
+	tradeanim_do_givemon_scroll
+	tradeanim_wait_40
+	tradeanim_poof
+	tradeanim_rocking_ball
+	tradeanim_enter_link_tube
+	tradeanim_wait_anim
+	tradeanim_bulge_through_tube
+	tradeanim_wait_anim
+	tradeanim_textbox_scroll
+	tradeanim_give_trademon_sfx
+	tradeanim_tube_to_player
+	tradeanim_sent_to_ot_text
+	tradeanim_scroll_out_right
+	tradeanim_end
+
+RunTradeAnimScript: ; 28fa1
+	ld hl, wTradeAnimAddress
+	ld [hl], e
+	inc hl
+	ld [hl], d
+	ld a, [hMapAnims]
+	push af
+	xor a
+	ld [hMapAnims], a
+	ld hl, VramState
+	ld a, [hl]
+	push af
+	res 0, [hl]
+	ld hl, Options
+	ld a, [hl]
+	push af
+	set 4, [hl]
+	call .TradeAnimLayout
+	ld a, [wcf66]
+	and a
+	jr nz, .anim_loop
+	ld de, MUSIC_EVOLUTION
+	call PlayMusic2
+.anim_loop
+	call DoTradeAnimation
+	jr nc, .anim_loop
+	pop af
+	ld [Options], a
+	pop af
+	ld [VramState], a
+	pop af
+	ld [hMapAnims], a
+	ret
+
+; 28fdb
+
+.TradeAnimLayout: ; 28fdb
+	xor a
+	ld [wJumptableIndex], a
+	call ClearBGPalettes
+	call ClearSprites
+	call ClearTileMap
+	call DisableLCD
+	call LoadFontsBattleExtra
+	callab ClearSpriteAnims
+	ld a, [hCGB]
+	and a
+	jr z, .NotCGB
+	ld a, $1
+	ld [rVBK], a
+	ld hl, VTiles0
+	ld bc, sScratch - VTiles0
+	xor a
+	call ByteFill
+	ld a, $0
+	ld [rVBK], a
+
+.NotCGB:
+	hlbgcoord 0, 0
+	ld bc, sScratch - VBGMap0
+	ld a, " "
+	call ByteFill
+	ld hl, TradeGameBoyLZ
+	ld de, VTiles2 tile $31
+	call Decompress
+	ld hl, TradeArrowGFX
+	ld de, VTiles1 tile $6d
+	ld bc, $10
+	ld a, BANK(TradeArrowGFX)
+	call FarCopyBytes
+	ld hl, TradeArrowGFX + $10
+	ld de, VTiles1 tile $6e
+	ld bc, $10
+	ld a, BANK(TradeArrowGFX)
+	call FarCopyBytes
+	xor a
+	ld [hSCX], a
+	ld [hSCY], a
+	ld a, $7
+	ld [hWX], a
+	ld a, $90
+	ld [hWY], a
+	callba GetTrademonFrontpic
+	call EnableLCD
+	call LoadTradeBallAndCableGFX
+	ld a, [wPlayerTrademonSpecies]
+	ld hl, wPlayerTrademonDVs
+	ld de, VTiles0
+	call TradeAnim_GetFrontpic
+	ld a, [wOTTrademonSpecies]
+	ld hl, wOTTrademonDVs
+	ld de, VTiles0 tile $31
+	call TradeAnim_GetFrontpic
+	ld a, [wPlayerTrademonSpecies]
+	ld de, wPlayerTrademonSpeciesName
+	call TradeAnim_GetNickname
+	ld a, [wOTTrademonSpecies]
+	ld de, wOTTrademonSpeciesName
+	call TradeAnim_GetNickname
+	call TradeAnim_NormalPals
+	ret
+
+; 29082
+
+DoTradeAnimation: ; 29082
+	ld a, [wJumptableIndex]
+	bit 7, a
+	jr nz, .finished
+	call .DoTradeAnimCommand
+	callab PlaySpriteAnimations
+	ld hl, wcf65
+	inc [hl]
+	call DelayFrame
+	and a
+	ret
+
+.finished
+	call LoadStandardFont
+	scf
+	ret
+
+; 290a0
+
+.DoTradeAnimCommand: ; 290a0
+	ld a, [wJumptableIndex]
+	ld e, a
+	ld d, 0
+	ld hl, .JumpTable
+	add hl, de
+	add hl, de
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	jp hl
+; 290af
+
+.JumpTable: ; 290af
+; entries correspond to macros/trade_anim.asm enumeration
+	dw TradeAnim_AdvanceScriptPointer ; 00
+	dw TradeAnim_ShowGivemonData      ; 01
+	dw TradeAnim_ShowGetmonData       ; 02
+	dw TradeAnim_EnterLinkTube1       ; 03
+	dw TradeAnim_EnterLinkTube2       ; 04
+	dw TradeAnim_ExitLinkTube         ; 05
+	dw TradeAnim_TubeToOT1            ; 06
+	dw TradeAnim_TubeToOT2            ; 07
+	dw TradeAnim_TubeToOT3            ; 08
+	dw TradeAnim_TubeToOT4            ; 09
+	dw TradeAnim_TubeToOT5            ; 0a
+	dw TradeAnim_TubeToOT6            ; 0b
+	dw TradeAnim_TubeToOT7            ; 0c
+	dw TradeAnim_TubeToOT8            ; 0d
+	dw TradeAnim_TubeToPlayer1        ; 0e
+	dw TradeAnim_TubeToPlayer2        ; 0f
+	dw TradeAnim_TubeToPlayer3        ; 10
+	dw TradeAnim_TubeToPlayer4        ; 11
+	dw TradeAnim_TubeToPlayer5        ; 12
+	dw TradeAnim_TubeToPlayer6        ; 13
+	dw TradeAnim_TubeToPlayer7        ; 14
+	dw TradeAnim_TubeToPlayer8        ; 15
+	dw TradeAnim_SentToOTText         ; 16
+	dw TradeAnim_OTBidsFarewell       ; 17
+	dw TradeAnim_TakeCareOfText       ; 18
+	dw TradeAnim_OTSendsText1         ; 19
+	dw TradeAnim_OTSendsText2         ; 1a
+	dw TradeAnim_SetupGivemonScroll   ; 1b
+	dw TradeAnim_DoGivemonScroll      ; 1c
+	dw TradeAnim_FrontpicScrollStart  ; 1d
+	dw TradeAnim_TextboxScrollStart   ; 1e
+	dw TradeAnim_ScrollOutRight       ; 1f
+	dw TradeAnim_ScrollOutRight2      ; 20
+	dw TraideAnim_Wait80              ; 21
+	dw TraideAnim_Wait40              ; 22
+	dw TradeAnim_RockingBall          ; 23
+	dw TradeAnim_DropBall             ; 24
+	dw TradeAnim_WaitAnim             ; 25
+	dw TradeAnim_WaitAnim2            ; 26
+	dw TradeAnim_Poof                 ; 27
+	dw TradeAnim_BulgeThroughTube     ; 28
+	dw TradeAnim_GiveTrademonSFX      ; 29
+	dw TradeAnim_GetTrademonSFX       ; 2a
+	dw TradeAnim_End                  ; 2b
+	dw TradeAnim_AnimateFrontpic      ; 2c
+	dw TraideAnim_Wait96              ; 2d
+	dw TraideAnim_Wait80IfOTEgg       ; 2e
+	dw TraideAnim_Wait180IfOTEgg      ; 2f
+; 2910f
+
+TradeAnim_IncrementJumptableIndex: ; 2910f
+	ld hl, wJumptableIndex
+	inc [hl]
+	ret
+
+; 29114
+
+TradeAnim_AdvanceScriptPointer: ; 29114
+	ld hl, wTradeAnimAddress
+	ld e, [hl]
+	inc hl
+	ld d, [hl]
+	ld a, [de]
+	ld [wJumptableIndex], a
+	inc de
+	ld [hl], d
+	dec hl
+	ld [hl], e
+	ret
+
+; 29123
+
+TradeAnim_End: ; 29123
+	ld hl, wJumptableIndex
+	set 7, [hl]
+	ret
+
+; 29129
+
+TradeAnim_TubeToOT1: ; 29129
+	ld a, $ed ; >>>>>>>>
+	call TradeAnim_PlaceTrademonStatsOnTubeAnim
+	ld a, [wLinkTradeSendmonSpecies]
+	ld [wd265], a
+	xor a
+	depixel 5, 11, 4, 0
+	ld b, $0
+	jr TradeAnim_InitTubeAnim
+
+TradeAnim_TubeToPlayer1: ; 2913c
+	ld a, $ee ; <<<<<<<<
+	call TradeAnim_PlaceTrademonStatsOnTubeAnim
+	ld a, [wLinkTradeGetmonSpecies]
+	ld [wd265], a
+	ld a, $2
+	depixel 9, 18, 4, 4
+	ld b, $4
+TradeAnim_InitTubeAnim: ; 2914e
+	push bc
+	push de
+	push bc
+	push de
+
+	push af
+	call DisableLCD
+	callab ClearSpriteAnims
+	hlbgcoord 20, 3
+	ld bc, 12
+	ld a, $60
+	call ByteFill
+	pop af
+
+	call TradeAnim_TubeAnimJumptable
+
+	xor a
+	ld [hSCX], a
+	ld a, $7
+	ld [hWX], a
+	ld a, $70
+	ld [hWY], a
+	call EnableLCD
+	call LoadTradeBubbleGFX
+
+	pop de
+	ld a, SPRITE_ANIM_INDEX_TRADEMON_ICON
+	call _InitSpriteAnimStruct
+
+	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
+	add hl, bc
+	pop bc
+	ld [hl], b
+
+	pop de
+	ld a, SPRITE_ANIM_INDEX_TRADEMON_BUBBLE
+	call _InitSpriteAnimStruct
+
+	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
+	add hl, bc
+	pop bc
+	ld [hl], b
+
+	call WaitBGMap
+	ld b, SCGB_TRADE_TUBE
+	call GetSGBLayout
+	ld a, %11100100 ; 3,2,1,0
+	call DmgToCgbBGPals
+	ld a, %11010000
+	call DmgToCgbObjPal0
+
+	call TradeAnim_IncrementJumptableIndex
+	ld a, $5c
+	ld [wcf64], a
+	ret
+
+; 291af
+
+TradeAnim_TubeToOT2: ; 291af
+	call TradeAnim_FlashBGPals
+	ld a, [hSCX]
+	add $2
+	ld [hSCX], a
+	cp $50
+	ret nz
+	ld a, $1
+	call TradeAnim_TubeAnimJumptable
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 291c4
+
+TradeAnim_TubeToOT3: ; 291c4
+	call TradeAnim_FlashBGPals
+	ld a, [hSCX]
+	add $2
+	ld [hSCX], a
+	cp $a0
+	ret nz
+	ld a, $2
+	call TradeAnim_TubeAnimJumptable
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 291d9
+
+TradeAnim_TubeToOT4: ; 291d9
+	call TradeAnim_FlashBGPals
+	ld a, [hSCX]
+	add $2
+	ld [hSCX], a
+	and a
+	ret nz
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 291e8
+
+TradeAnim_TubeToPlayer3: ; 291e8
+	call TradeAnim_FlashBGPals
+	ld a, [hSCX]
+	sub $2
+	ld [hSCX], a
+	cp $b0
+	ret nz
+	ld a, $1
+	call TradeAnim_TubeAnimJumptable
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 291fd
+
+TradeAnim_TubeToPlayer4: ; 291fd
+	call TradeAnim_FlashBGPals
+	ld a, [hSCX]
+	sub $2
+	ld [hSCX], a
+	cp $60
+	ret nz
+	xor a
+	call TradeAnim_TubeAnimJumptable
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 29211
+
+TradeAnim_TubeToPlayer5: ; 29211
+	call TradeAnim_FlashBGPals
+	ld a, [hSCX]
+	sub $2
+	ld [hSCX], a
+	and a
+	ret nz
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 29220
+
+TradeAnim_TubeToOT6:
+TradeAnim_TubeToPlayer6: ; 29220
+	ld a, $80
+	ld [wcf64], a
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 29229
+
+TradeAnim_TubeToOT8:
+TradeAnim_TubeToPlayer8: ; 29229
+	call ClearBGPalettes
+	call ClearTileMap
+	call ClearSprites
+	call DisableLCD
+	callab ClearSpriteAnims
+	hlbgcoord 0, 0
+	ld bc, sScratch - VBGMap0
+	ld a, " "
+	call ByteFill
+	xor a
+	ld [hSCX], a
+	ld a, $90
+	ld [hWY], a
+	call EnableLCD
+	call LoadTradeBallAndCableGFX
+	call WaitBGMap
+	call TradeAnim_NormalPals
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 2925d
+
+TradeAnim_TubeToOT5:
+TradeAnim_TubeToOT7:
+TradeAnim_TubeToPlayer2:
+TradeAnim_TubeToPlayer7: ; 2925d
+	call TradeAnim_FlashBGPals
+	ld hl, wcf64
+	ld a, [hl]
+	and a
+	jr z, .done
+	dec [hl]
+	ret
+
+.done
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 2926d
+
+TradeAnim_GiveTrademonSFX: ; 2926d
+	call TradeAnim_AdvanceScriptPointer
+	ld de, SFX_GIVE_TRADEMON
+	call PlaySFX
+	ret
+
+; 29277
+
+TradeAnim_GetTrademonSFX: ; 29277
+	call TradeAnim_AdvanceScriptPointer
+	ld de, SFX_GET_TRADEMON
+	call PlaySFX
+	ret
+
+; 29281
+
+TradeAnim_TubeAnimJumptable: ; 29281
+	and 3
+	ld e, a
+	ld d, 0
+	ld hl, .Jumptable
+	add hl, de
+	add hl, de
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	jp hl
+; 2928f
+
+.Jumptable: ; 2928f
+	dw .Zero
+	dw .One
+	dw .Two
+	dw .Three
+; 29297
+
+.Zero: ; 29297
+.Three: ; 29297
+	call TradeAnim_BlankTileMap
+	hlcoord 9, 3
+	ld [hl], $5b
+	inc hl
+	ld bc, 10
+	ld a, $60
+	call ByteFill
+	hlcoord 3, 2
+	call TradeAnim_CopyTradeGameBoyTilemap
+	ret
+
+; 292af
+
+.One: ; 292af
+	call TradeAnim_BlankTileMap
+	hlcoord 0, 3
+	ld bc, SCREEN_WIDTH
+	ld a, $60
+	call ByteFill
+	ret
+
+; 292be
+
+.Two: ; 292be
+	call TradeAnim_BlankTileMap
+	hlcoord 0, 3
+	ld bc, $11
+	ld a, $60
+	call ByteFill
+	hlcoord 17, 3
+	ld a, $5d
+	ld [hl], a
+
+	ld a, $61
+	ld de, SCREEN_WIDTH
+	ld c, $3
+.loop
+	add hl, de
+	ld [hl], a
+	dec c
+	jr nz, .loop
+
+	add hl, de
+	ld a, $5f
+	ld [hld], a
+	ld a, $5b
+	ld [hl], a
+	hlcoord 10, 6
+	call TradeAnim_CopyTradeGameBoyTilemap
+	ret
+
+; 292ec
+
+TradeAnim_CopyTradeGameBoyTilemap: ; 292ec
+	ld de, TradeGameBoyTilemap
+	lb bc, 8, 6
+	call TradeAnim_CopyBoxFromDEtoHL
+	ret
+
+; 292f6
+
+TradeAnim_PlaceTrademonStatsOnTubeAnim: ; 292f6
+	push af
+	call ClearBGPalettes
+	call WaitTop
+	ld a, VBGMap1 / $100
+	ld [hBGMapAddress + 1], a
+	call ClearTileMap
+	hlcoord 0, 0
+	ld bc, SCREEN_WIDTH
+	ld a, "─"
+	call ByteFill
+	hlcoord 0, 1
+	ld de, wLinkPlayer1Name
+	call PlaceString
+	ld hl, wLinkPlayer2Name
+	ld de, 0
+.find_name_end_loop
+	ld a, [hli]
+	cp "@"
+	jr z, .done
+	dec de
+	jr .find_name_end_loop
+
+.done
+	hlcoord 0, 4
+	add hl, de
+	ld de, wLinkPlayer2Name
+	call PlaceString
+	hlcoord 7, 2
+	ld bc, 6
+	pop af
+	call ByteFill
+	call WaitBGMap
+	call WaitTop
+	ld a, VBGMap0 / $100
+	ld [hBGMapAddress + 1], a
+	call ClearTileMap
+	ret
+
+; 29348
+
+TradeAnim_EnterLinkTube1: ; 29348
+	call ClearTileMap
+	call WaitTop
+	ld a, $a0
+	ld [hSCX], a
+	call DelayFrame
+	hlcoord 8, 2
+	ld de, TradeLinkTubeTilemap
+	lb bc, 3, 12
+	call TradeAnim_CopyBoxFromDEtoHL
+	call WaitBGMap
+	ld b, SCGB_TRADE_TUBE
+	call GetSGBLayout
+	ld a, %11100100 ; 3,2,1,0
+	call DmgToCgbBGPals
+	lb de, %11100100, %11100100 ; 3,2,1,0, 3,2,1,0
+	call DmgToCgbObjPals
+	ld de, SFX_POTION
+	call PlaySFX
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 2937e
+
+TradeAnim_EnterLinkTube2: ; 2937e
+	ld a, [hSCX]
+	and a
+	jr z, .done
+	add $4
+	ld [hSCX], a
+	ret
+
+.done
+	ld c, 80
+	call DelayFrames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29391
+
+TradeAnim_ExitLinkTube: ; 29391
+	ld a, [hSCX]
+	cp $a0
+	jr z, .done
+	sub $4
+	ld [hSCX], a
+	ret
+
+.done
+	call ClearTileMap
+	xor a
+	ld [hSCX], a
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 293a6
+
+TradeAnim_SetupGivemonScroll: ; 293a6
+	ld a, $8f
+	ld [hWX], a
+	ld a, $88
+	ld [hSCX], a
+	ld a, $50
+	ld [hWY], a
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 293b6
+
+TradeAnim_DoGivemonScroll: ; 293b6
+	ld a, [hWX]
+	cp $7
+	jr z, .done
+	sub $4
+	ld [hWX], a
+	ld a, [hSCX]
+	sub $4
+	ld [hSCX], a
+	ret
+
+.done
+	ld a, $7
+	ld [hWX], a
+	xor a
+	ld [hSCX], a
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 293d2
+
+TradeAnim_FrontpicScrollStart: ; 293d2
+	ld a, $7
+	ld [hWX], a
+	ld a, $50
+	ld [hWY], a
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 293de
+
+TradeAnim_TextboxScrollStart: ; 293de
+	ld a, $7
+	ld [hWX], a
+	ld a, $90
+	ld [hWY], a
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 293ea
+
+TradeAnim_ScrollOutRight: ; 293ea
+	call WaitTop
+	ld a, VBGMap1 / $100
+	ld [hBGMapAddress + 1], a
+	call WaitBGMap
+	ld a, $7
+	ld [hWX], a
+	xor a
+	ld [hWY], a
+	call DelayFrame
+	call WaitTop
+	ld a, VBGMap0 / $100
+	ld [hBGMapAddress + 1], a
+	call ClearTileMap
+	call TradeAnim_IncrementJumptableIndex
+	ret
+
+; 2940c
+
+TradeAnim_ScrollOutRight2: ; 2940c
+	ld a, [hWX]
+	cp $a1
+	jr nc, .done
+	add $4
+	ld [hWX], a
+	ret
+
+.done
+	ld a, VBGMap1 / $100
+	ld [hBGMapAddress + 1], a
+	call WaitBGMap
+	ld a, $7
+	ld [hWX], a
+	ld a, $90
+	ld [hWY], a
+	ld a, VBGMap0 / $100
+	ld [hBGMapAddress + 1], a
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 2942e
+
+TradeAnim_ShowGivemonData: ; 2942e
+	call ShowPlayerTrademonStats
+	ld a, [wPlayerTrademonSpecies]
+	ld [CurPartySpecies], a
+	ld a, [wPlayerTrademonDVs]
+	ld [TempMonDVs], a
+	ld a, [wPlayerTrademonDVs + 1]
+	ld [TempMonDVs + 1], a
+	ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
+	call GetSGBLayout
+	ld a, %11100100 ; 3,2,1,0
+	call DmgToCgbBGPals
+	call TradeAnim_ShowGivemonFrontpic
+
+	ld a, [wPlayerTrademonSpecies]
+	call GetCryIndex
+	jr c, .skip_cry
+	ld e, c
+	ld d, b
+	call PlayCryHeader
+.skip_cry
+
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29461
+
+TradeAnim_ShowGetmonData: ; 29461
+	call ShowOTTrademonStats
+	ld a, [wOTTrademonSpecies]
+	ld [CurPartySpecies], a
+	ld a, [wOTTrademonDVs]
+	ld [TempMonDVs], a
+	ld a, [wOTTrademonDVs + 1]
+	ld [TempMonDVs + 1], a
+	ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
+	call GetSGBLayout
+	ld a, %11100100 ; 3,2,1,0
+	call DmgToCgbBGPals
+	call TradeAnim_ShowGetmonFrontpic
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29487
+
+TradeAnim_AnimateFrontpic: ; 29487
+	callba AnimateTrademonFrontpic
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29491
+
+TradeAnim_GetFrontpic: ; 29491
+	push de
+	push af
+	predef GetUnownLetter
+	pop af
+	ld [CurPartySpecies], a
+	ld [CurSpecies], a
+	call GetBaseData
+	pop de
+	predef GetFrontpic
+	ret
+
+; 294a9
+
+TradeAnim_GetNickname: ; 294a9
+	push de
+	ld [wd265], a
+	call GetPokemonName
+	ld hl, StringBuffer1
+	pop de
+	ld bc, NAME_LENGTH
+	call CopyBytes
+	ret
+
+; 294bb
+
+TradeAnim_ShowGivemonFrontpic: ; 294bb
+	ld de, VTiles0
+	jr TradeAnim_ShowFrontpic
+
+TradeAnim_ShowGetmonFrontpic: ; 294c0
+	ld de, VTiles0 tile $31
+TradeAnim_ShowFrontpic: ; 294c3
+	call DelayFrame
+	ld hl, VTiles2
+	lb bc, 10, $31
+	call Request2bpp
+	call WaitTop
+	call TradeAnim_BlankTileMap
+	hlcoord 7, 2
+	xor a
+	ld [hGraphicStartTile], a
+	lb bc, 7, 7
+	predef PlaceGraphic
+	call WaitBGMap
+	ret
+
+; 294e7
+
+TraideAnim_Wait80: ; 294e7
+	ld c, 80
+	call DelayFrames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 294f0
+
+TraideAnim_Wait40: ; 294f0
+	ld c, 40
+	call DelayFrames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 294f9
+
+TraideAnim_Wait96: ; 294f9
+	ld c, 96
+	call DelayFrames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29502
+
+TraideAnim_Wait80IfOTEgg: ; 29502
+	call IsOTTrademonEgg
+	ret nz
+	ld c, 80
+	call DelayFrames
+	ret
+
+; 2950c
+
+TraideAnim_Wait180IfOTEgg: ; 2950c
+	call IsOTTrademonEgg
+	ret nz
+	ld c, 180
+	call DelayFrames
+	ret
+
+; 29516
+
+IsOTTrademonEgg: ; 29516
+	call TradeAnim_AdvanceScriptPointer
+	ld a, [wOTTrademonSpecies]
+	cp EGG
+	ret
+
+; 2951f
+ShowPlayerTrademonStats: ; 2951f
+	ld de, wPlayerTrademonSpecies
+	ld a, [de]
+	cp EGG
+	jr z, TrademonStats_Egg
+	call TrademonStats_MonTemplate
+	ld de, wPlayerTrademonSpecies
+	call TrademonStats_PrintSpeciesNumber
+	ld de, wPlayerTrademonSpeciesName
+	call TrademonStats_PrintSpeciesName
+	ld a, [wPlayerTrademonCaughtData]
+	ld de, wPlayerTrademonOTName
+	call TrademonStats_PrintOTName
+	ld de, wPlayerTrademonID
+	call TrademonStats_PrintTrademonID
+	call TrademonStats_WaitBGMap
+	ret
+
+; 29549
+
+ShowOTTrademonStats: ; 29549
+	ld de, wOTTrademonSpecies
+	ld a, [de]
+	cp EGG
+	jr z, TrademonStats_Egg
+	call TrademonStats_MonTemplate
+	ld de, wOTTrademonSpecies
+	call TrademonStats_PrintSpeciesNumber
+	ld de, wOTTrademonSpeciesName
+	call TrademonStats_PrintSpeciesName
+	ld a, [wOTTrademonCaughtData]
+	ld de, wOTTrademonOTName
+	call TrademonStats_PrintOTName
+	ld de, wOTTrademonID
+	call TrademonStats_PrintTrademonID
+	call TrademonStats_WaitBGMap
+	ret
+
+; 29573
+
+TrademonStats_MonTemplate: ; 29573
+	call WaitTop
+	call TradeAnim_BlankTileMap
+	ld a, VBGMap1 / $100
+	ld [hBGMapAddress + 1], a
+	hlcoord 3, 0
+	ld b, $6
+	ld c, $d
+	call TextBox
+	hlcoord 4, 0
+	ld de, .OTMonData
+	call PlaceString
+	ret
+
+; 29591
+
+.OTMonData: ; 29591
+	db   "─── №."
+	next ""
+	next "OT/"
+	next "<ID>№.@"
+; 295a1
+
+TrademonStats_Egg: ; 295a1
+	call WaitTop
+	call TradeAnim_BlankTileMap
+	ld a, VBGMap1 / $100
+	ld [hBGMapAddress + 1], a
+	hlcoord 3, 0
+	ld b, 6
+	ld c, 13
+	call TextBox
+	hlcoord 4, 2
+	ld de, .EggData
+	call PlaceString
+	call TrademonStats_WaitBGMap
+	ret
+
+; 295c2
+
+.EggData: ; 295c2
+	db   "EGG"
+	next "OT/?????"
+	next "<ID>№.?????@"
+; 295d8
+
+TrademonStats_WaitBGMap: ; 295d8
+	call WaitBGMap
+	call WaitTop
+	ld a, VBGMap0 / $100
+	ld [hBGMapAddress + 1], a
+	ret
+
+; 295e3
+
+TrademonStats_PrintSpeciesNumber: ; 295e3
+	hlcoord 10, 0
+	lb bc, PRINTNUM_LEADINGZEROS | 1, 3
+	call PrintNum
+	ld [hl], " "
+	ret
+
+; 295ef
+
+TrademonStats_PrintSpeciesName: ; 295ef
+	hlcoord 4, 2
+	call PlaceString
+	ret
+
+; 295f6
+
+TrademonStats_PrintOTName: ; 295f6
+	cp 3
+	jr c, .caught_gender_okay
+	xor a
+.caught_gender_okay
+	push af
+	hlcoord 7, 4
+	call PlaceString
+	inc bc
+	pop af
+	ld hl, .Gender
+	ld d, 0
+	ld e, a
+	add hl, de
+	ld a, [hl]
+	ld [bc], a
+	ret
+
+; 2960e
+
+.Gender: ; 2960e
+	db " ", "♂", "♀"
+; 29611
+
+TrademonStats_PrintTrademonID: ; 29611
+	hlcoord 7, 6
+	lb bc, PRINTNUM_LEADINGZEROS | 2, 5
+	call PrintNum
+	ret
+
+; 2961b
+
+TradeAnim_RockingBall: ; 2961b
+	depixel 10, 11, 4, 0
+	ld a, SPRITE_ANIM_INDEX_TRADE_POKE_BALL
+	call _InitSpriteAnimStruct
+	call TradeAnim_AdvanceScriptPointer
+	ld a, $20
+	ld [wcf64], a
+	ret
+
+; 2962c
+
+TradeAnim_DropBall: ; 2962c
+	depixel 10, 11, 4, 0
+	ld a, SPRITE_ANIM_INDEX_TRADE_POKE_BALL
+	call _InitSpriteAnimStruct
+	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
+	add hl, bc
+	ld [hl], $1
+	ld hl, SPRITEANIMSTRUCT_YOFFSET
+	add hl, bc
+	ld [hl], $dc
+	call TradeAnim_AdvanceScriptPointer
+	ld a, $38
+	ld [wcf64], a
+	ret
+
+; 29649
+
+TradeAnim_Poof: ; 29649
+	depixel 10, 11, 4, 0
+	ld a, SPRITE_ANIM_INDEX_TRADE_POOF
+	call _InitSpriteAnimStruct
+	call TradeAnim_AdvanceScriptPointer
+	ld a, $10
+	ld [wcf64], a
+	ld de, SFX_BALL_POOF
+	call PlaySFX
+	ret
+
+; 29660
+
+TradeAnim_BulgeThroughTube: ; 29660
+	ld a, %11100100 ; 3,2,1,0
+	call DmgToCgbObjPal0
+	depixel 5, 11
+	ld a, SPRITE_ANIM_INDEX_TRADE_TUBE_BULGE
+	call _InitSpriteAnimStruct
+	call TradeAnim_AdvanceScriptPointer
+	ld a, $40
+	ld [wcf64], a
+	ret
+
+; 29676
+
+TradeAnim_AnimateTrademonInTube: ; 29676 (a:5676)
+	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
+	add hl, bc
+	ld e, [hl]
+	ld d, 0
+	ld hl, .Jumptable
+	add hl, de
+	add hl, de
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	jp hl
+; 29686
+
+.Jumptable: ; 29686 (a:5686)
+	dw .InitTimer
+	dw .WaitTimer1
+	dw .MoveRight
+	dw .MoveDown
+	dw .MoveUp
+	dw .MoveLeft
+	dw .WaitTimer2
+; 2969a
+
+.JumptableNext: ; 29694 (a:5694)
+	ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
+	add hl, bc
+	inc [hl]
+	ret
+
+.InitTimer: ; 2969a (a:569a)
+	call .JumptableNext
+	ld hl, SPRITEANIMSTRUCT_0C
+	add hl, bc
+	ld [hl], $80
+	ret
+
+.WaitTimer1: ; 296a4 (a:56a4)
+	ld hl, SPRITEANIMSTRUCT_0C
+	add hl, bc
+	ld a, [hl]
+	dec [hl]
+	and a
+	ret nz
+	call .JumptableNext
+
+.MoveRight: ; 296af (a:56af)
+	ld hl, SPRITEANIMSTRUCT_XCOORD
+	add hl, bc
+	ld a, [hl]
+	cp $94
+	jr nc, .done_move_right
+	inc [hl]
+	ret
+
+.done_move_right
+	call .JumptableNext
+
+.MoveDown: ; 296bd (a:56bd)
+	ld hl, SPRITEANIMSTRUCT_YCOORD
+	add hl, bc
+	ld a, [hl]
+	cp $4c
+	jr nc, .done_move_down
+	inc [hl]
+	ret
+
+.done_move_down
+	ld hl, SPRITEANIMSTRUCT_INDEX
+	add hl, bc
+	ld [hl], $0
+	ret
+
+.MoveUp: ; 296cf (a:56cf)
+	ld hl, SPRITEANIMSTRUCT_YCOORD
+	add hl, bc
+	ld a, [hl]
+	cp $2c
+	jr z, .done_move_up
+	dec [hl]
+	ret
+
+.done_move_up
+	call .JumptableNext
+
+.MoveLeft: ; 296dd (a:56dd)
+	ld hl, SPRITEANIMSTRUCT_XCOORD
+	add hl, bc
+	ld a, [hl]
+	cp $58
+	jr z, .done_move_left
+	dec [hl]
+	ret
+
+.done_move_left
+	call .JumptableNext
+	ld hl, SPRITEANIMSTRUCT_0C
+	add hl, bc
+	ld [hl], $80
+	ret
+
+.WaitTimer2: ; 296f2 (a:56f2)
+	ld hl, SPRITEANIMSTRUCT_0C
+	add hl, bc
+	ld a, [hl]
+	dec [hl]
+	and a
+	ret nz
+	ld hl, SPRITEANIMSTRUCT_INDEX
+	add hl, bc
+	ld [hl], $0
+	ret
+
+; 29701 (a:5701)
+
+TradeAnim_SentToOTText: ; 29701
+	ld a, [wLinkMode]
+	cp LINK_TIMECAPSULE
+	jr z, .time_capsule
+	ld hl, .Text_MonName
+	call PrintText
+	ld c, 189
+	call DelayFrames
+	ld hl, .Text_WasSentTo
+	call PrintText
+	call TradeAnim_Wait80Frames
+	ld c, 128
+	call DelayFrames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+.time_capsule
+	ld hl, .Text_WasSentTo
+	call PrintText
+	call TradeAnim_Wait80Frames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29732
+
+.Text_WasSentTo: ; 0x29732
+	; was sent to @ .
+	text_jump UnknownText_0x1bc6e9
+	db "@"
+; 0x29737
+
+.Text_MonName: ; 0x29737
+	;
+	text_jump UnknownText_0x1bc701
+	db "@"
+; 0x2973c
+
+TradeAnim_OTBidsFarewell: ; 2973c
+	ld hl, .Text_BidsFarewellToMon
+	call PrintText
+	call TradeAnim_Wait80Frames
+	ld hl, .Text_MonName
+	call PrintText
+	call TradeAnim_Wait80Frames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29752
+
+.Text_BidsFarewellToMon: ; 0x29752
+	; bids farewell to
+	text_jump UnknownText_0x1bc703
+	db "@"
+; 0x29757
+
+.Text_MonName: ; 0x29757
+	; .
+	text_jump UnknownText_0x1bc719
+	db "@"
+; 0x2975c
+
+TradeAnim_TakeCareOfText: ; 2975c
+	call WaitTop
+	hlcoord 0, 10
+	ld bc, 8 * SCREEN_WIDTH
+	ld a, " "
+	call ByteFill
+	call WaitBGMap
+	ld hl, .Text_TakeGoodCareOfMon
+	call PrintText
+	call TradeAnim_Wait80Frames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 2977a
+
+.Text_TakeGoodCareOfMon: ; 0x2977a
+	; Take good care of @ .
+	text_jump UnknownText_0x1bc71f
+	db "@"
+; 0x2977f
+
+TradeAnim_OTSendsText1: ; 2977f
+	ld hl, .Text_ForYourMon
+	call PrintText
+	call TradeAnim_Wait80Frames
+	ld hl, .Text_OTSends
+	call PrintText
+	call TradeAnim_Wait80Frames
+	ld c, 14
+	call DelayFrames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 2979a
+
+.Text_ForYourMon: ; 0x2979a
+	; For @ 's @ ,
+	text_jump UnknownText_0x1bc739
+	db "@"
+; 0x2979f
+
+.Text_OTSends: ; 0x2979f
+	; sends @ .
+	text_jump UnknownText_0x1bc74c
+	db "@"
+; 0x297a4
+
+TradeAnim_OTSendsText2: ; 297a4
+	ld hl, .Text_WillTrade
+	call PrintText
+	call TradeAnim_Wait80Frames
+	ld hl, .Text_ForYourMon
+	call PrintText
+	call TradeAnim_Wait80Frames
+	ld c, 14
+	call DelayFrames
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 297bf
+
+.Text_WillTrade: ; 0x297bf
+	; will trade @ @
+	text_jump UnknownText_0x1bc75e
+	db "@"
+; 0x297c4
+
+.Text_ForYourMon: ; 0x297c4
+	; for @ 's @ .
+	text_jump UnknownText_0x1bc774
+	db "@"
+; 0x297c9
+
+TradeAnim_Wait80Frames: ; 297c9
+	ld c, 80
+	call DelayFrames
+	ret
+
+; 297cf
+
+TradeAnim_BlankTileMap: ; 297cf
+	hlcoord 0, 0
+	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+	ld a, " "
+	call ByteFill
+	ret
+
+; 297db
+
+TradeAnim_CopyBoxFromDEtoHL: ; 297db
+.row
+	push bc
+	push hl
+.col
+	ld a, [de]
+	inc de
+	ld [hli], a
+	dec c
+	jr nz, .col
+	pop hl
+	ld bc, SCREEN_WIDTH
+	add hl, bc
+	pop bc
+	dec b
+	jr nz, .row
+	ret
+
+; 297ed
+
+TradeAnim_NormalPals: ; 297ed
+	ld a, [hSGB]
+	and a
+	ld a, %11100100 ; 3,2,1,0
+	jr z, .not_sgb
+	ld a, $f0
+
+.not_sgb
+	call DmgToCgbObjPal0
+	ld a, %11100100 ; 3,2,1,0
+	call DmgToCgbBGPals
+	ret
+
+; 297ff
+
+LinkTradeAnim_LoadTradePlayerNames: ; 297ff
+	push de
+	ld de, wLinkPlayer1Name
+	ld bc, NAME_LENGTH
+	call CopyBytes
+	pop hl
+	ld de, wLinkPlayer2Name
+	ld bc, NAME_LENGTH
+	call CopyBytes
+	ret
+
+; 29814
+
+LinkTradeAnim_LoadTradeMonSpecies: ; 29814
+	ld a, [hl]
+	ld [wLinkTradeSendmonSpecies], a
+	ld a, [de]
+	ld [wLinkTradeGetmonSpecies], a
+	ret
+
+; 2981d
+
+TradeAnim_FlashBGPals: ; 2981d
+	ld a, [wcf65]
+	and $7
+	ret nz
+	ld a, [rBGP]
+	xor %00111100
+	call DmgToCgbBGPals
+	ret
+
+; 2982b
+
+LoadTradeBallAndCableGFX: ; 2982b
+	call DelayFrame
+	ld de, TradeBallGFX
+	ld hl, VTiles0 tile $62
+	lb bc, BANK(TradeBallGFX), $6
+	call Request2bpp
+	ld de, TradePoofGFX
+	ld hl, VTiles0 tile $68
+	lb bc, BANK(TradePoofGFX), $c
+	call Request2bpp
+	ld de, TradeCableGFX
+	ld hl, VTiles0 tile $74
+	lb bc, BANK(TradeCableGFX), $4
+	call Request2bpp
+	xor a
+	ld hl, wSpriteAnimDict
+	ld [hli], a
+	ld [hl], $62
+	ret
+
+; 2985a
+
+LoadTradeBubbleGFX: ; 2985a
+	call DelayFrame
+	ld e, $3
+	callab LoadMenuMonIcon
+	ld de, TradeBubbleGFX
+	ld hl, VTiles0 tile $72
+	lb bc, BANK(TradeBubbleGFX), $4
+	call Request2bpp
+	xor a
+	ld hl, wSpriteAnimDict
+	ld [hli], a
+	ld [hl], $62
+	ret
+
+; 29879
+
+TradeAnim_WaitAnim: ; 29879
+	ld hl, wcf64
+	ld a, [hl]
+	and a
+	jr z, .done
+	dec [hl]
+	ret
+
+.done
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29886
+
+TradeAnim_WaitAnim2: ; 29886
+	ld hl, wcf64
+	ld a, [hl]
+	and a
+	jr z, .done
+	dec [hl]
+	ret
+
+.done
+	call TradeAnim_AdvanceScriptPointer
+	ret
+
+; 29893
+
+
+DebugTrade: ; 29893
+; This function is unreferenced.
+; It was meant for use in Japanese versions, so the
+; constant used for copy length was changed by accident.
+
+	ld hl, .DebugTradeData
+
+	ld a, [hli]
+	ld [wPlayerTrademonSpecies], a
+	ld de, wPlayerTrademonSenderName
+	ld c, 11 + 2 ; jp: 6 + 2
+.loop1
+	ld a, [hli]
+	ld [de], a
+	inc de
+	dec c
+	jr nz, .loop1
+
+	ld a, [hli]
+	ld [wOTTrademonSpecies], a
+	ld de, wOTTrademonSenderName
+	ld c, 11 + 2 ; jp: 6 + 2
+.loop2
+	ld a, [hli]
+	ld [de], a
+	inc de
+	dec c
+	jr nz, .loop2
+	ret
+
+; 298b5
+
+.DebugTradeData: ; 298b5
+	db VENUSAUR, "ゲーフり@@", $23, $01 ; GAME FREAK
+	db CHARIZARD, "クりーチャ@", $56, $04 ; Creatures Inc.
+; 298c7
+
+
+TradeGameBoyTilemap: ; 298c7
+; 6x8
+	db $31, $32, $32, $32, $32, $33
+	db $34, $35, $36, $36, $37, $38
+	db $34, $39, $3a, $3a, $3b, $38
+	db $3c, $3d, $3e, $3e, $3f, $40
+	db $41, $42, $43, $43, $44, $45
+	db $46, $47, $43, $48, $49, $4a
+	db $41, $43, $4b, $4c, $4d, $4e
+	db $4f, $50, $50, $50, $51, $52
+; 297f7
+
+TradeLinkTubeTilemap: ; 297f7
+; 12x3
+	db $43, $55, $56, $53, $53, $53, $53, $53, $53, $53, $53, $53
+	db $43, $57, $58, $54, $54, $54, $54, $54, $54, $54, $54, $54
+	db $43, $59, $5a, $43, $43, $43, $43, $43, $43, $43, $43, $43
+; 2991b
+
+TradeArrowGFX:  INCBIN "gfx/trade/arrow.2bpp"
+TradeCableGFX:  INCBIN "gfx/trade/cable.2bpp"
+TradeBubbleGFX: INCBIN "gfx/trade/bubble.2bpp"
+TradeGameBoyLZ: INCBIN "gfx/trade/game_boy.2bpp.lz"
+TradeBallGFX:   INCBIN "gfx/trade/ball.2bpp"
+TradePoofGFX:   INCBIN "gfx/trade/poof.2bpp"
--- a/macros.asm
+++ b/macros.asm
@@ -22,5 +22,5 @@
 
 percent EQUS "* $ff / 100"
 
-tiles EQUS "* $10"
-tile  EQUS "+ $10 *"
+tiles EQUS "* LEN_2BPP_TILE"
+tile  EQUS "+ LEN_2BPP_TILE *"
--- a/main.asm
+++ b/main.asm
@@ -612,7 +612,7 @@
 INCLUDE "event/mom.asm"
 INCLUDE "event/daycare.asm"
 INCLUDE "event/photo.asm"
-INCLUDE "engine/breeding/egg.asm"
+INCLUDE "engine/breeding.asm"
 
 
 INCLUDE "tilesets/data.asm"
@@ -1771,7 +1771,7 @@
 	db 12, 00 ; start coords
 	db 17, 19 ; end coords
 
-INCLUDE "predef/crystal.asm"
+INCLUDE "engine/crystal_colors.asm"
 
 Unknown_4985a: ; unreferenced
 	db $ab, $03, $57, $24, $ac, $0e, $13, $32
@@ -5073,7 +5073,7 @@
 SECTION "bank3E", ROMX
 
 INCLUDE "gfx/font.asm"
-INCLUDE "engine/time_capsule/conversion.asm"
+INCLUDE "engine/time_capsule.asm"
 INCLUDE "engine/unowndex.asm"
 INCLUDE "event/magikarp.asm"
 INCLUDE "battle/hidden_power.asm"
--- a/predef/cgb.asm
+++ /dev/null
@@ -1,1127 +1,0 @@
-; Replaces the functionality of sgb.asm to work with CGB hardware.
-
-CheckCGB: ; 8d55
-	ld a, [hCGB]
-	and a
-	ret
-; 8d59
-
-Predef_LoadSGBLayoutCGB: ; 8d59
-	ld a, b
-	cp SCGB_RAM
-	jr nz, .not_ram
-	ld a, [SGBPredef]
-.not_ram
-	cp SCGB_PARTY_MENU_HP_PALS
-	jp z, CGB_ApplyPartyMenuHPPals
-	call ResetBGPals
-	ld l, a
-	ld h, 0
-	add hl, hl
-	ld de, .dw
-	add hl, de
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	ld de, .ReturnFromJumpTable
-	push de
-	jp hl
-; 8d79
-
-.ReturnFromJumpTable: ; 8d79
-	ret
-; 8d7a
-
-.dw ; 8d7a
-	dw _CGB_BattleGrayscale
-	dw _CGB_BattleColors
-	dw _CGB_PokegearPals
-	dw _CGB_StatsScreenHPPals
-	dw _CGB_Pokedex
-	dw _CGB_SlotMachine
-	dw _CGB06
-	dw _CGB07
-	dw _CGB_Diploma
-	dw _CGB_MapPals
-	dw _CGB_PartyMenu
-	dw _CGB_Evolution
-	dw _CGB0c
-	dw _CGB0d
-	dw _CGB_MoveList
-	dw _CGB0f
-	dw _CGB_PokedexSearchOption
-	dw _CGB11
-	dw _CGB_Pokepic
-	dw _CGB13
-	dw _CGB_PackPals
-	dw _CGB_TrainerCard
-	dw _CGB_PokedexUnownMode
-	dw _CGB_BillsPC
-	dw _CGB_UnownPuzzle
-	dw _CGB_GamefreakLogo ; called before copyright
-	dw _CGB_PlayerOrMonFrontpicPals
-	dw _CGB_TradeTube
-	dw _CGB_TrainerOrMonFrontpicPals
-	dw _CGB_MysteryGift
-	dw _CGB1e
-; 8db8
-
-_CGB_BattleGrayscale: ; 8db8
-	ld hl, PalPacket_9c66 + 1
-	ld de, UnknBGPals
-	ld c, 4
-	call CopyPalettes
-	ld hl, PalPacket_9c66 + 1
-	ld de, UnknBGPals palette PAL_BATTLE_BG_EXP
-	ld c, 4
-	call CopyPalettes
-	ld hl, PalPacket_9c66 + 1
-	ld de, UnknOBPals
-	ld c, 2
-	call CopyPalettes
-	jr _CGB_FinishBattleScreenLayout
-
-_CGB_BattleColors: ; 8ddb
-	ld de, UnknBGPals
-	call GetBattlemonBackpicPalettePointer
-	push hl
-	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_PLAYER
-	call GetEnemyFrontpicPalettePointer
-	push hl
-	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_ENEMY
-	ld a, [EnemyHPPal]
-	ld l, a
-	ld h, $0
-	add hl, hl
-	add hl, hl
-	ld bc, Palettes_a8be
-	add hl, bc
-	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_ENEMY_HP
-	ld a, [PlayerHPPal]
-	ld l, a
-	ld h, $0
-	add hl, hl
-	add hl, hl
-	ld bc, Palettes_a8be
-	add hl, bc
-	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_PLAYER_HP
-	ld hl, Palettes_a8ca
-	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_BG_EXP
-	ld de, UnknOBPals
-	pop hl
-	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_OB_ENEMY
-	pop hl
-	call LoadPalette_White_Col1_Col2_Black ; PAL_BATTLE_OB_PLAYER
-	ld a, SCGB_BATTLE_COLORS
-	ld [SGBPredef], a
-	call ApplyPals
-_CGB_FinishBattleScreenLayout: ; 8e23
-	call InitPartyMenuBGPal7
-	hlcoord 0, 0, AttrMap
-	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
-	ld a, PAL_BATTLE_BG_ENEMY_HP
-	call ByteFill
-	hlcoord 0, 4, AttrMap
-	lb bc, 8, 10
-	ld a, PAL_BATTLE_BG_PLAYER
-	call FillBoxCGB
-	hlcoord 10, 0, AttrMap
-	lb bc, 7, 10
-	ld a, PAL_BATTLE_BG_ENEMY
-	call FillBoxCGB
-	hlcoord 0, 0, AttrMap
-	lb bc, 4, 10
-	ld a, PAL_BATTLE_BG_ENEMY_HP
-	call FillBoxCGB
-	hlcoord 10, 7, AttrMap
-	lb bc, 5, 10
-	ld a, PAL_BATTLE_BG_PLAYER_HP
-	call FillBoxCGB
-	hlcoord 10, 11, AttrMap
-	lb bc, 1, 9
-	ld a, PAL_BATTLE_BG_EXP
-	call FillBoxCGB
-	hlcoord 0, 12, AttrMap
-	ld bc, 6 * SCREEN_WIDTH
-	ld a, PAL_BATTLE_BG_TEXT
-	call ByteFill
-	ld hl, Palettes_979c
-	ld de, UnknOBPals palette PAL_BATTLE_OB_GRAY
-	ld bc, 6 palettes
-	ld a, $5
-	call FarCopyWRAM
-	call ApplyAttrMap
-	ret
-; 8e85
-
-
-InitPartyMenuBGPal7: ; 8e85
-	callba Function100dc0
-Mobile_InitPartyMenuBGPal7: ; 8e8b
-	ld hl, Palette_b311
-	jr nc, .not_mobile
-	ld hl, Palette_b309
-.not_mobile
-	ld de, UnknBGPals palette 7
-	ld bc, 1 palettes
-	ld a, $5
-	call FarCopyWRAM
-	ret
-; 8e9f
-
-InitPartyMenuBGPal0: ; 8e9f
-	callba Function100dc0
-	ld hl, Palette_b311
-	jr nc, .not_mobile
-	ld hl, Palette_b309
-.not_mobile
-	ld de, UnknBGPals palette 0
-	ld bc, 1 palettes
-	ld a, $5
-	call FarCopyWRAM
-	ret
-; 8eb9
-
-_CGB_PokegearPals: ; 8eb9
-	ld a, [PlayerGender]
-	bit 0, a
-	jr z, .male
-	ld hl, FemalePokegearPals
-	jr .got_pals
-
-.male
-	ld hl, MalePokegearPals
-.got_pals
-	ld de, UnknBGPals
-	ld bc, 6 palettes
-	ld a, $5
-	call FarCopyWRAM
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 8edb
-
-_CGB_StatsScreenHPPals: ; 8edb
-	ld de, UnknBGPals
-	ld a, [wCurHPPal]
-	ld l, a
-	ld h, $0
-	add hl, hl
-	add hl, hl
-	ld bc, Palettes_a8be
-	add hl, bc
-	call LoadPalette_White_Col1_Col2_Black ; hp palette
-	ld a, [CurPartySpecies]
-	ld bc, TempMonDVs
-	call GetPlayerOrMonPalettePointer
-	call LoadPalette_White_Col1_Col2_Black ; mon palette
-	ld hl, Palettes_a8ca
-	call LoadPalette_White_Col1_Col2_Black ; exp palette
-	ld hl, StatsScreenPagePals
-	ld de, UnknBGPals palette 3
-	ld bc, 3 palettes ; pink, green, and blue page palettes
-	ld a, $5
-	call FarCopyWRAM
-	call WipeAttrMap
-
-	hlcoord 0, 0, AttrMap
-	lb bc, 8, SCREEN_WIDTH
-	ld a, $1 ; mon palette
-	call FillBoxCGB
-
-	hlcoord 10, 16, AttrMap
-	ld bc, 10
-	ld a, $2 ; exp palette
-	call ByteFill
-
-	hlcoord 13, 5, AttrMap
-	lb bc, 2, 2
-	ld a, $3 ; pink page palette
-	call FillBoxCGB
-
-	hlcoord 15, 5, AttrMap
-	lb bc, 2, 2
-	ld a, $4 ; green page palette
-	call FillBoxCGB
-
-	hlcoord 17, 5, AttrMap
-	lb bc, 2, 2
-	ld a, $5 ; blue page palette
-	call FillBoxCGB
-
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 8f52
-
-StatsScreenPagePals: ; 8f52
-; pink
-	RGB 31, 31, 31
-	RGB 31, 19, 31
-	RGB 31, 15, 31
-	RGB 00, 00, 00
-; green
-	RGB 31, 31, 31
-	RGB 21, 31, 14
-	RGB 17, 31, 00
-	RGB 00, 00, 00
-; blue
-	RGB 31, 31, 31
-	RGB 17, 31, 31
-	RGB 17, 31, 31
-	RGB 00, 00, 00
-; 8f6a
-
-StatsScreenPals: ; 8f6a
-; pink
-	RGB 31, 19, 31
-; green
-	RGB 21, 31, 14
-; blue
-	RGB 17, 31, 31
-; 8f70
-
-_CGB_Pokedex: ; 8f70
-	ld de, UnknBGPals
-	ld a, $1d
-	call GetPredefPal
-	call LoadHLPaletteIntoDE ; dex interface palette
-	ld a, [CurPartySpecies]
-	cp $ff
-	jr nz, .is_pokemon
-	ld hl, .PokedexQuestionMarkPalette
-	call LoadHLPaletteIntoDE ; green question mark palette
-	jr .got_palette
-
-.is_pokemon
-	call GetMonPalettePointer_
-	call LoadPalette_White_Col1_Col2_Black ; mon palette
-.got_palette
-	call WipeAttrMap
-	hlcoord 1, 1, AttrMap
-	lb bc, 7, 7
-	ld a, $1 ; green question mark palette
-	call FillBoxCGB
-	call InitPartyMenuOBPals
-	ld hl, .PokedexCursorPalette
-	ld de, UnknOBPals palette 7 ; green cursor palette
-	ld bc, 1 palettes
-	ld a, $5
-	call FarCopyWRAM
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 8fba
-
-.PokedexQuestionMarkPalette: ; 8fba
-	RGB 11, 23, 00
-	RGB 07, 17, 00
-	RGB 06, 16, 03
-	RGB 05, 12, 01
-
-.PokedexCursorPalette: ; 8fc2
-	RGB 00, 00, 00
-	RGB 11, 23, 00
-	RGB 07, 17, 00
-	RGB 00, 00, 00
-; 8fca
-
-_CGB_BillsPC: ; 8fca
-	ld de, UnknBGPals
-	ld a, $1d
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	ld a, [CurPartySpecies]
-	cp $ff
-	jr nz, .GetMonPalette
-	ld hl, .BillsPCOrangePalette
-	call LoadHLPaletteIntoDE
-	jr .Resume
-
-.GetMonPalette:
-	ld bc, TempMonDVs
-	call GetPlayerOrMonPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-.Resume:
-	call WipeAttrMap
-	hlcoord 1, 4, AttrMap
-	lb bc, 7, 7
-	ld a, $1
-	call FillBoxCGB
-	call InitPartyMenuOBPals
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 9009
-
-.Function9009: ; 9009
-	ld hl, .BillsPCOrangePalette
-	call LoadHLPaletteIntoDE
-	jr .asm_901a
-
-.unused
-	ld bc, TempMonDVs
-	call GetPlayerOrMonPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-.asm_901a
-	call WipeAttrMap
-	hlcoord 1, 1, AttrMap
-	lb bc, 7, 7
-	ld a, $1
-	call FillBoxCGB
-	call InitPartyMenuOBPals
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 9036
-
-.BillsPCOrangePalette: ; 9036
-	RGB 31, 15, 00
-	RGB 23, 12, 00
-	RGB 15, 07, 00
-	RGB 00, 00, 00
-; 903e
-
-_CGB_PokedexUnownMode: ; 903e
-	ld de, UnknBGPals
-	ld a, $1d
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	ld a, [CurPartySpecies]
-	call GetMonPalettePointer_
-	call LoadPalette_White_Col1_Col2_Black
-	call WipeAttrMap
-	hlcoord 7, 5, AttrMap
-	lb bc, 7, 7
-	ld a, $1
-	call FillBoxCGB
-	call InitPartyMenuOBPals
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 906e
-
-_CGB_SlotMachine: ; 906e
-	ld hl, SlotMachinePals
-	ld de, UnknBGPals
-	ld bc, 16 palettes
-	ld a, $5
-	call FarCopyWRAM
-	call WipeAttrMap
-	hlcoord 0, 2, AttrMap
-	lb bc, 10, 3
-	ld a, $2
-	call FillBoxCGB
-	hlcoord 17, 2, AttrMap
-	lb bc, 10, 3
-	ld a, $2
-	call FillBoxCGB
-	hlcoord 0, 4, AttrMap
-	lb bc, 6, 3
-	ld a, $3
-	call FillBoxCGB
-	hlcoord 17, 4, AttrMap
-	lb bc, 6, 3
-	ld a, $3
-	call FillBoxCGB
-	hlcoord 0, 6, AttrMap
-	lb bc, 2, 3
-	ld a, $4
-	call FillBoxCGB
-	hlcoord 17, 6, AttrMap
-	lb bc, 2, 3
-	ld a, $4
-	call FillBoxCGB
-	hlcoord 4, 2, AttrMap
-	lb bc, 2, 12
-	ld a, $1
-	call FillBoxCGB
-	hlcoord 3, 2, AttrMap
-	lb bc, 10, 1
-	ld a, $1
-	call FillBoxCGB
-	hlcoord 16, 2, AttrMap
-	lb bc, 10, 1
-	ld a, $1
-	call FillBoxCGB
-	hlcoord 0, 12, AttrMap
-	ld bc, $78
-	ld a, $7
-	call ByteFill
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 90f8
-
-_CGB06: ; 90f8
-	ld hl, PalPacket_9ca6 + 1
-	call CopyFourPalettes
-	call WipeAttrMap
-	ld de, UnknOBPals
-	ld a, $3c
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	hlcoord 0, 6, AttrMap
-	lb bc, 12, SCREEN_WIDTH
-	ld a, $1
-	call FillBoxCGB
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 9122
-
-_CGB07: ; 9122
-	ld b, 0
-	ld hl, .Jumptable
-	add hl, bc
-	add hl, bc
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	jp hl
-; 912d
-
-.Jumptable: ; 912d
-	dw .Function9133
-	dw .Function9166
-	dw .Function9180
-; 9133
-
-.Function9133: ; 9133
-	ld hl, .Palette_914e
-	ld de, UnknBGPals
-	call LoadHLPaletteIntoDE
-	ld hl, .Palette_9156
-	ld de, UnknOBPals
-	ld bc, 2 palettes
-	ld a, $5
-	call FarCopyWRAM
-	call WipeAttrMap
-	ret
-; 914e
-
-.Palette_914e: ; 914e
-	RGB 19, 31, 19
-	RGB 18, 23, 31
-	RGB 11, 21, 28
-	RGB 04, 16, 24
-
-.Palette_9156: ; 9156
-	RGB 29, 29, 29
-	RGB 20, 19, 20
-	RGB 19, 06, 04
-	RGB 03, 04, 06
-
-	RGB 31, 31, 31
-	RGB 31, 31, 31
-	RGB 31, 00, 00
-	RGB 03, 04, 06
-; 9166
-
-.Function9166: ; 9166
-	ld de, UnknBGPals
-	ld a, $38
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-
-	ld de, UnknOBPals
-	ld a, $39
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	call WipeAttrMap
-	ret
-; 9180
-
-.Function9180: ; 9180
-	ld hl, PalPacket_9c36 + 1
-	call CopyFourPalettes
-	ld de, UnknOBPals
-	ld a, $3a
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	call WipeAttrMap
-	ret
-; 9195
-
-_CGB11: ; 9195
-	ld hl, Palettes_b789
-	ld de, UnknBGPals
-	ld bc, 5 palettes
-	ld a, $5
-	call FarCopyWRAM
-	call ApplyPals
-	call WipeAttrMap
-	call ApplyAttrMap
-	ret
-; 91ad
-
-_CGB_Diploma: ; 91ad
-	ld hl, DiplomaPalettes
-	ld de, UnknBGPals
-	ld bc, 16 palettes
-	ld a, $5
-	call FarCopyWRAM
-
-	ld hl, PalPacket_9cb6 + 1
-	call CopyFourPalettes
-	call WipeAttrMap
-	call ApplyAttrMap
-	ret
-; 91c8
-
-_CGB_MapPals: ; 91c8
-	call LoadMapPals
-	ld a, SCGB_MAPPALS
-	ld [SGBPredef], a
-	ret
-; 91d1
-
-_CGB_PartyMenu: ; 91d1
-	ld hl, PalPacket_9c56 + 1
-	call CopyFourPalettes
-	call InitPartyMenuBGPal0
-	call InitPartyMenuBGPal7
-	call InitPartyMenuOBPals
-	call ApplyAttrMap
-	ret
-; 91e4
-
-_CGB_Evolution: ; 91e4
-	ld de, UnknBGPals
-	ld a, c
-	and a
-	jr z, .pokemon
-	ld a, $1a
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	jr .got_palette
-
-.pokemon
-	ld hl, PartyMon1DVs
-	ld bc, PARTYMON_STRUCT_LENGTH
-	ld a, [CurPartyMon]
-	call AddNTimes
-	ld c, l
-	ld b, h
-	ld a, [PlayerHPPal]
-	call GetPlayerOrMonPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld hl, Palettes_979c
-	ld de, UnknOBPals palette 2
-	ld bc, 6 palettes
-	ld a, $5
-	call FarCopyWRAM
-
-.got_palette
-	call WipeAttrMap
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 9228
-
-_CGB0c: ; 9228
-	ld hl, Palettes_b6f1
-	ld de, UnknBGPals
-	ld bc, 5 palettes
-	ld a, $5
-	call FarCopyWRAM
-	ld hl, Palettes_b719
-	ld de, UnknOBPals
-	ld bc, 2 palettes
-	ld a, $5
-	call FarCopyWRAM
-	ld a, SCGB_DIPLOMA
-	ld [SGBPredef], a
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 9251
-
-_CGB0d: ; 9251
-	ld hl, PalPacket_9cb6 + 1
-	call CopyFourPalettes
-	call WipeAttrMap
-	call ApplyAttrMap
-	ret
-; 925e
-
-_CGB_UnownPuzzle: ; 925e
-	ld hl, PalPacket_9bc6 + 1
-	call CopyFourPalettes
-	ld de, UnknOBPals
-	ld a, $4c
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	ld a, [rSVBK]
-	push af
-	ld a, $5
-	ld [rSVBK], a
-	ld hl, UnknOBPals
-	ld a, $1f
-	ld [hli], a
-	ld a, $0
-	ld [hl], a
-	pop af
-	ld [rSVBK], a
-	call WipeAttrMap
-	call ApplyAttrMap
-	ret
-; 9289
-
-_CGB_TrainerCard: ; 9289
-	ld de, UnknBGPals
-	xor a ; CHRIS
-	call GetTrainerPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld a, FALKNER ; KRIS
-	call GetTrainerPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld a, BUGSY
-	call GetTrainerPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld a, WHITNEY
-	call GetTrainerPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld a, MORTY
-	call GetTrainerPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld a, CHUCK
-	call GetTrainerPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld a, JASMINE
-	call GetTrainerPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld a, PRYCE
-	call GetTrainerPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	ld a, $24
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-
-	; fill screen with opposite-gender palette for the card border
-	hlcoord 0, 0, AttrMap
-	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
-	ld a, [PlayerGender]
-	and a
-	ld a, $1 ; kris
-	jr z, .got_gender
-	ld a, $0 ; chris
-.got_gender
-	call ByteFill
-	; fill trainer sprite area with same-gender palette
-	hlcoord 14, 1, AttrMap
-	lb bc, 7, 5
-	ld a, [PlayerGender]
-	and a
-	ld a, $0 ; chris
-	jr z, .got_gender2
-	ld a, $1 ; kris
-.got_gender2
-	call FillBoxCGB
-	; top-right corner still uses the border's palette
-	hlcoord 18, 1, AttrMap
-	ld [hl], $1
-	hlcoord 2, 11, AttrMap
-	lb bc, 2, 4
-	ld a, $1 ; falkner
-	call FillBoxCGB
-	hlcoord 6, 11, AttrMap
-	lb bc, 2, 4
-	ld a, $2 ; bugsy
-	call FillBoxCGB
-	hlcoord 10, 11, AttrMap
-	lb bc, 2, 4
-	ld a, $3 ; whitney
-	call FillBoxCGB
-	hlcoord 14, 11, AttrMap
-	lb bc, 2, 4
-	ld a, $4 ; morty
-	call FillBoxCGB
-	hlcoord 2, 14, AttrMap
-	lb bc, 2, 4
-	ld a, $5 ; chuck
-	call FillBoxCGB
-	hlcoord 6, 14, AttrMap
-	lb bc, 2, 4
-	ld a, $6 ; jasmine
-	call FillBoxCGB
-	hlcoord 10, 14, AttrMap
-	lb bc, 2, 4
-	ld a, $7 ; pryce
-	call FillBoxCGB
-	; clair uses kris's palette
-	ld a, [PlayerGender]
-	and a
-	push af
-	jr z, .got_gender3
-	hlcoord 14, 14, AttrMap
-	lb bc, 2, 4
-	ld a, $1
-	call FillBoxCGB
-.got_gender3
-	pop af
-	ld c, $0
-	jr nz, .got_gender4
-	inc c
-.got_gender4
-	ld a, c
-	hlcoord 18, 1, AttrMap
-	ld [hl], a
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 9373
-
-_CGB_MoveList: ; 9373
-	ld de, UnknBGPals
-	ld a, $10
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	ld a, [PlayerHPPal]
-	ld l, a
-	ld h, 0
-	add hl, hl
-	add hl, hl
-	ld bc, Palettes_a8be
-	add hl, bc
-	call LoadPalette_White_Col1_Col2_Black
-	call WipeAttrMap
-	hlcoord 11, 1, AttrMap
-	lb bc, 2, 9
-	ld a, $1
-	call FillBoxCGB
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 93a6
-
-_CGB0f: ; 93a6
-	ld hl, PalPacket_9c46 + 1
-	call CopyFourPalettes
-	call WipeAttrMap
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 93ba
-
-_CGB_PokedexSearchOption: ; 93ba
-	ld de, UnknBGPals
-	ld a, $1d
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	call WipeAttrMap
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 93d3
-
-_CGB_PackPals: ; 93d3
-; pack pals
-	ld a, [BattleType]
-	cp BATTLETYPE_TUTORIAL
-	jr z, .tutorial_male
-
-	ld a, [PlayerGender]
-	bit 0, a
-	jr z, .tutorial_male
-
-	ld hl, .KrisPackPals
-	jr .got_gender
-
-.tutorial_male
-	ld hl, .ChrisPackPals
-
-.got_gender
-	ld de, UnknBGPals
-	ld bc, 8 palettes ; 6 palettes?
-	ld a, $5
-	call FarCopyWRAM
-	call WipeAttrMap
-	hlcoord 0, 0, AttrMap
-	lb bc, 1, 10
-	ld a, $1
-	call FillBoxCGB
-	hlcoord 10, 0, AttrMap
-	lb bc, 1, 10
-	ld a, $2
-	call FillBoxCGB
-	hlcoord 7, 2, AttrMap
-	lb bc, 9, 1
-	ld a, $3
-	call FillBoxCGB
-	hlcoord 0, 7, AttrMap
-	lb bc, 3, 5
-	ld a, $4
-	call FillBoxCGB
-	hlcoord 0, 3, AttrMap
-	lb bc, 3, 5
-	ld a, $5
-	call FillBoxCGB
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 9439
-
-.ChrisPackPals: ; 9439
-	RGB 31, 31, 31
-	RGB 15, 15, 31
-	RGB 00, 00, 31
-	RGB 00, 00, 00
-
-	RGB 31, 31, 31
-	RGB 15, 15, 31
-	RGB 00, 00, 31
-	RGB 00, 00, 00
-
-	RGB 31, 11, 31
-	RGB 15, 15, 31
-	RGB 00, 00, 31
-	RGB 00, 00, 00
-
-	RGB 31, 31, 31
-	RGB 15, 15, 31
-	RGB 00, 00, 31
-	RGB 31, 00, 00
-
-	RGB 31, 31, 31
-	RGB 15, 15, 31
-	RGB 31, 00, 00
-	RGB 00, 00, 00
-
-	RGB 31, 31, 31
-	RGB 07, 19, 07
-	RGB 07, 19, 07
-	RGB 00, 00, 00
-; 9469
-
-.KrisPackPals: ; 9469
-	RGB 31, 31, 31
-	RGB 31, 14, 31
-	RGB 31, 07, 31
-	RGB 00, 00, 00
-
-	RGB 31, 31, 31
-	RGB 31, 14, 31
-	RGB 31, 07, 31
-	RGB 00, 00, 00
-
-	RGB 15, 15, 31
-	RGB 31, 14, 31
-	RGB 31, 07, 31
-	RGB 00, 00, 00
-
-	RGB 31, 31, 31
-	RGB 31, 14, 31
-	RGB 31, 07, 31
-	RGB 31, 00, 00
-
-	RGB 31, 31, 31
-	RGB 31, 14, 31
-	RGB 31, 00, 00
-	RGB 00, 00, 00
-
-	RGB 31, 31, 31
-	RGB 07, 19, 07
-	RGB 07, 19, 07
-	RGB 00, 00, 00
-; 9499
-
-_CGB_Pokepic: ; 9499
-	call _CGB_MapPals
-	ld de, SCREEN_WIDTH
-	hlcoord 0, 0, AttrMap
-	ld a, [wMenuBorderTopCoord]
-.loop
-	and a
-	jr z, .found_top
-	dec a
-	add hl, de
-	jr .loop
-
-.found_top
-	ld a, [wMenuBorderLeftCoord]
-	ld e, a
-	ld d, $0
-	add hl, de
-	ld a, [wMenuBorderTopCoord]
-	ld b, a
-	ld a, [wMenuBorderBottomCoord]
-	inc a
-	sub b
-	ld b, a
-	ld a, [wMenuBorderLeftCoord]
-	ld c, a
-	ld a, [wMenuBorderRightCoord]
-	sub c
-	inc a
-	ld c, a
-	ld a, $0
-	call FillBoxCGB
-	call ApplyAttrMap
-	ret
-; 94d0
-
-_CGB13: ; 94d0
-	ld hl, PalPacket_9ba6 + 1
-	call CopyFourPalettes
-	call WipeAttrMap
-	hlcoord 0, 4, AttrMap
-	lb bc, 10, SCREEN_WIDTH
-	ld a, $2
-	call FillBoxCGB
-	hlcoord 0, 6, AttrMap
-	lb bc, 6, SCREEN_WIDTH
-	ld a, $1
-	call FillBoxCGB
-	call ApplyAttrMap
-	call ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 94fa
-
-_CGB_GamefreakLogo: ; 94fa
-	ld de, UnknBGPals
-	ld a, $4e
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	ld hl, .Palette
-	ld de, UnknOBPals
-	call LoadHLPaletteIntoDE
-	ld hl, .Palette
-	ld de, UnknOBPals palette 1
-	call LoadHLPaletteIntoDE
-	call WipeAttrMap
-	call ApplyAttrMap
-	call ApplyPals
-	ret
-; 9521
-
-.Palette: ; 9521
-	RGB 31, 31, 31
-	RGB 13, 11, 00
-	RGB 23, 12, 28
-	RGB 00, 00, 00
-; 9529
-
-_CGB_PlayerOrMonFrontpicPals: ; 9529
-	ld de, UnknBGPals
-	ld a, [CurPartySpecies]
-	ld bc, TempMonDVs
-	call GetPlayerOrMonPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	call WipeAttrMap
-	call ApplyAttrMap
-	call ApplyPals
-	ret
-; 9542
-
-_CGB1e: ; 9542
-	ld de, UnknBGPals
-	ld a, [CurPartySpecies]
-	call GetMonPalettePointer_
-	call LoadPalette_White_Col1_Col2_Black
-	call WipeAttrMap
-	call ApplyAttrMap
-	ret
-; 9555
-
-_CGB_TradeTube: ; 9555
-	ld hl, PalPacket_9cc6 + 1
-	call CopyFourPalettes
-	ld hl, Palettes_b681
-	ld de, UnknOBPals
-	ld bc, 1 palettes
-	ld a, $5
-	call FarCopyWRAM
-	ld de, UnknOBPals palette 7
-	ld a, $1c
-	call GetPredefPal
-	call LoadHLPaletteIntoDE
-	call WipeAttrMap
-	ret
-; 9578
-
-_CGB_TrainerOrMonFrontpicPals: ; 9578
-	ld de, UnknBGPals
-	ld a, [CurPartySpecies]
-	ld bc, TempMonDVs
-	call GetFrontpicPalettePointer
-	call LoadPalette_White_Col1_Col2_Black
-	call WipeAttrMap
-	call ApplyAttrMap
-	call ApplyPals
-	ret
-; 9591
-
-_CGB_MysteryGift: ; 9591
-	ld hl, .Palettes
-	ld de, UnknBGPals
-	ld bc, 2 palettes
-	ld a, $5
-	call FarCopyWRAM
-	call ApplyPals
-	call WipeAttrMap
-	hlcoord 3, 7, AttrMap
-	lb bc, 8, 14
-	ld a, $1
-	call FillBoxCGB
-	hlcoord 1, 5, AttrMap
-	lb bc, 1, 18
-	ld a, $1
-	call FillBoxCGB
-	hlcoord 1, 16, AttrMap
-	lb bc, 1, 18
-	ld a, $1
-	call FillBoxCGB
-	hlcoord 0, 0, AttrMap
-	lb bc, 17, 2
-	ld a, $1
-	call FillBoxCGB
-	hlcoord 18, 5, AttrMap
-	lb bc, 12, 1
-	ld a, $1
-	call FillBoxCGB
-	call ApplyAttrMap
-	ret
-; 95e0
-
-.Palettes: ; 95e0
-	RGB 31, 31, 31
-	RGB 16, 31, 14
-	RGB 05, 14, 21
-	RGB 05, 13, 10
-
-	RGB 31, 31, 31
-	RGB 11, 21, 25
-	RGB 05, 14, 21
-	RGB 00, 03, 19
-; 95f0
--- a/predef/crystal.asm
+++ /dev/null
@@ -1,614 +1,0 @@
-GetMysteryGift_MobileAdapterLayout: ; 4930f (mobile)
-	ld a, b
-	cp SCGB_RAM
-	jr nz, .not_ram
-	ld a, [SGBPredef]
-.not_ram
-	push af
-	callba ResetBGPals
-	pop af
-	ld l, a
-	ld h, 0
-	add hl, hl
-	ld de, .dw
-	add hl, de
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	ld de, .done
-	push de
-	jp hl
-.done
-	ret
-; 49330 (12:5330)
-
-.dw ; 49330
-
-	dw MG_Mobile_Layout00
-	dw MG_Mobile_Layout01
-	dw MG_Mobile_Layout02
-; 49336
-
-MG_Mobile_Layout_FillBox: ; 49336
-.row
-	push bc
-	push hl
-.col
-	ld [hli], a
-	dec c
-	jr nz, .col
-	pop hl
-	ld bc, SCREEN_WIDTH
-	add hl, bc
-	pop bc
-	dec b
-	jr nz, .row
-	ret
-; 49346
-
-MG_Mobile_Layout_WipeAttrMap: ; 49346 (12:5346)
-	hlcoord 0, 0, AttrMap
-	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
-	xor a
-	call ByteFill
-	ret
-
-MG_Mobile_Layout_LoadPals: ; 49351 (12:5351)
-	ld de, UnknBGPals
-	ld hl, Palette_493e1
-	ld bc, 5 palettes
-	ld a, $5 ; BANK(UnknBGPals)
-	call FarCopyWRAM
-	ld de, UnknBGPals + 7 palettes
-	ld hl, Palette_TextBG7
-	ld bc, 1 palettes
-	ld a, $5 ; BANK(UnknBGPals)
-	call FarCopyWRAM
-	ret
-
-MG_Mobile_Layout00: ; 4936e (12:536e)
-	call MG_Mobile_Layout_LoadPals
-	call MG_Mobile_Layout_WipeAttrMap
-	call MG_Mobile_Layout_CreatePalBoxes
-	callba ApplyAttrMap
-	callba ApplyPals
-	ret
-
-MG_Mobile_Layout_CreatePalBoxes: ; 49384 (12:5384)
-	hlcoord 0, 0, AttrMap
-	lb bc, 4, 1
-	ld a, $1
-	call MG_Mobile_Layout_FillBox
-	lb bc, 2, 1
-	ld a, $2
-	call MG_Mobile_Layout_FillBox
-	lb bc, 6, 1
-	ld a, $3
-	call MG_Mobile_Layout_FillBox
-	hlcoord 1, 0, AttrMap
-	ld a, $1
-	lb bc, 3, 18
-	call MG_Mobile_Layout_FillBox
-	lb bc, 2, 18
-	ld a, $2
-	call MG_Mobile_Layout_FillBox
-	lb bc, 12, 18
-	ld a, $3
-	call MG_Mobile_Layout_FillBox
-	hlcoord 19, 0, AttrMap
-	lb bc, 4, 1
-	ld a, $1
-	call MG_Mobile_Layout_FillBox
-	lb bc, 2, 1
-	ld a, $2
-	call MG_Mobile_Layout_FillBox
-	lb bc, 6, 1
-	ld a, $3
-	call MG_Mobile_Layout_FillBox
-	hlcoord 0, 12, AttrMap
-	ld bc, 6 * SCREEN_WIDTH
-	ld a, $7
-	call ByteFill
-	ret
-; 493e1 (12:53e1)
-
-Palette_493e1: ; 493e1
-	RGB 03, 07, 09
-	RGB 26, 31, 00
-	RGB 20, 16, 03
-	RGB 31, 31, 31
-
-	RGB 13, 24, 29
-	RGB 11, 16, 30
-	RGB 07, 11, 22
-	RGB 05, 06, 18
-
-	RGB 31, 31, 31
-	RGB 20, 26, 31
-	RGB 13, 24, 29
-	RGB 11, 16, 30
-
-	RGB 31, 31, 31
-	RGB 20, 26, 31
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-
-	RGB 31, 31, 31
-	RGB 20, 16, 08
-	RGB 31, 00, 00
-	RGB 00, 00, 00
-; 49409
-
-LoadOW_BGPal7:: ; 49409
-	ld hl, Palette_TextBG7
-	ld de, UnknBGPals + 8 * 7
-	ld bc, 8
-	ld a, $5
-	call FarCopyWRAM
-	ret
-; 49418
-
-Palette_TextBG7: ; 49418
-	RGB 31, 31, 31
-	RGB 08, 19, 28
-	RGB 05, 05, 16
-	RGB 00, 00, 00
-; 49420
-
-Function49420:: ; 49420 (12:5420)
-	ld hl, MansionPalette4
-	ld de, UnknBGPals + $30
-	ld bc, $8
-	ld a, $5 ; BANK(UnknBGPals)
-	call FarCopyWRAM
-	ret
-; 4942f (12:542f)
-
-MG_Mobile_Layout01: ; 4942f
-	call MG_Mobile_Layout_LoadPals
-	ld de, UnknBGPals + $38
-	ld hl, Palette_49478
-	ld bc, $8
-	ld a, $5 ; BANK(UnknBGPals)
-	call FarCopyWRAM
-	call MG_Mobile_Layout_WipeAttrMap
-	hlcoord 0, 0, AttrMap
-	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
-	xor a
-	call ByteFill
-	hlcoord 0, 14, AttrMap
-	ld bc, 4 * SCREEN_WIDTH
-	ld a, $7
-	call ByteFill
-	ld a, [wd002]
-	bit 6, a
-	jr z, .asm_49464
-	call Function49480
-	jr .asm_49467
-
-.asm_49464
-	call Function49496
-
-.asm_49467
-	callba ApplyAttrMap
-	callba ApplyPals
-	ld a, $1
-	ld [hCGBPalUpdate], a
-	ret
-; 49478
-
-Palette_49478: ; 49478
-	RGB 31, 31, 31
-	RGB 26, 31, 00
-	RGB 20, 16, 03
-	RGB 00, 00, 00
-; 49480
-
-Function49480: ; 49480
-	hlcoord 0, 0, AttrMap
-	lb bc, 4, SCREEN_WIDTH
-	ld a, $7
-	call MG_Mobile_Layout_FillBox
-	hlcoord 0, 2, AttrMap
-	ld a, $4
-	ld [hl], a
-	hlcoord 19, 2, AttrMap
-	ld [hl], a
-	ret
-; 49496
-
-Function49496: ; 49496
-	hlcoord 0, 0, AttrMap
-	lb bc, 2, SCREEN_WIDTH
-	ld a, $7
-	call MG_Mobile_Layout_FillBox
-	hlcoord 0, 1, AttrMap
-	ld a, $4
-	ld [hl], a
-	hlcoord 19, 1, AttrMap
-	ld [hl], a
-	ret
-; 494ac
-
-LoadSpecialMapPalette: ; 494ac
-	ld a, [wTileset]
-	cp TILESET_POKECOM_CENTER
-	jr z, .pokecom_2f
-	cp TILESET_BATTLE_TOWER
-	jr z, .battle_tower
-	cp TILESET_ICE_PATH
-	jr z, .ice_path
-	cp TILESET_HOUSE_1
-	jr z, .house
-	cp TILESET_RADIO_TOWER
-	jr z, .radio_tower
-	cp TILESET_CELADON_MANSION
-	jr z, .mansion_mobile
-	jr .do_nothing
-
-.pokecom_2f
-	call LoadPokeComPalette
-	scf
-	ret
-
-.battle_tower
-	call LoadBattleTowerPalette
-	scf
-	ret
-
-.ice_path
-	ld a, [wPermission] ; permission
-	and 7
-	cp 3 ; Hall of Fame
-	jr z, .do_nothing
-	call LoadIcePathPalette
-	scf
-	ret
-
-.house
-	call LoadHousePalette
-	scf
-	ret
-
-.radio_tower
-	call LoadRadioTowerPalette
-	scf
-	ret
-
-.mansion_mobile
-	call LoadMansionPalette
-	scf
-	ret
-
-.do_nothing
-	and a
-	ret
-; 494f2
-
-LoadPokeComPalette: ; 494f2
-	ld a, $5
-	ld de, UnknBGPals
-	ld hl, PokeComPalette
-	ld bc, 8 palettes
-	call FarCopyWRAM
-	ret
-; 49501
-
-PokeComPalette: ; 49501
-INCLUDE "tilesets/pokecom.pal"
-; 49541
-
-LoadBattleTowerPalette: ; 49541
-	ld a, $5
-	ld de, UnknBGPals
-	ld hl, BattleTowerPalette
-	ld bc, 8 palettes
-	call FarCopyWRAM
-	ret
-; 49550
-
-BattleTowerPalette: ; 49550
-INCLUDE "tilesets/battle_tower.pal"
-; 49590
-
-LoadIcePathPalette: ; 49590
-	ld a, $5
-	ld de, UnknBGPals
-	ld hl, IcePathPalette
-	ld bc, 8 palettes
-	call FarCopyWRAM
-	ret
-; 4959f
-
-IcePathPalette: ; 4959f
-INCLUDE "tilesets/ice_path.pal"
-; 495df
-
-LoadHousePalette: ; 495df
-	ld a, $5
-	ld de, UnknBGPals
-	ld hl, HousePalette
-	ld bc, 8 palettes
-	call FarCopyWRAM
-	ret
-; 495ee
-
-HousePalette: ; 495ee
-INCLUDE "tilesets/house.pal"
-; 4962e
-
-LoadRadioTowerPalette: ; 4962e
-	ld a, $5
-	ld de, UnknBGPals
-	ld hl, RadioTowerPalette
-	ld bc, 8 palettes
-	call FarCopyWRAM
-	ret
-; 4963d
-
-RadioTowerPalette: ; 4963d
-INCLUDE "tilesets/radio_tower.pal"
-; 4967d
-
-MansionPalette1: ; 4967d
-	RGB 30, 28, 26
-	RGB 19, 19, 19
-	RGB 13, 13, 13
-	RGB 07, 07, 07
-
-	RGB 30, 28, 26
-	RGB 31, 19, 24
-	RGB 30, 10, 06
-	RGB 07, 07, 07
-
-	RGB 18, 24, 09
-	RGB 15, 20, 01
-	RGB 09, 13, 00
-	RGB 07, 07, 07
-
-	RGB 30, 28, 26
-	RGB 15, 16, 31
-	RGB 09, 09, 31
-	RGB 07, 07, 07
-
-	RGB 30, 28, 26
-	RGB 31, 31, 07
-	RGB 31, 16, 01
-	RGB 07, 07, 07
-
-	RGB 26, 24, 17
-	RGB 21, 17, 07
-	RGB 16, 13, 03
-	RGB 07, 07, 07
-
-MansionPalette3: ; 496ad
-	RGB 30, 28, 26
-	RGB 17, 19, 31
-	RGB 14, 16, 31
-	RGB 07, 07, 07
-
-	RGB 31, 31, 16
-	RGB 31, 31, 16
-	RGB 14, 09, 00
-	RGB 00, 00, 00
-; 496bd
-
-MansionPalette4: ; 496bd
-	RGB 05, 05, 16
-	RGB 08, 19, 28
-	RGB 00, 00, 00
-	RGB 31, 31, 31
-; 496c5
-
-LoadMansionPalette: ; 496c5
-	ld a, $5
-	ld de, UnknBGPals
-	ld hl, MansionPalette1
-	ld bc, 8 palettes
-	call FarCopyWRAM
-	ld a, $5
-	ld de, UnknBGPals + 4 palettes
-	ld hl, MansionPalette2
-	ld bc, 1 palettes
-	call FarCopyWRAM
-	ld a, $5
-	ld de, UnknBGPals + 3 palettes
-	ld hl, MansionPalette3
-	ld bc, 1 palettes
-	call FarCopyWRAM
-	ld a, $5
-	ld de, UnknBGPals + 6 palettes
-	ld hl, MansionPalette4
-	ld bc, 1 palettes
-	call FarCopyWRAM
-	ret
-; 496fe
-
-MansionPalette2: ; 496fe
-	RGB 25, 24, 23
-	RGB 20, 19, 19
-	RGB 14, 16, 31
-	RGB 07, 07, 07
-; 49706
-
-MG_Mobile_Layout02: ; 49706
-	ld hl, Palette_49732
-	ld de, UnknBGPals
-	ld bc, 1 palettes
-	ld a, $5
-	call FarCopyWRAM
-	callba ApplyPals
-	call MG_Mobile_Layout_WipeAttrMap
-	callba ApplyAttrMap
-	ld hl, Palette_4973a
-	ld de, UnknOBPals
-	ld bc, 1 palettes
-	ld a, $5
-	call FarCopyWRAM
-	ret
-; 49732
-
-Palette_49732: ; 49732
-	RGB 31, 31, 31
-	RGB 23, 16, 07
-	RGB 23, 07, 07
-	RGB 03, 07, 20
-; 4973a
-
-Palette_4973a: ; 4973a
-	RGB 00, 00, 00
-	RGB 07, 05, 31
-	RGB 14, 18, 31
-	RGB 31, 31, 31
-; 49742
-
-Function49742: ; 49742
-	ld hl, Palette_49757
-	ld de, UnknBGPals
-	ld bc, $40
-	ld a, $5
-	call FarCopyWRAM
-	callba ApplyPals
-	ret
-; 49757
-
-Palette_49757: ; 49757
-	RGB 31, 31, 63
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-
-	RGB 31, 31, 63
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-
-	RGB 04, 02, 15
-	RGB 21, 00, 21
-	RGB 31, 00, 00
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 21, 00, 21
-	RGB 30, 16, 26
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 21, 00, 21
-	RGB 16, 16, 16
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 21, 00, 21
-	RGB 31, 12, 12
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 21, 00, 21
-	RGB 07, 08, 31
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 21, 00, 21
-	RGB 29, 28, 09
-	RGB 31, 31, 31
-; 49797
-
-_InitMG_Mobile_LinkTradePalMap: ; 49797
-	hlcoord 0, 0, AttrMap
-	lb bc, 16, 2
-	ld a, $4
-	call MG_Mobile_Layout_FillBox
-	ld a, $3
-	ldcoord_a 0, 1, AttrMap
-	ldcoord_a 0, 14, AttrMap
-	hlcoord 2, 0, AttrMap
-	lb bc, 8, 18
-	ld a, $5
-	call MG_Mobile_Layout_FillBox
-	hlcoord 2, 8, AttrMap
-	lb bc, 8, 18
-	ld a, $6
-	call MG_Mobile_Layout_FillBox
-	hlcoord 0, 16, AttrMap
-	lb bc, 2, SCREEN_WIDTH
-	ld a, $4
-	call MG_Mobile_Layout_FillBox
-	ld a, $3
-	lb bc, 6, 1
-	hlcoord 6, 1, AttrMap
-	call MG_Mobile_Layout_FillBox
-	ld a, $3
-	lb bc, 6, 1
-	hlcoord 17, 1, AttrMap
-	call MG_Mobile_Layout_FillBox
-	ld a, $3
-	lb bc, 6, 1
-	hlcoord 6, 9, AttrMap
-	call MG_Mobile_Layout_FillBox
-	ld a, $3
-	lb bc, 6, 1
-	hlcoord 17, 9, AttrMap
-	call MG_Mobile_Layout_FillBox
-	ld a, $2
-	hlcoord 2, 16, AttrMap
-	ld [hli], a
-	ld a, $7
-	ld [hli], a
-	ld [hli], a
-	ld [hli], a
-	ld a, $2
-	ld [hl], a
-	hlcoord 2, 17, AttrMap
-	ld a, $3
-	ld bc, 6
-	call ByteFill
-	ret
-; 49811
-
-LoadTradeRoomBGPals: ; 49811
-	ld hl, Palette_49826
-	ld de, UnknBGPals + $10
-	ld bc, $30
-	ld a, $5
-	call FarCopyWRAM
-	callba ApplyPals
-	ret
-; 49826
-
-Palette_49826: ; 49826
-	RGB 04, 02, 15
-	RGB 07, 09, 31
-	RGB 31, 00, 00
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 07, 09, 31
-	RGB 15, 23, 30
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 07, 09, 31
-	RGB 16, 16, 16
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 07, 09, 31
-	RGB 25, 07, 04
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 07, 09, 31
-	RGB 03, 22, 08
-	RGB 31, 31, 31
-
-	RGB 04, 02, 15
-	RGB 07, 09, 31
-	RGB 29, 28, 09
-	RGB 31, 31, 31
-; 49856
-
-InitMG_Mobile_LinkTradePalMap: ; 49856
-	call _InitMG_Mobile_LinkTradePalMap
-	ret
-; 4985a
--- a/predef/sgb.asm
+++ /dev/null
@@ -1,636 +1,0 @@
-Predef_LoadSGBLayout: ; 864c
-; LoadSGBLayout
-	call CheckCGB
-	jp nz, Predef_LoadSGBLayoutCGB
-
-	ld a, b
-	cp SCGB_RAM
-	jr nz, .not_ram
-	ld a, [SGBPredef]
-.not_ram
-	cp SCGB_PARTY_MENU_HP_PALS
-	jp z, SGB_ApplyPartyMenuHPPals
-	ld l, a
-	ld h, 0
-	add hl, hl
-	ld de, .Jumptable
-	add hl, de
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	ld de, .Finish
-	push de
-	jp hl
-; 866f
-
-.Jumptable: ; 866f
-	dw .SGB_BattleGrayscale
-	dw .SGB_BattleColors
-	dw .SGB_PokegearPals
-	dw .SGB_StatsScreenHPPals
-	dw .SGB_Pokedex
-	dw .SGB_SlotMachine
-	dw .SGB06
-	dw .SGB07
-	dw .SGB_Diploma
-	dw .SGB_MapPals
-	dw .SGB_PartyMenu
-	dw .SGB_Evolution
-	dw .SGB0c
-	dw .SGB0d
-	dw .SGB_MoveList
-	dw .SGB0f
-	dw .SGB_PokedexSearchOption
-	dw .SGB11
-	dw .SGB12
-	dw .SGB13
-	dw .SGB_PackPals
-	dw .SGB_TrainerCard
-	dw .SGB_PokedexUnownMode
-	dw .SGB_BillsPC
-	dw .SGB_UnownPuzzle
-	dw .SGB19
-	dw .SGB_PlayerOrMonFrontpicPals
-	dw .SGB_TradeTube
-	dw .SGB_TrainerOrMonFrontpicPals
-	dw .SGB_MysteryGift
-	dw .SGB1e
-; 86ad
-
-.SGB_BattleGrayscale: ; 86ad
-	ld hl, PalPacket_9c66
-	ld de, BlkPacket_9aa6
-	ret
-; 86b4
-
-.SGB_BattleColors: ; 86b4
-	ld hl, BlkPacket_9aa6
-	call PushSGBPals_
-
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-
-	ld a, [PlayerHPPal]
-	ld l, a
-	ld h, 0
-	add hl, hl
-	add hl, hl
-	ld de, Palettes_a8be
-	add hl, de
-
-	ld a, [hli]
-	ld [wSGBPals + 3], a
-	ld a, [hli]
-	ld [wSGBPals + 4], a
-	ld a, [hli]
-	ld [wSGBPals + 5], a
-	ld a, [hl]
-	ld [wSGBPals + 6], a
-
-	ld a, [EnemyHPPal]
-	ld l, a
-	ld h, 0
-	add hl, hl
-	add hl, hl
-
-	ld de, Palettes_a8be
-	add hl, de
-	ld a, [hli]
-	ld [wSGBPals + 9], a
-	ld a, [hli]
-	ld [wSGBPals + 10], a
-	ld a, [hli]
-	ld [wSGBPals + 11], a
-	ld a, [hl]
-	ld [wSGBPals + 12], a
-
-	ld hl, PalPacket_9cf6
-	ld de, wSGBPals + $10
-	ld bc, $10
-	call CopyBytes
-
-	call GetBattlemonBackpicPalettePointer
-
-	ld a, [hli]
-	ld [wSGBPals + $13], a
-	ld a, [hli]
-	ld [wSGBPals + $14], a
-	ld a, [hli]
-	ld [wSGBPals + $15], a
-	ld a, [hl]
-	ld [wSGBPals + $16], a
-	call GetEnemyFrontpicPalettePointer
-	ld a, [hli]
-	ld [wSGBPals + $19], a
-	ld a, [hli]
-	ld [wSGBPals + $1a], a
-	ld a, [hli]
-	ld [wSGBPals + $1b], a
-	ld a, [hl]
-	ld [wSGBPals + $1c], a
-
-	ld hl, wSGBPals
-	ld de, wSGBPals + $10
-	ld a, SCGB_BATTLE_COLORS
-	ld [SGBPredef], a
-	ret
-; 873c
-
-.SGB_MoveList: ; 873c
-	ld hl, PalPacket_9bd6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-
-	ld hl, wSGBPals + 1
-	ld [hl], $10
-	inc hl
-	inc hl
-
-	ld a, [PlayerHPPal]
-	add $2f
-	ld [hl], a
-	ld hl, wSGBPals
-	ld de, BlkPacket_9ad6
-	ret
-; 875c
-
-.SGB_PokegearPals: ; 875c
-	ld hl, PalPacket_9c76
-	ld de, BlkPacket_9a86
-	ret
-; 8763
-
-.SGB_StatsScreenHPPals: ; 8763
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	ld a, [wCurHPPal]
-	ld l, a
-	ld h, 0
-	add hl, hl
-	add hl, hl
-	ld de, Palettes_a8be
-	add hl, de
-	ld a, [hli]
-	ld [wSGBPals + 3], a
-	ld a, [hli]
-	ld [wSGBPals + 4], a
-	ld a, [hli]
-	ld [wSGBPals + 5], a
-	ld a, [hl]
-	ld [wSGBPals + 6], a
-	ld a, [CurPartySpecies]
-	ld bc, TempMonDVs
-	call GetPlayerOrMonPalettePointer
-	ld a, [hli]
-	ld [wSGBPals + 9], a
-	ld a, [hli]
-	ld [wSGBPals + 10], a
-	ld a, [hli]
-	ld [wSGBPals + 11], a
-	ld a, [hl]
-	ld [wSGBPals + 12], a
-	ld hl, wSGBPals
-	ld de, BlkPacket_9ac6
-	ret
-; 87ab
-
-.SGB_PartyMenu: ; 87ab
-	ld hl, PalPacket_9c56
-	ld de, wSGBPals + 1
-	ret
-; 87b2
-
-.SGB_Pokedex: ; 87b2
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	ld hl, wSGBPals + 3
-	ld [hl], $9f
-	inc hl
-	ld [hl], $2a
-	inc hl
-	ld [hl], $5a
-	inc hl
-	ld [hl], $19
-	ld a, [CurPartySpecies]
-	call GetMonPalettePointer_
-	ld a, [hli]
-	ld [wSGBPals + 9], a
-	ld a, [hli]
-	ld [wSGBPals + 10], a
-	ld a, [hli]
-	ld [wSGBPals + 11], a
-	ld a, [hl]
-	ld [wSGBPals + 12], a
-	ld hl, wSGBPals
-	ld de, BlkPacket_9ae6
-	ret
-; 87e9
-
-.SGB_BillsPC: ; 87e9
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	ld hl, wSGBPals + 3
-	ld [hl], $9f
-	inc hl
-	ld [hl], $2a
-	inc hl
-	ld [hl], $5a
-	inc hl
-	ld [hl], $19
-	ld a, [CurPartySpecies]
-	ld bc, TempMonDVs
-	call GetPlayerOrMonPalettePointer
-	ld a, [hli]
-	ld [wSGBPals + 9], a
-	ld a, [hli]
-	ld [wSGBPals + 10], a
-	ld a, [hli]
-	ld [wSGBPals + 11], a
-	ld a, [hl]
-	ld [wSGBPals + 12], a
-	ld hl, wSGBPals
-	ld de, BlkPacket_9ae6
-	ret
-; 8823
-
-.SGB_PokedexUnownMode: ; 8823
-	call .SGB_Pokedex
-	ld de, BlkPacket_9af6
-	ret
-; 882a
-
-.SGB_PokedexSearchOption: ; 882a
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	ld hl, wSGBPals + 3
-	ld [hl], $9f
-	inc hl
-	ld [hl], $2a
-	inc hl
-	ld [hl], $5a
-	inc hl
-	ld [hl], $19
-	ld hl, wSGBPals
-	ld de, BlkPacket_9a86
-	ret
-; 884b
-
-.SGB_PackPals: ; 884b
-	ld hl, PalPacket_9c36
-	ld de, BlkPacket_9a86
-	ret
-; 8852
-
-.SGB_SlotMachine: ; 8852
-	ld hl, PalPacket_9c96
-	ld de, BlkPacket_9b06
-	ret
-; 8859
-
-.SGB06: ; 8859
-	ld hl, PalPacket_9ca6
-	ld de, BlkPacket_9b76
-	ret
-; 8860
-
-.SGB_Diploma:
-.SGB_MysteryGift: ; 8860
-	ld hl, PalPacket_9cb6
-	ld de, BlkPacket_9a86
-	ret
-; 8867
-
-.SGB07: ; 8867
-	ld b, 0
-	ld hl, .BlkPacketTable_SGB07
-rept 4
-	add hl, bc
-endr
-	ld e, [hl]
-	inc hl
-	ld d, [hl]
-	inc hl
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	ret
-; 8878
-
-.BlkPacketTable_SGB07: ; 8878
-	dw BlkPacket_9a86, PalPacket_9be6
-	dw BlkPacket_9a96, PalPacket_9c06
-	dw BlkPacket_9a86, PalPacket_9c16
-; 8884
-
-.SGB0c: ; 8884
-	ld hl, PalPacket_9b96
-	ld de, BlkPacket_9b56
-	ld a, SCGB_DIPLOMA
-	ld [SGBPredef], a
-	ret
-; 8890
-
-.SGB13: ; 8890
-	ld hl, PalPacket_9ba6
-	ld de, BlkPacket_9b86
-	ret
-; 8897
-
-.SGB0f: ; 8897
-	ld hl, PalPacket_9c46
-	ld de, BlkPacket_9a86
-	ret
-; 889e
-
-.SGB11: ; 889e
-	ld hl, BlkPacket_9a86
-	ld de, PlayerLightScreenCount
-	ld bc, $10
-	call CopyBytes
-	ld hl, PalPacket_9bb6
-	ld de, BlkPacket_9a86
-	ret
-; 88b1
-
-.SGB_MapPals: ; 88b1
-	ld hl, PalPacket_9bd6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	call .GetMapPalsIndex
-	ld hl, wSGBPals + 1
-	ld [hld], a
-	ld de, BlkPacket_9a86
-	ld a, SCGB_MAPPALS
-	ld [SGBPredef], a
-	ret
-; 88cd
-
-.SGB_Evolution: ; 88cd
-	push bc
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	pop bc
-	ld a, c
-	and a
-	jr z, .partymon
-	; Egg
-	ld hl, wSGBPals + 3
-	; RGB 7, 7, 7
-	ld [hl], $e7
-	inc hl
-	ld [hl], $1c
-	inc hl
-	; RGB 2, 3, 3
-	ld [hl], $62
-	inc hl
-	ld [hl], $c
-	jr .done
-
-.partymon
-	ld hl, PartyMon1DVs
-	ld bc, PARTYMON_STRUCT_LENGTH
-	ld a, [CurPartyMon]
-	call AddNTimes
-	ld c, l
-	ld b, h
-	ld a, [PlayerHPPal]
-	call GetPlayerOrMonPalettePointer
-	ld a, [hli]
-	ld [wSGBPals + 3], a
-	ld a, [hli]
-	ld [wSGBPals + 4], a
-	ld a, [hli]
-	ld [wSGBPals + 5], a
-	ld a, [hl]
-	ld [wSGBPals + 6], a
-
-.done
-	ld hl, wSGBPals
-	ld de, BlkPacket_9a86
-	ret
-; 891a
-
-.SGB0d:
-.SGB_TrainerCard: ; 891a
-	ld hl, PalPacket_9cb6
-	ld de, BlkPacket_9a86
-	ret
-; 8921
-
-.SGB_UnownPuzzle: ; 8921
-	ld hl, PalPacket_9bc6
-	ld de, BlkPacket_9a86
-	ret
-; 8928
-
-.SGB12: ; 8928
-	ld hl, PalPacket_9bd6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	ld hl, BlkPacket_9a86
-	ld de, wSGBPals + $10
-	ld bc, $10
-	call CopyBytes
-	call .GetMapPalsIndex
-	ld hl, wSGBPals + 1
-	ld [hl], a
-	ld hl, wSGBPals + 3
-	ld [hl], $2e
-	ld hl, wSGBPals + $13
-	ld a, 5
-	ld [hli], a
-	ld a, [wMenuBorderLeftCoord]
-	ld [hli], a
-	ld a, [wMenuBorderTopCoord]
-	ld [hli], a
-	ld a, [wMenuBorderRightCoord]
-	ld [hli], a
-	ld a, [wMenuBorderBottomCoord]
-	ld [hl], a
-	ld hl, wSGBPals
-	ld de, wSGBPals + $10
-	ret
-; 8969
-
-.SGB1e: ; 8969
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	ld a, [CurPartySpecies]
-	ld l, a
-	ld h, 0
-	add hl, hl
-	add hl, hl
-	add hl, hl
-	ld de, PokemonPalettes
-	add hl, de
-	ld a, [wcf65]
-	and 3
-	sla a
-	sla a
-	ld c, a
-	ld b, 0
-	add hl, bc
-	ld a, [hli]
-	ld [wSGBPals + 3], a
-	ld a, [hli]
-	ld [wSGBPals + 4], a
-	ld a, [hli]
-	ld [wSGBPals + 5], a
-	ld a, [hl]
-	ld [wSGBPals + 6], a
-	ld hl, wSGBPals
-	ld de, BlkPacket_9a86
-	ret
-; 89a6
-
-.SGB19: ; 89a6
-	ld hl, PalPacket_9cd6
-	ld de, BlkPacket_9a86
-	ret
-; 89ad
-
-.SGB_PlayerOrMonFrontpicPals: ; 89ad
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	ld a, [CurPartySpecies]
-	ld bc, TempMonDVs
-	call GetPlayerOrMonPalettePointer
-	ld a, [hli]
-	ld [wSGBPals + 3], a
-	ld a, [hli]
-	ld [wSGBPals + 4], a
-	ld a, [hli]
-	ld [wSGBPals + 5], a
-	ld a, [hl]
-	ld [wSGBPals + 6], a
-	ld hl, wSGBPals
-	ld de, BlkPacket_9a86
-	ret
-; 89d9
-
-.SGB_TradeTube: ; 89d9
-	ld hl, PalPacket_9cc6
-	ld de, BlkPacket_9a86
-	ret
-; 89e0
-
-.SGB_TrainerOrMonFrontpicPals: ; 89e0
-	ld hl, PalPacket_9ce6
-	ld de, wSGBPals
-	ld bc, $10
-	call CopyBytes
-	ld a, [CurPartySpecies]
-	ld bc, TempMonDVs
-	call GetFrontpicPalettePointer
-	ld a, [hli]
-	ld [wSGBPals + 3], a
-	ld a, [hli]
-	ld [wSGBPals + 4], a
-	ld a, [hli]
-	ld [wSGBPals + 5], a
-	ld a, [hl]
-	ld [wSGBPals + 6], a
-	ld hl, wSGBPals
-	ld de, BlkPacket_9a86
-	ret
-; 8a0c
-
-.GetMapPalsIndex: ; 8a0c
-	ld a, [TimeOfDayPal]
-	cp NITE_F
-	jr c, .morn_day
-	ld a, $19
-	ret
-
-.morn_day
-	ld a, [wPermission]
-	cp ROUTE
-	jr z, .route
-	cp CAVE
-	jr z, .cave
-	cp DUNGEON
-	jr z, .cave
-	cp PERM_5
-	jr z, .perm5
-	cp GATE
-	jr z, .gate
-	ld a, [MapGroup]
-	ld e, a
-	ld d, 0
-	ld hl, .SGBRoofPalInds
-	add hl, de
-	ld a, [hl]
-	ret
-
-.route
-	ld a, $00
-	ret
-
-.cave
-	ld a, $18
-	ret
-
-.perm5
-	ld a, $06
-	ret
-
-.gate
-	ld a, $03
-	ret
-; 8a45
-
-.SGBRoofPalInds: ; 8a45
-	db $00 ; Unused
-	db $12 ; Olivine
-	db $14 ; Mahogany
-	db $18 ; Various Dungeons
-	db $11 ; Ecruteak
-	db $15 ; Blackthorn
-	db $09 ; Cinnabar
-	db $04 ; Cerulean
-	db $0f ; Azalea
-	db $16 ; Lake Of Rage
-	db $0e ; Violet
-	db $10 ; Goldenrod
-	db $06 ; Vermilion
-	db $01 ; Palette
-	db $03 ; Pewter
-	db $06 ; Fast Ship
-	db $0b ; Indigo Plateau
-	db $08 ; Fuchsia
-	db $05 ; Lavender
-	db $17 ; Silver Cave Outside
-	db $08 ; Pokemon Center 2F
-	db $07 ; Celadon
-	db $13 ; Cianwood
-	db $02 ; Viridian
-	db $0c ; New Bark
-	db $0a ; Saffron
-	db $0d ; Cherrygrove
-; 8a60
-
-.Finish: ; 8a60
-	push de
-	call PushSGBPals_
-	pop hl
-	jp PushSGBPals_
-; 8a68
--- a/tilesets/bg.pal
+++ /dev/null
@@ -1,227 +1,0 @@
-; morn
-
-; gray
-	RGB 28, 31, 16
-	RGB 21, 21, 21
-	RGB 13, 13, 13
-	RGB 07, 07, 07
-; red
-	RGB 28, 31, 16
-	RGB 31, 19, 24
-	RGB 30, 10, 06
-	RGB 07, 07, 07
-; green
-	RGB 22, 31, 10
-	RGB 12, 25, 01
-	RGB 05, 14, 00
-	RGB 07, 07, 07
-; water
-	RGB 31, 31, 31
-	RGB 08, 12, 31
-	RGB 01, 04, 31
-	RGB 07, 07, 07
-; yellow
-	RGB 28, 31, 16
-	RGB 31, 31, 07
-	RGB 31, 16, 01
-	RGB 07, 07, 07
-; brown
-	RGB 28, 31, 16
-	RGB 24, 18, 07
-	RGB 20, 15, 03
-	RGB 07, 07, 07
-; roof
-	RGB 28, 31, 16
-	RGB 15, 31, 31
-	RGB 05, 17, 31
-	RGB 07, 07, 07
-; text
-	RGB 31, 31, 16
-	RGB 31, 31, 16
-	RGB 14, 09, 00
-	RGB 00, 00, 00
-
-; day
-
-; gray
-	RGB 27, 31, 27
-	RGB 21, 21, 21
-	RGB 13, 13, 13
-	RGB 07, 07, 07
-; red
-	RGB 27, 31, 27
-	RGB 31, 19, 24
-	RGB 30, 10, 06
-	RGB 07, 07, 07
-; green
-	RGB 22, 31, 10
-	RGB 12, 25, 01
-	RGB 05, 14, 00
-	RGB 07, 07, 07
-; water
-	RGB 31, 31, 31
-	RGB 08, 12, 31
-	RGB 01, 04, 31
-	RGB 07, 07, 07
-; yellow
-	RGB 27, 31, 27
-	RGB 31, 31, 07
-	RGB 31, 16, 01
-	RGB 07, 07, 07
-; brown
-	RGB 27, 31, 27
-	RGB 24, 18, 07
-	RGB 20, 15, 03
-	RGB 07, 07, 07
-; roof
-	RGB 27, 31, 27
-	RGB 15, 31, 31
-	RGB 05, 17, 31
-	RGB 07, 07, 07
-; text
-	RGB 31, 31, 16
-	RGB 31, 31, 16
-	RGB 14, 09, 00
-	RGB 00, 00, 00
-
-; nite
-
-; gray
-	RGB 15, 14, 24
-	RGB 11, 11, 19
-	RGB 07, 07, 12
-	RGB 00, 00, 00
-; red
-	RGB 15, 14, 24
-	RGB 14, 07, 17
-	RGB 13, 00, 08
-	RGB 00, 00, 00
-; green
-	RGB 15, 14, 24
-	RGB 08, 13, 19
-	RGB 00, 11, 13
-	RGB 00, 00, 00
-; water
-	RGB 15, 14, 24
-	RGB 05, 05, 17
-	RGB 03, 03, 10
-	RGB 00, 00, 00
-; yellow
-	RGB 30, 30, 11
-	RGB 16, 14, 18
-	RGB 16, 14, 10
-	RGB 00, 00, 00
-; brown
-	RGB 15, 14, 24
-	RGB 12, 09, 15
-	RGB 08, 04, 05
-	RGB 00, 00, 00
-; roof
-	RGB 15, 14, 24
-	RGB 13, 12, 23
-	RGB 11, 09, 20
-	RGB 00, 00, 00
-; text
-	RGB 31, 31, 16
-	RGB 31, 31, 16
-	RGB 14, 09, 00
-	RGB 00, 00, 00
-
-; dark
-
-; gray
-	RGB 01, 01, 02
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-; red
-	RGB 01, 01, 02
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-; green
-	RGB 01, 01, 02
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-; water
-	RGB 01, 01, 02
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-; yellow
-	RGB 30, 30, 11
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-; brown
-	RGB 01, 01, 02
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-; roof
-	RGB 01, 01, 02
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-	RGB 00, 00, 00
-; text
-	RGB 31, 31, 16
-	RGB 31, 31, 16
-	RGB 14, 09, 00
-	RGB 00, 00, 00
-
-; indoor
-
-; gray
-	RGB 30, 28, 26
-	RGB 19, 19, 19
-	RGB 13, 13, 13
-	RGB 07, 07, 07
-; red
-	RGB 30, 28, 26
-	RGB 31, 19, 24
-	RGB 30, 10, 06
-	RGB 07, 07, 07
-; green
-	RGB 18, 24, 09
-	RGB 15, 20, 01
-	RGB 09, 13, 00
-	RGB 07, 07, 07
-; water
-	RGB 30, 28, 26
-	RGB 15, 16, 31
-	RGB 09, 09, 31
-	RGB 07, 07, 07
-; yellow
-	RGB 30, 28, 26
-	RGB 31, 31, 07
-	RGB 31, 16, 01
-	RGB 07, 07, 07
-; brown
-	RGB 26, 24, 17
-	RGB 21, 17, 07
-	RGB 16, 13, 03
-	RGB 07, 07, 07
-; roof
-	RGB 30, 28, 26
-	RGB 17, 19, 31
-	RGB 14, 16, 31
-	RGB 07, 07, 07
-; text
-	RGB 31, 31, 16
-	RGB 31, 31, 16
-	RGB 14, 09, 00
-	RGB 00, 00, 00
-
-; overworld water
-
-; morn/day
-	RGB 23, 23, 31
-	RGB 18, 19, 31
-	RGB 13, 12, 31
-	RGB 07, 07, 07
-; nite
-	RGB 15, 13, 27
-	RGB 10, 09, 20
-	RGB 04, 03, 18
-	RGB 00, 00, 00
--- a/tilesets/house.pal
+++ /dev/null
@@ -1,40 +1,0 @@
-; gray
-	RGB 30, 28, 26
-	RGB 19, 19, 19
-	RGB 13, 13, 13
-	RGB 07, 07, 07
-; red
-	RGB 30, 28, 26
-	RGB 31, 19, 24
-	RGB 30, 10, 06
-	RGB 07, 07, 07
-; green
-	RGB 30, 28, 26
-	RGB 15, 20, 01
-	RGB 09, 13, 00
-	RGB 07, 07, 07
-; water (blue)
-	RGB 30, 28, 26
-	RGB 15, 16, 31
-	RGB 09, 09, 31
-	RGB 07, 07, 07
-; yellow
-	RGB 30, 28, 26
-	RGB 31, 31, 07
-	RGB 31, 16, 01
-	RGB 07, 07, 07
-; brown
-	RGB 26, 24, 17
-	RGB 21, 17, 07
-	RGB 16, 13, 03
-	RGB 07, 07, 07
-; roof (glass)
-	RGB 30, 28, 26
-	RGB 31, 19, 24
-	RGB 16, 13, 03
-	RGB 07, 07, 07
-; text
-	RGB 31, 31, 16
-	RGB 31, 31, 16
-	RGB 14, 09, 00
-	RGB 00, 00, 00
--- /dev/null
+++ b/tilesets/house_1.pal
@@ -1,0 +1,40 @@
+; gray
+	RGB 30, 28, 26
+	RGB 19, 19, 19
+	RGB 13, 13, 13
+	RGB 07, 07, 07
+; red
+	RGB 30, 28, 26
+	RGB 31, 19, 24
+	RGB 30, 10, 06
+	RGB 07, 07, 07
+; green
+	RGB 30, 28, 26
+	RGB 15, 20, 01
+	RGB 09, 13, 00
+	RGB 07, 07, 07
+; water (blue)
+	RGB 30, 28, 26
+	RGB 15, 16, 31
+	RGB 09, 09, 31
+	RGB 07, 07, 07
+; yellow
+	RGB 30, 28, 26
+	RGB 31, 31, 07
+	RGB 31, 16, 01
+	RGB 07, 07, 07
+; brown
+	RGB 26, 24, 17
+	RGB 21, 17, 07
+	RGB 16, 13, 03
+	RGB 07, 07, 07
+; roof (glass)
+	RGB 30, 28, 26
+	RGB 31, 19, 24
+	RGB 16, 13, 03
+	RGB 07, 07, 07
+; text
+	RGB 31, 31, 16
+	RGB 31, 31, 16
+	RGB 14, 09, 00
+	RGB 00, 00, 00
--- a/tilesets/ob.pal
+++ /dev/null
@@ -1,39 +1,0 @@
-	; morn
-	RGB 28,31,16, 31,19,10, 31,07,01, 00,00,00 ; red
-	RGB 28,31,16, 31,19,10, 10,09,31, 00,00,00 ; blue
-	RGB 28,31,16, 31,19,10, 07,23,03, 00,00,00 ; green
-	RGB 28,31,16, 31,19,10, 15,10,03, 00,00,00 ; brown
-	RGB 28,31,16, 31,19,10, 30,10,06, 00,00,00 ; pink
-	RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver
-	RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree
-	RGB 28,31,16, 24,18,07, 20,15,03, 07,07,07 ; rock
-
-	; day
-	RGB 27,31,27, 31,19,10, 31,07,01, 00,00,00 ; red
-	RGB 27,31,27, 31,19,10, 10,09,31, 00,00,00 ; blue
-	RGB 27,31,27, 31,19,10, 07,23,03, 00,00,00 ; green
-	RGB 27,31,27, 31,19,10, 15,10,03, 00,00,00 ; brown
-	RGB 27,31,27, 31,19,10, 30,10,06, 00,00,00 ; pink
-	RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver
-	RGB 22,31,10, 12,25,01, 05,14,00, 07,07,07 ; tree
-	RGB 27,31,27, 24,18,07, 20,15,03, 07,07,07 ; rock
-
-	; nite
-	RGB 15,14,24, 31,19,10, 31,07,01, 00,00,00 ; red
-	RGB 15,14,24, 31,19,10, 10,09,31, 00,00,00 ; blue
-	RGB 15,14,24, 31,19,10, 07,23,03, 00,00,00 ; green
-	RGB 15,14,24, 31,19,10, 15,10,03, 00,00,00 ; brown
-	RGB 15,14,24, 31,19,10, 30,10,06, 00,00,00 ; pink
-	RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver
-	RGB 15,14,24, 08,13,19, 00,11,13, 00,00,00 ; tree
-	RGB 15,14,24, 12,09,15, 08,04,05, 00,00,00 ; rock
-
-	; dark
-	RGB 01,01,02, 31,19,10, 31,07,01, 00,00,00 ; red
-	RGB 01,01,02, 31,19,10, 10,09,31, 00,00,00 ; blue
-	RGB 01,01,02, 31,19,10, 07,23,03, 00,00,00 ; green
-	RGB 01,01,02, 31,19,10, 15,10,03, 00,00,00 ; brown
-	RGB 01,01,02, 31,19,10, 30,10,06, 00,00,00 ; pink
-	RGB 31,31,31, 31,31,31, 13,13,13, 00,00,00 ; silver
-	RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; tree
-	RGB 01,01,02, 00,00,00, 00,00,00, 00,00,00 ; rock
--- a/tilesets/pokecom.pal
+++ /dev/null
@@ -1,40 +1,0 @@
-; gray
-	RGB 30, 28, 26
-	RGB 19, 19, 19
-	RGB 13, 13, 13
-	RGB 07, 07, 07
-; red
-	RGB 30, 28, 26
-	RGB 31, 19, 24
-	RGB 30, 10, 06
-	RGB 07, 07, 07
-; green
-	RGB 18, 24, 09
-	RGB 15, 20, 01
-	RGB 09, 13, 00
-	RGB 07, 07, 07
-; water (blue)
-	RGB 30, 28, 26
-	RGB 17, 19, 31
-	RGB 14, 16, 31
-	RGB 07, 07, 07
-; yellow
-	RGB 31, 26, 21
-	RGB 31, 20, 01
-	RGB 14, 16, 31
-	RGB 07, 07, 07
-; brown
-	RGB 21, 17, 07
-	RGB 17, 19, 31
-	RGB 16, 13, 03
-	RGB 07, 07, 07
-; roof
-	RGB 05, 05, 16
-	RGB 08, 19, 28
-	RGB 00, 00, 00
-	RGB 31, 31, 31
-; text
-	RGB 31, 31, 16
-	RGB 31, 31, 16
-	RGB 14, 09, 00
-	RGB 00, 00, 00
--- /dev/null
+++ b/tilesets/pokecom_center.pal
@@ -1,0 +1,40 @@
+; gray
+	RGB 30, 28, 26
+	RGB 19, 19, 19
+	RGB 13, 13, 13
+	RGB 07, 07, 07
+; red
+	RGB 30, 28, 26
+	RGB 31, 19, 24
+	RGB 30, 10, 06
+	RGB 07, 07, 07
+; green
+	RGB 18, 24, 09
+	RGB 15, 20, 01
+	RGB 09, 13, 00
+	RGB 07, 07, 07
+; water (blue)
+	RGB 30, 28, 26
+	RGB 17, 19, 31
+	RGB 14, 16, 31
+	RGB 07, 07, 07
+; yellow
+	RGB 31, 26, 21
+	RGB 31, 20, 01
+	RGB 14, 16, 31
+	RGB 07, 07, 07
+; brown
+	RGB 21, 17, 07
+	RGB 17, 19, 31
+	RGB 16, 13, 03
+	RGB 07, 07, 07
+; roof
+	RGB 05, 05, 16
+	RGB 08, 19, 28
+	RGB 00, 00, 00
+	RGB 31, 31, 31
+; text
+	RGB 31, 31, 16
+	RGB 31, 31, 16
+	RGB 14, 09, 00
+	RGB 00, 00, 00
--- a/tilesets/roof.pal
+++ /dev/null
@@ -1,161 +1,0 @@
-; group 0 (unused)
-	RGB 21, 21, 21
-	RGB 11, 11, 11
-	RGB 21, 21, 21
-	RGB 11, 11, 11
-
-; group 1 (Olivine)
-	RGB 14, 17, 31
-	RGB 07, 11, 15
-	RGB 09, 09, 17
-	RGB 05, 07, 13
-
-; group 2 (Mahogany)
-	RGB 12, 19, 00
-	RGB 06, 10, 00
-	RGB 06, 09, 07
-	RGB 04, 05, 06
-
-; group 3
-	RGB 21, 21, 21
-	RGB 11, 11, 11
-	RGB 21, 21, 21
-	RGB 17, 08, 07
-
-; group 4 (Ecruteak)
-	RGB 31, 19, 00
-	RGB 27, 10, 05
-	RGB 15, 07, 02
-	RGB 11, 04, 02
-
-; group 5 (Blackthorn)
-	RGB 11, 10, 16
-	RGB 05, 06, 07
-	RGB 03, 04, 08
-	RGB 00, 00, 00
-
-; group 6 (Cinnabar)
-	RGB 31, 10, 00
-	RGB 18, 06, 00
-	RGB 18, 05, 09
-	RGB 17, 08, 07
-
-; group 7 (Cerulean)
-	RGB 17, 27, 31
-	RGB 05, 15, 31
-	RGB 07, 08, 22
-	RGB 07, 07, 16
-
-; group 8 (Azalea)
-	RGB 22, 20, 10
-	RGB 17, 14, 03
-	RGB 11, 11, 05
-	RGB 10, 09, 07
-
-; group 9 (Lake of Rage)
-	RGB 31, 08, 04
-	RGB 09, 09, 08
-	RGB 18, 05, 09
-	RGB 09, 09, 08
-
-; group 10 (Violet)
-	RGB 24, 14, 31
-	RGB 13, 07, 21
-	RGB 12, 03, 18
-	RGB 09, 03, 15
-
-; group 11 (Goldenrod)
-	RGB 25, 25, 00
-	RGB 20, 17, 08
-	RGB 12, 12, 00
-	RGB 10, 09, 05
-
-; group 12 (Vermilion)
-	RGB 27, 23, 01
-	RGB 23, 11, 00
-	RGB 15, 11, 01
-	RGB 11, 10, 01
-
-; group 13 (Pallet)
-	RGB 27, 28, 31
-	RGB 17, 19, 22
-	RGB 14, 14, 18
-	RGB 10, 09, 13
-
-; group 14 (Pewter)
-	RGB 19, 19, 16
-	RGB 10, 12, 15
-	RGB 09, 09, 11
-	RGB 04, 05, 07
-
-; group 15 (Mount Moon Square)
-	RGB 14, 17, 31
-	RGB 07, 11, 15
-	RGB 09, 13, 19
-	RGB 07, 07, 16
-
-; group 16 (Route 23)
-	RGB 21, 21, 21
-	RGB 13, 13, 13
-	RGB 11, 11, 19
-	RGB 07, 07, 12
-
-; group 17 (Fuchsia)
-	RGB 31, 18, 29
-	RGB 17, 13, 20
-	RGB 14, 06, 12
-	RGB 11, 03, 10
-
-; group 18 (Lavender)
-	RGB 23, 15, 31
-	RGB 16, 05, 31
-	RGB 12, 07, 17
-	RGB 08, 06, 10
-
-; group 19 (Route 28)
-	RGB 21, 21, 25
-	RGB 16, 16, 16
-	RGB 13, 13, 13
-	RGB 07, 07, 07
-
-; group 20
-	RGB 21, 21, 21
-	RGB 11, 11, 11
-	RGB 21, 21, 21
-	RGB 11, 11, 11
-
-; group 21 (Celadon)
-	RGB 19, 31, 15
-	RGB 31, 22, 02
-	RGB 12, 13, 09
-	RGB 09, 12, 03
-
-; group 22 (Cianwood)
-	RGB 15, 10, 31
-	RGB 07, 05, 15
-	RGB 06, 05, 17
-	RGB 02, 02, 08
-
-; group 23 (Viridian)
-	RGB 21, 31, 07
-	RGB 13, 25, 04
-	RGB 09, 14, 08
-	RGB 06, 10, 04
-
-; group 24 (New Bark)
-	RGB 20, 31, 14
-	RGB 11, 23, 05
-	RGB 09, 13, 08
-	RGB 06, 09, 04
-
-; group 25 (Saffron)
-	RGB 31, 26, 00
-	RGB 31, 15, 00
-	RGB 13, 13, 01
-	RGB 08, 08, 01
-
-; group 26 (Cherrygrove)
-	RGB 31, 14, 28
-	RGB 31, 05, 21
-	RGB 14, 07, 17
-	RGB 13, 00, 08