shithub: pokecrystal

Download patch

ref: 6e257bc7cdab3249cc8fbdf4c808f0ebc442022e
parent: c635e30777ba57e3fd4249862fd562936d0d47bd
author: PikalaxALT <[email protected]>
date: Mon Dec 14 15:06:41 EST 2015

mystery gift, credits

--- a/engine/credits.asm
+++ b/engine/credits.asm
@@ -1,5 +1,8 @@
 INCLUDE "includes.asm"
 
+wCreditsBorderFrame EQU $cf64
+wCreditsBorderMon   EQU $cf65
+wCreditsLYOverride  EQU $cf66
 
 SECTION "Credits", ROMX, BANK[CREDITS]
 
@@ -119,11 +122,11 @@
 
 
 Credits:: ; 109847
-	bit 6, b
+	bit 6, b ; Hall Of Fame
 	ld a, $0
-	jr z, .asm_10984f
+	jr z, .okay
 	ld a, $40
-.asm_10984f
+.okay
 	ld [wJumptableIndex], a
 
 	ld a, [rSVBK]
@@ -135,17 +138,17 @@
 	call ClearTileMap
 	call ClearSprites
 
-	ld hl, wca00
+	ld hl, wCreditsFaux2bpp
 	ld c, $80
 	ld de, $ff00
 
-.asm_10986a
+.load_loop
 	ld a, e
 	ld [hli], a
 	ld a, d
 	ld [hli], a
 	dec c
-	jr nz, .asm_10986a
+	jr nz, .load_loop
 
 	ld de, CreditsBorderGFX
 	ld hl, VTiles2 tile $20
@@ -163,20 +166,20 @@
 	call Request2bpp
 
 	ld a, $ff
-	ld [wcf64], a
+	ld [wCreditsBorderFrame], a
 	xor a
-	ld [wcf65], a
+	ld [wCreditsBorderMon], a
 
-	call Function109bca
+	call Credits_LoadBorderGFX
 	ld e, l
 	ld d, h
 	ld hl, VTiles2
-	lb bc, BANK(CreditsMonsGFX), $10
+	lb bc, BANK(CreditsMonsGFX), 16
 	call Request2bpp
 
-	call Function109a95
+	call ConstructCreditsTilemap
 	xor a
-	ld [wcf66], a
+	ld [wCreditsLYOverride], a
 
 	ld hl, LYOverrides
 	ld bc, $100
@@ -200,16 +203,16 @@
 	ld [wcd21], a
 	ld [CreditsTimer], a
 
-.asm_1098de
-	call Function109908
-	call Function1098fd
-	jr nz, .asm_1098ee
+.execution_loop
+	call Credits_HandleBButton
+	call Credits_HandleAButton
+	jr nz, .exit_credits
 
-	call Function109926
+	call Credits_Jumptable
 	call DelayFrame
-	jr .asm_1098de
+	jr .execution_loop
 
-.asm_1098ee
+.exit_credits
 	call ClearBGPalettes
 	xor a
 	ld [hLCDStatCustom], a
@@ -221,9 +224,9 @@
 	ret
 ; 1098fd
 
-Function1098fd: ; 1098fd
+Credits_HandleAButton: ; 1098fd
 	ld a, [hJoypadDown]
-	and $1
+	and A_BUTTON
 	ret z
 	ld a, [wJumptableIndex]
 	bit 7, a
@@ -230,9 +233,9 @@
 	ret
 ; 109908
 
-Function109908: ; 109908
+Credits_HandleBButton: ; 109908
 	ld a, [hJoypadDown]
-	and $2
+	and B_BUTTON
 	ret z
 	ld a, [wJumptableIndex]
 	bit 6, a
@@ -240,12 +243,11 @@
 	ld hl, CreditsPos
 	ld a, [hli]
 	cp $d
-	jr nc, .asm_10991e
+	jr nc, .okay
 	ld a, [hli]
 	and a
 	ret z
-
-.asm_10991e
+.okay
 	ld hl, CreditsTimer
 	ld a, [hl]
 	and a
@@ -254,12 +256,12 @@
 	ret
 ; 109926
 
-Function109926: ; 109926
+Credits_Jumptable: ; 109926
 	ld a, [wJumptableIndex]
 	and $f
 	ld e, a
 	ld d, 0
-	ld hl, Jumptable_109937
+	ld hl, .Jumptable
 rept 2
 	add hl, de
 endr
@@ -270,28 +272,29 @@
 ; 109937
 
 
-Jumptable_109937: ; 109937 (42:5937)
-	dw ParseCredits
-	dw Function109951
-	dw Function109951
-	dw Function10995e
-	dw Function109964
-	dw Function10997b
-	dw Function109986
-	dw Function109951
-	dw Function109951
-	dw Function109951
-	dw Function109964
-	dw Function10997b
-	dw Function109956
+.Jumptable: ; 109937 (42:5937)
+	jumptable_start
+	jumptable ParseCredits
+	jumptable Credits_Next
+	jumptable Credits_Next
+	jumptable Credits_PrepBGMapUpdate
+	jumptable Credits_UpdateGFXRequestPath
+	jumptable Credits_RequestGFX
+	jumptable Credits_LYOverride
+	jumptable Credits_Next
+	jumptable Credits_Next
+	jumptable Credits_Next
+	jumptable Credits_UpdateGFXRequestPath
+	jumptable Credits_RequestGFX
+	jumptable Credits_LoopBack
 
 
-Function109951: ; 109951 (42:5951)
+Credits_Next: ; 109951 (42:5951)
 	ld hl, wJumptableIndex
 	inc [hl]
 	ret
 
-Function109956: ; 109956 (42:5956)
+Credits_LoopBack: ; 109956 (42:5956)
 	ld hl, wJumptableIndex
 	ld a, [hl]
 	and $f0
@@ -298,51 +301,51 @@
 	ld [hl], a
 	ret
 
-Function10995e: ; 10995e (42:595e)
+Credits_PrepBGMapUpdate: ; 10995e (42:595e)
 	xor a
 	ld [hBGMapMode], a
-	jp Function109951
+	jp Credits_Next
 
-Function109964: ; 109964 (42:5964)
-	call Function109bca
+Credits_UpdateGFXRequestPath: ; 109964 (42:5964)
+	call Credits_LoadBorderGFX
 	ld a, l
 	ld [Requested2bppSource], a
 	ld a, h
 	ld [Requested2bppSource + 1], a
-	ld a, $0
+	ld a, VTiles2 % $100
 	ld [Requested2bppDest], a
-	ld a, $90
+	ld a, VTiles2 / $100
 	ld [Requested2bppDest + 1], a
-	jr Function10997b
+	jr Credits_RequestGFX
 
-Function10997b: ; 10997b (42:597b)
+Credits_RequestGFX: ; 10997b (42:597b)
 	xor a
 	ld [hBGMapMode], a
 	ld a, $8
 	ld [Requested2bpp], a
-	jp Function109951
+	jp Credits_Next
 
-Function109986: ; 109986 (42:5986)
+Credits_LYOverride: ; 109986 (42:5986)
 	ld a, [rLY]
 	cp $30
-	jr c, Function109986
-	ld a, [wcf66]
+	jr c, Credits_LYOverride
+	ld a, [wCreditsLYOverride]
 rept 2
 	dec a
 endr
-	ld [wcf66], a
+	ld [wCreditsLYOverride], a
 	ld hl, LYOverrides + $1f
-	call Function1099a3
+	call .Fill
 	ld hl, LYOverrides + $87
-	call Function1099a3
-	jp Function109951
+	call .Fill
+	jp Credits_Next
 
-Function1099a3: ; 1099a3 (42:59a3)
+.Fill: ; 1099a3 (42:59a3)
 	ld c, $8
-.asm_1099a5
+.loop
 	ld [hli], a
 	dec c
-	jr nz, .asm_1099a5
+	jr nz, .loop
 	ret
 ; 1099aa
 
@@ -437,15 +440,15 @@
 	
 .theend
 ; Display "The End" graphic.
-	call Function109c11
+	call Credits_TheEnd
 	jr .loop
 	
 .scene
 ; Update the scene number and corresponding palette.
 	call .get
-	ld [wcf65], a ; scene
+	ld [wCreditsBorderMon], a ; scene
 	xor a
-	ld [wcf64], a ; frame
+	ld [wCreditsBorderFrame], a ; frame
 	call GetCreditsPalette
 	call SetPalettes ; update hw pal registers
 	jr .loop
@@ -453,7 +456,7 @@
 .clear
 ; Clear the banner.
 	ld a, $ff
-	ld [wcf64], a ; frame
+	ld [wCreditsBorderFrame], a ; frame
 	jr .loop
 	
 .music
@@ -484,13 +487,13 @@
 	ld [hBGMapMode], a
 	
 .done
-	jp Function109951
+	jp Credits_Next
 	
 .end
 ; Stop execution.
 	ld hl, wJumptableIndex
 	set 7, [hl]
-	ld a, $20
+	ld a, 32
 	ld [MusicFade], a
 	ld a, MUSIC_POST_CREDITS % $100
 	ld [MusicFadeID], a
@@ -521,91 +524,96 @@
 ; 109a95
 
 
-Function109a95: ; 109a95 (42:5a95)
+ConstructCreditsTilemap: ; 109a95 (42:5a95)
 	xor a
 	ld [hBGMapMode], a
 	ld a, $c
 	ld [hBGMapAddress], a
+
 	ld a, $28
 	hlcoord 0, 0
-	ld bc, $168
+	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
 	call ByteFill
+
 	ld a, $7f
 	hlcoord 0, 4
-	ld bc, $118
+	ld bc, (SCREEN_HEIGHT - 4) * SCREEN_WIDTH
 	call ByteFill
+
 	hlcoord 0, 4
 	ld a, $24
-	call Function109b1d
+	call DrawCreditsBorder
+
 	hlcoord 0, 17
 	ld a, $20
-	call Function109b1d
+	call DrawCreditsBorder
+
 	hlcoord 0, 0, AttrMap
-	ld bc, $50
+	ld bc, 4 * SCREEN_WIDTH
 	xor a
 	call ByteFill
+
 	hlcoord 0, 4, AttrMap
-	ld bc, $14
+	ld bc, SCREEN_WIDTH
 	ld a, $1
 	call ByteFill
+
 	hlcoord 0, 5, AttrMap
-	ld bc, $f0
+	ld bc, 12 * SCREEN_WIDTH
 	ld a, $2
 	call ByteFill
+
 	hlcoord 0, 17, AttrMap
-	ld bc, $14
+	ld bc, SCREEN_WIDTH
 	ld a, $1
 	call ByteFill
+
 	call WaitBGMap2
 	xor a
 	ld [hBGMapMode], a
 	ld [hBGMapAddress], a
 	hlcoord 0, 0
-	call Function109aff
+	call .InitTopPortion
 	call WaitBGMap2
 	ret
 
-Function109aff: ; 109aff (42:5aff)
-	ld b, $5
-.asm_109b01
+.InitTopPortion: ; 109aff (42:5aff)
+	ld b, 5
+.outer_loop
 	push hl
-	ld de, $11
-	ld c, $4
+	ld de, SCREEN_WIDTH - 3
+	ld c, 4
 	xor a
-.asm_109b08
+.inner_loop
+rept 3
 	ld [hli], a
 	inc a
-	ld [hli], a
-	inc a
-	ld [hli], a
-	inc a
+endr
 	ld [hl], a
 	inc a
 	add hl, de
 	dec c
-	jr nz, .asm_109b08
+	jr nz, .inner_loop
 	pop hl
 rept 4
 	inc hl
 endr
 	dec b
-	jr nz, .asm_109b01
+	jr nz, .outer_loop
 	ret
 
-Function109b1d: ; 109b1d (42:5b1d)
-	ld c, $5
-.asm_109b1f
+DrawCreditsBorder: ; 109b1d (42:5b1d)
+	ld c, SCREEN_WIDTH / 4
+.loop
 	push af
+rept 3
 	ld [hli], a
 	inc a
+endr
 	ld [hli], a
-	inc a
-	ld [hli], a
-	inc a
-	ld [hli], a
 	pop af
 	dec c
-	jr nz, .asm_109b1f
+	jr nz, .loop
 	ret
 
 GetCreditsPalette: ; 109b2c
@@ -619,7 +627,7 @@
 	
 .GetPalAddress
 ; Each set of palette data is 24 bytes long.
-	ld a, [wcf65] ; scene
+	ld a, [wCreditsBorderMon] ; scene
 	and 3
 	add a
 	add a ; * 8
@@ -724,11 +732,11 @@
 	RGB 31, 31, 31
 ; 109bca
 
-Function109bca: ; 109bca (42:5bca)
-	ld hl, wcf64
+Credits_LoadBorderGFX: ; 109bca (42:5bca)
+	ld hl, wCreditsBorderFrame
 	ld a, [hl]
 	cp $ff
-	jr z, .asm_109bed
+	jr z, .init
 
 	and 3
 	ld e, a
@@ -735,7 +743,7 @@
 	inc a
 	and 3
 	ld [hl], a
-	ld a, [wcf65]
+	ld a, [wCreditsBorderMon]
 	and 3
 rept 2
 	add a
@@ -744,7 +752,7 @@
 	add a
 	ld e, a
 	ld d, 0
-	ld hl, CreditsMonsFrames
+	ld hl, .Frames
 	add hl, de
 	ld a, [hli]
 	ld h, [hl]
@@ -751,43 +759,42 @@
 	ld l, a
 	ret
 
-.asm_109bed
-	ld hl, wca00
+.init
+	ld hl, wCreditsFaux2bpp
 	ret
 ; 109bf1 (42:5bf1)
 
-CreditsMonsFrames: ; 109bf1
+.Frames: ; 109bf1
 	dw CreditsPichuGFX
-	dw CreditsPichuGFX     + $100
-	dw CreditsPichuGFX     + $200
-	dw CreditsPichuGFX     + $300
+	dw CreditsPichuGFX     + 16 tiles
+	dw CreditsPichuGFX     + 32 tiles
+	dw CreditsPichuGFX     + 48 tiles
 	dw CreditsSmoochumGFX
-	dw CreditsSmoochumGFX  + $100
-	dw CreditsSmoochumGFX  + $200
-	dw CreditsSmoochumGFX  + $300
+	dw CreditsSmoochumGFX  + 16 tiles
+	dw CreditsSmoochumGFX  + 32 tiles
+	dw CreditsSmoochumGFX  + 48 tiles
 	dw CreditsDittoGFX
-	dw CreditsDittoGFX     + $100
-	dw CreditsDittoGFX     + $200
-	dw CreditsDittoGFX     + $300
+	dw CreditsDittoGFX     + 16 tiles
+	dw CreditsDittoGFX     + 32 tiles
+	dw CreditsDittoGFX     + 48 tiles
 	dw CreditsIgglybuffGFX
-	dw CreditsIgglybuffGFX + $100
-	dw CreditsIgglybuffGFX + $200
-	dw CreditsIgglybuffGFX + $300
+	dw CreditsIgglybuffGFX + 16 tiles
+	dw CreditsIgglybuffGFX + 32 tiles
+	dw CreditsIgglybuffGFX + 48 tiles
 ; 109c11
 
-Function109c11: ; 109c11 (42:5c11)
+Credits_TheEnd: ; 109c11 (42:5c11)
 	ld a, $40
 	hlcoord 6, 9
-	call Function109c1c
+	call .Load
 	hlcoord 6, 10
-
-Function109c1c: ; 109c1c (42:5c1c)
-	ld c, $8
-.asm_109c1e
+.Load: ; 109c1c (42:5c1c)
+	ld c, 8
+.loop
 	ld [hli], a
 	inc a
 	dec c
-	jr nz, .asm_109c1e
+	jr nz, .loop
 	ret
 ; 109c24 (42:5c24)
 
--- a/engine/evolution_animation.asm
+++ b/engine/evolution_animation.asm
@@ -9,7 +9,7 @@
 	ld a, [BaseDexNo]
 	push af
 
-	call _EvolutionAnimation
+	call .EvolutionAnimation
 
 	pop af
 	ld [BaseDexNo], a
@@ -29,7 +29,7 @@
 	ret
 ; 4e607
 
-_EvolutionAnimation: ; 4e607
+.EvolutionAnimation: ; 4e607
 	ld a, $e4
 	ld [rOBP0], a
 
@@ -38,9 +38,9 @@
 
 	callba ClearSpriteAnims
 
-	ld de, EvolutionGFX
+	ld de, .GFX
 	ld hl, VTiles0
-	lb bc, BANK(EvolutionGFX), 8
+	lb bc, BANK(.GFX), 8
 	call Request2bpp
 
 	xor a
@@ -76,7 +76,7 @@
 
 	ld a, $1
 	ld [hBGMapMode], a
-	call Function4e794
+	call .check_statused
 	jr c, .skip_cry
 
 	ld a, [Buffer1]
@@ -106,10 +106,10 @@
 
 	ld c, $0
 	call .GetSGBLayout
-	call Function4e7a6
+	call .PlayEvolvedSFX
 	callba ClearSpriteAnims
-	call Function4e794
-	jr c, .asm_4e6de
+	call .check_statused
+	jr c, .no_anim
 
 	ld a, [wc2c6]
 	push af
@@ -131,7 +131,7 @@
 	ld [wc2c6], a
 	ret
 
-.asm_4e6de
+.no_anim
 	ret
 
 .cancel_evo
@@ -143,9 +143,9 @@
 
 	ld c, $0
 	call .GetSGBLayout
-	call Function4e7a6
+	call .PlayEvolvedSFX
 	callba ClearSpriteAnims
-	call Function4e794
+	call .check_statused
 	ret c
 
 	ld a, [PlayerHPPal]
@@ -259,7 +259,7 @@
 	ret
 ; 4e794
 
-Function4e794: ; 4e794
+.check_statused: ; 4e794
 	ld a, [CurPartyMon]
 	ld hl, PartyMon1Species
 	call GetPartyLocation
@@ -269,7 +269,7 @@
 	ret
 ; 4e7a6
 
-Function4e7a6: ; 4e7a6
+.PlayEvolvedSFX: ; 4e7a6
 	ld a, [Buffer4]
 	and a
 	ret nz
@@ -279,24 +279,24 @@
 	ld a, [hl]
 	push af
 	ld [hl], $0
-.loop
-	call Function4e7cf
+.loop4
+	call .balls_of_light
 	jr nc, .done
-	call Function4e80c
-	jr .loop
+	call .AnimateBallsOfLight
+	jr .loop4
 
 .done
 	ld c, 32
-.loop2
-	call Function4e80c
+.loop5
+	call .AnimateBallsOfLight
 	dec c
-	jr nz, .loop2
+	jr nz, .loop5
 	pop af
 	ld [wJumptableIndex], a
 	ret
 ; 4e7cf
 
-Function4e7cf: ; 4e7cf
+.balls_of_light: ; 4e7cf
 	ld hl, wJumptableIndex
 	ld a, [hl]
 	cp 32
@@ -304,45 +304,45 @@
 	ld d, a
 	inc [hl]
 	and $1
-	jr nz, .asm_4e7e6
+	jr nz, .done_balls
 	ld e, $0
-	call Function4e7e8
+	call .GenerateBallOfLight
 	ld e, $10
-	call Function4e7e8
+	call .GenerateBallOfLight
 
-.asm_4e7e6
+.done_balls
 	scf
 	ret
 ; 4e7e8
 
-Function4e7e8: ; 4e7e8
+.GenerateBallOfLight: ; 4e7e8
 	push de
 	depixel 9, 11
 	ld a, SPRITE_ANIM_INDEX_13
 	call _InitSpriteAnimStruct
-	ld hl, $b
+	ld hl, SPRITEANIMSTRUCT_0B
 	add hl, bc
 	ld a, [wJumptableIndex]
-	and $e
+	and %1110
 	sla a
 	pop de
 	add e
 	ld [hl], a
-	ld hl, $3
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
 	add hl, bc
 	ld [hl], $0
-	ld hl, $c
+	ld hl, SPRITEANIMSTRUCT_0C
 	add hl, bc
 	ld [hl], $10
 	ret
 ; 4e80c
 
-Function4e80c: ; 4e80c
+.AnimateBallsOfLight: ; 4e80c
 	push bc
 	callab PlaySpriteAnimations
 	; a = (([hVBlankCounter] + 4) / 2) % NUM_PALETTES
 	ld a, [hVBlankCounter]
-	and $e
+	and %1110
 	srl a
 rept 2
 	inc a
@@ -351,7 +351,7 @@
 	ld b, a
 	ld hl, Sprites + 3 ; attributes
 	ld c, 40
-.loop
+.loop6
 	ld a, [hl]
 	or b
 	ld [hli], a
@@ -359,7 +359,7 @@
 	inc hl
 endr
 	dec c
-	jr nz, .loop
+	jr nz, .loop6
 	pop bc
 	call DelayFrame
 	ret
@@ -366,6 +366,6 @@
 ; 4e831
 
 
-EvolutionGFX:
+.GFX:
 INCBIN "gfx/evo/bubble_large.2bpp"
 INCBIN "gfx/evo/bubble.2bpp"
--- /dev/null
+++ b/engine/init_gender.asm
@@ -1,0 +1,115 @@
+InitCrystalData: ; 48000
+	ld a, $1
+	ld [wd474], a
+	xor a
+	ld [wd473], a
+	ld [PlayerGender], a
+	ld [wd475], a
+	ld [wd476], a
+	ld [wd477], a
+	ld [wd478], a
+	ld [wd002], a
+	ld [wd003], a
+	; could have done "ld a, [wd479] \ and %11111100", saved four operations
+	ld a, [wd479]
+	res 0, a
+	ld [wd479], a
+	ld a, [wd479]
+	res 1, a
+	ld [wd479], a
+	ret
+; 4802f
+
+INCLUDE "misc/mobile_12.asm"
+
+InitGender: ; 48dcb (12:4dcb)
+	call InitGenderScreen
+	call LoadGenderScreenPal
+	call LoadGenderScreenLightBlueTile
+	call WaitBGMap2
+	call SetPalettes
+	ld hl, TextJump_AreYouABoyOrAreYouAGirl
+	call PrintText
+	ld hl, .MenuDataHeader
+	call LoadMenuDataHeader
+	call WaitBGMap2
+	call InterpretMenu2
+	call WriteBackup
+	ld a, [MenuSelection2]
+	dec a
+	ld [PlayerGender], a
+	ld c, 10
+	call DelayFrames
+	ret
+; 48dfc (12:4dfc)
+
+.MenuDataHeader: ; 0x48dfc
+	db $40 ; flags
+	db 04, 06 ; start coords
+	db 09, 12 ; end coords
+	dw .MenuData2
+	db 1 ; default option
+; 0x48e04
+
+.MenuData2: ; 0x48e04
+	db $a1 ; flags
+	db 2 ; items
+	db "Boy@"
+	db "Girl@"
+; 0x48e0f
+
+TextJump_AreYouABoyOrAreYouAGirl: ; 0x48e0f
+	; Are you a boy? Or are you a girl?
+	text_jump Text_AreYouABoyOrAreYouAGirl
+	db "@"
+; 0x48e14
+
+InitGenderScreen: ; 48e14 (12:4e14)
+	ld a, $10
+	ld [MusicFade], a
+	ld a, $0
+	ld [MusicFadeIDLo], a
+	ld a, $0
+	ld [MusicFadeIDHi], a
+	ld c, 8
+	call DelayFrames
+	call ClearBGPalettes
+	call InitCrystalData
+	call LoadFontsExtra
+	hlcoord 0, 0
+	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+	ld a, $0
+	call ByteFill
+	hlcoord 0, 0, AttrMap
+	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+	xor a
+	call ByteFill
+	ret
+
+LoadGenderScreenPal: ; 48e47 (12:4e47)
+	ld hl, .Palette
+	ld de, UnknBGPals
+	ld bc, 1 palettes
+	ld a, $5
+	call FarCopyWRAM
+	callba Function96a4
+	ret
+; 48e5c (12:4e5c)
+
+.Palette: ; 48e5c
+	RGB 31, 31, 31
+	RGB 09, 30, 31
+	RGB 01, 11, 31
+	RGB 00, 00, 00
+; 48e64
+
+LoadGenderScreenLightBlueTile: ; 48e64 (12:4e64)
+	ld de, .LightBlueTile
+	ld hl, VTiles2 tile $00
+	lb bc, BANK(.LightBlueTile), 1
+	call Get2bpp
+	ret
+; 48e71 (12:4e71)
+
+.LightBlueTile: ; 48e71
+INCBIN "gfx/intro/gender_screen.2bpp"
--- a/engine/intro_menu.asm
+++ b/engine/intro_menu.asm
@@ -353,7 +353,7 @@
 Continue: ; 5d65
 	callba TryLoadSaveFile
 	jr c, .FailToLoad
-	callba Function150b9
+	callba _LoadData
 	call LoadStandardMenuDataHeader
 	call DisplaySaveInfoOnContinue
 	ld a, $1
--- a/engine/main_menu.asm
+++ b/engine/main_menu.asm
@@ -556,7 +556,7 @@
 	ld bc, $6
 	call CopyBytes
 	call CloseSRAM
-	callba Function150b9
+	callba _LoadData
 	ld c, 2
 	call DelayFrames
 	ld c, $1
--- a/engine/mysterygift.asm
+++ b/engine/mysterygift.asm
@@ -15,7 +15,9 @@
 	ld [wca02], a
 	ld a, [rIE]
 	push af
+
 	call Function104a95
+
 	ld d, a
 	xor a
 	ld [rIF], a
@@ -37,7 +39,7 @@
 	cp $6c
 	jp nz, .CommunicationError
 	ld a, [wc900]
-	cp $3
+	cp 3
 	jr z, .skip_checks
 	call .CheckAlreadyGotFiveGiftsToday
 	ld hl, .Text_MaxFiveGifts ; Only 5 gifts a day
@@ -46,7 +48,7 @@
 	ld hl, .Text_MaxOneGiftPerPerson ; Only one gift a day per person
 	jp c, .PrintTextAndExit
 .skip_checks
-	ld a, [wc962]
+	ld a, [wMysteryGiftPlayerBackupItem]
 	and a
 	jp nz, .GiftWaiting
 	ld a, [wc912]
@@ -53,11 +55,11 @@
 	and a
 	jp nz, .FriendNotReady
 	ld a, [wc900]
-	cp $3
+	cp 3
 	jr z, .skip_append_save
 	call .AddMysteryGiftPartnerID
 	ld a, [wc900]
-	cp $4
+	cp 4
 	jr z, .skip_append_save
 	call .SaveMysteryGiftTrainerName
 	callba RestoreMobileEventIndex
@@ -64,10 +66,10 @@
 	callba MobileFn_1060a9
 	callba BackupMobileEventIndex
 .skip_append_save
-	ld a, [wc90f]
+	ld a, [wMysteryGiftPartnerSentDeco]
 	and a
 	jr z, .item
-	ld a, [wc911]
+	ld a, [wMysteryGiftPartnerWhichDeco]
 	ld c, a
 	callba MysteryGiftGetDecoration
 	push bc
@@ -85,7 +87,7 @@
 
 .item
 	call GetMysteryGiftBank
-	ld a, [wc910]
+	ld a, [wMysteryGiftPartnerWhichItem]
 	ld c, a
 	callba MysteryGiftGetItemHeldEffect
 	ld a, c
@@ -249,7 +251,7 @@
 	ld a, [hPrintNum9]
 	cp $2
 	jr z, Function104b22
-	ld hl, $ffb3
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d56
 	jr nz, .ly_loop
@@ -323,7 +325,7 @@
 	jp Function104bd0
 
 Function104b40: ; 104b40 (41:4b40)
-	ld hl, $ffb3
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d56
 	ret nz
@@ -333,14 +335,14 @@
 	ld a, [hPrintNum10]
 	cp $6c
 	ret nz
-	ld a, [$ffb3]
+	ld a, [hPrintNum1]
 	cp $96
 	jp nz, Function104d32
 	ld a, $90
-	ld [$ffb3], a
+	ld [hPrintNum1], a
 	call Function104d38
 	ret nz
-	ld hl, $ffb3
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d4e
 	ret nz
@@ -362,8 +364,8 @@
 
 Function104b88: ; 104b88 (41:4b88)
 	ld a, $96
-	ld [$ffb3], a
-	ld hl, $ffb3
+	ld [hPrintNum1], a
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d4e
 	ret nz
@@ -373,7 +375,7 @@
 	ret nz
 	call Function104d43
 	ret nz
-	ld hl, $ffb3
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d56
 	ret nz
@@ -381,7 +383,7 @@
 	ld a, [hPrintNum10]
 	cp $6c
 	ret nz
-	ld a, [$ffb3]
+	ld a, [hPrintNum1]
 	cp $90
 	jp nz, Function104d32
 	call Function104d38
@@ -407,13 +409,13 @@
 	dec [hl]
 	jr z, .asm_104c18
 	ld hl, wMysteryGiftTrainerData
-	ld de, wc900
-	ld bc, $14
+	ld de, wMysteryGiftPartnerData
+	ld bc, wMysteryGiftPartnerDataEnd - wMysteryGiftPartnerData
 	call CopyBytes
 	ld a, [wMysteryGiftTrainerData]
 	cp $3
 	jr nc, .asm_104c18
-	callba Function10510b
+	callba StagePartyDataForMysteryGift
 	call Function1050fb
 	ld a, $26
 	ld [wca02], a
@@ -479,7 +481,7 @@
 	jp Function104d1c
 
 Function104c8a: ; 104c8a (41:4c8a)
-	ld hl, $ffb3
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d56
 	ret nz
@@ -487,14 +489,14 @@
 	ld a, [hPrintNum10]
 	cp $6c
 	ret nz
-	ld a, [$ffb3]
+	ld a, [hPrintNum1]
 	cp $3c
 	jp nz, Function104d32
 	swap a
-	ld [$ffb3], a
+	ld [hPrintNum1], a
 	call Function104d38
 	ret nz
-	ld hl, $ffb3
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d4e
 	ret nz
@@ -516,8 +518,8 @@
 
 Function104cd2: ; 104cd2 (41:4cd2)
 	ld a, $3c
-	ld [$ffb3], a
-	ld hl, $ffb3
+	ld [hPrintNum1], a
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d4e
 	ret nz
@@ -527,7 +529,7 @@
 	ret nz
 	call Function104d43
 	ret nz
-	ld hl, $ffb3
+	ld hl, hPrintNum1
 	ld b, $1
 	call Function104d56
 	ret nz
@@ -535,7 +537,7 @@
 	ld a, [hPrintNum10]
 	cp $6c
 	ret nz
-	ld a, [$ffb3]
+	ld a, [hPrintNum1]
 	swap a
 	cp $3c
 	jp nz, Function104d32
@@ -1196,29 +1198,35 @@
 ; 10510b
 
 
-Function10510b: ; 10510b (41:510b)
+StagePartyDataForMysteryGift: ; 10510b (41:510b)
+; You will be sending this data to your mystery gift partner.
+; Structure is the same as a trainer with species and moves
+; defined.
 	ld a, BANK(sPokemonData)
 	call GetSRAMBank
-	ld de, OverworldMap
+	ld de, wMysteryGiftStaging
 	ld bc, sPokemonData + PartyMons - wPokemonData
 	ld hl, sPokemonData + PartySpecies - wPokemonData
-.asm_105119
+.loop
 	ld a, [hli]
-	cp $ff
-	jr z, .asm_105148
+	cp -1
+	jr z, .party_end
 	cp EGG
-	jr z, .asm_10513e
+	jr z, .next
 	push hl
+	; copy level
 	ld hl, MON_LEVEL
 	add hl, bc
 	ld a, [hl]
 	ld [de], a
 	inc de
+	; copy species
 	ld hl, MON_SPECIES
 	add hl, bc
 	ld a, [hl]
 	ld [de], a
 	inc de
+	; copy moves
 	ld hl, MON_MOVES
 	add hl, bc
 	push bc
@@ -1226,7 +1234,7 @@
 	call CopyBytes
 	pop bc
 	pop hl
-.asm_10513e
+.next
 	push hl
 	ld hl, PARTYMON_STRUCT_LENGTH
 	add hl, bc
@@ -1233,9 +1241,9 @@
 	ld b, h
 	ld c, l
 	pop hl
-	jr .asm_105119
-.asm_105148
-	ld a, $ff
+	jr .loop
+.party_end
+	ld a, -1
 	ld [de], a
 	ld a, $26
 	ld [wca00], a
@@ -1247,7 +1255,7 @@
 	ld hl, MysteryGiftGFX
 	ld de, VTiles2 tile $00
 	ld a, BANK(MysteryGiftGFX)
-	ld bc, Function105688 - MysteryGiftGFX
+	ld bc, MysteryGiftGFXEnd - MysteryGiftGFX
 	call FarCopyBytes
 	hlcoord 0, 0
 	ld a, $42
@@ -1268,13 +1276,13 @@
 	ld [hl], a
 	hlcoord 7, 1
 	ld a, $12
-	call Function10522e
+	call .Load5GFX
 	hlcoord 2, 2
 	ld a, $17
-	call Function105236
+	call .Load16GFX
 	hlcoord 2, 3
 	ld a, $27
-	call Function105236
+	call .Load16GFX
 	hlcoord 9, 4
 	ld a, $37
 	ld [hli], a
@@ -1284,19 +1292,19 @@
 	ld [hl], $4
 	hlcoord 1, 3
 	ld a, $5
-	call Function105246
+	call .Load14Column
 	ld a, $9
 	hlcoord 18, 5
-	call Function105242
+	call .Load11Column
 	hlcoord 2, 5
 	ld a, $b
-	call Function105251
+	call .Load16Row
 	hlcoord 2, 16
 	ld a, $7
-	call Function105251
+	call .Load16Row
 	hlcoord 2, 5
 	ld a, $d
-	call Function10522e
+	call .Load5GFX
 	hlcoord 7, 5
 	ld [hl], $c
 	hlcoord 18, 5
@@ -1307,16 +1315,16 @@
 	ld [hl], $6
 	hlcoord 2, 6
 	ld a, $3a
-	call Function105251
+	call .Load16Row
 	hlcoord 2, 15
 	ld a, $40
-	call Function105251
+	call .Load16Row
 	hlcoord 2, 6
 	ld a, $3c
-	call Function10523e
+	call .Load9Column
 	hlcoord 17, 6
 	ld a, $3e
-	call Function10523e
+	call .Load9Column
 	hlcoord 2, 6
 	ld [hl], $39
 	hlcoord 17, 6
@@ -1332,56 +1340,56 @@
 	call SetPalettes
 	ret
 
-Function10522e: ; 10522e (41:522e)
-	ld b, $5
-	jr asm_105238
+.Load5GFX: ; 10522e (41:522e)
+	ld b,  5
+	jr .gfx_loop
 ; 105232 (41:5232)
 
-Function105232: ; unreferenced
-	ld b, 6
-	jr asm_105238
+.Load6GFX: ; unreferenced
+	ld b,  6
+	jr .gfx_loop
 
-Function105236: ; 105236 (41:5236)
-	ld b, $10
+.Load16GFX: ; 105236 (41:5236)
+	ld b, 16
 
-asm_105238: ; 105238 (41:5238)
+.gfx_loop: ; 105238 (41:5238)
 	ld [hli], a
 	inc a
 	dec b
-	jr nz, asm_105238
+	jr nz, .gfx_loop
 	ret
 
-Function10523e: ; 10523e (41:523e)
-	ld b, $9
-	jr asm_105248
+.Load9Column: ; 10523e (41:523e)
+	ld b,  9
+	jr .col_loop
 
-Function105242: ; 105242 (41:5242)
-	ld b, $b
-	jr asm_105248
+.Load11Column: ; 105242 (41:5242)
+	ld b, 11
+	jr .col_loop
 
-Function105246: ; 105246 (41:5246)
-	ld b, $e
+.Load14Column: ; 105246 (41:5246)
+	ld b, 14
 
-asm_105248: ; 105248 (41:5248)
+.col_loop: ; 105248 (41:5248)
 	ld [hl], a
-	ld de, $14
+	ld de, SCREEN_WIDTH
 	add hl, de
 	dec b
-	jr nz, asm_105248
+	jr nz, .col_loop
 	ret
 
-Function105251: ; 105251 (41:5251)
-	ld b, $10
-.asm_105253
+.Load16Row: ; 105251 (41:5251)
+	ld b, 16
+.row_loop
 	ld [hli], a
 	dec b
-	jr nz, .asm_105253
+	jr nz, .row_loop
 	ret
 
 MysteryGiftGFX: ; 105258
 INCBIN "gfx/misc/mystery_gift.2bpp"
+MysteryGiftGFXEnd:
 
-
 Function105688: ; 105688 (41:5688)
 	call ClearTileMap
 	call ClearSprites
@@ -1412,15 +1420,15 @@
 	ld c, 60
 	call DelayFrames
 	call Function105777
-	ld hl, Text_10575e
+	ld hl, Text_ReceivedCard
 	call PrintText
 	ld de, wMysteryGiftTrainerData
 	callba Function8ac70
 	ld a, c
 	ld [wd265], a
-	ld hl, Text_105768
+	ld hl, Text_CardNotRegistered
 	jr c, asm_105726
-	ld hl, Text_105763
+	ld hl, Text_ListedCardAsNumber
 	jr asm_105726
 
 Function1056eb: ; 1056eb (41:56eb)
@@ -1454,12 +1462,12 @@
 
 Function105712: ; 105712 (41:5712)
 	call Function105777
-	ld hl, Text_10576d
+	ld hl, Text_MGLinkCanceled
 	jr asm_105726
 
 Function10571a: ; 10571a (41:571a)
 	call Function105777
-	ld hl, Text_105772
+	ld hl, Text_MGCommError
 	call PrintText
 	jp Function105688
 
@@ -1472,7 +1480,7 @@
 
 String_10572e: ; 10572e
 	db   "エーボタン¯おすと"
-	next "つうしん",   $4a, "おこなわれるよ!"
+	next "つうしん<PKMN>おこなわれるよ!"
 	next "ビーボタン¯おすと"
 	next "つうしん¯ちゅうし します"
 	db   "@"
@@ -1479,23 +1487,23 @@
 
 ; 10575e
 
-Text_10575e: ; 10575e
+Text_ReceivedCard: ; 10575e
 	text_jump UnknownText_0x1c051a
 	db "@"
 
-Text_105763: ; 105763
+Text_ListedCardAsNumber: ; 105763
 	text_jump UnknownText_0x1c0531
 	db "@"
 
-Text_105768: ; 105768
+Text_CardNotRegistered: ; 105768
 	text_jump UnknownText_0x1c0555
 	db "@"
 
-Text_10576d: ; 10576d
+Text_MGLinkCanceled: ; 10576d
 	text_jump UnknownText_0x1c0573
 	db "@"
 
-Text_105772: ; 105772
+Text_MGCommError: ; 105772
 	text_jump UnknownText_0x1c0591
 	db "@"
 ; 105777
@@ -1572,30 +1580,30 @@
 	ld [hl], a
 	hlcoord 4, 2
 	ld a, $13
-	call Function1058ca
+	call .Load11Row
 	hlcoord 4, 3
 	ld a, $1e
-	call Function1058ce
+	call .Load12Row
 	hlcoord 4, 4
 	ld a, $2a
-	call Function1058ce
+	call .Load12Row
 	hlcoord 1, 2
 	ld [hl], $4
 	hlcoord 1, 3
 	ld a, $5
-	call Function1058de
+	call .Load14Column
 	ld a, $9
 	hlcoord 18, 5
-	call Function1058da
+	call .Load11Column
 	hlcoord 2, 5
 	ld a, $b
-	call Function1058e9
+	call .Load16Row
 	hlcoord 2, 16
 	ld a, $7
-	call Function1058e9
+	call .Load16Row
 	hlcoord 2, 5
 	ld a, $d
-	call Function1058c6
+	call .Load6Row
 	hlcoord 8, 5
 	ld [hl], $c
 	hlcoord 18, 5
@@ -1606,16 +1614,16 @@
 	ld [hl], $6
 	hlcoord 2, 6
 	ld a, $37
-	call Function1058e9
+	call .Load16Row
 	hlcoord 2, 15
 	ld a, $3d
-	call Function1058e9
+	call .Load16Row
 	hlcoord 2, 6
 	ld a, $39
-	call Function1058d6
+	call .Load9Column
 	hlcoord 17, 6
 	ld a, $3b
-	call Function1058d6
+	call .Load9Column
 	hlcoord 2, 6
 	ld [hl], $36
 	hlcoord 17, 6
@@ -1625,7 +1633,7 @@
 	hlcoord 17, 15
 	ld [hl], $3e
 	ld de, Sprites
-	ld hl, OAM_1058f0
+	ld hl, .OAM_data
 	ld bc, $40
 	call CopyBytes
 	call EnableLCD
@@ -1634,69 +1642,69 @@
 	callba Function4930f
 	jp SetPalettes
 
-Function1058c6: ; 1058c6 (41:58c6)
-	ld b, $6
-	jr asm_1058d0
+.Load6Row: ; 1058c6 (41:58c6)
+	ld b,  6
+	jr .row_loop
 
-Function1058ca: ; 1058ca (41:58ca)
-	ld b, $b
-	jr asm_1058d0
+.Load11Row: ; 1058ca (41:58ca)
+	ld b, 11
+	jr .row_loop
 
-Function1058ce: ; 1058ce (41:58ce)
-	ld b, $c
+.Load12Row: ; 1058ce (41:58ce)
+	ld b, 12
 
-asm_1058d0: ; 1058d0 (41:58d0)
+.row_loop: ; 1058d0 (41:58d0)
 	ld [hli], a
 	inc a
 	dec b
-	jr nz, asm_1058d0
+	jr nz, .row_loop
 	ret
 
-Function1058d6: ; 1058d6 (41:58d6)
-	ld b, $9
-	jr asm_1058e0
+.Load9Column: ; 1058d6 (41:58d6)
+	ld b,  9
+	jr .column_loop
 
-Function1058da: ; 1058da (41:58da)
-	ld b, $b
-	jr asm_1058e0
+.Load11Column: ; 1058da (41:58da)
+	ld b, 11
+	jr .column_loop
 
-Function1058de: ; 1058de (41:58de)
-	ld b, $e
+.Load14Column: ; 1058de (41:58de)
+	ld b, 14
 
-asm_1058e0: ; 1058e0 (41:58e0)
+.column_loop: ; 1058e0 (41:58e0)
 	ld [hl], a
 	ld de, SCREEN_WIDTH
 	add hl, de
 	dec b
-	jr nz, asm_1058e0
+	jr nz, .column_loop
 	ret
 
-Function1058e9: ; 1058e9 (41:58e9)
-	ld b, $10
-.asm_1058eb
+.Load16Row: ; 1058e9 (41:58e9)
+	ld b, 16
+.row_loop_no_inc
 	ld [hli], a
 	dec b
-	jr nz, .asm_1058eb
+	jr nz, .row_loop_no_inc
 	ret
 ; 1058f0 (41:58f0)
 
-OAM_1058f0: ; 1058f0
-	db $11, $34, $00, $00
-	db $11, $3c, $01, $00
-	db $11, $44, $02, $00
-	db $11, $4c, $03, $00
-	db $19, $34, $04, $00
-	db $19, $3c, $05, $00
-	db $19, $44, $06, $00
-	db $19, $4c, $07, $00
-	db $01, $5c, $00, $00
-	db $01, $64, $01, $00
-	db $01, $6c, $02, $00
-	db $01, $74, $03, $00
-	db $09, $5c, $04, $00
-	db $09, $64, $05, $00
-	db $09, $6c, $06, $00
-	db $09, $74, $07, $00
+.OAM_data: ; 1058f0
+	dsprite  2, 1,  6, 4, $00, $00
+	dsprite  2, 1,  7, 4, $01, $00
+	dsprite  2, 1,  8, 4, $02, $00
+	dsprite  2, 1,  9, 4, $03, $00
+	dsprite  3, 1,  6, 4, $04, $00
+	dsprite  3, 1,  7, 4, $05, $00
+	dsprite  3, 1,  8, 4, $06, $00
+	dsprite  3, 1,  9, 4, $07, $00
+	dsprite  0, 1, 11, 4, $00, $00
+	dsprite  0, 1, 12, 4, $01, $00
+	dsprite  0, 1, 13, 4, $02, $00
+	dsprite  0, 1, 14, 4, $03, $00
+	dsprite  1, 1, 11, 4, $04, $00
+	dsprite  1, 1, 12, 4, $05, $00
+	dsprite  1, 1, 13, 4, $06, $00
+	dsprite  1, 1, 14, 4, $07, $00
 
 ; japanese mystery gift gfx
 MysteryGiftJP_GFX: ; 105930
--- a/engine/mysterygift2.asm
+++ b/engine/mysterygift2.asm
@@ -1,8 +1,8 @@
 Function2c642: ; 2c642 (b:4642)
-	ld de, wc800
+	ld de, wMysteryGiftStaging
 	ld a, $1
 	ld [de], a
-	inc de
+	inc de ; wc801
 	ld a, BANK(sGameData)
 	call GetSRAMBank
 	ld hl, sPlayerData + PlayerID - wPlayerData
@@ -13,34 +13,34 @@
 	ld a, [hl]
 	ld [de], a
 	ld c, a
-	inc de
+	inc de ; wc803
 	push bc
 	ld hl, sPlayerData + PlayerName - wPlayerData
 	ld bc, NAME_LENGTH
 	call CopyBytes
-	push de
+	push de ; wc80e
 	ld hl, sPokemonData + PokedexCaught - wPokemonData
-	ld b, (NUM_POKEMON + 7) / 8
+	ld b, EndPokedexCaught - PokedexCaught
 	call CountSetBits
 	pop de
 	pop bc
 	ld a, [wd265]
 	ld [de], a
-	inc de
+	inc de ; wc80f
 	call CloseSRAM
 	call Random
 	and $1
 	ld [de], a
-	inc de
-	call Function2c6ac
+	inc de ; wc810
+	call .RandomSample
 	ld [de], a
-	inc de
+	inc de ; wc811
 	ld a, c
 	ld c, b
 	ld b, a
-	call Function2c6ac
+	call .RandomSample
 	ld [de], a
-	inc de
+	inc de ; wc812
 	ld a, BANK(sBackupMysteryGiftItem)
 	call GetSRAMBank
 	ld a, [sBackupMysteryGiftItem]
@@ -51,12 +51,12 @@
 	ld a, $14
 	ld [wca00], a
 	call CloseSRAM
-	ld hl, wc800
-	ld de, wc950
-	ld bc, $14
+	ld hl, wMysteryGiftStaging
+	ld de, wMysteryGiftPlayerData
+	ld bc, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData
 	jp CopyBytes
 
-Function2c6ac: ; 2c6ac (b:46ac)
+.RandomSample: ; 2c6ac (b:46ac)
 	push de
 	call Random
 	cp $19 ; 10 percent
@@ -124,8 +124,8 @@
 MysteryGiftGetItemHeldEffect: ; 2c708 (b:4708)
 	ld a, c
 	cp $25 ; 37
-	jr nc, Function2c722
-	ld hl, Unknown_2c725
+	jr nc, MysteryGiftFallbackItem
+	ld hl, MysteryGiftItems
 	ld b, 0
 	add hl, bc
 	ld c, [hl]
@@ -134,20 +134,19 @@
 MysteryGiftGetDecoration: ; 2c715 (b:4715)
 	ld a, c
 	cp $25 ; 37
-	jr nc, Function2c722
-	ld hl, Unknown_2c74a
+	jr nc, MysteryGiftFallbackItem
+	ld hl, MysteryGiftDecos
 	ld b, 0
 	add hl, bc
 	ld c, [hl]
 	ret
 
-Function2c722: ; 2c722 (b:4722)
+MysteryGiftFallbackItem: ; 2c722 (b:4722)
 	ld c, DECO_POLKADOT_BED ; GREAT_BALL
 	ret
 ; 2c725 (b:4725)
 
-Unknown_2c725: ; 2c725
-; May or may not be items.
+MysteryGiftItems: ; 2c725
 	db BERRY
 	db PRZCUREBERRY
 	db MINT_BERRY
@@ -187,8 +186,7 @@
 	db MIRAGE_MAIL
 ; 2c74a
 
-Unknown_2c74a: ; 2c74a
-; May or may not be items.
+MysteryGiftDecos: ; 2c74a
 	db DECO_SNES
 	db DECO_BIG_SNORLAX_DOLL
 	db DECO_BIG_ONIX_DOLL
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -892,7 +892,7 @@
 	jp CloseSRAM
 
 
-Function150b9: ; 150b9
+_LoadData: ; 150b9
 	ld a, BANK(sCrystalData)
 	call GetSRAMBank
 	ld hl, sCrystalData
@@ -938,8 +938,11 @@
 ; 150f9
 
 SaveBoxAddress: ; 150f9
+; Save box via wMisc.
+; We do this in three steps because the size of wMisc is less than
+; the size of sBox.
 	push hl
-
+; Load the first part of the active box.
 	push af
 	push de
 	ld a, BANK(sBox)
@@ -951,7 +954,7 @@
 	call CloseSRAM
 	pop de
 	pop af
-
+; Save it to the target box.
 	push af
 	push de
 	call GetSRAMBank
@@ -959,6 +962,8 @@
 	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
+
+; Load the second part of the active box.
 	ld a, BANK(sBox)
 	call GetSRAMBank
 	ld hl, sBox + (wMiscEnd - wMisc)
@@ -973,7 +978,7 @@
 	add hl, de
 	ld e, l
 	ld d, h
-
+; Save it to the next part of the target box.
 	push af
 	push de
 	call GetSRAMBank
@@ -981,6 +986,8 @@
 	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
+
+; Load the third and final part of the active box.
 	ld a, BANK(sBox)
 	call GetSRAMBank
 	ld hl, sBox + (wMiscEnd - wMisc) * 2
@@ -995,7 +1002,7 @@
 	add hl, de
 	ld e, l
 	ld d, h
-
+; Save it to the final part of the target box.
 	call GetSRAMBank
 	ld hl, wMisc
 	ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
@@ -1008,10 +1015,13 @@
 
 
 LoadBoxAddress: ; 1517d (5:517d)
+; Load box via wMisc.
+; We do this in three steps because the size of wMisc is less than
+; the size of sBox.
 	push hl
 	ld l, e
 	ld h, d
-
+; Load part 1
 	push af
 	push hl
 	call GetSRAMBank
@@ -1031,7 +1041,7 @@
 
 	ld de, (wMiscEnd - wMisc)
 	add hl, de
-
+; Load part 2
 	push af
 	push hl
 	call GetSRAMBank
@@ -1048,7 +1058,7 @@
 	call CloseSRAM
 	pop hl
 	pop af
-
+; Load part 3
 	ld de, (wMiscEnd - wMisc)
 	add hl, de
 	call GetSRAMBank
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -3211,7 +3211,7 @@
 	callba HallOfFame
 	ld hl, GameTimerPause
 	set 0, [hl]
-	jr DisplayCredits
+	jr ReturnFromCredits
 ; 97bf3
 
 Script_credits: ; 97bf3
@@ -3218,7 +3218,7 @@
 ; script command 0xa2
 
 	callba RedCredits
-DisplayCredits:
+ReturnFromCredits:
 	call Script_end_all
 	ld a, $3
 	call LoadMapStatus
--- a/engine/timeofdaypals.asm
+++ b/engine/timeofdaypals.asm
@@ -125,7 +125,7 @@
 ; 8c084
 
 FadeOutPalettes:: ; 8c084
-	call Function8c0c1
+	call FillWhiteBGColor
 	ld c, $9
 	call GetTimePalFade
 	ld b, $4
@@ -134,7 +134,7 @@
 ; 8c092
 
 Special_BattleTowerFade: ; 8c092
-	call Function8c0c1
+	call FillWhiteBGColor
 	ld c, $9
 	call GetTimePalFade
 	ld b, $4
@@ -167,19 +167,20 @@
 ; 8c0c1
 
 
-Function8c0c1: ; 8c0c1
+FillWhiteBGColor: ; 8c0c1
 	ld a, [rSVBK]
 	push af
 	ld a, $5
 	ld [rSVBK], a
+
 	ld hl, UnknBGPals
 	ld a, [hli]
 	ld e, a
 	ld a, [hli]
 	ld d, a
-	ld hl, UnknBGPals + 8
-	ld c, $6
-.asm_8c0d4
+	ld hl, UnknBGPals + 1 palettes
+	ld c, 6
+.loop
 	ld a, e
 	ld [hli], a
 	ld a, d
@@ -188,7 +189,8 @@
 	inc hl
 endr
 	dec c
-	jr nz, .asm_8c0d4
+	jr nz, .loop
+
 	pop af
 	ld [rSVBK], a
 	ret
@@ -200,7 +202,7 @@
 
 ReplaceTimeOfDayPals: ; 8c0e5
 	ld hl, .BrightnessLevels
-	ld a, [wc2d0]
+	ld a, [wMapTimeOfDay]
 	cp $4 ; Dark cave, needs Flash
 	jr z, .DarkCave
 	and $7
@@ -306,7 +308,7 @@
 rept 3
 	inc hl
 endr
-	ld c, $2
+	ld c, 2
 	call DelayFrames
 	dec b
 	jr nz, .loop
@@ -319,7 +321,7 @@
 rept 3
 	dec hl
 endr
-	ld c, $2
+	ld c, 2
 	call DelayFrames
 	dec b
 	jr nz, .loop
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -7,13 +7,12 @@
 	call ResetBikeFlags
 	ld a, $5
 	call RunMapCallback
-
 RunCallback_03: ; 1045c4
 	callba ClearCmdQueue
 	ld a, $3
 	call RunMapCallback
 	call GetMapHeaderTimeOfDayNybble
-	ld [wc2d0], a
+	ld [wMapTimeOfDay], a
 	ret
 
 
binary files /dev/null b/gfx/intro/gender_screen.2bpp differ
binary files a/gfx/unknown/048e71.2bpp /dev/null differ
--- a/main.asm
+++ b/main.asm
@@ -10788,124 +10788,10 @@
 
 INCLUDE "engine/mail.asm"
 
-SECTION "bank12", ROMX, BANK[$12]
+SECTION "Crystal Unique", ROMX, BANK[$12]
 
-Function48000: ; 48000
-	ld a, $1
-	ld [wd474], a
-	xor a
-	ld [wd473], a
-	ld [PlayerGender], a
-	ld [wd475], a
-	ld [wd476], a
-	ld [wd477], a
-	ld [wd478], a
-	ld [wd002], a
-	ld [wd003], a
-	; could have done "ld a, [wd479] \ and %11111100", saved four operations
-	ld a, [wd479]
-	res 0, a
-	ld [wd479], a
-	ld a, [wd479]
-	res 1, a
-	ld [wd479], a
-	ret
-; 4802f
+INCLUDE "engine/init_gender.asm"
 
-INCLUDE "misc/mobile_12.asm"
-
-InitGender: ; 48dcb (12:4dcb)
-	call Function48e14
-	call Function48e47
-	call Function48e64
-	call WaitBGMap2
-	call SetPalettes
-	ld hl, TextJump_AreYouABoyOrAreYouAGirl
-	call PrintText
-	ld hl, .MenuDataHeader
-	call LoadMenuDataHeader
-	call WaitBGMap2
-	call InterpretMenu2
-	call WriteBackup
-	ld a, [MenuSelection2]
-	dec a
-	ld [PlayerGender], a
-	ld c, 10
-	call DelayFrames
-	ret
-; 48dfc (12:4dfc)
-
-.MenuDataHeader: ; 0x48dfc
-	db $40 ; flags
-	db 04, 06 ; start coords
-	db 09, 12 ; end coords
-	dw .MenuData2
-	db 1 ; default option
-; 0x48e04
-
-.MenuData2: ; 0x48e04
-	db $a1 ; flags
-	db 2 ; items
-	db "Boy@"
-	db "Girl@"
-; 0x48e0f
-
-TextJump_AreYouABoyOrAreYouAGirl: ; 0x48e0f
-	; Are you a boy? Or are you a girl?
-	text_jump Text_AreYouABoyOrAreYouAGirl
-	db "@"
-; 0x48e14
-
-Function48e14: ; 48e14 (12:4e14)
-	ld a, $10
-	ld [MusicFade], a
-	ld a, $0
-	ld [MusicFadeIDLo], a
-	ld a, $0
-	ld [MusicFadeIDHi], a
-	ld c, 8
-	call DelayFrames
-	call ClearBGPalettes
-	call Function48000
-	call LoadFontsExtra
-	hlcoord 0, 0
-	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
-	ld a, $0
-	call ByteFill
-	hlcoord 0, 0, AttrMap
-	ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
-	xor a
-	call ByteFill
-	ret
-
-Function48e47: ; 48e47 (12:4e47)
-	ld hl, Palette_48e5c
-	ld de, UnknBGPals
-	ld bc, $8
-	ld a, $5
-	call FarCopyWRAM
-	callba Function96a4
-	ret
-; 48e5c (12:4e5c)
-
-Palette_48e5c: ; 48e5c
-	RGB 31, 31, 31
-	RGB 09, 30, 31
-	RGB 01, 11, 31
-	RGB 00, 00, 00
-; 48e64
-
-Function48e64: ; 48e64 (12:4e64)
-	ld de, GFX_48e71
-	ld hl, VTiles2 tile $00
-	lb bc, BANK(GFX_48e71), 1
-	call Get2bpp
-	ret
-; 48e71 (12:4e71)
-
-GFX_48e71: ; 48e71
-INCBIN "gfx/unknown/048e71.2bpp"
-
 DrawKrisPackGFX: ; 48e81
 	ld hl, PackFGFXPointers
 rept 2
@@ -11064,9 +10950,10 @@
 ; 49330 (12:5330)
 
 .jumptable: ; 49330
-	dw Function4936e
-	dw Function4942f
-	dw Function49706
+	jumptable_start
+	jumptable Function4936e
+	jumptable Function4942f
+	jumptable Function49706
 ; 49336
 
 Function49336: ; 49336
--- a/misc/mobile_12.asm
+++ b/misc/mobile_12.asm
@@ -6,7 +6,7 @@
 	set 0, [hl]
 	ld a, c
 	and a
-	call z, Function48000
+	call z, InitCrystalData
 	call ClearBGPalettes
 	call Function48d3d
 	ld a, [wd479]
--- a/misc/mobile_22.asm
+++ b/misc/mobile_22.asm
@@ -214,7 +214,7 @@
 Function89245: ; 89245 (22:5245)
 	callba TryLoadSaveFile
 	ret c
-	callba Function150b9
+	callba _LoadData
 	and a
 	ret
 
--- a/text/common_3.asm
+++ b/text/common_3.asm
@@ -294,7 +294,7 @@
 	text_from_ram StringBuffer1
 	text ""
 	cont "to @"
-	text_from_ram wc950 + 3
+	text_from_ram wMysteryGiftPlayerName
 	text "'s home."
 	prompt
 ; 1c051a
--- a/wram.asm
+++ b/wram.asm
@@ -334,7 +334,8 @@
 wc2cd:: ds 1
 wSpriteUpdatesEnabled:: ds 1
 wc2cf:: ds 1
-wc2d0:: ds 4
+wMapTimeOfDay:: ds 1
+	ds 3
 wc2d4:: ds 1
 wc2d5:: ds 1
 wLastDexEntry:: ds 1
@@ -1128,18 +1129,18 @@
 OverworldMapEnd::
 	ds OverworldMap - @
 
+wMysteryGiftPartyTemp:: ; ds PARTY_LENGTH * (1 + 1 + NUM_MOVES)
+wMysteryGiftStaging::
+
 wc800::	ds 1
-wMysteryGiftPlayerID::
 wc801:: ds 1
 wc802:: ds 1
-wMysteryGiftPlayerName::
 wc803:: ds 4
 wc807:: ds 7
-wMysteryGiftPlayerDexCaught:: ds 1
+wc80e:: ds 1
 wc80f:: ds 1
 wc810:: ds 1
 wc811:: ds 1
-wMysteryGiftPlayerBackupItem::
 wc812:: ds 1
 wc813:: ds 1
 wc814:: ds 4
@@ -1162,20 +1163,33 @@
 wc8d0:: ds 16
 wc8e0:: ds 16
 wc8f0:: ds 16
+
+wMysteryGiftPartnerData::
 wc900:: ds 1
 wMysteryGiftPartnerID:: ds 2
 wMysteryGiftPartnerName:: ds NAME_LENGTH
-wc90e:: ds 1
-wc90f:: ds 1
-wc910:: ds 1
-wc911:: ds 1
-wc912:: ds 14
+wMysteryGiftPartnerDexCaught:: ds 1
+wc90f::
+wMysteryGiftPartnerSentDeco:: ds 1
+wMysteryGiftPartnerWhichItem:: ds 1
+wMysteryGiftPartnerWhichDeco:: ds 1
+wc912:: ds 2
+wMysteryGiftPartnerDataEnd::
+	ds 12
 wc920:: ds 16
 wc930:: ds 16
 wc940:: ds 16
-wc950:: ds 16
-wc960:: ds 2
-wc962:: ds 2
+wMysteryGiftPlayerData::
+wc950:: ds 1
+wMysteryGiftPlayerID:: ds 2
+wMysteryGiftPlayerName:: ds NAME_LENGTH
+wMysteryGiftPlayerDexCaught:: ds 1
+wMysteryGiftPlayerSentDeco:: ds 1
+wMysteryGiftPlayerWhichItem:: ds 1
+wMysteryGiftPlayerWhichDeco:: ds 1
+wMysteryGiftPlayerBackupItem:: ds 2
+wMysteryGiftPlayerDataEnd::
+
 wc964:: ds 12
 wc970:: ds 16
 wc980:: ds 16
@@ -1188,6 +1202,8 @@
 wc9f0:: ds 4
 wc9f4:: ds 5
 wc9f9:: ds 7
+
+wCreditsFaux2bpp::
 wca00:: ds 1
 wca01:: ds 1
 wca02:: ds 14