pokecrystal-board/engine/pokedex/pokedex.asm

2576 lines
45 KiB
NASM
Raw Normal View History

2018-01-11 09:00:01 -08:00
; Pokedex_RunJumptable.Jumptable indexes
2016-01-09 23:05:34 -08:00
const_def
const DEXSTATE_MAIN_SCR
const DEXSTATE_UPDATE_MAIN_SCR
const DEXSTATE_DEX_ENTRY_SCR
const DEXSTATE_UPDATE_DEX_ENTRY_SCR
const DEXSTATE_REINIT_DEX_ENTRY_SCR
const DEXSTATE_SEARCH_SCR
const DEXSTATE_UPDATE_SEARCH_SCR
const DEXSTATE_OPTION_SCR
const DEXSTATE_UPDATE_OPTION_SCR
const DEXSTATE_SEARCH_RESULTS_SCR
const DEXSTATE_UPDATE_SEARCH_RESULTS_SCR
const DEXSTATE_UNOWN_MODE
const DEXSTATE_UPDATE_UNOWN_MODE
const DEXSTATE_EXIT
2015-02-11 13:36:02 -08:00
2018-01-21 13:53:19 -08:00
POKEDEX_SCX EQU 5
GLOBAL POKEDEX_SCX
2018-01-16 14:59:05 -08:00
2018-06-24 07:09:41 -07:00
Pokedex:
ldh a, [hWX]
2015-02-11 13:36:02 -08:00
ld l, a
ldh a, [hWY]
2015-02-11 13:36:02 -08:00
ld h, a
push hl
ldh a, [hSCX]
2015-02-11 13:36:02 -08:00
push af
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-02-11 13:36:02 -08:00
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
2018-01-23 14:39:09 -08:00
ld a, [wVramState]
2015-02-11 13:36:02 -08:00
push af
xor a
2018-01-23 14:39:09 -08:00
ld [wVramState], a
ldh a, [hInMenu]
2015-02-11 13:36:02 -08:00
push af
ld a, $1
ldh [hInMenu], a
2015-02-11 13:36:02 -08:00
xor a
ldh [hMapAnims], a
2015-02-11 13:36:02 -08:00
call InitPokedex
call DelayFrame
.main
call JoyTextDelay
2015-10-24 16:49:19 -07:00
ld a, [wJumptableIndex]
2015-02-11 13:36:02 -08:00
bit 7, a
jr nz, .exit
2016-01-09 23:05:34 -08:00
call Pokedex_RunJumptable
2015-02-11 13:36:02 -08:00
call DelayFrame
jr .main
.exit
ld de, SFX_READ_TEXT_2
call PlaySFX
call WaitSFX
call ClearSprites
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
ld [wLastDexMode], a
2015-02-11 13:36:02 -08:00
pop af
ldh [hInMenu], a
2015-02-11 13:36:02 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wVramState], a
2015-02-11 13:36:02 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2015-02-11 13:36:02 -08:00
pop af
ldh [hSCX], a
2015-02-11 13:36:02 -08:00
pop hl
ld a, l
ldh [hWX], a
2015-02-11 13:36:02 -08:00
ld a, h
ldh [hWY], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
InitPokedex:
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
2015-02-11 13:36:02 -08:00
call ClearSprites
call ClearTileMap
2015-11-29 18:34:59 -08:00
call Pokedex_LoadGFX
2015-02-11 13:36:02 -08:00
2015-11-12 21:49:27 -08:00
ld hl, wPokedexDataStart
ld bc, wPokedexDataEnd - wPokedexDataStart
2015-02-11 13:36:02 -08:00
xor a
call ByteFill
xor a
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2018-01-11 12:36:11 -08:00
ld [wPrevDexEntryJumptableIndex], a
ld [wPrevDexEntryBackup], a
2015-02-11 13:36:02 -08:00
ld [wcf66], a
2015-11-29 18:34:59 -08:00
call Pokedex_CheckUnlockedUnownMode
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
ld a, [wLastDexMode]
ld [wCurrentDexMode], a
2015-02-11 13:36:02 -08:00
2016-01-09 19:03:38 -08:00
call Pokedex_OrderMonsByMode
2015-11-29 18:34:59 -08:00
call Pokedex_InitCursorPosition
call Pokedex_GetLandmark
2017-12-24 09:47:30 -08:00
farcall DrawDexEntryScreenRightEdge
2015-11-29 18:34:59 -08:00
call Pokedex_ResetBGMapMode
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_CheckUnlockedUnownMode:
ld a, [wStatusFlags]
2018-01-22 12:40:43 -08:00
bit STATUSFLAGS_UNOWN_DEX_F, a
2015-11-29 18:34:59 -08:00
jr nz, .unlocked
2015-02-11 13:36:02 -08:00
xor a
2015-11-29 18:34:59 -08:00
ld [wUnlockedUnownMode], a
2015-02-11 13:36:02 -08:00
ret
2015-11-29 18:34:59 -08:00
.unlocked
ld a, TRUE
ld [wUnlockedUnownMode], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_InitCursorPosition:
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder
2018-01-11 12:36:11 -08:00
ld a, [wPrevDexEntry]
2015-02-11 13:36:02 -08:00
and a
2015-11-29 18:34:59 -08:00
jr z, .done
cp NUM_POKEMON + 1
jr nc, .done
2015-02-11 13:36:02 -08:00
ld b, a
2015-11-29 18:34:59 -08:00
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
cp $8
2015-11-29 18:34:59 -08:00
jr c, .only_one_page
2015-02-11 13:36:02 -08:00
sub $7
ld c, a
2015-11-29 18:34:59 -08:00
.loop1
2015-02-11 13:36:02 -08:00
ld a, b
cp [hl]
2015-11-29 18:34:59 -08:00
jr z, .done
2015-02-11 13:36:02 -08:00
inc hl
2016-01-09 17:51:14 -08:00
ld a, [wDexListingScrollOffset]
2015-02-11 13:36:02 -08:00
inc a
2016-01-09 17:51:14 -08:00
ld [wDexListingScrollOffset], a
2015-02-11 13:36:02 -08:00
dec c
2015-11-29 18:34:59 -08:00
jr nz, .loop1
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
.only_one_page
2015-02-11 13:36:02 -08:00
ld c, $7
2015-11-29 18:34:59 -08:00
.loop2
2015-02-11 13:36:02 -08:00
ld a, b
cp [hl]
2015-11-29 18:34:59 -08:00
jr z, .done
2015-02-11 13:36:02 -08:00
inc hl
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
2015-02-11 13:36:02 -08:00
inc a
2015-11-29 18:34:59 -08:00
ld [wDexListingCursor], a
2015-02-11 13:36:02 -08:00
dec c
2015-11-29 18:34:59 -08:00
jr nz, .loop2
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
.done
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_GetLandmark:
2018-01-23 14:39:09 -08:00
ld a, [wMapGroup]
2015-02-11 13:36:02 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wMapNumber]
2015-02-11 13:36:02 -08:00
ld c, a
call GetWorldMapLocation
cp SPECIAL_MAP
2015-11-29 18:34:59 -08:00
jr nz, .load
2015-02-11 13:36:02 -08:00
2018-01-23 14:39:09 -08:00
ld a, [wBackupMapGroup]
2015-02-11 13:36:02 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wBackupMapNumber]
2015-02-11 13:36:02 -08:00
ld c, a
call GetWorldMapLocation
2015-11-29 18:34:59 -08:00
.load
ld [wDexCurrentLocation], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_RunJumptable:
2015-10-24 16:49:19 -07:00
ld a, [wJumptableIndex]
2015-11-29 18:34:59 -08:00
ld hl, .Jumptable
call Pokedex_LoadPointer
jp hl
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.Jumptable:
2018-01-11 09:00:01 -08:00
; entries correspond to DEXSTATE_* constants
2016-01-09 17:51:14 -08:00
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
2016-01-09 23:05:34 -08:00
dw Pokedex_Exit
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_IncrementDexPointer:
2015-10-24 16:49:19 -07:00
ld hl, wJumptableIndex
2015-02-11 13:36:02 -08:00
inc [hl]
ret
2018-06-24 07:09:41 -07:00
Pokedex_Exit:
2015-10-24 16:49:19 -07:00
ld hl, wJumptableIndex
2015-02-11 13:36:02 -08:00
set 7, [hl]
ret
2018-06-24 07:09:41 -07:00
Pokedex_InitMainScreen:
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call ClearSprites
xor a
2018-01-23 14:39:09 -08:00
hlcoord 0, 0, wAttrMap
2015-11-29 18:34:59 -08:00
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
2015-02-11 13:36:02 -08:00
call ByteFill
2017-12-24 09:47:30 -08:00
farcall DrawPokedexListWindow
2015-02-11 13:36:02 -08:00
hlcoord 0, 17
ld de, String_START_SEARCH
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2016-01-09 17:51:14 -08:00
ld a, 7
ld [wDexListingHeight], a
call Pokedex_PrintListing
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode_3ifDMG_4ifCGB
call Pokedex_ResetBGMapMode
2016-01-09 19:03:38 -08:00
call Pokedex_DrawMainScreenBG
2018-01-21 13:53:19 -08:00
ld a, POKEDEX_SCX
ldh [hSCX], a
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
cp DEXMODE_OLD
2015-02-11 13:36:02 -08:00
ld a, $4a
2015-11-29 18:34:59 -08:00
jr z, .okay
2015-02-11 13:36:02 -08:00
ld a, $47
2015-11-29 18:34:59 -08:00
.okay
ldh [hWX], a
2015-02-11 13:36:02 -08:00
xor a
ldh [hWY], a
2015-02-11 13:36:02 -08:00
call WaitBGMap
2015-11-29 18:34:59 -08:00
call Pokedex_ResetBGMapMode
ld a, -1
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-01-09 17:51:14 -08:00
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
call Pokedex_UpdateCursorOAM
2017-12-24 09:47:30 -08:00
farcall DrawPokedexListWindow
2015-02-11 13:36:02 -08:00
hlcoord 0, 17
ld de, String_START_SEARCH
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2016-01-09 17:51:14 -08:00
ld a, 7
ld [wDexListingHeight], a
call Pokedex_PrintListing
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_UpdateMainScreen:
2016-01-09 17:51:14 -08:00
ld hl, hJoyPressed
2015-02-11 13:36:02 -08:00
ld a, [hl]
and B_BUTTON
jr nz, .b
ld a, [hl]
and A_BUTTON
jr nz, .a
ld a, [hl]
and SELECT
jr nz, .select
ld a, [hl]
and START
jr nz, .start
2016-01-09 17:51:14 -08:00
call Pokedex_ListingHandleDPadInput
2015-02-11 13:36:02 -08:00
ret nc
2016-01-09 17:51:14 -08:00
call Pokedex_UpdateCursorOAM
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 17:51:14 -08:00
call Pokedex_PrintListing
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode3
call Pokedex_ResetBGMapMode
2015-02-11 13:36:02 -08:00
ret
.a
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
2015-02-11 13:36:02 -08:00
ret z
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_DEX_ENTRY_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_MAIN_SCR
2018-01-11 12:36:11 -08:00
ld [wPrevDexEntryJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
.select
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_OPTION_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
xor a
ldh [hSCX], a
2015-02-11 13:36:02 -08:00
ld a, $a7
ldh [hWX], a
2015-02-11 13:36:02 -08:00
call DelayFrame
ret
.start
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_SEARCH_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
xor a
ldh [hSCX], a
2015-02-11 13:36:02 -08:00
ld a, $a7
ldh [hWX], a
2015-02-11 13:36:02 -08:00
call DelayFrame
ret
.b
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_EXIT
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_InitDexEntryScreen:
2015-02-11 13:36:02 -08:00
call LowVolume
2018-01-16 14:59:05 -08:00
xor a ; page 1
ld [wPokedexStatus], a
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call ClearSprites
2015-11-29 18:34:59 -08:00
call Pokedex_LoadCurrentFootprint
2016-01-09 17:51:14 -08:00
call Pokedex_DrawDexEntryScreenBG
call Pokedex_InitArrowCursor
call Pokedex_GetSelectedMon
2018-01-11 12:36:11 -08:00
ld [wPrevDexEntry], a
2017-12-24 09:47:30 -08:00
farcall DisplayDexEntry
2015-11-29 18:34:59 -08:00
call Pokedex_DrawFootprint
2015-02-11 13:36:02 -08:00
call WaitBGMap
ld a, $a7
ldh [hWX], a
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-01-09 17:51:14 -08:00
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
call PlayMonCry
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_UpdateDexEntryScreen:
2016-01-09 17:51:14 -08:00
ld de, DexEntryScreen_ArrowCursorData
call Pokedex_MoveArrowCursor
ld hl, hJoyPressed
2015-02-11 13:36:02 -08:00
ld a, [hl]
and B_BUTTON
2016-01-09 19:03:38 -08:00
jr nz, .return_to_prev_screen
2015-02-11 13:36:02 -08:00
ld a, [hl]
and A_BUTTON
2016-01-09 19:03:38 -08:00
jr nz, .do_menu_action
2015-11-29 18:34:59 -08:00
call Pokedex_NextOrPreviousDexEntry
2015-02-11 13:36:02 -08:00
ret nc
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
2016-01-09 19:03:38 -08:00
.do_menu_action
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2016-01-09 19:03:38 -08:00
ld hl, DexEntryScreen_MenuActionJumptable
2015-11-29 18:34:59 -08:00
call Pokedex_LoadPointer
jp hl
2015-02-11 13:36:02 -08:00
2016-01-09 19:03:38 -08:00
.return_to_prev_screen
2018-01-23 14:39:09 -08:00
ld a, [wLastVolume]
2015-02-11 13:36:02 -08:00
and a
2015-11-29 18:34:59 -08:00
jr z, .max_volume
2015-02-11 13:36:02 -08:00
ld a, $77
2018-01-23 14:39:09 -08:00
ld [wLastVolume], a
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
.max_volume
2015-02-11 13:36:02 -08:00
call MaxVolume
2018-01-11 12:36:11 -08:00
ld a, [wPrevDexEntryJumptableIndex]
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_Page:
ld a, [wPokedexStatus]
2018-01-16 14:59:05 -08:00
xor 1 ; toggle page
ld [wPokedexStatus], a
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2018-01-11 12:36:11 -08:00
ld [wPrevDexEntry], a
2017-12-24 09:47:30 -08:00
farcall DisplayDexEntry
2015-02-11 13:36:02 -08:00
call WaitBGMap
ret
2018-06-24 07:09:41 -07:00
Pokedex_ReinitDexEntryScreen:
2016-01-09 17:51:14 -08:00
; Reinitialize the Pokédex entry screen after changing the selected mon.
call Pokedex_BlackOutBG
2018-01-16 14:59:05 -08:00
xor a ; page 1
ld [wPokedexStatus], a
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 17:51:14 -08:00
call Pokedex_DrawDexEntryScreenBG
call Pokedex_InitArrowCursor
2015-11-29 18:34:59 -08:00
call Pokedex_LoadCurrentFootprint
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2018-01-11 12:36:11 -08:00
ld [wPrevDexEntry], a
2017-12-24 09:47:30 -08:00
farcall DisplayDexEntry
2015-11-29 18:34:59 -08:00
call Pokedex_DrawFootprint
2016-01-09 17:51:14 -08:00
call Pokedex_LoadSelectedMonTiles
2015-02-11 13:36:02 -08:00
call WaitBGMap
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-01-09 17:51:14 -08:00
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
call PlayMonCry
2015-10-24 16:49:19 -07:00
ld hl, wJumptableIndex
2015-02-11 13:36:02 -08:00
dec [hl]
ret
2018-06-24 07:09:41 -07:00
DexEntryScreen_ArrowCursorData:
2015-11-29 18:34:59 -08:00
db D_RIGHT | D_LEFT, 4
2018-01-16 14:59:05 -08:00
dwcoord 1, 17 ; PAGE
dwcoord 6, 17 ; AREA
dwcoord 11, 17 ; CRY
dwcoord 15, 17 ; PRNT
2015-11-29 18:34:59 -08:00
2018-06-24 07:09:41 -07:00
DexEntryScreen_MenuActionJumptable:
2015-12-09 08:38:40 -08:00
dw Pokedex_Page
dw .Area
dw .Cry
dw .Print
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.Area:
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2015-02-11 13:36:02 -08:00
xor a
ldh [hSCX], a
2015-02-11 13:36:02 -08:00
call DelayFrame
ld a, $7
ldh [hWX], a
2015-02-11 13:36:02 -08:00
ld a, $90
ldh [hWY], a
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2015-11-29 18:34:59 -08:00
ld a, [wDexCurrentLocation]
2015-02-11 13:36:02 -08:00
ld e, a
predef Pokedex_GetArea
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2015-02-11 13:36:02 -08:00
call DelayFrame
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
ld a, $90
ldh [hWY], a
2018-01-21 13:53:19 -08:00
ld a, POKEDEX_SCX
ldh [hSCX], a
2015-02-11 13:36:02 -08:00
call DelayFrame
2016-01-09 19:03:38 -08:00
call Pokedex_RedisplayDexEntry
2016-01-09 17:51:14 -08:00
call Pokedex_LoadSelectedMonTiles
2015-02-11 13:36:02 -08:00
call WaitBGMap
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-01-09 17:51:14 -08:00
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.Cry:
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
ld a, [wTempSpecies]
2015-02-11 13:36:02 -08:00
call GetCryIndex
ld e, c
ld d, b
call PlayCry
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.Print:
2016-01-09 19:03:38 -08:00
call Pokedex_ApplyPrintPals
2015-02-11 13:36:02 -08:00
xor a
ldh [hSCX], a
2018-01-11 12:36:11 -08:00
ld a, [wPrevDexEntryBackup]
2015-02-11 13:36:02 -08:00
push af
2018-01-11 12:36:11 -08:00
ld a, [wPrevDexEntryJumptableIndex]
2015-02-11 13:36:02 -08:00
push af
2015-10-24 16:49:19 -07:00
ld a, [wJumptableIndex]
2015-02-11 13:36:02 -08:00
push af
2017-12-24 09:47:30 -08:00
farcall PrintDexEntry
2015-02-11 13:36:02 -08:00
pop af
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
pop af
2018-01-11 12:36:11 -08:00
ld [wPrevDexEntryJumptableIndex], a
2015-02-11 13:36:02 -08:00
pop af
2018-01-11 12:36:11 -08:00
ld [wPrevDexEntryBackup], a
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
2015-02-11 13:36:02 -08:00
call DisableLCD
2015-11-29 18:34:59 -08:00
call Pokedex_LoadInvertedFont
2016-01-09 19:03:38 -08:00
call Pokedex_RedisplayDexEntry
2015-02-11 13:36:02 -08:00
call EnableLCD
call WaitBGMap
2018-01-21 13:53:19 -08:00
ld a, POKEDEX_SCX
ldh [hSCX], a
2016-01-09 19:03:38 -08:00
call Pokedex_ApplyUsualPals
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_RedisplayDexEntry:
2016-01-09 17:51:14 -08:00
call Pokedex_DrawDexEntryScreenBG
call Pokedex_GetSelectedMon
2017-12-24 09:47:30 -08:00
farcall DisplayDexEntry
2015-11-29 18:34:59 -08:00
call Pokedex_DrawFootprint
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_InitOptionScreen:
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call ClearSprites
2016-01-09 17:51:14 -08:00
call Pokedex_DrawOptionScreenBG
call Pokedex_InitArrowCursor
2017-12-09 11:22:58 -08:00
ld a, [wCurrentDexMode] ; Index of the topmost visible item in a scrolling menu ???
2016-01-09 17:51:14 -08:00
ld [wDexArrowCursorPosIndex], a
2016-01-09 19:03:38 -08:00
call Pokedex_DisplayModeDescription
2015-02-11 13:36:02 -08:00
call WaitBGMap
2016-01-09 19:56:37 -08:00
ld a, SCGB_POKEDEX_SEARCH_OPTION
2016-01-09 17:51:14 -08:00
call Pokedex_GetSGBLayout
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_UpdateOptionScreen:
2015-11-29 18:34:59 -08:00
ld a, [wUnlockedUnownMode]
2015-02-11 13:36:02 -08:00
and a
2016-01-09 19:03:38 -08:00
jr nz, .okay
ld de, .NoUnownModeArrowCursorData
jr .okay2
.okay
ld de, .ArrowCursorData
.okay2
2016-01-09 17:51:14 -08:00
call Pokedex_MoveArrowCursor
2016-01-09 19:03:38 -08:00
call c, Pokedex_DisplayModeDescription
ld hl, hJoyPressed
2015-02-11 13:36:02 -08:00
ld a, [hl]
2016-01-09 19:03:38 -08:00
and SELECT | B_BUTTON
jr nz, .return_to_main_screen
2015-02-11 13:36:02 -08:00
ld a, [hl]
2016-01-09 19:03:38 -08:00
and A_BUTTON
jr nz, .do_menu_action
2015-02-11 13:36:02 -08:00
ret
2016-01-09 19:03:38 -08:00
.do_menu_action
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2016-01-09 19:03:38 -08:00
ld hl, .MenuActionJumptable
2015-11-29 18:34:59 -08:00
call Pokedex_LoadPointer
jp hl
2015-02-11 13:36:02 -08:00
2016-01-09 19:03:38 -08:00
.return_to_main_screen
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_MAIN_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.NoUnownModeArrowCursorData:
2015-11-29 18:34:59 -08:00
db D_UP | D_DOWN, 3
2018-01-16 14:59:05 -08:00
dwcoord 2, 4 ; NEW
dwcoord 2, 6 ; OLD
dwcoord 2, 8 ; ABC
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.ArrowCursorData:
2015-11-29 18:34:59 -08:00
db D_UP | D_DOWN, 4
2018-01-16 14:59:05 -08:00
dwcoord 2, 4 ; NEW
dwcoord 2, 6 ; OLD
dwcoord 2, 8 ; ABC
dwcoord 2, 10 ; UNOWN
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.MenuActionJumptable:
2016-01-09 19:03:38 -08:00
dw .MenuAction_NewMode
dw .MenuAction_OldMode
dw .MenuAction_ABCMode
dw .MenuAction_UnownMode
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.MenuAction_NewMode:
2016-01-06 13:59:56 -08:00
ld b, DEXMODE_NEW
2016-01-09 19:03:38 -08:00
jr .ChangeMode
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.MenuAction_OldMode:
2016-01-06 13:59:56 -08:00
ld b, DEXMODE_OLD
2016-01-09 19:03:38 -08:00
jr .ChangeMode
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.MenuAction_ABCMode:
2016-01-06 13:59:56 -08:00
ld b, DEXMODE_ABC
2016-01-09 19:03:38 -08:00
2018-06-24 07:09:41 -07:00
.ChangeMode:
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
2015-02-11 13:36:02 -08:00
cp b
2016-01-09 19:03:38 -08:00
jr z, .skip_changing_mode ; Skip if new mode is same as current.
2015-02-11 13:36:02 -08:00
ld a, b
2015-11-29 18:34:59 -08:00
ld [wCurrentDexMode], a
2016-01-09 19:03:38 -08:00
call Pokedex_OrderMonsByMode
call Pokedex_DisplayChangingModesMessage
2015-02-11 13:36:02 -08:00
xor a
2016-01-09 17:51:14 -08:00
ld [wDexListingScrollOffset], a
2015-11-29 18:34:59 -08:00
ld [wDexListingCursor], a
call Pokedex_InitCursorPosition
2015-02-11 13:36:02 -08:00
2016-01-09 19:03:38 -08:00
.skip_changing_mode
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_MAIN_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.MenuAction_UnownMode:
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_UNOWN_MODE
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_InitSearchScreen:
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call ClearSprites
2016-01-09 17:51:14 -08:00
call Pokedex_DrawSearchScreenBG
call Pokedex_InitArrowCursor
ld a, NORMAL + 1
ld [wDexSearchMonType1], a
2015-02-11 13:36:02 -08:00
xor a
2016-01-09 17:51:14 -08:00
ld [wDexSearchMonType2], a
call Pokedex_PlaceSearchScreenTypeStrings
2015-02-11 13:36:02 -08:00
xor a
ld [wDexSearchSlowpokeFrame], a
2017-12-24 09:47:30 -08:00
farcall DoDexSearchSlowpokeFrame
2015-02-11 13:36:02 -08:00
call WaitBGMap
2016-01-09 19:56:37 -08:00
ld a, SCGB_POKEDEX_SEARCH_OPTION
2016-01-09 17:51:14 -08:00
call Pokedex_GetSGBLayout
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_UpdateSearchScreen:
2016-01-09 17:51:14 -08:00
ld de, .ArrowCursorData
call Pokedex_MoveArrowCursor
call Pokedex_UpdateSearchMonType
call c, Pokedex_PlaceSearchScreenTypeStrings
ld hl, hJoyPressed
2015-02-11 13:36:02 -08:00
ld a, [hl]
and START | B_BUTTON
2016-01-09 19:03:38 -08:00
jr nz, .cancel
2015-02-11 13:36:02 -08:00
ld a, [hl]
and A_BUTTON
2016-01-09 19:03:38 -08:00
jr nz, .do_menu_action
2015-02-11 13:36:02 -08:00
ret
2016-01-09 19:03:38 -08:00
.do_menu_action
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
ld hl, .MenuActionJumptable
2015-11-29 18:34:59 -08:00
call Pokedex_LoadPointer
jp hl
2015-02-11 13:36:02 -08:00
2016-01-09 19:03:38 -08:00
.cancel
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_MAIN_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.ArrowCursorData:
2015-11-29 18:34:59 -08:00
db D_UP | D_DOWN, 4
2018-01-16 14:59:05 -08:00
dwcoord 2, 4 ; TYPE 1
dwcoord 2, 6 ; TYPE 2
dwcoord 2, 13 ; BEGIN SEARCH
dwcoord 2, 15 ; CANCEL
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.MenuActionJumptable:
2016-01-09 17:51:14 -08:00
dw .MenuAction_MonSearchType
dw .MenuAction_MonSearchType
dw .MenuAction_BeginSearch
dw .MenuAction_Cancel
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.MenuAction_MonSearchType:
2016-01-09 17:51:14 -08:00
call Pokedex_NextSearchMonType
call Pokedex_PlaceSearchScreenTypeStrings
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.MenuAction_BeginSearch:
2016-01-09 17:51:14 -08:00
call Pokedex_SearchForMons
2017-12-24 09:47:30 -08:00
farcall AnimateDexSearchSlowpoke
2016-01-09 17:51:14 -08:00
ld a, [wDexSearchResultCount]
2015-02-11 13:36:02 -08:00
and a
2016-01-09 17:51:14 -08:00
jr nz, .show_search_results
2016-01-09 19:03:38 -08:00
; No mon with matching types was found.
call Pokedex_OrderMonsByMode
call Pokedex_DisplayTypeNotFoundMessage
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 17:51:14 -08:00
call Pokedex_DrawSearchScreenBG
call Pokedex_InitArrowCursor
call Pokedex_PlaceSearchScreenTypeStrings
2015-02-11 13:36:02 -08:00
call WaitBGMap
ret
2016-01-09 17:51:14 -08:00
.show_search_results
2015-11-29 18:34:59 -08:00
ld [wDexListingEnd], a
2016-01-09 17:51:14 -08:00
ld a, [wDexListingScrollOffset]
ld [wDexListingScrollOffsetBackup], a
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
ld [wDexListingCursorBackup], a
2018-01-11 12:36:11 -08:00
ld a, [wPrevDexEntry]
ld [wPrevDexEntryBackup], a
2015-02-11 13:36:02 -08:00
xor a
2016-01-09 17:51:14 -08:00
ld [wDexListingScrollOffset], a
2015-11-29 18:34:59 -08:00
ld [wDexListingCursor], a
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_SEARCH_RESULTS_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.MenuAction_Cancel:
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_MAIN_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_InitSearchResultsScreen:
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
xor a
2018-01-23 14:39:09 -08:00
hlcoord 0, 0, wAttrMap
2015-11-29 18:34:59 -08:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
2015-02-11 13:36:02 -08:00
call ByteFill
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode4
call Pokedex_ResetBGMapMode
2017-12-24 09:47:30 -08:00
farcall DrawPokedexSearchResultsWindow
2016-01-09 17:51:14 -08:00
call Pokedex_PlaceSearchResultsTypeStrings
ld a, 4
ld [wDexListingHeight], a
call Pokedex_PrintListing
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode3
call Pokedex_ResetBGMapMode
2016-01-09 17:51:14 -08:00
call Pokedex_DrawSearchResultsScreenBG
2018-01-21 13:53:19 -08:00
ld a, POKEDEX_SCX
ldh [hSCX], a
2015-02-11 13:36:02 -08:00
ld a, $4a
ldh [hWX], a
2015-02-11 13:36:02 -08:00
xor a
ldh [hWY], a
2015-02-11 13:36:02 -08:00
call WaitBGMap
2015-11-29 18:34:59 -08:00
call Pokedex_ResetBGMapMode
2017-12-24 09:47:30 -08:00
farcall DrawPokedexSearchResultsWindow
2016-01-09 17:51:14 -08:00
call Pokedex_PlaceSearchResultsTypeStrings
call Pokedex_UpdateSearchResultsCursorOAM
2018-01-11 09:00:01 -08:00
ld a, -1
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-01-09 17:51:14 -08:00
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_UpdateSearchResultsScreen:
2016-01-09 19:03:38 -08:00
ld hl, hJoyPressed
2015-02-11 13:36:02 -08:00
ld a, [hl]
and B_BUTTON
2016-01-09 19:03:38 -08:00
jr nz, .return_to_search_screen
2015-02-11 13:36:02 -08:00
ld a, [hl]
and A_BUTTON
2016-01-09 19:03:38 -08:00
jr nz, .go_to_dex_entry
2016-01-09 17:51:14 -08:00
call Pokedex_ListingHandleDPadInput
2015-02-11 13:36:02 -08:00
ret nc
2016-01-09 17:51:14 -08:00
call Pokedex_UpdateSearchResultsCursorOAM
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 17:51:14 -08:00
call Pokedex_PrintListing
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode3
call Pokedex_ResetBGMapMode
2015-02-11 13:36:02 -08:00
ret
2016-01-09 19:03:38 -08:00
.go_to_dex_entry
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
2015-02-11 13:36:02 -08:00
ret z
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_DEX_ENTRY_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_SEARCH_RESULTS_SCR
2018-01-11 12:36:11 -08:00
ld [wPrevDexEntryJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
2016-01-09 19:03:38 -08:00
.return_to_search_screen
ld a, [wDexListingScrollOffsetBackup]
2016-01-09 17:51:14 -08:00
ld [wDexListingScrollOffset], a
ld a, [wDexListingCursorBackup]
2015-11-29 18:34:59 -08:00
ld [wDexListingCursor], a
2018-01-11 12:36:11 -08:00
ld a, [wPrevDexEntryBackup]
ld [wPrevDexEntry], a
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2015-02-11 13:36:02 -08:00
call ClearSprites
2016-01-09 19:03:38 -08:00
call Pokedex_OrderMonsByMode
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_SEARCH_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
xor a
ldh [hSCX], a
2015-02-11 13:36:02 -08:00
ld a, $a7
ldh [hWX], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_InitUnownMode:
2015-11-29 18:34:59 -08:00
call Pokedex_LoadUnownFont
2016-01-09 19:46:41 -08:00
call Pokedex_DrawUnownModeBG
2015-02-11 13:36:02 -08:00
xor a
2016-01-09 19:46:41 -08:00
ld [wDexCurrentUnownIndex], a
call Pokedex_LoadUnownFrontpicTiles
call Pokedex_UnownModePlaceCursor
2017-12-24 09:47:30 -08:00
farcall PrintUnownWord
2015-02-11 13:36:02 -08:00
call WaitBGMap
2016-01-09 19:56:37 -08:00
ld a, SCGB_POKEDEX_UNOWN_MODE
2016-01-09 17:51:14 -08:00
call Pokedex_GetSGBLayout
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_UpdateUnownMode:
2016-01-09 17:51:14 -08:00
ld hl, hJoyPressed
2015-02-11 13:36:02 -08:00
ld a, [hl]
and A_BUTTON | B_BUTTON
2015-11-29 18:34:59 -08:00
jr nz, .a_b
2016-01-09 19:03:38 -08:00
call Pokedex_UnownModeHandleDPadInput
2015-02-11 13:36:02 -08:00
ret
2015-11-29 18:34:59 -08:00
.a_b
2016-01-09 17:51:14 -08:00
call Pokedex_BlackOutBG
2016-01-09 23:05:34 -08:00
ld a, DEXSTATE_OPTION_SCR
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
call DelayFrame
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSGB
jr nz, .decompress
2017-12-24 09:47:30 -08:00
farcall LoadSGBPokedexGFX2
2015-11-29 18:34:59 -08:00
jr .done
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
.decompress
2015-02-11 13:36:02 -08:00
ld hl, PokedexLZ
2017-12-28 04:32:33 -08:00
ld de, vTiles2 tile $31
2018-01-14 16:43:35 -08:00
lb bc, BANK(PokedexLZ), 58
2015-11-04 13:14:27 -08:00
call DecompressRequest2bpp
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
.done
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_UnownModeHandleDPadInput:
2015-10-16 10:35:43 -07:00
ld hl, hJoyLast
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_RIGHT
jr nz, .right
ld a, [hl]
and D_LEFT
jr nz, .left
ret
.right
2016-01-09 19:46:41 -08:00
ld a, [wDexUnownCount]
2015-02-11 13:36:02 -08:00
ld e, a
2016-01-09 19:46:41 -08:00
ld hl, wDexCurrentUnownIndex
2015-02-11 13:36:02 -08:00
ld a, [hl]
inc a
cp e
ret nc
ld a, [hl]
inc [hl]
2015-11-29 18:34:59 -08:00
jr .update
2015-02-11 13:36:02 -08:00
.left
2016-01-09 19:46:41 -08:00
ld hl, wDexCurrentUnownIndex
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
ret z
ld a, [hl]
dec [hl]
2015-11-29 18:34:59 -08:00
.update
2015-02-11 13:36:02 -08:00
push af
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
pop af
2016-01-09 19:46:41 -08:00
call Pokedex_UnownModeEraseCursor
call Pokedex_LoadUnownFrontpicTiles
call Pokedex_UnownModePlaceCursor
2017-12-24 09:47:30 -08:00
farcall PrintUnownWord
2015-02-11 13:36:02 -08:00
ld a, $1
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call DelayFrame
call DelayFrame
ret
2018-06-24 07:09:41 -07:00
Pokedex_UnownModeEraseCursor:
2016-01-09 19:46:41 -08:00
ld c, " "
jr Pokedex_UnownModeUpdateCursorGfx
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_UnownModePlaceCursor:
2016-01-09 19:46:41 -08:00
ld a, [wDexCurrentUnownIndex]
ld c, $5a ; diamond cursor
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_UnownModeUpdateCursorGfx:
2015-02-11 13:36:02 -08:00
ld e, a
ld d, 0
2016-01-09 19:46:41 -08:00
ld hl, UnownModeLetterAndCursorCoords + 2
2015-07-20 19:18:18 -07:00
rept 4
2015-02-11 13:36:02 -08:00
add hl, de
2015-07-20 19:18:18 -07:00
endr
2015-02-11 13:36:02 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
ld [hl], c
ret
2018-06-24 07:09:41 -07:00
Pokedex_NextOrPreviousDexEntry:
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
ld [wBackupDexListingCursor], a
2016-01-09 17:51:14 -08:00
ld a, [wDexListingScrollOffset]
2015-11-29 18:34:59 -08:00
ld [wBackupDexListingPage], a
2015-10-16 10:35:43 -07:00
ld hl, hJoyLast
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_UP
jr nz, .up
ld a, [hl]
and D_DOWN
jr nz, .down
and a
ret
.up
2016-01-09 17:51:14 -08:00
ld a, [wDexListingHeight]
2015-02-11 13:36:02 -08:00
ld d, a
2015-11-29 18:34:59 -08:00
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
ld e, a
2016-01-09 17:51:14 -08:00
call Pokedex_ListingMoveCursorUp
2015-11-29 18:34:59 -08:00
jr nc, .nope
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
jr nz, .yep
2015-02-11 13:36:02 -08:00
jr .up
.down
2016-01-09 17:51:14 -08:00
ld a, [wDexListingHeight]
2015-02-11 13:36:02 -08:00
ld d, a
2015-11-29 18:34:59 -08:00
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
ld e, a
2016-01-09 17:51:14 -08:00
call Pokedex_ListingMoveCursorDown
2015-11-29 18:34:59 -08:00
jr nc, .nope
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
jr nz, .yep
2015-02-11 13:36:02 -08:00
jr .down
2015-11-29 18:34:59 -08:00
.yep
2015-02-11 13:36:02 -08:00
scf
ret
2015-11-29 18:34:59 -08:00
.nope
ld a, [wBackupDexListingCursor]
ld [wDexListingCursor], a
ld a, [wBackupDexListingPage]
2016-01-09 17:51:14 -08:00
ld [wDexListingScrollOffset], a
2015-02-11 13:36:02 -08:00
and a
ret
2018-06-24 07:09:41 -07:00
Pokedex_ListingHandleDPadInput:
2016-01-09 17:51:14 -08:00
; Handles D-pad input for a list of Pokémon.
ld a, [wDexListingHeight]
2015-02-11 13:36:02 -08:00
ld d, a
2015-11-29 18:34:59 -08:00
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
ld e, a
2015-10-16 10:35:43 -07:00
ld hl, hJoyLast
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_UP
2016-01-09 17:51:14 -08:00
jr nz, Pokedex_ListingMoveCursorUp
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_DOWN
2016-01-09 17:51:14 -08:00
jr nz, Pokedex_ListingMoveCursorDown
2015-02-11 13:36:02 -08:00
ld a, d
cp e
2016-01-09 17:51:14 -08:00
jr nc, Pokedex_ListingPosStayedSame
2015-02-11 13:36:02 -08:00
ld a, [hl]
2016-01-09 17:51:14 -08:00
and D_LEFT
jr nz, Pokedex_ListingMoveUpOnePage
2015-02-11 13:36:02 -08:00
ld a, [hl]
2016-01-09 17:51:14 -08:00
and D_RIGHT
jr nz, Pokedex_ListingMoveDownOnePage
jr Pokedex_ListingPosStayedSame
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_ListingMoveCursorUp:
2015-11-29 18:34:59 -08:00
ld hl, wDexListingCursor
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
2016-01-09 17:51:14 -08:00
jr z, .try_scrolling
2015-02-11 13:36:02 -08:00
dec [hl]
2016-01-09 17:51:14 -08:00
jr Pokedex_ListingPosChanged
.try_scrolling
ld hl, wDexListingScrollOffset
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
2016-01-09 17:51:14 -08:00
jr z, Pokedex_ListingPosStayedSame
2015-02-11 13:36:02 -08:00
dec [hl]
2016-01-09 17:51:14 -08:00
jr Pokedex_ListingPosChanged
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_ListingMoveCursorDown:
2015-11-29 18:34:59 -08:00
ld hl, wDexListingCursor
2015-02-11 13:36:02 -08:00
ld a, [hl]
inc a
cp e
2016-01-09 17:51:14 -08:00
jr nc, Pokedex_ListingPosStayedSame
2015-02-11 13:36:02 -08:00
cp d
2016-01-09 17:51:14 -08:00
jr nc, .try_scrolling
2015-02-11 13:36:02 -08:00
inc [hl]
2016-01-09 17:51:14 -08:00
jr Pokedex_ListingPosChanged
.try_scrolling
ld hl, wDexListingScrollOffset
2015-02-11 13:36:02 -08:00
add [hl]
cp e
2016-01-09 17:51:14 -08:00
jr nc, Pokedex_ListingPosStayedSame
2015-02-11 13:36:02 -08:00
inc [hl]
2016-01-09 17:51:14 -08:00
jr Pokedex_ListingPosChanged
2018-06-24 07:09:41 -07:00
Pokedex_ListingMoveUpOnePage:
2016-01-09 17:51:14 -08:00
ld hl, wDexListingScrollOffset
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
2016-01-09 17:51:14 -08:00
jr z, Pokedex_ListingPosStayedSame
2015-02-11 13:36:02 -08:00
cp d
2016-01-09 17:51:14 -08:00
jr nc, .not_near_top
; If we're already less than page away from the top, go to the top.
2015-02-11 13:36:02 -08:00
xor a
ld [hl], a
2016-01-09 17:51:14 -08:00
jr Pokedex_ListingPosChanged
.not_near_top
2015-02-11 13:36:02 -08:00
sub d
ld [hl], a
2016-01-09 17:51:14 -08:00
jr Pokedex_ListingPosChanged
2018-06-24 07:09:41 -07:00
Pokedex_ListingMoveDownOnePage:
2016-01-09 17:51:14 -08:00
; When moving down a page, the return value always report a change in position.
ld hl, wDexListingScrollOffset
2015-02-11 13:36:02 -08:00
ld a, d
add a
add [hl]
2016-01-09 17:51:14 -08:00
jr c, .near_bottom
2015-02-11 13:36:02 -08:00
cp e
2016-01-09 17:51:14 -08:00
jr c, .not_near_bottom
.near_bottom
2015-02-11 13:36:02 -08:00
ld a, e
sub d
ld [hl], a
2016-01-09 17:51:14 -08:00
jr Pokedex_ListingPosChanged
.not_near_bottom
2015-02-11 13:36:02 -08:00
ld a, [hl]
add d
ld [hl], a
2016-01-09 17:51:14 -08:00
jr Pokedex_ListingPosChanged
2018-06-24 07:09:41 -07:00
Pokedex_ListingPosStayedSame:
2015-02-11 13:36:02 -08:00
and a
ret
2016-01-09 17:51:14 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_ListingPosChanged:
2015-02-11 13:36:02 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
Pokedex_FillColumn:
2016-01-19 16:51:05 -08:00
; Fills a column starting at HL, going downwards.
; B is the height of the column and A is the tile it's filled with.
2015-02-11 13:36:02 -08:00
push de
2016-01-12 09:46:18 -08:00
ld de, SCREEN_WIDTH
.loop
2015-02-11 13:36:02 -08:00
ld [hl], a
add hl, de
dec b
2016-01-12 09:46:18 -08:00
jr nz, .loop
2015-02-11 13:36:02 -08:00
pop de
ret
2018-06-24 07:09:41 -07:00
Pokedex_DrawMainScreenBG:
2016-01-09 17:51:14 -08:00
; Draws the left sidebar and the bottom bar on the main screen.
2015-02-11 13:36:02 -08:00
hlcoord 0, 17
ld de, String_START_SEARCH
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
ld a, $32
hlcoord 0, 0
2015-11-29 18:34:59 -08:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
2015-02-11 13:36:02 -08:00
call ByteFill
hlcoord 0, 0
2015-02-11 13:36:02 -08:00
lb bc, 7, 7
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 0, 9
2016-01-12 09:46:18 -08:00
lb bc, 6, 7
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 1, 11
ld de, String_SEEN
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2018-01-23 14:39:09 -08:00
ld hl, wPokedexSeen
ld b, wEndPokedexSeen - wPokedexSeen
2015-02-11 13:36:02 -08:00
call CountSetBits
ld de, wNumSetBits
2015-02-11 13:36:02 -08:00
hlcoord 5, 12
lb bc, 1, 3
2015-02-11 13:36:02 -08:00
call PrintNum
hlcoord 1, 14
ld de, String_OWN
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2018-01-23 14:39:09 -08:00
ld hl, wPokedexCaught
ld b, wEndPokedexCaught - wPokedexCaught
2015-02-11 13:36:02 -08:00
call CountSetBits
ld de, wNumSetBits
2015-02-11 13:36:02 -08:00
hlcoord 5, 15
lb bc, 1, 3
2015-02-11 13:36:02 -08:00
call PrintNum
hlcoord 1, 17
ld de, String_SELECT_OPTION
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 8, 1
2016-01-12 09:46:18 -08:00
ld b, 7
2015-02-11 13:36:02 -08:00
ld a, $5a
2016-01-19 16:51:05 -08:00
call Pokedex_FillColumn
2015-02-11 13:36:02 -08:00
hlcoord 8, 10
2016-01-12 09:46:18 -08:00
ld b, 6
2015-02-11 13:36:02 -08:00
ld a, $5a
2016-01-19 16:51:05 -08:00
call Pokedex_FillColumn
2015-02-11 13:36:02 -08:00
hlcoord 8, 0
ld [hl], $59
hlcoord 8, 8
ld [hl], $53
hlcoord 8, 9
ld [hl], $54
hlcoord 8, 16
ld [hl], $5b
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceFrontpicTopLeftCorner
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
String_SEEN:
2018-01-11 09:00:01 -08:00
db "SEEN", -1
2018-06-24 07:09:41 -07:00
String_OWN:
2018-01-11 09:00:01 -08:00
db "OWN", -1
2018-06-24 07:09:41 -07:00
String_SELECT_OPTION:
2015-02-11 13:36:02 -08:00
db $3b, $48, $49, $4a, $44, $45, $46, $47 ; SELECT > OPTION
2018-01-11 09:00:01 -08:00
; fallthrough
2018-06-24 07:09:41 -07:00
String_START_SEARCH:
2018-01-11 09:00:01 -08:00
db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, -1 ; START > SEARCH
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_DrawDexEntryScreenBG:
2015-11-29 18:34:59 -08:00
call Pokedex_FillBackgroundColor2
hlcoord 0, 0
2016-01-12 09:46:18 -08:00
lb bc, 15, 18
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 19, 0
ld [hl], $34
hlcoord 19, 1
2016-01-12 09:46:18 -08:00
ld a, " "
ld b, 15
2016-01-19 16:51:05 -08:00
call Pokedex_FillColumn
2015-02-11 13:36:02 -08:00
ld [hl], $39
hlcoord 1, 10
2016-01-12 09:46:18 -08:00
ld bc, 19
2015-02-11 13:36:02 -08:00
ld a, $61
call ByteFill
hlcoord 1, 17
2016-01-12 09:46:18 -08:00
ld bc, 18
ld a, " "
2015-02-11 13:36:02 -08:00
call ByteFill
hlcoord 9, 7
2016-01-09 17:51:14 -08:00
ld de, .Height
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 9, 9
2016-01-09 17:51:14 -08:00
ld de, .Weight
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 0, 17
2016-01-09 17:51:14 -08:00
ld de, .MenuItems
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
call Pokedex_PlaceFrontpicTopLeftCorner
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.Unused:
2018-01-11 09:00:01 -08:00
db $5c, $5d, -1 ; No.
2018-06-24 07:09:41 -07:00
.Height:
2018-01-11 09:00:01 -08:00
db "HT ?", $5e, "??", $5f, -1 ; HT ?'??"
2018-06-24 07:09:41 -07:00
.Weight:
2018-01-11 09:00:01 -08:00
db "WT ???lb", -1 ; WT ???lb
2018-06-24 07:09:41 -07:00
.MenuItems:
2018-01-11 09:00:01 -08:00
db $3b, " PAGE AREA CRY PRNT", -1
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_DrawOptionScreenBG:
2015-11-29 18:34:59 -08:00
call Pokedex_FillBackgroundColor2
2015-02-11 13:36:02 -08:00
hlcoord 0, 2
lb bc, 8, 18
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 0, 12
lb bc, 4, 18
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 0, 1
2016-01-09 17:51:14 -08:00
ld de, .Title
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 3, 4
2016-01-09 17:51:14 -08:00
ld de, .Modes
2015-02-11 13:36:02 -08:00
call PlaceString
2015-11-29 18:34:59 -08:00
ld a, [wUnlockedUnownMode]
2015-02-11 13:36:02 -08:00
and a
ret z
hlcoord 3, 10
2016-01-09 17:51:14 -08:00
ld de, .UnownMode
2015-02-11 13:36:02 -08:00
call PlaceString
ret
2018-06-24 07:09:41 -07:00
.Title:
2018-01-11 09:00:01 -08:00
db $3b, " OPTION ", $3c, -1
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.Modes:
db "NEW #DEX MODE"
next "OLD #DEX MODE"
next "A to Z MODE"
db "@"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.UnownMode:
2015-02-11 13:36:02 -08:00
db "UNOWN MODE@"
2018-06-24 07:09:41 -07:00
Pokedex_DrawSearchScreenBG:
2015-11-29 18:34:59 -08:00
call Pokedex_FillBackgroundColor2
2015-02-11 13:36:02 -08:00
hlcoord 0, 2
lb bc, 14, 18
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 0, 1
2016-01-09 17:51:14 -08:00
ld de, .Title
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 8, 4
2016-01-09 17:51:14 -08:00
ld de, .TypeLeftRightArrows
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 8, 6
2016-01-09 17:51:14 -08:00
ld de, .TypeLeftRightArrows
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 3, 4
2016-01-09 17:51:14 -08:00
ld de, .Types
2015-02-11 13:36:02 -08:00
call PlaceString
hlcoord 3, 13
2016-01-09 17:51:14 -08:00
ld de, .Menu
2015-02-11 13:36:02 -08:00
call PlaceString
ret
2018-06-24 07:09:41 -07:00
.Title:
2018-01-11 09:00:01 -08:00
db $3b, " SEARCH ", $3c, -1
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.TypeLeftRightArrows:
2018-01-11 09:00:01 -08:00
db $3d, " ", $3e, -1
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.Types:
2015-02-11 13:36:02 -08:00
db "TYPE1"
next "TYPE2"
db "@"
2018-06-24 07:09:41 -07:00
.Menu:
2015-02-11 13:36:02 -08:00
db "BEGIN SEARCH!!"
next "CANCEL"
db "@"
2018-06-24 07:09:41 -07:00
Pokedex_DrawSearchResultsScreenBG:
2015-11-29 18:34:59 -08:00
call Pokedex_FillBackgroundColor2
hlcoord 0, 0
2015-02-11 13:36:02 -08:00
lb bc, 7, 7
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 0, 11
lb bc, 5, 18
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 1, 12
2016-01-09 17:51:14 -08:00
ld de, .BottomWindowText
2015-02-11 13:36:02 -08:00
call PlaceString
2016-01-09 17:51:14 -08:00
ld de, wDexSearchResultCount
2015-02-11 13:36:02 -08:00
hlcoord 1, 16
lb bc, 1, 3
2015-02-11 13:36:02 -08:00
call PrintNum
hlcoord 8, 0
ld [hl], $59
hlcoord 8, 1
2016-01-12 09:46:18 -08:00
ld b, 7
2015-02-11 13:36:02 -08:00
ld a, $5a
2016-01-19 16:51:05 -08:00
call Pokedex_FillColumn
2015-02-11 13:36:02 -08:00
hlcoord 8, 8
ld [hl], $53
hlcoord 8, 9
ld [hl], $69
hlcoord 8, 10
ld [hl], $6a
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceFrontpicTopLeftCorner
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.BottomWindowText:
2015-02-11 13:36:02 -08:00
db "SEARCH RESULTS"
next " TYPE"
next " FOUND!"
db "@"
2018-06-24 07:09:41 -07:00
Pokedex_PlaceSearchResultsTypeStrings:
2016-01-09 17:51:14 -08:00
ld a, [wDexSearchMonType1]
2015-02-11 13:36:02 -08:00
hlcoord 0, 14
2016-01-09 17:51:14 -08:00
call Pokedex_PlaceTypeString
ld a, [wDexSearchMonType1]
2015-02-11 13:36:02 -08:00
ld b, a
2016-01-09 17:51:14 -08:00
ld a, [wDexSearchMonType2]
2015-02-11 13:36:02 -08:00
and a
2016-01-09 17:51:14 -08:00
jr z, .done
2015-02-11 13:36:02 -08:00
cp b
2016-01-09 17:51:14 -08:00
jr z, .done
2015-02-11 13:36:02 -08:00
hlcoord 2, 15
2016-01-09 17:51:14 -08:00
call Pokedex_PlaceTypeString
2015-02-11 13:36:02 -08:00
hlcoord 1, 15
2016-01-09 17:51:14 -08:00
ld [hl], "/"
.done
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_DrawUnownModeBG:
2015-11-29 18:34:59 -08:00
call Pokedex_FillBackgroundColor2
2015-02-11 13:36:02 -08:00
hlcoord 2, 1
lb bc, 10, 13
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 2, 14
lb bc, 1, 13
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
hlcoord 2, 15
ld [hl], $3d
hlcoord 16, 15
ld [hl], $3e
hlcoord 6, 5
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceFrontpicAtHL
2015-02-11 13:36:02 -08:00
ld de, 0
ld b, 0
2018-07-18 10:06:56 -07:00
ld c, NUM_UNOWN
2015-11-29 18:34:59 -08:00
.loop
2018-01-23 14:39:09 -08:00
ld hl, wUnownDex
2015-02-11 13:36:02 -08:00
add hl, de
ld a, [hl]
and a
2015-11-29 18:34:59 -08:00
jr z, .done
2015-02-11 13:36:02 -08:00
push af
2016-01-09 19:46:41 -08:00
ld hl, UnownModeLetterAndCursorCoords
2015-07-20 19:18:18 -07:00
rept 4
2015-02-11 13:36:02 -08:00
add hl, de
2015-07-20 19:18:18 -07:00
endr
2015-02-11 13:36:02 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
pop af
2015-11-29 18:34:59 -08:00
add $40 - 1 ; Unown A
2015-02-11 13:36:02 -08:00
ld [hl], a
inc de
inc b
dec c
2015-11-29 18:34:59 -08:00
jr nz, .loop
.done
2015-02-11 13:36:02 -08:00
ld a, b
2016-01-09 19:46:41 -08:00
ld [wDexUnownCount], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
UnownModeLetterAndCursorCoords:
2018-01-16 14:59:05 -08:00
; entries correspond to Unown forms
2015-11-29 18:34:59 -08:00
; letter, cursor
2018-01-16 14:59:05 -08:00
dwcoord 4,11, 3,11 ; A
dwcoord 4,10, 3,10 ; B
dwcoord 4, 9, 3, 9 ; C
dwcoord 4, 8, 3, 8 ; D
dwcoord 4, 7, 3, 7 ; E
dwcoord 4, 6, 3, 6 ; F
dwcoord 4, 5, 3, 5 ; G
dwcoord 4, 4, 3, 4 ; H
dwcoord 4, 3, 3, 2 ; I
dwcoord 5, 3, 5, 2 ; J
dwcoord 6, 3, 6, 2 ; K
dwcoord 7, 3, 7, 2 ; L
dwcoord 8, 3, 8, 2 ; M
dwcoord 9, 3, 9, 2 ; N
dwcoord 10, 3, 10, 2 ; O
dwcoord 11, 3, 11, 2 ; P
dwcoord 12, 3, 12, 2 ; Q
dwcoord 13, 3, 13, 2 ; R
dwcoord 14, 3, 15, 2 ; S
dwcoord 14, 4, 15, 4 ; T
dwcoord 14, 5, 15, 5 ; U
dwcoord 14, 6, 15, 6 ; V
dwcoord 14, 7, 15, 7 ; W
dwcoord 14, 8, 15, 8 ; X
dwcoord 14, 9, 15, 9 ; Y
dwcoord 14,10, 15,10 ; Z
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_FillBackgroundColor2:
hlcoord 0, 0
2015-02-11 13:36:02 -08:00
ld a, $32
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
2015-02-11 13:36:02 -08:00
call ByteFill
ret
2018-06-24 07:09:41 -07:00
Pokedex_PlaceFrontpicTopLeftCorner:
2015-02-11 13:36:02 -08:00
hlcoord 1, 1
2018-06-24 07:09:41 -07:00
Pokedex_PlaceFrontpicAtHL:
2015-02-11 13:36:02 -08:00
xor a
ld b, $7
2015-11-29 18:34:59 -08:00
.row
2015-02-11 13:36:02 -08:00
ld c, $7
push af
push hl
2015-11-29 18:34:59 -08:00
.col
2015-02-11 13:36:02 -08:00
ld [hli], a
add $7
dec c
2015-11-29 18:34:59 -08:00
jr nz, .col
2015-02-11 13:36:02 -08:00
pop hl
2015-11-29 18:34:59 -08:00
ld de, SCREEN_WIDTH
2015-02-11 13:36:02 -08:00
add hl, de
pop af
inc a
dec b
2015-11-29 18:34:59 -08:00
jr nz, .row
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_PlaceString:
2015-11-29 18:34:59 -08:00
.loop
2015-02-11 13:36:02 -08:00
ld a, [de]
2015-11-29 18:34:59 -08:00
cp -1
2015-02-11 13:36:02 -08:00
ret z
inc de
ld [hli], a
2015-11-29 18:34:59 -08:00
jr .loop
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_PlaceBorder:
2015-02-11 13:36:02 -08:00
push hl
ld a, $33
ld [hli], a
ld d, $34
2015-11-29 18:34:59 -08:00
call .FillRow
2015-02-11 13:36:02 -08:00
ld a, $35
ld [hl], a
pop hl
2015-11-29 18:34:59 -08:00
ld de, SCREEN_WIDTH
2015-02-11 13:36:02 -08:00
add hl, de
2015-11-29 18:34:59 -08:00
.loop
2015-02-11 13:36:02 -08:00
push hl
ld a, $36
ld [hli], a
ld d, $7f
2015-11-29 18:34:59 -08:00
call .FillRow
2015-02-11 13:36:02 -08:00
ld a, $37
ld [hl], a
pop hl
2015-11-29 18:34:59 -08:00
ld de, SCREEN_WIDTH
2015-02-11 13:36:02 -08:00
add hl, de
dec b
2015-11-29 18:34:59 -08:00
jr nz, .loop
2015-02-11 13:36:02 -08:00
ld a, $38
ld [hli], a
ld d, $39
2015-11-29 18:34:59 -08:00
call .FillRow
2015-02-11 13:36:02 -08:00
ld a, $3a
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
.FillRow:
2015-02-11 13:36:02 -08:00
ld e, c
2015-11-29 18:34:59 -08:00
.row_loop
2015-02-11 13:36:02 -08:00
ld a, e
and a
ret z
ld a, d
ld [hli], a
dec e
2015-11-29 18:34:59 -08:00
jr .row_loop
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_PrintListing:
2016-01-09 17:51:14 -08:00
; Prints the list of Pokémon on the main Pokédex screen.
2015-11-29 18:34:59 -08:00
; This check is completely useless.
ld a, [wCurrentDexMode]
cp DEXMODE_OLD
jr z, .okay
ld c, 11
jr .resume
.okay
ld c, 11
; End useless check
2016-01-09 17:51:14 -08:00
2015-11-29 18:34:59 -08:00
.resume
2016-01-09 17:51:14 -08:00
; Clear (2 * [wDexListingHeight] + 1) by 11 box starting at 0,1
2015-02-11 13:36:02 -08:00
hlcoord 0, 1
2016-01-09 17:51:14 -08:00
ld a, [wDexListingHeight]
2015-02-11 13:36:02 -08:00
add a
inc a
ld b, a
2015-11-29 18:34:59 -08:00
ld a, " "
call Pokedex_FillBox
2017-12-09 12:28:03 -08:00
; Load de with wPokedexOrder + [wDexListingScrollOffset]
2016-01-09 17:51:14 -08:00
ld a, [wDexListingScrollOffset]
2015-02-11 13:36:02 -08:00
ld e, a
ld d, $0
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder
2015-02-11 13:36:02 -08:00
add hl, de
ld e, l
ld d, h
hlcoord 0, 2
2016-01-09 17:51:14 -08:00
ld a, [wDexListingHeight]
2015-11-29 18:34:59 -08:00
.loop
2015-02-11 13:36:02 -08:00
push af
ld a, [de]
ld [wTempSpecies], a ; also sets wNamedObjectIndexBuffer
2015-02-11 13:36:02 -08:00
push de
push hl
2016-01-09 17:51:14 -08:00
call .PrintEntry
2015-02-11 13:36:02 -08:00
pop hl
2015-11-29 18:34:59 -08:00
ld de, 2 * SCREEN_WIDTH
2015-02-11 13:36:02 -08:00
add hl, de
pop de
inc de
pop af
dec a
2015-11-29 18:34:59 -08:00
jr nz, .loop
2016-01-09 17:51:14 -08:00
call Pokedex_LoadSelectedMonTiles
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.PrintEntry:
2016-01-09 17:51:14 -08:00
; Prints one entry in the list of Pokémon on the main Pokédex screen.
2015-02-11 13:36:02 -08:00
and a
ret z
2015-11-29 18:34:59 -08:00
call Pokedex_PrintNumberIfOldMode
call Pokedex_PlaceDefaultStringIfNotSeen
2015-02-11 13:36:02 -08:00
ret c
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceCaughtSymbolIfCaught
2015-02-11 13:36:02 -08:00
push hl
call GetPokemonName
pop hl
call PlaceString
ret
2018-06-24 07:09:41 -07:00
Pokedex_PrintNumberIfOldMode:
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
cp DEXMODE_OLD
jr z, .printnum
2015-02-11 13:36:02 -08:00
ret
2015-11-29 18:34:59 -08:00
.printnum
2015-02-11 13:36:02 -08:00
push hl
2015-11-29 18:34:59 -08:00
ld de, -SCREEN_WIDTH
2015-02-11 13:36:02 -08:00
add hl, de
ld de, wTempSpecies
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
2015-02-11 13:36:02 -08:00
call PrintNum
pop hl
ret
2018-06-24 07:09:41 -07:00
Pokedex_PlaceCaughtSymbolIfCaught:
2015-11-29 18:34:59 -08:00
call Pokedex_CheckCaught
jr nz, .place_caught_symbol
2015-02-11 13:36:02 -08:00
inc hl
ret
2015-11-29 18:34:59 -08:00
.place_caught_symbol
2015-02-11 13:36:02 -08:00
ld a, $4f
ld [hli], a
ret
2018-06-24 07:09:41 -07:00
Pokedex_PlaceDefaultStringIfNotSeen:
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
2015-02-11 13:36:02 -08:00
ret nz
inc hl
2015-11-29 18:34:59 -08:00
ld de, .NameNotSeen
2015-02-11 13:36:02 -08:00
call PlaceString
scf
ret
2018-06-24 07:09:41 -07:00
.NameNotSeen:
2015-02-11 13:36:02 -08:00
db "-----@"
2018-06-24 07:09:41 -07:00
Pokedex_DrawFootprint:
2015-02-11 13:36:02 -08:00
hlcoord 18, 1
ld a, $62
ld [hli], a
inc a
ld [hl], a
hlcoord 18, 2
ld a, $64
ld [hli], a
inc a
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
Pokedex_GetSelectedMon:
2016-01-09 17:51:14 -08:00
; 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.
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
2016-01-09 17:51:14 -08:00
ld hl, wDexListingScrollOffset
2015-02-11 13:36:02 -08:00
add [hl]
ld e, a
ld d, $0
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder
2015-02-11 13:36:02 -08:00
add hl, de
ld a, [hl]
ld [wTempSpecies], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_CheckCaught:
2015-02-11 13:36:02 -08:00
push de
push hl
ld a, [wTempSpecies]
2015-02-11 13:36:02 -08:00
dec a
call CheckCaughtMon
pop hl
pop de
ret
2018-06-24 07:09:41 -07:00
Pokedex_CheckSeen:
2015-02-11 13:36:02 -08:00
push de
push hl
ld a, [wTempSpecies]
2015-02-11 13:36:02 -08:00
dec a
call CheckSeenMon
pop hl
pop de
ret
2018-06-24 07:09:41 -07:00
Pokedex_OrderMonsByMode:
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder
ld bc, wPokedexOrderEnd - wPokedexOrder
2015-02-11 13:36:02 -08:00
xor a
call ByteFill
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
ld hl, .Jumptable
call Pokedex_LoadPointer
jp hl
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.Jumptable:
2015-11-29 18:34:59 -08:00
dw .NewMode
dw .OldMode
dw Pokedex_ABCMode
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.NewMode:
2015-02-11 13:36:02 -08:00
ld de, NewPokedexOrder
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder
2015-02-11 13:36:02 -08:00
ld c, NUM_POKEMON
2015-11-29 18:34:59 -08:00
.loopnew
2015-02-11 13:36:02 -08:00
ld a, [de]
inc de
ld [hli], a
dec c
2015-11-29 18:34:59 -08:00
jr nz, .loopnew
call .FindLastSeen
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.OldMode:
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder
2015-02-11 13:36:02 -08:00
ld a, $1
ld c, NUM_POKEMON
2015-11-29 18:34:59 -08:00
.loopold
2015-02-11 13:36:02 -08:00
ld [hli], a
inc a
dec c
2015-11-29 18:34:59 -08:00
jr nz, .loopold
call .FindLastSeen
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.FindLastSeen:
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder + NUM_POKEMON - 1
2015-02-11 13:36:02 -08:00
ld d, NUM_POKEMON
ld e, d
2015-11-29 18:34:59 -08:00
.loopfindend
2015-02-11 13:36:02 -08:00
ld a, [hld]
ld [wTempSpecies], a
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
jr nz, .foundend
2015-02-11 13:36:02 -08:00
dec d
dec e
2015-11-29 18:34:59 -08:00
jr nz, .loopfindend
.foundend
2015-02-11 13:36:02 -08:00
ld a, d
2015-11-29 18:34:59 -08:00
ld [wDexListingEnd], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_ABCMode:
2015-02-11 13:36:02 -08:00
xor a
2015-11-29 18:34:59 -08:00
ld [wDexListingEnd], a
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder
2015-02-11 13:36:02 -08:00
ld de, AlphabeticalPokedexOrder
ld c, NUM_POKEMON
2015-11-29 18:34:59 -08:00
.loop1abc
2015-02-11 13:36:02 -08:00
push bc
ld a, [de]
ld [wTempSpecies], a
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
jr z, .skipabc
ld a, [wTempSpecies]
2015-02-11 13:36:02 -08:00
ld [hli], a
2015-11-29 18:34:59 -08:00
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
inc a
2015-11-29 18:34:59 -08:00
ld [wDexListingEnd], a
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
.skipabc
2015-02-11 13:36:02 -08:00
inc de
pop bc
dec c
2015-11-29 18:34:59 -08:00
jr nz, .loop1abc
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
ld c, 0
2015-11-29 18:34:59 -08:00
.loop2abc
2015-02-11 13:36:02 -08:00
cp NUM_POKEMON
2015-11-29 18:34:59 -08:00
jr z, .doneabc
2015-02-11 13:36:02 -08:00
ld [hl], c
inc hl
inc a
2015-11-29 18:34:59 -08:00
jr .loop2abc
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
.doneabc
2015-02-11 13:36:02 -08:00
ret
INCLUDE "data/pokemon/dex_order_alpha.asm"
2015-02-11 13:36:02 -08:00
INCLUDE "data/pokemon/dex_order_new.asm"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_DisplayModeDescription:
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
hlcoord 0, 12
2016-01-12 09:46:18 -08:00
lb bc, 4, 18
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2016-01-09 19:03:38 -08:00
ld hl, .Modes
2015-11-29 18:34:59 -08:00
call Pokedex_LoadPointer
2015-02-11 13:36:02 -08:00
ld e, l
ld d, h
hlcoord 1, 14
call PlaceString
ld a, $1
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.Modes:
2015-11-29 18:34:59 -08:00
dw .NewMode
dw .OldMode
dw .ABCMode
dw .UnownMode
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.NewMode:
2015-11-29 18:34:59 -08:00
db "<PK><MN> are listed by"
next "evolution type.@"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.OldMode:
2015-11-29 18:34:59 -08:00
db "<PK><MN> are listed by"
next "official type.@"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.ABCMode:
2015-11-29 18:34:59 -08:00
db "<PK><MN> are listed"
next "alphabetically.@"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.UnownMode:
db "UNOWN are listed"
next "in catching order.@"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_DisplayChangingModesMessage:
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
hlcoord 0, 12
2016-01-12 09:46:18 -08:00
lb bc, 4, 18
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
ld de, String_ChangingModesPleaseWait
2015-02-11 13:36:02 -08:00
hlcoord 1, 14
call PlaceString
ld a, $1
ldh [hBGMapMode], a
2015-11-29 18:34:59 -08:00
ld c, 64
2015-02-11 13:36:02 -08:00
call DelayFrames
ld de, SFX_CHANGE_DEX_MODE
call PlaySFX
2015-11-29 18:34:59 -08:00
ld c, 64
2015-02-11 13:36:02 -08:00
call DelayFrames
ret
2018-06-24 07:09:41 -07:00
String_ChangingModesPleaseWait:
2015-11-29 18:34:59 -08:00
db "Changing modes."
next "Please wait.@"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_UpdateSearchMonType:
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
cp 2
2016-01-09 19:03:38 -08:00
jr nc, .no_change
2015-10-16 10:35:43 -07:00
ld hl, hJoyLast
2015-02-11 13:36:02 -08:00
ld a, [hl]
2016-01-09 17:51:14 -08:00
and D_LEFT
jr nz, Pokedex_PrevSearchMonType
2015-02-11 13:36:02 -08:00
ld a, [hl]
2016-01-09 17:51:14 -08:00
and D_RIGHT
jr nz, Pokedex_NextSearchMonType
2016-01-09 19:03:38 -08:00
.no_change
2015-02-11 13:36:02 -08:00
and a
ret
2016-01-09 17:51:14 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_PrevSearchMonType:
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2015-02-11 13:36:02 -08:00
and a
2016-01-09 19:03:38 -08:00
jr nz, .type2
2016-01-09 17:51:14 -08:00
ld hl, wDexSearchMonType1
2015-02-11 13:36:02 -08:00
ld a, [hl]
2018-01-10 22:45:27 -08:00
cp 1
2016-01-09 19:03:38 -08:00
jr z, .wrap_around
2015-02-11 13:36:02 -08:00
dec [hl]
2016-01-09 19:03:38 -08:00
jr .done
.type2
2016-01-09 17:51:14 -08:00
ld hl, wDexSearchMonType2
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
2016-01-09 19:03:38 -08:00
jr z, .wrap_around
2015-02-11 13:36:02 -08:00
dec [hl]
2016-01-09 19:03:38 -08:00
jr .done
.wrap_around
2018-01-10 22:45:27 -08:00
ld [hl], NUM_TYPES - 1
2016-01-09 19:03:38 -08:00
.done
2015-02-11 13:36:02 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
Pokedex_NextSearchMonType:
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2015-02-11 13:36:02 -08:00
and a
2016-01-09 19:03:38 -08:00
jr nz, .type2
2016-01-09 17:51:14 -08:00
ld hl, wDexSearchMonType1
2015-02-11 13:36:02 -08:00
ld a, [hl]
2018-01-10 22:45:27 -08:00
cp NUM_TYPES - 1
2016-01-09 19:03:38 -08:00
jr nc, .type1_wrap_around
2015-02-11 13:36:02 -08:00
inc [hl]
2016-01-09 19:03:38 -08:00
jr .done
.type1_wrap_around
2018-01-10 22:45:27 -08:00
ld [hl], 1
2016-01-09 19:03:38 -08:00
jr .done
.type2
2016-01-09 17:51:14 -08:00
ld hl, wDexSearchMonType2
2015-02-11 13:36:02 -08:00
ld a, [hl]
2018-01-10 22:45:27 -08:00
cp NUM_TYPES - 1
2016-01-09 19:03:38 -08:00
jr nc, .type2_wrap_around
2015-02-11 13:36:02 -08:00
inc [hl]
2016-01-09 19:03:38 -08:00
jr .done
.type2_wrap_around
ld [hl], 0
.done
2015-02-11 13:36:02 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
Pokedex_PlaceSearchScreenTypeStrings:
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
hlcoord 9, 3
2016-01-09 17:51:14 -08:00
lb bc, 4, 8
ld a, " "
2015-11-29 18:34:59 -08:00
call Pokedex_FillBox
2016-01-09 17:51:14 -08:00
ld a, [wDexSearchMonType1]
2015-02-11 13:36:02 -08:00
hlcoord 9, 4
2016-01-09 17:51:14 -08:00
call Pokedex_PlaceTypeString
ld a, [wDexSearchMonType2]
2015-02-11 13:36:02 -08:00
hlcoord 9, 6
2016-01-09 17:51:14 -08:00
call Pokedex_PlaceTypeString
2015-02-11 13:36:02 -08:00
ld a, $1
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_PlaceTypeString:
2015-02-11 13:36:02 -08:00
push hl
ld e, a
ld d, 0
2018-01-10 22:45:27 -08:00
ld hl, PokedexTypeSearchStrings
2015-07-20 19:18:18 -07:00
rept 9
2015-02-11 13:36:02 -08:00
add hl, de
2015-07-20 19:18:18 -07:00
endr
2015-02-11 13:36:02 -08:00
ld e, l
ld d, h
pop hl
call PlaceString
ret
2018-01-10 22:45:27 -08:00
INCLUDE "data/types/search_strings.asm"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_SearchForMons:
2016-01-09 17:51:14 -08:00
ld a, [wDexSearchMonType2]
2015-02-11 13:36:02 -08:00
and a
2016-01-09 17:51:14 -08:00
call nz, .Search
ld a, [wDexSearchMonType1]
2015-02-11 13:36:02 -08:00
and a
2016-01-09 17:51:14 -08:00
call nz, .Search
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.Search:
2015-02-11 13:36:02 -08:00
dec a
ld e, a
ld d, 0
2018-01-10 22:45:27 -08:00
ld hl, PokedexTypeSearchConversionTable
2015-02-11 13:36:02 -08:00
add hl, de
ld a, [hl]
2016-01-09 17:51:14 -08:00
ld [wDexConvertedMonType], a
2017-12-09 12:28:03 -08:00
ld hl, wPokedexOrder
ld de, wPokedexOrder
2015-02-11 13:36:02 -08:00
ld c, NUM_POKEMON
xor a
2016-01-09 17:51:14 -08:00
ld [wDexSearchResultCount], a
.loop
2015-02-11 13:36:02 -08:00
push bc
ld a, [hl]
and a
2016-01-09 17:51:14 -08:00
jr z, .next_mon
ld [wTempSpecies], a
2018-01-23 14:39:09 -08:00
ld [wCurSpecies], a
2015-11-29 18:34:59 -08:00
call Pokedex_CheckCaught
2016-01-09 17:51:14 -08:00
jr z, .next_mon
2015-02-11 13:36:02 -08:00
push hl
push de
call GetBaseData
pop de
pop hl
2016-01-09 17:51:14 -08:00
ld a, [wDexConvertedMonType]
2015-02-11 13:36:02 -08:00
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wBaseType1]
2015-02-11 13:36:02 -08:00
cp b
2016-01-09 17:51:14 -08:00
jr z, .match_found
2018-01-23 14:39:09 -08:00
ld a, [wBaseType2]
2015-02-11 13:36:02 -08:00
cp b
2016-01-09 17:51:14 -08:00
jr nz, .next_mon
2015-02-11 13:36:02 -08:00
2016-01-09 17:51:14 -08:00
.match_found
ld a, [wTempSpecies]
2015-02-11 13:36:02 -08:00
ld [de], a
inc de
2016-01-09 17:51:14 -08:00
ld a, [wDexSearchResultCount]
2015-02-11 13:36:02 -08:00
inc a
2016-01-09 17:51:14 -08:00
ld [wDexSearchResultCount], a
2015-02-11 13:36:02 -08:00
2016-01-09 17:51:14 -08:00
.next_mon
2015-02-11 13:36:02 -08:00
inc hl
pop bc
dec c
2016-01-09 17:51:14 -08:00
jr nz, .loop
2015-02-11 13:36:02 -08:00
ld l, e
ld h, d
2016-01-09 17:51:14 -08:00
ld a, [wDexSearchResultCount]
2015-02-11 13:36:02 -08:00
ld c, 0
2016-01-09 17:51:14 -08:00
.zero_remaining_mons
2015-02-11 13:36:02 -08:00
cp NUM_POKEMON
2016-01-09 17:51:14 -08:00
jr z, .done
2015-02-11 13:36:02 -08:00
ld [hl], c
inc hl
inc a
2016-01-09 17:51:14 -08:00
jr .zero_remaining_mons
2015-02-11 13:36:02 -08:00
2016-01-09 17:51:14 -08:00
.done
2015-02-11 13:36:02 -08:00
ret
2018-01-10 22:45:27 -08:00
INCLUDE "data/types/search_types.asm"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_DisplayTypeNotFoundMessage:
2015-02-11 13:36:02 -08:00
xor a
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
hlcoord 0, 12
2016-01-12 09:46:18 -08:00
lb bc, 4, 18
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2016-01-09 19:03:38 -08:00
ld de, .TypeNotFound
2015-02-11 13:36:02 -08:00
hlcoord 1, 14
call PlaceString
ld a, $1
ldh [hBGMapMode], a
2015-02-11 13:36:02 -08:00
ld c, $80
call DelayFrames
ret
2018-06-24 07:09:41 -07:00
.TypeNotFound:
db "The specified type"
next "was not found.@"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_UpdateCursorOAM:
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
2016-01-09 17:51:14 -08:00
cp DEXMODE_OLD
jp z, Pokedex_PutOldModeCursorOAM
call Pokedex_PutNewModeABCModeCursorOAM
call Pokedex_PutScrollbarOAM
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_PutOldModeCursorOAM:
2016-01-09 17:51:14 -08:00
ld hl, .CursorOAM
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
2015-02-11 13:36:02 -08:00
or a
2016-01-09 17:51:14 -08:00
jr nz, .okay
ld hl, .CursorAtTopOAM
.okay
call Pokedex_LoadCursorOAM
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.CursorOAM:
dsprite 3, 0, 9, -1, $30, 7
dsprite 2, 0, 9, -1, $31, 7
dsprite 2, 0, 10, -1, $32, 7
dsprite 2, 0, 11, -1, $32, 7
dsprite 2, 0, 12, -1, $32, 7
dsprite 2, 0, 13, -1, $33, 7
dsprite 2, 0, 16, -2, $33, 7 | X_FLIP
dsprite 2, 0, 17, -2, $32, 7 | X_FLIP
dsprite 2, 0, 18, -2, $32, 7 | X_FLIP
dsprite 2, 0, 19, -2, $32, 7 | X_FLIP
dsprite 2, 0, 20, -2, $31, 7 | X_FLIP
dsprite 3, 0, 20, -2, $30, 7 | X_FLIP
dsprite 4, 0, 9, -1, $30, 7 | Y_FLIP
dsprite 5, 0, 9, -1, $31, 7 | Y_FLIP
dsprite 5, 0, 10, -1, $32, 7 | Y_FLIP
dsprite 5, 0, 11, -1, $32, 7 | Y_FLIP
dsprite 5, 0, 12, -1, $32, 7 | Y_FLIP
dsprite 5, 0, 13, -1, $33, 7 | Y_FLIP
dsprite 5, 0, 16, -2, $33, 7 | X_FLIP | Y_FLIP
dsprite 5, 0, 17, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 0, 18, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 0, 19, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 0, 20, -2, $31, 7 | X_FLIP | Y_FLIP
dsprite 4, 0, 20, -2, $30, 7 | X_FLIP | Y_FLIP
2018-01-10 10:47:57 -08:00
db -1
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
.CursorAtTopOAM:
2016-01-09 17:51:14 -08:00
; 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.
dsprite 3, 0, 9, -1, $30, 7
dsprite 2, 0, 9, -1, $34, 7
dsprite 2, 0, 10, -1, $35, 7
dsprite 2, 0, 11, -1, $35, 7
dsprite 2, 0, 12, -1, $35, 7
dsprite 2, 0, 13, -1, $36, 7
dsprite 2, 0, 16, -2, $36, 7 | X_FLIP
dsprite 2, 0, 17, -2, $35, 7 | X_FLIP
dsprite 2, 0, 18, -2, $35, 7 | X_FLIP
dsprite 2, 0, 19, -2, $35, 7 | X_FLIP
dsprite 2, 0, 20, -2, $34, 7 | X_FLIP
dsprite 3, 0, 20, -2, $30, 7 | X_FLIP
dsprite 4, 0, 9, -1, $30, 7 | Y_FLIP
dsprite 5, 0, 9, -1, $31, 7 | Y_FLIP
dsprite 5, 0, 10, -1, $32, 7 | Y_FLIP
dsprite 5, 0, 11, -1, $32, 7 | Y_FLIP
dsprite 5, 0, 12, -1, $32, 7 | Y_FLIP
dsprite 5, 0, 13, -1, $33, 7 | Y_FLIP
dsprite 5, 0, 16, -2, $33, 7 | X_FLIP | Y_FLIP
dsprite 5, 0, 17, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 0, 18, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 0, 19, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 0, 20, -2, $31, 7 | X_FLIP | Y_FLIP
dsprite 4, 0, 20, -2, $30, 7 | X_FLIP | Y_FLIP
2018-01-10 10:47:57 -08:00
db -1
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_PutNewModeABCModeCursorOAM:
2016-01-09 17:51:14 -08:00
ld hl, .CursorOAM
call Pokedex_LoadCursorOAM
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.CursorOAM:
dsprite 3, 3, 9, -1, $30, 7
dsprite 2, 3, 9, -1, $31, 7
dsprite 2, 3, 10, -1, $32, 7
dsprite 2, 3, 11, -1, $32, 7
dsprite 2, 3, 12, -1, $33, 7
dsprite 2, 3, 16, 0, $33, 7 | X_FLIP
dsprite 2, 3, 17, 0, $32, 7 | X_FLIP
dsprite 2, 3, 18, 0, $32, 7 | X_FLIP
dsprite 2, 3, 19, 0, $31, 7 | X_FLIP
dsprite 3, 3, 19, 0, $30, 7 | X_FLIP
dsprite 4, 3, 9, -1, $30, 7 | Y_FLIP
dsprite 5, 3, 9, -1, $31, 7 | Y_FLIP
dsprite 5, 3, 10, -1, $32, 7 | Y_FLIP
dsprite 5, 3, 11, -1, $32, 7 | Y_FLIP
dsprite 5, 3, 12, -1, $33, 7 | Y_FLIP
dsprite 5, 3, 16, 0, $33, 7 | X_FLIP | Y_FLIP
dsprite 5, 3, 17, 0, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 3, 18, 0, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 3, 19, 0, $31, 7 | X_FLIP | Y_FLIP
dsprite 4, 3, 19, 0, $30, 7 | X_FLIP | Y_FLIP
2018-01-10 10:47:57 -08:00
db -1
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_UpdateSearchResultsCursorOAM:
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
2016-01-09 17:51:14 -08:00
cp DEXMODE_OLD
jp z, Pokedex_PutOldModeCursorOAM
ld hl, .CursorOAM
call Pokedex_LoadCursorOAM
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
.CursorOAM:
dsprite 3, 3, 9, -1, $30, 7
dsprite 2, 3, 9, -1, $31, 7
dsprite 2, 3, 10, -1, $32, 7
dsprite 2, 3, 11, -1, $32, 7
dsprite 2, 3, 12, -1, $32, 7
dsprite 2, 3, 13, -1, $33, 7
dsprite 2, 3, 16, -2, $33, 7 | X_FLIP
dsprite 2, 3, 17, -2, $32, 7 | X_FLIP
dsprite 2, 3, 18, -2, $32, 7 | X_FLIP
dsprite 2, 3, 19, -2, $32, 7 | X_FLIP
dsprite 2, 3, 20, -2, $31, 7 | X_FLIP
dsprite 3, 3, 20, -2, $30, 7 | X_FLIP
dsprite 4, 3, 9, -1, $30, 7 | Y_FLIP
dsprite 5, 3, 9, -1, $31, 7 | Y_FLIP
dsprite 5, 3, 10, -1, $32, 7 | Y_FLIP
dsprite 5, 3, 11, -1, $32, 7 | Y_FLIP
dsprite 5, 3, 12, -1, $32, 7 | Y_FLIP
dsprite 5, 3, 13, -1, $33, 7 | Y_FLIP
dsprite 5, 3, 16, -2, $33, 7 | X_FLIP | Y_FLIP
dsprite 5, 3, 17, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 3, 18, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 3, 19, -2, $32, 7 | X_FLIP | Y_FLIP
dsprite 5, 3, 20, -2, $31, 7 | X_FLIP | Y_FLIP
dsprite 4, 3, 20, -2, $30, 7 | X_FLIP | Y_FLIP
2018-01-10 10:47:57 -08:00
db -1
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_LoadCursorOAM:
2018-01-30 11:52:46 -08:00
ld de, wVirtualOAMSprite00
2016-01-09 17:51:14 -08:00
.loop
2015-02-11 13:36:02 -08:00
ld a, [hl]
2018-01-10 10:47:57 -08:00
cp -1
2015-02-11 13:36:02 -08:00
ret z
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
2015-02-11 13:36:02 -08:00
and $7
swap a
2018-01-10 10:47:57 -08:00
add [hl] ; y
2015-02-11 13:36:02 -08:00
inc hl
ld [de], a
inc de
2018-01-10 10:47:57 -08:00
ld a, [hli] ; x
2015-02-11 13:36:02 -08:00
ld [de], a
inc de
2018-01-10 10:47:57 -08:00
ld a, [hli] ; tile id
2015-02-11 13:36:02 -08:00
ld [de], a
inc de
2018-01-10 10:47:57 -08:00
ld a, [hli] ; attributes
2015-02-11 13:36:02 -08:00
ld [de], a
inc de
2016-01-09 17:51:14 -08:00
jr .loop
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_PutScrollbarOAM:
2016-01-09 17:51:14 -08:00
; Writes the OAM data for the scrollbar in the new mode and ABC mode.
2015-02-11 13:36:02 -08:00
push de
2015-11-29 18:34:59 -08:00
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
dec a
ld e, a
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
2016-01-09 17:51:14 -08:00
ld hl, wDexListingScrollOffset
2015-02-11 13:36:02 -08:00
add [hl]
cp e
2018-07-29 13:15:06 -07:00
jr z, .max
ld hl, 0
ld bc, 121 ; max y - min y
2015-02-11 13:36:02 -08:00
call AddNTimes
ld e, l
ld d, h
2018-07-29 13:15:06 -07:00
ld b, 0
2015-02-11 13:36:02 -08:00
ld a, d
or e
2018-07-29 13:15:06 -07:00
jr z, .done
2015-11-29 18:34:59 -08:00
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
ld c, a
2018-07-29 13:15:06 -07:00
.loop
2015-02-11 13:36:02 -08:00
ld a, e
sub c
ld e, a
ld a, d
2018-07-29 13:15:06 -07:00
sbc 0
2015-02-11 13:36:02 -08:00
ld d, a
2018-07-29 13:15:06 -07:00
jr c, .done
2015-02-11 13:36:02 -08:00
inc b
2018-07-29 13:15:06 -07:00
jr .loop
.max
ld b, 121 ; max y - min y
.done
ld a, 20 ; min y
2015-02-11 13:36:02 -08:00
add b
pop hl
ld [hli], a
2018-07-29 13:15:06 -07:00
ld a, 161 ; x
2015-02-11 13:36:02 -08:00
ld [hli], a
2018-07-29 13:15:06 -07:00
ld a, $0f ; tile id
2015-02-11 13:36:02 -08:00
ld [hli], a
2018-07-29 13:15:06 -07:00
ld [hl], 0 ; attributes
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_InitArrowCursor:
2015-02-11 13:36:02 -08:00
xor a
2016-01-09 17:51:14 -08:00
ld [wDexArrowCursorPosIndex], a
ld [wDexArrowCursorDelayCounter], a
ld [wDexArrowCursorBlinkCounter], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_MoveArrowCursor:
2015-11-29 18:34:59 -08:00
; bc = [de] - 1
2015-02-11 13:36:02 -08:00
ld a, [de]
ld b, a
inc de
ld a, [de]
dec a
ld c, a
inc de
2016-01-09 17:51:14 -08:00
call Pokedex_BlinkArrowCursor
2015-11-29 18:34:59 -08:00
2016-01-09 17:51:14 -08:00
ld hl, hJoyPressed
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_LEFT | D_UP
and b
2016-01-09 19:03:38 -08:00
jr nz, .move_left_or_up
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_RIGHT | D_DOWN
and b
2016-01-09 19:03:38 -08:00
jr nz, .move_right_or_down
2015-02-11 13:36:02 -08:00
ld a, [hl]
and SELECT
and b
2016-01-09 19:03:38 -08:00
jr nz, .select
2016-01-09 17:51:14 -08:00
call Pokedex_ArrowCursorDelay
2016-01-09 19:03:38 -08:00
jr c, .no_action
2015-10-16 10:35:43 -07:00
ld hl, hJoyLast
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_LEFT | D_UP
and b
2016-01-09 19:03:38 -08:00
jr nz, .move_left_or_up
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_RIGHT | D_DOWN
and b
2016-01-09 19:03:38 -08:00
jr nz, .move_right_or_down
jr .no_action
2015-11-29 18:34:59 -08:00
2016-01-09 19:03:38 -08:00
.move_left_or_up
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2015-02-11 13:36:02 -08:00
and a
2016-01-09 19:03:38 -08:00
jr z, .no_action
2016-01-09 17:51:14 -08:00
call Pokedex_GetArrowCursorPos
2015-11-29 18:34:59 -08:00
ld [hl], " "
2016-01-09 17:51:14 -08:00
ld hl, wDexArrowCursorPosIndex
2015-02-11 13:36:02 -08:00
dec [hl]
2016-01-09 19:03:38 -08:00
jr .update_cursor_pos
2015-11-29 18:34:59 -08:00
2016-01-09 19:03:38 -08:00
.move_right_or_down
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2015-02-11 13:36:02 -08:00
cp c
2016-01-09 19:03:38 -08:00
jr nc, .no_action
2016-01-09 17:51:14 -08:00
call Pokedex_GetArrowCursorPos
2015-11-29 18:34:59 -08:00
ld [hl], " "
2016-01-09 17:51:14 -08:00
ld hl, wDexArrowCursorPosIndex
2015-02-11 13:36:02 -08:00
inc [hl]
2016-01-09 17:51:14 -08:00
2016-01-09 19:03:38 -08:00
.update_cursor_pos
2016-01-09 17:51:14 -08:00
call Pokedex_GetArrowCursorPos
2015-11-29 18:34:59 -08:00
ld [hl], "▶"
2016-01-09 17:51:14 -08:00
ld a, 12
ld [wDexArrowCursorDelayCounter], a
2015-02-11 13:36:02 -08:00
xor a
2016-01-09 17:51:14 -08:00
ld [wDexArrowCursorBlinkCounter], a
2015-02-11 13:36:02 -08:00
scf
ret
2015-11-29 18:34:59 -08:00
2016-01-09 19:03:38 -08:00
.no_action
2015-02-11 13:36:02 -08:00
and a
ret
2015-11-29 18:34:59 -08:00
2016-01-09 19:03:38 -08:00
.select
2016-01-09 17:51:14 -08:00
call Pokedex_GetArrowCursorPos
2015-11-29 18:34:59 -08:00
ld [hl], " "
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2015-02-11 13:36:02 -08:00
cp c
2016-01-09 19:03:38 -08:00
jr c, .update
2016-01-09 17:51:14 -08:00
ld a, -1
2016-01-09 19:03:38 -08:00
.update
2015-02-11 13:36:02 -08:00
inc a
2016-01-09 17:51:14 -08:00
ld [wDexArrowCursorPosIndex], a
2016-01-09 19:03:38 -08:00
jr .update_cursor_pos
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_GetArrowCursorPos:
2016-01-09 17:51:14 -08:00
ld a, [wDexArrowCursorPosIndex]
2015-02-11 13:36:02 -08:00
add a
ld l, a
2016-01-09 17:51:14 -08:00
ld h, 0
2015-02-11 13:36:02 -08:00
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ret
2018-06-24 07:09:41 -07:00
Pokedex_BlinkArrowCursor:
2016-01-09 17:51:14 -08:00
ld hl, wDexArrowCursorBlinkCounter
2015-02-11 13:36:02 -08:00
ld a, [hl]
inc [hl]
and $8
2015-11-29 18:34:59 -08:00
jr z, .blink_on
2016-01-09 17:51:14 -08:00
call Pokedex_GetArrowCursorPos
2015-11-29 18:34:59 -08:00
ld [hl], " "
2015-02-11 13:36:02 -08:00
ret
2015-11-29 18:34:59 -08:00
.blink_on
2016-01-09 17:51:14 -08:00
call Pokedex_GetArrowCursorPos
2015-11-29 18:34:59 -08:00
ld [hl], "▶"
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_ArrowCursorDelay:
2016-01-09 17:51:14 -08:00
; Updates the delay counter set when moving the arrow cursor.
; Returns whether the delay is active in carry.
ld hl, wDexArrowCursorDelayCounter
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
ret z
2015-11-29 18:34:59 -08:00
2015-02-11 13:36:02 -08:00
dec [hl]
scf
ret
2018-06-24 07:09:41 -07:00
Pokedex_FillBox:
jp FillBoxWithByte
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_BlackOutBG:
2016-01-09 17:51:14 -08:00
; Make BG palettes black so that the BG becomes all black.
ldh a, [rSVBK]
2015-02-11 13:36:02 -08:00
push af
ld a, BANK(wBGPals1)
ldh [rSVBK], a
2018-01-01 06:08:21 -08:00
ld hl, wBGPals1
2018-01-01 05:47:16 -08:00
ld bc, 8 palettes
2015-02-11 13:36:02 -08:00
xor a
call ByteFill
pop af
ldh [rSVBK], a
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_ApplyPrintPals:
2015-02-11 13:36:02 -08:00
ld a, $ff
call DmgToCgbBGPals
ld a, $ff
2015-12-09 08:38:40 -08:00
call DmgToCgbObjPal0
2015-02-11 13:36:02 -08:00
call DelayFrame
ret
2018-06-24 07:09:41 -07:00
Pokedex_GetSGBLayout:
2015-02-11 13:36:02 -08:00
ld b, a
call GetSGBLayout
2018-06-24 07:09:41 -07:00
Pokedex_ApplyUsualPals:
2016-01-09 19:03:38 -08:00
; This applies the palettes used for most Pokédex screens.
2015-02-11 13:36:02 -08:00
ld a, $e4
call DmgToCgbBGPals
ld a, $e0
2015-12-09 08:38:40 -08:00
call DmgToCgbObjPal0
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
Pokedex_LoadPointer:
2015-02-11 13:36:02 -08:00
ld e, a
ld d, 0
add hl, de
add hl, de
2015-02-11 13:36:02 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
ret
2018-06-24 07:09:41 -07:00
Pokedex_LoadSelectedMonTiles:
2016-01-09 17:51:14 -08:00
; Loads the tiles of the currently selected Pokémon.
call Pokedex_GetSelectedMon
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
jr z, .QuestionMark
ld a, [wFirstUnownSeen]
2018-01-23 14:39:09 -08:00
ld [wUnownLetter], a
ld a, [wTempSpecies]
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2015-02-11 13:36:02 -08:00
call GetBaseData
2017-12-28 04:32:33 -08:00
ld de, vTiles2
predef GetMonFrontpic
2015-02-11 13:36:02 -08:00
ret
.QuestionMark:
ld a, BANK(sScratch)
2015-02-11 13:36:02 -08:00
call GetSRAMBank
2017-12-24 09:47:30 -08:00
farcall LoadQuestionMarkPic
2017-12-28 04:32:33 -08:00
ld hl, vTiles2
ld de, sScratch
ld c, 7 * 7
ldh a, [hROMBank]
2015-02-11 13:36:02 -08:00
ld b, a
call Get2bpp
call CloseSRAM
ret
2018-06-24 07:09:41 -07:00
Pokedex_LoadCurrentFootprint:
2016-01-09 17:51:14 -08:00
call Pokedex_GetSelectedMon
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_LoadAnyFootprint:
ld a, [wTempSpecies]
2015-02-11 13:36:02 -08:00
dec a
2018-01-09 14:20:47 -08:00
and %11111000
2015-02-11 13:36:02 -08:00
srl a
srl a
srl a
ld e, 0
ld d, a
ld a, [wTempSpecies]
2015-02-11 13:36:02 -08:00
dec a
2018-01-09 14:20:47 -08:00
and %111
2015-02-11 13:36:02 -08:00
swap a ; * $10
ld l, a
ld h, 0
add hl, de
ld de, Footprints
add hl, de
push hl
ld e, l
ld d, h
2017-12-28 04:32:33 -08:00
ld hl, vTiles2 tile $62
2015-02-11 13:36:02 -08:00
lb bc, BANK(Footprints), 2
call Request1bpp
pop hl
; Whoever was editing footprints forgot to fix their
; tile editor. Now each bottom half is 8 tiles off.
2015-11-29 18:34:59 -08:00
ld de, 8 tiles
2015-02-11 13:36:02 -08:00
add hl, de
ld e, l
ld d, h
2017-12-28 04:32:33 -08:00
ld hl, vTiles2 tile $64
2015-02-11 13:36:02 -08:00
lb bc, BANK(Footprints), 2
call Request1bpp
ret
2018-06-24 07:09:41 -07:00
Pokedex_LoadGFX:
2015-02-11 13:36:02 -08:00
call DisableLCD
2017-12-28 04:32:33 -08:00
ld hl, vTiles2
2015-11-29 18:34:59 -08:00
ld bc, $31 tiles
2015-02-11 13:36:02 -08:00
xor a
call ByteFill
2015-11-29 18:34:59 -08:00
call Pokedex_LoadInvertedFont
2015-11-04 13:14:27 -08:00
call LoadFontsExtra
2017-12-28 04:32:33 -08:00
ld hl, vTiles2 tile $60
2015-11-29 18:34:59 -08:00
ld bc, $20 tiles
call Pokedex_InvertTiles
call Pokedex_CheckSGB
jr nz, .LoadPokedexLZ
2017-12-24 09:47:30 -08:00
farcall LoadSGBPokedexGFX
2015-11-29 18:34:59 -08:00
jr .LoadPokedexSlowpokeLZ
.LoadPokedexLZ:
2015-02-11 13:36:02 -08:00
ld hl, PokedexLZ
2017-12-28 04:32:33 -08:00
ld de, vTiles2 tile $31
2015-02-11 13:36:02 -08:00
call Decompress
.LoadPokedexSlowpokeLZ:
2015-02-11 13:36:02 -08:00
ld hl, PokedexSlowpokeLZ
2017-12-28 04:32:33 -08:00
ld de, vTiles0
2015-02-11 13:36:02 -08:00
call Decompress
ld a, 6
call SkipMusic
call EnableLCD
ret
2018-06-24 07:09:41 -07:00
Pokedex_LoadInvertedFont:
2015-11-04 13:14:27 -08:00
call LoadStandardFont
2017-12-28 04:32:33 -08:00
ld hl, vTiles1
2015-11-29 18:34:59 -08:00
ld bc, $80 tiles
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
Pokedex_InvertTiles:
2015-11-29 18:34:59 -08:00
.loop
2015-02-11 13:36:02 -08:00
ld a, [hl]
xor $ff
ld [hli], a
dec bc
ld a, b
or c
2015-11-29 18:34:59 -08:00
jr nz, .loop
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
PokedexLZ:
2015-11-29 18:34:59 -08:00
INCBIN "gfx/pokedex/pokedex.2bpp.lz"
2015-02-11 13:36:02 -08:00
2018-06-24 07:09:41 -07:00
PokedexSlowpokeLZ:
2015-02-11 13:36:02 -08:00
INCBIN "gfx/pokedex/slowpoke.2bpp.lz"
2018-06-24 07:09:41 -07:00
Pokedex_CheckSGB:
ldh a, [hCGB]
2015-02-11 13:36:02 -08:00
or a
ret nz
ldh a, [hSGB]
2015-02-11 13:36:02 -08:00
dec a
ret
2018-06-24 07:09:41 -07:00
Pokedex_LoadUnownFont:
2015-08-20 23:00:59 -07:00
ld a, BANK(sScratch)
2015-02-11 13:36:02 -08:00
call GetSRAMBank
ld hl, UnownFont
2015-08-20 23:00:59 -07:00
ld de, sScratch + $188
2015-11-29 18:34:59 -08:00
ld bc, 39 tiles
2015-02-11 13:36:02 -08:00
ld a, BANK(UnownFont)
call FarCopyBytes
2015-08-20 23:00:59 -07:00
ld hl, sScratch + $188
2018-07-18 10:06:56 -07:00
ld bc, (NUM_UNOWN + 1) tiles
2015-11-29 18:34:59 -08:00
call Pokedex_InvertTiles
2015-08-20 23:00:59 -07:00
ld de, sScratch + $188
2017-12-28 04:32:33 -08:00
ld hl, vTiles2 tile $40
2018-07-18 10:06:56 -07:00
lb bc, BANK(Pokedex_LoadUnownFont), NUM_UNOWN + 1
2015-02-11 13:36:02 -08:00
call Request2bpp
call CloseSRAM
ret
2018-06-24 07:09:41 -07:00
Pokedex_LoadUnownFrontpicTiles:
2018-01-23 14:39:09 -08:00
ld a, [wUnownLetter]
2015-02-11 13:36:02 -08:00
push af
2016-01-09 19:46:41 -08:00
ld a, [wDexCurrentUnownIndex]
2015-02-11 13:36:02 -08:00
ld e, a
2016-01-09 19:46:41 -08:00
ld d, 0
2018-01-23 14:39:09 -08:00
ld hl, wUnownDex
2015-02-11 13:36:02 -08:00
add hl, de
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wUnownLetter], a
2015-02-11 13:36:02 -08:00
ld a, UNOWN
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2015-02-11 13:36:02 -08:00
call GetBaseData
2017-12-28 04:32:33 -08:00
ld de, vTiles2 tile $00
predef GetMonFrontpic
2015-02-11 13:36:02 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wUnownLetter], a
2015-02-11 13:36:02 -08:00
ret
2018-06-24 07:09:41 -07:00
_NewPokedexEntry:
xor a
ldh [hBGMapMode], a
2017-12-24 09:47:30 -08:00
farcall DrawDexEntryScreenRightEdge
2015-11-29 18:34:59 -08:00
call Pokedex_ResetBGMapMode
call DisableLCD
call LoadStandardFont
call LoadFontsExtra
2015-11-29 18:34:59 -08:00
call Pokedex_LoadGFX
call Pokedex_LoadAnyFootprint
ld a, [wTempSpecies]
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
2016-01-09 17:51:14 -08:00
call Pokedex_DrawDexEntryScreenBG
2015-11-29 18:34:59 -08:00
call Pokedex_DrawFootprint
hlcoord 0, 17
ld [hl], $3b
inc hl
2015-11-29 18:34:59 -08:00
ld bc, 19
ld a, " "
call ByteFill
2017-12-24 09:47:30 -08:00
farcall DisplayDexEntry
call EnableLCD
call WaitBGMap
call GetBaseData
2017-12-28 04:32:33 -08:00
ld de, vTiles2
predef GetMonFrontpic
2016-01-09 17:51:14 -08:00
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
call PlayMonCry
ret
2018-06-24 07:09:41 -07:00
Pokedex_SetBGMapMode3:
ld a, $3
ldh [hBGMapMode], a
ld c, 4
call DelayFrames
ret
2018-06-24 07:09:41 -07:00
Pokedex_SetBGMapMode4:
ld a, $4
ldh [hBGMapMode], a
ld c, 4
call DelayFrames
ret
2018-06-24 07:09:41 -07:00
Pokedex_SetBGMapMode_3ifDMG_4ifCGB:
ldh a, [hCGB]
and a
2015-11-29 18:34:59 -08:00
jr z, .DMG
call Pokedex_SetBGMapMode4
.DMG:
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode3
ret
2018-06-24 07:09:41 -07:00
Pokedex_ResetBGMapMode:
xor a
ldh [hBGMapMode], a
ret