pokecrystal-board/engine/battle_anims/core.asm

318 lines
4.9 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
QueueBattleAnimation:
2018-01-23 14:39:09 -08:00
ld hl, wActiveAnimObjects
ld e, NUM_ANIM_OBJECTS
.loop
ld a, [hl]
and a
jr z, .done
ld bc, BATTLEANIMSTRUCT_LENGTH
add hl, bc
dec e
jr nz, .loop
scf
ret
.done
ld c, l
ld b, h
ld hl, wLastAnimObjectIndex
inc [hl]
call InitBattleAnimation
ret
2018-06-24 07:09:41 -07:00
DeinitBattleAnimation:
ld hl, BATTLEANIMSTRUCT_INDEX
add hl, bc
ld [hl], $0
ret
2018-06-24 07:09:41 -07:00
InitBattleAnimation:
ld a, [wBattleObjectTempID]
ld e, a
ld d, 0
ld hl, BattleAnimObjects
rept BATTLEANIMOBJ_LENGTH
add hl, de
endr
ld e, l
ld d, h
ld hl, BATTLEANIMSTRUCT_INDEX
add hl, bc
ld a, [wLastAnimObjectIndex]
ld [hli], a ; BATTLEANIMSTRUCT_INDEX
ld a, [de]
inc de
ld [hli], a ; BATTLEANIMSTRUCT_OAMFLAGS
ld a, [de]
inc de
ld [hli], a ; BATTLEANIMSTRUCT_FIX_Y
ld a, [de]
inc de
ld [hli], a ; BATTLEANIMSTRUCT_FRAMESET_ID
ld a, [de]
inc de
ld [hli], a ; BATTLEANIMSTRUCT_FUNCTION
ld a, [de]
inc de
ld [hli], a ; BATTLEANIMSTRUCT_PALETTE
ld a, [de]
call GetBattleAnimTileOffset
ld [hli], a ; BATTLEANIMSTRUCT_TILEID
ld a, [wBattleObjectTempXCoord]
ld [hli], a ; BATTLEANIMSTRUCT_XCOORD
ld a, [wBattleObjectTempYCoord]
ld [hli], a ; BATTLEANIMSTRUCT_YCOORD
xor a
ld [hli], a ; BATTLEANIMSTRUCT_XOFFSET
ld [hli], a ; BATTLEANIMSTRUCT_YOFFSET
ld a, [wBattleObjectTempParam]
ld [hli], a ; BATTLEANIMSTRUCT_PARAM
xor a
ld [hli], a ; BATTLEANIMSTRUCT_DURATION
dec a
ld [hli], a ; BATTLEANIMSTRUCT_FRAME
xor a
ld [hli], a ; BATTLEANIMSTRUCT_JUMPTABLE_INDEX
ld [hli], a ; BATTLEANIMSTRUCT_VAR1
ld [hl], a ; BATTLEANIMSTRUCT_VAR2
ret
2018-06-24 07:09:41 -07:00
BattleAnimOAMUpdate:
call InitBattleAnimBuffer
call GetBattleAnimFrame
cp dowait_command
jp z, .done
cp delanim_command
jp z, .delete
push af
ld hl, wBattleAnimTempOAMFlags
ld a, [wBattleAnimTempFrameOAMFlags]
xor [hl]
2019-02-16 10:08:34 -08:00
and PRIORITY | Y_FLIP | X_FLIP
ld [hl], a
pop af
push bc
call GetBattleAnimOAMPointer
ld a, [wBattleAnimTempTileID]
add [hl] ; tile offset
ld [wBattleAnimTempTileID], a
inc hl
ld a, [hli] ; oam data length
ld c, a
ld a, [hli] ; oam data pointer
ld h, [hl]
ld l, a
ld a, [wBattleAnimOAMPointerLo]
ld e, a
ld d, HIGH(wVirtualOAM)
.loop
; Y Coord
ld a, [wBattleAnimTempYCoord]
ld b, a
ld a, [wBattleAnimTempYOffset]
add b
ld b, a
push hl
ld a, [hl]
ld hl, wBattleAnimTempOAMFlags
bit OAM_Y_FLIP, [hl]
jr z, .no_yflip
add $8
xor $ff
inc a
.no_yflip
pop hl
add b
ld [de], a
; X Coord
inc hl
inc de
ld a, [wBattleAnimTempXCoord]
ld b, a
ld a, [wBattleAnimTempXOffset]
add b
ld b, a
push hl
ld a, [hl]
ld hl, wBattleAnimTempOAMFlags
bit OAM_X_FLIP, [hl]
jr z, .no_xflip
add $8
xor $ff
inc a
.no_xflip
pop hl
add b
ld [de], a
; Tile ID
inc hl
inc de
ld a, [wBattleAnimTempTileID]
add BATTLEANIM_BASE_TILE
add [hl]
ld [de], a
; Attributes
inc hl
inc de
ld a, [wBattleAnimTempOAMFlags]
ld b, a
ld a, [hl]
xor b
and PRIORITY | Y_FLIP | X_FLIP
ld b, a
ld a, [hl]
and OBP_NUM
or b
ld b, a
ld a, [wBattleAnimTempPalette]
and PALETTE_MASK | VRAM_BANK_1
or b
ld [de], a
inc hl
inc de
ld a, e
ld [wBattleAnimOAMPointerLo], a
cp LOW(wVirtualOAMEnd)
jr nc, .exit_set_carry
dec c
jr nz, .loop
pop bc
jr .done
.delete
call DeinitBattleAnimation
.done
and a
ret
.exit_set_carry
pop bc
scf
ret
2018-06-24 07:09:41 -07:00
InitBattleAnimBuffer:
ld hl, BATTLEANIMSTRUCT_OAMFLAGS
add hl, bc
ld a, [hl]
2019-02-16 10:08:34 -08:00
and PRIORITY
ld [wBattleAnimTempOAMFlags], a
xor a
ld [wBattleAnimTempFrameOAMFlags], a
ld hl, BATTLEANIMSTRUCT_PALETTE
add hl, bc
ld a, [hl]
ld [wBattleAnimTempPalette], a
ld hl, BATTLEANIMSTRUCT_FIX_Y
add hl, bc
ld a, [hl]
ld [wBattleAnimTempFixY], a
ld hl, BATTLEANIMSTRUCT_TILEID
add hl, bc
ld a, [hli]
ld [wBattleAnimTempTileID], a
ld a, [hli]
ld [wBattleAnimTempXCoord], a
ld a, [hli]
ld [wBattleAnimTempYCoord], a
ld a, [hli]
ld [wBattleAnimTempXOffset], a
ld a, [hli]
ld [wBattleAnimTempYOffset], a
ldh a, [hBattleTurn]
and a
ret z
ld hl, BATTLEANIMSTRUCT_OAMFLAGS
add hl, bc
ld a, [hl]
ld [wBattleAnimTempOAMFlags], a
bit 0, [hl]
ret z
ld hl, BATTLEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hli]
ld d, a
ld a, (-10 * 8) + 4
sub d
ld [wBattleAnimTempXCoord], a
ld a, [hli]
ld d, a
ld a, [wBattleAnimTempFixY]
cp $ff
jr nz, .check_kinesis_softboiled_milkdrink
ld a, 5 * 8
add d
jr .done
.check_kinesis_softboiled_milkdrink
sub d
push af
2018-01-23 14:39:09 -08:00
ld a, [wFXAnimID + 1]
or a
jr nz, .no_sub
2018-01-23 14:39:09 -08:00
ld a, [wFXAnimID]
cp KINESIS
jr z, .do_sub
cp SOFTBOILED
jr z, .do_sub
cp MILK_DRINK
jr nz, .no_sub
.do_sub
pop af
sub 1 * 8
jr .done
.no_sub
pop af
.done
ld [wBattleAnimTempYCoord], a
ld a, [hli]
xor $ff
inc a
ld [wBattleAnimTempXOffset], a
ret
2018-06-24 07:09:41 -07:00
GetBattleAnimTileOffset:
push hl
push bc
ld hl, wBattleAnimTileDict
ld b, a
2020-10-30 12:39:08 -07:00
ld c, NUM_BATTLEANIMTILEDICT_ENTRIES
.loop
ld a, [hli]
cp b
jr z, .load
inc hl
dec c
jr nz, .loop
xor a
jr .done
.load
ld a, [hl]
.done
pop bc
pop hl
ret
2018-06-24 07:09:41 -07:00
_ExecuteBGEffects:
2017-12-24 09:47:30 -08:00
callfar ExecuteBGEffects
ret
2018-06-24 07:09:41 -07:00
_QueueBGEffect:
2017-12-24 09:47:30 -08:00
callfar QueueBGEffect
ret
INCLUDE "data/battle_anims/objects.asm"