
;DRAW--Program to draw on screen  with sursor arrows
;For 320 * 200 medium res color mode
 up     equ    48h       ;scan code for up arrow
 down   equ    50h       ;scan code for down arrow
 right  equ    4dh       ;scan code for right arrow
 left   equ    4bh       ;scan code for left arrow
 escape equ    1bh       ;"Esc" character
;**************************************************
prognam   segment         ;define code segment
;--------------------------------------------------
main    proc     far
        assume   cs:prognam
start:  push    ds        ;set up stack for return       
        sub     ax,ax
	push	ax
;clear screen by scrolling it,using ROM call
	mov	ah,6	  ;scroll up function
	mov	al,0	  ;code to blank acreen
	mov	cx,0	  ;upper left = 0,0
	mov	dl,79	  ;lower right corner
	mov	dh,24	  ; at 79,24
	int	10h	  ;call video interrupt
;screen pointer will be in CX,DX registers
;row number ( 0 to 320d ) in DX
;column number ( 0 to 320d ) in CX
	mov	ah,0	  ;set grapgics mode
	mov	al,04	  ;320 * 200 color
	int	10h
	mov	ah,0bh	  ;set color patette
	mov	bh,0	  ;background
	mov	bl,0	  ;black
	int	10h
	mov	ah,0bh	  ;select palette
	mov	bh,01
	mov	bl,0	  ;palette 0
	int	10h
	mov	dx,100d	  ;set screen pointer to
	mov	cx,160d	  ;center of screen
;get character from keyboard
get_char:
	mov	ah,0	  ;code for read char
	int	16h	  ;keyboard I/O ROM call
	cmp	al,escape ;is it Esc char ?
	jz	exit	  ;yes
	cmp	al,33h	  ;is it more than "3" ?
	jg	plot	  ;yes,not a color
	cmp	al,30h	  ;is it less than "0" ?
	jl	plot	  ;yes,not a color
	mov	bl,al	  ;save it in BL
	and	bl,03
	jmp	get_char  ;get next character
;figure out which way to go,and draw new line
plot:	mov	al,ah	  ;put scan code in AL
	cmp	al,up	  ;is it up arrow ?
	jnz	not_up	  ;no
	dec	dx	  ;yes,decrement row
not_up:	cmp	al,down	  ;is it down arrow ?
	jnz	not_down  ;no
	inc	dx	  ;yes,increment row
not_down:
	cmp	al,right  ;isit right arrow ?
	jnz	not_right ;no
	inc	cx	  ;yes,increment column
not_right:
	cmp	al,left	  ;is it left arrow ?
	jnz	write	  ;no
	dec	cx	  ;yes,decrement column
;use ROM routine to write dot
;reguires row# in DX,col in CX,color in AL
write:	mov	al,bl	  ;setcolor value
	mov	ah,0ch	  ;write dot function
	int	10h	  ;video BIOS routine
	jmp	get_char  ;get next color and arrow
exit:	ret		  ;return to DOS
main	endp
;--------------------------------------------------
prognam	ends
	end	start
