;Copyright 2000 - Mark McDonald All rights reserved
; MCOLS routine for PowerBASIC
; DECLARE: SUB MCOLS(BYVAL integer, BYVAL integer)
; DESC:    Set Mouse horizontal limits.
; EXAMP:   MCOLS Col, Cols

extrn   GETVMODE: Far

MCODE Segment Byte
        Assume  CS: MCODE

        Public  MCOLS

MCOLS Proc Far

ARG     Cols:   WORD, Col: WORD = Retbytes

        push    BP                      ;
        mov     BP, SP                  ;
        push    DS                      ;

;       call    GETVMODE                ; get screen mode

        mov     CX, Col                 ; CX = Col
        dec     CX                      ; make zero based

;       cmp     AX, 3                   ; 80 x 25 color?
;       je      FixCol                  ; yes, adjust
;       cmp     AX, 7                   ; 80 x 25 mono?
;       jne     GetCols                 ; no, get columns
FixCol:
        add     CX, CX                  ; times 2
        add     CX, CX                  ; times 4
        add     CX, CX                  ; times 8
GetCols:
        mov     DX, Cols                ; DX = Cols
        dec     DX                      ; zero based

;       cmp     AX, 3                   ; 80 x 25 color?
;       je      FixCols                 ; yes, adjust
;       cmp     AX, 7                   ; 80 x 25 mono?
;       jne     SetLimit                ; no, get columns
FixCols:
        add     DX, DX                  ; times 2
        add     DX, DX                  ; times 4
        add     DX, DX                  ; times 8
SetLimit:
        add     DX, CX                  ; add Col and Cols

        mov     AX, 07h                 ;
        int     33h                     ;

        pop     DS                      ;
        pop     BP                      ;
        retf    Retbytes                ;

MCOLS EndP
MCODE EndS
        End