Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/battle/draw_hud_pokeball_gfx.asm
1271 views
1
DrawAllPokeballs:
2
call LoadPartyPokeballGfx
3
call SetupOwnPartyPokeballs
4
ld a, [wIsInBattle]
5
dec a
6
ret z ; return if wild pokémon
7
jp SetupEnemyPartyPokeballs
8
9
DrawEnemyPokeballs:
10
call LoadPartyPokeballGfx
11
jp SetupEnemyPartyPokeballs
12
13
LoadPartyPokeballGfx:
14
ld de, PokeballTileGraphics
15
ld hl, vSprites tile $31
16
lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10
17
jp CopyVideoData
18
19
SetupOwnPartyPokeballs:
20
call PlacePlayerHUDTiles
21
ld hl, wPartyMon1
22
ld de, wPartyCount
23
call SetupPokeballs
24
ld a, $60
25
ld hl, wBaseCoordX
26
ld [hli], a
27
ld [hl], a
28
ld a, 8
29
ld [wHUDPokeballGfxOffsetX], a
30
ld hl, wShadowOAM
31
jp WritePokeballOAMData
32
33
SetupEnemyPartyPokeballs:
34
call PlaceEnemyHUDTiles
35
ld hl, wEnemyMons
36
ld de, wEnemyPartyCount
37
call SetupPokeballs
38
ld hl, wBaseCoordX
39
ld a, $48
40
ld [hli], a
41
ld [hl], $20
42
ld a, -8
43
ld [wHUDPokeballGfxOffsetX], a
44
ld hl, wShadowOAMSprite06
45
jp WritePokeballOAMData
46
47
SetupPokeballs:
48
ld a, [de]
49
push af
50
ld de, wBuffer
51
ld c, PARTY_LENGTH
52
ld a, $34 ; empty pokeball
53
.emptyloop
54
ld [de], a
55
inc de
56
dec c
57
jr nz, .emptyloop
58
pop af
59
ld de, wBuffer
60
.monloop
61
push af
62
call PickPokeball
63
inc de
64
pop af
65
dec a
66
jr nz, .monloop
67
ret
68
69
PickPokeball:
70
inc hl
71
ld a, [hli]
72
and a
73
jr nz, .alive
74
ld a, [hl]
75
and a
76
ld b, $33 ; crossed ball (fainted)
77
jr z, .done_fainted
78
.alive
79
inc hl
80
inc hl
81
ld a, [hl] ; status
82
and a
83
ld b, $32 ; black ball (status)
84
jr nz, .done
85
dec b ; regular ball
86
jr .done
87
.done_fainted
88
inc hl
89
inc hl
90
.done
91
ld a, b
92
ld [de], a
93
ld bc, wPartyMon2 - wPartyMon1Status
94
add hl, bc ; next mon struct
95
ret
96
97
WritePokeballOAMData:
98
ld de, wBuffer
99
ld c, PARTY_LENGTH
100
.loop
101
ld a, [wBaseCoordY]
102
ld [hli], a
103
ld a, [wBaseCoordX]
104
ld [hli], a
105
ld a, [de]
106
ld [hli], a
107
xor a
108
ld [hli], a
109
ld a, [wBaseCoordX]
110
ld b, a
111
ld a, [wHUDPokeballGfxOffsetX]
112
add b
113
ld [wBaseCoordX], a
114
inc de
115
dec c
116
jr nz, .loop
117
ret
118
119
PlacePlayerHUDTiles:
120
ld hl, PlayerBattleHUDGraphicsTiles
121
ld de, wHUDGraphicsTiles
122
ld bc, $3
123
call CopyData
124
hlcoord 18, 10
125
ld de, -1
126
jr PlaceHUDTiles
127
128
PlayerBattleHUDGraphicsTiles:
129
; The tile numbers for specific parts of the battle display for the player's pokemon
130
db $73 ; unused ($73 is hardcoded into the routine that uses these bytes)
131
db $77 ; lower-right corner tile of the HUD
132
db $6F ; lower-left triangle tile of the HUD
133
134
PlaceEnemyHUDTiles:
135
ld hl, EnemyBattleHUDGraphicsTiles
136
ld de, wHUDGraphicsTiles
137
ld bc, $3
138
call CopyData
139
hlcoord 1, 2
140
ld de, $1
141
jr PlaceHUDTiles
142
143
EnemyBattleHUDGraphicsTiles:
144
; The tile numbers for specific parts of the battle display for the enemy
145
db $73 ; unused ($73 is hardcoded in the routine that uses these bytes)
146
db $74 ; lower-left corner tile of the HUD
147
db $78 ; lower-right triangle tile of the HUD
148
149
PlaceHUDTiles:
150
ld [hl], $73
151
ld bc, SCREEN_WIDTH
152
add hl, bc
153
ld a, [wHUDGraphicsTiles + 1] ; leftmost tile
154
ld [hl], a
155
ld a, 8
156
.loop
157
add hl, de
158
ld [hl], $76
159
dec a
160
jr nz, .loop
161
add hl, de
162
ld a, [wHUDGraphicsTiles + 2] ; rightmost tile
163
ld [hl], a
164
ret
165
166
SetupPlayerAndEnemyPokeballs:
167
call LoadPartyPokeballGfx
168
ld hl, wPartyMons
169
ld de, wPartyCount
170
call SetupPokeballs
171
ld hl, wBaseCoordX
172
ld a, $50
173
ld [hli], a
174
ld [hl], $40
175
ld a, 8
176
ld [wHUDPokeballGfxOffsetX], a
177
ld hl, wShadowOAM
178
call WritePokeballOAMData
179
ld hl, wEnemyMons
180
ld de, wEnemyPartyCount
181
call SetupPokeballs
182
ld hl, wBaseCoordX
183
ld a, $50
184
ld [hli], a
185
ld [hl], $68
186
ld hl, wShadowOAMSprite06
187
jp WritePokeballOAMData
188
189
; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (fainted) and pokeball slot (no mon)
190
PokeballTileGraphics::
191
INCBIN "gfx/battle/balls.2bpp"
192
PokeballTileGraphicsEnd:
193
194