_stdbuf equ 1536
_arr equ 128
_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
WSYNC equ 54282
color__Black equ 0
color__White equ 15
COLOR0 equ 708
COLPF equ 53270
COLBK equ 53274
dl_command__BLANK8 equ 112
dl_command__CHR0 equ 2
dl_command__NEXT equ 65
SDLSTL equ 560
NMIEN equ 54286
VDSLST equ 512
VVBLKD equ 548
s equ 32768
   org $2e0
   dta a($2000)
   org $2000
;### interrupts.atl(39) sdlstl = gr0
   lda #<gr0
   sta SDLSTL-0
   lda #>gr0
   sta SDLSTL-0+1
;### interrupts.atl(40) COLOR0(2) = red+8
   lda #72
   sta COLOR0-0+2
;### interrupts.atl(41) COLOR0(5) = black
   lda #color__Black
   sta COLOR0-0+5
;### interrupts.atl(45) s(1,1) = "Demonstration of Interrupts in ATALAN"
   ldy #1
   lda s_lo,y
   clc
   adc #1
   sta _arr-0
   lda s_hi,y
   adc #0
   sta _arr-0+1
   jsr _std_print_adr
   dta b(37),c'Demonstration of Interrupts in ATALAN'
   dta b(0)
;### interrupts.atl(49) on'vbi cycle
   lda #<cycle
   sta VVBLKD-0
   lda #>cycle
   sta VVBLKD-0+1
;### interrupts.atl(50) on'dli set_col
   lda #<set_col
   sta VDSLST-0
   lda #>set_col
   sta VDSLST-0+1
   lda #192
   sta NMIEN
_lbl4:
   jmp _lbl4
gr0:
;### interrupts.atl(13) 	3 times BLANK8, 
   dta b(dl_command__BLANK8)
   dta b(dl_command__BLANK8)
   dta b(dl_command__BLANK8)
;### interrupts.atl(14) 	CHR0+LMS, s, 
   dta b(66)
   dta a(s)
;### interrupts.atl(15) 	2 times CHR0, 
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
;### interrupts.atl(16) 	CHR0+DLI, 
   dta b(130)
;### interrupts.atl(17) 	20 times CHR0, 
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
   dta b(dl_command__CHR0)
;### interrupts.atl(18) 	NEXT, gr0
   dta b(dl_command__NEXT)
   dta a(gr0)
s_lo:  :24 dta l(s + #*40)
s_hi:  :24 dta h(s + #*40)
   rts
set_col .proc
   pha
   txa
   pha
   tya
   pha
;### interrupts.atl(26) 	wait'line
   sta WSYNC
;### interrupts.atl(27) 	COLPF(2) = white	
   lda #color__White
   sta COLPF-0+2
   pla
   tay
   pla
   tax
   pla
   rti
.endp
cycle .proc
;### interrupts.atl(34) 	inc	COLOR0(5)
   inc COLOR0+5
;### interrupts.atl(35) 	COLBK = COLOR0(5)		;as we are using deferred VBI, we must copy the color to hardware register
   lda COLOR0-0+5
   sta COLBK
   jmp $e462
.endp
   icl 'C:\nes\atalan\codebase\atalan\platform\atari\atari.asm'
   icl 'C:\nes\atalan\codebase\atalan\processor\m6502\m6502.asm'

