pokecrystal/engine/sprites.asm

751 lines
12 KiB
NASM
Raw Normal View History

ClearSpriteAnims: ; 8cf53
ld hl, wSpriteAnimDict
ld bc, wSpriteAnimsEnd - wSpriteAnimDict
2015-11-13 05:49:27 +00:00
.loop
ld [hl], $0
inc hl
dec bc
ld a, c
or b
jr nz, .loop
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8cf62
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
Function8cf62: ; 8cf62
call PlaySpriteAnimations
2015-11-13 05:49:27 +00:00
call DelayFrame
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8cf69
2015-11-05 01:20:14 +00:00
PlaySpriteAnimations: ; 8cf69
2015-11-13 05:49:27 +00:00
push hl
push de
push bc
2015-11-05 01:20:14 +00:00
push af
ld a, 0 * 4
ld [wOAMRetentionSize], a
call DoNextFrameForAllSprites
2015-11-13 05:49:27 +00:00
2015-11-05 01:20:14 +00:00
pop af
2015-11-13 05:49:27 +00:00
pop bc
pop de
pop hl
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8cf7a
2015-11-05 01:20:14 +00:00
DoNextFrameForAllSprites: ; 8cf7a
ld hl, wSpriteAnimationStructs
2015-11-13 05:49:27 +00:00
ld e, 10 ; There are 10 structs here.
2015-11-05 01:20:14 +00:00
.loop
2015-11-13 05:49:27 +00:00
ld a, [hl]
and a
jr z, .next ; This struct is deinitialized.
ld c, l
ld b, h
push hl
push de
call DoAnimFrame ; Uses a massive jumptable
2015-11-13 05:49:27 +00:00
call Function8d04c
pop de
pop hl
jr c, .done
.next
ld bc, $10
add hl, bc
dec e
2015-11-05 01:20:14 +00:00
jr nz, .loop
ld a, [wOAMRetentionSize]
2015-11-13 05:49:27 +00:00
ld l, a
ld h, Sprites / $0100
2015-11-05 01:20:14 +00:00
.loop2 ; Clear (Sprites + [wOAMRetentionSize] --> SpritesEnd)
2015-11-13 05:49:27 +00:00
ld a, l
cp SpritesEnd % $100
jr nc, .done
xor a
ld [hli], a
jr .loop2
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.done
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8cfa8
2015-11-05 01:20:14 +00:00
DoNextFrameForFirst16Sprites: ; 8cfa8 (23:4fa8)
ld hl, wSpriteAnimationStructs
2015-11-13 05:49:27 +00:00
ld e, 10
.loop
ld a, [hl]
and a
jr z, .next
ld c, l
ld b, h
push hl
push de
call DoAnimFrame ; Uses a massive jumptable
2015-11-13 05:49:27 +00:00
call Function8d04c
pop de
pop hl
jr c, .done
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.next
ld bc, $10
add hl, bc
dec e
jr nz, .loop
2015-11-05 01:20:14 +00:00
ld a, [wOAMRetentionSize]
2015-11-13 05:49:27 +00:00
ld l, a
ld h, (Sprites + $40) / $100
2015-11-05 01:20:14 +00:00
.loop2 ; Clear (Sprites + [wOAMRetentionSize] --> Sprites + $40)
2015-11-13 05:49:27 +00:00
ld a, l
cp (Sprites + 16 * 4) % $100
2015-11-13 05:49:27 +00:00
jr nc, .done
xor a
ld [hli], a
jr .loop2
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.done
2015-11-05 01:20:14 +00:00
ret
2015-11-13 15:48:49 +00:00
InitSpriteAnimStruct:: ; 8cfd6
2015-12-04 13:46:11 +00:00
; Initialize animation a at pixel x=e, y=d
; Find if there's any room in the wSpriteAnimationStructs array, which is 10x16
2015-11-13 05:49:27 +00:00
push de
2015-11-05 01:20:14 +00:00
push af
ld hl, wSpriteAnimationStructs
2015-11-13 05:49:27 +00:00
ld e, 10
.loop
2015-11-05 01:20:14 +00:00
ld a, [hl]
2015-11-13 05:49:27 +00:00
and a
jr z, .found
ld bc, $10
add hl, bc
dec e
2015-11-05 01:20:14 +00:00
jr nz, .loop
2015-11-13 05:49:27 +00:00
; We've reached the end. There is no more room here.
; Return carry.
pop af
pop de
scf
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
.found
; Back up the structure address to bc.
ld c, l
ld b, h
; Value [wc3b4] is initially set to -1. Set it to
; the number of objects loaded into this array.
ld hl, wc3b4
inc [hl]
ld a, [hl]
and a
jr nz, .initialized
inc [hl]
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.initialized
; Get row a of Unknown_8d1c4, copy the pointer into de
pop af
ld e, a
ld d, 0
ld hl, Unknown_8d1c4
rept 3
add hl, de
endr
ld e, l
ld d, h
; Set hl to the first field (field 0) in the current structure.
2015-12-04 13:46:11 +00:00
ld hl, SPRITEANIMSTRUCT_INDEX
2015-11-13 05:49:27 +00:00
add hl, bc
; Load the index.
ld a, [wc3b4]
ld [hli], a
; Copy the table entry to the next two fields.
ld a, [de]
ld [hli], a
inc de
ld a, [de]
ld [hli], a
inc de
; Look up the third field from the table in the wc300 array (10x2).
; Take the value and load it in
ld a, [de]
2015-12-04 13:46:11 +00:00
call GetSpriteAnimVTile
2015-11-13 05:49:27 +00:00
ld [hli], a
pop de
2015-12-04 13:46:11 +00:00
; Set hl to field 4 (X coordinate). Kinda pointless, because we're presumably already here.
ld hl, SPRITEANIMSTRUCT_XCOORD
2015-11-05 01:20:14 +00:00
add hl, bc
2015-11-13 05:49:27 +00:00
; Load the original value of de into here.
ld a, e
ld [hli], a
ld a, d
ld [hli], a
; load 0 into the next four fields
xor a
rept 2
ld [hli], a
2015-11-05 01:20:14 +00:00
endr
2015-11-13 05:49:27 +00:00
xor a
rept 2
ld [hli], a
endr
; load -1 into the next field
dec a
ld [hli], a
; load 0 into the last five fields
xor a
rept 4
ld [hli], a
endr
ld [hl], a
2015-12-04 13:46:11 +00:00
; back up the address of the first field to wSpriteAnimAddrBackup
2015-11-13 05:49:27 +00:00
ld a, c
2015-12-04 13:46:11 +00:00
ld [wSpriteAnimAddrBackup], a
2015-11-13 05:49:27 +00:00
ld a, b
2015-12-04 13:46:11 +00:00
ld [wSpriteAnimAddrBackup + 1], a
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8d036
2015-11-05 01:20:14 +00:00
2015-12-04 13:46:11 +00:00
DeinitializeSprite: ; 8d036
2015-11-13 05:49:27 +00:00
; Clear the index field of the struct in bc.
ld hl, SPRITEANIMSTRUCT_INDEX
2015-11-13 05:49:27 +00:00
add hl, bc
ld [hl], $0
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8d03d
2015-11-05 01:20:14 +00:00
2015-12-04 13:46:11 +00:00
DeinitializeAllSprites: ; 8d03d (23:503d)
; Clear the index field of every struct in the wSpriteAnimationStructs array.
ld hl, wSpriteAnimationStructs
2015-11-13 05:49:27 +00:00
ld bc, $10
ld e, 10
xor a
.loop
ld [hl], a
add hl, bc
dec e
jr nz, .loop
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
Function8d04c: ; 8d04c
2015-12-04 13:46:11 +00:00
call InitSpriteAnimBuffer ; init WRAM
2015-11-13 05:49:27 +00:00
call Function8d132 ; read from a memory array
cp -3
jr z, .done
cp -4
jr z, .delete
call Function8d1a2 ; OAM?
; add byte to [wCurrAnimVTile]
ld a, [wCurrAnimVTile]
2015-11-13 05:49:27 +00:00
add [hl]
ld [wCurrAnimVTile], a
2015-11-13 05:49:27 +00:00
inc hl
; load pointer into hl
2015-11-05 01:20:14 +00:00
ld a, [hli]
2015-11-13 05:49:27 +00:00
ld h, [hl]
ld l, a
push bc
ld a, [wOAMRetentionSize]
2015-11-05 01:20:14 +00:00
ld e, a
2015-11-13 05:49:27 +00:00
ld d, Sprites / $100
2015-11-05 01:20:14 +00:00
ld a, [hli]
ld c, a ; number of objects
2015-11-13 05:49:27 +00:00
.loop
; first byte: y (px)
2015-12-04 13:46:11 +00:00
; [de] = [wCurrAnimYCoord] + [wCurrAnimYOffset] + [wGlobalAnimYOffset] + AddOrSubtractY([hl])
ld a, [wCurrAnimYCoord]
2015-11-13 05:49:27 +00:00
ld b, a
ld a, [wCurrAnimYOffset]
2015-11-13 05:49:27 +00:00
add b
ld b, a
2015-12-02 22:59:05 +00:00
ld a, [wGlobalAnimYOffset]
2015-11-13 05:49:27 +00:00
add b
ld b, a
2015-12-04 13:46:11 +00:00
call AddOrSubtractY
2015-11-13 05:49:27 +00:00
add b
ld [de], a
inc hl
inc de
; second byte: x (px)
2015-12-04 13:46:11 +00:00
; [de] = [wCurrAnimXCoord] + [wCurrAnimXOffset] + [wGlobalAnimXOffset] + AddOrSubtractX([hl])
ld a, [wCurrAnimXCoord]
2015-11-13 05:49:27 +00:00
ld b, a
ld a, [wCurrAnimXOffset]
2015-11-13 05:49:27 +00:00
add b
ld b, a
2015-12-02 22:59:05 +00:00
ld a, [wGlobalAnimXOffset]
2015-11-13 05:49:27 +00:00
add b
ld b, a
2015-12-04 13:46:11 +00:00
call AddOrSubtractX
2015-11-13 05:49:27 +00:00
add b
ld [de], a
inc hl
inc de
; third byte: vtile
; [de] = [wCurrAnimVTile] + [hl]
ld a, [wCurrAnimVTile]
2015-11-13 05:49:27 +00:00
add [hl]
ld [de], a
inc hl
inc de
; fourth byte: attributes
; [de] = Function8d0de([hl])
2015-11-13 05:49:27 +00:00
call Function8d0de
ld [de], a
inc hl
inc de
ld a, e
ld [wOAMRetentionSize], a
2015-11-13 05:49:27 +00:00
cp SpritesEnd % $100
jr nc, .reached_the_end
2015-11-13 05:49:27 +00:00
dec c
jr nz, .loop
pop bc
jr .done
2015-11-05 01:20:14 +00:00
.delete
2015-12-04 13:46:11 +00:00
call DeinitializeSprite
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.done
2015-11-05 01:20:14 +00:00
and a
ret
.reached_the_end
2015-11-13 05:49:27 +00:00
pop bc
2015-11-05 01:20:14 +00:00
scf
ret
2015-11-13 05:49:27 +00:00
; 8d0be
2015-11-05 01:20:14 +00:00
2015-12-04 13:46:11 +00:00
AddOrSubtractY: ; 8d0be
2015-11-13 05:49:27 +00:00
push hl
2015-11-05 01:20:14 +00:00
ld a, [hl]
2015-12-04 13:46:11 +00:00
ld hl, wCurrSpriteAddSubFlags
2015-11-13 05:49:27 +00:00
bit 6, [hl]
jr z, .ok
2015-12-04 13:46:11 +00:00
; 8 - a
2015-11-13 05:49:27 +00:00
add $8
xor $ff
inc a
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.ok
pop hl
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8d0ce
2015-11-05 01:20:14 +00:00
2015-12-04 13:46:11 +00:00
AddOrSubtractX: ; 8d0ce
2015-11-05 01:20:14 +00:00
push hl
ld a, [hl]
2015-12-04 13:46:11 +00:00
ld hl, wCurrSpriteAddSubFlags
2015-11-13 05:49:27 +00:00
bit 5, [hl]
jr z, .ok
2015-12-04 13:46:11 +00:00
; 8 - a
2015-11-13 05:49:27 +00:00
add $8
xor $ff
inc a
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.ok
pop hl
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8d0de
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
Function8d0de: ; 8d0de
2015-12-04 13:46:11 +00:00
ld a, [wCurrSpriteAddSubFlags]
2015-11-13 05:49:27 +00:00
ld b, a
ld a, [hl]
xor b
and $e0
ld b, a
ld a, [hl]
and $1f
or b
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8d0ec
2015-11-05 01:20:14 +00:00
2015-12-04 13:46:11 +00:00
InitSpriteAnimBuffer: ; 8d0ec
2015-11-05 01:20:14 +00:00
xor a
2015-12-04 13:46:11 +00:00
ld [wCurrSpriteAddSubFlags], a
ld hl, SPRITEANIMSTRUCT_TILE_ID
2015-11-13 05:49:27 +00:00
add hl, bc
ld a, [hli]
ld [wCurrAnimVTile], a
2015-11-13 05:49:27 +00:00
ld a, [hli]
ld [wCurrAnimXCoord], a
2015-11-13 05:49:27 +00:00
ld a, [hli]
ld [wCurrAnimYCoord], a
2015-11-13 05:49:27 +00:00
ld a, [hli]
ld [wCurrAnimXOffset], a
2015-11-13 05:49:27 +00:00
ld a, [hli]
ld [wCurrAnimYOffset], a
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8d109
2015-11-05 01:20:14 +00:00
2015-12-04 13:46:11 +00:00
GetSpriteAnimVTile: ; 8d109
2015-11-19 23:07:20 +00:00
; a = wSpriteAnimDict[a] if a in wSpriteAnimDict else 0
2015-12-04 13:46:11 +00:00
; VTiles offset
2015-11-05 01:20:14 +00:00
push hl
push bc
2015-11-19 23:07:20 +00:00
ld hl, wSpriteAnimDict
2015-11-05 01:20:14 +00:00
ld b, a
2015-11-13 05:49:27 +00:00
ld c, 10
2015-11-05 01:20:14 +00:00
.loop
2015-11-13 05:49:27 +00:00
ld a, [hli]
2015-11-05 01:20:14 +00:00
cp b
2015-11-13 05:49:27 +00:00
jr z, .ok
2015-11-05 01:20:14 +00:00
inc hl
dec c
jr nz, .loop
2015-11-13 05:49:27 +00:00
xor a
jr .done
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.ok
ld a, [hl]
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.done
2015-11-05 01:20:14 +00:00
pop bc
pop hl
ret
2015-11-13 05:49:27 +00:00
; 8d120
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
Function8d120:: ; 8d120
2015-12-02 22:59:05 +00:00
ld hl, SPRITEANIMSTRUCT_01
2015-11-13 05:49:27 +00:00
add hl, bc
ld [hl], a
2015-12-02 22:59:05 +00:00
ld hl, SPRITEANIMSTRUCT_DURATION
2015-11-13 05:49:27 +00:00
add hl, bc
2015-12-02 22:59:05 +00:00
ld [hl], 0
ld hl, SPRITEANIMSTRUCT_FRAME
2015-11-13 05:49:27 +00:00
add hl, bc
2015-12-02 22:59:05 +00:00
ld [hl], -1
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
; 8d132
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
Function8d132: ; 8d132
2015-11-05 01:20:14 +00:00
.loop
ld hl, SPRITEANIMSTRUCT_DURATION
2015-11-13 05:49:27 +00:00
add hl, bc
ld a, [hl]
2015-11-05 01:20:14 +00:00
and a
jr z, .next_frame ; finished the current sequence
2015-11-13 05:49:27 +00:00
dec [hl]
call Function8d189 ; load pointer from Unknown_8d6e6
2015-11-13 05:49:27 +00:00
ld a, [hli]
push af
jr .okay
2015-11-13 05:49:27 +00:00
.next_frame
ld hl, SPRITEANIMSTRUCT_FRAME
2015-11-13 05:49:27 +00:00
add hl, bc
inc [hl]
call Function8d189 ; load pointer from Unknown_8d6e6
2015-11-13 05:49:27 +00:00
ld a, [hli]
cp -2
2015-11-13 05:49:27 +00:00
jr z, .minus_2
cp -1
2015-11-13 05:49:27 +00:00
jr z, .minus_1
2015-11-13 05:49:27 +00:00
push af
ld a, [hl]
2015-11-05 01:20:14 +00:00
push hl
2015-11-13 05:49:27 +00:00
and $3f
2015-12-04 13:46:11 +00:00
ld hl, SPRITEANIMSTRUCT_DURATIONOFFSET
2015-11-13 05:49:27 +00:00
add hl, bc
add [hl]
ld hl, SPRITEANIMSTRUCT_DURATION
2015-11-13 05:49:27 +00:00
add hl, bc
ld [hl], a
2015-11-05 01:20:14 +00:00
pop hl
.okay
2015-11-13 05:49:27 +00:00
ld a, [hl]
and $c0
srl a
2015-12-04 13:46:11 +00:00
ld [wCurrSpriteAddSubFlags], a
2015-11-13 05:49:27 +00:00
pop af
2015-11-05 01:20:14 +00:00
ret
2015-11-13 05:49:27 +00:00
.minus_1
xor a
ld hl, SPRITEANIMSTRUCT_DURATION
2015-11-13 05:49:27 +00:00
add hl, bc
ld [hl], a
ld hl, SPRITEANIMSTRUCT_FRAME
2015-11-13 05:49:27 +00:00
add hl, bc
rept 2
dec [hl]
endr
jr .loop
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
.minus_2
xor a
ld hl, SPRITEANIMSTRUCT_DURATION
2015-11-13 05:49:27 +00:00
add hl, bc
ld [hl], a
2015-11-13 05:49:27 +00:00
dec a
ld hl, SPRITEANIMSTRUCT_FRAME
2015-11-13 05:49:27 +00:00
add hl, bc
ld [hl], a
jr .loop
; 8d189
Function8d189: ; 8d189
; Get the data for the current frame for the current animation sequence
; Unknown_8d6e6[SpriteAnim[SPRITEANIMSTRUCT_01]][SpriteAnim[SPRITEANIMSTRUCT_FRAME]]
ld hl, SPRITEANIMSTRUCT_01
2015-11-13 05:49:27 +00:00
add hl, bc
ld e, [hl]
ld d, 0
ld hl, Unknown_8d6e6
rept 2
add hl, de
endr
ld e, [hl]
inc hl
ld d, [hl]
ld hl, SPRITEANIMSTRUCT_FRAME
2015-11-13 05:49:27 +00:00
add hl, bc
ld l, [hl]
ld h, 0
add hl, hl
add hl, de
ret
; 8d1a2
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
Function8d1a2: ; 8d1a2
; Load OAM data pointer
2015-11-13 05:49:27 +00:00
ld e, a
ld d, 0
ld hl, Unknown_8d94d
rept 3
add hl, de
endr
ret
; 8d1ac
2015-11-05 01:20:14 +00:00
2015-11-13 05:49:27 +00:00
Function8d1ac: ; unreferenced
push hl
ld l, a
ld h, 0
2015-11-05 01:20:14 +00:00
rept 2
2015-11-13 05:49:27 +00:00
add hl, hl
2015-11-05 01:20:14 +00:00
endr
2015-11-13 05:49:27 +00:00
ld de, Unknown_8e706 ; broken 2bpp pointers
add hl, de
ld c, [hl]
inc hl
ld b, [hl]
inc hl
ld e, [hl]
inc hl
ld d, [hl]
pop hl
push bc
call Request2bpp
pop bc
ret
; 8d1c4
Unknown_8d1c4: ; 8d1c4
2015-12-04 13:46:11 +00:00
; ??, sequence, tile
2015-11-13 15:48:49 +00:00
db $01, SPRITE_ANIM_SEQ_01, $00 ; 00
db $07, SPRITE_ANIM_SEQ_04, $00 ; 01
db $08, SPRITE_ANIM_SEQ_05, $05 ; 02
db $0a, SPRITE_ANIM_SEQ_06, $00 ; 03
db $0b, SPRITE_ANIM_SEQ_07, $06 ; 04
db $0c, SPRITE_ANIM_SEQ_08, $06 ; 05
db $0d, SPRITE_ANIM_SEQ_09, $07 ; 06
db $0e, SPRITE_ANIM_SEQ_0A, $07 ; 07
db $10, SPRITE_ANIM_SEQ_0B, $07 ; 08
db $08, SPRITE_ANIM_SEQ_0C, $05 ; 09
2015-12-04 13:46:11 +00:00
db $11, SPRITE_ANIM_SEQ_00, $00 ; 0a flying sprite
2015-11-13 15:48:49 +00:00
db $12, SPRITE_ANIM_SEQ_0D, $08 ; 0b
db $12, SPRITE_ANIM_SEQ_0E, $08 ; 0c
db $12, SPRITE_ANIM_SEQ_0F, $08 ; 0d
db $13, SPRITE_ANIM_SEQ_10, $00 ; 0e
db $15, SPRITE_ANIM_SEQ_00, $00 ; 0f
db $16, SPRITE_ANIM_SEQ_11, $00 ; 10
db $17, SPRITE_ANIM_SEQ_12, $00 ; 11
db $18, SPRITE_ANIM_SEQ_12, $00 ; 12
db $19, SPRITE_ANIM_SEQ_13, $00 ; 13
2015-12-04 13:46:11 +00:00
db $1a, SPRITE_ANIM_SEQ_14, $00 ; 14 radio tuning knob
2015-11-13 15:48:49 +00:00
db $1b, SPRITE_ANIM_SEQ_00, $00 ; 15
db $1d, SPRITE_ANIM_SEQ_15, $00 ; 16
db $1e, SPRITE_ANIM_SEQ_00, $00 ; 17
2015-12-04 13:46:11 +00:00
db $1d, SPRITE_ANIM_SEQ_17, $00 ; 18 flying leaves
2015-11-13 15:48:49 +00:00
db $1f, SPRITE_ANIM_SEQ_00, $00 ; 19
db $24, SPRITE_ANIM_SEQ_19, $00 ; 1a
db $25, SPRITE_ANIM_SEQ_00, $00 ; 1b
db $20, SPRITE_ANIM_SEQ_13, $00 ; 1c
db $26, SPRITE_ANIM_SEQ_1A, $00 ; 1d
db $2d, SPRITE_ANIM_SEQ_00, $00 ; 1e
db $2e, SPRITE_ANIM_SEQ_00, $00 ; 1f
db $2f, SPRITE_ANIM_SEQ_00, $00 ; 20
db $30, SPRITE_ANIM_SEQ_00, $00 ; 21
db $31, SPRITE_ANIM_SEQ_00, $00 ; 22
db $32, SPRITE_ANIM_SEQ_1B, $00 ; 23
db $33, SPRITE_ANIM_SEQ_1C, $00 ; 24
db $34, SPRITE_ANIM_SEQ_00, $00 ; 25
db $35, SPRITE_ANIM_SEQ_1D, $00 ; 26
db $37, SPRITE_ANIM_SEQ_1E, $00 ; 27
db $38, SPRITE_ANIM_SEQ_1E, $00 ; 28
2015-12-02 22:59:05 +00:00
db $39, SPRITE_ANIM_SEQ_20, $00 ; 29 intro unown
2015-11-13 15:48:49 +00:00
db $3f, SPRITE_ANIM_SEQ_21, $00 ; 2a
db $3e, SPRITE_ANIM_SEQ_22, $00 ; 2b
db $40, SPRITE_ANIM_SEQ_00, $00 ; 2c
2015-11-13 05:49:27 +00:00
; 8d24b
INCLUDE "engine/sprite_anims.asm" ; DoAnimFrame
2015-11-13 05:49:27 +00:00
INCLUDE "data/sprite_engine.asm"
; Unknown_8d6e6
; Unknown_8d94d
2015-11-13 05:49:27 +00:00
2015-12-04 13:46:11 +00:00
ApplySineWaveX: ; 8e72a
2015-11-13 05:49:27 +00:00
add $10
2015-12-04 13:46:11 +00:00
ApplySineWaveY: ; 8e72c
2015-11-13 05:49:27 +00:00
and $3f
cp $20
2015-12-04 13:46:11 +00:00
jr nc, .flip
call .ApplyOffset
2015-11-13 05:49:27 +00:00
ld a, h
ret
2015-12-04 13:46:11 +00:00
.flip
2015-11-13 05:49:27 +00:00
and $1f
2015-12-04 13:46:11 +00:00
call .ApplyOffset
2015-11-13 05:49:27 +00:00
ld a, h
xor $ff ; cpl
inc a
ret
; 8e741
2015-12-04 13:46:11 +00:00
.ApplyOffset: ; 8e741
2015-11-13 05:49:27 +00:00
ld e, a
ld a, d
ld d, 0
ld hl, .sinewave
2015-11-13 05:49:27 +00:00
rept 2
add hl, de
endr
ld e, [hl]
inc hl
ld d, [hl]
ld hl, 0
.loop
2015-11-13 05:49:27 +00:00
srl a
jr nc, .skip_add
2015-11-13 05:49:27 +00:00
add hl, de
.skip_add
2015-11-13 05:49:27 +00:00
sla e
rl d
2015-11-05 01:20:14 +00:00
and a
jr nz, .loop
2015-11-13 05:49:27 +00:00
ret
; 8e75d
.sinewave: ; 8e75d
2015-11-13 05:49:27 +00:00
sine_wave $100
2015-11-19 23:07:20 +00:00
AnimateEndOfExpBar: ; 8e79d
2015-11-19 23:07:20 +00:00
ld a, [hSGB]
ld de, EndOfExpBarGFX
2015-11-19 23:07:20 +00:00
and a
jr z, .load
ld de, SGBEndOfExpBarGFX
2015-11-19 23:07:20 +00:00
.load
ld hl, VTiles0 tile $00
lb bc, BANK(EndOfExpBarGFX), 1
2015-11-19 23:07:20 +00:00
call Request2bpp
ld c, $8
ld d, $0
.loop
2015-11-19 23:07:20 +00:00
push bc
call .AnimateFrame
2015-11-19 23:07:20 +00:00
call DelayFrame
pop bc
rept 2
inc d
endr
dec c
jr nz, .loop
2015-11-19 23:07:20 +00:00
call ClearSprites
ret
; 8e7c6
.AnimateFrame: ; 8e7c6
2015-11-19 23:07:20 +00:00
ld hl, Sprites
ld c, $8
.anim_loop
2015-11-19 23:07:20 +00:00
ld a, c
and a
ret z
dec c
ld a, c
sla a
sla a
sla a
push af
2015-11-19 23:07:20 +00:00
push de
push hl
2015-12-04 13:46:11 +00:00
call ApplySineWaveY
2015-11-19 23:07:20 +00:00
pop hl
pop de
add 13 * 8
2015-11-19 23:07:20 +00:00
ld [hli], a
2015-11-19 23:07:20 +00:00
pop af
push de
push hl
2015-12-04 13:46:11 +00:00
call ApplySineWaveX
2015-11-19 23:07:20 +00:00
pop hl
pop de
add 10 * 8 + 4
2015-11-19 23:07:20 +00:00
ld [hli], a
2015-11-19 23:07:20 +00:00
ld a, $0
ld [hli], a
ld a, $6 ; OBJ 6
2015-11-19 23:07:20 +00:00
ld [hli], a
jr .anim_loop
2015-11-19 23:07:20 +00:00
; 8e7f4
EndOfExpBarGFX: ; 8e7f4
INCBIN "gfx/battle/expbarend.2bpp"
SGBEndOfExpBarGFX: ; 8e804
INCBIN "gfx/battle/expbarend_sgb.2bpp"
2015-11-19 23:07:20 +00:00
ClearSpriteAnims2: ; 8e814
2015-11-19 23:07:20 +00:00
push hl
push de
push bc
push af
ld hl, wSpriteAnimDict
ld bc, wSpriteAnimsEnd - wSpriteAnimDict
.loop
ld [hl], $0
inc hl
dec bc
ld a, c
or b
jr nz, .loop
pop af
pop bc
pop de
pop hl
ret
; 8e82b