home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0000 - 0009 / ibm0000-0009 / ibm0003.tar / ibm0003 / TPOWER53.ZIP / TPASM.ARC / TPMOUSE.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-07-10  |  17.4 KB  |  694 lines

  1. ;******************************************************
  2. ;           TPMOUSE.ASM 5.07
  3. ;           Mouse support routines
  4. ;     Copyright (c) TurboPower Software 1988.
  5. ; Portions copyright (c) Sunny Hill Software 1985, 1986
  6. ;     and used under license to    TurboPower Software
  7. ;         All rights reserved.
  8. ;******************************************************
  9.  
  10.     INCLUDE    TPCOMMON.ASM
  11.  
  12. ;******************************************************    Data
  13.  
  14. DATA    SEGMENT    BYTE PUBLIC
  15.  
  16.     ;Pascal    variables
  17.  
  18.     EXTRN    ScreenHeight : BYTE    ;Current height    of display
  19.     EXTRN    ScreenWidth : BYTE    ;Current width of display
  20.  
  21.     EXTRN    MouseInstalled : BYTE    ;set to    True if    mouse installed
  22.     EXTRN    MouseCursorOn :    BYTE    ;keeps tracks of mouse cursor visibility
  23.  
  24.     EXTRN    MouseXLo : BYTE        ;coordinates for mouse window
  25.     EXTRN    MouseXHi : BYTE
  26.     EXTRN    MouseYLo : BYTE
  27.     EXTRN    MouseYHi : BYTE
  28.  
  29.     EXTRN    MouseRoutine : DWORD    ;user's event handler
  30.     EXTRN    MouseRoutineEvent : BYTE
  31.  
  32.     EXTRN    MouseEvent : BYTE    ;last mouse event
  33.     EXTRN    MouseStatus : BYTE    ;last button status
  34.     EXTRN    MouseLastX : BYTE    ;last horizontal coordinate
  35.     EXTRN    MouseLastY : BYTE    ;last vertical coordinate
  36.  
  37. DATA    ENDS
  38.  
  39. ;******************************************************    Code
  40.  
  41. CODE    SEGMENT    BYTE PUBLIC
  42.  
  43.     ASSUME    CS:CODE,DS:DATA
  44.  
  45.     PUBLIC    InitializeMouse, ShowMousePrim,    HideMousePrim
  46.     PUBLIC    MouseWhereXY, MouseWhereX, MouseWhereY,    MouseGotoXY
  47.     PUBLIC    MouseButtonPressed, MouseButtonReleased
  48.     PUBLIC    MouseWindow, SoftMouseCursor, HardMouseCursor
  49.     PUBLIC    GetMousePage, SetMousePage
  50.     PUBLIC    MouseEventPrim,    MouseEventHandler
  51.     PUBLIC    GetMickeyCount,    SetMickeyToPixelRatio
  52.     PUBLIC    GetStorageSize,    SaveMouseStatePrim, RestoreMouseStatePrim
  53.  
  54. ;******************************************************    Macros
  55.  
  56. MouseCall    MACRO    Function
  57.         MOV    AX,Function    ;function code into AX
  58.         INT    33h        ;call the mouse    driver
  59.         ENDM
  60.  
  61. CheckMouse    MACRO    PopCount
  62.         LOCAL OK
  63.         CMP    MouseInstalled,True
  64.         JE    OK
  65.         XOR    AX,AX        ;return    0 in AX
  66.         RET    PopCount    ;return
  67.     OK:
  68.         ENDM
  69.  
  70. ;******************************************************    MouseEventPrim
  71.  
  72. ;procedure MouseEventPrim(EventMask : MouseEventType;
  73. ;              UserRoutine :    Pointer); external;
  74.  
  75. ;Specify the address of    a routine to be    called when certain mouse events occur
  76.  
  77. EventMask    EQU WORD PTR [BP+10]
  78. UserRoutine    EQU DWORD PTR [BP+6]
  79.  
  80. MouseEventPrim    PROC FAR
  81.  
  82.     CheckMouse 6        ;make sure mouse is installed
  83.     StackFrameBP        ;set up    stack frame
  84.     MOV    CX,EventMask
  85.     LES    DX,UserRoutine
  86.     MouseCall 12        ;Set User-Defined Subroutine Input Mask
  87.     ExitCode 6        ;clean up stack    and return
  88.  
  89. MouseEventPrim    ENDP
  90.  
  91. ;******************************************************    MouseEventHandler
  92.  
  93. ;procedure MouseEventHandler;
  94.  
  95. MouseEventHandler    PROC FAR
  96.  
  97.     PUSH    AX        ;save all registers
  98.     PUSH    BX
  99.     PUSH    CX
  100.     PUSH    DX
  101.     PUSH    SI
  102.     PUSH    DI
  103.     PUSH    DS
  104.     PUSH    ES
  105.     PUSH    BP
  106.  
  107.     MOV    SI,SEG DATA    ;set up    our DS
  108.     MOV    DS,SI
  109.  
  110.     ;store event information in global variables
  111.     PUSH    AX        ;save event info
  112.     MOV    MouseEvent,AL    ;save the event    mask in    MouseEvent
  113.     MOV    MouseStatus,BL    ;save the button status    in MouseStatus
  114.     MOV    AX,CX        ;scale last horizontal coordinate
  115.     CALL    ScaleDownX
  116.     MOV    MouseLastX,AL    ;save last horizontal in MouseLastX
  117.     MOV    AX,DX        ;scale last vertical coordinate
  118.     CALL    ScaleDownY
  119.     MOV    MouseLastY,AL    ;save last vertical in MouseLastY
  120.     POP    AX        ;restore event info
  121.  
  122.     TEST    AL,MouseRoutineEvent    ;is this an event they're interested in?
  123.     JZ    mehExit        ;if not, don't call them
  124.  
  125.     LES    DI,MouseRoutine    ;ES:DI = MouseRoutine
  126.     MOV    SI,ES        ;SI has    segment, DI has    offset
  127.     OR    SI,DI        ;MouseRoutine =    nil?
  128.     JZ    mehExit        ;if so,    exit
  129.  
  130.     ;MouseRoutine not nil, so call it
  131.     CallFar    MouseRoutine    ;call user-written event handler
  132.  
  133. mehExit:
  134.     POP    BP        ;restore registers
  135.     POP    ES
  136.     POP    DS
  137.     POP    DI
  138.     POP    SI
  139.     POP    DX
  140.     POP    CX
  141.     POP    BX
  142.     POP    AX
  143.     RET            ;and do    a FAR return
  144.  
  145. MouseEventHandler    ENDP
  146.  
  147. ;******************************************************    InitializeMouse
  148.  
  149. ;procedure InitializeMouse;
  150.  
  151. ;Reinitializes mouse and sets MouseInstalled.
  152.  
  153. InitializeMouse    PROC FAR
  154.  
  155.     MOV    MouseCursorOn,False    ;reset cursor flag
  156.     MOV    MouseInstalled,False    ;assume    failure
  157.  
  158.     MOV    AX,3533h        ;Get INT 33 vector
  159.     INT    21h            ;call DOS
  160.     MOV    AX,ES            ;is vector nil?
  161.     OR    BX,AX
  162.     JZ    MIexit            ;if so,    no mouse
  163.  
  164.     MouseCall 0            ;Mouse Installed Flag and Reset    function
  165.     CMP    AX,-1            ;function returns 0 if not installed, else -1
  166.     JNE    MIexit
  167.     INC    MouseInstalled        ;it's installed
  168.  
  169.     MOV    MouseRoutine.Segm,0    ;reset our event variables
  170.     MOV    MouseRoutine.Ofst,0
  171.     MOV    MouseRoutineEvent,0
  172.     MOV    MouseEvent,0
  173.     MOV    MouseStatus,0
  174. MIexit:
  175.     RET
  176.  
  177. InitializeMouse    ENDP
  178.  
  179. ;******************************************************    ShowMousePrim
  180.  
  181. ;procedure ShowMousePrim;
  182. ;Show the mouse    cursor.
  183.  
  184. ShowMousePrim    PROC FAR
  185.  
  186.     CheckMouse 0        ;make sure mouse is installed
  187.     MOV    MouseCursorOn,True
  188.     MouseCall 1        ;Show Cursor function
  189.     RET
  190.  
  191. ShowMousePrim    ENDP
  192.  
  193. ;******************************************************    HideMousePrim
  194.  
  195. ;procedure HideMousePrim;
  196. ;Hide the mouse    cursor.
  197.  
  198. HideMousePrim    PROC FAR
  199.  
  200.     MOV    MouseCursorOn,False
  201.     CheckMouse 0        ;make sure mouse is installed
  202.     MouseCall 2        ;Hide Cursor function
  203.     RET
  204.  
  205. HideMousePrim    ENDP
  206.  
  207. ;******************************************************    ScaleUpY
  208.  
  209. ;on entry, BL has a screen row coordinate to be    scaled into the    mouse's
  210. ;  coordinate system
  211. ;on exit, AX has the result
  212.  
  213. ScaleUpY    PROC NEAR
  214.  
  215.     DEC    BL        ;convert to 0-based number
  216.     MOV    AL,8        ;get scaling factor into AL
  217.     MUL    BL        ;multiply by coordinate    in BL
  218.     RET
  219.  
  220. ScaleUpY    ENDP
  221.  
  222. ;******************************************************    ScaleUpX
  223.  
  224. ;on entry, BL has a screen column coordinate to    be scaled into the mouse's
  225. ;  coordinate system
  226. ;on exit, AX has the result
  227.  
  228. ScaleUpX    PROC NEAR
  229.  
  230.     DEC    BL        ;convert to 0-based number
  231.     MOV    AL,8        ;get scaling factor into AL
  232.     CMP    ScreenWidth,80
  233.     JAE    suxGo
  234.     MOV    AL,16
  235. suxGo:
  236.     MUL    BL        ;multiply by coordinate    in BL
  237.     RET
  238.  
  239.     RET
  240.  
  241. ScaleUpX    ENDP
  242.  
  243. ;******************************************************    ScaleDownY
  244.  
  245. ;on entry, AX has a number in the mouse's coordinate system that needs to be
  246. ;  scaled down to a screen row coordinate
  247. ;on exit, AL has the result
  248.  
  249. ScaleDownY    PROC NEAR
  250.  
  251.     PUSH    BX        ;save BX
  252.     CMP    AX,0        ;check for > 0
  253.     JG    sdyOK
  254.     MOV    AL,MouseYLo    ;force it to a valid range
  255.     JMP    SHORT sdyExit
  256. sdyOK:
  257.     MOV    BL,8        ;get scaling factor into BL
  258.     DIV    BL        ;divide    coordinate by scaling factor
  259. sdyExit:
  260.     SUB    AL,MouseYLo    ;make it relative to current window
  261.     INC    AL        ;convert to 1-based number
  262.     POP    BX        ;restore BX
  263.     RET
  264.  
  265. ScaleDownY    ENDP
  266.  
  267. ;******************************************************    ScaleDownX
  268.  
  269. ;on entry, AX has a number in the mouse's coordinate system that needs to be
  270. ;  scaled down to a screen column coordinate
  271. ;on exit, AL has the result
  272.  
  273. ScaleDownX    PROC NEAR
  274.  
  275.     PUSH    BX        ;save BX
  276.     CMP    AX,0        ;check for > 0
  277.     JG    sdxOK
  278.     MOV    AL,MouseXLo    ;force it to a valid range
  279.     JMP    SHORT sdxExit
  280. sdxOK:
  281.     MOV    BL,8        ;get scaling factor into BL
  282.     CMP    ScreenWidth,80
  283.     JAE    sdxGo
  284.     MOV    BL,16
  285. sdxGo:
  286.     DIV    BL        ;divide    coordinate by scaling factor
  287. sdxExit:
  288.     SUB    AL,MouseXLo    ;make it relative to current window
  289.     INC    AL        ;convert to 1-based number
  290.     POP    BX        ;restore BX
  291.     RET
  292.  
  293. ScaleDownX    ENDP
  294.  
  295. ;******************************************************    MouseWhereXY
  296.  
  297. ;procedure MouseWhereXY(var MouseX, MouseY : Byte; var Status :    ButtonStatus);
  298.  
  299. ;Returns mouse position    and button status.
  300.  
  301. MouseXvar    EQU DWORD PTR [BP+14]
  302. MouseYvar    EQU DWORD PTR [BP+10]
  303. StatusVar    EQU DWORD PTR [BP+6]
  304.  
  305. MouseWhereXY    PROC FAR
  306.  
  307.     CheckMouse 12        ;make sure mouse is installed
  308.     StackFrameBP        ;set up    stack frame
  309.     MouseCall 3        ;Get Mouse Position and    Button Status
  310.     MOV    AL,BL        ;button    status returned    in BX
  311.     LES    DI,StatusVar    ;put it    in StatusVar
  312.     STOSB
  313.     MOV    AX,CX        ;X position returned in    CX
  314.     CALL    ScaleDownX    ;scale it and put it in    MouseX
  315.     LES    DI,MouseXvar
  316.     STOSB
  317.     MOV    AX,DX        ;Y position returned in    DX
  318.     CALL    ScaleDownY    ;scale it and put it in    MouseY
  319.     LES    DI,MouseYvar
  320.     STOSB
  321.     ExitCode 12        ;clean up stack    and return
  322.  
  323. MouseWhereXY    ENDP
  324.  
  325. ;******************************************************    MouseWhereX
  326.  
  327. MouseWhereX    PROC FAR
  328.  
  329.     CheckMouse 0        ;make sure mouse is installed
  330.     MouseCall 3        ;Get Mouse Position and    Button Status
  331.     MOV    AX,CX        ;X position returned in    CX
  332.     CALL    ScaleDownX    ;scale it
  333.     MOV    MouseLastX,AL    ;save in MouseLastX
  334.     RET
  335.  
  336. MouseWhereX    ENDP
  337.  
  338. ;******************************************************    MouseWhereY
  339.  
  340. MouseWhereY    PROC FAR
  341.  
  342.     CheckMouse 0        ;make sure mouse is installed
  343.     MouseCall 3        ;Get Mouse Position and    Button Status
  344.     MOV    AX,DX        ;Y position returned in    DX
  345.     CALL    ScaleDownY    ;scale it
  346.     MOV    MouseLastY,AL    ;save in MouseLastY
  347.     RET
  348.  
  349. MouseWhereY    ENDP
  350.  
  351. ;******************************************************    MouseGotoXY
  352.  
  353. ;procedure MouseGotoXY(MouseX, MouseY :    Byte);
  354.  
  355. ;Set mouse position
  356.  
  357. MouseX    EQU BYTE PTR [BP+8]
  358. MouseY    EQU BYTE PTR [BP+6]
  359.  
  360. MouseGotoXY    PROC FAR
  361.  
  362.     CheckMouse 4        ;make sure mouse is installed
  363.     StackFrameBP        ;set up    stack frame
  364.  
  365.     MOV    CL,MouseY    ;check the Y coordinate
  366.     ADD    CL,MouseYLo    ;make it relative to current window
  367.     CMP    CL,MouseYHi    ;is it inside the window?
  368.     JA    mgxyExit
  369.  
  370.     MOV    BL,MouseX    ;check the X coordinate
  371.     ADD    BL,MouseXLo    ;make it relative to current window
  372.     CMP    BL,MouseXHi    ;is it inside the window?
  373.     JA    mgxyExit
  374.  
  375.     CALL    ScaleUpX    ;load scaled X position    into AX
  376.     MOV    BL,CL        ;MouseY    coordinate into    BL
  377.     MOV    CX,AX        ;scaled    X position into    CX
  378.  
  379.     CALL    ScaleUpY    ;load scaled Y position    into DX
  380.     MOV    DX,AX
  381.     MouseCall 4        ;Set Mouse Cursor Position
  382.  
  383.     CALL    MouseWhereX    ;update    MouseLastX and MouseLastY
  384.     CALL    MouseWhereY
  385. mgxyExit:
  386.     ExitCode 4        ;clean up stack    and return
  387.  
  388. MouseGotoXY    ENDP
  389.  
  390. ;******************************************************    MouseButtonPressed
  391.  
  392. ;function MouseButtonPressed(Button : ButtonStatus; var    Count :    Word;
  393. ;                 var LastX,    LastY :    Byte) :    Boolean;
  394.  
  395. ;Returns True if the Button to check has been pressed. If so, Count has    the
  396. ; number of times it has been pressed, and LastX/LastY have its    position the
  397. ; last time it was pressed.
  398.  
  399. Button    EQU BYTE PTR [BP+18]
  400. Count    EQU DWORD PTR [BP+14]
  401. LastX    EQU DWORD PTR [BP+10]
  402. LastY    EQU DWORD PTR [BP+06]
  403.  
  404. MouseButtonPressed    PROC FAR
  405.  
  406.     CheckMouse 14        ;make sure mouse is installed
  407.     StackFrameBP        ;set up    stack frame
  408.     MOV    BL,Button    ;BX has    Button to check
  409.     DEC    BL        ;!!.06
  410.     SetZero    BH
  411.     MouseCall 5        ;Get Button Press Information
  412.     LES    DI,Count    ;BX has    count of button    presses
  413.     MOV    ES:[DI],BX
  414.     PUSH    BX        ;save count           !!.06
  415.     MOV    AX,CX        ;CX has    last X position
  416.     CALL    ScaleDownX    ;scale it and put it in    LastX
  417.     LES    DI,LastX
  418.     STOSB
  419.     MOV    AX,DX        ;DX has    last Y position
  420.     CALL    ScaleDownY    ;scale it and put it in    LastY
  421.     LES    DI,LastY
  422.     STOSB
  423.     POP    BX        ;restore count
  424.     SetZero    AL        ;assume    false
  425.     OR    BX,BX        ;has the Button    been pressed? !!.06
  426.     JZ    mbcExit
  427.     INC    AL
  428. mbcExit:
  429.     ExitCode 14        ;clean up stack    and return
  430.  
  431. MouseButtonPressed    ENDP
  432.  
  433. ;******************************************************    MouseButtonReleased
  434.  
  435. ;function MouseButtonReleased(Button : ButtonStatus; var Count : Word;
  436. ;                 var LastX,    LastY :    Byte) :    Word;
  437.  
  438. ;Returns True if the Button to check has been released.    If so, Count has the
  439. ;  number of times it has been released, and LastX/LastY have its position the
  440. ;  last    time it    was released.
  441.  
  442. MouseButtonReleased    PROC FAR
  443.  
  444.     CheckMouse 14        ;make sure mouse is installed
  445.     StackFrameBP        ;set up    stack frame
  446.     MOV    BL,Button    ;BX has    Button to check
  447.     DEC    BL        ;!!.06
  448.     SetZero    BH
  449.     MouseCall 6        ;Get Button Release Information
  450.     LES    DI,Count    ;BX has    count of button    releases
  451.     MOV    ES:[DI],BX
  452.     PUSH    BX        ;save count              !!.06
  453.     MOV    AX,CX        ;CX has    last X position
  454.     CALL    ScaleDownX    ;scale it and put it in    LastX
  455.     LES    DI,LastX
  456.     STOSB
  457.     MOV    AX,DX        ;DX has    last Y position
  458.     CALL    ScaleDownY    ;scale it and put it in    LastY
  459.     LES    DI,LastY
  460.     STOSB
  461.     POP    BX        ;restore count
  462.     SetZero    AL        ;assume    false
  463.     OR    BX,BX        ;has the Button    been released? !!.06
  464.     JZ    mbrExit
  465.     INC    AL
  466. mbrExit:
  467.     ExitCode 14        ;clean up stack    and return
  468.  
  469. MouseButtonReleased    ENDP
  470.  
  471. ;******************************************************    MouseWindow
  472.  
  473. ;procedure MouseWindow(XLow, YLow, XHigh, YHigh    : Byte);
  474. ;Sets window coordinates to be observed    by the mouse
  475.  
  476. XLo    EQU BYTE PTR [BP+12]
  477. YLo    EQU BYTE PTR [BP+10]
  478. XHi    EQU BYTE PTR [BP+8]
  479. YHi    EQU BYTE PTR [BP+6]
  480.  
  481. MouseWindow    PROC FAR
  482.  
  483.     CheckMouse 8        ;make sure mouse is installed
  484.     StackFrameBP        ;set up    stack frame
  485.  
  486.     ;validate all parameters BEFORE    setting    any window coordinates
  487.     MOV    BL,XLo        ;BL = XLo-1
  488.     DEC    BL
  489.     MOV    BH,XHi        ;BH = XHi-1
  490.     DEC    BH
  491.     CMP    BL,BH        ;XLo > XHi?
  492.     JA    mwDone
  493.     CMP    BH,ScreenWidth    ;XHi > ScreenWidth?
  494.     JAE    mwDone
  495.     MOV    AL,YLo        ;AL = YLo-1
  496.     DEC    AL
  497.     MOV    AH,YHi        ;AH = YHi-1
  498.     DEC    AH
  499.     CMP    AL,AH        ;YLo > YHi?
  500.     JA    mwDone
  501.     CMP    AH,ScreenHeight    ;YHi > ScreenHeight?
  502.     JAE    mwDone
  503.  
  504.     MOV    MouseXLo,BL    ;save 0-based coordinates for mouse window
  505.     MOV    MouseYLo,AL
  506.  
  507.     INC    BH        ;save 1-based coordinates for mouse window
  508.     MOV    MouseXHi,BH
  509.     INC    AH
  510.     MOV    MouseYHi,AH
  511.  
  512.     INC    BL        ;BL = XLo
  513.     CALL    ScaleUpX    ;scale the XLow    param (in BL) and put in CX
  514.     MOV    CX,AX
  515.     MOV    BL,XHi        ;scale the XHigh param and put in DX
  516.     CALL    ScaleUpX
  517.     MOV    DX,AX
  518.     MouseCall 7        ;Set Minimum and Maximum Horizontal Position
  519.  
  520.     MOV    BL,YLo        ;scale the YLow    param and put in CX
  521.     CALL    ScaleUpY
  522.     MOV    CX,AX
  523.     MOV    BL,YHi        ;scale the YHigh param and put in DX
  524.     CALL    ScaleUpY
  525.     MOV    DX,AX
  526.     MouseCall 8        ;Set Minimum and Maximum Vertical Position
  527. mwDone:
  528.     ExitCode 8        ;clean up stack    and return
  529.  
  530. MouseWindow    ENDP
  531.  
  532. ;******************************************************    SoftMouseCursor
  533.  
  534. ;procedure SoftMouseCursor(ScreenMask, CursorMask : Word);
  535.  
  536. ;Set mouse to use a software cursor.
  537.  
  538. SoftMouseCursor:
  539.     SetZero    BX        ;select    software cursor
  540.     JMP    SHORT hmcEntry    ;rest is same as HardMouseCursor
  541.  
  542. ;******************************************************    HardMouseCursor
  543.  
  544. ;procedure HardMouseCursor(StartLine, EndLine :    Word);
  545.  
  546. ;Set mouse to use the hardware cursor. StartLine and EndLine specify the
  547. ;shape of the cursor.
  548.  
  549. Arg1        EQU WORD PTR [BP+8]
  550. Arg2        EQU WORD PTR [BP+6]
  551.  
  552. HardMouseCursor    PROC FAR
  553.  
  554.     MOV    BX,1        ;select    hardware cursor
  555.  
  556. hmcEntry:
  557.     CheckMouse 4        ;make sure mouse is installed
  558.     StackFrameBP        ;set up    stack frame
  559.     MOV    CX,Arg1
  560.     MOV    DX,Arg2
  561.     MouseCall 10        ;Set Text Cursor
  562.     ExitCode 4        ;clean up stack    and return
  563.  
  564. HardMouseCursor     ENDP
  565.  
  566. ;******************************************************    GetMickeyCount
  567.  
  568. ;procedure GetMickeyCount(var Horizontal, Vertical : Integer);
  569.  
  570. ;Returns the horizontal    and vertical mickey count since    the last call to this
  571. ;function.
  572.  
  573. gmcHoriz    EQU DWORD PTR [BP+10]
  574. gmcVert        EQU DWORD PTR [BP+6]
  575.  
  576. GetMickeyCount    PROC FAR
  577.  
  578.     CheckMouse 8        ;make sure mouse is installed
  579.     StackFrameBP        ;set up    stack frame
  580.     MouseCall 11        ;Read Mouse Motion Counters
  581.     LES    DI,gmcHoriz
  582.     MOV    ES:[DI],CX
  583.     LES    DI,gmcVert
  584.     MOV    ES:[DI],DX
  585.     ExitCode 8        ;clean up stack    and return
  586.  
  587. GetMickeyCount    ENDP
  588.  
  589. ;******************************************************    SetMickeyToPixelRatio
  590.  
  591. ;procedure SetMickeyToPixelRatio(Horizontal, Vertical :    Integer);
  592.  
  593. ;Sets the mickey-to-pixel ratio
  594.  
  595. mtpHoriz    EQU WORD PTR [BP+8]
  596. mtpVert        EQU WORD PTR [BP+6]
  597.  
  598. SetMickeyToPixelRatio    PROC FAR
  599.  
  600.     CheckMouse 4        ;make sure mouse is installed
  601.     StackFrameBP        ;set up    stack frame
  602.     MOV    AX,7FFFh    ;for masking out the high bit
  603.     MOV    CX,mtpHoriz    ;CX has    horixontal mickeys
  604.     AND    CX,AX
  605.     MOV    DX,mtpVert    ;DX has    vertical mickeys
  606.     AND    DX,AX
  607.     MouseCall 15        ;Set Mickey/Pixel Ratio
  608.     ExitCode 4        ;clean up stack    and return
  609.  
  610. SetMickeyToPixelRatio    ENDP
  611.  
  612. ;******************************************************    GetStorageSize
  613.  
  614. ;function GetStorageSize : Word;
  615. ;Returns amount    of memory needed to save state of mouse    driver
  616.  
  617. GetStorageSize    PROC FAR
  618.  
  619.     CheckMouse 0        ;make sure mouse is installed
  620.     MouseCall 21        ;Query Save-State Storage Size
  621.     MOV    AX,BX        ;size returned in BX
  622.     RET
  623.  
  624. GetStorageSize    ENDP
  625.  
  626. ;******************************************************    SaveMouseStatePrim
  627.  
  628. ;procedure SaveMouseStatePrim(var Buffer);
  629.  
  630. ;Save mouse state in Buffer
  631.  
  632. Buffer    EQU DWORD PTR [BP+6]
  633.  
  634. SaveMouseStatePrim    PROC FAR
  635.  
  636.     CheckMouse 4        ;make sure mouse is installed
  637.     StackFrameBP        ;set up    stack frame
  638.     LES    DX,Buffer    ;ES:DX points to buffer
  639.     MouseCall 22        ;Save Mouse Driver State
  640.     ExitCode 4        ;clean up stack    and return
  641.  
  642. SaveMouseStatePrim    ENDP
  643.  
  644. ;******************************************************    RestoreMouseStatePrim
  645.  
  646. ;procedure RestoreMouseStatePrim(var Buffer);
  647.  
  648. ;Restore mouse state from Buffer
  649.  
  650. RestoreMouseStatePrim    PROC FAR
  651.  
  652.     CheckMouse 4        ;make sure mouse is installed
  653.     StackFrameBP        ;set up    stack frame
  654.     LES    DX,Buffer    ;ES:DX points to buffer
  655.     MouseCall 23        ;Restore Mouse Driver State
  656.     ExitCode 4        ;clean up stack    and return
  657.  
  658. RestoreMouseStatePrim    ENDP
  659.  
  660. ;******************************************************    SetMousePage
  661.  
  662. ;procedure SetMousePage(Page : Byte);
  663. ;Sets the video    page where the mouse will be displayed
  664.  
  665. PageNum    EQU BYTE PTR [BP+6]
  666.  
  667. SetMousePage    PROC FAR
  668.  
  669.     CheckMouse 2        ;make sure mouse is installed
  670.     StackFrameBP        ;set up    stack frame
  671.     MOV    BL,PageNum    ;BX has    page number
  672.     SetZero    BH
  673.     MouseCall 29        ;Set CRT Page Number
  674.     ExitCode 2        ;clean up stack    and return
  675.  
  676. SetMousePage    ENDP
  677.  
  678. ;******************************************************    GetMousePage
  679.  
  680. ;function GetMousePage : Byte;
  681. ;Returns the video page    where the mouse    is being displayed
  682.  
  683. GetMousePage    PROC FAR
  684.  
  685.     CheckMouse 0        ;make sure mouse is installed
  686.     MouseCall 30        ;Get CRT Page Number
  687.     MOV    AX,BX        ;page returned in BX
  688.     RET
  689.  
  690. GetMousePage    ENDP
  691.  
  692. CODE    ENDS
  693.     END
  694.