Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/gfx/mon_icons.asm
1271 views
1
AnimatePartyMon_ForceSpeed1:
2
xor a
3
ld [wCurrentMenuItem], a
4
ld b, a
5
inc a
6
jr GetAnimationSpeed
7
8
; wPartyMenuHPBarColors contains the party mon's health bar colors
9
; 0: green
10
; 1: yellow
11
; 2: red
12
AnimatePartyMon::
13
ld hl, wPartyMenuHPBarColors
14
ld a, [wCurrentMenuItem]
15
ld c, a
16
ld b, 0
17
add hl, bc
18
ld a, [hl]
19
20
GetAnimationSpeed:
21
ld c, a
22
ld hl, PartyMonSpeeds
23
add hl, bc
24
ld a, [wOnSGB]
25
xor $1
26
add [hl]
27
ld c, a
28
add a
29
ld b, a
30
ld a, [wAnimCounter]
31
and a
32
jr z, .resetSprites
33
cp c
34
jr z, .animateSprite
35
.incTimer
36
inc a
37
cp b
38
jr nz, .skipResetTimer
39
xor a ; reset timer
40
.skipResetTimer
41
ld [wAnimCounter], a
42
jp DelayFrame
43
.resetSprites
44
push bc
45
ld hl, wMonPartySpritesSavedOAM
46
ld de, wShadowOAM
47
ld bc, $60
48
call CopyData
49
pop bc
50
xor a
51
jr .incTimer
52
.animateSprite
53
push bc
54
ld hl, wShadowOAMSprite00TileID
55
ld bc, $10
56
ld a, [wCurrentMenuItem]
57
call AddNTimes
58
ld c, ICONOFFSET
59
ld a, [hl]
60
cp ICON_BALL << 2
61
jr z, .editCoords
62
cp ICON_HELIX << 2
63
jr nz, .editTileIDS
64
; ICON_BALL and ICON_HELIX only shake up and down
65
.editCoords
66
dec hl
67
dec hl ; dec hl to the OAM y coord
68
ld c, $1 ; amount to increase the y coord by
69
; otherwise, load a second sprite frame
70
.editTileIDS
71
ld b, $4
72
ld de, $4
73
.loop
74
ld a, [hl]
75
add c
76
ld [hl], a
77
add hl, de
78
dec b
79
jr nz, .loop
80
pop bc
81
ld a, c
82
jr .incTimer
83
84
; Party mon animations cycle between 2 frames.
85
; The members of the PartyMonSpeeds array specify the number of V-blanks
86
; that each frame lasts for green HP, yellow HP, and red HP in order.
87
; On the naming screen, the yellow HP speed is always used.
88
PartyMonSpeeds:
89
db 5, 16, 32
90
91
LoadMonPartySpriteGfx:
92
; Load mon party sprite tile patterns into VRAM during V-blank.
93
ld hl, MonPartySpritePointers
94
ld a, $1c
95
96
LoadAnimSpriteGfx:
97
; Load animated sprite tile patterns into VRAM during V-blank. hl is the address
98
; of an array of structures that contain arguments for CopyVideoData and a is
99
; the number of structures in the array.
100
ld bc, $0
101
.loop
102
push af
103
push bc
104
push hl
105
add hl, bc
106
ld a, [hli]
107
ld e, a
108
ld a, [hli]
109
ld d, a
110
ld a, [hli]
111
ld c, a
112
ld a, [hli]
113
ld b, a
114
ld a, [hli]
115
ld h, [hl]
116
ld l, a
117
call CopyVideoData
118
pop hl
119
pop bc
120
ld a, $6
121
add c
122
ld c, a
123
pop af
124
dec a
125
jr nz, .loop
126
ret
127
128
LoadMonPartySpriteGfxWithLCDDisabled:
129
; Load mon party sprite tile patterns into VRAM immediately by disabling the
130
; LCD.
131
call DisableLCD
132
ld hl, MonPartySpritePointers
133
ld a, $1c
134
ld bc, $0
135
.loop
136
push af
137
push bc
138
push hl
139
add hl, bc
140
ld a, [hli]
141
ld e, a
142
ld a, [hli]
143
ld d, a
144
push de
145
ld a, [hli]
146
ld c, a
147
swap c
148
ld b, $0
149
ld a, [hli]
150
ld e, [hl]
151
inc hl
152
ld d, [hl]
153
pop hl
154
call FarCopyData2
155
pop hl
156
pop bc
157
ld a, $6
158
add c
159
ld c, a
160
pop af
161
dec a
162
jr nz, .loop
163
jp EnableLCD
164
165
INCLUDE "data/icon_pointers.asm"
166
167
WriteMonPartySpriteOAMByPartyIndex:
168
; Write OAM blocks for the party mon in [hPartyMonIndex].
169
push hl
170
push de
171
push bc
172
ldh a, [hPartyMonIndex]
173
ld hl, wPartySpecies
174
ld e, a
175
ld d, 0
176
add hl, de
177
ld a, [hl]
178
call GetPartyMonSpriteID
179
ld [wOAMBaseTile], a
180
call WriteMonPartySpriteOAM
181
pop bc
182
pop de
183
pop hl
184
ret
185
186
WriteMonPartySpriteOAMBySpecies:
187
; Write OAM blocks for the party sprite of the species in
188
; [wMonPartySpriteSpecies].
189
xor a
190
ldh [hPartyMonIndex], a
191
ld a, [wMonPartySpriteSpecies]
192
call GetPartyMonSpriteID
193
ld [wOAMBaseTile], a
194
jr WriteMonPartySpriteOAM
195
196
UnusedPartyMonSpriteFunction:
197
; This function is unused and doesn't appear to do anything useful. It looks
198
; like it may have been intended to load the tile patterns and OAM data for
199
; the mon party sprite associated with the species in [wCurPartySpecies].
200
; However, its calculations are off and it loads garbage data.
201
ld a, [wCurPartySpecies]
202
call GetPartyMonSpriteID
203
push af
204
ld hl, vSprites tile $00
205
call .LoadTilePatterns
206
pop af
207
add $54
208
ld hl, vSprites tile $04
209
call .LoadTilePatterns
210
xor a
211
ld [wMonPartySpriteSpecies], a
212
jr WriteMonPartySpriteOAMBySpecies
213
214
.LoadTilePatterns
215
push hl
216
add a
217
ld c, a
218
ld b, 0
219
ld hl, MonPartySpritePointers
220
add hl, bc
221
add hl, bc
222
add hl, bc
223
ld a, [hli]
224
ld e, a
225
ld a, [hli]
226
ld d, a
227
ld a, [hli]
228
ld c, a
229
ld a, [hli]
230
ld b, a
231
pop hl
232
jp CopyVideoData
233
234
WriteMonPartySpriteOAM:
235
; Write the OAM blocks for the first animation frame into the OAM buffer and
236
; make a copy at wMonPartySpritesSavedOAM.
237
push af
238
ld c, $10
239
ld h, HIGH(wShadowOAM)
240
ldh a, [hPartyMonIndex]
241
swap a
242
ld l, a
243
add $10
244
ld b, a
245
pop af
246
cp ICON_HELIX << 2
247
jr z, .helix
248
call WriteSymmetricMonPartySpriteOAM
249
jr .makeCopy
250
.helix
251
call WriteAsymmetricMonPartySpriteOAM
252
; Make a copy of the OAM buffer with the first animation frame written so that
253
; we can flip back to it from the second frame by copying it back.
254
.makeCopy
255
ld hl, wShadowOAM
256
ld de, wMonPartySpritesSavedOAM
257
ld bc, $60
258
jp CopyData
259
260
GetPartyMonSpriteID:
261
ld [wPokedexNum], a
262
predef IndexToPokedex
263
ld a, [wPokedexNum]
264
ld c, a
265
dec a
266
srl a
267
ld hl, MonPartyData
268
ld e, a
269
ld d, 0
270
add hl, de
271
ld a, [hl]
272
bit 0, c ; even or odd?
273
jr nz, .skipSwap
274
swap a ; use lower nybble if pokedex num is even
275
.skipSwap
276
and $f0
277
srl a ; value == ICON constant << 2
278
srl a
279
ret
280
281
INCLUDE "data/pokemon/menu_icons.asm"
282
283
DEF INC_FRAME_1 EQUS "0, $20"
284
DEF INC_FRAME_2 EQUS "$20, $20"
285
286
BugIconFrame1: INCBIN "gfx/icons/bug.2bpp", INC_FRAME_1
287
PlantIconFrame1: INCBIN "gfx/icons/plant.2bpp", INC_FRAME_1
288
BugIconFrame2: INCBIN "gfx/icons/bug.2bpp", INC_FRAME_2
289
PlantIconFrame2: INCBIN "gfx/icons/plant.2bpp", INC_FRAME_2
290
SnakeIconFrame1: INCBIN "gfx/icons/snake.2bpp", INC_FRAME_1
291
QuadrupedIconFrame1: INCBIN "gfx/icons/quadruped.2bpp", INC_FRAME_1
292
SnakeIconFrame2: INCBIN "gfx/icons/snake.2bpp", INC_FRAME_2
293
QuadrupedIconFrame2: INCBIN "gfx/icons/quadruped.2bpp", INC_FRAME_2
294
295
TradeBubbleIconGFX: INCBIN "gfx/trade/bubble.2bpp"
296
297