
INT #$13
LOOP INT #$15
JSR DRAW
INT #$14
JMP LOOP


DRAW
JSR DRAWGRID
RTS


DRAWLINE
LDX $1FE01
LDY $1FE02
XLOOP 
INX
LDA $1FE01
ADC $1FE04
CPX A
LDA $1FE07
INT #$16
BNE XLOOP
RTS

; draw rectangle sub routine
; takes memory locations $1FE01 (X) $1FE04 (X2)
; $1FE02 (Y1) $1FE03 (Y2) 

DRAWRECT 
LDA $1FE02
YLOOP INC
PHA
STA $1FE02
JSR DRAWLINE
PLA
ADC #1
LDX $1FE03
CPX A
BNE YLOOP
RTS

; draw grid

DRAWGRID
GRIDLOOP
LDA $1FE07 ; load the color
ADC #1 ; add 1 to the color
STA $1FE07 ; store the color
LDA $1FE01 ; load the X1
ADC #2 ; add 2 to the X1
STA $1FE01 ; store the X1
ADC #2 ; add 2 to the X2
STA $1FE04 ; store the X2
ADC #2 
STA $1FE02 ; 
ADC #16
STA $1FE03
JSR DRAWRECT
RTS