examples: new sprite animation demo
This commit is contained in:
parent
bde01e402c
commit
e08d610aef
6 changed files with 186 additions and 24 deletions
|
|
@ -1,4 +1,5 @@
|
|||
.EQU SPRITE_HEIGHT 16
|
||||
.EQU SPRITE_HEIGHT 32 ; height in lines
|
||||
.EQU SPRITE_STRIPES 4 ; width in words i.e. 8-pixel stripes
|
||||
|
||||
.EQU WORDS_PER_LINE 80
|
||||
.EQU FB_RA $900
|
||||
|
|
@ -65,7 +66,8 @@ CALC_VMEM_ADDR:
|
|||
.EQU PS_Y 16
|
||||
.EQU PS_SHIFT_C 20
|
||||
.EQU PS_SPILL 24
|
||||
.EQU PS_FS 28
|
||||
.EQU PS_STRIPE_C 28
|
||||
.EQU PS_FS 32
|
||||
PUTSPRITE:
|
||||
FPADJ -PS_FS
|
||||
STORE PS_SPRITE_DATA
|
||||
|
|
@ -160,10 +162,14 @@ PS_LOOP2_X:
|
|||
STOREI ; store result into i/o reg
|
||||
DROP
|
||||
|
||||
;
|
||||
; process spilled bits and right half of sprite data
|
||||
;
|
||||
; set counter for remaining stripes
|
||||
LOADC SPRITE_STRIPES - 1
|
||||
STORE PS_STRIPE_C
|
||||
|
||||
;
|
||||
; process spilled bits and next vertical stripe of sprite data
|
||||
;
|
||||
PS_NEXT_STRIPE:
|
||||
; put spill bits on stack for later
|
||||
LOAD PS_SPILL
|
||||
|
||||
|
|
@ -176,7 +182,9 @@ PS_LOOP2_X:
|
|||
; reset spill bits
|
||||
LOADC 0
|
||||
STORE PS_SPILL
|
||||
|
||||
|
||||
; last spill bits are on ToS now
|
||||
|
||||
; shift pixel data to right
|
||||
LOAD PS_SHIFT_C ; load shift count
|
||||
PS_LOOP3: ; test it for zero
|
||||
|
|
@ -230,8 +238,14 @@ PS_LOOP3_X:
|
|||
SWAP
|
||||
STOREI
|
||||
DROP
|
||||
|
||||
; write spilled bits into next vmem word
|
||||
|
||||
LOAD PS_STRIPE_C ; decrement stripe count
|
||||
DEC 1
|
||||
DUP
|
||||
STORE PS_STRIPE_C
|
||||
CBRANCH.NZ PS_NEXT_STRIPE ; if non-zero, next stripe
|
||||
|
||||
; write spilled bits of the last stripe into next vmem word
|
||||
LOAD PS_SPILL ; get spill bits
|
||||
DUP
|
||||
LOADCP CALC_MASK ; calculate sprite mask for spill bits
|
||||
|
|
@ -274,7 +288,8 @@ PS_L_XT:
|
|||
.EQU UD_S_BGDATA 12
|
||||
.EQU UD_S_OFFSET 16
|
||||
.EQU UD_S_BGORIG 20
|
||||
.EQU UD_S_FS 24
|
||||
.EQU UD_STRIPE_C 24
|
||||
.EQU UD_S_FS 28
|
||||
UNDRAWSPRITE:
|
||||
FPADJ -UD_S_FS
|
||||
STORE UD_S_BGORIG
|
||||
|
|
@ -318,25 +333,35 @@ UD_S_L1:
|
|||
STOREI
|
||||
; reuse addr from STOREI
|
||||
|
||||
; load 2nd word of background data
|
||||
LOADC SPRITE_STRIPES - 1 ; set remaining stripe count
|
||||
STORE UD_STRIPE_C
|
||||
|
||||
UD_NEXT_STRIPE:
|
||||
; load next word of background data
|
||||
LOAD UD_S_BGDATA
|
||||
INC 4
|
||||
DUP
|
||||
STORE UD_S_BGDATA
|
||||
LOADI
|
||||
STOREI ; and write it to vmem
|
||||
DROP
|
||||
; reuse addr from STOREI
|
||||
|
||||
; if pixel shift is zero, no 3rd word
|
||||
LOAD UD_STRIPE_C ; decrease remaining stripe count
|
||||
DEC 1
|
||||
DUP
|
||||
STORE UD_STRIPE_C
|
||||
CBRANCH.NZ UD_NEXT_STRIPE ; if non-zero, next stripe
|
||||
|
||||
DROP ; remove addr from STOREI
|
||||
|
||||
; if pixel shift is zero, no spill word
|
||||
LOAD UD_S_PXS
|
||||
CBRANCH.Z UD_S_L2
|
||||
|
||||
; load 3rd word of background data
|
||||
; load next word of background data
|
||||
LOADCP FB_IO
|
||||
LOAD UD_S_BGDATA
|
||||
INC 4
|
||||
DUP
|
||||
STORE UD_S_BGDATA
|
||||
LOADI
|
||||
STOREI ; and write it to vmem
|
||||
DROP
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue