belgo.org

Stuff about Christopher Shepherd, with a seemingly incongruous domain name.

STARZ.S (Draw a star field, not my source, author unknown)


lst off
org $8000

lda #$c1
sta $c029 ;Graphics Screen

clc
xce
rep $30 ;16-bit mx

ldx #0 ; Palette Drawing
lda #$010 ; Blue
]lp stal $E19E02,x
pha
lda #$0FFF ; Red
stal $E19E1E,x
lda #$0FFF ; White
stal $E19E1C,x
txa
clc
adc #$20
tax
pla
clc
adc #$010
cpx #$200
bcc ]lp

]bigloop jsr wait
lda star1
star = *-2
cmp #$0000
beq ]reset
tax
lda #$FF00
stal $e12000,x
dex
cpx lmt1
lmt = *-2
beq ]limit
stx star1
val1 = *-2
inc star ;Set all locations for next star
inc star
inc lmt
inc lmt
inc val1
inc val1
inc val2
inc val2
inc val3
inc val3
lda #$0000
stal $e12000,x
bra ]bigloop
]reset lda #star1 ;Set all locations for first star
sta star
sta val1
sta val2
sta val3
lda #lmt1
sta lmt
bra ]bigloop
]limit lda star1 ;Reset star to far end of scanline
val2 = *-2
clc
adc #$a0
sta star1
val3 = *-2
bra ]bigloop

wait lda #$FFFF
]doda dec
cmp #$0000
bne ]doda
rts

star1 dw 50*$a0+100    ; Y=50, X=200
star2 dw 100*$a0+50    ; Y=100, X=100
star3 dw 150*$a0+70
star4 dw 10*$a0+150
star5 dw 170*$a0+140
hex 00,00

lmt1 dw 50*$a0
lmt2 dw 100*$a0
lmt3 dw 150*$a0
lmt4 dw 10*$a0
lmt5 dw 170*$a0
hex 00,00