Mouse functions within Modula-2.

Below, you find my mouse handling libraries which I eveloped for FST Modula-2. They contain the most widely used mouse functions and are adequate to make fancy slidebars and such.
As usual: this software is GNU GPL. I omitted the GPL message, but I guess you got the picture.

DEFINITION MODULE for mouse control.

DEFINITION MODULE Mouse;


TYPE    MouseRecord = RECORD
            MouseX, MouseY,
            Status, Buttons     : CARDINAL;
        END;

PROCEDURE InitMouse (VAR MouseData : MouseRecord);
(*
    Initialize the mousedriver.
    On return, MouseButtons contains the number of buttons on the device,
    whereas the function returns the mouse status: 0FFFFH = Present
    *)

PROCEDURE ShowMouse;
(*
    Make Mouse cursor visible on screen
    *)

PROCEDURE HideMouse;
(*
    Make Mouse cursor invisible
    *)

PROCEDURE GetMouseStatus (VAR MouseData : MouseRecord);
(*
    Get mouse position and status of the buttons.
    *)

PROCEDURE SetMouseCursor (MouseH, MouseV : CARDINAL);
(*
    Set Mouse cursor to screen coordinates.
    *)

PROCEDURE ConfineMouse (MouseH, Mouseh, MouseV, Mousev : CARDINAL);
(*
    Define window in which the mouse can operate.
    *)

PROCEDURE SetCursorShape (Mode : BOOLEAN; AndMask, XorMask : CARDINAL);
(*
    Define shape of the mousecursor.
    IF Mode = FALSE THEN Software cursor, ELSE hardware cursor.
    AndMask and XorMask determine visual effects.
    *)

PROCEDURE ReadMouseMotion (VAR DeltaX, DeltaY : CARDINAL);
(*
    Get relative movement of the mousecursor since last call.
    *)

PROCEDURE SetMousePage (Page : CARDINAL);
(*
    Determine in which vidoe page the mouse will be active.
    *)

PROCEDURE GetMousePage (VAR MousePage : CARDINAL);
(*
    Retrieve the video page number in which the mouse is currently roving.
    *)

END Mouse.
   

IMPLEMENTATION MODULE for mouse control

IMPLEMENTATION MODULE Mouse;


FROM    SYSTEM      IMPORT  ASSEMBLER;

VAR     MouseData   : MouseRecord;


PROCEDURE InitMouse (VAR MouseData : MouseRecord);

BEGIN
    ASM
        XOR  AX, AX
        INT  33H
        LES  DI, MouseData
        MOV  ES:[DI+4], AX      (* AX=0 => no mouse *)
        MOV  ES:[DI+6], BX      (* Nr of buttons    *)
    END;
END InitMouse;


PROCEDURE ShowMouse;        (*  Make Mouse cursor visible on screen     *)

BEGIN
    ASM
        MOV     AX, 1
        INT     33H
    END;
END ShowMouse;


PROCEDURE HideMouse;        (*  Make Mouse cursor invisible     *)

BEGIN
    ASM
        MOV     AX, 2
        INT     33H
    END;
END HideMouse;


PROCEDURE GetMouseStatus (VAR MouseData : MouseRecord);

BEGIN
    ASM
        MOV     AX, 3
        INT     33H
        LES     DI, MouseData
        MOV     AX, CX
        STOSW
        MOV     AX, DX
        STOSW
        MOV     AX, BX
        STOSW
    END;
END GetMouseStatus;


PROCEDURE SetMouseCursor (MouseX, MouseY : CARDINAL);

BEGIN
    ASM
        MOV     AX, 4
        MOV     CX, MouseX
        MOV     DX, MouseY
        INT     33H
    END;
END SetMouseCursor;


PROCEDURE ConfineMouse (LeftX, RightX, LeftY, RightY : CARDINAL);

BEGIN
    ASM
        MOV     AX, 7
        MOV     CX, LeftX
        MOV     DX, RightX
        INT     33H
        MOV     AX, 8
        MOV     CX, LeftY
        MOV     DX, RightY
        INT     33H
    END;
END ConfineMouse;


PROCEDURE SetCursorShape (Mode : BOOLEAN; AndMask, XorMask : CARDINAL);

BEGIN
    ASM
        MOV     AX, 0AH
        MOV     BX, Mode
        MOV     CX, AndMask
        MOV     DX, XorMask
        INT     33H
    END;
END SetCursorShape;


PROCEDURE ReadMouseMotion (VAR DeltaX, DeltaY : CARDINAL);

BEGIN
    ASM
        MOV     AX, 0BH
        INT     33H
        LES     DI, DeltaX
        MOV     AX, CX
        STOSW
        LES     DI, DeltaY
        MOV     AX, DX
        STOSW
    END;
END ReadMouseMotion;


PROCEDURE SetMousePage (Page : CARDINAL);

BEGIN
    ASM
        MOV     BX, Page
        MOV     AX, 1DH
        INT     33H
    END;
END SetMousePage;


PROCEDURE GetMousePage (VAR MousePage : CARDINAL);

BEGIN
    ASM
        MOV     AX, 1EH
        INT     33H
        LES     DI, MousePage
        MOV     ES:[DI], BX
    END;
END GetMousePage;

END Mouse.
   

Page created in the 90's and