pokered/engine/battle/draw_hud_pokeball_gfx.asm

193 lines
3.6 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
DrawAllPokeballs:
call LoadPartyPokeballGfx
call SetupOwnPartyPokeballs
2015-08-31 02:38:41 +00:00
ld a, [wIsInBattle]
dec a
ret z ; return if wild pokémon
jp SetupEnemyPartyPokeballs
2016-06-12 00:24:04 +00:00
DrawEnemyPokeballs:
call LoadPartyPokeballGfx
jp SetupEnemyPartyPokeballs
2016-06-12 00:24:04 +00:00
LoadPartyPokeballGfx:
ld de, PokeballTileGraphics
ld hl, vSprites + $310
2015-08-10 04:56:20 +00:00
lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10
jp CopyVideoData
2016-06-12 00:24:04 +00:00
SetupOwnPartyPokeballs:
call PlacePlayerHUDTiles
ld hl, wPartyMon1
ld de, wPartyCount
call SetupPokeballs
ld a, $60
2015-08-31 02:38:41 +00:00
ld hl, wBaseCoordX
ld [hli], a
ld [hl], a
2015-07-23 13:07:12 +00:00
ld a, 8
ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer
jp WritePokeballOAMData
2016-06-12 00:24:04 +00:00
SetupEnemyPartyPokeballs:
call PlaceEnemyHUDTiles
ld hl, wEnemyMons
ld de, wEnemyPartyCount
call SetupPokeballs
2015-08-31 02:38:41 +00:00
ld hl, wBaseCoordX
ld a, $48
ld [hli], a
ld [hl], $20
2015-07-23 13:07:12 +00:00
ld a, -8
ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer + PARTY_LENGTH * 4
jp WritePokeballOAMData
SetupPokeballs:
ld a, [de]
push af
ld de, wBuffer
ld c, PARTY_LENGTH
ld a, $34 ; empty pokeball
.emptyloop
ld [de], a
inc de
dec c
jr nz, .emptyloop
pop af
ld de, wBuffer
.monloop
push af
call PickPokeball
inc de
pop af
dec a
jr nz, .monloop
ret
2016-06-12 00:24:04 +00:00
PickPokeball:
inc hl
ld a, [hli]
and a
jr nz, .alive
ld a, [hl]
and a
ld b, $33 ; crossed ball (fainted)
jr z, .done_fainted
.alive
inc hl
inc hl
ld a, [hl] ; status
and a
ld b, $32 ; black ball (status)
jr nz, .done
dec b ; regular ball
jr .done
.done_fainted
inc hl
inc hl
.done
ld a, b
ld [de], a
2015-07-23 13:07:12 +00:00
ld bc, wPartyMon2 - wPartyMon1Status
add hl, bc ; next mon struct
ret
2016-06-12 00:24:04 +00:00
WritePokeballOAMData:
ld de, wBuffer
ld c, PARTY_LENGTH
.loop
2015-08-31 02:38:41 +00:00
ld a, [wBaseCoordY]
ld [hli], a
2015-08-31 02:38:41 +00:00
ld a, [wBaseCoordX]
ld [hli], a
ld a, [de]
ld [hli], a
xor a
ld [hli], a
2015-08-31 02:38:41 +00:00
ld a, [wBaseCoordX]
ld b, a
2015-07-23 13:07:12 +00:00
ld a, [wHUDPokeballGfxOffsetX]
add b
2015-08-31 02:38:41 +00:00
ld [wBaseCoordX], a
inc de
dec c
jr nz, .loop
ret
2016-06-12 00:24:04 +00:00
PlacePlayerHUDTiles:
ld hl, PlayerBattleHUDGraphicsTiles
2015-07-23 13:07:12 +00:00
ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
2015-07-18 20:52:03 +00:00
coord hl, 18, 10
2015-07-23 13:07:12 +00:00
ld de, -1
jr PlaceHUDTiles
2016-06-12 00:24:04 +00:00
PlayerBattleHUDGraphicsTiles:
; The tile numbers for specific parts of the battle display for the player's pokemon
db $73 ; unused ($73 is hardcoded into the routine that uses these bytes)
db $77 ; lower-right corner tile of the HUD
db $6F ; lower-left triangle tile of the HUD
2016-06-12 00:24:04 +00:00
PlaceEnemyHUDTiles:
ld hl, EnemyBattleHUDGraphicsTiles
2015-07-23 13:07:12 +00:00
ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
2015-07-18 20:52:03 +00:00
coord hl, 1, 2
ld de, $1
jr PlaceHUDTiles
2016-06-12 00:24:04 +00:00
EnemyBattleHUDGraphicsTiles:
; The tile numbers for specific parts of the battle display for the enemy
db $73 ; unused ($73 is hardcoded in the routine that uses these bytes)
db $74 ; lower-left corner tile of the HUD
db $78 ; lower-right triangle tile of the HUD
2016-06-12 00:24:04 +00:00
PlaceHUDTiles:
ld [hl], $73
2015-07-14 07:16:19 +00:00
ld bc, SCREEN_WIDTH
add hl, bc
2015-07-23 13:07:12 +00:00
ld a, [wHUDGraphicsTiles + 1] ; leftmost tile
ld [hl], a
2015-07-23 13:07:12 +00:00
ld a, 8
.loop
add hl, de
ld [hl], $76
dec a
2015-07-23 13:07:12 +00:00
jr nz, .loop
add hl, de
2015-07-23 13:07:12 +00:00
ld a, [wHUDGraphicsTiles + 2] ; rightmost tile
ld [hl], a
ret
2016-06-12 00:24:04 +00:00
SetupPlayerAndEnemyPokeballs:
call LoadPartyPokeballGfx
ld hl, wPartyMons
ld de, wPartyCount
call SetupPokeballs
2015-08-31 02:38:41 +00:00
ld hl, wBaseCoordX
ld a, $50
ld [hli], a
ld [hl], $40
2015-07-23 13:07:12 +00:00
ld a, 8
ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer
call WritePokeballOAMData
ld hl, wEnemyMons
ld de, wEnemyPartyCount
call SetupPokeballs
2015-08-31 02:38:41 +00:00
ld hl, wBaseCoordX
ld a, $50
ld [hli], a
ld [hl], $68
ld hl, wOAMBuffer + $18
jp WritePokeballOAMData
; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon)
2016-06-12 00:24:04 +00:00
PokeballTileGraphics::
INCBIN "gfx/pokeball.2bpp"
2015-08-10 04:56:20 +00:00
PokeballTileGraphicsEnd: