; Horizontal Stars
; Demo program for ATALAN programming language

;(c) 2010 Rudla Kudla


use atari

i:0..242				; number of lines with stars
hpos:array(242) of byte
speed:array(242) of 1..4
col:array(242) of color

;Turn off screen, so we have nice black deep space


DMACTL = off
GRACTL = off

;Initialize start positions, speeds and colors


for i 
	hpos(i)  = RANDOM
	speed(i) = (RANDOM mod 4) + 1
	col(i)   = RANDOM bitor 3			;make the star color light enough 

;Setup sprite 0


player(0).gfx = %00000001
player(0).size = 0

until STRIG(0) = pressed

	until VCOUNT = 4 
		wait'line
		
	for i
		player(0).color = col(i)
		player(0).x = hpos(i)
		hpos(i) = hpos(i) + speed(i)
		wait'line

;Turn off sprite and turn on screen


player(0).gfx = 0
DMACTL = dl + playfield