; 05-sprites.s - sixteen sprites from the 128-entry engine, moved once a frame ; ; cl65 -t c64 -C c64-asm.cfg -u __EXEHDR__ --asm-include-dir ../include -o 05-sprites.prg 05-sprites.s .include "vicx.inc" .include "vicxlib.inc" PATTERN = $8000 ; a multiple of 32 COUNT = 16 CLRSCR = $E544 ; KERNAL: clear the text screen frame = $FB ; two free zero-page bytes temp = $FC .code jsr CLRSCR ; start with an empty text screen sei VICX_UNLOCK_SEQ lda VICX_ID0 cmp #$56 beq found cli rts found: SET_PAL 32, 255, 255, 255 SET_PAL 33, 250, 212, 64 SET_PAL 34, 214, 64, 52 ; One 8x8 pattern, one byte per pixel, color 0 transparent. VICX_P0_SET PATTERN, VICX_STEP_1 ldx #0 copy: lda shape,x sta VICX_P0_DATA inx cpx #64 bne copy lda #VICX_CTRL_SPR sta VICX_CTRL lda #0 sta frame loop: lda VICX_FRAME ; the table is latched at the start of a frame wait: cmp VICX_FRAME beq wait inc frame ; Rewrite the first COUNT entries: 8 bytes each, straight through port 0. VICX_P0_SET VICX_SPRITES, VICX_STEP_1 ldx #0 next: txa ; X = frame x (1, 2 or 3) + 8 x sprite number and #3 tay lda #0 clc speed: adc frame dey bpl speed sta temp txa asl asl asl clc adc temp sta VICX_P0_DATA ; +0 X low lda #VICX_SW_8 | VICX_SH_8 sta VICX_P0_DATA ; +1 X high bits, size txa ; Y = 12 x sprite number asl asl sta temp asl clc adc temp sta VICX_P0_DATA ; +2 Y low lda #VICX_S_ON sta VICX_P0_DATA ; +3 Y high bits, on lda #<(PATTERN / 32) sta VICX_P0_DATA ; +4 pattern address / 32 lda #>(PATTERN / 32) sta VICX_P0_DATA lda #VICX_S_8BIT sta VICX_P0_DATA ; +6 8-bit pixels lda #0 sta VICX_P0_DATA ; +7 hit mask inx cpx #COUNT bne next jmp loop ; runs until reset shape: .byte 0, 0,34,34,34,34, 0, 0 .byte 0,34,33,33,33,33,34, 0 .byte 34,33,32,32,33,33,33,34 .byte 34,33,32,33,33,33,33,34 .byte 34,33,33,33,33,33,33,34 .byte 34,33,33,33,33,33,33,34 .byte 0,34,33,33,33,33,34, 0 .byte 0, 0,34,34,34,34, 0, 0