;Copyright 2000 - Mark McDonald All rights reserved
; MLOCATE routine for PowerBASIC
; PROC:    MLOCATE
; DECLARE: SUB MLOCATE(BYVAL integer, BYVAL integer)
; DESC:    Locate the mouse cursor.
;          MLOCATE Row, Col

;Extrn   GETSCRNMODE: Far

MCODE Segment Byte
        Assume  CS: MCODE

        Public  MLOCATE

MLOCATE Proc Far

ARG     Col:    WORD, Row: WORD = Retbytes
;--- Save All Registers for Power BASIC ---
        push    BP                      ;
        mov     BP,SP                   ;
        push    DS                      ; save DS for PowerBASIC
        mov     CX, Col                 ; put column in CX
        mov     DX, Row                 ; put row in DX
        DEC     CX                      ; convert to 0 base
        DEC     DX                      ; convert to 0 base

        mov     AL, 8                   ; 8 pixels per char in text mode
        mul     CL                      ; multiply by X position
        mov     CX, AX                  ; put back in CX

        mov     AL, 8                   ; 8 pixels per char in text mode
        mul     DL                      ; multiply by Y position
        mov     DX, AX                  ; put back in DX
        mov     AX, 04h                 ; function 04h, set mouse location
        int     33h                     ; call mouse interrupt

;--- Restore ALL Registers Saved for Power BASIC ---
        pop     DS                      ; restore DS
        pop     BP                      ; restore BP
        retf    Retbytes

MLOCATE EndP
MCODE EndS
        End