;Copyright 2000 - Mark McDonald All rights reserved
; ISMOUSE routine for PowerBASIC
; DECLARE: FUNCTION ISMOUSE() AS INTEGER
; DESC:    Returns 1 if a mouse/mouse driver is present.
; EXAMP:   UseMouse = IsMouse     ' enable mouse handling if mouse exists

MCODE Segment Byte
        Assume  CS: MCODE

        Public  ISMOUSE

ISMOUSE Proc Far

        push    DS                      ;
        push    BP

        xor     AX, AX                  ; clear AX
        mov     ES, AX                  ; and ES
        mov     BX, 0CCh                ; location of mouse interrupt address
        les     BX, ES:[BX]             ; in BIOS
        mov     BL, Byte Ptr ES: [BX]   ; get vector pointer
        or      AL, BL                  ; is anything there?
        jz      Exit                    ; no, exit

        mov     AX, 3533h               ; ask DOS where the mouse interrupt is
        int     21h                     ;
        mov     AX, ES                  ; put segment in AX
        or      AX, BX                  ; anything there?
        je      Exit                    ; no, exit

        xor     AX, AX                  ; get mouse type
        int     33h                     ; call mouse interrupt
                                        ; AX returns 0 if no mouse present
        or      AX, AX                  ; anything there?
        jz      Exit                    ; no, exit
        mov     AX, 1                   ; yes, return true
Exit:
        pop     BP
        pop     DS                      ;
        retf                            ;

ISMOUSE EndP
MCODE EndS
        End