diff options
author | YamaArashi <shadow962@live.com> | 2016-01-09 17:51:14 -0800 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-01-09 17:51:14 -0800 |
commit | e033ea3a37f594d04b7132ad54765a8fee312ae5 (patch) | |
tree | dd03597df2fdb8e956601cd0c34fab2b4786b848 | |
parent | f14562da4b066a80af3edfc5171e083f63532109 (diff) |
commented pokedex more
-rwxr-xr-x | constants/cgb_constants.asm | 2 | ||||
-rw-r--r-- | engine/pokedex.asm | 879 | ||||
-rw-r--r-- | predef/cgb.asm | 4 | ||||
-rw-r--r-- | predef/sgb.asm | 6 | ||||
-rw-r--r-- | wram.asm | 21 |
5 files changed, 424 insertions, 488 deletions
diff --git a/constants/cgb_constants.asm b/constants/cgb_constants.asm index 028cc71d7..ac40af7a4 100755 --- 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 diff --git a/engine/pokedex.asm b/engine/pokedex.asm index d1e2d7edf..379de56ba 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -57,7 +57,6 @@ Pokedex: ; 40000 ld a, h ld [hWY], a ret -; 40063 InitPokedex: ; 40063 call ClearBGPalettes @@ -87,7 +86,6 @@ InitPokedex: ; 40063 callba Function1de247 call Pokedex_ResetBGMapMode ret -; 400a2 Pokedex_CheckUnlockedUnownMode: ; 400a2 ld a, [StatusFlags] @@ -102,7 +100,6 @@ Pokedex_CheckUnlockedUnownMode: ; 400a2 ld a, TRUE ld [wUnlockedUnownMode], a ret -; 400b4 Pokedex_InitCursorPosition: ; 400b4 ld hl, wPokedexDataStart @@ -124,9 +121,9 @@ Pokedex_InitCursorPosition: ; 400b4 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 @@ Pokedex_InitCursorPosition: ; 400b4 .done ret -; 400ed Pokedex_GetLandmark: ; 400ed ld a, [MapGroup] @@ -166,31 +162,29 @@ Pokedex_GetLandmark: ; 400ed .load ld [wDexCurrentLocation], a ret -; 4010b Pokedex_Main: ; 4010b ld a, [wJumptableIndex] 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 @@ Pokedex_CloseDex: ; 40136 (10:4136) set 7, [hl] ret -Function4013c: ; 4013c (10:413c) +Pokedex_InitMainScreen: ; 4013c (10:413c) xor a ld [hBGMapMode], a call ClearSprites @@ -215,12 +209,12 @@ Function4013c: ; 4013c (10:413c) 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 @@ Function4013c: ; 4013c (10:413c) 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 @@ Function401ae: ; 401ae (10:41ae) 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 @@ Function401ae: ; 401ae (10:41ae) ret .select - call Function41401 + call Pokedex_BlackOutBG ld a, $7 ld [wJumptableIndex], a xor a @@ -297,7 +291,7 @@ Function401ae: ; 401ae (10:41ae) ret .start - call Function41401 + call Pokedex_BlackOutBG ld a, $5 ld [wJumptableIndex], a xor a @@ -312,7 +306,7 @@ Function401ae: ; 401ae (10:41ae) ld [wJumptableIndex], a ret -Function40217: ; 40217 (10:4217) +Pokedex_InitDexEntryScreen: ; 40217 (10:4217) call LowVolume xor a ld [wPokedexStatus], a @@ -320,28 +314,28 @@ Function40217: ; 40217 (10:4217) 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 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 @@ Function40258: ; 40258 (10:4258) ret .a - ld a, [wc7d8] + ld a, [wDexArrowCursorPosIndex] ld hl, DexEntryPage_Jumptable call Pokedex_LoadPointer jp [hl] @@ -371,63 +365,59 @@ Function40258: ; 40258 (10:4258) 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 dwcoord 11, 17 dwcoord 15, 17 -; 402f2 DexEntryPage_Jumptable: ; 402f2 dw Pokedex_Page 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 @@ DexEntryPage_Jumptable: ; 402f2 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,24 +439,22 @@ DexEntryPage_Jumptable: ; 402f2 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 ld d, b call PlayCryHeader ret -; 4034f .Print: ; 4034f call Function41415 @@ -495,32 +483,30 @@ DexEntryPage_Jumptable: ; 402f2 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 @@ Function403be: ; 403be (10:43be) .asm_403c9 ld de, Unknown_403fb .asm_403cc - call Function4135a + call Pokedex_MoveArrowCursor call c, Function40e5b ld hl, hJoyPressed ; $ffa7 ld a, [hl] @@ -542,24 +528,22 @@ Function403be: ; 403be (10:43be) 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 dwcoord 2, 4 dwcoord 2, 6 dwcoord 2, 8 -; 403fb Unknown_403fb: ; 403fb db D_UP | D_DOWN, 4 @@ -567,14 +551,12 @@ Unknown_403fb: ; 403fb dwcoord 2, 6 dwcoord 2, 8 dwcoord 2, 10 -; 40405 Jumptable_40405: ; 40405 (10:4405) dw Function4040d dw Function40411 dw Function40415 dw Function4043a -; 4040d Function4040d: ; 4040d (10:440d) ld b, DEXMODE_NEW @@ -595,48 +577,48 @@ Function40417: ; 40417 (10:4417) 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,80 +628,74 @@ Function40471: ; 40471 (10:4471) 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 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 @@ Function4050a: ; 4050a (10:450a) 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 @@ Function4050a: ; 4050a (10:450a) 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 @@ Function40562: ; 40562 (10:4562) 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 @@ Function40562: ; 40562 (10:4562) .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 @@ Function40562: ; 40562 (10:4562) 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 @@ Pokedex_UnownMode: ; 405bd (10:45bd) 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 @@ Function405df: ; 405df (10:45df) ret .a_b - call Function41401 + call Pokedex_BlackOutBG ld a, $7 ld [wJumptableIndex], a call DelayFrame @@ -909,7 +885,7 @@ endr 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 @@ Pokedex_NextOrPreviousDexEntry: ; 4066c (10:466c) 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,118 +929,126 @@ Pokedex_NextOrPreviousDexEntry: ; 4066c (10:466c) 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 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 @@ Function4074c: ; 4074c (10:474c) 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 @@ Function4074c: ; 4074c (10:474c) 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 @@ Function4074c: ; 4074c (10:474c) ld [hl], $5b call Pokedex_PlaceFrontpicTopLeftCorner ret -; 407e1 (10:47e1) String_SEEN: ; 407e1 db "SEEN", $ff @@ -1129,9 +1112,8 @@ String_SELECT_OPTION: ; 407ea 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 @@ Function407fd: ; 407fd 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 @@ Function407fd: ; 407fd 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 @@ Function4087c: ; 4087c (10:487c) 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 @@ Function40962: ; 40962 (10:4962) 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 @@ Function40962: ; 40962 (10:4962) 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 @@ Function40962: ; 40962 (10:4962) 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 @@ endr ld a, b ld [wc7de], a ret -; 40a3e (10:4a3e) Unknown_40a3e: ; 40a3e ; letter, cursor @@ -1383,7 +1351,6 @@ Unknown_40a3e: ; 40a3e 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 @@ Pokedex_FillBackgroundColor2: ; 40aa6 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill ret -; 40ab2 Pokedex_PlaceFrontpicTopLeftCorner: ; 40ab2 hlcoord 1, 1 @@ -1415,7 +1381,6 @@ Pokedex_PlaceFrontpicAtHL: ; 40ab5 dec b jr nz, .row ret -; 40acd Pokedex_PlaceString: ; 40acd .loop @@ -1425,7 +1390,6 @@ Pokedex_PlaceString: ; 40acd inc de ld [hli], a jr .loop -; 40ad5 Pokedex_PlaceBorder: ; 40ad5 @@ -1459,7 +1423,6 @@ Pokedex_PlaceBorder: ; 40ad5 ld a, $3a ld [hl], a ret -; 40b06 .FillRow: ; 40b06 ld e, c @@ -1471,10 +1434,11 @@ Pokedex_PlaceBorder: ; 40ad5 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,18 +1448,19 @@ Function40b0f: ; 40b0f (10:4b0f) .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 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,14 +1468,14 @@ Function40b0f: ; 40b0f (10:4b0f) ld e, l ld d, h hlcoord 0, 2 - ld a, [wc7d3] + ld a, [wDexListingHeight] .loop push af ld a, [de] 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 @@ Function40b0f: ; 40b0f (10:4b0f) 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 @@ Pokedex_PlaceDefaultStringIfNotSeen: ; 40b8d (10:4b8d) call PlaceString scf ret -; 40b9a (10:4b9a) .NameNotSeen: ; 40b9a db "-----@" -; 40ba0 Pokedex_DrawFootprint: ; 40ba0 hlcoord 18, 1 @@ -1588,12 +1552,14 @@ Pokedex_DrawFootprint: ; 40ba0 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 @@ Pokedex_GetMonAtCursorPosition: ; 40bb1 ld a, [hl] ld [wd265], a ret -; 40bc4 Pokedex_CheckCaught: ; 40bc4 (10:4bc4) @@ -1625,7 +1590,6 @@ Pokedex_CheckSeen: ; 40bd0 pop hl pop de ret -; 40bdc @@ -1638,7 +1602,6 @@ Pokedex_ChangeMode: ; 40bdc ld hl, .Jumptable call Pokedex_LoadPointer jp [hl] -; 40bf0 .Jumptable: ; 40bf0 (10:4bf0) @@ -1724,7 +1687,6 @@ Pokedex_ABCMode: ; 40c30 .doneabc ret -; 40c65 AlphabeticalPokedexOrder: ; 0x40c65 INCLUDE "data/pokedex/order_alpha.asm" @@ -1738,7 +1700,7 @@ Function40e5b: ; 40e5b 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,34 +1710,28 @@ Function40e5b: ; 40e5b ld a, $1 ld [hBGMapMode], a ret -; 40e7d Unknown_40e7d: ; 40e7d dw .NewMode 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,39 +1751,38 @@ Function40f08: ; 40f08 (10:4f08) 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 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 @@ Function40f4f: ; 40f4f (10:4f4f) .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 @@ Function40f84: ; 40f84 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 @@ Function40f84: ; 40f84 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 @@ endr pop hl call PlaceString ret -; 40fe4 (10:4fe4) -Strings_40fe4: ; 40fe4 +.TypeStrings: ; 40fe4 db " ---- @" db " NORMAL @" db " FIRE @" @@ -1917,84 +1870,83 @@ Strings_40fe4: ; 40fe4 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 @@ Unknown_410f6: ; 410f6 db DRAGON db DARK db STEEL -; 41107 Function41107: ; 41107 xor a @@ -2028,34 +1979,30 @@ Function41107: ; 41107 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 @@ Unknown_41167: ; 41167 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 @@ Unknown_411c8: ; 411c8 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 @@ Unknown_41230: ; 41230 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 @@ Unknown_41290: ; 41290 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 @@ Function412f1: ; 412f1 (10:52f1) 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 @@ Function4130e: ; 4130e (10:530e) 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 @@ Function4135a: ; 4135a (10:535a) 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,45 +2269,47 @@ Function4135a: ; 4135a (10:535a) 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] 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_CursorFrameDelay: ; 413f5 (10:53f5) 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 @@ Function41415: ; 41415 call DelayFrame ret -Function41423: ; 41423 +Pokedex_GetSGBLayout: ; 41423 ld b, a call GetSGBLayout @@ -2407,7 +2352,6 @@ Function41427: ; 41427 ld a, $e0 call DmgToCgbObjPal0 ret -; 41432 Pokedex_LoadPointer: ; 41432 @@ -2420,10 +2364,10 @@ endr 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 @@ Function4143b: ; 4143b 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 @@ Pokedex_LoadAnyFootprint: ; 4147b call Request1bpp ret -; 414b7 Pokedex_LoadGFX: ; 414b7 @@ -2540,11 +2482,9 @@ Pokedex_InvertTiles: ; 41504 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 @@ Pokedex_CheckSGB: ; 41a24 ld a, [hSGB] dec a ret -; 41a2c Pokedex_LoadUnownFont: ; 41a2c ld a, BANK(sScratch) @@ -2575,7 +2514,6 @@ Pokedex_LoadUnownFont: ; 41a2c call Request2bpp call CloseSRAM ret -; 41a58 Function41a58: ; 41a58 (10:5a58) ld a, [UnownLetter] @@ -2583,7 +2521,7 @@ Function41a58: ; 41a58 (10:5a58) 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 @@ Function41a58: ; 41a58 (10:5a58) pop af ld [UnownLetter], a ret -; 41a7f _NewPokedexEntry: ; 41a7f xor a @@ -2609,7 +2546,7 @@ _NewPokedexEntry: ; 41a7f 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 @@ _NewPokedexEntry: ; 41a7f 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 @@ Pokedex_ResetBGMapMode: ; 41af7 xor a ld [hBGMapMode], a ret -; 41afb diff --git a/predef/cgb.asm b/predef/cgb.asm index 9a24dfce1..ef0b242d3 100644 --- a/predef/cgb.asm +++ b/predef/cgb.asm @@ -37,7 +37,7 @@ Predef_LoadSGBLayoutCGB: ; 8d59 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 @@ StatsScreenPals: ; 8f6a RGB 17, 31, 31 ; 8f70 -_CGB04: ; 8f70 +_CGB_Pokedex: ; 8f70 ld de, UnknBGPals ld a, $1d call GetPredefPal diff --git a/predef/sgb.asm b/predef/sgb.asm index be44adc63..3d400bafe 100644 --- a/predef/sgb.asm +++ b/predef/sgb.asm @@ -28,7 +28,7 @@ Predef_LoadSGBLayout: ; 864c 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 @@ endr ret ; 87b2 -.SGB04: ; 87b2 +.SGB_Pokedex: ; 87b2 ld hl, PalPacket_9ce6 ld de, wSGBPals ld bc, $10 @@ -267,7 +267,7 @@ endr ; 8823 .SGB16: ; 8823 - call .SGB04 + call .SGB_Pokedex ld de, BlkPacket_9af6 ret ; 882a @@ -921,26 +921,27 @@ wPokedexDataStart:: 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:: |