2018-06-24 14:09:41 +00:00
|
|
|
QueueBattleAnimation:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wActiveAnimObjects
|
2019-02-16 00:33:40 +00:00
|
|
|
ld e, NUM_ANIM_OBJECTS
|
2015-12-24 19:07:33 +00:00
|
|
|
.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
|
2019-02-15 16:21:51 +00:00
|
|
|
ld hl, wLastAnimObjectIndex
|
2015-12-24 19:07:33 +00:00
|
|
|
inc [hl]
|
|
|
|
call InitBattleAnimation
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DeinitBattleAnimation:
|
2015-12-24 19:07:33 +00:00
|
|
|
ld hl, BATTLEANIMSTRUCT_INDEX
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], $0
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
InitBattleAnimation:
|
2018-11-22 11:32:24 +00:00
|
|
|
ld a, [wBattleObjectTempID]
|
2015-12-24 19:07:33 +00:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, BattleAnimObjects
|
|
|
|
rept 6
|
|
|
|
add hl, de
|
|
|
|
endr
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
ld hl, BATTLEANIMSTRUCT_INDEX
|
|
|
|
add hl, bc
|
2019-02-15 16:21:51 +00:00
|
|
|
ld a, [wLastAnimObjectIndex]
|
2015-12-24 19:07:33 +00:00
|
|
|
ld [hli], a ; Index
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a ; 01
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a ; 02
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a ; Frameset ID
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a ; Function
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a ; 05
|
|
|
|
ld a, [de]
|
|
|
|
call GetBattleAnimTileOffset
|
|
|
|
ld [hli], a ; Tile ID
|
2018-11-22 11:32:24 +00:00
|
|
|
ld a, [wBattleObjectTempXCoord]
|
2015-12-24 19:07:33 +00:00
|
|
|
ld [hli], a ; X Coord
|
2018-11-22 11:32:24 +00:00
|
|
|
ld a, [wBattleObjectTempYCoord]
|
2015-12-24 19:07:33 +00:00
|
|
|
ld [hli], a ; Y Coord
|
|
|
|
xor a
|
|
|
|
ld [hli], a ; X Offset
|
|
|
|
ld [hli], a ; Y Offset
|
2019-02-06 07:07:11 +00:00
|
|
|
ld a, [wBattleObjectTempParam]
|
|
|
|
ld [hli], a ; Param
|
2015-12-24 19:07:33 +00:00
|
|
|
xor a
|
|
|
|
ld [hli], a ; 0c
|
|
|
|
dec a
|
|
|
|
ld [hli], a ; 0d
|
|
|
|
xor a
|
|
|
|
ld [hli], a ; 0e
|
|
|
|
ld [hli], a ; 0f
|
|
|
|
ld [hl], a ; 10
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
BattleAnimOAMUpdate:
|
2015-12-24 19:07:33 +00:00
|
|
|
call InitBattleAnimBuffer
|
|
|
|
call GetBattleAnimFrame
|
2019-02-15 01:56:24 +00:00
|
|
|
cp dowait_command
|
2015-12-24 19:07:33 +00:00
|
|
|
jp z, .done
|
2019-02-15 01:56:24 +00:00
|
|
|
cp delanim_command
|
2015-12-24 19:07:33 +00:00
|
|
|
jp z, .delete
|
2019-02-15 01:56:24 +00:00
|
|
|
|
2015-12-24 19:07:33 +00:00
|
|
|
push af
|
|
|
|
ld hl, wBattleAnimTempOAMFlags
|
2019-02-15 01:56:24 +00:00
|
|
|
ld a, [wBattleAnimTempFrameOAMFlags]
|
2015-12-24 19:07:33 +00:00
|
|
|
xor [hl]
|
2019-02-16 18:08:34 +00:00
|
|
|
and PRIORITY | Y_FLIP | X_FLIP
|
2015-12-24 19:07:33 +00:00
|
|
|
ld [hl], a
|
|
|
|
pop af
|
2019-02-15 01:56:24 +00:00
|
|
|
|
2015-12-24 19:07:33 +00:00
|
|
|
push bc
|
|
|
|
call GetBattleAnimOAMPointer
|
|
|
|
ld a, [wBattleAnimTempTileID]
|
2019-02-15 01:56:24 +00:00
|
|
|
add [hl] ; tile offset
|
2015-12-24 19:07:33 +00:00
|
|
|
ld [wBattleAnimTempTileID], a
|
|
|
|
inc hl
|
2019-02-15 01:56:24 +00:00
|
|
|
ld a, [hli] ; oam data length
|
2015-12-24 19:07:33 +00:00
|
|
|
ld c, a
|
2019-02-15 01:56:24 +00:00
|
|
|
ld a, [hli] ; oam data pointer
|
2015-12-24 19:07:33 +00:00
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, [wBattleAnimOAMPointerLo]
|
|
|
|
ld e, a
|
2018-01-23 21:45:34 +00:00
|
|
|
ld d, HIGH(wVirtualOAM)
|
2019-02-15 01:56:24 +00:00
|
|
|
|
2015-12-24 19:07:33 +00:00
|
|
|
.loop
|
2019-02-15 01:56:24 +00:00
|
|
|
; Y Coord
|
2015-12-24 19:07:33 +00:00
|
|
|
ld a, [wBattleAnimTempYCoord]
|
|
|
|
ld b, a
|
|
|
|
ld a, [wBattleAnimTempYOffset]
|
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
push hl
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, wBattleAnimTempOAMFlags
|
2019-02-15 01:56:24 +00:00
|
|
|
bit OAM_Y_FLIP, [hl]
|
2015-12-24 19:07:33 +00:00
|
|
|
jr z, .no_yflip
|
|
|
|
add $8
|
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
.no_yflip
|
|
|
|
pop hl
|
|
|
|
add b
|
|
|
|
ld [de], a
|
2019-02-15 01:56:24 +00:00
|
|
|
|
|
|
|
; X Coord
|
2015-12-24 19:07:33 +00:00
|
|
|
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
|
2019-02-15 01:56:24 +00:00
|
|
|
bit OAM_X_FLIP, [hl]
|
2015-12-24 19:07:33 +00:00
|
|
|
jr z, .no_xflip
|
|
|
|
add $8
|
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
.no_xflip
|
|
|
|
pop hl
|
|
|
|
add b
|
|
|
|
ld [de], a
|
2019-02-15 01:56:24 +00:00
|
|
|
|
|
|
|
; Tile ID
|
2015-12-24 19:07:33 +00:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
ld a, [wBattleAnimTempTileID]
|
2018-11-21 22:44:31 +00:00
|
|
|
add BATTLEANIM_BASE_TILE
|
2015-12-24 19:07:33 +00:00
|
|
|
add [hl]
|
|
|
|
ld [de], a
|
2019-02-15 01:56:24 +00:00
|
|
|
|
|
|
|
; Attributes
|
2015-12-24 19:07:33 +00:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
ld a, [wBattleAnimTempOAMFlags]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
xor b
|
2019-02-15 01:56:24 +00:00
|
|
|
and PRIORITY | Y_FLIP | X_FLIP
|
2015-12-24 19:07:33 +00:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2019-02-15 01:56:24 +00:00
|
|
|
and OBP_NUM
|
2015-12-24 19:07:33 +00:00
|
|
|
or b
|
|
|
|
ld b, a
|
|
|
|
ld a, [wBattleAnimTempPalette]
|
2019-02-16 18:08:34 +00:00
|
|
|
and (PRIORITY | Y_FLIP | X_FLIP | OBP_NUM) ^ $ff
|
2015-12-24 19:07:33 +00:00
|
|
|
or b
|
|
|
|
ld [de], a
|
2019-02-15 01:56:24 +00:00
|
|
|
|
2015-12-24 19:07:33 +00:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
ld a, e
|
|
|
|
ld [wBattleAnimOAMPointerLo], a
|
2019-02-15 01:56:24 +00:00
|
|
|
cp LOW(wVirtualOAMEnd)
|
2015-12-24 19:07:33 +00:00
|
|
|
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 14:09:41 +00:00
|
|
|
InitBattleAnimBuffer:
|
2015-12-24 19:07:33 +00:00
|
|
|
ld hl, BATTLEANIMSTRUCT_01
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2019-02-15 01:56:24 +00:00
|
|
|
|
2019-02-16 18:08:34 +00:00
|
|
|
and PRIORITY
|
2015-12-24 19:07:33 +00:00
|
|
|
ld [wBattleAnimTempOAMFlags], a
|
|
|
|
xor a
|
2019-02-15 01:56:24 +00:00
|
|
|
ld [wBattleAnimTempFrameOAMFlags], a
|
2015-12-24 19:07:33 +00:00
|
|
|
ld hl, BATTLEANIMSTRUCT_PALETTE
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wBattleAnimTempPalette], a
|
|
|
|
ld hl, BATTLEANIMSTRUCT_02
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2017-12-27 00:27:56 +00:00
|
|
|
ld [wBattleAnimTempField02], a
|
2015-12-24 19:07:33 +00:00
|
|
|
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
|
2019-02-15 01:56:24 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hBattleTurn]
|
2015-12-24 19:07:33 +00:00
|
|
|
and a
|
|
|
|
ret z
|
2019-02-15 01:56:24 +00:00
|
|
|
|
2015-12-24 19:07:33 +00:00
|
|
|
ld hl, BATTLEANIMSTRUCT_01
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wBattleAnimTempOAMFlags], a
|
|
|
|
bit 0, [hl]
|
|
|
|
ret z
|
2019-02-15 01:56:24 +00:00
|
|
|
|
2015-12-24 19:07:33 +00:00
|
|
|
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
|
2017-12-27 00:27:56 +00:00
|
|
|
ld a, [wBattleAnimTempField02]
|
2015-12-24 19:07:33 +00:00
|
|
|
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 22:39:09 +00:00
|
|
|
ld a, [wFXAnimID + 1]
|
2015-12-24 19:07:33 +00:00
|
|
|
or a
|
|
|
|
jr nz, .no_sub
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wFXAnimID]
|
2015-12-24 19:07:33 +00:00
|
|
|
cp KINESIS
|
|
|
|
jr z, .kinesis
|
|
|
|
cp SOFTBOILED
|
|
|
|
jr z, .softboiled
|
|
|
|
cp MILK_DRINK
|
|
|
|
jr nz, .no_sub
|
|
|
|
.kinesis
|
|
|
|
.softboiled
|
|
|
|
.milk_drink
|
|
|
|
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 14:09:41 +00:00
|
|
|
GetBattleAnimTileOffset:
|
2015-12-24 19:07:33 +00:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
ld hl, wBattleAnimTileDict
|
|
|
|
ld b, a
|
|
|
|
ld c, 10 / 2
|
|
|
|
.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 14:09:41 +00:00
|
|
|
_ExecuteBGEffects:
|
2017-12-24 17:47:30 +00:00
|
|
|
callfar ExecuteBGEffects
|
2015-12-24 19:07:33 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_QueueBGEffect:
|
2017-12-24 17:47:30 +00:00
|
|
|
callfar QueueBGEffect
|
2015-12-24 19:07:33 +00:00
|
|
|
ret
|