2016-06-12 00:24:04 +00:00
|
|
|
ShowPokedexMenu:
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOut
|
|
|
|
call ClearScreen
|
2015-07-03 19:37:53 +00:00
|
|
|
call UpdateSprites
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wListScrollOffset]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
|
|
|
ld [wListScrollOffset], a
|
|
|
|
ld [wLastMenuItem], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wd11e], a
|
|
|
|
ld [hJoy7], a
|
2014-05-22 22:13:20 +00:00
|
|
|
.setUpGraphics
|
2015-08-12 09:16:56 +00:00
|
|
|
ld b, SET_PAL_GENERIC
|
|
|
|
call RunPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
callab LoadPokedexTilePatterns
|
|
|
|
.doPokemonListMenu
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wTopMenuItemY
|
|
|
|
ld a, 3
|
|
|
|
ld [hli], a ; top menu item Y
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hli], a ; top menu item X
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wMenuWatchMovingOutOfBounds], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
inc hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 6
|
|
|
|
ld [hli], a ; max menu item ID
|
|
|
|
ld [hl], D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
|
2014-05-22 22:13:20 +00:00
|
|
|
call HandlePokedexListMenu
|
2017-12-30 00:54:27 +00:00
|
|
|
jr c, .goToSideMenu ; if the player chose a pokemon from the list
|
2014-05-22 22:13:20 +00:00
|
|
|
.exitPokedex
|
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wMenuWatchMovingOutOfBounds], a
|
|
|
|
ld [wCurrentMenuItem], a
|
|
|
|
ld [wLastMenuItem], a
|
|
|
|
ld [hJoy7], a
|
|
|
|
ld [wWastedByteCD3A], a
|
|
|
|
ld [wOverrideSimulatedJoypadStatesMask], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wListScrollOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOutWithDelay3
|
2015-08-12 09:16:56 +00:00
|
|
|
call RunDefaultPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
jp ReloadMapData
|
|
|
|
.goToSideMenu
|
|
|
|
call HandlePokedexSideMenu
|
|
|
|
dec b
|
2017-12-30 00:54:27 +00:00
|
|
|
jr z, .exitPokedex ; if the player chose Quit
|
2014-05-22 22:13:20 +00:00
|
|
|
dec b
|
2017-12-30 00:54:27 +00:00
|
|
|
jr z, .doPokemonListMenu ; if pokemon not seen or player pressed B button
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .setUpGraphics ; if pokemon data or area was shown
|
|
|
|
|
|
|
|
; handles the menu on the lower right in the pokedex screen
|
|
|
|
; OUTPUT:
|
|
|
|
; b = reason for exiting menu
|
|
|
|
; 00: showed pokemon data or area
|
|
|
|
; 01: the player chose Quit
|
|
|
|
; 02: the pokemon has not been seen yet or the player pressed the B button
|
2016-06-12 00:24:04 +00:00
|
|
|
HandlePokedexSideMenu:
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceUnfilledArrowMenuCursor
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, a
|
|
|
|
ld a, [wLastMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wListScrollOffset]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
add b
|
|
|
|
inc a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wd11e], a
|
|
|
|
ld a, [wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wDexMaxSeenMon]
|
2015-07-19 03:49:52 +00:00
|
|
|
push af ; this doesn't need to be preserved
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wPokedexSeen
|
2014-05-22 22:13:20 +00:00
|
|
|
call IsPokemonBitSet
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, 2
|
|
|
|
jr z, .exitSideMenu
|
2014-05-22 22:13:20 +00:00
|
|
|
call PokedexToIndex
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wTopMenuItemY
|
|
|
|
ld a, 10
|
|
|
|
ld [hli], a ; top menu item Y
|
|
|
|
ld a, 15
|
|
|
|
ld [hli], a ; top menu item X
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hli], a ; current menu item ID
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 3
|
|
|
|
ld [hli], a ; max menu item ID
|
2015-08-11 05:34:32 +00:00
|
|
|
;ld a, A_BUTTON | B_BUTTON
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hli], a ; menu watched keys (A button and B button)
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hli], a ; old menu item ID
|
|
|
|
ld [wMenuWatchMovingOutOfBounds], a
|
2014-05-22 22:13:20 +00:00
|
|
|
.handleMenuInput
|
|
|
|
call HandleMenuInput
|
2017-12-30 00:54:27 +00:00
|
|
|
bit 1, a ; was the B button pressed?
|
|
|
|
ld b, 2
|
|
|
|
jr nz, .buttonBPressed
|
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
jr z, .choseData
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
jr z, .choseCry
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
jr z, .choseArea
|
2014-05-22 22:13:20 +00:00
|
|
|
.choseQuit
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, 1
|
2014-05-22 22:13:20 +00:00
|
|
|
.exitSideMenu
|
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wDexMaxSeenMon], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wListScrollOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wLastMenuItem], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
2014-05-22 22:13:20 +00:00
|
|
|
push bc
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 3
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, 20
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, " ", 13
|
2014-05-22 22:13:20 +00:00
|
|
|
call DrawTileLine ; cover up the menu cursor in the pokemon list
|
|
|
|
pop bc
|
|
|
|
ret
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
.buttonBPressed
|
|
|
|
push bc
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 15, 10
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, 20
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, " ", 7
|
2014-05-22 22:13:20 +00:00
|
|
|
call DrawTileLine ; cover up the menu cursor in the side menu
|
|
|
|
pop bc
|
|
|
|
jr .exitSideMenu
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
.choseData
|
|
|
|
call ShowPokedexDataInternal
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .exitSideMenu
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
; play pokemon cry
|
|
|
|
.choseCry
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e]
|
2015-07-22 14:57:31 +00:00
|
|
|
call GetCryData
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySound
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .handleMenuInput
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
.choseArea
|
2014-06-16 20:57:26 +00:00
|
|
|
predef LoadTownMap_Nest ; display pokemon areas
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, 0
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .exitSideMenu
|
|
|
|
|
|
|
|
; handles the list of pokemon on the left of the pokedex screen
|
|
|
|
; sets carry flag if player presses A, unsets carry flag if player presses B
|
2016-06-12 00:24:04 +00:00
|
|
|
HandlePokedexListMenu:
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [H_AUTOBGTRANSFERENABLED], a
|
2014-05-22 22:13:20 +00:00
|
|
|
; draw the horizontal line separating the seen and owned amounts from the menu
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 15, 8
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, "─"
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 14, 0
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hl], $71 ; vertical line tile
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 14, 1
|
2014-05-22 22:13:20 +00:00
|
|
|
call DrawPokedexVerticalLine
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 14, 9
|
2014-05-22 22:13:20 +00:00
|
|
|
call DrawPokedexVerticalLine
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wPokedexSeen
|
|
|
|
ld b, wPokedexSeenEnd - wPokedexSeen
|
2014-05-22 22:13:20 +00:00
|
|
|
call CountSetBits
|
2015-08-07 11:24:06 +00:00
|
|
|
ld de, wNumSetBits
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 16, 3
|
2015-07-28 01:48:44 +00:00
|
|
|
lb bc, 1, 3
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintNumber ; print number of seen pokemon
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wPokedexOwned
|
|
|
|
ld b, wPokedexOwnedEnd - wPokedexOwned
|
2014-05-22 22:13:20 +00:00
|
|
|
call CountSetBits
|
2015-08-07 11:24:06 +00:00
|
|
|
ld de, wNumSetBits
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 16, 6
|
2015-07-28 01:48:44 +00:00
|
|
|
lb bc, 1, 3
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintNumber ; print number of owned pokemon
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 16, 2
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, PokedexSeenText
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 16, 5
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, PokedexOwnText
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 1
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, PokedexContentsText
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 16, 10
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, PokedexMenuItemsText
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
|
|
|
; find the highest pokedex number among the pokemon the player has seen
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wPokedexSeenEnd - 1
|
|
|
|
ld b, (wPokedexSeenEnd - wPokedexSeen) * 8 + 1
|
2014-05-22 22:13:20 +00:00
|
|
|
.maxSeenPokemonLoop
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hld]
|
|
|
|
ld c, 8
|
2014-05-22 22:13:20 +00:00
|
|
|
.maxSeenPokemonInnerLoop
|
|
|
|
dec b
|
|
|
|
sla a
|
2017-12-30 00:54:27 +00:00
|
|
|
jr c, .storeMaxSeenPokemon
|
2014-05-22 22:13:20 +00:00
|
|
|
dec c
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .maxSeenPokemonInnerLoop
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .maxSeenPokemonLoop
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
.storeMaxSeenPokemon
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, b
|
|
|
|
ld [wDexMaxSeenMon], a
|
2014-05-22 22:13:20 +00:00
|
|
|
.loop
|
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [H_AUTOBGTRANSFERENABLED], a
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 4, 2
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 14, 10
|
2014-05-22 22:13:20 +00:00
|
|
|
call ClearScreenArea
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 3
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wListScrollOffset]
|
|
|
|
ld [wd11e], a
|
|
|
|
ld d, 7
|
|
|
|
ld a, [wDexMaxSeenMon]
|
|
|
|
cp 7
|
|
|
|
jr nc, .printPokemonLoop
|
|
|
|
ld d, a
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wMaxMenuItem], a
|
2014-05-22 22:13:20 +00:00
|
|
|
; loop to print pokemon pokedex numbers and names
|
|
|
|
; if the player has owned the pokemon, it puts a pokeball beside the name
|
|
|
|
.printPokemonLoop
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
push de
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, -SCREEN_WIDTH
|
|
|
|
add hl, de
|
|
|
|
ld de, wd11e
|
2015-07-28 01:48:44 +00:00
|
|
|
lb bc, LEADING_ZEROES | 1, 3
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintNumber ; print the pokedex number
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, SCREEN_WIDTH
|
|
|
|
add hl, de
|
2014-05-22 22:13:20 +00:00
|
|
|
dec hl
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wPokedexOwned
|
2014-05-22 22:13:20 +00:00
|
|
|
call IsPokemonBitSet
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, " "
|
|
|
|
jr z, .writeTile
|
|
|
|
ld a, $72 ; pokeball tile
|
2014-05-22 22:13:20 +00:00
|
|
|
.writeTile
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hl], a ; put a pokeball next to pokemon that the player has owned
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wPokedexSeen
|
2014-05-22 22:13:20 +00:00
|
|
|
call IsPokemonBitSet
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .getPokemonName ; if the player has seen the pokemon
|
|
|
|
ld de, .dashedLine ; print a dashed line in place of the name if the player hasn't seen the pokemon
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .skipGettingName
|
|
|
|
.dashedLine ; for unseen pokemon in the list
|
|
|
|
db "----------@"
|
|
|
|
.getPokemonName
|
|
|
|
call PokedexToIndex
|
|
|
|
call GetMonName
|
|
|
|
.skipGettingName
|
|
|
|
pop hl
|
|
|
|
inc hl
|
|
|
|
call PlaceString
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
|
|
|
add hl, bc
|
2014-05-22 22:13:20 +00:00
|
|
|
pop de
|
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
dec d
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .printPokemonLoop
|
|
|
|
ld a, 01
|
|
|
|
ld [H_AUTOBGTRANSFERENABLED], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call Delay3
|
|
|
|
call GBPalNormal
|
|
|
|
call HandleMenuInput
|
2017-12-30 00:54:27 +00:00
|
|
|
bit 1, a ; was the B button pressed?
|
|
|
|
jp nz, .buttonBPressed
|
2014-05-22 22:13:20 +00:00
|
|
|
.checkIfUpPressed
|
2017-12-30 00:54:27 +00:00
|
|
|
bit 6, a ; was Up pressed?
|
|
|
|
jr z, .checkIfDownPressed
|
2014-05-22 22:13:20 +00:00
|
|
|
.upPressed ; scroll up one row
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wListScrollOffset]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
jp z, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wListScrollOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .loop
|
|
|
|
.checkIfDownPressed
|
2017-12-30 00:54:27 +00:00
|
|
|
bit 7, a ; was Down pressed?
|
|
|
|
jr z, .checkIfRightPressed
|
2014-05-22 22:13:20 +00:00
|
|
|
.downPressed ; scroll down one row
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wDexMaxSeenMon]
|
|
|
|
cp 7
|
|
|
|
jp c, .loop ; can't if the list is shorter than 7
|
|
|
|
sub 7
|
|
|
|
ld b, a
|
|
|
|
ld a, [wListScrollOffset]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp b
|
2017-12-30 00:54:27 +00:00
|
|
|
jp z, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wListScrollOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .loop
|
|
|
|
.checkIfRightPressed
|
2017-12-30 00:54:27 +00:00
|
|
|
bit 4, a ; was Right pressed?
|
|
|
|
jr z, .checkIfLeftPressed
|
2014-05-22 22:13:20 +00:00
|
|
|
.rightPressed ; scroll down 7 rows
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wDexMaxSeenMon]
|
|
|
|
cp 7
|
|
|
|
jp c, .loop ; can't if the list is shorter than 7
|
|
|
|
sub 6
|
|
|
|
ld b, a
|
|
|
|
ld a, [wListScrollOffset]
|
|
|
|
add 7
|
|
|
|
ld [wListScrollOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
cp b
|
2017-12-30 00:54:27 +00:00
|
|
|
jp c, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
dec b
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, b
|
|
|
|
ld [wListScrollOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .loop
|
|
|
|
.checkIfLeftPressed ; scroll up 7 rows
|
2017-12-30 00:54:27 +00:00
|
|
|
bit 5, a ; was Left pressed?
|
|
|
|
jr z, .buttonAPressed
|
2014-05-22 22:13:20 +00:00
|
|
|
.leftPressed
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wListScrollOffset]
|
|
|
|
sub 7
|
|
|
|
ld [wListScrollOffset], a
|
|
|
|
jp nc, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wListScrollOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .loop
|
|
|
|
.buttonAPressed
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
.buttonBPressed
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
DrawPokedexVerticalLine:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld c, 9 ; height of line
|
|
|
|
ld de, SCREEN_WIDTH
|
|
|
|
ld a, $71 ; vertical line tile
|
2014-05-22 22:13:20 +00:00
|
|
|
.loop
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hl], a
|
|
|
|
add hl, de
|
|
|
|
xor 1 ; toggle between vertical line tile and box tile
|
2014-05-22 22:13:20 +00:00
|
|
|
dec c
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PokedexSeenText:
|
2014-05-22 22:13:20 +00:00
|
|
|
db "SEEN@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PokedexOwnText:
|
2014-05-22 22:13:20 +00:00
|
|
|
db "OWN@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PokedexContentsText:
|
2014-05-22 22:13:20 +00:00
|
|
|
db "CONTENTS@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PokedexMenuItemsText:
|
2014-05-22 22:13:20 +00:00
|
|
|
db "DATA"
|
|
|
|
next "CRY"
|
|
|
|
next "AREA"
|
|
|
|
next "QUIT@"
|
|
|
|
|
|
|
|
; tests if a pokemon's bit is set in the seen or owned pokemon bit fields
|
|
|
|
; INPUT:
|
2014-05-26 21:04:56 +00:00
|
|
|
; [wd11e] = pokedex number
|
2014-05-22 22:13:20 +00:00
|
|
|
; hl = address of bit field
|
2016-06-12 00:24:04 +00:00
|
|
|
IsPokemonBitSet:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld c, a
|
|
|
|
ld b, FLAG_TEST
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, c
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
; function to display pokedex data from outside the pokedex
|
2016-06-12 00:24:04 +00:00
|
|
|
ShowPokedexData:
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOutWithDelay3
|
|
|
|
call ClearScreen
|
|
|
|
call UpdateSprites
|
|
|
|
callab LoadPokedexTilePatterns ; load pokedex tiles
|
|
|
|
|
|
|
|
; function to display pokedex data from inside the pokedex
|
2016-06-12 00:24:04 +00:00
|
|
|
ShowPokedexDataInternal:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wd72c
|
|
|
|
set 1, [hl]
|
|
|
|
ld a, $33 ; 3/7 volume
|
|
|
|
ld [rNR50], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOut ; zero all palettes
|
|
|
|
call ClearScreen
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e] ; pokemon ID
|
|
|
|
ld [wcf91], a
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2015-08-12 09:16:56 +00:00
|
|
|
ld b, SET_PAL_POKEDEX
|
|
|
|
call RunPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wd11e], a
|
|
|
|
ld a, [hTilesetType]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hTilesetType], a
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 0
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, 1
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, $64, SCREEN_WIDTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call DrawTileLine ; draw top border
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 17
|
2015-08-05 21:20:29 +00:00
|
|
|
ld b, $6f
|
2014-05-22 22:13:20 +00:00
|
|
|
call DrawTileLine ; draw bottom border
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 1
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, 20
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, $66, $10
|
2014-05-22 22:13:20 +00:00
|
|
|
call DrawTileLine ; draw left border
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 19, 1
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, $67
|
2014-05-22 22:13:20 +00:00
|
|
|
call DrawTileLine ; draw right border
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $63 ; upper left corner tile
|
2014-06-25 20:58:27 +00:00
|
|
|
Coorda 0, 0
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $65 ; upper right corner tile
|
2014-06-25 20:58:27 +00:00
|
|
|
Coorda 19, 0
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $6c ; lower left corner tile
|
2014-06-25 20:58:27 +00:00
|
|
|
Coorda 0, 17
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $6e ; lower right corner tile
|
2014-06-25 20:58:27 +00:00
|
|
|
Coorda 19, 17
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 0, 9
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, PokedexDataDividerLine
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString ; draw horizontal divider line
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 9, 6
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, HeightWeightText
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 9, 2
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, PokedexEntryPointers
|
|
|
|
ld a, [wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld d, [hl] ; de = address of pokedex entry
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 9, 4
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString ; print species name
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld h, b
|
|
|
|
ld l, c
|
2014-05-22 22:13:20 +00:00
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
call IndexToPokedex
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 2, 8
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, "№"
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hli], a
|
|
|
|
ld a, "⠄"
|
|
|
|
ld [hli], a
|
|
|
|
ld de, wd11e
|
2015-07-28 01:48:44 +00:00
|
|
|
lb bc, LEADING_ZEROES | 1, 3
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintNumber ; print pokedex number
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wPokedexOwned
|
2014-05-22 22:13:20 +00:00
|
|
|
call IsPokemonBitSet
|
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wd11e], a
|
|
|
|
ld a, [wcf91]
|
|
|
|
ld [wd0b5], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop de
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push hl
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
call Delay3
|
|
|
|
call GBPalNormal
|
|
|
|
call GetMonHeader ; load pokemon picture location
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 1, 1
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlayCry ; play pokemon cry
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop af
|
2016-06-12 04:30:05 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, c
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
jp z, .waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de ; de = address of feet (height)
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [de] ; reads feet, but a is overwritten without being used
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 12, 6
|
2015-07-28 01:48:44 +00:00
|
|
|
lb bc, 1, 2
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintNumber ; print feet (height)
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $60 ; feet symbol tile (one tick)
|
|
|
|
ld [hl], a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc de
|
|
|
|
inc de ; de = address of inches (height)
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 15, 6
|
2015-07-28 01:48:44 +00:00
|
|
|
lb bc, LEADING_ZEROES | 1, 2
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintNumber ; print inches (height)
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $61 ; inches symbol tile (two ticks)
|
|
|
|
ld [hl], a
|
2014-05-22 22:13:20 +00:00
|
|
|
; now print the weight (note that weight is stored in tenths of pounds internally)
|
|
|
|
inc de
|
|
|
|
inc de
|
|
|
|
inc de ; de = address of upper byte of weight
|
|
|
|
push de
|
2015-07-18 15:17:29 +00:00
|
|
|
; put weight in big-endian order at hDexWeight
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, hDexWeight
|
|
|
|
ld a, [hl] ; save existing value of [hDexWeight]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [de] ; a = upper byte of weight
|
|
|
|
ld [hli], a ; store upper byte of weight in [hDexWeight]
|
|
|
|
ld a, [hl] ; save existing value of [hDexWeight + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
dec de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [de] ; a = lower byte of weight
|
|
|
|
ld [hl], a ; store lower byte of weight in [hDexWeight + 1]
|
|
|
|
ld de, hDexWeight
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 11, 8
|
2015-07-28 01:48:44 +00:00
|
|
|
lb bc, 2, 5 ; 2 bytes, 5 digits
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintNumber ; print weight
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 14, 8
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hDexWeight + 1]
|
|
|
|
sub 10
|
|
|
|
ld a, [hDexWeight]
|
|
|
|
sbc 0
|
|
|
|
jr nc, .next
|
|
|
|
ld [hl], "0" ; if the weight is less than 10, put a 0 before the decimal point
|
2014-05-22 22:13:20 +00:00
|
|
|
.next
|
|
|
|
inc hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld [hld], a ; make space for the decimal point by moving the last digit forward one tile
|
|
|
|
ld [hl], "⠄" ; decimal point tile
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hDexWeight + 1], a ; restore original value of [hDexWeight + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hDexWeight], a ; restore original value of [hDexWeight]
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
inc hl ; hl = address of pokedex description text
|
2015-07-18 20:52:03 +00:00
|
|
|
coord bc, 1, 11
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, 2
|
|
|
|
ld [$fff4], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call TextCommandProcessor ; print pokedex description text
|
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [$fff4], a
|
2014-05-22 22:13:20 +00:00
|
|
|
.waitForButtonPress
|
2014-05-25 18:21:48 +00:00
|
|
|
call JoypadLowSensitivity
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hJoy5]
|
|
|
|
and A_BUTTON | B_BUTTON
|
|
|
|
jr z, .waitForButtonPress
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hTilesetType], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOut
|
|
|
|
call ClearScreen
|
2015-08-12 09:16:56 +00:00
|
|
|
call RunDefaultPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadTextBoxTilePatterns
|
|
|
|
call GBPalNormal
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wd72c
|
|
|
|
res 1, [hl]
|
|
|
|
ld a, $77 ; max volume
|
|
|
|
ld [rNR50], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
HeightWeightText:
|
2016-07-18 06:17:03 +00:00
|
|
|
db "HT ?",$60,"??",$61
|
|
|
|
next "WT ???lb@"
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
; XXX does anything point to this?
|
2016-06-12 00:24:04 +00:00
|
|
|
PokeText:
|
2015-06-12 16:00:48 +00:00
|
|
|
db "#@"
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
; horizontal line that divides the pokedex text description from the rest of the data
|
2016-06-12 00:24:04 +00:00
|
|
|
PokedexDataDividerLine:
|
2014-05-22 22:13:20 +00:00
|
|
|
db $68,$69,$6B,$69,$6B
|
|
|
|
db $69,$6B,$69,$6B,$6B
|
|
|
|
db $6B,$6B,$69,$6B,$69
|
|
|
|
db $6B,$69,$6B,$69,$6A
|
2016-07-18 06:17:03 +00:00
|
|
|
db "@"
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
; draws a line of tiles
|
|
|
|
; INPUT:
|
|
|
|
; b = tile ID
|
|
|
|
; c = number of tile ID's to write
|
|
|
|
; de = amount to destination address after each tile (1 for horizontal, 20 for vertical)
|
|
|
|
; hl = destination address
|
2016-06-12 00:24:04 +00:00
|
|
|
DrawTileLine:
|
2014-05-22 22:13:20 +00:00
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
.loop
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [hl], b
|
|
|
|
add hl, de
|
2014-05-22 22:13:20 +00:00
|
|
|
dec c
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
INCLUDE "data/pokedex_entries.asm"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PokedexToIndex:
|
2014-05-26 21:04:56 +00:00
|
|
|
; converts the Pokédex number at wd11e to an index
|
2014-05-22 22:13:20 +00:00
|
|
|
push bc
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e]
|
|
|
|
ld b, a
|
|
|
|
ld c, 0
|
|
|
|
ld hl, PokedexOrder
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
.loop ; go through the list until we find an entry with a matching dex number
|
|
|
|
inc c
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp b
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, c
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
IndexToPokedex:
|
2017-06-24 20:01:43 +00:00
|
|
|
; converts the index number at wd11e to a Pokédex number
|
2014-05-22 22:13:20 +00:00
|
|
|
push bc
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, PokedexOrder
|
|
|
|
ld b, 0
|
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
INCLUDE "data/pokedex_order.asm"
|