summaryrefslogtreecommitdiff
path: root/engine/menus/pokedex.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/menus/pokedex.asm')
-rw-r--r--engine/menus/pokedex.asm354
1 files changed, 218 insertions, 136 deletions
diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm
index 2af8d714..8e4fef19 100644
--- a/engine/menus/pokedex.asm
+++ b/engine/menus/pokedex.asm
@@ -12,9 +12,10 @@ ShowPokedexMenu:
ld [wd11e], a
ldh [hJoy7], a
.setUpGraphics
+ callfar LoadPokedexTilePatterns
+.loop
ld b, SET_PAL_GENERIC
call RunPaletteCommand
- callfar LoadPokedexTilePatterns
.doPokemonListMenu
ld hl, wTopMenuItemY
ld a, 3
@@ -43,12 +44,15 @@ ShowPokedexMenu:
call GBPalWhiteOutWithDelay3
call RunDefaultPaletteCommand
jp ReloadMapData
+
.goToSideMenu
call HandlePokedexSideMenu
dec b
jr z, .exitPokedex ; if the player chose Quit
dec b
jr z, .doPokemonListMenu ; if pokemon not seen or player pressed B button
+ dec b
+ jr z, .loop
jp .setUpGraphics ; if pokemon data or area was shown
; handles the menu on the lower right in the pokedex screen
@@ -79,20 +83,21 @@ HandlePokedexSideMenu:
jr z, .exitSideMenu
call PokedexToIndex
ld hl, wTopMenuItemY
- ld a, 10
+ ld a, 8
ld [hli], a ; top menu item Y
ld a, 15
ld [hli], a ; top menu item X
xor a
ld [hli], a ; current menu item ID
inc hl
- ld a, 3
+ ld a, 4
ld [hli], a ; max menu item ID
- ;ld a, A_BUTTON | B_BUTTON
+ ld a, A_BUTTON | B_BUTTON
ld [hli], a ; menu watched keys (A button and B button)
xor a
ld [hli], a ; old menu item ID
ld [wMenuWatchMovingOutOfBounds], a
+ ldh [hJoy7], a
.handleMenuInput
call HandleMenuInput
bit 1, a ; was the B button pressed?
@@ -105,6 +110,8 @@ HandlePokedexSideMenu:
jr z, .choseCry
dec a
jr z, .choseArea
+ dec a
+ jr z, .chosePrint
.choseQuit
ld b, 1
.exitSideMenu
@@ -118,6 +125,8 @@ HandlePokedexSideMenu:
ld [wLastMenuItem], a
pop af
ld [wCurrentMenuItem], a
+ ld a, $1
+ ldh [hJoy7], a
push bc
hlcoord 0, 3
ld de, 20
@@ -128,9 +137,9 @@ HandlePokedexSideMenu:
.buttonBPressed
push bc
- hlcoord 15, 10
+ hlcoord 15, 8
ld de, 20
- lb bc, " ", 7
+ lb bc, " ", 9
call DrawTileLine ; cover up the menu cursor in the side menu
pop bc
jr .exitSideMenu
@@ -152,13 +161,105 @@ HandlePokedexSideMenu:
ld b, 0
jr .exitSideMenu
+.chosePrint
+ ldh a, [hTileAnimations]
+ push af
+ xor a
+ ldh [hTileAnimations], a
+ ld a, [wd11e]
+ ld [wcf91], a
+ callfar PrintPokedexEntry
+ xor a
+ ldh [hAutoBGTransferEnabled], a
+ call ClearScreen
+ pop af
+ ldh [hTileAnimations], a
+ ld b, $3
+ 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
HandlePokedexListMenu:
+ call Pokedex_DrawInterface
+.loop
+ call Pokedex_PlacePokemonList
+ call GBPalNormal
+ call HandleMenuInput
+ bit BIT_B_BUTTON, a ; was the B button pressed?
+ jp nz, .buttonBPressed
+ bit BIT_A_BUTTON, a ; was the A button pressed?
+ jp nz, .buttonAPressed
+.checkIfUpPressed
+ bit BIT_D_UP, a ; was Up pressed?
+ jr z, .checkIfDownPressed
+.upPressed ; scroll up one row
+ ld a, [wListScrollOffset]
+ and a
+ jp z, .loop
+ dec a
+ ld [wListScrollOffset], a
+ jp .loop
+
+.checkIfDownPressed
+ bit BIT_D_DOWN, a ; was Down pressed?
+ jr z, .checkIfRightPressed
+.downPressed ; scroll down one row
+ 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]
+ cp b
+ jp z, .loop
+ inc a
+ ld [wListScrollOffset], a
+ jp .loop
+
+.checkIfRightPressed
+ bit BIT_D_RIGHT, a ; was Right pressed?
+ jr z, .checkIfLeftPressed
+.rightPressed ; scroll down 7 rows
+ 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
+ cp b
+ jp c, .loop
+ dec b
+ ld a, b
+ ld [wListScrollOffset], a
+ jp .loop
+
+.checkIfLeftPressed ; scroll up 7 rows
+ bit BIT_D_LEFT, a ; was Left pressed?
+ jr z, .buttonAPressed
+.leftPressed
+ ld a, [wListScrollOffset]
+ sub 7
+ ld [wListScrollOffset], a
+ jp nc, .loop
+ xor a
+ ld [wListScrollOffset], a
+ jp .loop
+
+.buttonAPressed
+ scf
+ ret
+
+.buttonBPressed
+ and a
+ ret
+
+Pokedex_DrawInterface:
xor a
ldh [hAutoBGTransferEnabled], a
; draw the horizontal line separating the seen and owned amounts from the menu
- hlcoord 15, 8
+ hlcoord 15, 6
ld a, "─"
ld [hli], a
ld [hli], a
@@ -175,26 +276,26 @@ HandlePokedexListMenu:
ld b, wPokedexSeenEnd - wPokedexSeen
call CountSetBits
ld de, wNumSetBits
- hlcoord 16, 3
+ hlcoord 16, 2
lb bc, 1, 3
call PrintNumber ; print number of seen pokemon
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
ld de, wNumSetBits
- hlcoord 16, 6
+ hlcoord 16, 5
lb bc, 1, 3
call PrintNumber ; print number of owned pokemon
- hlcoord 16, 2
+ hlcoord 16, 1
ld de, PokedexSeenText
call PlaceString
- hlcoord 16, 5
+ hlcoord 16, 4
ld de, PokedexOwnText
call PlaceString
hlcoord 1, 1
ld de, PokedexContentsText
call PlaceString
- hlcoord 16, 10
+ hlcoord 16, 8
ld de, PokedexMenuItemsText
call PlaceString
; find the highest pokedex number among the pokemon the player has seen
@@ -214,7 +315,37 @@ HandlePokedexListMenu:
.storeMaxSeenPokemon
ld a, b
ld [wDexMaxSeenMon], a
+ ret
+
+DrawPokedexVerticalLine:
+ ld c, 9 ; height of line
+ ld de, SCREEN_WIDTH ; width of screen
+ ld a, $71 ; vertical line tile
.loop
+ ld [hl], a
+ add hl, de
+ xor 1 ; toggle between vertical line tile and box tile
+ dec c
+ jr nz, .loop
+ ret
+
+PokedexSeenText:
+ db "SEEN@"
+
+PokedexOwnText:
+ db "OWN@"
+
+PokedexContentsText:
+ db "CONTENTS@"
+
+PokedexMenuItemsText:
+ db "DATA"
+ next "CRY"
+ next "AREA"
+ next "PRNT"
+ next "QUIT@"
+
+Pokedex_PlacePokemonList:
xor a
ldh [hAutoBGTransferEnabled], a
hlcoord 4, 2
@@ -282,98 +413,8 @@ HandlePokedexListMenu:
ld a, 01
ldh [hAutoBGTransferEnabled], a
call Delay3
- call GBPalNormal
- call HandleMenuInput
- bit 1, a ; was the B button pressed?
- jp nz, .buttonBPressed
-.checkIfUpPressed
- bit 6, a ; was Up pressed?
- jr z, .checkIfDownPressed
-.upPressed ; scroll up one row
- ld a, [wListScrollOffset]
- and a
- jp z, .loop
- dec a
- ld [wListScrollOffset], a
- jp .loop
-.checkIfDownPressed
- bit 7, a ; was Down pressed?
- jr z, .checkIfRightPressed
-.downPressed ; scroll down one row
- 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]
- cp b
- jp z, .loop
- inc a
- ld [wListScrollOffset], a
- jp .loop
-.checkIfRightPressed
- bit 4, a ; was Right pressed?
- jr z, .checkIfLeftPressed
-.rightPressed ; scroll down 7 rows
- 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
- cp b
- jp c, .loop
- dec b
- ld a, b
- ld [wListScrollOffset], a
- jp .loop
-.checkIfLeftPressed ; scroll up 7 rows
- bit 5, a ; was Left pressed?
- jr z, .buttonAPressed
-.leftPressed
- ld a, [wListScrollOffset]
- sub 7
- ld [wListScrollOffset], a
- jp nc, .loop
- xor a
- ld [wListScrollOffset], a
- jp .loop
-.buttonAPressed
- scf
- ret
-.buttonBPressed
- and a
- ret
-
-DrawPokedexVerticalLine:
- ld c, 9 ; height of line
- ld de, SCREEN_WIDTH
- ld a, $71 ; vertical line tile
-.loop
- ld [hl], a
- add hl, de
- xor 1 ; toggle between vertical line tile and box tile
- dec c
- jr nz, .loop
ret
-PokedexSeenText:
- db "SEEN@"
-
-PokedexOwnText:
- db "OWN@"
-
-PokedexContentsText:
- db "CONTENTS@"
-
-PokedexMenuItemsText:
- 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:
; [wd11e] = pokedex number
@@ -401,8 +442,11 @@ ShowPokedexDataInternal:
set 1, [hl]
ld a, $33 ; 3/7 volume
ldh [rNR50], a
+ ldh a, [hTileAnimations]
+ push af
+ xor a
+ ldh [hTileAnimations], a
call GBPalWhiteOut ; zero all palettes
- call ClearScreen
ld a, [wd11e] ; pokemon ID
ld [wcf91], a
push af
@@ -410,10 +454,42 @@ ShowPokedexDataInternal:
call RunPaletteCommand
pop af
ld [wd11e], a
- ldh a, [hTileAnimations]
- push af
- xor a
+ call DrawDexEntryOnScreen
+ call c, Pokedex_PrintFlavorTextAtRow11
+.waitForButtonPress
+ call JoypadLowSensitivity
+ ldh a, [hJoy5]
+ and A_BUTTON | B_BUTTON
+ jr z, .waitForButtonPress
+ pop af
ldh [hTileAnimations], a
+ call GBPalWhiteOut
+ call ClearScreen
+ call RunDefaultPaletteCommand
+ call LoadTextBoxTilePatterns
+ call GBPalNormal
+ ld hl, wd72c
+ res 1, [hl]
+ ld a, $77 ; max volume
+ ldh [rNR50], a
+ ret
+
+HeightWeightText:
+ db "HT ?′??″"
+ next "WT ???lb@"
+
+; XXX does anything point to this?
+PokeText:
+ db "#@"
+
+; horizontal line that divides the pokedex text description from the rest of the data
+PokedexDataDividerLine:
+ db $68, $69, $6B, $69, $6B, $69, $6B, $69, $6B, $6B
+ db $6B, $6B, $69, $6B, $69, $6B, $69, $6B, $69, $6A
+ db "@"
+
+DrawDexEntryOnScreen:
+ call ClearScreen
hlcoord 0, 0
ld de, 1
@@ -512,7 +588,8 @@ ShowPokedexDataInternal:
ld a, c
and a
- jp z, .waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description
+ ret z ; if the pokemon has not been owned, don't print the height, weight, or description
+
inc de ; de = address of feet (height)
ld a, [de] ; reads feet, but a is overwritten without being used
hlcoord 12, 6
@@ -565,43 +642,48 @@ ShowPokedexDataInternal:
ldh [hDexWeight], a ; restore original value of [hDexWeight]
pop hl
inc hl ; hl = address of pokedex description text
+ scf
+ ret
+
+Pokedex_PrintFlavorTextAtRow11:
bccoord 1, 11
+Pokedex_PrintFlavorTextAtBC:
ld a, %10
ldh [hClearLetterPrintingDelayFlags], a
call TextCommandProcessor ; print pokedex description text
xor a
ldh [hClearLetterPrintingDelayFlags], a
-.waitForButtonPress
- call JoypadLowSensitivity
- ldh a, [hJoy5]
- and A_BUTTON | B_BUTTON
- jr z, .waitForButtonPress
- pop af
- ldh [hTileAnimations], a
- call GBPalWhiteOut
- call ClearScreen
- call RunDefaultPaletteCommand
- call LoadTextBoxTilePatterns
- call GBPalNormal
- ld hl, wd72c
- res 1, [hl]
- ld a, $77 ; max volume
- ldh [rNR50], a
ret
-HeightWeightText:
- db "HT ?′??″"
- next "WT ???lb@"
-
-; XXX does anything point to this?
-PokeText:
- db "#@"
-
-; horizontal line that divides the pokedex text description from the rest of the data
-PokedexDataDividerLine:
- db $68, $69, $6B, $69, $6B, $69, $6B, $69, $6B, $6B
- db $6B, $6B, $69, $6B, $69, $6B, $69, $6B, $69, $6A
- db "@"
+Pokedex_PrepareDexEntryForPrinting:
+ hlcoord 0, 0
+ ld de, SCREEN_WIDTH
+ lb bc, $66, $d
+ call DrawTileLine
+ hlcoord 19, 0
+ ld b, $67
+ call DrawTileLine
+ hlcoord 0, 13
+ ld de, $1
+ lb bc, $6f, SCREEN_WIDTH
+ call DrawTileLine
+ ld a, $6c
+ ldcoord_a 0, 13
+ ld a, $6e
+ ldcoord_a 19, 13
+ ld a, [wPrinterPokedexEntryTextPointer]
+ ld l, a
+ ld a, [wPrinterPokedexEntryTextPointer + 1]
+ ld h, a
+ bccoord 1, 1
+ ldh a, [hFlagsFFFA]
+ set 3, a
+ ldh [hFlagsFFFA], a
+ call Pokedex_PrintFlavorTextAtBC
+ ldh a, [hFlagsFFFA]
+ res 3, a
+ ldh [hFlagsFFFA], a
+ ret
; draws a line of tiles
; INPUT: