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
|
AnimatePartyMon_ForceSpeed1:
xor a
ld [wCurrentMenuItem], a
ld b, a
inc a
jr GetAnimationSpeed
; wPartyMenuHPBarColors contains the party mon's health bar colors
; 0: green
; 1: yellow
; 2: red
AnimatePartyMon::
ld hl, wPartyMenuHPBarColors
ld a, [wCurrentMenuItem]
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
GetAnimationSpeed:
ld c, a
ld hl, PartyMonSpeeds
add hl, bc
ld a, [wOnSGB]
xor $1
add [hl]
ld c, a
add a
ld b, a
ld a, [wAnimCounter]
and a
jr z, .resetSprites
cp c
jr z, .animateSprite
.incTimer
inc a
cp b
jr nz, .skipResetTimer
xor a ; reset timer
.skipResetTimer
ld [wAnimCounter], a
jp DelayFrame
.resetSprites
push bc
ld hl, wMonPartySpritesSavedOAM
ld de, wOAMBuffer
ld bc, $60
call CopyData
pop bc
xor a
jr .incTimer
.animateSprite
push bc
ld hl, wOAMBuffer + $02 ; OAM tile id
ld bc, $10
ld a, [wCurrentMenuItem]
call AddNTimes
ld c, ICONOFFSET
ld a, [hl]
cp ICON_BALL << 2
jr z, .editCoords
cp ICON_HELIX << 2
jr nz, .editTileIDS
; ICON_BALL and ICON_HELIX only shake up and down
.editCoords
dec hl
dec hl ; dec hl to the OAM y coord
ld c, $1 ; amount to increase the y coord by
; otherwise, load a second sprite frame
.editTileIDS
ld b, $4
ld de, $4
.loop
ld a, [hl]
add c
ld [hl], a
add hl, de
dec b
jr nz, .loop
pop bc
ld a, c
jr .incTimer
; Party mon animations cycle between 2 frames.
; The members of the PartyMonSpeeds array specify the number of V-blanks
; that each frame lasts for green HP, yellow HP, and red HP in order.
; On the naming screen, the yellow HP speed is always used.
PartyMonSpeeds:
db 5, 16, 32
LoadMonPartySpriteGfx:
; Load mon party sprite tile patterns into VRAM during V-blank.
ld hl, MonPartySpritePointers
ld a, $1c
LoadAnimSpriteGfx:
; Load animated sprite tile patterns into VRAM during V-blank. hl is the address
; of an array of structures that contain arguments for CopyVideoData and a is
; the number of structures in the array.
ld bc, $0
.loop
push af
push bc
push hl
add hl, bc
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [hli]
ld h, [hl]
ld l, a
call CopyVideoData
pop hl
pop bc
ld a, $6
add c
ld c, a
pop af
dec a
jr nz, .loop
ret
LoadMonPartySpriteGfxWithLCDDisabled:
; Load mon party sprite tile patterns into VRAM immediately by disabling the
; LCD.
call DisableLCD
ld hl, MonPartySpritePointers
ld a, $1c
ld bc, $0
.loop
push af
push bc
push hl
add hl, bc
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
push de
ld a, [hli]
ld c, a
swap c
ld b, $0
ld a, [hli]
ld e, [hl]
inc hl
ld d, [hl]
pop hl
call FarCopyData2
pop hl
pop bc
ld a, $6
add c
ld c, a
pop af
dec a
jr nz, .loop
jp EnableLCD
INCLUDE "data/icon_pointers.asm"
WriteMonPartySpriteOAMByPartyIndex:
; Write OAM blocks for the party mon in [hPartyMonIndex].
push hl
push de
push bc
ldh a, [hPartyMonIndex]
ld hl, wPartySpecies
ld e, a
ld d, 0
add hl, de
ld a, [hl]
call GetPartyMonSpriteID
ld [wOAMBaseTile], a
call WriteMonPartySpriteOAM
pop bc
pop de
pop hl
ret
WriteMonPartySpriteOAMBySpecies:
; Write OAM blocks for the party sprite of the species in
; [wMonPartySpriteSpecies].
xor a
ldh [hPartyMonIndex], a
ld a, [wMonPartySpriteSpecies]
call GetPartyMonSpriteID
ld [wOAMBaseTile], a
jr WriteMonPartySpriteOAM
UnusedPartyMonSpriteFunction:
; This function is unused and doesn't appear to do anything useful. It looks
; like it may have been intended to load the tile patterns and OAM data for
; the mon party sprite associated with the species in [wcf91].
; However, its calculations are off and it loads garbage data.
ld a, [wcf91]
call GetPartyMonSpriteID
push af
ld hl, vSprites tile $00
call .LoadTilePatterns
pop af
add $54
ld hl, vSprites tile $04
call .LoadTilePatterns
xor a
ld [wMonPartySpriteSpecies], a
jr WriteMonPartySpriteOAMBySpecies
.LoadTilePatterns
push hl
add a
ld c, a
ld b, 0
ld hl, MonPartySpritePointers
add hl, bc
add hl, bc
add hl, bc
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
pop hl
jp CopyVideoData
WriteMonPartySpriteOAM:
; Write the OAM blocks for the first animation frame into the OAM buffer and
; make a copy at wMonPartySpritesSavedOAM.
push af
ld c, $10
ld h, HIGH(wOAMBuffer)
ldh a, [hPartyMonIndex]
swap a
ld l, a
add $10
ld b, a
pop af
cp ICON_HELIX << 2
jr z, .helix
call WriteSymmetricMonPartySpriteOAM
jr .makeCopy
.helix
call WriteAsymmetricMonPartySpriteOAM
; Make a copy of the OAM buffer with the first animation frame written so that
; we can flip back to it from the second frame by copying it back.
.makeCopy
ld hl, wOAMBuffer
ld de, wMonPartySpritesSavedOAM
ld bc, $60
jp CopyData
GetPartyMonSpriteID:
ld [wd11e], a
predef IndexToPokedex
ld a, [wd11e]
ld c, a
dec a
srl a
ld hl, MonPartyData
ld e, a
ld d, 0
add hl, de
ld a, [hl]
bit 0, c
jr nz, .skipSwap
swap a ; use lower nybble if pokedex num is even
.skipSwap
and $f0
srl a ; value == ICON constant << 2
srl a
ret
INCLUDE "data/pokemon/menu_icons.asm"
INC_FRAME_1 EQUS "0, $20"
INC_FRAME_2 EQUS "$20, $20"
BugIconFrame1: INCBIN "gfx/icons/bug.2bpp", INC_FRAME_1
PlantIconFrame1: INCBIN "gfx/icons/plant.2bpp", INC_FRAME_1
BugIconFrame2: INCBIN "gfx/icons/bug.2bpp", INC_FRAME_2
PlantIconFrame2: INCBIN "gfx/icons/plant.2bpp", INC_FRAME_2
SnakeIconFrame1: INCBIN "gfx/icons/snake.2bpp", INC_FRAME_1
QuadrupedIconFrame1: INCBIN "gfx/icons/quadruped.2bpp", INC_FRAME_1
SnakeIconFrame2: INCBIN "gfx/icons/snake.2bpp", INC_FRAME_2
QuadrupedIconFrame2: INCBIN "gfx/icons/quadruped.2bpp", INC_FRAME_2
TradeBubbleIconGFX: INCBIN "gfx/trade/bubble.2bpp"
|