pokecrystal-board/engine/pokedex.asm

2663 lines
40 KiB
NASM
Raw Normal View History

2015-02-11 13:36:02 -08:00
Pokedex: ; 40000
ld a, [hWX]
ld l, a
ld a, [hWY]
ld h, a
push hl
ld a, [hSCX]
push af
ld hl, Options
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [VramState]
push af
xor a
ld [VramState], a
2015-10-16 10:35:43 -07:00
ld a, [hInMenu]
2015-02-11 13:36:02 -08:00
push af
ld a, $1
2015-10-16 10:35:43 -07:00
ld [hInMenu], a
2015-02-11 13:36:02 -08:00
xor a
2015-11-05 11:06:03 -08:00
ld [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
2015-11-29 18:34:59 -08:00
call Pokedex_Main
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
2015-10-16 10:35:43 -07:00
ld [hInMenu], a
2015-02-11 13:36:02 -08:00
pop af
ld [VramState], a
pop af
ld [Options], a
pop af
ld [hSCX], a
pop hl
ld a, l
ld [hWX], a
ld a, h
ld [hWY], a
ret
; 40063
InitPokedex: ; 40063
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
2015-02-11 13:36:02 -08:00
ld [wcf64], a
ld [wcf65], a
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
2015-11-29 18:34:59 -08:00
call Pokedex_ChangeMode
call Pokedex_InitCursorPosition
call Pokedex_GetLandmark
2015-02-11 13:36:02 -08:00
callba Function1de247
2015-11-29 18:34:59 -08:00
call Pokedex_ResetBGMapMode
2015-02-11 13:36:02 -08:00
ret
; 400a2
2015-11-29 18:34:59 -08:00
Pokedex_CheckUnlockedUnownMode: ; 400a2
2015-02-11 13:36:02 -08:00
ld a, [StatusFlags]
bit 1, 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
; 400b4
2015-11-29 18:34:59 -08:00
Pokedex_InitCursorPosition: ; 400b4
ld hl, wPokedexDataStart
ld a, [wLastDexEntry]
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
2015-11-29 18:34:59 -08:00
ld a, [wDexListingPage]
2015-02-11 13:36:02 -08:00
inc a
2015-11-29 18:34:59 -08:00
ld [wDexListingPage], 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
; 400ed
2015-11-29 18:34:59 -08:00
Pokedex_GetLandmark: ; 400ed
2015-02-11 13:36:02 -08:00
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
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
ld a, [BackupMapGroup]
ld b, a
ld a, [BackupMapNumber]
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
; 4010b
2015-11-29 18:34:59 -08:00
Pokedex_Main: ; 4010b
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
2015-02-11 13:36:02 -08:00
jp [hl]
; 40115
2015-11-29 18:34:59 -08:00
.Jumptable: ; 40115 (10:4115)
2015-02-11 13:36:02 -08:00
dw Function4013c
dw Function401ae
dw Function40217
dw Function40258
dw Function402aa
dw Function40443
dw Function40471
dw Function4039d
dw Function403be
dw Function4050a
dw Function40562
2015-11-29 18:34:59 -08:00
dw Pokedex_UnownMode ; Unown Dex
2015-02-11 13:36:02 -08:00
dw Function405df
2015-11-29 18:34:59 -08:00
dw Pokedex_CloseDex ; Exit
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
Pokedex_IncrementDexPointer: ; 40131 (10:4131)
2015-10-24 16:49:19 -07:00
ld hl, wJumptableIndex
2015-02-11 13:36:02 -08:00
inc [hl]
ret
2015-11-29 18:34:59 -08:00
Pokedex_CloseDex: ; 40136 (10:4136)
2015-10-24 16:49:19 -07:00
ld hl, wJumptableIndex
2015-02-11 13:36:02 -08:00
set 7, [hl]
ret
Function4013c: ; 4013c (10:413c)
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call ClearSprites
xor a
hlcoord 0, 0, AttrMap
2015-11-29 18:34:59 -08:00
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
2015-02-11 13:36:02 -08:00
call ByteFill
2015-11-29 18:34:59 -08:00
callba 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
2015-02-11 13:36:02 -08:00
ld a, $7
ld [wc7d3], a
call Function40b0f
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode_3ifDMG_4ifCGB
call Pokedex_ResetBGMapMode
2015-02-11 13:36:02 -08:00
call Function4074c
ld a, $5
ld [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
ld [hWX], a
2015-02-11 13:36:02 -08:00
xor a
ld [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
2015-02-11 13:36:02 -08:00
ld [CurPartySpecies], a
ld a, $4
call Function41423
call Function41148
2015-11-29 18:34:59 -08:00
callba 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
2015-02-11 13:36:02 -08:00
ld a, $7
ld [wc7d3], a
call Function40b0f
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
Function401ae: ; 401ae (10:41ae)
ld hl, hJoyPressed ; $ffa7
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
call Function406c5
ret nc
call Function41148
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call Function40b0f
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode3
call Pokedex_ResetBGMapMode
2015-02-11 13:36:02 -08:00
ret
.a
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
call Pokedex_CheckSeen
2015-02-11 13:36:02 -08:00
ret z
ld a, $2
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ld a, $0
ld [wcf64], a
ret
.select
call Function41401
ld a, $7
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
xor a
ld [hSCX], a
2015-02-11 13:36:02 -08:00
ld a, $a7
ld [hWX], a
2015-02-11 13:36:02 -08:00
call DelayFrame
ret
.start
call Function41401
ld a, $5
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
xor a
ld [hSCX], a
2015-02-11 13:36:02 -08:00
ld a, $a7
ld [hWX], a
2015-02-11 13:36:02 -08:00
call DelayFrame
ret
.b
ld a, $d
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
Function40217: ; 40217 (10:4217)
call LowVolume
xor a
ld [wPokedexStatus], a
2015-02-11 13:36:02 -08:00
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call ClearSprites
2015-11-29 18:34:59 -08:00
call Pokedex_LoadCurrentFootprint
2015-02-11 13:36:02 -08:00
call Function407fd
call Function4134f
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
ld [wLastDexEntry], a
callba 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
ld [hWX], a
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
2015-02-11 13:36:02 -08:00
ld [CurPartySpecies], a
ld a, $4
call Function41423
ld a, [CurPartySpecies]
call PlayCry
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
Function40258: ; 40258 (10:4258)
2015-12-09 08:38:40 -08:00
ld de, DexEntryPage_JoypadCoords
2015-02-11 13:36:02 -08:00
call Function4135a
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and B_BUTTON
jr nz, .b
ld a, [hl]
and A_BUTTON
jr nz, .a
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
.a
ld a, [wc7d8]
2015-12-09 08:38:40 -08:00
ld hl, DexEntryPage_Jumptable
2015-11-29 18:34:59 -08:00
call Pokedex_LoadPointer
2015-02-11 13:36:02 -08:00
jp [hl]
.b
ld a, [LastVolume]
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
ld [LastVolume], a
2015-11-29 18:34:59 -08:00
.max_volume
2015-02-11 13:36:02 -08:00
call MaxVolume
ld a, [wcf64]
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
; 40292 (10:4292)
2015-12-09 08:38:40 -08:00
Pokedex_Page: ; 40292
ld a, [wPokedexStatus]
2015-02-11 13:36:02 -08:00
xor $1
ld [wPokedexStatus], a
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
ld [wLastDexEntry], a
callba DisplayDexEntry
2015-02-11 13:36:02 -08:00
call WaitBGMap
ret
; 402aa
Function402aa: ; 402aa (10:42aa)
call Function41401
xor a
ld [wPokedexStatus], a
2015-02-11 13:36:02 -08:00
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call Function407fd
call Function4134f
2015-11-29 18:34:59 -08:00
call Pokedex_LoadCurrentFootprint
call Pokedex_GetMonAtCursorPosition
ld [wLastDexEntry], a
callba DisplayDexEntry
2015-11-29 18:34:59 -08:00
call Pokedex_DrawFootprint
2015-02-11 13:36:02 -08:00
call Function4143b
call WaitBGMap
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
2015-02-11 13:36:02 -08:00
ld [CurPartySpecies], a
ld a, $4
call Function41423
ld a, [CurPartySpecies]
call PlayCry
2015-10-24 16:49:19 -07:00
ld hl, wJumptableIndex
2015-02-11 13:36:02 -08:00
dec [hl]
ret
; 402e8 (10:42e8)
2015-12-09 08:38:40 -08:00
DexEntryPage_JoypadCoords: ; 402e8
2015-11-29 18:34:59 -08:00
db D_RIGHT | D_LEFT, 4
2015-02-11 13:36:02 -08:00
dwcoord 1, 17
dwcoord 6, 17
dwcoord 11, 17
dwcoord 15, 17
2015-11-29 18:34:59 -08:00
2015-02-11 13:36:02 -08:00
; 402f2
2015-12-09 08:38:40 -08:00
DexEntryPage_Jumptable: ; 402f2
dw Pokedex_Page
dw .Area
dw .Cry
dw .Print
2015-02-11 13:36:02 -08:00
; 402fa
2015-12-09 08:38:40 -08:00
.Area: ; 402fa
2015-02-11 13:36:02 -08:00
call Function41401
xor a
ld [hSCX], a
call DelayFrame
ld a, $7
ld [hWX], a
ld a, $90
ld [hWY], a
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
ld a, [wDexCurrentLocation]
2015-02-11 13:36:02 -08:00
ld e, a
2015-12-09 08:38:40 -08:00
predef _Area
2015-02-11 13:36:02 -08:00
call Function41401
call DelayFrame
xor a
ld [hBGMapMode], a
ld a, $90
ld [hWY], a
ld a, $5
ld [hSCX], a
call DelayFrame
call Function4038d
call Function4143b
call WaitBGMap
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
2015-02-11 13:36:02 -08:00
ld [CurPartySpecies], a
ld a, $4
call Function41423
ret
; 40340
2015-12-09 08:38:40 -08:00
.Cry: ; 40340
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
2015-02-11 13:36:02 -08:00
ld a, [wd265]
call GetCryIndex
ld e, c
ld d, b
call PlayCryHeader
ret
; 4034f
2015-12-09 08:38:40 -08:00
.Print: ; 4034f
2015-02-11 13:36:02 -08:00
call Function41415
xor a
ld [hSCX], a
ld a, [wcf65]
push af
ld a, [wcf64]
push af
2015-10-24 16:49:19 -07:00
ld a, [wJumptableIndex]
2015-02-11 13:36:02 -08:00
push af
2015-11-22 21:21:21 -08:00
callba 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
ld [wcf64], a
pop af
ld [wcf65], 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
2015-02-11 13:36:02 -08:00
call Function4038d
call EnableLCD
call WaitBGMap
ld a, $5
ld [hSCX], a
call Function41427
ret
; 4038d
Function4038d: ; 4038d
call Function407fd
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
callba DisplayDexEntry
2015-11-29 18:34:59 -08:00
call Pokedex_DrawFootprint
2015-02-11 13:36:02 -08:00
ret
; 4039d
Function4039d: ; 4039d (10:439d)
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call ClearSprites
call Function4087c
call Function4134f
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
2015-02-11 13:36:02 -08:00
ld [wc7d8], a
call Function40e5b
call WaitBGMap
ld a, $10
call Function41423
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
Function403be: ; 403be (10:43be)
2015-11-29 18:34:59 -08:00
ld a, [wUnlockedUnownMode]
2015-02-11 13:36:02 -08:00
and a
jr nz, .asm_403c9
ld de, Unknown_403f3
jr .asm_403cc
.asm_403c9
ld de, Unknown_403fb
.asm_403cc
call Function4135a
call c, Function40e5b
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and $6
jr nz, .asm_403ea
ld a, [hl]
and $1
jr nz, .asm_403e0
ret
.asm_403e0
ld a, [wc7d8]
ld hl, Jumptable_40405
2015-11-29 18:34:59 -08:00
call Pokedex_LoadPointer
2015-02-11 13:36:02 -08:00
jp [hl]
.asm_403ea
call Function41401
ld a, $0
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
; 403f3 (10:43f3)
Unknown_403f3: ; 403f3
2015-11-29 18:34:59 -08:00
db D_UP | D_DOWN, 3
dwcoord 2, 4
dwcoord 2, 6
dwcoord 2, 8
2015-02-11 13:36:02 -08:00
; 403fb
Unknown_403fb: ; 403fb
2015-11-29 18:34:59 -08:00
db D_UP | D_DOWN, 4
dwcoord 2, 4
dwcoord 2, 6
dwcoord 2, 8
2015-02-11 13:36:02 -08:00
dwcoord 2, 10
; 40405
Jumptable_40405: ; 40405 (10:4405)
dw Function4040d
dw Function40411
dw Function40415
dw Function4043a
; 4040d
Function4040d: ; 4040d (10:440d)
ld b, $0
jr Function40417
Function40411: ; 40411 (10:4411)
ld b, $1
jr Function40417
Function40415: ; 40415 (10:4415)
ld b, $2
Function40417: ; 40417 (10:4417)
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
2015-02-11 13:36:02 -08:00
cp b
jr z, .asm_40431
ld a, b
2015-11-29 18:34:59 -08:00
ld [wCurrentDexMode], a
call Pokedex_ChangeMode
2015-02-11 13:36:02 -08:00
call Function40f08
xor a
2015-11-29 18:34:59 -08:00
ld [wDexListingPage], a
ld [wDexListingCursor], a
call Pokedex_InitCursorPosition
2015-02-11 13:36:02 -08:00
.asm_40431
call Function41401
ld a, $0
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
Function4043a: ; 4043a (10:443a)
call Function41401
ld a, $b
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
Function40443: ; 40443 (10:4443)
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call ClearSprites
call Function408f0
call Function4134f
ld a, $1
ld [wc7d5], a
xor a
ld [wc7d6], a
call Function40fa8
xor a
ld [wDexSearchSlowpokeFrame], a
callba DoDexSearchSlowpokeFrame
2015-02-11 13:36:02 -08:00
call WaitBGMap
ld a, $10
call Function41423
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
Function40471: ; 40471 (10:4471)
ld de, Unknown_4049e
call Function4135a
call Function40f4f
call c, Function40fa8
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and START | B_BUTTON
jr nz, .asm_40495
ld a, [hl]
and A_BUTTON
jr nz, .asm_4048b
ret
.asm_4048b
ld a, [wc7d8]
ld hl, Jumptable_404a8
2015-11-29 18:34:59 -08:00
call Pokedex_LoadPointer
2015-02-11 13:36:02 -08:00
jp [hl]
.asm_40495
call Function41401
ld a, $0
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
; 4049e (10:449e)
Unknown_4049e: ; 4049e
2015-11-29 18:34:59 -08:00
db D_UP | D_DOWN, 4
2015-02-11 13:36:02 -08:00
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
Function404b0: ; 404b0
call Function40f84
call Function40fa8
ret
; 404b7
Function404b7: ; 404b7
call Function41086
callba AnimateDexSearchSlowpoke
2015-02-11 13:36:02 -08:00
ld a, [wc7d7]
and a
jr nz, .asm_404dc
2015-11-29 18:34:59 -08:00
call Pokedex_ChangeMode
2015-02-11 13:36:02 -08:00
call Function41107
xor a
ld [hBGMapMode], a
call Function408f0
call Function4134f
call Function40fa8
call WaitBGMap
ret
.asm_404dc
2015-11-29 18:34:59 -08:00
ld [wDexListingEnd], a
ld a, [wDexListingPage]
2015-02-11 13:36:02 -08:00
ld [wc7e0], a
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
2015-02-11 13:36:02 -08:00
ld [wc7e1], a
2015-11-29 18:34:59 -08:00
ld a, [wLastDexEntry]
2015-02-11 13:36:02 -08:00
ld [wcf65], a
xor a
2015-11-29 18:34:59 -08:00
ld [wDexListingPage], a
ld [wDexListingCursor], a
2015-02-11 13:36:02 -08:00
call Function41401
ld a, $9
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
; 40501
Function40501: ; 40501
call Function41401
ld a, $0
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ret
; 4050a
Function4050a: ; 4050a (10:450a)
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
xor a
hlcoord 0, 0, AttrMap
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
callba DrawPokedexSearchResultsWindow
2015-02-11 13:36:02 -08:00
call Function409cf
ld a, $4
ld [wc7d3], a
call Function40b0f
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode3
call Pokedex_ResetBGMapMode
2015-02-11 13:36:02 -08:00
call Function40962
ld a, $5
ld [hSCX], a
2015-02-11 13:36:02 -08:00
ld a, $4a
ld [hWX], a
2015-02-11 13:36:02 -08:00
xor a
ld [hWY], a
2015-02-11 13:36:02 -08:00
call WaitBGMap
2015-11-29 18:34:59 -08:00
call Pokedex_ResetBGMapMode
callba DrawPokedexSearchResultsWindow
2015-02-11 13:36:02 -08:00
call Function409cf
call Function41281
ld a, $ff
ld [CurPartySpecies], a
ld a, $4
call Function41423
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
Function40562: ; 40562 (10:4562)
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and B_BUTTON
jr nz, .asm_40595
ld a, [hl]
and A_BUTTON
jr nz, .asm_40583
call Function406c5
ret nc
call Function41281
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call Function40b0f
2015-11-29 18:34:59 -08:00
call Pokedex_SetBGMapMode3
call Pokedex_ResetBGMapMode
2015-02-11 13:36:02 -08:00
ret
.asm_40583
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
call Pokedex_CheckSeen
2015-02-11 13:36:02 -08:00
ret z
ld a, $2
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
ld a, $9
ld [wcf64], a
ret
.asm_40595
ld a, [wc7e0]
2015-11-29 18:34:59 -08:00
ld [wDexListingPage], a
2015-02-11 13:36:02 -08:00
ld a, [wc7e1]
2015-11-29 18:34:59 -08:00
ld [wDexListingCursor], a
2015-02-11 13:36:02 -08:00
ld a, [wcf65]
2015-11-29 18:34:59 -08:00
ld [wLastDexEntry], a
2015-02-11 13:36:02 -08:00
call Function41401
call ClearSprites
2015-11-29 18:34:59 -08:00
call Pokedex_ChangeMode
2015-02-11 13:36:02 -08:00
ld a, $5
2015-10-24 16:49:19 -07:00
ld [wJumptableIndex], a
2015-02-11 13:36:02 -08:00
xor a
ld [hSCX], a
2015-02-11 13:36:02 -08:00
ld a, $a7
ld [hWX], a
2015-02-11 13:36:02 -08:00
ret
2015-11-29 18:34:59 -08:00
Pokedex_UnownMode: ; 405bd (10:45bd)
call Pokedex_LoadUnownFont
2015-02-11 13:36:02 -08:00
call Function409f1
xor a
ld [wc7dd], a
call Function41a58
call Function40658
2015-11-29 18:34:59 -08:00
callba PrintUnownWord
2015-02-11 13:36:02 -08:00
call WaitBGMap
ld a, $16
call Function41423
2015-11-29 18:34:59 -08:00
call Pokedex_IncrementDexPointer
2015-02-11 13:36:02 -08:00
ret
Function405df: ; 405df (10:45df)
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and A_BUTTON | B_BUTTON
2015-11-29 18:34:59 -08:00
jr nz, .a_b
2015-02-11 13:36:02 -08:00
call Function40610
ret
2015-11-29 18:34:59 -08:00
.a_b
2015-02-11 13:36:02 -08:00
call Function41401
ld a, $7
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
2015-02-11 13:36:02 -08:00
callba Function1ddf26
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
ld de, VTiles2 tile $31
2015-02-11 13:36:02 -08:00
lb bc, BANK(PokedexLZ), $3a
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
Function40610: ; 40610 (10:4610)
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
ld a, [wc7de]
ld e, a
ld hl, wc7dd
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
ld hl, wc7dd
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
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
pop af
call Function40654
call Function41a58
call Function40658
2015-11-29 18:34:59 -08:00
callba PrintUnownWord
2015-02-11 13:36:02 -08:00
ld a, $1
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
call DelayFrame
call DelayFrame
ret
Function40654: ; 40654 (10:4654)
ld c, $7f
jr asm_4065d
Function40658: ; 40658 (10:4658)
ld a, [wc7dd]
ld c, $5a
asm_4065d: ; 4065d (10:465d)
ld e, a
ld d, 0
ld hl, Unknown_40a3e + 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
2015-11-29 18:34:59 -08:00
Pokedex_NextOrPreviousDexEntry: ; 4066c (10:466c)
ld a, [wDexListingCursor]
ld [wBackupDexListingCursor], a
ld a, [wDexListingPage]
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
ld a, [wc7d3]
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
call Function406ea
2015-11-29 18:34:59 -08:00
jr nc, .nope
call Pokedex_GetMonAtCursorPosition
call Pokedex_CheckSeen
jr nz, .yep
2015-02-11 13:36:02 -08:00
jr .up
.down
ld a, [wc7d3]
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
call Function406fe
2015-11-29 18:34:59 -08:00
jr nc, .nope
call Pokedex_GetMonAtCursorPosition
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]
ld [wDexListingPage], a
2015-02-11 13:36:02 -08:00
and a
ret
Function406c5: ; 406c5 (10:46c5)
ld a, [wc7d3]
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
jr nz, Function406ea
ld a, [hl]
and D_DOWN
jr nz, Function406fe
ld a, d
cp e
jr nc, asm_4073d
ld a, [hl]
and $20
jr nz, asm_40716
ld a, [hl]
and $10
jr nz, asm_40728
jr asm_4073d
Function406ea: ; 406ea (10:46ea)
2015-11-29 18:34:59 -08:00
ld hl, wDexListingCursor
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
jr z, .asm_406f4
dec [hl]
jr asm_4073f
.asm_406f4
2015-11-29 18:34:59 -08:00
ld hl, wDexListingPage
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
jr z, asm_4073d
dec [hl]
jr asm_4073f
Function406fe: ; 406fe (10:46fe)
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
jr nc, asm_4073d
cp d
jr nc, .asm_4070c
inc [hl]
jr asm_4073f
.asm_4070c
2015-11-29 18:34:59 -08:00
ld hl, wDexListingPage
2015-02-11 13:36:02 -08:00
add [hl]
cp e
jr nc, asm_4073d
inc [hl]
jr asm_4073f
asm_40716: ; 40716 (10:4716)
2015-11-29 18:34:59 -08:00
ld hl, wDexListingPage
2015-02-11 13:36:02 -08:00
ld a, [hl]
and a
jr z, asm_4073d
cp d
jr nc, .asm_40724
xor a
ld [hl], a
jr asm_4073f
.asm_40724
sub d
ld [hl], a
jr asm_4073f
asm_40728: ; 40728 (10:4728)
2015-11-29 18:34:59 -08:00
ld hl, wDexListingPage
2015-02-11 13:36:02 -08:00
ld a, d
add a
add [hl]
jr c, .asm_40733
cp e
jr c, .asm_40738
.asm_40733
ld a, e
sub d
ld [hl], a
jr asm_4073f
.asm_40738
ld a, [hl]
add d
ld [hl], a
jr asm_4073f
asm_4073d: ; 4073d (10:473d)
and a
ret
asm_4073f: ; 4073f (10:473f)
scf
ret
Function40741: ; 40741
push de
ld de, $0014
.asm_40745
ld [hl], a
add hl, de
dec b
jr nz, .asm_40745
pop de
ret
; 4074c
Function4074c: ; 4074c (10:474c)
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
ld bc, $607
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
2015-02-11 13:36:02 -08:00
ld hl, PokedexSeen ; wdeb9 (aliases: EndPokedexSeen)
ld b, EndPokedexSeen - PokedexSeen
call CountSetBits
ld de, wd265
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
2015-02-11 13:36:02 -08:00
ld hl, PokedexCaught
ld b, EndPokedexCaught - PokedexCaught
call CountSetBits
ld de, wd265
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
ld b, $7
ld a, $5a
call Function40741
hlcoord 8, 10
ld b, $6
ld a, $5a
call Function40741
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
; 407e1 (10:47e1)
String_SEEN: ; 407e1
2015-02-11 13:36:02 -08:00
db "SEEN", $ff
String_OWN: ; 407e6
2015-02-11 13:36:02 -08:00
db "OWN", $ff
String_SELECT_OPTION: ; 407ea
2015-02-11 13:36:02 -08:00
db $3b, $48, $49, $4a, $44, $45, $46, $47 ; SELECT > OPTION
String_START_SEARCH: ; 407f2
2015-02-11 13:36:02 -08:00
db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, $ff ; START > SEARCH
; 407fd
Function407fd: ; 407fd
2015-11-29 18:34:59 -08:00
call Pokedex_FillBackgroundColor2
hlcoord 0, 0
2015-02-11 13:36:02 -08:00
ld bc, $0f12
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
ld a, $7f
ld b, $f
call Function40741
ld [hl], $39
hlcoord 1, 10
ld bc, $0013
ld a, $61
call ByteFill
hlcoord 1, 17
ld bc, $0012
ld a, $7f
call ByteFill
hlcoord 9, 7
ld de, Unknown_40852
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 9, 9
ld de, Unknown_4085c
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 0, 17
ld de, Unknown_40867
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
call Pokedex_PlaceFrontpicTopLeftCorner
2015-02-11 13:36:02 -08:00
ret
; 4084f
Unknown_4084f: ; 4084f
db $5c, $5d, $ff ; No.
Unknown_40852: ; 40852
db "HT ?", $5e, "??", $5f, $ff ; HT ?'??"
Unknown_4085c: ; 4085c
db "WT ???lb", $ff ; WT ???lb
Unknown_40867: ; 40867
db $3b, " PAGE AREA CRY PRNT", $ff
; 4087c
Function4087c: ; 4087c (10:487c)
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
ld de, Unknown_408b2
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 3, 4
ld de, String_408bd
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
ld de, String_408e5
call PlaceString
ret
; 408b2 (10:48b2)
Unknown_408b2: ; 408b2
db $3b, " OPTION ", $3c, $ff
; 408bd
String_408bd: ; 408bd
db "NEW #DEX MODE"
next "OLD #DEX MODE"
next "A to Z MODE"
db "@"
2015-02-11 13:36:02 -08:00
; 408e5
String_408e5: ; 408e5
db "UNOWN MODE@"
; 408f0
Function408f0: ; 408f0 (10:48f0)
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
ld de, Unknown_4092a
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 8, 4
ld de, Unknown_40935
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 8, 6
ld de, Unknown_40935
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceString
2015-02-11 13:36:02 -08:00
hlcoord 3, 4
ld de, String_40940
call PlaceString
hlcoord 3, 13
ld de, String_4094c
call PlaceString
ret
; 4092a (10:492a)
Unknown_4092a: ; 4092a
db $3b, " SEARCH ", $3c, $ff
; 40925
Unknown_40935: ; 40935
db $3d, " ", $3e, $ff
; 40940
String_40940: ; 40940
db "TYPE1"
next "TYPE2"
db "@"
; 4094c
String_4094c: ; 4094c
db "BEGIN SEARCH!!"
next "CANCEL"
db "@"
; 40962
Function40962: ; 40962 (10:4962)
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
ld de, String_409ae
call PlaceString
ld de, wc7d7
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
ld b, $7
ld a, $5a
call Function40741
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
; 409ae (10:49ae)
String_409ae: ; 409ae
db "SEARCH RESULTS"
next " TYPE"
next " FOUND!"
db "@"
; 409cf
Function409cf: ; 409cf (10:49cf)
ld a, [wc7d5]
hlcoord 0, 14
call Function40fcd
ld a, [wc7d5]
ld b, a
ld a, [wc7d6]
and a
jr z, .asm_409f0
cp b
jr z, .asm_409f0
hlcoord 2, 15
call Function40fcd
hlcoord 1, 15
ld [hl], $f3
.asm_409f0
ret
Function409f1: ; 409f1 (10:49f1)
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
ld c, 26
2015-11-29 18:34:59 -08:00
.loop
2015-02-11 13:36:02 -08:00
ld hl, UnownDex
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
ld hl, Unknown_40a3e
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
ld [wc7de], a
ret
; 40a3e (10:4a3e)
Unknown_40a3e: ; 40a3e
2015-11-29 18:34:59 -08:00
; letter, cursor
2015-02-11 13:36:02 -08:00
dwcoord 4,11, 3,11
dwcoord 4,10, 3,10
dwcoord 4, 9, 3, 9
dwcoord 4, 8, 3, 8
dwcoord 4, 7, 3, 7
dwcoord 4, 6, 3, 6
dwcoord 4, 5, 3, 5
dwcoord 4, 4, 3, 4
dwcoord 4, 3, 3, 2
dwcoord 5, 3, 5, 2
dwcoord 6, 3, 6, 2
dwcoord 7, 3, 7, 2
dwcoord 8, 3, 8, 2
dwcoord 9, 3, 9, 2
dwcoord 10, 3, 10, 2
dwcoord 11, 3, 11, 2
dwcoord 12, 3, 12, 2
dwcoord 13, 3, 13, 2
dwcoord 14, 3, 15, 2
dwcoord 14, 4, 15, 4
dwcoord 14, 5, 15, 5
dwcoord 14, 6, 15, 6
dwcoord 14, 7, 15, 7
dwcoord 14, 8, 15, 8
dwcoord 14, 9, 15, 9
dwcoord 14,10, 15,10
; 40aa6
2015-11-29 18:34:59 -08:00
Pokedex_FillBackgroundColor2: ; 40aa6
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
; 40ab2
2015-11-29 18:34:59 -08:00
Pokedex_PlaceFrontpicTopLeftCorner: ; 40ab2
2015-02-11 13:36:02 -08:00
hlcoord 1, 1
2015-11-29 18:34:59 -08:00
Pokedex_PlaceFrontpicAtHL: ; 40ab5
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
; 40acd
2015-11-29 18:34:59 -08:00
Pokedex_PlaceString: ; 40acd
.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
; 40ad5
2015-11-29 18:34:59 -08:00
Pokedex_PlaceBorder: ; 40ad5
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
; 40b06
2015-11-29 18:34:59 -08:00
.FillRow: ; 40b06
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
; 40b0f
Function40b0f: ; 40b0f (10:4b0f)
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
.resume
; Clear (2 * [wc7d3] + 1) by 11 box starting at 0,1
2015-02-11 13:36:02 -08:00
hlcoord 0, 1
ld a, [wc7d3]
add a
inc a
ld b, a
2015-11-29 18:34:59 -08:00
ld a, " "
call Pokedex_FillBox
; Load de with wPokedexDataStart + [wDexListingPage]
ld a, [wDexListingPage]
2015-02-11 13:36:02 -08:00
ld e, a
ld d, $0
2015-11-29 18:34:59 -08:00
ld hl, wPokedexDataStart
2015-02-11 13:36:02 -08:00
add hl, de
ld e, l
ld d, h
hlcoord 0, 2
ld a, [wc7d3]
2015-11-29 18:34:59 -08:00
.loop
2015-02-11 13:36:02 -08:00
push af
ld a, [de]
ld [wd265], a
push de
push hl
call Function40b55
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
2015-02-11 13:36:02 -08:00
call Function4143b
ret
Function40b55: ; 40b55 (10:4b55)
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
2015-11-29 18:34:59 -08:00
Pokedex_PrintNumberIfOldMode: ; 40b6a (10:4b6a)
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, wd265
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
2015-02-11 13:36:02 -08:00
call PrintNum
pop hl
ret
2015-11-29 18:34:59 -08:00
Pokedex_PlaceCaughtSymbolIfCaught: ; 40b82 (10:4b82)
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
2015-11-29 18:34:59 -08:00
Pokedex_PlaceDefaultStringIfNotSeen: ; 40b8d (10:4b8d)
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
; 40b9a (10:4b9a)
2015-11-29 18:34:59 -08:00
.NameNotSeen: ; 40b9a
2015-02-11 13:36:02 -08:00
db "-----@"
; 40ba0
2015-11-29 18:34:59 -08:00
Pokedex_DrawFootprint: ; 40ba0
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
; 40bb1
2015-11-29 18:34:59 -08:00
Pokedex_GetMonAtCursorPosition: ; 40bb1
ld a, [wDexListingCursor]
ld hl, wDexListingPage
2015-02-11 13:36:02 -08:00
add [hl]
ld e, a
ld d, $0
2015-11-29 18:34:59 -08:00
ld hl, wPokedexDataStart
2015-02-11 13:36:02 -08:00
add hl, de
ld a, [hl]
ld [wd265], a
ret
; 40bc4
2015-11-29 18:34:59 -08:00
Pokedex_CheckCaught: ; 40bc4 (10:4bc4)
2015-02-11 13:36:02 -08:00
push de
push hl
ld a, [wd265]
dec a
call CheckCaughtMon
pop hl
pop de
ret
2015-11-29 18:34:59 -08:00
Pokedex_CheckSeen: ; 40bd0
2015-02-11 13:36:02 -08:00
push de
push hl
ld a, [wd265]
dec a
call CheckSeenMon
pop hl
pop de
ret
; 40bdc
2015-11-29 18:34:59 -08:00
Pokedex_ChangeMode: ; 40bdc
ld hl, wPokedexDataStart
ld bc, wPokedexMetadata - wPokedexDataStart
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
2015-02-11 13:36:02 -08:00
jp [hl]
; 40bf0
2015-11-29 18:34:59 -08:00
.Jumptable: ; 40bf0 (10:4bf0)
dw .NewMode
dw .OldMode
dw Pokedex_ABCMode
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
.NewMode: ; 40bf6 (10:4bf6)
2015-02-11 13:36:02 -08:00
ld de, NewPokedexOrder
2015-11-29 18:34:59 -08:00
ld hl, wPokedexDataStart
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
2015-11-29 18:34:59 -08:00
.OldMode: ; 40c08 (10:4c08)
ld hl, wPokedexDataStart
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
2015-11-29 18:34:59 -08:00
.FindLastSeen: ; 40c18 (10:4c18)
ld hl, wPokedexDataStart + 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 [wd265], 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
2015-11-29 18:34:59 -08:00
Pokedex_ABCMode: ; 40c30
2015-02-11 13:36:02 -08:00
xor a
2015-11-29 18:34:59 -08:00
ld [wDexListingEnd], a
ld hl, wPokedexDataStart
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 [wd265], a
2015-11-29 18:34:59 -08:00
call Pokedex_CheckSeen
jr z, .skipabc
2015-02-11 13:36:02 -08:00
ld a, [wd265]
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
; 40c65
AlphabeticalPokedexOrder: ; 0x40c65
INCLUDE "data/pokedex/order_alpha.asm"
NewPokedexOrder: ; 0x40d60
INCLUDE "data/pokedex/order_new.asm"
Function40e5b: ; 40e5b
xor a
ld [hBGMapMode], a
hlcoord 0, 12
2015-11-29 18:34:59 -08:00
lb bc, 4, SCREEN_WIDTH - 2
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
ld a, [wc7d8]
ld hl, Unknown_40e7d
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
ld [hBGMapMode], a
ret
; 40e7d
Unknown_40e7d: ; 40e7d
2015-11-29 18:34:59 -08:00
dw .NewMode
dw .OldMode
dw .ABCMode
dw .UnownMode
2015-02-11 13:36:02 -08:00
; 40e85
2015-11-29 18:34:59 -08:00
.NewMode: ; 40e85
db "<PK><MN> are listed by"
next "evolution type.@"
2015-02-11 13:36:02 -08:00
; 40ea6
2015-11-29 18:34:59 -08:00
.OldMode: ; 40ea6
db "<PK><MN> are listed by"
next "official type.@"
2015-02-11 13:36:02 -08:00
; 40ec6
2015-11-29 18:34:59 -08:00
.ABCMode: ; 40ec6
db "<PK><MN> are listed"
next "alphabetically.@"
2015-02-11 13:36:02 -08:00
; 40ee4
2015-11-29 18:34:59 -08:00
.UnownMode: ; 40ee4
db "UNOWN are listed"
next "in catching order.@"
2015-02-11 13:36:02 -08:00
; 40f08
Function40f08: ; 40f08 (10:4f08)
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
hlcoord 0, 12
2015-11-29 18:34:59 -08:00
lb bc, 4, SCREEN_WIDTH - 2
call Pokedex_PlaceBorder
ld de, String_ChangingModesPleaseWait
2015-02-11 13:36:02 -08:00
hlcoord 1, 14
call PlaceString
ld a, $1
ld [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
; 40f32 (10:4f32)
2015-11-29 18:34:59 -08:00
String_ChangingModesPleaseWait: ; 40f32
db "Changing modes."
next "Please wait.@"
2015-02-11 13:36:02 -08:00
; 40f4f
Function40f4f: ; 40f4f (10:4f4f)
ld a, [wc7d8]
cp $2
jr nc, .asm_40f63
2015-10-16 10:35:43 -07:00
ld hl, hJoyLast
2015-02-11 13:36:02 -08:00
ld a, [hl]
and $20
jr nz, .asm_40f65
ld a, [hl]
and $10
jr nz, Function40f84
.asm_40f63
and a
ret
.asm_40f65
ld a, [wc7d8]
and a
jr nz, .asm_40f76
ld hl, wc7d5
ld a, [hl]
cp $1
jr z, .asm_40f80
dec [hl]
jr .asm_40f82
.asm_40f76
ld hl, wc7d6
ld a, [hl]
and a
jr z, .asm_40f80
dec [hl]
jr .asm_40f82
.asm_40f80
ld [hl], $11
.asm_40f82
scf
ret
; 40f84
Function40f84: ; 40f84
ld a, [wc7d8]
and a
jr nz, .asm_40f99
ld hl, wc7d5
ld a, [hl]
cp $11
jr nc, .asm_40f95
inc [hl]
jr .asm_40fa6
.asm_40f95
ld [hl], $1
jr .asm_40fa6
.asm_40f99
ld hl, wc7d6
ld a, [hl]
cp $11
jr nc, .asm_40fa4
inc [hl]
jr .asm_40fa6
.asm_40fa4
ld [hl], $0
.asm_40fa6
scf
ret
Function40fa8: ; 40fa8 (10:4fa8)
xor a
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
hlcoord 9, 3
ld bc, $408
ld a, $7f
2015-11-29 18:34:59 -08:00
call Pokedex_FillBox
2015-02-11 13:36:02 -08:00
ld a, [wc7d5]
hlcoord 9, 4
call Function40fcd
ld a, [wc7d6]
hlcoord 9, 6
call Function40fcd
ld a, $1
ld [hBGMapMode], a
2015-02-11 13:36:02 -08:00
ret
Function40fcd: ; 40fcd (10:4fcd)
push hl
ld e, a
ld d, 0
ld hl, Strings_40fe4
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
; 40fe4 (10:4fe4)
Strings_40fe4: ; 40fe4
db " ---- @"
db " NORMAL @"
db " FIRE @"
db " WATER @"
db " GRASS @"
db "ELECTRIC@"
db " ICE @"
db "FIGHTING@"
db " POISON @"
db " GROUND @"
db " FLYING @"
db "PSYCHIC @"
db " BUG @"
db " ROCK @"
db " GHOST @"
db " DRAGON @"
db " DARK @"
db " STEEL @"
; 41086
Function41086: ; 41086
ld a, [wc7d6]
and a
call nz, Function41095
ld a, [wc7d5]
and a
call nz, Function41095
ret
; 41095
Function41095: ; 41095
dec a
ld e, a
ld d, 0
ld hl, Unknown_410f6
add hl, de
ld a, [hl]
ld [wc7df], a
2015-11-29 18:34:59 -08:00
ld hl, wPokedexDataStart
ld de, wPokedexDataStart
2015-02-11 13:36:02 -08:00
ld c, NUM_POKEMON
xor a
ld [wc7d7], a
.asm_410ad
push bc
ld a, [hl]
and a
jr z, .asm_410e0
ld [wd265], a
ld [CurSpecies], a
2015-11-29 18:34:59 -08:00
call Pokedex_CheckCaught
2015-02-11 13:36:02 -08:00
jr z, .asm_410e0
push hl
push de
call GetBaseData
pop de
pop hl
ld a, [wc7df]
ld b, a
ld a, [BaseType1]
cp b
jr z, .asm_410d4
ld a, [BaseType2]
cp b
jr nz, .asm_410e0
.asm_410d4
ld a, [wd265]
ld [de], a
inc de
ld a, [wc7d7]
inc a
ld [wc7d7], a
.asm_410e0
inc hl
pop bc
dec c
jr nz, .asm_410ad
ld l, e
ld h, d
ld a, [wc7d7]
ld c, 0
.asm_410ec
cp NUM_POKEMON
jr z, .asm_410f5
ld [hl], c
inc hl
inc a
jr .asm_410ec
.asm_410f5
ret
; 410f6
Unknown_410f6: ; 410f6
db NORMAL
db FIRE
db WATER
db GRASS
db ELECTRIC
db ICE
db FIGHTING
db POISON
db GROUND
db FLYING
db PSYCHIC
db BUG
db ROCK
db GHOST
db DRAGON
db DARK
db STEEL
; 41107
Function41107: ; 41107
xor a
ld [hBGMapMode], a
hlcoord 0, 12
ld bc, $0412
2015-11-29 18:34:59 -08:00
call Pokedex_PlaceBorder
2015-02-11 13:36:02 -08:00
ld de, String_41126
hlcoord 1, 14
call PlaceString
ld a, $1
ld [hBGMapMode], a
ld c, $80
call DelayFrames
ret
; 41126
String_41126: ; 41126
db "The specified type"
next "was not found.@"
2015-02-11 13:36:02 -08:00
; 41148
Function41148: ; 41148 (10:5148)
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
2015-02-11 13:36:02 -08:00
cp $1
jp z, Function41157
call Function41229
call Function4130e
ret
Function41157: ; 41157 (10:5157)
ld hl, Unknown_41167
2015-11-29 18:34:59 -08:00
ld a, [wDexListingCursor]
2015-02-11 13:36:02 -08:00
or a
jr nz, .asm_41163
ld hl, Unknown_411c8
.asm_41163
call Function412f1
ret
; 41167 (10:5167)
Unknown_41167: ; 41167
; OAM
db $18, $47, $30, $07
db $10, $47, $31, $07
db $10, $4f, $32, $07
db $10, $57, $32, $07
db $10, $5f, $32, $07
db $10, $67, $33, $07
db $10, $7e, $33, $27
db $10, $86, $32, $27
db $10, $8e, $32, $27
db $10, $96, $32, $27
db $10, $9e, $31, $27
db $18, $9e, $30, $27
db $20, $47, $30, $47
db $28, $47, $31, $47
db $28, $4f, $32, $47
db $28, $57, $32, $47
db $28, $5f, $32, $47
db $28, $67, $33, $47
db $28, $7e, $33, $67
db $28, $86, $32, $67
db $28, $8e, $32, $67
db $28, $96, $32, $67
db $28, $9e, $31, $67
db $20, $9e, $30, $67
db $ff
; 411c8
Unknown_411c8: ; 411c8
; OAM
db $18, $47, $30, $07
db $10, $47, $34, $07
db $10, $4f, $35, $07
db $10, $57, $35, $07
db $10, $5f, $35, $07
db $10, $67, $36, $07
db $10, $7e, $36, $27
db $10, $86, $35, $27
db $10, $8e, $35, $27
db $10, $96, $35, $27
db $10, $9e, $34, $27
db $18, $9e, $30, $27
db $20, $47, $30, $47
db $28, $47, $31, $47
db $28, $4f, $32, $47
db $28, $57, $32, $47
db $28, $5f, $32, $47
db $28, $67, $33, $47
db $28, $7e, $33, $67
db $28, $86, $32, $67
db $28, $8e, $32, $67
db $28, $96, $32, $67
db $28, $9e, $31, $67
db $20, $9e, $30, $67
db $ff
; 41229
Function41229: ; 41229 (10:5229)
ld hl, Unknown_41230
call Function412f1
ret
; 41230 (10:5230)
Unknown_41230: ; 41230
; OAM
db $1b, $47, $30, $07
db $13, $47, $31, $07
db $13, $4f, $32, $07
db $13, $57, $32, $07
db $13, $5f, $33, $07
db $13, $80, $33, $27
db $13, $88, $32, $27
db $13, $90, $32, $27
db $13, $98, $31, $27
db $1b, $98, $30, $27
db $23, $47, $30, $47
db $2b, $47, $31, $47
db $2b, $4f, $32, $47
db $2b, $57, $32, $47
db $2b, $5f, $33, $47
db $2b, $80, $33, $67
db $2b, $88, $32, $67
db $2b, $90, $32, $67
db $2b, $98, $31, $67
db $23, $98, $30, $67
db $ff
; 41281
Function41281: ; 41281 (10:5281)
2015-11-29 18:34:59 -08:00
ld a, [wCurrentDexMode]
2015-02-11 13:36:02 -08:00
cp $1
jp z, Function41157
ld hl, Unknown_41290
call Function412f1
ret
; 41290 (10:5290)
Unknown_41290: ; 41290
; OAM
db $1b, $47, $30, $07
db $13, $47, $31, $07
db $13, $4f, $32, $07
db $13, $57, $32, $07
db $13, $5f, $32, $07
db $13, $67, $33, $07
db $13, $7e, $33, $27
db $13, $86, $32, $27
db $13, $8e, $32, $27
db $13, $96, $32, $27
db $13, $9e, $31, $27
db $1b, $9e, $30, $27
db $23, $47, $30, $47
db $2b, $47, $31, $47
db $2b, $4f, $32, $47
db $2b, $57, $32, $47
db $2b, $5f, $32, $47
db $2b, $67, $33, $47
db $2b, $7e, $33, $67
db $2b, $86, $32, $67
db $2b, $8e, $32, $67
db $2b, $96, $32, $67
db $2b, $9e, $31, $67
db $23, $9e, $30, $67
db $ff
; 412f1
Function412f1: ; 412f1 (10:52f1)
ld de, Sprites
.asm_412f4
ld a, [hl]
cp $ff
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
add [hl]
inc hl
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
jr .asm_412f4
Function4130e: ; 4130e (10:530e)
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]
ld hl, wDexListingPage
2015-02-11 13:36:02 -08:00
add [hl]
cp e
jr z, .asm_4133f
ld hl, $0
ld bc, $79
call AddNTimes
ld e, l
ld d, h
ld b, $0
ld a, d
or e
jr z, .asm_41341
2015-11-29 18:34:59 -08:00
ld a, [wDexListingEnd]
2015-02-11 13:36:02 -08:00
ld c, a
.asm_41333
ld a, e
sub c
ld e, a
ld a, d
sbc $0
ld d, a
jr c, .asm_41341
inc b
jr .asm_41333
.asm_4133f
ld b, $79
.asm_41341
ld a, $14
add b
pop hl
ld [hli], a
ld a, $a1
ld [hli], a
ld a, $f
ld [hli], a
ld [hl], $0
ret
Function4134f: ; 4134f (10:534f)
xor a
ld [wc7d8], a
ld [wc7d9], a
ld [wc7da], a
ret
Function4135a: ; 4135a (10:535a)
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
2015-11-29 18:34:59 -08:00
call Pokedex_BlinkInfoScreenCursor
2015-02-11 13:36:02 -08:00
ld hl, hJoyPressed ; $ffa7
ld a, [hl]
and D_LEFT | D_UP
and b
2015-11-29 18:34:59 -08:00
jr nz, .MoveCursorLeft
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_RIGHT | D_DOWN
and b
2015-11-29 18:34:59 -08:00
jr nz, .MoveCursorRight
2015-02-11 13:36:02 -08:00
ld a, [hl]
and SELECT
and b
2015-11-29 18:34:59 -08:00
jr nz, .Select
call Pokedex_CursorFrameDelay
jr c, .NoAction
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
2015-11-29 18:34:59 -08:00
jr nz, .MoveCursorLeft
2015-02-11 13:36:02 -08:00
ld a, [hl]
and D_RIGHT | D_DOWN
and b
2015-11-29 18:34:59 -08:00
jr nz, .MoveCursorRight
jr .NoAction
.MoveCursorLeft
2015-02-11 13:36:02 -08:00
ld a, [wc7d8]
and a
2015-11-29 18:34:59 -08:00
jr z, .NoAction
call Pokedex_GetCursorPosition
ld [hl], " "
2015-02-11 13:36:02 -08:00
ld hl, wc7d8
dec [hl]
2015-11-29 18:34:59 -08:00
jr .UpdateCursorPosition
.MoveCursorRight
2015-02-11 13:36:02 -08:00
ld a, [wc7d8]
cp c
2015-11-29 18:34:59 -08:00
jr nc, .NoAction
call Pokedex_GetCursorPosition
ld [hl], " "
2015-02-11 13:36:02 -08:00
ld hl, wc7d8
inc [hl]
2015-11-29 18:34:59 -08:00
.UpdateCursorPosition
call Pokedex_GetCursorPosition
ld [hl], "â–¶"
2015-02-11 13:36:02 -08:00
ld a, $c
ld [wc7d9], a
xor a
ld [wc7da], a
scf
ret
2015-11-29 18:34:59 -08:00
.NoAction
2015-02-11 13:36:02 -08:00
and a
ret
2015-11-29 18:34:59 -08:00
.Select
call Pokedex_GetCursorPosition
ld [hl], " "
2015-02-11 13:36:02 -08:00
ld a, [wc7d8]
cp c
2015-11-29 18:34:59 -08:00
jr c, .Update
2015-02-11 13:36:02 -08:00
ld a, $ff
2015-11-29 18:34:59 -08:00
.Update
2015-02-11 13:36:02 -08:00
inc a
ld [wc7d8], a
2015-11-29 18:34:59 -08:00
jr .UpdateCursorPosition
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
Pokedex_GetCursorPosition: ; 413d4 (10:53d4)
2015-02-11 13:36:02 -08:00
ld a, [wc7d8]
add a
ld l, a
ld h, $0
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ret
2015-11-29 18:34:59 -08:00
Pokedex_BlinkInfoScreenCursor: ; 413e0 (10:53e0)
2015-02-11 13:36:02 -08:00
ld hl, wc7da
ld a, [hl]
inc [hl]
and $8
2015-11-29 18:34:59 -08:00
jr z, .blink_on
call Pokedex_GetCursorPosition
ld [hl], " "
2015-02-11 13:36:02 -08:00
ret
2015-11-29 18:34:59 -08:00
.blink_on
call Pokedex_GetCursorPosition
ld [hl], "â–¶"
2015-02-11 13:36:02 -08:00
ret
2015-11-29 18:34:59 -08:00
Pokedex_CursorFrameDelay: ; 413f5 (10:53f5)
2015-02-11 13:36:02 -08:00
ld hl, wc7d9
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
2015-11-29 18:34:59 -08:00
Pokedex_FillBox: ; 413fe (10:53fe)
jp FillBoxWithByte
2015-02-11 13:36:02 -08:00
Function41401: ; 41401 (10:5401)
ld a, [rSVBK]
2015-02-11 13:36:02 -08:00
push af
ld a, $5
ld [rSVBK], a
2015-11-20 12:15:32 -08:00
ld hl, UnknBGPals
2015-02-11 13:36:02 -08:00
ld bc, $40
xor a
call ByteFill
pop af
ld [rSVBK], a
2015-02-11 13:36:02 -08:00
Function41415: ; 41415
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
Function41423: ; 41423
ld b, a
call GetSGBLayout
Function41427: ; 41427
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
; 41432
2015-11-29 18:34:59 -08:00
Pokedex_LoadPointer: ; 41432
2015-02-11 13:36:02 -08:00
ld e, a
ld d, 0
2015-07-20 19:18:18 -07:00
rept 2
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
ret
; 4143b
Function4143b: ; 4143b
2015-11-29 18:34:59 -08:00
call Pokedex_GetMonAtCursorPosition
call Pokedex_CheckSeen
jr z, .QuestionMark
ld a, [wFirstUnownSeen]
2015-02-11 13:36:02 -08:00
ld [UnownLetter], a
ld a, [wd265]
ld [CurPartySpecies], a
call GetBaseData
ld de, VTiles2
predef GetFrontpic
ret
2015-11-29 18:34:59 -08:00
.QuestionMark
ld a, BANK(sScratch)
2015-02-11 13:36:02 -08:00
call GetSRAMBank
2015-11-29 18:34:59 -08:00
callba LoadQuestionMarkPic
2015-02-11 13:36:02 -08:00
ld hl, VTiles2
ld de, sScratch
ld c, 7 * 7
2015-02-11 13:36:02 -08:00
ld a, [hROMBank]
ld b, a
call Get2bpp
call CloseSRAM
ret
; 41478
2015-11-29 18:34:59 -08:00
Pokedex_LoadCurrentFootprint: ; 41478 (10:5478)
call Pokedex_GetMonAtCursorPosition
2015-02-11 13:36:02 -08:00
2015-11-29 18:34:59 -08:00
Pokedex_LoadAnyFootprint: ; 4147b
2015-02-11 13:36:02 -08:00
ld a, [wd265]
dec a
2015-11-29 18:34:59 -08:00
and ($ff ^ $07) ; $f8 ; $1f << 3
2015-02-11 13:36:02 -08:00
srl a
srl a
srl a
ld e, 0
ld d, a
ld a, [wd265]
dec a
and 7
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
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
ld hl, VTiles2 tile $64
2015-02-11 13:36:02 -08:00
lb bc, BANK(Footprints), 2
call Request1bpp
ret
; 414b7
2015-11-29 18:34:59 -08:00
Pokedex_LoadGFX: ; 414b7
2015-02-11 13:36:02 -08:00
call DisableLCD
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
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
callba LoadSGBPokedexGFX
jr .LoadPokedexSlowpokeLZ
.LoadPokedexLZ
2015-02-11 13:36:02 -08:00
ld hl, PokedexLZ
ld de, VTiles2 tile $31
2015-02-11 13:36:02 -08:00
call Decompress
2015-11-29 18:34:59 -08:00
.LoadPokedexSlowpokeLZ
2015-02-11 13:36:02 -08:00
ld hl, PokedexSlowpokeLZ
ld de, VTiles0
call Decompress
ld a, 6
call SkipMusic
call EnableLCD
ret
2015-11-29 18:34:59 -08:00
Pokedex_LoadInvertedFont: ; 414fb
2015-11-04 13:14:27 -08:00
call LoadStandardFont
2015-02-11 13:36:02 -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
2015-11-29 18:34:59 -08:00
Pokedex_InvertTiles: ; 41504
.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
; 4150e
PokedexLZ: ; 4150e
2015-11-29 18:34:59 -08:00
INCBIN "gfx/pokedex/pokedex.2bpp.lz"
2015-02-11 13:36:02 -08:00
; 416b0
PokedexSlowpokeLZ: ; 416b0
INCBIN "gfx/pokedex/slowpoke.2bpp.lz"
2015-11-29 18:34:59 -08:00
Pokedex_CheckSGB: ; 41a24
2015-02-11 13:36:02 -08:00
ld a, [hCGB]
or a
ret nz
ld a, [hSGB]
dec a
ret
; 41a2c
2015-11-29 18:34:59 -08:00
Pokedex_LoadUnownFont: ; 41a2c
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
2015-11-29 18:34:59 -08:00
ld bc, 27 tiles
call Pokedex_InvertTiles
2015-08-20 23:00:59 -07:00
ld de, sScratch + $188
ld hl, VTiles2 tile $40
2015-11-29 18:34:59 -08:00
lb bc, BANK(Pokedex_LoadUnownFont), 27
2015-02-11 13:36:02 -08:00
call Request2bpp
call CloseSRAM
ret
; 41a58
Function41a58: ; 41a58 (10:5a58)
ld a, [UnownLetter]
push af
ld a, [wc7dd]
ld e, a
ld d, $0
ld hl, EndPokedexSeen ; wded9 (aliases: UnownDex)
add hl, de
ld a, [hl]
ld [UnownLetter], a
ld a, UNOWN
ld [CurPartySpecies], a
call GetBaseData
ld de, VTiles2 tile $00
2015-02-11 13:36:02 -08:00
predef GetFrontpic
pop af
ld [UnownLetter], a
ret
; 41a7f
2015-11-29 18:34:59 -08:00
_NewPokedexEntry: ; 41a7f
xor a
ld [hBGMapMode], a
callba Function1de247
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, [wd265]
ld [CurPartySpecies], a
call Function407fd
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
callba DisplayDexEntry
call EnableLCD
call WaitBGMap
call GetBaseData
ld de, VTiles2
predef GetFrontpic
ld a, $4
call Function41423
ld a, [CurPartySpecies]
call PlayCry
ret
; 41ad7
2015-11-29 18:34:59 -08:00
Pokedex_SetBGMapMode3: ; 41ad7 (10:5ad7)
ld a, $3
ld [hBGMapMode], a
ld c, 4
call DelayFrames
ret
2015-11-29 18:34:59 -08:00
Pokedex_SetBGMapMode4: ; 41ae1 (10:5ae1)
ld a, $4
ld [hBGMapMode], a
ld c, 4
call DelayFrames
ret
2015-11-29 18:34:59 -08:00
Pokedex_SetBGMapMode_3ifDMG_4ifCGB: ; 41aeb (10:5aeb)
ld a, [hCGB]
and a
2015-11-29 18:34:59 -08:00
jr z, .DMG
call Pokedex_SetBGMapMode4
.DMG
call Pokedex_SetBGMapMode3
ret
2015-11-29 18:34:59 -08:00
Pokedex_ResetBGMapMode: ; 41af7
xor a
ld [hBGMapMode], a
ret
; 41afb