			run start

			SDMCTL = $22f
			HPOSP0 = $d000
			HPOSM0 = $d004
			COLPM0 = $d012
			GRACTL = $d01d
			RANDOM = $d20a
			PMBASE = $d407
			WSYNC = $d40a
			VCOUNT = $d40b

			starpos = $5000
			starspeed = $5100
									
			org $4000
start			
			ldx #0
filltable	lda RANDOM
			sta starpos,x
			and #3
			sta starspeed,x
			lda #1				
			sta $3200,x
			dex
			bne filltable

			lda #3
			sta GRACTL	
			lda #42
			sta SDMCTL			
			lda #$30
			sta PMBASE
						
loop		ldx VCOUNT
			lda starpos,x
			sta HPOSP0
			stx COLPM0
			clc
			sbc starspeed,x
			sta starpos,x
			inx
			sta WSYNC
			jmp loop
