TITLE GRID -- Program to draw grid on screen
;   use ROM routine
;   For 320 x 200 medium res color mode
;-----------------------------------------------------
pro_nam	segment			;define code segment
assume	cs:pro_nam
;-----------------------------------------------------
main	proc	far		;main part of prognam
start:
	push	ds		;set up stack for ret
	sub	ax,ax
	push	ax

	mov	ah,0
	mov	al,4
	int	10h		;call video interrupt

	call	hori		;draw horizontal lines
	mov	ah,0		;kbd input
	int	16h

	mov	ah,0		;clear screen
	mov	al,4
	int	10h

	call	vert		;draw vertical line
	mov	ah,0
	int	16h

	mov	ah,0		;clear screen
	mov	al,4
	int	10h

	call	hori		;draw horizontal
	call	vert		;  and vertical line

	mov	ah,0		;entre any key
	int	16h		;  for return

	mov	ah,0		;reset video mode
	mov	al,3		;80 x 25 color text
	int	10h

	ret			;return
main	endp
;-----------------------------------------------------
hori	proc	near
;draw horizontal lines every 20 pixels
	mov	dx,0		;row number in DX
hline:
	mov	cx,0		;column number in CX
hdot:
	mov	al,1		;set color to 1
	mov	ah,0ch		;write dot function
	int	10h		;call video ROM
	inc	cx		;next dot
	cmp	cx,300		;done all dots ?
	jl	hdot		;not yet
	add	dx,20		;next horizontal line
	cmp	dx,200		;off the screen yet ?
	jl	hline		;not yet
	ret
hori	endp
;------------------------------------------------------
vert	proc near
;draw one vertical lines every 20 pixels
	mov	cx,0		;set to first line
vline:
	mov	dx,0		;start of vert line
vdot:
	mov	al,2		;set color to 2
	mov	ah,0ch		;write dot funtion
	int	10h		;call video ROM
	inc	dx		;next dot
	cmp	dx,180		;done all dots ?
	jl	vdot		;not yet
	add	cx,20		;next vertical line
	cmp	cx,320		;off the screen yet ?
	jl	vline		;do next line
	ret			;return
vert	endp
;-----------------------------------------------------
pro_nam	ends			;end of code segment
	end	start
			