home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / VOGLE / DRIVERS / IBMPC / MOUSE.ASM < prev    next >
Assembly Source File  |  2000-02-11  |  3KB  |  155 lines

  1.  
  2. MOUSE_TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  3. MOUSE_TEXT    ENDS
  4. MOUSE_DATA    SEGMENT  WORD PUBLIC 'DATA'
  5. MOUSE_DATA    ENDS
  6. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  7. _BSS    ENDS
  8. DGROUP    GROUP    _BSS,    MOUSE_DATA
  9.     ASSUME  CS: MOUSE_TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  10.  
  11. MOUSE_TEXT      SEGMENT
  12. public    _ismouse, _showmouse, _unshowmouse, _readmouse, _set_loc
  13.  
  14. ;
  15. ; The Microsoft mouse manual says that you should bung a 5 at location
  16. ; 40h:49h (Ie. The spot that says what mode we're in) for the mouse to work
  17. ; on a HERCULES Card.
  18. ;
  19. _set_loc   proc    far
  20.     push    bp
  21.     mov    bp, sp
  22.         push    si
  23.         push    di
  24.     push    bx
  25.  
  26.         mov     bx,40h
  27.         mov     es,bx
  28.         mov     bx,49h
  29.         mov     si,bx
  30.     mov    ah,es:[si]
  31.         mov     ah, byte ptr [bp + 6]
  32.         mov     byte ptr es:[si],ah            ; Bung something there
  33.  
  34.     mov    ax, [bp + 6]
  35.     pop     bx
  36.         pop     di
  37.         pop     si
  38.         mov     sp, bp
  39.         pop     bp
  40.  
  41.         ret
  42. _set_loc   endp
  43.  
  44. ;
  45. ; Check if the mouse driver is present, if it is, then set
  46. ; the x and y limits for it.
  47. ;
  48. _ismouse        proc far
  49.         push    bp
  50.         push    es
  51.         mov     bp,sp
  52.  
  53.         mov     ax,03533h       ;Get int 33h by calling int 21
  54.         int     21
  55.         mov     ax,es           ;Check segment, offset of int 33
  56.         or      ax,bx           ;vector. If 0 or pointing to IRET
  57.         jnz     yesdrv          ;then driver not installed.
  58.         mov     bl, es:[bx]
  59.         cmp     bl,0cfh
  60.         jne     yesdrv
  61.  
  62.         mov     ax,0            ; return 0 (false) if no driver
  63.         jmp     pissoff
  64.  
  65. yesdrv: 
  66.         mov     ax,0            ; Initialize mouse
  67.         int     33h
  68.         cmp     ax,0            ; Is mouse installed 
  69.         jz      pissoff         ; pissoff if not installed
  70.  
  71.     mov    ax,7        ;Function 7, set x limits
  72.     mov    cx,0        
  73.     mov    dx,[bp+6]
  74.     int    33h
  75.     mov    ax,8        ;Function 8, set y limits
  76.     mov    cx,0            
  77.     mov    dx,[bp+8]    
  78.     int    33h
  79.         mov     ax,1            ; return 1 (true) if driver installed
  80.  
  81. pissoff:                        ; pissoff back to caller.
  82.         mov     sp,bp
  83.         pop     es
  84.         pop     bp
  85.         ret     
  86.  
  87. _ismouse        endp
  88.  
  89. ;
  90. ; Turns the mouse cursor on
  91. ;
  92. _showmouse    proc far
  93.         push    bp
  94.         mov     bp,sp
  95.     mov    ax,1
  96.     int     33h
  97.     mov    sp,bp
  98.     pop    bp
  99.     ret
  100. _showmouse    endp
  101.  
  102. ;
  103. ; Turns the mouse cursor off
  104. ;
  105. _unshowmouse    proc far
  106.         push    bp
  107.         mov     bp,sp
  108.     mov    ax,2
  109.     int     33h
  110.     mov    sp,bp
  111.     pop    bp
  112.     ret
  113. _unshowmouse    endp
  114.  
  115. ;
  116. ;    readmouse(xmouse, ymouse)
  117. ;
  118. _readmouse      proc far
  119.         push    bp
  120.         mov     bp,sp
  121.     push    di
  122.     push    bx
  123.     push    cx
  124.     push    dx
  125. ;
  126. ;    Get mouse status.
  127. ;
  128.     mov     ax,3
  129.     int     33h
  130.     
  131.         mov    ax,bx                 ; return buttons 
  132.  
  133. ;       mov     di,[bp+4]            ;x  <= this is for small mem model
  134. ;        mov     word ptr [di],cx
  135. ;        mov     di,[bp+6]            ;y
  136. ;        mov     word ptr [di],dx
  137.  
  138.     les    di,[bp+6]        ; <= this is for large mem model
  139.     mov    word ptr es:[di],cx        ;x
  140.     les    di,[bp+10]
  141.     mov    word ptr es:[di],dx        ;y
  142.  
  143.     pop    dx
  144.     pop    cx
  145.     pop    bx
  146.     pop    di
  147.         mov     sp,bp
  148.         pop     bp
  149.         ret     
  150.  
  151. _readmouse      endp
  152.  
  153. MOUSE_TEXT    ENDS
  154. END
  155.