bool__false equ 0
bool__true equ 1
_stdbuf equ 1536
_arr equ 132
_putchr_proc_adr equ 1619
_std_print_adr__a equ _arr
_std_print_adr___10 equ _arr
_std_print_adr___11 equ _stdbuf
_std_print_adr___12 equ _putchr_proc_adr
timer equ 20
RANDOM equ 53770
CHBAS equ 756
button__state__pressed equ 0
STRIG equ 644
stick__state__left equ 11
stick__state__right equ 7
stick__state__down equ 13
STICK equ 632
COLOR0 equ 708
SDLSTL equ 560
s equ 32768
root__LM equ 15
root__RM equ 26
root__TM equ 1
root__BM equ 22
root__NEXT_LEFT equ 29
root__NEXT_TOP equ 5
root__WALL_CHR equ 69
root__RWALL_CHR equ 70
x equ 134
y equ 135
ti equ 136
c equ 137
nx equ 138
ny equ 139
steps equ 140
action__delay equ 141
j equ 142
k equ 143
down__lock equ 144
tile equ 145
next__tile equ 146
ntile equ 147
score equ 148
_s2___21 equ 128
draw__tile___24 equ 129
draw__tile___26 equ 130
_s4___27 equ 128
erase__tile___30 equ 129
erase__tile___32 equ 130
_s6___34 equ 128
test__collision___37 equ 129
test__collision___39 equ 130
test__collision___40 equ 131
_s7__y1 equ 150
_s9__y1 equ 151
_s10__x equ 152
_82 equ 153
   org $2e0
   dta a($2000)
   org $2000
;### tetris.atl(188) sdlstl = dl
   lda #<dl
   sta SDLSTL-0
   lda #>dl
   sta SDLSTL-0+1
;### tetris.atl(189) COLOR0(2) = 0
   lda #0
   sta COLOR0-0+2
;### tetris.atl(190) COLOR0(5) = 0
   sta COLOR0-0+5
   lda #>_42
   sta CHBAS
start__game:
;### tetris.atl(197) s(0,0) = "ATALAN TETRIS"
   ldy #0
   lda s_lo,y
   clc
   adc #0
   sta _arr-0
   lda s_hi,y
   adc #0
   sta _arr-0+1
   jsr _std_print_adr
   dta b(13),c'ATALAN TETRIS'
   dta b(0)
;### tetris.atl(198) s(NEXT_LEFT,3) = "NEXT"
   ldy #3
   lda s_lo,y
   clc
   adc #root__NEXT_LEFT
   sta _arr-0
   lda s_hi,y
   adc #0
   sta _arr-0+1
   jsr _std_print_adr
   dta b(4),c'NEXT'
   dta b(0)
;### tetris.atl(199) s(NEXT_LEFT,1)   = "SCORE: 0     "
   ldy #1
   lda s_lo,y
   clc
   adc #root__NEXT_LEFT
   sta _arr-0
   lda s_hi,y
   adc #0
   sta _arr-0+1
   jsr _std_print_adr
   dta b(13),c'SCORE: 0     '
   dta b(0)
;### tetris.atl(201) for y1:y
   lda #1
   sta _s7__y1
_lbl23:
;### tetris.atl(202) 	for x s(x,y1) = 0
   lda #16
   sta x
_lbl22:
   ldy _s7__y1
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy x
   lda #0
   sta (_arr),y
   inc x
   lda x
   cmp #26
   jne _lbl22
   inc _s7__y1
   lda _s7__y1
   cmp #22
   jne _lbl23
;### tetris.atl(204) for y1:TM..BM
   lda #root__TM
   sta _s9__y1
_lbl25:
;### tetris.atl(205)   s(LM,y1) = WALL_CHR
   ldy _s9__y1
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy #root__LM
   lda #root__WALL_CHR
   sta (_arr),y
;### tetris.atl(206)   s(RM,y1) = RWALL_CHR
   ldy #root__RM
   lda #root__RWALL_CHR
   sta (_arr),y
   inc _s9__y1
   lda _s9__y1
   cmp #23
   jne _lbl25
;### tetris.atl(208) for x:LM..RM
   lda #root__LM
   sta _s10__x
_lbl27:
;### tetris.atl(209) 	s(x,BM) = WALL_CHR
   ldy #root__BM
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy _s10__x
   lda #root__WALL_CHR
   sta (_arr),y
   inc _s10__x
   lda _s10__x
   cmp #27
   jne _lbl27
;### tetris.atl(211) action'delay = 0
   lda #0
   sta action__delay
;### tetris.atl(212) down'lock = false
   sta down__lock
;### tetris.atl(217) x,y = 19,1
   lda #19
   sta x
   lda #1
   sta y
;### tetris.atl(218) tile = RANDOM bitand 7
   lda RANDOM
   and #7
   sta tile
;### tetris.atl(219) next'tile = RANDOM bitand 7
   lda RANDOM
   and #7
   sta next__tile
;### tetris.atl(220) score = 0
   lda #0
   sta score-0
   sta score-0+1
;### tetris.atl(222) draw'tile next'tile NEXT_LEFT NEXT_TOP
   lda next__tile
   ldx #root__NEXT_LEFT
   ldy #root__NEXT_TOP
   jsr draw__tile
loop:
;### tetris.atl(226) steps = 20
   lda #20
   sta steps
;### tetris.atl(228) if STICK(0) = down and not down'lock then steps = 1
   lda STICK-0
   cmp #stick__state__down
   jne _lbl43
   lda down__lock
   cmp #bool__false
   jne _lbl43
   lda #1
   sta steps
_lbl28:
;### tetris.atl(277) if not test'collision(tile x y+1) then
   jmp _lbl43
_lbl44:
;### tetris.atl(232) 	draw'tile tile x y
   lda tile
   ldx x
   ldy y
   jsr draw__tile
;### tetris.atl(234) 	nx = x
   lda x
   sta nx
;### tetris.atl(235) 	ntile = tile
   lda tile
   sta ntile
;### tetris.atl(237) 	if STICK(0) <> down then down'lock = false
   lda STICK-0
   cmp #stick__state__down
   jeq _lbl31
   lda #bool__false
   sta down__lock
_lbl31:
;### tetris.atl(240) 	if action'delay > 0
   lda #0
   cmp action__delay
   jcs _lbl32
;### tetris.atl(241) 		action'delay = action'delay - 1
   dec action__delay
;### tetris.atl(242) 	else
   jmp _lbl35
_lbl32:
;### tetris.atl(243) 		action'delay = 6
   lda #6
   sta action__delay
;### tetris.atl(244) 		if STICK(0) = right
   lda STICK-0
   cmp #stick__state__right
   jne _lbl34
;### tetris.atl(245) 			inc nx
   inc nx
;### tetris.atl(246) 		else if STICK(0) = left
   jmp _lbl35
_lbl34:
   lda STICK-0
   cmp #stick__state__left
   jne _lbl36
;### tetris.atl(247) 			dec nx		
   dec nx
;### tetris.atl(248) 		else if STRIG(0) = pressed
   jmp _lbl35
_lbl36:
   lda STRIG-0
   cmp #button__state__pressed
   jne _lbl37
;### tetris.atl(249) 			ntile = rotation(tile)
   lda tile
   ;
   tax
   lda rotation-0,x
   sta ntile
;### tetris.atl(250) 		else
   jmp _lbl35
_lbl37:
;### tetris.atl(251) 			action'delay = 0
   lda #0
   sta action__delay
_lbl35:
;### tetris.atl(254) 	timer = 0
   lda #0
   sta timer
;### tetris.atl(257) 	erase'tile tile x y
_lbl40:
;### tetris.atl(255) 	while timer < 1
   lda timer
   cmp #1
   jcc _lbl40
_lbl39:
   lda tile
   ldx x
   ldy y
   jsr erase__tile
;### tetris.atl(262) 	if not test'collision ntile nx y then
   lda ntile
   ldx nx
   ldy y
   jsr test__collision
   cmp #bool__false
   jne _lbl41
;### tetris.atl(263) 		x = nx
   lda nx
   sta x
;### tetris.atl(264) 		tile = ntile
   lda ntile
   sta tile
_lbl41:
;### tetris.atl(266) 	dec steps
   dec steps
;### tetris.atl(269) 	if STICK(0) = down and not down'lock then
   lda STICK-0
   cmp #stick__state__down
   jne _lbl43
   lda down__lock
   cmp #bool__false
   jne _lbl43
;### tetris.atl(270) 			if steps > 5 then steps = 0
   lda #5
   cmp steps
   jcs _lbl43
   lda #0
   sta steps
_lbl43:
;### tetris.atl(230) while steps > 0
   lda #0
   cmp steps
   jcc _lbl44
_lbl30:
   lda y
   clc
   adc #1
   tay
   lda tile
   ldx x
   jsr test__collision
   cmp #bool__false
   jne _lbl45
;### tetris.atl(278) 	inc y
   inc y
;### tetris.atl(279) else
   jmp loop
_lbl45:
;### tetris.atl(280) 	draw'tile tile x y 
   lda tile
   ldx x
   ldy y
   jsr draw__tile
;### tetris.atl(284) 	y,ny = 21
   lda #21
   sta y
   sta ny
;### tetris.atl(306) 	s(29,1) = "SCORE: [score]"
   jmp _lbl54
_lbl60:
;### tetris.atl(287) 		collision = false
;### tetris.atl(288) 		for x where s(x,y) = 0 collision = true
   lda #16
   sta x
   ldx #bool__false
_lbl50:
   ldy y
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy x
   lda (_arr),y
   cmp #0
   jne _lbl49
   ldx #bool__true
_lbl49:
   inc x
   lda x
   cmp #26
   jne _lbl50
;### tetris.atl(290) 		if collision then
   cpx #bool__false
   jeq _lbl51
;### tetris.atl(291) 			for x s(x,ny) = s(x, y)
   lda #16
   sta x
_lbl53:
   ldy y
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy x
   lda (_arr),y
   tax
   ldy ny
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy x
   txa
   sta (_arr),y
   inc x
   lda x
   cmp #26
   jne _lbl53
;### tetris.atl(292) 			dec ny
   dec ny
;### tetris.atl(293) 			dec y 
   dec y
;### tetris.atl(294) 		else
   jmp _lbl54
_lbl51:
;### tetris.atl(295) 			score = score + 1
   inc score+0
   jne _lbl66
   inc score+1
_lbl66:
;### tetris.atl(297) 			dec y
   dec y
;### tetris.atl(299) 			for x
   lda #16
   sta x
_lbl59:
;### tetris.atl(300) 				c = s(x,y)
   ldy y
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy x
   lda (_arr),y
   tax
;### tetris.atl(301) 				if c = 64 then c = 67
   cmp #64
   jne _lbl56
   ldx #67
_lbl56:
;### tetris.atl(302) 				if c = 65 then c = 66
   cpx #65
   jne _lbl57
   ldx #66
_lbl57:
;### tetris.atl(303) 				if c = 68 then c = 67
   cpx #68
   jne _lbl58
   ldx #67
_lbl58:
;### tetris.atl(304) 				s(x,y) = c 
   ldy y
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy x
   txa
   sta (_arr),y
   inc x
   lda x
   cmp #26
   jne _lbl59
_lbl54:
;### tetris.atl(286) 	while y >= 1
   lda y
   cmp #1
   jcs _lbl60
_lbl48:
   ldy #1
   lda s_lo,y
   clc
   adc #29
   sta _arr-0
   lda s_hi,y
   adc #0
   sta _arr-0+1
   jsr _std_print_adr
   dta b(7),c'SCORE: '
   dta b(130),a(score)
   dta b(0)
;### tetris.atl(309) 	if STICK(0) = down then down'lock = true
   lda STICK-0
   cmp #stick__state__down
   jne _lbl61
   lda #bool__true
   sta down__lock
_lbl61:
;### tetris.atl(312) 	tile = next'tile
   lda next__tile
   sta tile
;### tetris.atl(313) 	erase'tile next'tile NEXT_LEFT NEXT_TOP
   ldx #root__NEXT_LEFT
   ldy #root__NEXT_TOP
   jsr erase__tile
;### tetris.atl(314) 	next'tile = random bitand 7
   lda RANDOM
   and #7
   sta next__tile
;### tetris.atl(315) 	draw'tile next'tile NEXT_LEFT NEXT_TOP
   ldy #root__NEXT_TOP
   jsr draw__tile
;### tetris.atl(316) 	x,y = 19,1
   lda #19
   sta x
   lda #1
   sta y
;### tetris.atl(320) 	if test'collision tile x y then goto game'over
   lda next__tile
   ldx #19
   ldy #1
   jsr test__collision
   cmp #bool__false
   jeq loop
game__over:
;### tetris.atl(329) s(19,10) = "GAME"
   ldy #10
   lda s_lo,y
   clc
   adc #19
   sta _arr-0
   lda s_hi,y
   adc #0
   sta _arr-0+1
   jsr _std_print_adr
   dta b(4),c'GAME'
   dta b(0)
;### tetris.atl(330) s(19,11) = "OVER"
   ldy #11
   lda s_lo,y
   clc
   adc #19
   sta _arr-0
   lda s_hi,y
   adc #0
   sta _arr-0+1
   jsr _std_print_adr
   dta b(4),c'OVER'
   dta b(0)
;### tetris.atl(334) erase'tile next'tile NEXT_LEFT NEXT_TOP
_lbl65:
;### tetris.atl(332) until STRIG(0) = pressed
   lda STRIG-0
   cmp #button__state__pressed
   jne _lbl65
_lbl64:
   lda next__tile
   ldx #root__NEXT_LEFT
   ldy #root__NEXT_TOP
   jsr erase__tile
;### tetris.atl(336) goto start'game
   jmp start__game
_lbl67:
   jmp _lbl67
dl:
;### tetris.atl(19) const dl:array = 3 times $70, $42, s, 23 times $02, $41, dl
   dta b(112)
   dta b(112)
   dta b(112)
   dta b(66)
   dta a(s)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(2)
   dta b(65)
   dta a(dl)
tiles:
;### tetris.atl(58) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(59) 	0,65,67,0
   dta b(0)
   dta b(65)
   dta b(67)
   dta b(0)
;### tetris.atl(60) 	0,66,0,0
   dta b(0)
   dta b(66)
   dta b(0)
   dta b(0)
;### tetris.atl(61) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(63) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(64) 	0,65,64,0
   dta b(0)
   dta b(65)
   dta b(64)
   dta b(0)
;### tetris.atl(65) 	0,66,67,0
   dta b(0)
   dta b(66)
   dta b(67)
   dta b(0)
;### tetris.atl(66) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(68) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(69) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(70) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(71) 	0,66,0,0
   dta b(0)
   dta b(66)
   dta b(0)
   dta b(0)
;### tetris.atl(73) 	0,65,67,0
   dta b(0)
   dta b(65)
   dta b(67)
   dta b(0)
;### tetris.atl(74) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(75) 	0,66,0,0
   dta b(0)
   dta b(66)
   dta b(0)
   dta b(0)
;### tetris.atl(76) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(78) 	66,68,0,0
   dta b(66)
   dta b(68)
   dta b(0)
   dta b(0)
;### tetris.atl(79) 	0 ,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(80) 	0 ,66,0,0
   dta b(0)
   dta b(66)
   dta b(0)
   dta b(0)
;### tetris.atl(81) 	0 ,0 ,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(83) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(84) 	0,66,68,0
   dta b(0)
   dta b(66)
   dta b(68)
   dta b(0)
;### tetris.atl(85) 	0,0,66,0
   dta b(0)
   dta b(0)
   dta b(66)
   dta b(0)
;### tetris.atl(86) 	0,0,0,0	
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(88) 	0,0,65,0
   dta b(0)
   dta b(0)
   dta b(65)
   dta b(0)
;### tetris.atl(89) 	0,65,67,0
   dta b(0)
   dta b(65)
   dta b(67)
   dta b(0)
;### tetris.atl(90) 	0,66,0,0
   dta b(0)
   dta b(66)
   dta b(0)
   dta b(0)
;### tetris.atl(91) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(93) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(94) 	66,68,67,0
   dta b(66)
   dta b(68)
   dta b(67)
   dta b(0)
;### tetris.atl(95) 	0,66,0,0
   dta b(0)
   dta b(66)
   dta b(0)
   dta b(0)
;### tetris.atl(96) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(98) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(99) 	66,68,0,0
   dta b(66)
   dta b(68)
   dta b(0)
   dta b(0)
;### tetris.atl(100) 	0,66,0,0
   dta b(0)
   dta b(66)
   dta b(0)
   dta b(0)
;### tetris.atl(101) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(103) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(104) 	66,67,67,0
   dta b(66)
   dta b(67)
   dta b(67)
   dta b(0)
;### tetris.atl(105) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(106) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(108) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(109) 	66,67,67,67
   dta b(66)
   dta b(67)
   dta b(67)
   dta b(67)
;### tetris.atl(110) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(111) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(113) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(114) 	66,67,68,0
   dta b(66)
   dta b(67)
   dta b(68)
   dta b(0)
;### tetris.atl(115) 	0,0,66,0
   dta b(0)
   dta b(0)
   dta b(66)
   dta b(0)
;### tetris.atl(116) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(118) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(119) 	0,65,0,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(120) 	66,67,0,0
   dta b(66)
   dta b(67)
   dta b(0)
   dta b(0)
;### tetris.atl(121) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(123) 	65,0,0,0
   dta b(65)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(124) 	66,67,67,0
   dta b(66)
   dta b(67)
   dta b(67)
   dta b(0)
;### tetris.atl(125) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(126) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(128) 	0, 0, 65,0
   dta b(0)
   dta b(0)
   dta b(65)
   dta b(0)
;### tetris.atl(129) 	66,67,67,0
   dta b(66)
   dta b(67)
   dta b(67)
   dta b(0)
;### tetris.atl(130) 	0, 0, 0, 0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(131) 	0, 0, 0, 0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(133) 	0 ,65,0 ,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(134) 	0 ,65,0 ,0
   dta b(0)
   dta b(65)
   dta b(0)
   dta b(0)
;### tetris.atl(135) 	0 ,66,67,0
   dta b(0)
   dta b(66)
   dta b(67)
   dta b(0)
;### tetris.atl(136) 	0 ,0 ,0 ,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(138) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(139) 	65,67,67,0
   dta b(65)
   dta b(67)
   dta b(67)
   dta b(0)
;### tetris.atl(140) 	66,0,0,0
   dta b(66)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(141) 	0,0,0,0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(143) 	0, 65,67,0
   dta b(0)
   dta b(65)
   dta b(67)
   dta b(0)
;### tetris.atl(144) 	66,67,0, 0
   dta b(66)
   dta b(67)
   dta b(0)
   dta b(0)
;### tetris.atl(145) 	0, 0, 0, 0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(146) 	0, 0, 0, 0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(148) 	66,68,0, 0
   dta b(66)
   dta b(68)
   dta b(0)
   dta b(0)
;### tetris.atl(149) 	0, 66,67, 0
   dta b(0)
   dta b(66)
   dta b(67)
   dta b(0)
;### tetris.atl(150) 	0, 0, 0, 0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
;### tetris.atl(151) 	0, 0, 0, 0
   dta b(0)
   dta b(0)
   dta b(0)
   dta b(0)
rotation:
;### tetris.atl(157) const rotation:array(tile) of tile = 7, 1, 10, 11, 14, 17, 18, 8, 9, 0, 2, 12, 13, 3, 15, 16, 4, 5, 6
   dta b(7)
   dta b(1)
   dta b(10)
   dta b(11)
   dta b(14)
   dta b(17)
   dta b(18)
   dta b(8)
   dta b(9)
   dta b(0)
   dta b(2)
   dta b(12)
   dta b(13)
   dta b(3)
   dta b(15)
   dta b(16)
   dta b(4)
   dta b(5)
   dta b(6)
   .align 1024
_42:
;### tetris.atl(191) set'font file "tetris.fnt"
   ins 'tetris.fnt'
s_lo:  :24 dta l(s + #*40)
s_hi:  :24 dta h(s + #*40)
tiles_lo:  :19 dta l(tiles + #*16)
tiles_hi:  :19 dta h(tiles + #*16)
   rts
draw__tile .proc
   sta draw__tile___24
   sty draw__tile___26
;### tetris.atl(160) 	ti = 0
   lda #0
   sta ti
;### tetris.atl(161) 	for j
   sta j
_lbl8:
;### tetris.atl(162) 		for k
   lda #0
   sta k
_lbl7:
;### tetris.atl(163) 			c = tiles(ti, tile)
   ldy draw__tile___24
   lda tiles_lo,y
   sta _arr-0
   lda tiles_hi,y
   sta _arr-0+1
   ldy ti
   lda (_arr),y
   sta c
;### tetris.atl(164) 			if c <> 0 then s(x+k,y+j) = c
   cmp #0
   jeq _lbl6
   txa
   clc
   adc k
   sta _s2___21
   lda draw__tile___26
   clc
   adc j
   tay
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy _s2___21
   lda c
   sta (_arr),y
_lbl6:
;### tetris.atl(165) 			ti = ti + 1
   inc ti
   inc k
   lda k
   cmp #4
   jne _lbl7
   inc j
   lda j
   cmp #4
   jne _lbl8
   rts
.endp
erase__tile .proc
   sta erase__tile___30
   sty erase__tile___32
;### tetris.atl(168) 	ti = 0
   lda #0
   sta ti
;### tetris.atl(169) 	for j
   sta j
_lbl13:
;### tetris.atl(170) 		for k
   lda #0
   sta k
_lbl12:
;### tetris.atl(171) 			c = tiles(ti, tile)
   ldy erase__tile___30
   lda tiles_lo,y
   sta _arr-0
   lda tiles_hi,y
   sta _arr-0+1
   ldy ti
   lda (_arr),y
   sta c
;### tetris.atl(172) 			if c <> 0 then s(x+k,y+j) = 0
   cmp #0
   jeq _lbl11
   txa
   clc
   adc k
   sta _s4___27
   lda erase__tile___32
   clc
   adc j
   tay
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy _s4___27
   lda #0
   sta (_arr),y
_lbl11:
;### tetris.atl(173) 			ti = ti + 1
   inc ti
   inc k
   lda k
   cmp #4
   jne _lbl12
   inc j
   lda j
   cmp #4
   jne _lbl13
   rts
.endp
test__collision .proc
   sta test__collision___37
   sty test__collision___39
;### tetris.atl(176) 	coll = false
   lda #bool__false
   sta test__collision___40
;### tetris.atl(177) 	ti = 0
   sta ti
;### tetris.atl(178) 	for j 
   sta j
_lbl19:
;### tetris.atl(179) 		for k
   lda #0
   sta k
_lbl18:
;### tetris.atl(180) 			c = tiles(ti, tile)
   ldy test__collision___37
   lda tiles_lo,y
   sta _arr-0
   lda tiles_hi,y
   sta _arr-0+1
   ldy ti
   lda (_arr),y
   sta c
;### tetris.atl(181) 			ti = ti + 1
   inc ti
;### tetris.atl(182) 			if c <> 0 if s(x+k,y+j) <> 0 then return true
   lda c
   cmp #0
   jeq _lbl17
   txa
   clc
   adc k
   sta _s6___34
   lda test__collision___39
   clc
   adc j
   tay
   lda s_lo,y
   sta _arr-0
   lda s_hi,y
   sta _arr-0+1
   ldy _s6___34
   lda (_arr),y
   sta _82
   cmp #0
   jeq _lbl17
   lda #bool__true
   sta test__collision___40
   jmp _exit32766
_lbl17:
   inc k
   lda k
   cmp #4
   jne _lbl18
   inc j
   lda j
   cmp #4
   jne _lbl19
_exit32766:
   lda test__collision___40
   rts
.endp
   icl 'C:\nes\atalan\codebase\atalan\platform\atari\atari.asm'
   icl 'C:\nes\atalan\codebase\atalan\processor\m6502\m6502.asm'

