-
Notifications
You must be signed in to change notification settings - Fork 995
/
status_screen.asm
482 lines (463 loc) · 8.18 KB
/
status_screen.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
DrawHP:
; Draws the HP bar in the stats screen
call GetPredefRegisters
ld a, $1
jr DrawHP_
DrawHP2:
; Draws the HP bar in the party screen
call GetPredefRegisters
ld a, $2
DrawHP_:
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
ldh a, [hUILayoutFlags]
bit BIT_PARTY_MENU_HP_BAR, 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
lb bc, 2, 3
call PrintNumber
ld a, "/"
ld [hli], a
ld de, wLoadedMonMaxHP
lb bc, 2, 3
call PrintNumber
pop hl
pop de
ret
; Predef 0x37
StatusScreen:
call LoadMonData
ld a, [wMonDataLocation]
cp BOX_DATA
jr c, .DontRecalculate
; mon is in a box or daycare
ld a, [wLoadedMonBoxLevel]
ld [wLoadedMonLevel], a
ld [wCurEnemyLevel], a
ld hl, wLoadedMonHPExp - 1
ld de, wLoadedMonStats
ld b, $1
call CalcStats ; Recalculate stats
.DontRecalculate
ld hl, wStatusFlags2
set BIT_NO_AUDIO_FADE_OUT, [hl]
ld a, $33
ldh [rNR50], a ; Reduce the volume
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
call LoadHpBarAndStatusTilePatterns
ld de, BattleHudTiles1 ; source
ld hl, vChars2 tile $6d ; dest
lb bc, BANK(BattleHudTiles1), 3
call CopyVideoDataDouble ; ·│ :L and halfarrow line end
ld de, BattleHudTiles2
ld hl, vChars2 tile $78
lb bc, BANK(BattleHudTiles2), 1
call CopyVideoDataDouble ; │
ld de, BattleHudTiles3
ld hl, vChars2 tile $76
lb bc, BANK(BattleHudTiles3), 2
call CopyVideoDataDouble ; ─ ┘
ld de, PTile
ld hl, vChars2 tile $72
lb bc, BANK(PTile), 1
call CopyVideoDataDouble ; bold P (for PP)
ldh a, [hTileAnimations]
push af
xor a
ldh [hTileAnimations], a
hlcoord 19, 1
lb bc, 6, 10
call DrawLineBox ; Draws the box around name, HP and status
ld de, -6
add hl, de
ld [hl], "<DOT>"
dec hl
ld [hl], "№"
hlcoord 19, 9
lb bc, 8, 6
call DrawLineBox ; Draws the box around types, ID No. and OT
hlcoord 10, 9
ld de, Type1Text
call PlaceString ; "TYPE1/"
hlcoord 11, 3
predef DrawHP
ld hl, wStatusScreenHPBarColor
call GetHealthBarColor
ld b, SET_PAL_STATUS_SCREEN
call RunPaletteCommand
hlcoord 16, 6
ld de, wLoadedMonStatus
call PrintStatusCondition
jr nz, .StatusWritten
hlcoord 16, 6
ld de, OKText
call PlaceString ; "OK"
.StatusWritten
hlcoord 9, 6
ld de, StatusText
call PlaceString ; "STATUS/"
hlcoord 14, 2
call PrintLevel ; Pokémon level
ld a, [wMonHIndex]
ld [wPokedexNum], a
ld [wCurSpecies], a
predef IndexToPokedex
hlcoord 3, 7
ld de, wPokedexNum
lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; Pokémon no.
hlcoord 11, 10
predef PrintMonType
ld hl, NamePointers2
call .GetStringPointer
ld d, h
ld e, l
hlcoord 9, 1
call PlaceString ; Pokémon name
ld hl, OTPointers
call .GetStringPointer
ld d, h
ld e, l
hlcoord 12, 16
call PlaceString ; OT
hlcoord 12, 14
ld de, wLoadedMonOTID
lb bc, LEADING_ZEROES | 2, 5
call PrintNumber ; ID Number
ld d, $0
call PrintStatsBox
call Delay3
call GBPalNormal
hlcoord 1, 0
call LoadFlippedFrontSpriteByMonIndex ; draw Pokémon picture
ld a, [wCurPartySpecies]
call PlayCry
call WaitForTextScrollButtonPress
pop af
ldh [hTileAnimations], a
ret
.GetStringPointer
ld a, [wMonDataLocation]
add a
ld c, a
ld b, 0
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wMonDataLocation]
cp DAYCARE_DATA
ret z
ld a, [wWhichPokemon]
jp SkipFixedLengthTextEntries
OTPointers:
dw wPartyMonOT
dw wEnemyMonOT
dw wBoxMonOT
dw wDayCareMonOT
NamePointers2:
dw wPartyMonNicks
dw wEnemyMonNicks
dw wBoxMonNicks
dw wDayCareMonName
Type1Text:
db "TYPE1/"
next ""
; fallthrough
Type2Text:
db "TYPE2/"
next ""
; fallthrough
IDNoText:
db "<ID>№/"
next ""
; fallthrough
OTText:
db "OT/"
next "@"
StatusText:
db "STATUS/@"
OKText:
db "OK@"
; Draws a line starting from hl high b and wide c
DrawLineBox:
ld de, SCREEN_WIDTH ; New line
.PrintVerticalLine
ld [hl], $78 ; │
add hl, de
dec b
jr nz, .PrintVerticalLine
ld [hl], $77 ; ┘
dec hl
.PrintHorizLine
ld [hl], $76 ; ─
dec hl
dec c
jr nz, .PrintHorizLine
ld [hl], $6f ; ← (halfarrow ending)
ret
PTile: INCBIN "gfx/font/P.1bpp"
PrintStatsBox:
ld a, d
and a ; a is 0 from the status screen
jr nz, .DifferentBox
hlcoord 0, 8
ld b, 8
ld c, 8
call TextBoxBorder ; Draws the box
hlcoord 1, 9 ; Start printing stats from here
ld bc, $19 ; Number offset
jr .PrintStats
.DifferentBox
hlcoord 9, 2
ld b, 8
ld c, 9
call TextBoxBorder
hlcoord 11, 3
ld bc, $18
.PrintStats
push bc
push hl
ld de, StatsText
call PlaceString
pop hl
pop bc
add hl, bc
ld de, wLoadedMonAttack
lb bc, 2, 3
call PrintStat
ld de, wLoadedMonDefense
call PrintStat
ld de, wLoadedMonSpeed
call PrintStat
ld de, wLoadedMonSpecial
jp PrintNumber
PrintStat:
push hl
call PrintNumber
pop hl
ld de, SCREEN_WIDTH * 2
add hl, de
ret
StatsText:
db "ATTACK"
next "DEFENSE"
next "SPEED"
next "SPECIAL@"
StatusScreen2:
ldh a, [hTileAnimations]
push af
xor a
ldh [hTileAnimations], a
ldh [hAutoBGTransferEnabled], a
ld bc, NUM_MOVES + 1
ld hl, wMoves
call FillMemory
ld hl, wLoadedMonMoves
ld de, wMoves
ld bc, NUM_MOVES
call CopyData
callfar FormatMovesString
hlcoord 9, 2
lb bc, 5, 10
call ClearScreenArea ; Clear under name
hlcoord 19, 3
ld [hl], $78
hlcoord 0, 8
ld b, 8
ld c, 18
call TextBoxBorder ; Draw move container
hlcoord 2, 9
ld de, wMovesString
call PlaceString ; Print moves
ld a, [wNumMovesMinusOne]
inc a
ld c, a
ld a, $4
sub c
ld b, a ; Number of moves ?
hlcoord 11, 10
ld de, SCREEN_WIDTH * 2
ld a, "<BOLD_P>"
call StatusScreen_PrintPP ; Print "PP"
ld a, b
and a
jr z, .InitPP
ld c, a
ld a, "-"
call StatusScreen_PrintPP ; Fill the rest with --
.InitPP
ld hl, wLoadedMonMoves
decoord 14, 10
ld b, 0
.PrintPP
ld a, [hli]
and a
jr z, .PPDone
push bc
push hl
push de
ld hl, wCurrentMenuItem
ld a, [hl]
push af
ld a, b
ld [hl], a
push hl
callfar GetMaxPP
pop hl
pop af
ld [hl], a
pop de
pop hl
push hl
ld bc, wPartyMon1PP - wPartyMon1Moves - 1
add hl, bc
ld a, [hl]
and $3f
ld [wStatusScreenCurrentPP], a
ld h, d
ld l, e
push hl
ld de, wStatusScreenCurrentPP
lb bc, 1, 2
call PrintNumber
ld a, "/"
ld [hli], a
ld de, wMaxPP
lb bc, 1, 2
call PrintNumber
pop hl
ld de, SCREEN_WIDTH * 2
add hl, de
ld d, h
ld e, l
pop hl
pop bc
inc b
ld a, b
cp $4
jr nz, .PrintPP
.PPDone
hlcoord 9, 3
ld de, StatusScreenExpText
call PlaceString
ld a, [wLoadedMonLevel]
push af
cp MAX_LEVEL
jr z, .Level100
inc a
ld [wLoadedMonLevel], a ; Increase temporarily if not 100
.Level100
hlcoord 14, 6
ld [hl], "<to>"
inc hl
inc hl
call PrintLevel
pop af
ld [wLoadedMonLevel], a
ld de, wLoadedMonExp
hlcoord 12, 4
lb bc, 3, 7
call PrintNumber ; exp
call CalcExpToLevelUp
ld de, wLoadedMonExp
hlcoord 7, 6
lb bc, 3, 7
call PrintNumber ; exp needed to level up
hlcoord 9, 0
call StatusScreen_ClearName
hlcoord 9, 1
call StatusScreen_ClearName
ld a, [wMonHIndex]
ld [wNamedObjectIndex], a
call GetMonName
hlcoord 9, 1
call PlaceString
ld a, $1
ldh [hAutoBGTransferEnabled], a
call Delay3
call WaitForTextScrollButtonPress ; wait for button
pop af
ldh [hTileAnimations], a
ld hl, wStatusFlags2
res BIT_NO_AUDIO_FADE_OUT, [hl]
ld a, $77
ldh [rNR50], a
call GBPalWhiteOut
jp ClearScreen
CalcExpToLevelUp:
ld a, [wLoadedMonLevel]
cp MAX_LEVEL
jr z, .atMaxLevel
inc a
ld d, a
callfar CalcExperience
ld hl, wLoadedMonExp + 2
ldh a, [hExperience + 2]
sub [hl]
ld [hld], a
ldh a, [hExperience + 1]
sbc [hl]
ld [hld], a
ldh a, [hExperience]
sbc [hl]
ld [hld], a
ret
.atMaxLevel
ld hl, wLoadedMonExp
xor a
ld [hli], a
ld [hli], a
ld [hl], a
ret
StatusScreenExpText:
db "EXP POINTS"
next "LEVEL UP@"
StatusScreen_ClearName:
ld bc, 10
ld a, " "
jp FillMemory
StatusScreen_PrintPP:
; print PP or -- c times, going down two rows each time
ld [hli], a
ld [hld], a
add hl, de
dec c
jr nz, StatusScreen_PrintPP
ret