-
Notifications
You must be signed in to change notification settings - Fork 817
/
pokemon.asm
323 lines (268 loc) · 3.92 KB
/
pokemon.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
IsAPokemon::
; Return carry if species a is not a Pokemon.
and a
jr z, .NotAPokemon
cp EGG
jr z, .Pokemon
cp NUM_POKEMON + 1
jr c, .Pokemon
.NotAPokemon:
scf
ret
.Pokemon:
and a
ret
DrawBattleHPBar::
; Draw an HP bar d tiles long at hl
; Fill it up to e pixels
push hl
push de
push bc
; Place 'HP:'
ld a, $60
ld [hli], a
ld a, $61
ld [hli], a
; Draw a template
push hl
ld a, $62 ; empty bar
.template
ld [hli], a
dec d
jr nz, .template
ld a, $6b ; bar end
add b
ld [hl], a
pop hl
; Safety check # pixels
ld a, e
and a
jr nz, .fill
ld a, c
and a
jr z, .done
ld e, 1
.fill
; Keep drawing tiles until pixel length is reached
ld a, e
sub TILE_WIDTH
jr c, .lastbar
ld e, a
ld a, $6a ; full bar
ld [hli], a
ld a, e
and a
jr z, .done
jr .fill
.lastbar
ld a, $62 ; empty bar
add e ; + e
ld [hl], a
.done
pop bc
pop de
pop hl
ret
PrepMonFrontpic::
ld a, $1
ld [wBoxAlignment], a
_PrepMonFrontpic::
ld a, [wCurPartySpecies]
call IsAPokemon
jr c, .not_pokemon
push hl
ld de, vTiles2
predef GetMonFrontpic
pop hl
xor a
ldh [hGraphicStartTile], a
lb bc, 7, 7
predef PlaceGraphic
xor a
ld [wBoxAlignment], a
ret
.not_pokemon
xor a
ld [wBoxAlignment], a
inc a
ld [wCurPartySpecies], a
ret
PlayStereoCry::
push af
ld a, 1
ld [wStereoPanningMask], a
pop af
call _PlayMonCry
call WaitSFX
ret
PlayStereoCry2::
; Don't wait for the cry to end.
; Used during pic animations.
push af
ld a, 1
ld [wStereoPanningMask], a
pop af
jp _PlayMonCry
PlayMonCry::
call PlayMonCry2
call WaitSFX
ret
PlayMonCry2::
; Don't wait for the cry to end.
push af
xor a
ld [wStereoPanningMask], a
ld [wCryTracks], a
pop af
call _PlayMonCry
ret
_PlayMonCry::
push hl
push de
push bc
call GetCryIndex
jr c, .done
ld e, c
ld d, b
call PlayCry
.done
pop bc
pop de
pop hl
ret
LoadCry::
; Load cry bc.
call GetCryIndex
ret c
ldh a, [hROMBank]
push af
ld a, BANK(PokemonCries)
rst Bankswitch
ld hl, PokemonCries
rept MON_CRY_LENGTH
add hl, bc
endr
ld e, [hl]
inc hl
ld d, [hl]
inc hl
ld a, [hli]
ld [wCryPitch], a
ld a, [hli]
ld [wCryPitch + 1], a
ld a, [hli]
ld [wCryLength], a
ld a, [hl]
ld [wCryLength + 1], a
pop af
rst Bankswitch
and a
ret
GetCryIndex::
and a
jr z, .no
cp NUM_POKEMON + 1
jr nc, .no
dec a
ld c, a
ld b, 0
and a
ret
.no
scf
ret
PrintLevel::
; Print wTempMonLevel at hl
ld a, [wTempMonLevel]
ld [hl], "<LV>"
inc hl
; How many digits?
ld c, 2
cp 100 ; This is distinct from MAX_LEVEL.
jr c, Print8BitNumLeftAlign
; 3-digit numbers overwrite the :L.
dec hl
inc c
jr Print8BitNumLeftAlign
PrintLevel_Force3Digits::
; Print :L and all 3 digits
ld [hl], "<LV>"
inc hl
ld c, 3
Print8BitNumLeftAlign::
ld [wTextDecimalByte], a
ld de, wTextDecimalByte
ld b, PRINTNUM_LEFTALIGN | 1
jp PrintNum
GetNthMove:: ; unreferenced
ld hl, wListMoves_MoveIndicesBuffer
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
ret
GetBaseData::
push bc
push de
push hl
ldh a, [hROMBank]
push af
ld a, BANK(BaseData)
rst Bankswitch
; Egg doesn't have BaseData
ld a, [wCurSpecies]
cp EGG
jr z, .egg
; Get BaseData
dec a
ld bc, BASE_DATA_SIZE
ld hl, BaseData
call AddNTimes
ld de, wCurBaseData
ld bc, BASE_DATA_SIZE
call CopyBytes
jr .end
.egg
ld de, UnusedEggPic
; Sprite dimensions
ld b, $55 ; 5x5
ld hl, wBasePicSize
ld [hl], b
; Beta front and back sprites
; (see pokegold-spaceworld's data/pokemon/base_stats/*)
ld hl, wBaseUnusedFrontpic
ld [hl], e
inc hl
ld [hl], d
inc hl
ld [hl], e
inc hl
ld [hl], d
jr .end ; useless
.end
; Replace Pokedex # with species
ld a, [wCurSpecies]
ld [wBaseDexNo], a
pop af
rst Bankswitch
pop hl
pop de
pop bc
ret
GetCurNickname::
ld a, [wCurPartyMon]
ld hl, wPartyMonNicknames
GetNickname::
; Get nickname a from list hl.
push hl
push bc
call SkipNames
ld de, wStringBuffer1
push de
ld bc, MON_NAME_LENGTH
call CopyBytes
pop de
callfar CorrectNickErrors
pop bc
pop hl
ret