pokered/engine/menu/status_screen.asm

480 lines
8.5 KiB
NASM
Raw Normal View History

DrawHP: ; 128ef (4:68ef)
; Draws the HP bar in the stats screen
call GetPredefRegisters
ld a, $1
jr DrawHP_
DrawHP2: ; 128f6 (4:68f6)
; Draws the HP bar in the party screen
call GetPredefRegisters
ld a, $2
DrawHP_: ; 128fb (4:68fb)
ld [wHPBarType], a
push hl
ld a, [wLoadedMonHP]
ld b, a
ld a, [wLoadedMonHP + 1]
ld c, a
or b
jr nz, .nonzeroHP
xor a
ld c, a
ld e, a
ld a, $6
ld d, a
jp .drawHPBarAndPrintFraction
.nonzeroHP
ld a, [wLoadedMonMaxHP]
ld d, a
ld a, [wLoadedMonMaxHP + 1]
ld e, a
predef HPBarLength
ld a, $6
ld d, a
ld c, a
.drawHPBarAndPrintFraction
pop hl
push de
push hl
push hl
call DrawHPBar
pop hl
ld a, [hFlags_0xFFF6]
bit 0, a
jr z, .printFractionBelowBar
ld bc, $9 ; right of bar
jr .printFraction
.printFractionBelowBar
ld bc, SCREEN_WIDTH + 1 ; below bar
.printFraction
add hl, bc
ld de, wLoadedMonHP
2015-07-28 01:48:44 +00:00
lb bc, 2, 3
call PrintNumber
ld a, "/"
ld [hli], a
ld de, wLoadedMonMaxHP
2015-07-28 01:48:44 +00:00
lb bc, 2, 3
call PrintNumber
pop hl
pop de
ret
2014-05-22 22:13:20 +00:00
; Predef 0x37
StatusScreen: ; 12953 (4:6953)
call LoadMonData
2015-07-16 03:04:58 +00:00
ld a, [wMonDataLocation]
cp BOX_DATA
jr c, .DontRecalculate
2015-07-16 03:04:58 +00:00
; mon is in a box or daycare
2015-02-08 02:37:40 +00:00
ld a, [wLoadedMonBoxLevel]
ld [wLoadedMonLevel], a
ld [W_CURENEMYLVL], a
2015-02-08 02:37:40 +00:00
ld hl, wLoadedMonHPExp - 1
ld de, wLoadedMonStats
2014-05-22 22:13:20 +00:00
ld b, $1
call CalcStats ; Recalculate stats
.DontRecalculate
ld hl, wd72c
2014-05-22 22:13:20 +00:00
set 1, [hl]
ld a, $33
ld [$ff24], a ; Reduce the volume
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
2014-05-22 22:13:20 +00:00
call LoadHpBarAndStatusTilePatterns
ld de, BattleHudTiles1 ; source
2014-05-29 08:31:46 +00:00
ld hl, vChars2 + $6d0 ; dest
2015-08-05 21:20:29 +00:00
lb bc, BANK(BattleHudTiles1), $03
2014-05-22 22:13:20 +00:00
call CopyVideoDataDouble ; ·│ :L and halfarrow line end
ld de, BattleHudTiles2
2014-05-29 08:31:46 +00:00
ld hl, vChars2 + $780
2015-08-05 21:20:29 +00:00
lb bc, BANK(BattleHudTiles2), $01
2014-05-22 22:13:20 +00:00
call CopyVideoDataDouble ; │
ld de, BattleHudTiles3
2014-05-29 08:31:46 +00:00
ld hl, vChars2 + $760
2015-08-05 21:20:29 +00:00
lb bc, BANK(BattleHudTiles3), $02
2014-05-22 22:13:20 +00:00
call CopyVideoDataDouble ; ─┘
ld de, PTile
2014-05-29 08:31:46 +00:00
ld hl, vChars2 + $720
2015-08-05 21:20:29 +00:00
lb bc, BANK(PTile), $01
2014-05-22 22:13:20 +00:00
call CopyVideoDataDouble ; P (for PP), inline
2014-09-14 18:29:18 +00:00
ld a, [hTilesetType]
2014-05-22 22:13:20 +00:00
push af
xor a
2014-09-14 18:29:18 +00:00
ld [hTilesetType], a
2015-07-18 20:52:03 +00:00
coord hl, 19, 1
2015-08-05 21:20:29 +00:00
lb bc, 6, 10
2014-05-22 22:13:20 +00:00
call DrawLineBox ; Draws the box around name, HP and status
2015-08-05 21:20:29 +00:00
ld de, -6
2014-05-22 22:13:20 +00:00
add hl, de
ld [hl], $f2 ; . after No ("." is a different one)
dec hl
ld [hl], "№"
2015-07-18 20:52:03 +00:00
coord hl, 19, 9
2015-08-05 21:20:29 +00:00
lb bc, 8, 6
2014-05-22 22:13:20 +00:00
call DrawLineBox ; Draws the box around types, ID No. and OT
2015-07-18 20:52:03 +00:00
coord hl, 10, 9
2014-05-22 22:13:20 +00:00
ld de, Type1Text
call PlaceString ; "TYPE1/"
2015-07-18 20:52:03 +00:00
coord hl, 11, 3
2015-02-08 06:18:42 +00:00
predef DrawHP
ld hl, wcf25
2014-05-22 22:13:20 +00:00
call GetHealthBarColor
ld b, $3
call GoPAL_SET ; SGB palette
2015-07-18 20:52:03 +00:00
coord hl, 16, 6
2015-02-08 02:37:40 +00:00
ld de, wLoadedMonStatus
2014-05-22 22:13:20 +00:00
call PrintStatusCondition
jr nz, .StatusWritten
2015-07-18 20:52:03 +00:00
coord hl, 16, 6
2014-05-22 22:13:20 +00:00
ld de, OKText
call PlaceString ; "OK"
.StatusWritten
2015-07-18 20:52:03 +00:00
coord hl, 9, 6
2014-05-22 22:13:20 +00:00
ld de, StatusText
call PlaceString ; "STATUS/"
2015-07-18 20:52:03 +00:00
coord hl, 14, 2
2014-05-22 22:13:20 +00:00
call PrintLevel ; Pokémon level
ld a, [W_MONHDEXNUM]
ld [wd11e], a
ld [wd0b5], a
predef IndexToPokedex
2015-07-18 20:52:03 +00:00
coord hl, 3, 7
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 ; Pokémon no.
2015-07-18 20:52:03 +00:00
coord hl, 11, 10
2015-02-08 00:24:16 +00:00
predef PrintMonType
ld hl, NamePointers2
2015-07-16 03:04:58 +00:00
call .GetStringPointer
2014-05-22 22:13:20 +00:00
ld d, h
ld e, l
2015-07-18 20:52:03 +00:00
coord hl, 9, 1
2014-05-22 22:13:20 +00:00
call PlaceString ; Pokémon name
ld hl, OTPointers
2015-07-16 03:04:58 +00:00
call .GetStringPointer
2014-05-22 22:13:20 +00:00
ld d, h
ld e, l
2015-07-18 20:52:03 +00:00
coord hl, 12, 16
2014-05-22 22:13:20 +00:00
call PlaceString ; OT
2015-07-18 20:52:03 +00:00
coord hl, 12, 14
2015-02-08 02:37:40 +00:00
ld de, wLoadedMonOTID
2015-07-28 01:48:44 +00:00
lb bc, LEADING_ZEROES | 2, 5
2014-05-22 22:13:20 +00:00
call PrintNumber ; ID Number
ld d, $0
call PrintStatsBox
call Delay3
call GBPalNormal
2015-07-18 20:52:03 +00:00
coord hl, 1, 0
2014-05-22 22:13:20 +00:00
call LoadFlippedFrontSpriteByMonIndex ; draw Pokémon picture
ld a, [wcf91]
2014-05-22 22:13:20 +00:00
call PlayCry ; play Pokémon cry
call WaitForTextScrollButtonPress ; wait for button
pop af
2014-09-14 18:29:18 +00:00
ld [hTilesetType], a
2014-05-22 22:13:20 +00:00
ret
2015-07-16 03:04:58 +00:00
.GetStringPointer
ld a, [wMonDataLocation]
2014-05-22 22:13:20 +00:00
add a
ld c, a
2015-07-16 03:04:58 +00:00
ld b, 0
2014-05-22 22:13:20 +00:00
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
2015-07-16 03:04:58 +00:00
ld a, [wMonDataLocation]
cp DAYCARE_DATA
2014-05-22 22:13:20 +00:00
ret z
ld a, [wWhichPokemon]
jp SkipFixedLengthTextEntries
OTPointers: ; 12a95 (4:6a95)
dw wPartyMonOT
dw wEnemyMonOT
dw wBoxMonOT
2014-05-22 22:13:20 +00:00
dw W_DAYCAREMONOT
NamePointers2: ; 12a9d (4:6a9d)
dw wPartyMonNicks
dw wEnemyMonNicks
dw wBoxMonNicks
2014-05-22 22:13:20 +00:00
dw W_DAYCAREMONNAME
Type1Text: ; 12aa5 (4:6aa5)
db "TYPE1/", $4e
Type2Text: ; 12aac (4:6aac)
db "TYPE2/", $4e
IDNoText: ; 12ab3 (4:6ab3)
db $73, "№", "/", $4e
OTText: ; 12ab7 (4:6ab7)
db "OT/", $4e, "@"
StatusText: ; 12abc (4:6abc)
db "STATUS/@"
OKText: ; 12ac4 (4:6ac4)
db "OK@"
; Draws a line starting from hl high b and wide c
DrawLineBox: ; 0x12ac7
2015-08-05 21:20:29 +00:00
ld de, SCREEN_WIDTH ; New line
2014-05-22 22:13:20 +00:00
.PrintVerticalLine
ld [hl], $78 ; │
add hl, de
dec b
jr nz, .PrintVerticalLine
2014-05-22 22:13:20 +00:00
ld [hl], $77 ; ┘
dec hl
.PrintHorizLine
ld [hl], $76 ; ─
dec hl
dec c
jr nz, .PrintHorizLine
2014-05-22 22:13:20 +00:00
ld [hl], $6f ; ← (halfarrow ending)
ret
PTile: ; 12adc (4:6adc) ; This is a single 1bpp "P" tile
INCBIN "gfx/p_tile.1bpp"
PrintStatsBox: ; 12ae4 (4:6ae4)
ld a, d
and a ; a is 0 from the status screen
jr nz, .DifferentBox
2015-07-18 20:52:03 +00:00
coord hl, 0, 8
2014-05-22 22:13:20 +00:00
ld b, $8
ld c, $8
call TextBoxBorder ; Draws the box
2015-07-18 20:52:03 +00:00
coord hl, 1, 9 ; Start printing stats from here
2014-05-22 22:13:20 +00:00
ld bc, $0019 ; Number offset
jr .PrintStats
2014-05-22 22:13:20 +00:00
.DifferentBox
2015-07-18 20:52:03 +00:00
coord hl, 9, 2
2014-05-22 22:13:20 +00:00
ld b, $8
ld c, $9
call TextBoxBorder
2015-07-18 20:52:03 +00:00
coord hl, 11, 3
2014-05-22 22:13:20 +00:00
ld bc, $0018
.PrintStats
push bc
push hl
ld de, StatsText
call PlaceString
pop hl
pop bc
add hl, bc
2015-02-08 02:37:40 +00:00
ld de, wLoadedMonAttack
2015-07-28 01:48:44 +00:00
lb bc, 2, 3
2014-05-22 22:13:20 +00:00
call PrintStat
2015-02-08 02:37:40 +00:00
ld de, wLoadedMonDefense
2014-05-22 22:13:20 +00:00
call PrintStat
2015-02-08 02:37:40 +00:00
ld de, wLoadedMonSpeed
2014-05-22 22:13:20 +00:00
call PrintStat
2015-02-08 02:37:40 +00:00
ld de, wLoadedMonSpecial
2014-05-22 22:13:20 +00:00
jp PrintNumber
PrintStat
push hl
call PrintNumber
pop hl
2015-07-14 07:16:19 +00:00
ld de, SCREEN_WIDTH * 2
2014-05-22 22:13:20 +00:00
add hl, de
ret
StatsText: ; 12b3a (4:6b3a)
db "ATTACK"
next "DEFENSE"
next "SPEED"
next "SPECIAL@"
StatusScreen2: ; 12b57 (4:6b57)
2014-09-14 18:29:18 +00:00
ld a, [hTilesetType]
2014-05-22 22:13:20 +00:00
push af
xor a
2014-09-14 18:29:18 +00:00
ld [hTilesetType], a
2015-07-19 03:49:52 +00:00
ld [H_AUTOBGTRANSFERENABLED], a
ld bc, NUM_MOVES + 1
2015-02-08 08:17:03 +00:00
ld hl, wMoves
2014-05-22 22:13:20 +00:00
call FillMemory
2015-02-08 02:37:40 +00:00
ld hl, wLoadedMonMoves
2015-02-08 08:17:03 +00:00
ld de, wMoves
ld bc, NUM_MOVES
2014-05-22 22:13:20 +00:00
call CopyData
2015-02-08 08:17:03 +00:00
callab FormatMovesString
2015-07-18 20:52:03 +00:00
coord hl, 9, 2
2015-07-19 03:49:52 +00:00
lb bc, 5, 10
2014-05-22 22:13:20 +00:00
call ClearScreenArea ; Clear under name
2015-07-18 20:52:03 +00:00
coord hl, 19, 3
2014-05-22 22:13:20 +00:00
ld [hl], $78
2015-07-18 20:52:03 +00:00
coord hl, 0, 8
2015-07-19 03:49:52 +00:00
ld b, 8
ld c, 18
2014-05-22 22:13:20 +00:00
call TextBoxBorder ; Draw move container
2015-07-18 20:52:03 +00:00
coord hl, 2, 9
2015-02-08 08:17:03 +00:00
ld de, wMovesString
2014-05-22 22:13:20 +00:00
call PlaceString ; Print moves
2015-07-15 06:16:06 +00:00
ld a, [wNumMovesMinusOne]
2014-05-22 22:13:20 +00:00
inc a
ld c, a
ld a, $4
sub c
ld b, a ; Number of moves ?
2015-07-18 20:52:03 +00:00
coord hl, 11, 10
2015-07-14 07:16:19 +00:00
ld de, SCREEN_WIDTH * 2
ld a, $72 ; special P tile id
call StatusScreen_PrintPP ; Print "PP"
2014-05-22 22:13:20 +00:00
ld a, b
and a
jr z, .InitPP
2014-05-22 22:13:20 +00:00
ld c, a
ld a, "-"
2015-07-14 07:16:19 +00:00
call StatusScreen_PrintPP ; Fill the rest with --
2014-05-22 22:13:20 +00:00
.InitPP ; 12bbb
2015-02-08 02:37:40 +00:00
ld hl, wLoadedMonMoves
2015-07-18 20:52:03 +00:00
coord de, 14, 10
2015-07-15 06:16:06 +00:00
ld b, 0
2014-05-22 22:13:20 +00:00
.PrintPP ; 12bc3
ld a, [hli]
and a
jr z, .PPDone
2014-05-22 22:13:20 +00:00
push bc
push hl
push de
ld hl, wCurrentMenuItem
ld a, [hl]
push af
ld a, b
ld [hl], a
push hl
callab GetMaxPP
pop hl
pop af
ld [hl], a
pop de
pop hl
push hl
2015-07-15 06:16:06 +00:00
ld bc, wPartyMon1PP - wPartyMon1Moves - 1
2014-05-22 22:13:20 +00:00
add hl, bc
ld a, [hl]
and $3f
2015-07-15 06:16:06 +00:00
ld [wStatusScreenCurrentPP], a
2014-05-22 22:13:20 +00:00
ld h, d
ld l, e
push hl
2015-07-15 06:16:06 +00:00
ld de, wStatusScreenCurrentPP
2015-07-28 01:48:44 +00:00
lb bc, 1, 2
2014-05-22 22:13:20 +00:00
call PrintNumber
ld a, "/"
ld [hli], a
ld de, wd11e
2015-07-28 01:48:44 +00:00
lb bc, 1, 2
2014-05-22 22:13:20 +00:00
call PrintNumber
pop hl
2015-07-14 07:16:19 +00:00
ld de, SCREEN_WIDTH * 2
2014-05-22 22:13:20 +00:00
add hl, de
ld d, h
ld e, l
pop hl
pop bc
inc b
ld a, b
cp $4
jr nz, .PrintPP
2014-05-22 22:13:20 +00:00
.PPDone
2015-07-18 20:52:03 +00:00
coord hl, 9, 3
2015-07-19 03:49:52 +00:00
ld de, StatusScreenExpText
2014-05-22 22:13:20 +00:00
call PlaceString
2015-07-19 03:49:52 +00:00
ld a, [wLoadedMonLevel]
2014-05-22 22:13:20 +00:00
push af
2014-06-10 21:06:30 +00:00
cp MAX_LEVEL
jr z, .Level100
2014-05-22 22:13:20 +00:00
inc a
2015-02-08 02:37:40 +00:00
ld [wLoadedMonLevel], a ; Increase temporarily if not 100
2014-05-22 22:13:20 +00:00
.Level100
2015-07-18 20:52:03 +00:00
coord hl, 14, 6
2014-05-22 22:13:20 +00:00
ld [hl], $70 ; 1-tile "to"
inc hl
inc hl
call PrintLevel
pop af
2015-02-08 02:37:40 +00:00
ld [wLoadedMonLevel], a
ld de, wLoadedMonExp
2015-07-18 20:52:03 +00:00
coord hl, 12, 4
2015-07-28 01:48:44 +00:00
lb bc, 3, 7
2014-05-22 22:13:20 +00:00
call PrintNumber ; exp
2015-07-19 03:49:52 +00:00
call CalcExpToLevelUp
2015-02-08 02:37:40 +00:00
ld de, wLoadedMonExp
2015-07-18 20:52:03 +00:00
coord hl, 7, 6
2015-07-28 01:48:44 +00:00
lb bc, 3, 7
2015-07-19 03:49:52 +00:00
call PrintNumber ; exp needed to level up
2015-07-18 20:52:03 +00:00
coord hl, 9, 0
2015-07-14 07:16:19 +00:00
call StatusScreen_ClearName
2015-07-18 20:52:03 +00:00
coord hl, 9, 1
2015-07-14 07:16:19 +00:00
call StatusScreen_ClearName
ld a, [W_MONHDEXNUM]
ld [wd11e], a
2014-05-22 22:13:20 +00:00
call GetMonName
2015-07-18 20:52:03 +00:00
coord hl, 9, 1
2014-05-22 22:13:20 +00:00
call PlaceString
ld a, $1
2015-07-19 03:49:52 +00:00
ld [H_AUTOBGTRANSFERENABLED], a
2014-05-22 22:13:20 +00:00
call Delay3
call WaitForTextScrollButtonPress ; wait for button
pop af
2014-09-14 18:29:18 +00:00
ld [hTilesetType], a
ld hl, wd72c
2014-05-22 22:13:20 +00:00
res 1, [hl]
ld a, $77
ld [$ff24], a
call GBPalWhiteOut
jp ClearScreen
2015-07-19 03:49:52 +00:00
CalcExpToLevelUp: ; 12c86 (4:6c86)
ld a, [wLoadedMonLevel]
2014-06-10 21:06:30 +00:00
cp MAX_LEVEL
2015-07-19 03:49:52 +00:00
jr z, .atMaxLevel
2014-05-22 22:13:20 +00:00
inc a
ld d, a
callab CalcExperience
2015-02-08 02:37:40 +00:00
ld hl, wLoadedMonExp + 2
2015-07-19 03:49:52 +00:00
ld a, [hExperience + 2]
2014-05-22 22:13:20 +00:00
sub [hl]
ld [hld], a
2015-07-19 03:49:52 +00:00
ld a, [hExperience + 1]
2014-05-22 22:13:20 +00:00
sbc [hl]
ld [hld], a
2015-07-19 03:49:52 +00:00
ld a, [hExperience]
2014-05-22 22:13:20 +00:00
sbc [hl]
ld [hld], a
ret
2015-07-19 03:49:52 +00:00
.atMaxLevel
2015-02-08 02:37:40 +00:00
ld hl, wLoadedMonExp
2014-05-22 22:13:20 +00:00
xor a
ld [hli], a
ld [hli], a
ld [hl], a
ret
2015-07-19 03:49:52 +00:00
StatusScreenExpText: ; 12caf (4:6caf)
db "EXP POINTS"
next "LEVEL UP@"
2014-05-22 22:13:20 +00:00
2015-07-14 07:16:19 +00:00
StatusScreen_ClearName: ; 12cc3 (4:6cc3)
ld bc, 10
ld a, " "
2014-05-22 22:13:20 +00:00
jp FillMemory
2015-07-14 07:16:19 +00:00
StatusScreen_PrintPP: ; 12ccb (4:6ccb)
; print PP or -- c times, going down two rows each time
2014-05-22 22:13:20 +00:00
ld [hli], a
ld [hld], a
add hl, de
dec c
2015-07-14 07:16:19 +00:00
jr nz, StatusScreen_PrintPP
2014-05-22 22:13:20 +00:00
ret