forked from pret/pokered
-
Notifications
You must be signed in to change notification settings - Fork 48
Code Dump
Vortyne edited this page May 25, 2025
·
5 revisions
ShowMonLearnset:
ld a, [wListScrollOffset]
push af
ld a, [wCurrentMenuItem]
push af
.learnsetList
ld hl, wTopMenuItemY
ld a, 3
ld [hli], a ; top menu item Y
xor a
ld [hli], a ; top menu item X
inc a
ld [wMenuWatchMovingOutOfBounds], a
inc hl
inc hl
ld a, 6
ld [hli], a ; max menu item ID
ld [hl], D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
call ShowLevelUpLearnset
jr c, .showMovedex
cp 1
.exitLearnset
pop af
ld [wCurrentMenuItem], a
pop af
ld [wListScrollOffset], a
ret
.showMovedex
ret
LearnsetViewJumpTable:
dw ShowLevelUpLearnset
dw ShowTMLearnset
dw ShowEvolutions
PrepLearnsetList:
xor a
ldh [hAutoBGTransferEnabled], a
hlcoord 4, 2
lb bc, 14, 10
call ClearScreenArea
hlcoord 1, 3
ld a, [wListScrollOffset]
ld [wLearnsetIndex], a
ld d, 7
ld a, [wDexMaxSeenMon]
cp 7
ret nc
ld d, a
dec a
ld [wMaxMenuItem], a
ret
ShowLevelUpLearnset:
callfar LoadLevelUpLearnsetIntoWRAM
.loop
call PrepLearnsetList
.printMoveEntryLoop
ld a, [wLearnsetIndex]
inc a
ld [wLearnsetIndex], a
push af
push de
push hl
;;;; page specific code starts
ld de, LvText
call PlaceString ; Place "Lv" text
push hl
; get level the move is learned at into e
ld hl, wLearnsetList
ld d, 0
dec a
ld e, a
add hl, de
add hl, de
ld a, [hl]
ld e, a
pop hl
lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; print level
;;;; page specific code ends
push hl
ld a, [wPokedexNum]
push af
ld a, [wLearnsetIndex]
ld hl, wLearnsetList
ld d, 0
ld e, a
add hl, de
add hl, de
inc hl
ld a, [hl]
ld [wMoveDexMoveID], a
ld hl, wMoveDexSeen
call IsMoveBitSet
jr nz, .getMoveName ; 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 ; TODO: reuse dashed lines
jr .skipGettingName
.dashedLine ; for unseen pokemon in the list
db "----------@"
.getMoveName
call GetMoveName
.skipGettingName
pop af
ld [wPokedexNum], a
pop hl
inc hl ; add a space before the move name is printed
call PlaceString
pop hl
ld bc, 2 * SCREEN_WIDTH
add hl, bc
pop de
pop af
ld [wLearnsetIndex], a
dec d
jr nz, .printMoveEntryLoop
ld a, 01
ldh [hAutoBGTransferEnabled], a
call Delay3
call GBPalNormal
call HandleMenuInput
bit BIT_B_BUTTON, a
jp nz, .buttonBPressed
bit BIT_A_BUTTON, a
jp nz, .buttonAPressed
.checkIfUpPressed
bit BIT_D_UP, a
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
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
jr z, .checkIfLeftPressed
.rightPressed
ld a, 1 ; go to right data view
and a
ret
.checkIfLeftPressed
bit BIT_D_LEFT, a
jr z, .buttonAPressed
.leftPressed
ld a, 2 ; go to left data view
and a
ret
.buttonAPressed
xor a
scf
ret
.buttonBPressed
xor a
and a
ret
LvText:
db "Lv@"
TMLearnsetListPrint:
push hl
; get the item ID into
ld hl, wLearnsetList
ld d, 0
dec a
ld e, a
add hl, de
ld a, [hl]
ld e, a
pop hl
lb bc, LEADING_ZEROES | 1, 3
jp PrintNumber ; print level