_arr equ 128
RANDOM equ 53770
VCOUNT equ 54283
WSYNC equ 54282
button__state__pressed equ 0
STRIG equ 644
dma__type__off equ 0
DMACTL equ 559
player__x equ 53248
player__gfx equ 53261
player__color equ 53266
player__size equ 53256
GRACTL equ 53277
i equ 130
hpos equ 1536
   org $2e0
   dta a($2000)
   org $2000
;### stars.atl(14) DMACTL = off
   lda #dma__type__off
   sta DMACTL
;### stars.atl(15) GRACTL = off
   sta GRACTL
;### stars.atl(19) for i 
   sta i
_lbl5:
;### stars.atl(20) 	hpos(i)  = RANDOM
   lda i
   ;
   tax
   lda RANDOM
   sta hpos-0,x
;### stars.atl(21) 	speed(i) = (RANDOM mod 4) + 1
   lda RANDOM
   and #3
   clc
   adc #1
   ldx i
   sta speed-0,x
;### stars.atl(22) 	col(i)   = RANDOM bitor 3			;make the star color light enough 
   lda RANDOM
   ora #3
   sta col-0,x
   inc i
   lda i
   cmp #243
   jne _lbl5
;### stars.atl(26) player(0).gfx = %00000001
   lda #1
   sta player__gfx-0
;### stars.atl(27) player(0).size = 0
   lda #0
   sta player__size-0
;### stars.atl(42) player(0).gfx = 0
   jmp _lbl6
_lbl10:
;### stars.atl(32) 		wait'line
   sta WSYNC
_lbl8:
;### stars.atl(31) 	until VCOUNT = 4 
   lda VCOUNT
   cmp #4
   jne _lbl10
_lbl9:
   lda #0
   sta i
_lbl12:
;### stars.atl(35) 		player(0).color = col(i)
   lda i
   ;
   tax
   lda col-0,x
   sta player__color-0
;### stars.atl(36) 		player(0).x = hpos(i)
   lda hpos-0,x
   sta player__x-0
;### stars.atl(37) 		hpos(i) = hpos(i) + speed(i)
   clc
   ldx i
   adc speed,x
   tax
   lda #<hpos
   sta _arr-0
   lda #>hpos
   clc
   adc i+1
   sta _arr-0+1
   ldy i-0+0
   txa
   sta (_arr),y
;### stars.atl(38) 		wait'line
   stx WSYNC
   inc i
   lda i
   cmp #243
   jne _lbl12
_lbl6:
;### stars.atl(29) until STRIG(0) = pressed
   lda STRIG-0
   cmp #button__state__pressed
   jne _lbl8
_lbl7:
   lda #0
   sta player__gfx-0
;### stars.atl(43) DMACTL = dl + playfield 
   lda #34
   sta DMACTL
_lbl14:
   jmp _lbl14
   icl 'C:\nes\atalan\codebase\atalan\platform\atari\atari.asm'
   icl 'C:\nes\atalan\codebase\atalan\processor\m6502\m6502.asm'

speed:
   .ds 243
col:
   .ds 243
