2018-06-24 07:09:41 -07:00
|
|
|
QueueBattleAnimation:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wActiveAnimObjects
|
2019-02-15 16:33:40 -08:00
|
|
|
ld e, NUM_ANIM_OBJECTS
|
2015-12-24 11:07:33 -08: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 08:21:51 -08:00
|
|
|
ld hl, wLastAnimObjectIndex
|
2015-12-24 11:07:33 -08:00
|
|
|
inc [hl]
|
|
|
|
call InitBattleAnimation
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DeinitBattleAnimation:
|
2015-12-24 11:07:33 -08:00
|
|
|
ld hl, BATTLEANIMSTRUCT_INDEX
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], $0
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
InitBattleAnimation:
|
2018-11-22 03:32:24 -08:00
|
|
|
ld a, [wBattleObjectTempID]
|
2015-12-24 11:07:33 -08: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 08:21:51 -08:00
|
|
|
ld a, [wLastAnimObjectIndex]
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_INDEX
|
2015-12-24 11:07:33 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_OAMFLAGS
|
2015-12-24 11:07:33 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_02
|
2015-12-24 11:07:33 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_FRAMESET_ID
|
2015-12-24 11:07:33 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_FUNCTION
|
2015-12-24 11:07:33 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_PALETTE
|
2015-12-24 11:07:33 -08:00
|
|
|
ld a, [de]
|
|
|
|
call GetBattleAnimTileOffset
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_TILEID
|
2018-11-22 03:32:24 -08:00
|
|
|
ld a, [wBattleObjectTempXCoord]
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_XCOORD
|
2018-11-22 03:32:24 -08:00
|
|
|
ld a, [wBattleObjectTempYCoord]
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_YCOORD
|
2015-12-24 11:07:33 -08:00
|
|
|
xor a
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_XOFFSET
|
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_YOFFSET
|
2019-02-05 23:07:11 -08:00
|
|
|
ld a, [wBattleObjectTempParam]
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_PARAM
|
2015-12-24 11:07:33 -08:00
|
|
|
xor a
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_DURATION
|
2015-12-24 11:07:33 -08:00
|
|
|
dec a
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_FRAME
|
2015-12-24 11:07:33 -08:00
|
|
|
xor a
|
2020-08-22 07:22:37 -07:00
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_JUMPTABLE_INDEX
|
|
|
|
ld [hli], a ; BATTLEANIMSTRUCT_VAR1
|
|
|
|
ld [hl], a ; BATTLEANIMSTRUCT_VAR2
|
2015-12-24 11:07:33 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleAnimOAMUpdate:
|
2015-12-24 11:07:33 -08:00
|
|
|
call InitBattleAnimBuffer
|
|
|
|
call GetBattleAnimFrame
|
2019-02-14 17:56:24 -08:00
|
|
|
cp dowait_command
|
2015-12-24 11:07:33 -08:00
|
|
|
jp z, .done
|
2019-02-14 17:56:24 -08:00
|
|
|
cp delanim_command
|
2015-12-24 11:07:33 -08:00
|
|
|
jp z, .delete
|
2019-02-14 17:56:24 -08:00
|
|
|
|
2015-12-24 11:07:33 -08:00
|
|
|
push af
|
|
|
|
ld hl, wBattleAnimTempOAMFlags
|
2019-02-14 17:56:24 -08:00
|
|
|
ld a, [wBattleAnimTempFrameOAMFlags]
|
2015-12-24 11:07:33 -08:00
|
|
|
xor [hl]
|
2019-02-16 10:08:34 -08:00
|
|
|
and PRIORITY | Y_FLIP | X_FLIP
|
2015-12-24 11:07:33 -08:00
|
|
|
ld [hl], a
|
|
|
|
pop af
|
2019-02-14 17:56:24 -08:00
|
|
|
|
2015-12-24 11:07:33 -08:00
|
|
|
push bc
|
|
|
|
call GetBattleAnimOAMPointer
|
|
|
|
ld a, [wBattleAnimTempTileID]
|
2019-02-14 17:56:24 -08:00
|
|
|
add [hl] ; tile offset
|
2015-12-24 11:07:33 -08:00
|
|
|
ld [wBattleAnimTempTileID], a
|
|
|
|
inc hl
|
2019-02-14 17:56:24 -08:00
|
|
|
ld a, [hli] ; oam data length
|
2015-12-24 11:07:33 -08:00
|
|
|
ld c, a
|
2019-02-14 17:56:24 -08:00
|
|
|
ld a, [hli] ; oam data pointer
|
2015-12-24 11:07:33 -08:00
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, [wBattleAnimOAMPointerLo]
|
|
|
|
ld e, a
|
2018-01-23 13:45:34 -08:00
|
|
|
ld d, HIGH(wVirtualOAM)
|
2019-02-14 17:56:24 -08:00
|
|
|
|
2015-12-24 11:07:33 -08:00
|
|
|
.loop
|
2019-02-14 17:56:24 -08:00
|
|
|
; Y Coord
|
2015-12-24 11:07:33 -08: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-14 17:56:24 -08:00
|
|
|
bit OAM_Y_FLIP, [hl]
|
2015-12-24 11:07:33 -08:00
|
|
|
jr z, .no_yflip
|
|
|
|
add $8
|
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
.no_yflip
|
|
|
|
pop hl
|
|
|
|
add b
|
|
|
|
ld [de], a
|
2019-02-14 17:56:24 -08:00
|
|
|
|
|
|
|
; X Coord
|
2015-12-24 11:07:33 -08: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-14 17:56:24 -08:00
|
|
|
bit OAM_X_FLIP, [hl]
|
2015-12-24 11:07:33 -08:00
|
|
|
jr z, .no_xflip
|
|
|
|
add $8
|
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
.no_xflip
|
|
|
|
pop hl
|
|
|
|
add b
|
|
|
|
ld [de], a
|
2019-02-14 17:56:24 -08:00
|
|
|
|
|
|
|
; Tile ID
|
2015-12-24 11:07:33 -08:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
ld a, [wBattleAnimTempTileID]
|
2018-11-21 14:44:31 -08:00
|
|
|
add BATTLEANIM_BASE_TILE
|
2015-12-24 11:07:33 -08:00
|
|
|
add [hl]
|
|
|
|
ld [de], a
|
2019-02-14 17:56:24 -08:00
|
|
|
|
|
|
|
; Attributes
|
2015-12-24 11:07:33 -08:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
ld a, [wBattleAnimTempOAMFlags]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
xor b
|
2019-02-14 17:56:24 -08:00
|
|
|
and PRIORITY | Y_FLIP | X_FLIP
|
2015-12-24 11:07:33 -08:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2019-02-14 17:56:24 -08:00
|
|
|
and OBP_NUM
|
2015-12-24 11:07:33 -08:00
|
|
|
or b
|
|
|
|
ld b, a
|
|
|
|
ld a, [wBattleAnimTempPalette]
|
2019-02-16 10:52:19 -08:00
|
|
|
and PALETTE_MASK | VRAM_BANK_1
|
2015-12-24 11:07:33 -08:00
|
|
|
or b
|
|
|
|
ld [de], a
|
2019-02-14 17:56:24 -08:00
|
|
|
|
2015-12-24 11:07:33 -08:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
ld a, e
|
|
|
|
ld [wBattleAnimOAMPointerLo], a
|
2019-02-14 17:56:24 -08:00
|
|
|
cp LOW(wVirtualOAMEnd)
|
2015-12-24 11:07:33 -08: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 07:09:41 -07:00
|
|
|
InitBattleAnimBuffer:
|
2020-08-22 07:22:37 -07:00
|
|
|
ld hl, BATTLEANIMSTRUCT_OAMFLAGS
|
2015-12-24 11:07:33 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2019-02-14 17:56:24 -08:00
|
|
|
|
2019-02-16 10:08:34 -08:00
|
|
|
and PRIORITY
|
2015-12-24 11:07:33 -08:00
|
|
|
ld [wBattleAnimTempOAMFlags], a
|
|
|
|
xor a
|
2019-02-14 17:56:24 -08:00
|
|
|
ld [wBattleAnimTempFrameOAMFlags], a
|
2015-12-24 11:07:33 -08: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-26 16:27:56 -08:00
|
|
|
ld [wBattleAnimTempField02], a
|
2015-12-24 11:07:33 -08: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-14 17:56:24 -08:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2015-12-24 11:07:33 -08:00
|
|
|
and a
|
|
|
|
ret z
|
2019-02-14 17:56:24 -08:00
|
|
|
|
2020-08-22 07:22:37 -07:00
|
|
|
ld hl, BATTLEANIMSTRUCT_OAMFLAGS
|
2015-12-24 11:07:33 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wBattleAnimTempOAMFlags], a
|
|
|
|
bit 0, [hl]
|
|
|
|
ret z
|
2019-02-14 17:56:24 -08:00
|
|
|
|
2015-12-24 11:07:33 -08: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-26 16:27:56 -08:00
|
|
|
ld a, [wBattleAnimTempField02]
|
2015-12-24 11:07:33 -08: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 14:39:09 -08:00
|
|
|
ld a, [wFXAnimID + 1]
|
2015-12-24 11:07:33 -08:00
|
|
|
or a
|
|
|
|
jr nz, .no_sub
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wFXAnimID]
|
2015-12-24 11:07:33 -08: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 07:09:41 -07:00
|
|
|
GetBattleAnimTileOffset:
|
2015-12-24 11:07:33 -08: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 07:09:41 -07:00
|
|
|
_ExecuteBGEffects:
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar ExecuteBGEffects
|
2015-12-24 11:07:33 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_QueueBGEffect:
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar QueueBGEffect
|
2015-12-24 11:07:33 -08:00
|
|
|
ret
|