pokedex cleanup and name some more pokedex functions

This commit is contained in:
Marcus Huderle 2025-04-05 10:03:59 -05:00
parent d3d141290c
commit 4ac20db58b
5 changed files with 78 additions and 79 deletions

View File

@ -44,20 +44,20 @@ LoadPokedexScreen: ; 0x2800e
ld [wPokedexOffset], a ld [wPokedexOffset], a
ld [wPokedexBlinkingCursorAndScrollBarCounter], a ld [wPokedexBlinkingCursorAndScrollBarCounter], a
ld [wd95c], a ld [wd95c], a
ld [wd960], a ld [wPokedexStartButtonIsPressed], a
ld [wd961], a ld [wd961], a
ld [wd95e], a ld [wd95e], a
ld a, $1 ld a, $1
ld [wd862], a ld [wd862], a
call ClearSpriteBuffer call ClearSpriteBuffer
call DisplayPokedexScrollBarAndCursor call DisplayPokedexScrollBarAndCursor
call Func_28931 call DrawSummaryWindowMonName
call Func_289c8 call DrawSummaryWindowMonSpecies
call Func_28a15 call DrawSummaryWindowMonAttributes
call Func_28972 call DrawPokedexMonNames
call Func_28a8a call Func_28a8a
call Func_28ad1 call Func_28ad1
call Func_28add call DrawSummaryWindowMonImage
call CountNumSeenOwnedMons call CountNumSeenOwnedMons
call SetAllPalettesWhite call SetAllPalettesWhite
ld a, Bank(Music_Pokedex) ld a, Bank(Music_Pokedex)
@ -165,19 +165,19 @@ MainPokedexScreen: ; 0x280fe
ldh a, [hJoypadState] ldh a, [hJoypadState]
bit BIT_START, a bit BIT_START, a
jr z, .asm_28168 jr z, .asm_28168
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
ld a, $ff ld a, $ff
ld [wd960], a ld [wPokedexStartButtonIsPressed], a
call z, Func_28add call z, DrawSummaryWindowMonImage
jr .done jr .done
.asm_28168 .asm_28168
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
ld a, $0 ld a, $0
ld [wd960], a ld [wPokedexStartButtonIsPressed], a
call nz, Func_28add call nz, DrawSummaryWindowMonImage
.done .done
call DisplayPokedexScrollBarAndCursor call DisplayPokedexScrollBarAndCursor
ret ret
@ -190,44 +190,44 @@ MonInfoPokedexScreen: ; 0x28178
bit BIT_A_BUTTON, a bit BIT_A_BUTTON, a
jr z, .checkIfBPressed jr z, .checkIfBPressed
call Func_28912 call Func_28912
jr .checkIfGameboyColorAndStartPressed jr .displayMonImage
.checkIfBPressed .checkIfBPressed
bit BIT_B_BUTTON, a bit BIT_B_BUTTON, a
jr z, .checkIfGameboyColorAndStartPressed jr z, .displayMonImage
jr .BButtonPressed jr .exitMonInfoView
.lastPokedexDescriptionPage .lastPokedexDescriptionPage
ldh a, [hNewlyPressedButtons] ldh a, [hNewlyPressedButtons]
and $3 and A_BUTTON | B_BUTTON
jr z, .checkIfGameboyColorAndStartPressed jr z, .displayMonImage
.BButtonPressed .exitMonInfoView
call Func_288a2 call Func_288a2
call DisplayPokedexScrollBarAndCursor call DisplayPokedexScrollBarAndCursor
ld a, $1 ld a, $1
ld [wScreenState], a ld [wScreenState], a
ret ret
.checkIfGameboyColorAndStartPressed .displayMonImage
ldh a, [hGameBoyColorFlag] ldh a, [hGameBoyColorFlag]
and a and a
jr z, .asm_281c7 jr z, .asm_281c7
ldh a, [hJoypadState] ldh a, [hJoypadState]
bit BIT_START, a bit BIT_START, a
jr z, .asm_281bb jr z, .asm_281bb
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
ld a, $ff ld a, $ff
ld [wd960], a ld [wPokedexStartButtonIsPressed], a
call z, Func_28add call z, DrawSummaryWindowMonImage
jr .asm_281c7 jr .asm_281c7
.asm_281bb .asm_281bb
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
ld a, $0 ld a, $0
ld [wd960], a ld [wPokedexStartButtonIsPressed], a
call nz, Func_28add call nz, DrawSummaryWindowMonImage
.asm_281c7 .asm_281c7
call Func_2885c call Func_2885c
ret ret
@ -243,7 +243,7 @@ UnusedFunc_281cb:
jr nc, .asm_281da jr nc, .asm_281da
inc b inc b
.asm_281da .asm_281da
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
jr nz, .asm_281fb jr nz, .asm_281fb
ld hl, MonBillboardPalettePointers ld hl, MonBillboardPalettePointers
@ -404,7 +404,7 @@ SpriteOffsetsTable_282b9:
db $80, $68 db $80, $68
Func_282e9: ; 0x282e9 Func_282e9: ; 0x282e9
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
jr z, .asm_28318 jr z, .asm_28318
ld a, [wCurPokedexIndex] ld a, [wCurPokedexIndex]
@ -461,7 +461,7 @@ Func_282e9: ; 0x282e9
call LoadVRAMData call LoadVRAMData
xor a xor a
ldh [rVBK], a ldh [rVBK], a
call Func_28972 call DrawPokedexMonNames
call Func_28a8a call Func_28a8a
call Func_28ad1 call Func_28ad1
ld a, $1 ld a, $1
@ -547,7 +547,7 @@ Func_28368: ; 0x28368
ld a, [hl] ld a, [hl]
or c or c
ld c, a ld c, a
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
jr nz, .asm_283ff jr nz, .asm_283ff
ld hl, BGPaletteIndices_2845c ld hl, BGPaletteIndices_2845c
@ -821,13 +821,12 @@ HandlePokedexDirectionalInput: ; 0x28513
ld a, [wPokedexCursorWasMoved] ld a, [wPokedexCursorWasMoved]
and a and a
ret z ret z
; if the cursor was moved, do a bunch of stuff (to be determined).
lb de, $00, $03 lb de, $00, $03
call PlaySoundEffect call PlaySoundEffect
call Func_28931 call DrawSummaryWindowMonName
call Func_289c8 call DrawSummaryWindowMonSpecies
call Func_28a15 call DrawSummaryWindowMonAttributes
call Func_28add call DrawSummaryWindowMonImage
xor a xor a
ld [wPokedexCursorWasMoved], a ld [wPokedexCursorWasMoved], a
ret ret
@ -835,7 +834,7 @@ HandlePokedexDirectionalInput: ; 0x28513
Func_285ca: ; 0x285ca Func_285ca: ; 0x285ca
xor a xor a
ld [wPressedButtonsPersistent], a ld [wPressedButtonsPersistent], a
call Func_28972 call DrawPokedexMonNames
call Func_28a8a call Func_28a8a
call Func_28ad1 call Func_28ad1
ld a, [wPressedButtonsPersistent] ld a, [wPressedButtonsPersistent]
@ -1102,7 +1101,7 @@ Func_28765: ; 0x28765
and $e and $e
ld c, a ld c, a
ld b, $0 ld b, $0
ld hl, TileLocations_287b7 ld hl, PokedexMonNamesTileLocations
add hl, bc add hl, bc
ld a, [hli] ld a, [hli]
ld e, a ld e, a
@ -1117,7 +1116,7 @@ Func_28765: ; 0x28765
xor a xor a
ld [wd862], a ld [wd862], a
ld a, [hl] ld a, [hl]
call LoadPokemonNameIntoVRAM call DrawPokedexListMonName
ret ret
.asm_28791 .asm_28791
@ -1128,7 +1127,7 @@ Func_28765: ; 0x28765
and $e and $e
ld c, a ld c, a
ld b, $0 ld b, $0
ld hl, TileLocations_287b7 ld hl, PokedexMonNamesTileLocations
add hl, bc add hl, bc
ld a, [hli] ld a, [hli]
ld e, a ld e, a
@ -1144,10 +1143,10 @@ Func_28765: ; 0x28765
ld [wd862], a ld [wd862], a
ld a, [hl] ld a, [hl]
add $5 add $5
call LoadPokemonNameIntoVRAM call DrawPokedexListMonName
ret ret
TileLocations_287b7: PokedexMonNamesTileLocations:
dw vTilesOB tile $0 dw vTilesOB tile $0
dw vTilesOB tile $A dw vTilesOB tile $A
dw vTilesOB tile $14 dw vTilesOB tile $14
@ -1176,7 +1175,7 @@ BGMapLocations_287c7:
dw vBGWin + $3C7 dw vBGWin + $3C7
AnimateMonSpriteIfStartIsPressed: ; 0x287e7 AnimateMonSpriteIfStartIsPressed: ; 0x287e7
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
ret z ret z
ld a, [wPokedexCursorWasMoved] ld a, [wPokedexCursorWasMoved]
@ -1309,8 +1308,8 @@ LoadPokemonDescriptionIntoVRAM: ; 0x288c6
ld hl, wPokedexFlags ld hl, wPokedexFlags
add hl, bc add hl, bc
bit BIT_POKEDEX_MON_CAUGHT, [hl] bit BIT_POKEDEX_MON_CAUGHT, [hl]
ld hl, Unknown_2c000 ld hl, BlankPokedexDescription
jr z, .asm_288f4 jr z, .loadDescription
ld a, [wCurPokedexIndex] ld a, [wCurPokedexIndex]
ld c, a ld c, a
ld b, $0 ld b, $0
@ -1327,7 +1326,7 @@ LoadPokemonDescriptionIntoVRAM: ; 0x288c6
ld b, a ld b, a
ld h, b ld h, b
ld l, c ld l, c
.asm_288f4 .loadDescription
xor a xor a
ld [wd860], a ld [wd860], a
ld [wd861], a ld [wd861], a
@ -1358,7 +1357,7 @@ Func_28912: ; 0x28912
ld [wd958], a ld [wd958], a
ret ret
Func_28931: ; 0x28931 DrawSummaryWindowMonName: ; 0x28931
ld a, [wCurPokedexIndex] ld a, [wCurPokedexIndex]
ld c, a ld c, a
ld b, $0 ld b, $0
@ -1369,9 +1368,9 @@ Func_28931: ; 0x28931
ld hl, BlankDexName ld hl, BlankDexName
jr z, .gotMonNameAddress jr z, .gotMonNameAddress
ld a, [wCurPokedexIndex] ld a, [wCurPokedexIndex]
; compute 11 * hl (11 is length of name)
ld c, a ld c, a
ld b, $0 ld b, $0
; compute 11 * bc (11 is length of name)
ld h, b ld h, b
ld l, c ld l, c
sla l sla l
@ -1398,35 +1397,33 @@ Func_28931: ; 0x28931
BlankDexName: BlankDexName:
db " @" db " @"
Func_28972: ; 0x28972 DrawPokedexMonNames: ; 0x28972
; b is the counter. Iterates 6 times.
; c is used to determine where to draw the name in the Pokedex ; c is used to determine where to draw the name in the Pokedex
ld a, [wPokedexOffset] ld a, [wPokedexOffset]
ld c, a ld c, a
ld b, $6 ld b, 6
.asm_28978 .loop
push bc push bc
ld a, c ld a, c
sla a ; make offset even (by doubling) sla a ; PokedexMonNamesTileLocations has 8 entries. These two lines are simply adjusting register a to index PokedexMonNamesTileLocations.
and $e ; largest even nybble and $e
ld e, a ld e, a
ld d, $0 ld d, $0
ld hl, TileLocations_287b7 ld hl, PokedexMonNamesTileLocations
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ld e, a ld e, a
ld a, [hl] ld a, [hl]
ld d, a ld d, a
; de has tile address for first letter of Pokemon name
ld a, c ld a, c
call LoadPokemonNameIntoVRAM call DrawPokedexListMonName
pop bc pop bc
inc c inc c
dec b dec b
jr nz, .asm_28978 jr nz, .loop
ret ret
LoadPokemonNameIntoVRAM: ; 0x28993 DrawPokedexListMonName: ; 0x28993
push hl push hl
ld c, a ld c, a
ld b, $0 ld b, $0
@ -1436,7 +1433,7 @@ LoadPokemonNameIntoVRAM: ; 0x28993
and a and a
ld hl, BlankDexName2 ld hl, BlankDexName2
jr z, .gotMonNameAddress jr z, .gotMonNameAddress
; compute 11*hl (note that the length of names is 11). ; compute 11 * bc (11 is length of name)
ld h, b ld h, b
ld l, c ld l, c
sla l sla l
@ -1451,7 +1448,6 @@ LoadPokemonNameIntoVRAM: ; 0x28993
ld bc, MonDexNames ld bc, MonDexNames
add hl, bc add hl, bc
.gotMonNameAddress .gotMonNameAddress
; hl now points to the mon name (or a blank name)
xor a xor a
ld [wd860], a ld [wd860], a
ld [wd861], a ld [wd861], a
@ -1463,7 +1459,7 @@ LoadPokemonNameIntoVRAM: ; 0x28993
BlankDexName2: BlankDexName2:
db " @" db " @"
Func_289c8: ; 0x289c8 DrawSummaryWindowMonSpecies: ; 0x289c8
ld a, [wCurPokedexIndex] ld a, [wCurPokedexIndex]
ld c, a ld c, a
ld b, $0 ld b, $0
@ -1488,10 +1484,10 @@ Func_289c8: ; 0x289c8
rl h rl h
add hl, bc add hl, bc
add hl, bc add hl, bc
add hl, bc ; value * 11 add hl, bc ; species * 11
sla l sla l
rl h rl h
add hl, bc ; value * 23 add hl, bc ; species * 23
ld bc, MonSpeciesNames ld bc, MonSpeciesNames
add hl, bc add hl, bc
.pokemonNotOwned .pokemonNotOwned
@ -1508,7 +1504,7 @@ BlankSpeciesName:
dw $4081 ; variable-width font character dw $4081 ; variable-width font character
db $00 db $00
Func_28a15: ; 0x28a15 DrawSummaryWindowMonAttributes: ; 0x28a15
ld a, [wCurPokedexIndex] ld a, [wCurPokedexIndex]
ld c, a ld c, a
ld b, $0 ld b, $0
@ -1645,7 +1641,7 @@ Func_28ad1: ; 0x28ad1
ldh [hNextFrameHBlankSCX], a ldh [hNextFrameHBlankSCX], a
ret ret
Func_28add: ; 0x28add DrawSummaryWindowMonImage: ; 0x28add
ld a, [wCurPokedexIndex] ld a, [wCurPokedexIndex]
ld c, a ld c, a
ld b, $0 ld b, $0
@ -1656,7 +1652,7 @@ Func_28add: ; 0x28add
jp z, LoadUncaughtPokemonBackgroundGfx jp z, LoadUncaughtPokemonBackgroundGfx
dec a dec a
jp z, LoadSeenPokemonGfx jp z, LoadSeenPokemonGfx
ld a, [wd960] ld a, [wPokedexStartButtonIsPressed]
and a and a
jr z, .asm_28afc jr z, .asm_28afc
call CheckIfMonHasAnimation call CheckIfMonHasAnimation
@ -2217,8 +2213,8 @@ LoadPokemonNameVWFCharacterTiles: ; 0x28e09
Func_28e73: ; 0x28e73 Func_28e73: ; 0x28e73
push hl push hl
ldh a, [hVariableWidthFontFF8F] ldh a, [hVariableWidthFontFF8F]
; `a` in this function always contains either $0A, $16, or $6c ; `a` in this function always contains either $0A, $16, or $6c
; compute 16*a and stores it as `bc`. ; compute 16*a and stores it as `bc`.
ld c, a ld c, a
ld b, $0 ld b, $0
sla c sla c
@ -2236,9 +2232,9 @@ Func_28e73: ; 0x28e73
ld a, h ld a, h
sbc b sbc b
ld h, a ld h, a
; When we `push hl`, this will be the address that we will return to when `ret` is called. ; When we `push hl`, this will be the address that we will return to when `ret` is called.
; Specifically, the address should occur somewhere in `Func_28e9a` or `Func_29566`, basically, ; Specifically, the address should occur somewhere in `Func_28e9a` or `Func_29566`, basically,
; indicating how many memory locations we should zero out. ; indicating how many memory locations we should zero out.
push hl push hl
ld hl, wc000 ld hl, wc000
ld a, [wd860] ld a, [wd860]

View File

@ -10,8 +10,8 @@ LoadDexVWFCharacter_: ; 0x8d17
ldh a, [hVariableWidthFontFF93] ldh a, [hVariableWidthFontFF93]
ld l, a ld l, a
ld h, $0 ld h, $0
; `hl` points to CharacterWidths address of the respective character ; `hl` points to CharacterWidths address of the respective character
; `bc` is the flipped VWF value. ; `bc` is the flipped VWF value.
add hl, bc add hl, bc
ldh a, [hVariableWidthFontFF8E] ldh a, [hVariableWidthFontFF8E]
cp h cp h
@ -42,7 +42,7 @@ LoadDexVWFCharacter_: ; 0x8d17
rr l rr l
ldh a, [hVariableWidthFontFF8F] ldh a, [hVariableWidthFontFF8F]
cp l cp l
; jump when done? ; jump when done?
jp c, Func_8df7 jp c, Func_8df7
.asm_8d5c .asm_8d5c
ldh a, [hVariableWidthFontFF90] ldh a, [hVariableWidthFontFF90]

View File

@ -142,10 +142,6 @@ INCLUDE "engine/pokedex.asm"
SECTION "bankb", ROMX SECTION "bankb", ROMX
Unknown_2c000: ; 0x2c000
dex_text " "
dex_end
INCLUDE "text/pokedex_descriptions.asm" INCLUDE "text/pokedex_descriptions.asm"
SECTION "bankc", ROMX SECTION "bankc", ROMX

View File

@ -1,3 +1,7 @@
BlankPokedexDescription: ; 0x2c000
dex_text " "
dex_end
PokedexDescriptionPointers: ; 0x2c002 PokedexDescriptionPointers: ; 0x2c002
dw BulbasaurPokedexDescription dw BulbasaurPokedexDescription
dw IvysaurPokedexDescription dw IvysaurPokedexDescription

View File

@ -2399,8 +2399,11 @@ wd95e:: ; 0xd95e
wPokedexCursorWasMoved:: ; 0xd95f wPokedexCursorWasMoved:: ; 0xd95f
ds $1 ds $1
; It's either 0 or $ff ... ; Keeps track of whether or not the START button is pressed in the Pokedex screen.
wd960:: ; 0xd960 ; This is used to know whether or not to display the animated mon catch sprite.
; $0 = START is NOT currently pressed
; $FF = START is currently pressed
wPokedexStartButtonIsPressed:: ; 0xd960
ds $1 ds $1
wd961:: ; 0xd961 wd961:: ; 0xd961