mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
4154f191e0
The X and Y flip flags can be applied through the stack consisting of: - Object attributes - Animation frame attributes - OAM Data Each of these negate eachother. Confused yet? The same stack is traversed to obtain the final tile ID, with an added layer on top for the base GFX offset and the offset for the dynamically loaded GFX requested by the object! wBattleAnimDelay is populated with the values passed to `anim_wait`.
123 lines
1.7 KiB
NASM
123 lines
1.7 KiB
NASM
ReinitBattleAnimFrameset:
|
|
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
|
|
add hl, bc
|
|
ld [hl], a
|
|
ld hl, BATTLEANIMSTRUCT_DURATION
|
|
add hl, bc
|
|
ld [hl], 0
|
|
ld hl, BATTLEANIMSTRUCT_FRAME
|
|
add hl, bc
|
|
ld [hl], -1
|
|
ret
|
|
|
|
GetBattleAnimFrame:
|
|
.loop
|
|
ld hl, BATTLEANIMSTRUCT_DURATION
|
|
add hl, bc
|
|
ld a, [hl]
|
|
and a
|
|
jr z, .next_frame
|
|
dec [hl]
|
|
call .GetPointer
|
|
ld a, [hli]
|
|
push af
|
|
jr .okay
|
|
|
|
.next_frame
|
|
ld hl, BATTLEANIMSTRUCT_FRAME
|
|
add hl, bc
|
|
inc [hl]
|
|
call .GetPointer
|
|
ld a, [hli]
|
|
cp dorestart_command
|
|
jr z, .restart
|
|
cp endanim_command
|
|
jr z, .repeat_last
|
|
|
|
push af
|
|
ld a, [hl]
|
|
push hl
|
|
and %00111111
|
|
ld hl, BATTLEANIMSTRUCT_DURATION
|
|
add hl, bc
|
|
ld [hl], a
|
|
pop hl
|
|
.okay
|
|
ld a, [hl]
|
|
and Y_FLIP << 1 | X_FLIP << 1 ; The << 1 is compensated in the "frame" macro
|
|
srl a
|
|
ld [wBattleAnimTempFrameOAMFlags], a
|
|
pop af
|
|
ret
|
|
|
|
.repeat_last
|
|
xor a
|
|
ld hl, BATTLEANIMSTRUCT_DURATION
|
|
add hl, bc
|
|
ld [hl], a
|
|
ld hl, BATTLEANIMSTRUCT_FRAME
|
|
add hl, bc
|
|
dec [hl]
|
|
dec [hl]
|
|
jr .loop
|
|
|
|
.restart
|
|
xor a
|
|
ld hl, BATTLEANIMSTRUCT_DURATION
|
|
add hl, bc
|
|
ld [hl], a
|
|
dec a
|
|
ld hl, BATTLEANIMSTRUCT_FRAME
|
|
add hl, bc
|
|
ld [hl], a
|
|
jr .loop
|
|
|
|
.GetPointer:
|
|
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
|
|
add hl, bc
|
|
ld e, [hl]
|
|
ld d, 0
|
|
ld hl, BattleAnimFrameData
|
|
add hl, de
|
|
add hl, de
|
|
ld e, [hl]
|
|
inc hl
|
|
ld d, [hl]
|
|
ld hl, BATTLEANIMSTRUCT_FRAME
|
|
add hl, bc
|
|
ld l, [hl]
|
|
ld h, $0
|
|
add hl, hl
|
|
add hl, de
|
|
ret
|
|
|
|
GetBattleAnimOAMPointer:
|
|
ld l, a
|
|
ld h, 0
|
|
ld de, BattleAnimOAMData
|
|
add hl, hl
|
|
add hl, hl
|
|
add hl, de
|
|
ret
|
|
|
|
LoadBattleAnimGFX:
|
|
push hl
|
|
ld l, a
|
|
ld h, 0
|
|
add hl, hl
|
|
add hl, hl
|
|
ld de, AnimObjGFX
|
|
add hl, de
|
|
ld c, [hl]
|
|
inc hl
|
|
ld b, [hl]
|
|
inc hl
|
|
ld a, [hli]
|
|
ld h, [hl]
|
|
ld l, a
|
|
pop de
|
|
push bc
|
|
call DecompressRequest2bpp
|
|
pop bc
|
|
ret
|