; Mouse manipulations.  left-click paints a dot, right-click gets out.

IDEAL
MODEL small
STACK 100h
DATASEG
color         db   14 
CODESEG

start:        mov ax, @data
              mov ds, ax
;graphics mode
              mov  ax,13h
              int  10h
;Init mouse
              mov  ax,0h
              int  33h
;Show mouse
              mov  ax,1h
              int  33h                                         
 
; Wait for key press
;              mov  ah,00h  
;              int  16h 
 
 
;Loop until  mouse clicked  

                   
mousecl:      xor  bx,bx           
              mov  ax,3h
              int  33h
              cmp  bx,01h  
              je   paint    ; left-click
              cmp  bx,02h
              je   stop     ; right-click
              jmp  mousecl
              
;Print dot near mouse
paint:
              shr  cx,1    ; adjust cx to 0-319 range
              sub  dx,1    ; So the mouse does not block the dot (one pixel above)
              mov  bh,0h
              mov  al,[color]
              mov  ah,0Ch
              int  10h

	          jmp  mousecl
;Text mode
stop:         mov  ax,3h
              int  10h                                            
                         
exit:         mov  ax, 4c00h
              int  21h
END start   