;painting the background for tick tac toe

IDEAL
MODEL small
STACK 600h
DATASEG
bg            equ 10 ;background color
red           equ 4  ;line color
x             dw 160
y             dw 100

CODESEG
proc          vertical
; before calling this, push the parameter of where to start the line (0-320)
              push bp
              mov  bp,sp
              mov  cx,[bp+4] ; location on the screen to start vertical line
              xor  dx,dx
l10:
              mov  bh,0h
              mov  al,red
              mov  ah,0ch
              int  10h
              inc  dx
              cmp  dx,200
              jne  l10
              pop  bp
              ret  2
endp          vertical              
 

proc          horizontal
; before calling this, push the parameter of where to start the line (0-200)
              push bp
              mov  bp,sp
              mov  dx,[bp+4] ; location on the screen to start horizontal line
              xor  cx,cx
l11:
              mov  bh,0h
              mov  al,red
              mov  ah,0ch
              int  10h
              inc  cx
              cmp  cx,320
              jne  l11
              pop  bp
              ret  2
endp          horizontal
 
              
proc          drawone                  
              push bx
              mov  bx,320
oneline:              
              mov  ah,0ch  
              int  10h 
              inc  cx
              dec  bx
              cmp  bx,0
              jnz  oneline
              pop  bx
              ret  
endp          drawone  
proc          background                ; 1 parameter - color
              push bp
              mov  bp,sp 
;Save registers state               
              push ax
              push bx
              push cx
              push dx               
              mov  al,[bp+4]            ; color
              mov  bx,200
              mov  cx,0
              mov  dx,0
drlines:              
              call drawone
              inc  dx
              mov  cx,0
              dec  bx
              cmp  bx,0
              jnz  drlines              ;loop on lines, creates the square
;Restore registers
			  pop  dx
			  pop  cx
			  pop  bx
			  pop  ax 
			  pop  bp
			  ret  2
endp          background

start:        mov  ax,@data
              mov  ds,ax 
; graphics mode              
              mov  ax,13h
              int  10h 
              push bg
              call background            ; Player asked for colorfull background  
              push 106
              call vertical
              push 212
              call vertical
              push 64
              call horizontal
              push 128
              call horizontal 
              
; Wait for key press
              mov  ah,00h
              int 16h
;return to text mode              
              mov  ah,0
              mov  al,2
              int  10h 
exit:         mov  ax, 4c00h
              int  21h
END start              