shithub: pokecrystal

Download patch

ref: e033ea3a37f594d04b7132ad54765a8fee312ae5
parent: f14562da4b066a80af3edfc5171e083f63532109
author: YamaArashi <shadow962@live.com>
date: Sat Jan 9 12:51:14 EST 2016

commented pokedex more

--- a/constants/cgb_constants.asm
+++ b/constants/cgb_constants.asm
@@ -3,7 +3,7 @@
 	const SCGB_BATTLE_COLORS
 	const SCGB_POKEGEAR_PALS
 	const SCGB_STATS_SCREEN_HP_PALS
-	const SCGB_04
+	const SCGB_POKEDEX
 	const SCGB_SLOT_MACHINE
 	const SCGB_06
 	const SCGB_07
--- a/engine/pokedex.asm
+++ b/engine/pokedex.asm
@@ -57,7 +57,6 @@
 	ld a, h
 	ld [hWY], a
 	ret
-; 40063
 
 InitPokedex: ; 40063
 	call ClearBGPalettes
@@ -87,7 +86,6 @@
 	callba Function1de247
 	call Pokedex_ResetBGMapMode
 	ret
-; 400a2
 
 Pokedex_CheckUnlockedUnownMode: ; 400a2
 	ld a, [StatusFlags]
@@ -102,7 +100,6 @@
 	ld a, TRUE
 	ld [wUnlockedUnownMode], a
 	ret
-; 400b4
 
 Pokedex_InitCursorPosition: ; 400b4
 	ld hl, wPokedexDataStart
@@ -124,9 +121,9 @@
 	cp [hl]
 	jr z, .done
 	inc hl
-	ld a, [wDexListingPage]
+	ld a, [wDexListingScrollOffset]
 	inc a
-	ld [wDexListingPage], a
+	ld [wDexListingScrollOffset], a
 	dec c
 	jr nz, .loop1
 
@@ -145,7 +142,6 @@
 
 .done
 	ret
-; 400ed
 
 Pokedex_GetLandmark: ; 400ed
 	ld a, [MapGroup]
@@ -166,7 +162,6 @@
 .load
 	ld [wDexCurrentLocation], a
 	ret
-; 4010b
 
 Pokedex_Main: ; 4010b
 	ld a, [wJumptableIndex]
@@ -173,24 +168,23 @@
 	ld hl, .Jumptable
 	call Pokedex_LoadPointer
 	jp [hl]
-; 40115
 
 
 .Jumptable: ; 40115 (10:4115)
-	dw Function4013c
-	dw Function401ae
-	dw Function40217
-	dw Function40258
-	dw Function402aa
-	dw Function40443
-	dw Function40471
-	dw Function4039d
-	dw Function403be
-	dw Function4050a
-	dw Function40562
-	dw Pokedex_UnownMode ; Unown Dex
-	dw Function405df
-	dw Pokedex_CloseDex ; Exit
+	dw Pokedex_InitMainScreen
+	dw Pokedex_UpdateMainScreen
+	dw Pokedex_InitDexEntryScreen
+	dw Pokedex_UpdateDexEntryScreen
+	dw Pokedex_ReinitDexEntryScreen
+	dw Pokedex_InitSearchScreen
+	dw Pokedex_UpdateSearchScreen
+	dw Pokedex_InitOptionScreen
+	dw Pokedex_UpdateOptionScreen
+	dw Pokedex_InitSearchResultsScreen
+	dw Pokedex_UpdateSearchResultsScreen
+	dw Pokedex_InitUnownMode
+	dw Pokedex_UpdateUnownMode
+	dw Pokedex_CloseDex
 
 
 Pokedex_IncrementDexPointer: ; 40131 (10:4131)
@@ -203,7 +197,7 @@
 	set 7, [hl]
 	ret
 
-Function4013c: ; 4013c (10:413c)
+Pokedex_InitMainScreen: ; 4013c (10:413c)
 	xor a
 	ld [hBGMapMode], a
 	call ClearSprites
@@ -215,12 +209,12 @@
 	hlcoord 0, 17
 	ld de, String_START_SEARCH
 	call Pokedex_PlaceString
-	ld a, $7
-	ld [wc7d3], a
-	call Function40b0f
+	ld a, 7
+	ld [wDexListingHeight], a
+	call Pokedex_PrintListing
 	call Pokedex_SetBGMapMode_3ifDMG_4ifCGB
 	call Pokedex_ResetBGMapMode
-	call Function4074c
+	call Pokedex_DrawMainScreenLeftSideAndBottom
 	ld a, $5
 	ld [hSCX], a
 
@@ -238,21 +232,21 @@
 	call Pokedex_ResetBGMapMode
 	ld a, -1
 	ld [CurPartySpecies], a
-	ld a, $4
-	call Function41423
-	call Function41148
+	ld a, SCGB_POKEDEX
+	call Pokedex_GetSGBLayout
+	call Pokedex_UpdateCursorOAM
 	callba DrawPokedexListWindow
 	hlcoord 0, 17
 	ld de, String_START_SEARCH
 	call Pokedex_PlaceString
-	ld a, $7
-	ld [wc7d3], a
-	call Function40b0f
+	ld a, 7
+	ld [wDexListingHeight], a
+	call Pokedex_PrintListing
 	call Pokedex_IncrementDexPointer
 	ret
 
-Function401ae: ; 401ae (10:41ae)
-	ld hl, hJoyPressed ; $ffa7
+Pokedex_UpdateMainScreen: ; 401ae (10:41ae)
+	ld hl, hJoyPressed
 	ld a, [hl]
 	and B_BUTTON
 	jr nz, .b
@@ -265,18 +259,18 @@
 	ld a, [hl]
 	and START
 	jr nz, .start
-	call Function406c5
+	call Pokedex_ListingHandleDPadInput
 	ret nc
-	call Function41148
+	call Pokedex_UpdateCursorOAM
 	xor a
 	ld [hBGMapMode], a
-	call Function40b0f
+	call Pokedex_PrintListing
 	call Pokedex_SetBGMapMode3
 	call Pokedex_ResetBGMapMode
 	ret
 
 .a
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	call Pokedex_CheckSeen
 	ret z
 	ld a, $2
@@ -286,7 +280,7 @@
 	ret
 
 .select
-	call Function41401
+	call Pokedex_BlackOutBG
 	ld a, $7
 	ld [wJumptableIndex], a
 	xor a
@@ -297,7 +291,7 @@
 	ret
 
 .start
-	call Function41401
+	call Pokedex_BlackOutBG
 	ld a, $5
 	ld [wJumptableIndex], a
 	xor a
@@ -312,7 +306,7 @@
 	ld [wJumptableIndex], a
 	ret
 
-Function40217: ; 40217 (10:4217)
+Pokedex_InitDexEntryScreen: ; 40217 (10:4217)
 	call LowVolume
 	xor a
 	ld [wPokedexStatus], a
@@ -320,9 +314,9 @@
 	ld [hBGMapMode], a
 	call ClearSprites
 	call Pokedex_LoadCurrentFootprint
-	call Function407fd
-	call Function4134f
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_DrawDexEntryScreenBG
+	call Pokedex_InitArrowCursor
+	call Pokedex_GetSelectedMon
 	ld [wLastDexEntry], a
 	callba DisplayDexEntry
 	call Pokedex_DrawFootprint
@@ -329,19 +323,19 @@
 	call WaitBGMap
 	ld a, $a7
 	ld [hWX], a
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	ld [CurPartySpecies], a
-	ld a, $4
-	call Function41423
+	ld a, SCGB_POKEDEX
+	call Pokedex_GetSGBLayout
 	ld a, [CurPartySpecies]
 	call PlayCry
 	call Pokedex_IncrementDexPointer
 	ret
 
-Function40258: ; 40258 (10:4258)
-	ld de, DexEntryPage_JoypadCoords
-	call Function4135a
-	ld hl, hJoyPressed ; $ffa7
+Pokedex_UpdateDexEntryScreen: ; 40258 (10:4258)
+	ld de, DexEntryScreen_ArrowCursorData
+	call Pokedex_MoveArrowCursor
+	ld hl, hJoyPressed
 	ld a, [hl]
 	and B_BUTTON
 	jr nz, .b
@@ -354,7 +348,7 @@
 	ret
 
 .a
-	ld a, [wc7d8]
+	ld a, [wDexArrowCursorPosIndex]
 	ld hl, DexEntryPage_Jumptable
 	call Pokedex_LoadPointer
 	jp [hl]
@@ -371,46 +365,44 @@
 	ld a, [wcf64]
 	ld [wJumptableIndex], a
 	ret
-; 40292 (10:4292)
 
 Pokedex_Page: ; 40292
 	ld a, [wPokedexStatus]
 	xor $1
 	ld [wPokedexStatus], a
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	ld [wLastDexEntry], a
 	callba DisplayDexEntry
 	call WaitBGMap
 	ret
-; 402aa
 
-Function402aa: ; 402aa (10:42aa)
-	call Function41401
+Pokedex_ReinitDexEntryScreen: ; 402aa (10:42aa)
+; Reinitialize the Pokédex entry screen after changing the selected mon.
+	call Pokedex_BlackOutBG
 	xor a
 	ld [wPokedexStatus], a
 	xor a
 	ld [hBGMapMode], a
-	call Function407fd
-	call Function4134f
+	call Pokedex_DrawDexEntryScreenBG
+	call Pokedex_InitArrowCursor
 	call Pokedex_LoadCurrentFootprint
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	ld [wLastDexEntry], a
 	callba DisplayDexEntry
 	call Pokedex_DrawFootprint
-	call Function4143b
+	call Pokedex_LoadSelectedMonTiles
 	call WaitBGMap
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	ld [CurPartySpecies], a
-	ld a, $4
-	call Function41423
+	ld a, SCGB_POKEDEX
+	call Pokedex_GetSGBLayout
 	ld a, [CurPartySpecies]
 	call PlayCry
 	ld hl, wJumptableIndex
 	dec [hl]
 	ret
-; 402e8 (10:42e8)
 
-DexEntryPage_JoypadCoords: ; 402e8
+DexEntryScreen_ArrowCursorData: ; 402e8
 	db D_RIGHT | D_LEFT, 4
 	dwcoord 1, 17
 	dwcoord 6, 17
@@ -417,7 +409,6 @@
 	dwcoord 11, 17
 	dwcoord 15, 17
 
-; 402f2
 
 DexEntryPage_Jumptable: ; 402f2
 	dw Pokedex_Page
@@ -424,10 +415,9 @@
 	dw .Area
 	dw .Cry
 	dw .Print
-; 402fa
 
 .Area: ; 402fa
-	call Function41401
+	call Pokedex_BlackOutBG
 	xor a
 	ld [hSCX], a
 	call DelayFrame
@@ -435,11 +425,11 @@
 	ld [hWX], a
 	ld a, $90
 	ld [hWY], a
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	ld a, [wDexCurrentLocation]
 	ld e, a
 	predef _Area
-	call Function41401
+	call Pokedex_BlackOutBG
 	call DelayFrame
 	xor a
 	ld [hBGMapMode], a
@@ -449,17 +439,16 @@
 	ld [hSCX], a
 	call DelayFrame
 	call Function4038d
-	call Function4143b
+	call Pokedex_LoadSelectedMonTiles
 	call WaitBGMap
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	ld [CurPartySpecies], a
-	ld a, $4
-	call Function41423
+	ld a, SCGB_POKEDEX
+	call Pokedex_GetSGBLayout
 	ret
-; 40340
 
 .Cry: ; 40340
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	ld a, [wd265]
 	call GetCryIndex
 	ld e, c
@@ -466,7 +455,6 @@
 	ld d, b
 	call PlayCryHeader
 	ret
-; 4034f
 
 .Print: ; 4034f
 	call Function41415
@@ -495,32 +483,30 @@
 	ld [hSCX], a
 	call Function41427
 	ret
-; 4038d
 
 Function4038d: ; 4038d
-	call Function407fd
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_DrawDexEntryScreenBG
+	call Pokedex_GetSelectedMon
 	callba DisplayDexEntry
 	call Pokedex_DrawFootprint
 	ret
-; 4039d
 
-Function4039d: ; 4039d (10:439d)
+Pokedex_InitOptionScreen: ; 4039d (10:439d)
 	xor a
 	ld [hBGMapMode], a
 	call ClearSprites
-	call Function4087c
-	call Function4134f
+	call Pokedex_DrawOptionScreenBG
+	call Pokedex_InitArrowCursor
 	ld a, [wCurrentDexMode]
-	ld [wc7d8], a
+	ld [wDexArrowCursorPosIndex], a
 	call Function40e5b
 	call WaitBGMap
 	ld a, $10
-	call Function41423
+	call Pokedex_GetSGBLayout
 	call Pokedex_IncrementDexPointer
 	ret
 
-Function403be: ; 403be (10:43be)
+Pokedex_UpdateOptionScreen: ; 403be (10:43be)
 	ld a, [wUnlockedUnownMode]
 	and a
 	jr nz, .asm_403c9
@@ -530,7 +516,7 @@
 .asm_403c9
 	ld de, Unknown_403fb
 .asm_403cc
-	call Function4135a
+	call Pokedex_MoveArrowCursor
 	call c, Function40e5b
 	ld hl, hJoyPressed ; $ffa7
 	ld a, [hl]
@@ -542,17 +528,16 @@
 	ret
 
 .asm_403e0
-	ld a, [wc7d8]
+	ld a, [wDexArrowCursorPosIndex]
 	ld hl, Jumptable_40405
 	call Pokedex_LoadPointer
 	jp [hl]
 
 .asm_403ea
-	call Function41401
+	call Pokedex_BlackOutBG
 	ld a, $0
 	ld [wJumptableIndex], a
 	ret
-; 403f3 (10:43f3)
 
 Unknown_403f3: ; 403f3
 	db D_UP | D_DOWN, 3
@@ -559,7 +544,6 @@
 	dwcoord 2,  4
 	dwcoord 2,  6
 	dwcoord 2,  8
-; 403fb
 
 Unknown_403fb: ; 403fb
 	db D_UP | D_DOWN, 4
@@ -567,7 +551,6 @@
 	dwcoord 2,  6
 	dwcoord 2,  8
 	dwcoord 2, 10
-; 40405
 
 Jumptable_40405: ; 40405 (10:4405)
 	dw Function4040d
@@ -574,7 +557,6 @@
 	dw Function40411
 	dw Function40415
 	dw Function4043a
-; 4040d
 
 Function4040d: ; 4040d (10:440d)
 	ld b, DEXMODE_NEW
@@ -595,48 +577,48 @@
 	call Pokedex_ChangeMode
 	call Function40f08
 	xor a
-	ld [wDexListingPage], a
+	ld [wDexListingScrollOffset], a
 	ld [wDexListingCursor], a
 	call Pokedex_InitCursorPosition
 
 .asm_40431
-	call Function41401
+	call Pokedex_BlackOutBG
 	ld a, $0
 	ld [wJumptableIndex], a
 	ret
 
 Function4043a: ; 4043a (10:443a)
-	call Function41401
+	call Pokedex_BlackOutBG
 	ld a, $b
 	ld [wJumptableIndex], a
 	ret
 
-Function40443: ; 40443 (10:4443)
+Pokedex_InitSearchScreen: ; 40443 (10:4443)
 	xor a
 	ld [hBGMapMode], a
 	call ClearSprites
-	call Function408f0
-	call Function4134f
-	ld a, $1
-	ld [wc7d5], a
+	call Pokedex_DrawSearchScreenBG
+	call Pokedex_InitArrowCursor
+	ld a, NORMAL + 1
+	ld [wDexSearchMonType1], a
 	xor a
-	ld [wc7d6], a
-	call Function40fa8
+	ld [wDexSearchMonType2], a
+	call Pokedex_PlaceSearchScreenTypeStrings
 	xor a
 	ld [wDexSearchSlowpokeFrame], a
 	callba DoDexSearchSlowpokeFrame
 	call WaitBGMap
 	ld a, $10
-	call Function41423
+	call Pokedex_GetSGBLayout
 	call Pokedex_IncrementDexPointer
 	ret
 
-Function40471: ; 40471 (10:4471)
-	ld de, Unknown_4049e
-	call Function4135a
-	call Function40f4f
-	call c, Function40fa8
-	ld hl, hJoyPressed ; $ffa7
+Pokedex_UpdateSearchScreen: ; 40471 (10:4471)
+	ld de, .ArrowCursorData
+	call Pokedex_MoveArrowCursor
+	call Pokedex_UpdateSearchMonType
+	call c, Pokedex_PlaceSearchScreenTypeStrings
+	ld hl, hJoyPressed
 	ld a, [hl]
 	and START | B_BUTTON
 	jr nz, .asm_40495
@@ -646,58 +628,54 @@
 	ret
 
 .asm_4048b
-	ld a, [wc7d8]
-	ld hl, Jumptable_404a8
+	ld a, [wDexArrowCursorPosIndex]
+	ld hl, .MenuActionJumptable
 	call Pokedex_LoadPointer
 	jp [hl]
 
 .asm_40495
-	call Function41401
+	call Pokedex_BlackOutBG
 	ld a, $0
 	ld [wJumptableIndex], a
 	ret
-; 4049e (10:449e)
 
-Unknown_4049e: ; 4049e
+.ArrowCursorData: ; 4049e
 	db D_UP | D_DOWN, 4
 	dwcoord 2, 4
 	dwcoord 2, 6
 	dwcoord 2, 13
 	dwcoord 2, 15
-; 404a8
 
-Jumptable_404a8: ; 404a8
-	dw Function404b0
-	dw Function404b0
-	dw Function404b7
-	dw Function40501
-; 404b0
+.MenuActionJumptable: ; 404a8
+	dw .MenuAction_MonSearchType
+	dw .MenuAction_MonSearchType
+	dw .MenuAction_BeginSearch
+	dw .MenuAction_Cancel
 
-Function404b0: ; 404b0
-	call Function40f84
-	call Function40fa8
+.MenuAction_MonSearchType: ; 404b0
+	call Pokedex_NextSearchMonType
+	call Pokedex_PlaceSearchScreenTypeStrings
 	ret
-; 404b7
 
-Function404b7: ; 404b7
-	call Function41086
+.MenuAction_BeginSearch: ; 404b7
+	call Pokedex_SearchForMons
 	callba AnimateDexSearchSlowpoke
-	ld a, [wc7d7]
+	ld a, [wDexSearchResultCount]
 	and a
-	jr nz, .asm_404dc
+	jr nz, .show_search_results
 	call Pokedex_ChangeMode
 	call Function41107
 	xor a
 	ld [hBGMapMode], a
-	call Function408f0
-	call Function4134f
-	call Function40fa8
+	call Pokedex_DrawSearchScreenBG
+	call Pokedex_InitArrowCursor
+	call Pokedex_PlaceSearchScreenTypeStrings
 	call WaitBGMap
 	ret
 
-.asm_404dc
+.show_search_results
 	ld [wDexListingEnd], a
-	ld a, [wDexListingPage]
+	ld a, [wDexListingScrollOffset]
 	ld [wc7e0], a
 	ld a, [wDexListingCursor]
 	ld [wc7e1], a
@@ -704,22 +682,20 @@
 	ld a, [wLastDexEntry]
 	ld [wcf65], a
 	xor a
-	ld [wDexListingPage], a
+	ld [wDexListingScrollOffset], a
 	ld [wDexListingCursor], a
-	call Function41401
+	call Pokedex_BlackOutBG
 	ld a, $9
 	ld [wJumptableIndex], a
 	ret
-; 40501
 
-Function40501: ; 40501
-	call Function41401
+.MenuAction_Cancel: ; 40501
+	call Pokedex_BlackOutBG
 	ld a, $0
 	ld [wJumptableIndex], a
 	ret
-; 4050a
 
-Function4050a: ; 4050a (10:450a)
+Pokedex_InitSearchResultsScreen: ; 4050a (10:450a)
 	xor a
 	ld [hBGMapMode], a
 	xor a
@@ -729,13 +705,13 @@
 	call Pokedex_SetBGMapMode4
 	call Pokedex_ResetBGMapMode
 	callba DrawPokedexSearchResultsWindow
-	call Function409cf
-	ld a, $4
-	ld [wc7d3], a
-	call Function40b0f
+	call Pokedex_PlaceSearchResultsTypeStrings
+	ld a, 4
+	ld [wDexListingHeight], a
+	call Pokedex_PrintListing
 	call Pokedex_SetBGMapMode3
 	call Pokedex_ResetBGMapMode
-	call Function40962
+	call Pokedex_DrawSearchResultsScreenBG
 	ld a, $5
 	ld [hSCX], a
 	ld a, $4a
@@ -745,16 +721,16 @@
 	call WaitBGMap
 	call Pokedex_ResetBGMapMode
 	callba DrawPokedexSearchResultsWindow
-	call Function409cf
-	call Function41281
+	call Pokedex_PlaceSearchResultsTypeStrings
+	call Pokedex_UpdateSearchResultsCursorOAM
 	ld a, $ff
 	ld [CurPartySpecies], a
-	ld a, $4
-	call Function41423
+	ld a, SCGB_POKEDEX
+	call Pokedex_GetSGBLayout
 	call Pokedex_IncrementDexPointer
 	ret
 
-Function40562: ; 40562 (10:4562)
+Pokedex_UpdateSearchResultsScreen: ; 40562 (10:4562)
 	ld hl, hJoyPressed ; $ffa7
 	ld a, [hl]
 	and B_BUTTON
@@ -762,18 +738,18 @@
 	ld a, [hl]
 	and A_BUTTON
 	jr nz, .asm_40583
-	call Function406c5
+	call Pokedex_ListingHandleDPadInput
 	ret nc
-	call Function41281
+	call Pokedex_UpdateSearchResultsCursorOAM
 	xor a
 	ld [hBGMapMode], a
-	call Function40b0f
+	call Pokedex_PrintListing
 	call Pokedex_SetBGMapMode3
 	call Pokedex_ResetBGMapMode
 	ret
 
 .asm_40583
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	call Pokedex_CheckSeen
 	ret z
 	ld a, $2
@@ -784,12 +760,12 @@
 
 .asm_40595
 	ld a, [wc7e0]
-	ld [wDexListingPage], a
+	ld [wDexListingScrollOffset], a
 	ld a, [wc7e1]
 	ld [wDexListingCursor], a
 	ld a, [wcf65]
 	ld [wLastDexEntry], a
-	call Function41401
+	call Pokedex_BlackOutBG
 	call ClearSprites
 	call Pokedex_ChangeMode
 	ld a, $5
@@ -800,7 +776,7 @@
 	ld [hWX], a
 	ret
 
-Pokedex_UnownMode: ; 405bd (10:45bd)
+Pokedex_InitUnownMode: ; 405bd (10:45bd)
 	call Pokedex_LoadUnownFont
 	call Function409f1
 	xor a
@@ -810,12 +786,12 @@
 	callba PrintUnownWord
 	call WaitBGMap
 	ld a, $16
-	call Function41423
+	call Pokedex_GetSGBLayout
 	call Pokedex_IncrementDexPointer
 	ret
 
-Function405df: ; 405df (10:45df)
-	ld hl, hJoyPressed ; $ffa7
+Pokedex_UpdateUnownMode: ; 405df (10:45df)
+	ld hl, hJoyPressed
 	ld a, [hl]
 	and A_BUTTON | B_BUTTON
 	jr nz, .a_b
@@ -823,7 +799,7 @@
 	ret
 
 .a_b
-	call Function41401
+	call Pokedex_BlackOutBG
 	ld a, $7
 	ld [wJumptableIndex], a
 	call DelayFrame
@@ -909,7 +885,7 @@
 Pokedex_NextOrPreviousDexEntry: ; 4066c (10:466c)
 	ld a, [wDexListingCursor]
 	ld [wBackupDexListingCursor], a
-	ld a, [wDexListingPage]
+	ld a, [wDexListingScrollOffset]
 	ld [wBackupDexListingPage], a
 	ld hl, hJoyLast
 	ld a, [hl]
@@ -922,25 +898,25 @@
 	ret
 
 .up
-	ld a, [wc7d3]
+	ld a, [wDexListingHeight]
 	ld d, a
 	ld a, [wDexListingEnd]
 	ld e, a
-	call Function406ea
+	call Pokedex_ListingMoveCursorUp
 	jr nc, .nope
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	call Pokedex_CheckSeen
 	jr nz, .yep
 	jr .up
 
 .down
-	ld a, [wc7d3]
+	ld a, [wDexListingHeight]
 	ld d, a
 	ld a, [wDexListingEnd]
 	ld e, a
-	call Function406fe
+	call Pokedex_ListingMoveCursorDown
 	jr nc, .nope
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 	call Pokedex_CheckSeen
 	jr nz, .yep
 	jr .down
@@ -953,12 +929,13 @@
 	ld a, [wBackupDexListingCursor]
 	ld [wDexListingCursor], a
 	ld a, [wBackupDexListingPage]
-	ld [wDexListingPage], a
+	ld [wDexListingScrollOffset], a
 	and a
 	ret
 
-Function406c5: ; 406c5 (10:46c5)
-	ld a, [wc7d3]
+Pokedex_ListingHandleDPadInput: ; 406c5 (10:46c5)
+; Handles D-pad input for a list of Pokémon.
+	ld a, [wDexListingHeight]
 	ld d, a
 	ld a, [wDexListingEnd]
 	ld e, a
@@ -965,106 +942,113 @@
 	ld hl, hJoyLast
 	ld a, [hl]
 	and D_UP
-	jr nz, Function406ea
+	jr nz, Pokedex_ListingMoveCursorUp
 	ld a, [hl]
 	and D_DOWN
-	jr nz, Function406fe
+	jr nz, Pokedex_ListingMoveCursorDown
 	ld a, d
 	cp e
-	jr nc, asm_4073d
+	jr nc, Pokedex_ListingPosStayedSame
 	ld a, [hl]
-	and $20
-	jr nz, asm_40716
+	and D_LEFT
+	jr nz, Pokedex_ListingMoveUpOnePage
 	ld a, [hl]
-	and $10
-	jr nz, asm_40728
-	jr asm_4073d
+	and D_RIGHT
+	jr nz, Pokedex_ListingMoveDownOnePage
+	jr Pokedex_ListingPosStayedSame
 
-Function406ea: ; 406ea (10:46ea)
+Pokedex_ListingMoveCursorUp: ; 406ea (10:46ea)
 	ld hl, wDexListingCursor
 	ld a, [hl]
 	and a
-	jr z, .asm_406f4
+	jr z, .try_scrolling
 	dec [hl]
-	jr asm_4073f
-.asm_406f4
-	ld hl, wDexListingPage
+	jr Pokedex_ListingPosChanged
+.try_scrolling
+	ld hl, wDexListingScrollOffset
 	ld a, [hl]
 	and a
-	jr z, asm_4073d
+	jr z, Pokedex_ListingPosStayedSame
 	dec [hl]
-	jr asm_4073f
+	jr Pokedex_ListingPosChanged
 
-Function406fe: ; 406fe (10:46fe)
+Pokedex_ListingMoveCursorDown: ; 406fe (10:46fe)
 	ld hl, wDexListingCursor
 	ld a, [hl]
 	inc a
 	cp e
-	jr nc, asm_4073d
+	jr nc, Pokedex_ListingPosStayedSame
 	cp d
-	jr nc, .asm_4070c
+	jr nc, .try_scrolling
 	inc [hl]
-	jr asm_4073f
-.asm_4070c
-	ld hl, wDexListingPage
+	jr Pokedex_ListingPosChanged
+.try_scrolling
+	ld hl, wDexListingScrollOffset
 	add [hl]
 	cp e
-	jr nc, asm_4073d
+	jr nc, Pokedex_ListingPosStayedSame
 	inc [hl]
-	jr asm_4073f
-asm_40716: ; 40716 (10:4716)
-	ld hl, wDexListingPage
+	jr Pokedex_ListingPosChanged
+
+Pokedex_ListingMoveUpOnePage: ; 40716 (10:4716)
+	ld hl, wDexListingScrollOffset
 	ld a, [hl]
 	and a
-	jr z, asm_4073d
+	jr z, Pokedex_ListingPosStayedSame
 	cp d
-	jr nc, .asm_40724
+	jr nc, .not_near_top
+; If we're already less than page away from the top, go to the top.
 	xor a
 	ld [hl], a
-	jr asm_4073f
-.asm_40724
+	jr Pokedex_ListingPosChanged
+.not_near_top
 	sub d
 	ld [hl], a
-	jr asm_4073f
-asm_40728: ; 40728 (10:4728)
-	ld hl, wDexListingPage
+	jr Pokedex_ListingPosChanged
+
+Pokedex_ListingMoveDownOnePage: ; 40728 (10:4728)
+; When moving down a page, the return value always report a change in position.
+	ld hl, wDexListingScrollOffset
 	ld a, d
 	add a
 	add [hl]
-	jr c, .asm_40733
+	jr c, .near_bottom
 	cp e
-	jr c, .asm_40738
-.asm_40733
+	jr c, .not_near_bottom
+.near_bottom
 	ld a, e
 	sub d
 	ld [hl], a
-	jr asm_4073f
-.asm_40738
+	jr Pokedex_ListingPosChanged
+.not_near_bottom
 	ld a, [hl]
 	add d
 	ld [hl], a
-	jr asm_4073f
-asm_4073d: ; 4073d (10:473d)
+	jr Pokedex_ListingPosChanged
+
+Pokedex_ListingPosStayedSame: ; 4073d (10:473d)
 	and a
 	ret
-asm_4073f: ; 4073f (10:473f)
+
+Pokedex_ListingPosChanged: ; 4073f (10:473f)
 	scf
 	ret
 
-Function40741: ; 40741
+Pokedex_HLDownBRows: ; 40741
+; Moves the tilemap pointer in HL down by B rows.
 	push de
-	ld de, $0014
-.asm_40745
+	ld de, SCREEN_WIDTH
+.loop
 	ld [hl], a
 	add hl, de
 	dec b
-	jr nz, .asm_40745
+	jr nz, .loop
 	pop de
 	ret
-; 4074c
 
 
-Function4074c: ; 4074c (10:474c)
+Pokedex_DrawMainScreenLeftSideAndBottom: ; 4074c (10:474c)
+; Draws the left sidebar and the bottom bar on the main screen.
 	hlcoord 0, 17
 	ld de, String_START_SEARCH
 	call Pokedex_PlaceString
@@ -1081,7 +1065,7 @@
 	hlcoord 1, 11
 	ld de, String_SEEN
 	call Pokedex_PlaceString
-	ld hl, PokedexSeen ; wdeb9 (aliases: EndPokedexSeen)
+	ld hl, PokedexSeen
 	ld b, EndPokedexSeen - PokedexSeen
 	call CountSetBits
 	ld de, wd265
@@ -1104,11 +1088,11 @@
 	hlcoord 8, 1
 	ld b, $7
 	ld a, $5a
-	call Function40741
+	call Pokedex_HLDownBRows
 	hlcoord 8, 10
 	ld b, $6
 	ld a, $5a
-	call Function40741
+	call Pokedex_HLDownBRows
 	hlcoord 8, 0
 	ld [hl], $59
 	hlcoord 8, 8
@@ -1119,7 +1103,6 @@
 	ld [hl], $5b
 	call Pokedex_PlaceFrontpicTopLeftCorner
 	ret
-; 407e1 (10:47e1)
 
 String_SEEN: ; 407e1
 	db "SEEN", $ff
@@ -1129,9 +1112,8 @@
 	db $3b, $48, $49, $4a, $44, $45, $46, $47 ; SELECT > OPTION
 String_START_SEARCH: ; 407f2
 	db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, $ff ; START > SEARCH
-; 407fd
 
-Function407fd: ; 407fd
+Pokedex_DrawDexEntryScreenBG: ; 407fd
 	call Pokedex_FillBackgroundColor2
 	hlcoord 0, 0
 	ld bc, $0f12
@@ -1141,7 +1123,7 @@
 	hlcoord 19, 1
 	ld a, $7f
 	ld b, $f
-	call Function40741
+	call Pokedex_HLDownBRows
 	ld [hl], $39
 	hlcoord 1, 10
 	ld bc, $0013
@@ -1152,29 +1134,27 @@
 	ld a, $7f
 	call ByteFill
 	hlcoord 9, 7
-	ld de, Unknown_40852
+	ld de, .Height
 	call Pokedex_PlaceString
 	hlcoord 9, 9
-	ld de, Unknown_4085c
+	ld de, .Weight
 	call Pokedex_PlaceString
 	hlcoord 0, 17
-	ld de, Unknown_40867
+	ld de, .MenuItems
 	call Pokedex_PlaceString
 	call Pokedex_PlaceFrontpicTopLeftCorner
 	ret
-; 4084f
 
-Unknown_4084f: ; 4084f
+.Unused: ; 4084f
 	db $5c, $5d, $ff ; No.
-Unknown_40852: ; 40852
+.Height: ; 40852
 	db "HT  ?", $5e, "??", $5f, $ff ; HT  ?'??"
-Unknown_4085c: ; 4085c
+.Weight: ; 4085c
 	db "WT   ???lb", $ff ; WT   ???lb
-Unknown_40867: ; 40867
+.MenuItems: ; 40867
 	db $3b, " PAGE AREA CRY PRNT", $ff
-; 4087c
 
-Function4087c: ; 4087c (10:487c)
+Pokedex_DrawOptionScreenBG: ; 4087c (10:487c)
 	call Pokedex_FillBackgroundColor2
 	hlcoord 0, 2
 	lb bc, 8, 18
@@ -1183,79 +1163,70 @@
 	lb bc, 4, 18
 	call Pokedex_PlaceBorder
 	hlcoord 0, 1
-	ld de, Unknown_408b2
+	ld de, .Title
 	call Pokedex_PlaceString
 	hlcoord 3, 4
-	ld de, String_408bd
+	ld de, .Modes
 	call PlaceString
 	ld a, [wUnlockedUnownMode]
 	and a
 	ret z
 	hlcoord 3, 10
-	ld de, String_408e5
+	ld de, .UnownMode
 	call PlaceString
 	ret
-; 408b2 (10:48b2)
 
-Unknown_408b2: ; 408b2
+.Title: ; 408b2
 	db $3b, " OPTION ", $3c, $ff
-; 408bd
 
-String_408bd: ; 408bd
+.Modes: ; 408bd
 	db   "NEW #DEX MODE"
 	next "OLD #DEX MODE"
 	next "A to Z MODE"
 	db "@"
-; 408e5
 
-String_408e5: ; 408e5
+.UnownMode: ; 408e5
 	db "UNOWN MODE@"
-; 408f0
 
-Function408f0: ; 408f0 (10:48f0)
+Pokedex_DrawSearchScreenBG: ; 408f0 (10:48f0)
 	call Pokedex_FillBackgroundColor2
 	hlcoord 0, 2
 	lb bc, 14, 18
 	call Pokedex_PlaceBorder
 	hlcoord 0, 1
-	ld de, Unknown_4092a
+	ld de, .Title
 	call Pokedex_PlaceString
 	hlcoord 8, 4
-	ld de, Unknown_40935
+	ld de, .TypeLeftRightArrows
 	call Pokedex_PlaceString
 	hlcoord 8, 6
-	ld de, Unknown_40935
+	ld de, .TypeLeftRightArrows
 	call Pokedex_PlaceString
 	hlcoord 3, 4
-	ld de, String_40940
+	ld de, .Types
 	call PlaceString
 	hlcoord 3, 13
-	ld de, String_4094c
+	ld de, .Menu
 	call PlaceString
 	ret
-; 4092a (10:492a)
 
-Unknown_4092a: ; 4092a
+.Title: ; 4092a
 	db $3b, " SEARCH ", $3c, $ff
-; 40925
 
-Unknown_40935: ; 40935
+.TypeLeftRightArrows: ; 40935
 	db $3d, "        ", $3e, $ff
-; 40940
 
-String_40940: ; 40940
+.Types: ; 40940
 	db   "TYPE1"
 	next "TYPE2"
 	db   "@"
-; 4094c
 
-String_4094c: ; 4094c
+.Menu: ; 4094c
 	db   "BEGIN SEARCH!!"
 	next "CANCEL"
 	db   "@"
-; 40962
 
-Function40962: ; 40962 (10:4962)
+Pokedex_DrawSearchResultsScreenBG: ; 40962 (10:4962)
 	call Pokedex_FillBackgroundColor2
 	hlcoord 0, 0
 	lb bc, 7, 7
@@ -1264,9 +1235,9 @@
 	lb bc, 5, 18
 	call Pokedex_PlaceBorder
 	hlcoord 1, 12
-	ld de, String_409ae
+	ld de, .BottomWindowText
 	call PlaceString
-	ld de, wc7d7
+	ld de, wDexSearchResultCount
 	hlcoord 1, 16
 	lb bc, 1, 3
 	call PrintNum
@@ -1275,7 +1246,7 @@
 	hlcoord 8, 1
 	ld b, $7
 	ld a, $5a
-	call Function40741
+	call Pokedex_HLDownBRows
 	hlcoord 8, 8
 	ld [hl], $53
 	hlcoord 8, 9
@@ -1284,31 +1255,29 @@
 	ld [hl], $6a
 	call Pokedex_PlaceFrontpicTopLeftCorner
 	ret
-; 409ae (10:49ae)
 
-String_409ae: ; 409ae
+.BottomWindowText: ; 409ae
 	db   "SEARCH RESULTS"
 	next "  TYPE"
 	next "    FOUND!"
 	db   "@"
-; 409cf
 
-Function409cf: ; 409cf (10:49cf)
-	ld a, [wc7d5]
+Pokedex_PlaceSearchResultsTypeStrings: ; 409cf (10:49cf)
+	ld a, [wDexSearchMonType1]
 	hlcoord 0, 14
-	call Function40fcd
-	ld a, [wc7d5]
+	call Pokedex_PlaceTypeString
+	ld a, [wDexSearchMonType1]
 	ld b, a
-	ld a, [wc7d6]
+	ld a, [wDexSearchMonType2]
 	and a
-	jr z, .asm_409f0
+	jr z, .done
 	cp b
-	jr z, .asm_409f0
+	jr z, .done
 	hlcoord 2, 15
-	call Function40fcd
+	call Pokedex_PlaceTypeString
 	hlcoord 1, 15
-	ld [hl], $f3
-.asm_409f0
+	ld [hl], "/"
+.done
 	ret
 
 Function409f1: ; 409f1 (10:49f1)
@@ -1353,7 +1322,6 @@
 	ld a, b
 	ld [wc7de], a
 	ret
-; 40a3e (10:4a3e)
 
 Unknown_40a3e: ; 40a3e
 ;           letter, cursor
@@ -1383,7 +1351,6 @@
 	dwcoord  14, 8,  15, 8
 	dwcoord  14, 9,  15, 9
 	dwcoord  14,10,  15,10
-; 40aa6
 
 Pokedex_FillBackgroundColor2: ; 40aa6
 	hlcoord 0, 0
@@ -1391,7 +1358,6 @@
 	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
 	call ByteFill
 	ret
-; 40ab2
 
 Pokedex_PlaceFrontpicTopLeftCorner: ; 40ab2
 	hlcoord 1, 1
@@ -1415,7 +1381,6 @@
 	dec b
 	jr nz, .row
 	ret
-; 40acd
 
 Pokedex_PlaceString: ; 40acd
 .loop
@@ -1425,7 +1390,6 @@
 	inc de
 	ld [hli], a
 	jr .loop
-; 40ad5
 
 
 Pokedex_PlaceBorder: ; 40ad5
@@ -1459,7 +1423,6 @@
 	ld a, $3a
 	ld [hl], a
 	ret
-; 40b06
 
 .FillRow: ; 40b06
 	ld e, c
@@ -1471,10 +1434,11 @@
 	ld [hli], a
 	dec e
 	jr .row_loop
-; 40b0f
 
 
-Function40b0f: ; 40b0f (10:4b0f)
+Pokedex_PrintListing: ; 40b0f (10:4b0f)
+; Prints the list of Pokémon on the main Pokédex screen.
+
 ; This check is completely useless.
 	ld a, [wCurrentDexMode]
 	cp DEXMODE_OLD
@@ -1484,10 +1448,11 @@
 .okay
 	ld c, 11
 ; End useless check
+
 .resume
-; Clear (2 * [wc7d3] + 1) by 11 box starting at 0,1
+; Clear (2 * [wDexListingHeight] + 1) by 11 box starting at 0,1
 	hlcoord 0, 1
-	ld a, [wc7d3]
+	ld a, [wDexListingHeight]
 	add a
 	inc a
 	ld b, a
@@ -1494,8 +1459,8 @@
 	ld a, " "
 	call Pokedex_FillBox
 
-; Load de with wPokedexDataStart + [wDexListingPage]
-	ld a, [wDexListingPage]
+; Load de with wPokedexDataStart + [wDexListingScrollOffset]
+	ld a, [wDexListingScrollOffset]
 	ld e, a
 	ld d, $0
 	ld hl, wPokedexDataStart
@@ -1503,7 +1468,7 @@
 	ld e, l
 	ld d, h
 	hlcoord 0, 2
-	ld a, [wc7d3]
+	ld a, [wDexListingHeight]
 .loop
 	push af
 	ld a, [de]
@@ -1510,7 +1475,7 @@
 	ld [wd265], a
 	push de
 	push hl
-	call Function40b55
+	call .PrintEntry
 	pop hl
 	ld de, 2 * SCREEN_WIDTH
 	add hl, de
@@ -1519,10 +1484,11 @@
 	pop af
 	dec a
 	jr nz, .loop
-	call Function4143b
+	call Pokedex_LoadSelectedMonTiles
 	ret
 
-Function40b55: ; 40b55 (10:4b55)
+.PrintEntry: ; 40b55 (10:4b55)
+; Prints one entry in the list of Pokémon on the main Pokédex screen.
 	and a
 	ret z
 	call Pokedex_PrintNumberIfOldMode
@@ -1570,11 +1536,9 @@
 	call PlaceString
 	scf
 	ret
-; 40b9a (10:4b9a)
 
 .NameNotSeen: ; 40b9a
 	db "-----@"
-; 40ba0
 
 Pokedex_DrawFootprint: ; 40ba0
 	hlcoord 18, 1
@@ -1588,12 +1552,14 @@
 	inc a
 	ld [hl], a
 	ret
-; 40bb1
 
 
-Pokedex_GetMonAtCursorPosition: ; 40bb1
+Pokedex_GetSelectedMon: ; 40bb1
+; Gets the species of the currently selected Pokémon. This corresponds to the
+; position of the cursor in the main listing, but this function can be used
+; on all Pokédex screens.
 	ld a, [wDexListingCursor]
-	ld hl, wDexListingPage
+	ld hl, wDexListingScrollOffset
 	add [hl]
 	ld e, a
 	ld d, $0
@@ -1602,7 +1568,6 @@
 	ld a, [hl]
 	ld [wd265], a
 	ret
-; 40bc4
 
 
 Pokedex_CheckCaught: ; 40bc4 (10:4bc4)
@@ -1625,7 +1590,6 @@
 	pop hl
 	pop de
 	ret
-; 40bdc
 
 
 
@@ -1638,7 +1602,6 @@
 	ld hl, .Jumptable
 	call Pokedex_LoadPointer
 	jp [hl]
-; 40bf0
 
 
 .Jumptable: ; 40bf0 (10:4bf0)
@@ -1724,7 +1687,6 @@
 
 .doneabc
 	ret
-; 40c65
 
 AlphabeticalPokedexOrder: ; 0x40c65
 INCLUDE "data/pokedex/order_alpha.asm"
@@ -1738,7 +1700,7 @@
 	hlcoord 0, 12
 	lb bc, 4, SCREEN_WIDTH - 2
 	call Pokedex_PlaceBorder
-	ld a, [wc7d8]
+	ld a, [wDexArrowCursorPosIndex]
 	ld hl, Unknown_40e7d
 	call Pokedex_LoadPointer
 	ld e, l
@@ -1748,7 +1710,6 @@
 	ld a, $1
 	ld [hBGMapMode], a
 	ret
-; 40e7d
 
 Unknown_40e7d: ; 40e7d
 	dw .NewMode
@@ -1755,27 +1716,22 @@
 	dw .OldMode
 	dw .ABCMode
 	dw .UnownMode
-; 40e85
 
 .NewMode: ; 40e85
 	db   "<PK><MN> are listed by"
 	next "evolution type.@"
-; 40ea6
 
 .OldMode: ; 40ea6
 	db   "<PK><MN> are listed by"
 	next "official type.@"
-; 40ec6
 
 .ABCMode: ; 40ec6
 	db   "<PK><MN> are listed"
 	next "alphabetically.@"
-; 40ee4
 
 .UnownMode: ; 40ee4
 	db   "UNOWN are listed"
 	next "in catching order.@"
-; 40f08
 
 Function40f08: ; 40f08 (10:4f08)
 	xor a
@@ -1795,32 +1751,31 @@
 	ld c, 64
 	call DelayFrames
 	ret
-; 40f32 (10:4f32)
 
 String_ChangingModesPleaseWait: ; 40f32
 	db   "Changing modes."
 	next "Please wait.@"
-; 40f4f
 
-Function40f4f: ; 40f4f (10:4f4f)
-	ld a, [wc7d8]
-	cp $2
-	jr nc, .asm_40f63
+Pokedex_UpdateSearchMonType: ; 40f4f (10:4f4f)
+	ld a, [wDexArrowCursorPosIndex]
+	cp 2
+	jr nc, .NoChange
 	ld hl, hJoyLast
 	ld a, [hl]
-	and $20
-	jr nz, .asm_40f65
+	and D_LEFT
+	jr nz, Pokedex_PrevSearchMonType
 	ld a, [hl]
-	and $10
-	jr nz, Function40f84
-.asm_40f63
+	and D_RIGHT
+	jr nz, Pokedex_NextSearchMonType
+.NoChange
 	and a
 	ret
-.asm_40f65
-	ld a, [wc7d8]
+
+Pokedex_PrevSearchMonType: ; 40f65
+	ld a, [wDexArrowCursorPosIndex]
 	and a
 	jr nz, .asm_40f76
-	ld hl, wc7d5
+	ld hl, wDexSearchMonType1
 	ld a, [hl]
 	cp $1
 	jr z, .asm_40f80
@@ -1827,7 +1782,7 @@
 	dec [hl]
 	jr .asm_40f82
 .asm_40f76
-	ld hl, wc7d6
+	ld hl, wDexSearchMonType2
 	ld a, [hl]
 	and a
 	jr z, .asm_40f80
@@ -1838,13 +1793,12 @@
 .asm_40f82
 	scf
 	ret
-; 40f84
 
-Function40f84: ; 40f84
-	ld a, [wc7d8]
+Pokedex_NextSearchMonType: ; 40f84
+	ld a, [wDexArrowCursorPosIndex]
 	and a
 	jr nz, .asm_40f99
-	ld hl, wc7d5
+	ld hl, wDexSearchMonType1
 	ld a, [hl]
 	cp $11
 	jr nc, .asm_40f95
@@ -1854,7 +1808,7 @@
 	ld [hl], $1
 	jr .asm_40fa6
 .asm_40f99
-	ld hl, wc7d6
+	ld hl, wDexSearchMonType2
 	ld a, [hl]
 	cp $11
 	jr nc, .asm_40fa4
@@ -1866,28 +1820,28 @@
 	scf
 	ret
 
-Function40fa8: ; 40fa8 (10:4fa8)
+Pokedex_PlaceSearchScreenTypeStrings: ; 40fa8 (10:4fa8)
 	xor a
 	ld [hBGMapMode], a
 	hlcoord 9, 3
-	ld bc, $408
-	ld a, $7f
+	lb bc, 4, 8
+	ld a, " "
 	call Pokedex_FillBox
-	ld a, [wc7d5]
+	ld a, [wDexSearchMonType1]
 	hlcoord 9, 4
-	call Function40fcd
-	ld a, [wc7d6]
+	call Pokedex_PlaceTypeString
+	ld a, [wDexSearchMonType2]
 	hlcoord 9, 6
-	call Function40fcd
+	call Pokedex_PlaceTypeString
 	ld a, $1
 	ld [hBGMapMode], a
 	ret
 
-Function40fcd: ; 40fcd (10:4fcd)
+Pokedex_PlaceTypeString: ; 40fcd (10:4fcd)
 	push hl
 	ld e, a
 	ld d, 0
-	ld hl, Strings_40fe4
+	ld hl, .TypeStrings
 rept 9
 	add hl, de
 endr
@@ -1896,9 +1850,8 @@
 	pop hl
 	call PlaceString
 	ret
-; 40fe4 (10:4fe4)
 
-Strings_40fe4: ; 40fe4
+.TypeStrings: ; 40fe4
 	db "  ----  @"
 	db " NORMAL @"
 	db "  FIRE  @"
@@ -1917,84 +1870,83 @@
 	db " DRAGON @"
 	db "  DARK  @"
 	db " STEEL  @"
-; 41086
 
-Function41086: ; 41086
-	ld a, [wc7d6]
+Pokedex_SearchForMons: ; 41086
+	ld a, [wDexSearchMonType2]
 	and a
-	call nz, Function41095
-	ld a, [wc7d5]
+	call nz, .Search
+	ld a, [wDexSearchMonType1]
 	and a
-	call nz, Function41095
+	call nz, .Search
 	ret
-; 41095
 
-Function41095: ; 41095
+.Search: ; 41095
 	dec a
 	ld e, a
 	ld d, 0
-	ld hl, Unknown_410f6
+	ld hl, .TypeConversionTable
 	add hl, de
 	ld a, [hl]
-	ld [wc7df], a
+	ld [wDexConvertedMonType], a
 	ld hl, wPokedexDataStart
 	ld de, wPokedexDataStart
 	ld c, NUM_POKEMON
 	xor a
-	ld [wc7d7], a
-.asm_410ad
+	ld [wDexSearchResultCount], a
+.loop
 	push bc
 	ld a, [hl]
 	and a
-	jr z, .asm_410e0
+	jr z, .next_mon
 	ld [wd265], a
 	ld [CurSpecies], a
 	call Pokedex_CheckCaught
-	jr z, .asm_410e0
+	jr z, .next_mon
 	push hl
 	push de
 	call GetBaseData
 	pop de
 	pop hl
-	ld a, [wc7df]
+	ld a, [wDexConvertedMonType]
 	ld b, a
 	ld a, [BaseType1]
 	cp b
-	jr z, .asm_410d4
+	jr z, .match_found
 	ld a, [BaseType2]
 	cp b
-	jr nz, .asm_410e0
+	jr nz, .next_mon
 
-.asm_410d4
+.match_found
 	ld a, [wd265]
 	ld [de], a
 	inc de
-	ld a, [wc7d7]
+	ld a, [wDexSearchResultCount]
 	inc a
-	ld [wc7d7], a
+	ld [wDexSearchResultCount], a
 
-.asm_410e0
+.next_mon
 	inc hl
 	pop bc
 	dec c
-	jr nz, .asm_410ad
+	jr nz, .loop
+
 	ld l, e
 	ld h, d
-	ld a, [wc7d7]
+	ld a, [wDexSearchResultCount]
 	ld c, 0
-.asm_410ec
+
+.zero_remaining_mons
 	cp NUM_POKEMON
-	jr z, .asm_410f5
+	jr z, .done
 	ld [hl], c
 	inc hl
 	inc a
-	jr .asm_410ec
+	jr .zero_remaining_mons
 
-.asm_410f5
+.done
 	ret
-; 410f6
 
-Unknown_410f6: ; 410f6
+.TypeConversionTable: ; 410f6
 	db NORMAL
 	db FIRE
 	db WATER
@@ -2012,7 +1964,6 @@
 	db DRAGON
 	db DARK
 	db STEEL
-; 41107
 
 Function41107: ; 41107
 	xor a
@@ -2028,34 +1979,30 @@
 	ld c, $80
 	call DelayFrames
 	ret
-; 41126
 
 String_41126: ; 41126
 	db   "The specified type"
 	next "was not found.@"
-; 41148
 
-Function41148: ; 41148 (10:5148)
+Pokedex_UpdateCursorOAM: ; 41148 (10:5148)
 	ld a, [wCurrentDexMode]
-	cp $1
-	jp z, Function41157
-	call Function41229
-	call Function4130e
+	cp DEXMODE_OLD
+	jp z, Pokedex_PutOldModeCursorOAM
+	call Pokedex_PutNewModeABCModeCursorOAM
+	call Pokedex_PutScrollbarOAM
 	ret
 
-Function41157: ; 41157 (10:5157)
-	ld hl, Unknown_41167
+Pokedex_PutOldModeCursorOAM: ; 41157 (10:5157)
+	ld hl, .CursorOAM
 	ld a, [wDexListingCursor]
 	or a
-	jr nz, .asm_41163
-	ld hl, Unknown_411c8
-.asm_41163
-	call Function412f1
+	jr nz, .okay
+	ld hl, .CursorAtTopOAM
+.okay
+	call Pokedex_LoadCursorOAM
 	ret
-; 41167 (10:5167)
 
-Unknown_41167: ; 41167
-; OAM
+.CursorOAM: ; 41167
 	db $18, $47, $30, $07
 	db $10, $47, $31, $07
 	db $10, $4f, $32, $07
@@ -2081,10 +2028,10 @@
 	db $28, $9e, $31, $67
 	db $20, $9e, $30, $67
 	db $ff
-; 411c8
 
-Unknown_411c8: ; 411c8
-; OAM
+.CursorAtTopOAM: ; 411c8
+; OAM data for when the cursor is at the top of the list. The tiles at the top
+; are cut off so they don't show up outside the list area.
 	db $18, $47, $30, $07
 	db $10, $47, $34, $07
 	db $10, $4f, $35, $07
@@ -2110,16 +2057,13 @@
 	db $28, $9e, $31, $67
 	db $20, $9e, $30, $67
 	db $ff
-; 41229
 
-Function41229: ; 41229 (10:5229)
-	ld hl, Unknown_41230
-	call Function412f1
+Pokedex_PutNewModeABCModeCursorOAM: ; 41229 (10:5229)
+	ld hl, .CursorOAM
+	call Pokedex_LoadCursorOAM
 	ret
-; 41230 (10:5230)
 
-Unknown_41230: ; 41230
-; OAM
+.CursorOAM: ; 41230
 	db $1b, $47, $30, $07
 	db $13, $47, $31, $07
 	db $13, $4f, $32, $07
@@ -2141,19 +2085,16 @@
 	db $2b, $98, $31, $67
 	db $23, $98, $30, $67
 	db $ff
-; 41281
 
-Function41281: ; 41281 (10:5281)
+Pokedex_UpdateSearchResultsCursorOAM: ; 41281 (10:5281)
 	ld a, [wCurrentDexMode]
-	cp $1
-	jp z, Function41157
-	ld hl, Unknown_41290
-	call Function412f1
+	cp DEXMODE_OLD
+	jp z, Pokedex_PutOldModeCursorOAM
+	ld hl, .CursorOAM
+	call Pokedex_LoadCursorOAM
 	ret
-; 41290 (10:5290)
 
-Unknown_41290: ; 41290
-; OAM
+.CursorOAM: ; 41290
 	db $1b, $47, $30, $07
 	db $13, $47, $31, $07
 	db $13, $4f, $32, $07
@@ -2179,11 +2120,10 @@
 	db $2b, $9e, $31, $67
 	db $23, $9e, $30, $67
 	db $ff
-; 412f1
 
-Function412f1: ; 412f1 (10:52f1)
+Pokedex_LoadCursorOAM: ; 412f1 (10:52f1)
 	ld de, Sprites
-.asm_412f4
+.loop
 	ld a, [hl]
 	cp $ff
 	ret z
@@ -2203,15 +2143,16 @@
 	ld a, [hli]
 	ld [de], a
 	inc de
-	jr .asm_412f4
+	jr .loop
 
-Function4130e: ; 4130e (10:530e)
+Pokedex_PutScrollbarOAM: ; 4130e (10:530e)
+; Writes the OAM data for the scrollbar in the new mode and ABC mode.
 	push de
 	ld a, [wDexListingEnd]
 	dec a
 	ld e, a
 	ld a, [wDexListingCursor]
-	ld hl, wDexListingPage
+	ld hl, wDexListingScrollOffset
 	add [hl]
 	cp e
 	jr z, .asm_4133f
@@ -2250,14 +2191,14 @@
 	ld [hl], $0
 	ret
 
-Function4134f: ; 4134f (10:534f)
+Pokedex_InitArrowCursor: ; 4134f (10:534f)
 	xor a
-	ld [wc7d8], a
-	ld [wc7d9], a
-	ld [wc7da], a
+	ld [wDexArrowCursorPosIndex], a
+	ld [wDexArrowCursorDelayCounter], a
+	ld [wDexArrowCursorBlinkCounter], a
 	ret
 
-Function4135a: ; 4135a (10:535a)
+Pokedex_MoveArrowCursor: ; 4135a (10:535a)
 ; bc = [de] - 1
 	ld a, [de]
 	ld b, a
@@ -2266,59 +2207,60 @@
 	dec a
 	ld c, a
 	inc de
-	call Pokedex_BlinkInfoScreenCursor
+	call Pokedex_BlinkArrowCursor
 
-	ld hl, hJoyPressed ; $ffa7
+	ld hl, hJoyPressed
 	ld a, [hl]
 	and D_LEFT | D_UP
 	and b
-	jr nz, .MoveCursorLeft
+	jr nz, .MoveCursorLeftOrUp
 	ld a, [hl]
 	and D_RIGHT | D_DOWN
 	and b
-	jr nz, .MoveCursorRight
+	jr nz, .MoveCursorRightOrDown
 	ld a, [hl]
 	and SELECT
 	and b
 	jr nz, .Select
-	call Pokedex_CursorFrameDelay
+	call Pokedex_ArrowCursorDelay
 	jr c, .NoAction
 	ld hl, hJoyLast
 	ld a, [hl]
 	and D_LEFT | D_UP
 	and b
-	jr nz, .MoveCursorLeft
+	jr nz, .MoveCursorLeftOrUp
 	ld a, [hl]
 	and D_RIGHT | D_DOWN
 	and b
-	jr nz, .MoveCursorRight
+	jr nz, .MoveCursorRightOrDown
 	jr .NoAction
 
-.MoveCursorLeft
-	ld a, [wc7d8]
+.MoveCursorLeftOrUp
+	ld a, [wDexArrowCursorPosIndex]
 	and a
 	jr z, .NoAction
-	call Pokedex_GetCursorPosition
+	call Pokedex_GetArrowCursorPos
 	ld [hl], " "
-	ld hl, wc7d8
+	ld hl, wDexArrowCursorPosIndex
 	dec [hl]
 	jr .UpdateCursorPosition
 
-.MoveCursorRight
-	ld a, [wc7d8]
+.MoveCursorRightOrDown
+	ld a, [wDexArrowCursorPosIndex]
 	cp c
 	jr nc, .NoAction
-	call Pokedex_GetCursorPosition
+	call Pokedex_GetArrowCursorPos
 	ld [hl], " "
-	ld hl, wc7d8
+	ld hl, wDexArrowCursorPosIndex
 	inc [hl]
+
 .UpdateCursorPosition
-	call Pokedex_GetCursorPosition
+	call Pokedex_GetArrowCursorPos
 	ld [hl], "▶"
-	ld a, $c
-	ld [wc7d9], a
+	ld a, 12
+	ld [wDexArrowCursorDelayCounter], a
 	xor a
-	ld [wc7da], a
+	ld [wDexArrowCursorBlinkCounter], a
 	scf
 	ret
 
@@ -2327,22 +2269,22 @@
 	ret
 
 .Select
-	call Pokedex_GetCursorPosition
+	call Pokedex_GetArrowCursorPos
 	ld [hl], " "
-	ld a, [wc7d8]
+	ld a, [wDexArrowCursorPosIndex]
 	cp c
 	jr c, .Update
-	ld a, $ff
+	ld a, -1
 .Update
 	inc a
-	ld [wc7d8], a
+	ld [wDexArrowCursorPosIndex], a
 	jr .UpdateCursorPosition
 
-Pokedex_GetCursorPosition: ; 413d4 (10:53d4)
-	ld a, [wc7d8]
+Pokedex_GetArrowCursorPos: ; 413d4 (10:53d4)
+	ld a, [wDexArrowCursorPosIndex]
 	add a
 	ld l, a
-	ld h, $0
+	ld h, 0
 	add hl, de
 	ld a, [hli]
 	ld h, [hl]
@@ -2349,23 +2291,25 @@
 	ld l, a
 	ret
 
-Pokedex_BlinkInfoScreenCursor: ; 413e0 (10:53e0)
-	ld hl, wc7da
+Pokedex_BlinkArrowCursor: ; 413e0 (10:53e0)
+	ld hl, wDexArrowCursorBlinkCounter
 	ld a, [hl]
 	inc [hl]
 	and $8
 	jr z, .blink_on
-	call Pokedex_GetCursorPosition
+	call Pokedex_GetArrowCursorPos
 	ld [hl], " "
 	ret
 
 .blink_on
-	call Pokedex_GetCursorPosition
+	call Pokedex_GetArrowCursorPos
 	ld [hl], "▶"
 	ret
 
-Pokedex_CursorFrameDelay: ; 413f5 (10:53f5)
-	ld hl, wc7d9
+Pokedex_ArrowCursorDelay: ; 413f5 (10:53f5)
+; Updates the delay counter set when moving the arrow cursor.
+; Returns whether the delay is active in carry.
+	ld hl, wDexArrowCursorDelayCounter
 	ld a, [hl]
 	and a
 	ret z
@@ -2377,7 +2321,8 @@
 Pokedex_FillBox: ; 413fe (10:53fe)
 	jp FillBoxWithByte
 
-Function41401: ; 41401 (10:5401)
+Pokedex_BlackOutBG: ; 41401 (10:5401)
+; Make BG palettes black so that the BG becomes all black.
 	ld a, [rSVBK]
 	push af
 	ld a, $5
@@ -2397,7 +2342,7 @@
 	call DelayFrame
 	ret
 
-Function41423: ; 41423
+Pokedex_GetSGBLayout: ; 41423
 	ld b, a
 	call GetSGBLayout
 
@@ -2407,7 +2352,6 @@
 	ld a, $e0
 	call DmgToCgbObjPal0
 	ret
-; 41432
 
 
 Pokedex_LoadPointer: ; 41432
@@ -2420,10 +2364,10 @@
 	ld h, [hl]
 	ld l, a
 	ret
-; 4143b
 
-Function4143b: ; 4143b
-	call Pokedex_GetMonAtCursorPosition
+Pokedex_LoadSelectedMonTiles: ; 4143b
+; Loads the tiles of the currently selected Pokémon.
+	call Pokedex_GetSelectedMon
 	call Pokedex_CheckSeen
 	jr z, .QuestionMark
 	ld a, [wFirstUnownSeen]
@@ -2447,11 +2391,10 @@
 	call Get2bpp
 	call CloseSRAM
 	ret
-; 41478
 
 
 Pokedex_LoadCurrentFootprint: ; 41478 (10:5478)
-	call Pokedex_GetMonAtCursorPosition
+	call Pokedex_GetSelectedMon
 
 Pokedex_LoadAnyFootprint: ; 4147b
 	ld a, [wd265]
@@ -2492,7 +2435,6 @@
 	call Request1bpp
 
 	ret
-; 414b7
 
 
 Pokedex_LoadGFX: ; 414b7
@@ -2540,11 +2482,9 @@
 	or c
 	jr nz, .loop
 	ret
-; 4150e
 
 PokedexLZ: ; 4150e
 INCBIN "gfx/pokedex/pokedex.2bpp.lz"
-; 416b0
 
 PokedexSlowpokeLZ: ; 416b0
 INCBIN "gfx/pokedex/slowpoke.2bpp.lz"
@@ -2556,7 +2496,6 @@
 	ld a, [hSGB]
 	dec a
 	ret
-; 41a2c
 
 Pokedex_LoadUnownFont: ; 41a2c
 	ld a, BANK(sScratch)
@@ -2575,7 +2514,6 @@
 	call Request2bpp
 	call CloseSRAM
 	ret
-; 41a58
 
 Function41a58: ; 41a58 (10:5a58)
 	ld a, [UnownLetter]
@@ -2583,7 +2521,7 @@
 	ld a, [wc7dd]
 	ld e, a
 	ld d, $0
-	ld hl, EndPokedexSeen ; wded9 (aliases: UnownDex)
+	ld hl, UnownDex
 	add hl, de
 	ld a, [hl]
 	ld [UnownLetter], a
@@ -2595,7 +2533,6 @@
 	pop af
 	ld [UnownLetter], a
 	ret
-; 41a7f
 
 _NewPokedexEntry: ; 41a7f
 	xor a
@@ -2609,7 +2546,7 @@
 	call Pokedex_LoadAnyFootprint
 	ld a, [wd265]
 	ld [CurPartySpecies], a
-	call Function407fd
+	call Pokedex_DrawDexEntryScreenBG
 	call Pokedex_DrawFootprint
 	hlcoord 0, 17
 	ld [hl], $3b
@@ -2623,12 +2560,11 @@
 	call GetBaseData
 	ld de, VTiles2
 	predef GetFrontpic
-	ld a, $4
-	call Function41423
+	ld a, SCGB_POKEDEX
+	call Pokedex_GetSGBLayout
 	ld a, [CurPartySpecies]
 	call PlayCry
 	ret
-; 41ad7
 
 
 Pokedex_SetBGMapMode3: ; 41ad7 (10:5ad7)
@@ -2659,4 +2595,3 @@
 	xor a
 	ld [hBGMapMode], a
 	ret
-; 41afb
--- a/predef/cgb.asm
+++ b/predef/cgb.asm
@@ -37,7 +37,7 @@
 	dw _CGB_BattleColors
 	dw _CGB_PokegearPals
 	dw _CGB_StatsScreenHPPals
-	dw _CGB04
+	dw _CGB_Pokedex
 	dw _CGB_SlotMachine
 	dw _CGB06
 	dw _CGB07
@@ -282,7 +282,7 @@
 	RGB 17, 31, 31
 ; 8f70
 
-_CGB04: ; 8f70
+_CGB_Pokedex: ; 8f70
 	ld de, UnknBGPals
 	ld a, $1d
 	call GetPredefPal
--- a/predef/sgb.asm
+++ b/predef/sgb.asm
@@ -28,7 +28,7 @@
 	dw .SGB_BattleColors
 	dw .SGB_PokegearPals
 	dw .SGB_StatsScreenHPPals
-	dw .SGB04
+	dw .SGB_Pokedex
 	dw .SGB_SlotMachine
 	dw .SGB06
 	dw .SGB07
@@ -209,7 +209,7 @@
 	ret
 ; 87b2
 
-.SGB04: ; 87b2
+.SGB_Pokedex: ; 87b2
 	ld hl, PalPacket_9ce6
 	ld de, wSGBPals
 	ld bc, $10
@@ -267,7 +267,7 @@
 ; 8823
 
 .SGB16: ; 8823
-	call .SGB04
+	call .SGB_Pokedex
 	ld de, BlkPacket_9af6
 	ret
 ; 882a
--- a/wram.asm
+++ b/wram.asm
@@ -921,26 +921,27 @@
 wPokedexOrder:: ds NUM_POKEMON +- 1
 wPokedexOrderEnd:: ds 6
 wPokedexMetadata::
-wDexListingPage::
-wc7d0:: ds 1 ; Dex list page
+wDexListingScrollOffset:: ; offset of the first displayed entry from the start
+wc7d0:: ds 1
 wDexListingCursor::
 wc7d1:: ds 1 ; Dex cursor
 wDexListingEnd::
 wc7d2:: ds 1 ; Last mon to display
-wc7d3:: ds 1 ; Number of mons visible per dex list page
+wDexListingHeight:: ; number of entries displayed at once in the dex listing
+wc7d3:: ds 1
 wCurrentDexMode::   ; Pokedex Mode
 wc7d4:: ds 1 ; Index of the topmost visible item in a scrolling menu
-wc7d5:: ds 1 ; Which row the cursor is at in a scrolling menu (0-6)
-wc7d6:: ds 1
-wc7d7:: ds 1
-wc7d8:: ds 1
-wc7d9:: ds 1
-wc7da:: ds 1
+wDexSearchMonType1:: ds 1 ; first type to search
+wDexSearchMonType2:: ds 1 ; second type to search
+wDexSearchResultCount:: ds 1
+wDexArrowCursorPosIndex:: ds 1
+wDexArrowCursorDelayCounter:: ds 1
+wDexArrowCursorBlinkCounter:: ds 1
 wDexSearchSlowpokeFrame:: ds 1
 wUnlockedUnownMode:: ds 1
 wc7dd:: ds 1
 wc7de:: ds 1
-wc7df:: ds 1
+wDexConvertedMonType:: ds 1 ; mon type converted from dex search mon type
 wc7e0:: ds 1
 wc7e1:: ds 1
 wBackupDexListingCursor::