pokeyellow/engine/battle/draw_hud_pokeball_gfx.asm
2015-12-12 14:49:45 -05:00

201 lines
3.9 KiB
NASM

DrawAllPokeballs: ; 3a8df (e:68df)
call LoadPartyPokeballGfx
call SetupOwnPartyPokeballs
ld a, [wIsInBattle]
dec a
ret z ; return if wild pokémon
jp SetupEnemyPartyPokeballs
DrawEnemyPokeballs: ; 3a8ed (e:68ed)
call LoadPartyPokeballGfx
jp SetupEnemyPartyPokeballs
LoadPartyPokeballGfx: ; 3a8f3 (e:68f3)
ld de, PokeballTileGraphics
ld hl, vSprites + $310
lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10
jp CopyVideoData
SetupOwnPartyPokeballs: ; 3a8ff (e:68ff)
call PlacePlayerHUDTiles
ld hl, wPartyMon1
ld de, wPartyCount
call SetupPokeballs
ld a, $60
ld hl, wBaseCoordX
ld [hli], a
ld [hl], a
ld a, 8
ld [wHUDPokeballGfxOffsetX], a
xor a
ld [wdef5], a
ld hl, wOAMBuffer
jp WritePokeballOAMData
SetupEnemyPartyPokeballs: ; 3a921 (e:6921)
call PlaceEnemyHUDTiles
ld hl, wEnemyMons
ld de, wEnemyPartyCount
call SetupPokeballs
ld hl, wBaseCoordX
ld a, $48
ld [hli], a
ld [hl], $20
ld a, -8
ld [wHUDPokeballGfxOffsetX], a
ld a, $1
ld [wdef5], a
ld hl, wOAMBuffer + PARTY_LENGTH * 4
jp WritePokeballOAMData
SetupPokeballs: ; 3a945 (e:6945)
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
PickPokeball: ; 3a961 (e:6961)
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
ld bc, wPartyMon2 - wPartyMon1Status
add hl, bc ; next mon struct
ret
WritePokeballOAMData: ; 3a980 (e:6980)
ld de, wBuffer
ld c, PARTY_LENGTH
.loop
ld a, [wBaseCoordY]
ld [hli], a
ld a, [wBaseCoordX]
ld [hli], a
ld a, [de]
ld [hli], a
ld a, [wdef5]
ld [hli], a
ld a, [wBaseCoordX]
ld b, a
ld a, [wHUDPokeballGfxOffsetX]
add b
ld [wBaseCoordX], a
inc de
dec c
jr nz, .loop
ret
PlacePlayerHUDTiles: ; 3a9a3 (e:69a3)
ld hl, PlayerBattleHUDGraphicsTiles
ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
coord hl, 18, 10
ld de, -1
jr PlaceHUDTiles
PlayerBattleHUDGraphicsTiles: ; 3a9b7 (e:69b7)
; 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
PlaceEnemyHUDTiles: ; 3a9ba (e:69ba)
ld hl, EnemyBattleHUDGraphicsTiles
ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
coord hl, 1, 2
ld de, $1
jr PlaceHUDTiles
EnemyBattleHUDGraphicsTiles: ; 3a9ce (e:69ce)
; 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
PlaceHUDTiles: ; 3a9d1 (e:69d1)
ld [hl], $73
ld bc, SCREEN_WIDTH
add hl, bc
ld a, [wHUDGraphicsTiles + 1] ; leftmost tile
ld [hl], a
ld a, 8
.loop
add hl, de
ld [hl], $76
dec a
jr nz, .loop
add hl, de
ld a, [wHUDGraphicsTiles + 2] ; rightmost tile
ld [hl], a
ret
SetupPlayerAndEnemyPokeballs: ; 3a9e9 (e:69e9)
call LoadPartyPokeballGfx
ld hl, wPartyMons
ld de, wPartyCount
call SetupPokeballs
ld hl, wBaseCoordX
ld a, $50
ld [hli], a
ld [hl], $40
ld a, 8
ld [wHUDPokeballGfxOffsetX], a
xor a
ld [wdef5], a
ld hl, wOAMBuffer
call WritePokeballOAMData
ld hl, wEnemyMons
ld de, wEnemyPartyCount
call SetupPokeballs
ld hl, wBaseCoordX
ld a, $50
ld [hli], a
ld [hl], $68
ld a, $1
ld [wdef5], a
ld hl, wOAMBuffer + $18
jp WritePokeballOAMData
; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon)
PokeballTileGraphics:: ; 3aa28 (e:6a28)
INCBIN "gfx/pokeball.2bpp"
PokeballTileGraphicsEnd: