Base Waving - Sprite - Scroll (Codebase 64 Wiki)
Base Waving - Sprite - Scroll (Codebase 64 Wiki)
id=base:waving_sprite_scroll
In addition to that all, the Y-coords of the sprites are changed based on sine data.
This codes assumes a letter-per-sprite font, in the same order as the screencodes, located at $2000.
The code is a stripped down and somewhat simplified version of what is used in “This Is Halloweed” (https://csdb.dk/release
/?id=197114 [https://csdb.dk/release/?id=197114]).
*=$0801
BasicUpstart($0810)
*=$0810
sei
jsr $e544 // KERNAL: clear screen
lda #$00 // reset sine wave pointers
sta sinreset+1
sta sinwave+1
lda #$ff
sta $d015 // turn on all sprites
ldx #$00
!: lda #$a0 // init with spaces in all sprite pointers
sta SPRITEPOINTER,x
lda #$0e // light blue
sta $d027,x // set sprite colours
inx
cpx #$08
bne !-
sta $dc0d
sta $dd0d
lda $dc0d
lda $dd0d
cli
jmp *
irq:
inc $d019
noreset:
clc
adc #(>spriteMemory<<2) // correct for location of sprite font
sta SPRITEPOINTER+7 // store new letter in sprite 8 pointer
sinreset:
ldx #$00 // sine wave counter
stx sinwave+1 // store in sine wave pointer
inc sinreset+1
ldy #$00
sinwave:
lda sindata // read sine wave data
sta $d001,y // store in Y-coords sprites
lda sinwave+1
clc
adc #SINLEAP // to make wave more interesting
sta sinwave+1 // increase sine wave pointer by SINLEAP
iny
iny
cpy #$10 // next sprites
bne sinwave
jmp $ea31 // end of IRQ1
.align $100
sindata:
.fill 256, 120 + 15.5*sin(toRadians(i*(3*360)/256))
scrolltext:
.text "this is a sprite scroller for codebase64.org "
.byte $00