;Copyright 2000 - Mark McDonald All rights reserved
; MWHERE routine for PowerBASIC
; DESC:    Return the location of the mouse cursor and which button(s)
;          pressed.
; EXAMP:   MWHERE Button, Row, Col

MCODE Segment Byte
        Assume  CS: MCODE

        Public MWHERE

MWHERE Proc Far

ARG     Col:    DWORD, Row: DWORD, BTN: DWORD = Retbytes

        push    BP                      ;
        mov     BP,SP                   ;
        push    DS                      ;
;--- CAll Mouse Driver ---
        mov     ax,0003h
        int     33h
;--- Get Row ---
        shr     dx,1
        shr     dx,1
        shr     dx,1
        add     dx,+001h
;--- Get Col ---
        shr     cx,1
        shr     cx,1
        shr     cx,1
        add     cx,+001h
;--- Load into Sub Parms ---
        lds     SI, BTN                 ; get location of button var
        mov     DS: [SI], BX            ; put pressed button in var
        lds     SI, Col                 ; get location of col var
        mov     DS: [SI], CX            ; put column in var
        lds     SI, Row                 ; get location of row var
        mov     DS: [SI], DX            ; put row in var
;--- Restore Registers ---
        pop     DS                      ;
        pop     BP                      ;
        retf    Retbytes                ;

MWHERE EndP
MCODE EndS
        End