home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / s / svgamous.zip / MOUSE2.BAS < prev    next >
BASIC Source File  |  1992-11-07  |  12KB  |  386 lines

  1. 'DECLARE SUB MouseCD (func%)
  2. 'DECLARE SUB MouseFunc (func%, IM AS ANY, OM AS ANY)
  3. '
  4. 'DEFINT A-Z
  5.  
  6. SUB MouseCD (func)
  7.  
  8. 'QB/EVGFX mouse cursor driver
  9.  
  10. '-- This routine requires DIM SHARED MouseBuffer(0 TO 128) AS INTEGER
  11. '-- in the main module.
  12.  
  13. 'This routine replaces MouseFunc() functions 1, 2, and 3. You cannot
  14. 'use MOUSE.COM/.SYS functions 1 and 2 (show & hide). You could use
  15. 'their func 3 (get cursor & button status) but you might as well use
  16. 'the one included here since it handles showing the mouse cursor.
  17.  
  18. 'Note: The current MouseFunc() SUB is included with this file group.
  19. 'It must be used in conjunction with MouseCD(). Make calls to MouseFunc()
  20. 'as normal. Funcs 1-3 will be transfered here. This isn't all that fast
  21. 'but it's the fastest (and currently, only) way I know how to do it.
  22.  
  23. 'Note: To create the mouse cursor a new GUISYS14.OBJ module is included.
  24. 'To update QBEVGFX3.LIB do the following:
  25. '
  26. 'C>lib qbevgfx3 -+guisys14;
  27.  
  28. 'Note: See the note on reinstating the default font below
  29.  
  30.  
  31. STATIC CalledBefore AS INTEGER
  32. STATIC mouseOn AS INTEGER
  33. STATIC lastX AS INTEGER
  34. STATIC lastY AS INTEGER
  35.  
  36. IF NOT CalledBefore THEN
  37.    lastX = -1
  38.    lastY = -1
  39. END IF
  40.  
  41. SELECT CASE func
  42. CASE 1
  43.    mouseOn = -1
  44.  
  45. CASE 2
  46.    mouseOn = 0
  47.    IF CalledBefore THEN
  48.       vseg = VARSEG(MouseBuffer(0))
  49.       voff = VARPTR(MouseBuffer(0))
  50.       PUTBLOCK 0, lastX, lastY, vseg, voff
  51.       CalledBefore = NOT CalledBefore
  52.    END IF
  53.  
  54. CASE 3
  55.    xreg.ax = 3
  56.    INTERRUPTX &H33, xreg, xreg
  57.    OM.bx = xreg.bx
  58.    OM.cx = xreg.cx
  59.    OM.dx = xreg.dx
  60.  
  61.    IF mouseOn THEN
  62.       IF lastX <> OM.cx OR lastY <> OM.dx THEN
  63.  
  64.          vseg = VARSEG(MouseBuffer(0))
  65.          voff = VARPTR(MouseBuffer(0))
  66.  
  67.          IF CalledBefore THEN
  68.             PUTBLOCK 0, lastX, lastY, vseg, voff
  69.          ELSE
  70.             CalledBefore = -1
  71.          END IF
  72.  
  73.          GETBLOCK 15, OM.cx, OM.dx, (OM.cx + 15), (OM.dx + 15), vseg, voff
  74.  
  75.          strg1$ = CHR$(158) + CHR$(159)       'screen mask
  76.          strg2$ = CHR$(156) + CHR$(157)       'cursor mask
  77.          DGSTR.Length = 2
  78.          DGSTR.addr = VARPTR(DGSTR.strg)
  79.  
  80.          FONTGUI14
  81.          DGSTR.strg = strg1$
  82.          nx = DRAWSTR(8, VARPTR(DGSTR), OM.cx, OM.dx, 15, 0, 8)
  83.          DGSTR.strg = strg2$
  84.          nx = DRAWSTR(24, VARPTR(DGSTR), OM.cx, OM.dx, 15, 0, 8)
  85.  
  86.          '----------------------------------------------
  87.          'This should be changed to your default font.
  88.          'You may want to keep a running status of the current font
  89.          'in use and select the appropriate font to reinstate.
  90.  
  91.          FONTSYS16
  92.          
  93.          lastX = OM.cx
  94.          lastY = OM.dx
  95.       END IF
  96.    END IF
  97. CASE ELSE
  98. END SELECT
  99.  
  100. END SUB
  101.  
  102. SUB MouseFunc (func, IM AS MouseTYPE, OM AS MouseTYPE)
  103.  
  104. 'mouse function routine
  105.  
  106. IF IsMouse = 0 AND func > 0 THEN EXIT SUB
  107.  
  108. IF func >= 1 AND func <= 3 THEN
  109.    MouseCD func
  110.    EXIT SUB
  111. END IF
  112.  
  113. xreg.es = -1    'IM.ax used to pass ES segment register if needed
  114. SELECT CASE func
  115. CASE 1   'SHOW CURSOR
  116.          'set: nothing
  117.          'rtn: nothing
  118.    xreg.ax = 1
  119. CASE 2   'HIDE CURSOR
  120.          'set: nothing
  121.          'rtn: nothing
  122.    xreg.ax = 2
  123. CASE 0   'MOUSE RESET AND STATUS
  124.          'set: nothing
  125.          'rtn: ax=status (0=not found/not reset)
  126.          '     bx=buttons
  127.    DEF SEG = 0
  128.    ms& = 256& * PEEK(207) + PEEK(206)
  129.    IF ms& > 32767 THEN ms& = ms& - 65536
  130.    MouseSeg = ms&
  131.    MouseOff = PEEK(204) + 256 * PEEK(205)
  132.    DEF SEG = MouseSeg
  133.    IsMouse = (MouseSeg <> 0 OR MouseOff <> 0) AND PEEK(MouseOff) <> &HCF
  134.    DEF SEG
  135.    IF IsMouse THEN
  136.       xreg.ax = 0
  137.    ELSE OM.ax = 0
  138.       EXIT SUB
  139.    END IF
  140. CASE 3   'GET BUTTON STATUS AND MOUSE POS
  141.          'set: nothing
  142.          'rtn: bx=button status
  143.          '     cx=horz cursor coor
  144.          '     dx=vert cursor coor
  145.    xreg.ax = 3
  146. CASE 4   'SET MOUSE CURSOR POS
  147.          'set: cx=new horz cursor pos
  148.          '     dx=new vert cursor pos
  149.          'rtn: nothing
  150.    xreg.ax = 4
  151.    xreg.cx = IM.cx
  152.    xreg.dx = IM.dx
  153. CASE 5   'GET BUTTON PRESS INFO
  154.          'set: bx=button
  155.          'rtn: ax=button status
  156.          '     bx=number of button presses
  157.          '     cx=horz cursor coor at last press
  158.          '     dx=vert cursor coor at last press
  159.    xreg.ax = 5
  160.    xreg.bx = IM.bx
  161. CASE 6   'GET BUTTON RELEASE INFO
  162.          'set: bx=button
  163.          'rtn: ax=button status
  164.          '     bx=number of button releases
  165.          '     cx=horz cursor coor at last release
  166.          '     dx=vert cursor coor at last release
  167.    xreg.ax = 6
  168.    xreg.bx = IM.bx
  169. CASE 7   'SET MIN AND MAX HORZ CURSOR POS
  170.          'set: cx=min pos
  171.          '     dx=max pos
  172.          'rtn: nothing
  173.    xreg.ax = 7
  174.    xreg.cx = IM.cx
  175.    xreg.dx = IM.dx
  176. CASE 8   'SET MIN AND MAX VERT CURSOR POS
  177.          'set: cx=min pos
  178.          '     dx=max pos
  179.          'rtn: nothing
  180.    xreg.ax = 8
  181.    xreg.cx = IM.cx
  182.    xreg.dx = IM.dx
  183. CASE 9   'SET GRAPHICS CURSOR BLOCK
  184.          'set: ax=segment of cursor mask (NEVER DEFAULT)
  185.          '     bx=horz cursor hot spot
  186.          '     cx=vert cursor hot spot
  187.          '     dx=pointer to screen
  188.          'rtn: nothing
  189.    xreg.ax = 9
  190.    xreg.bx = IM.bx
  191.    xreg.cx = IM.cx
  192.    xreg.dx = IM.dx
  193.    xreg.es = IM.ax
  194. CASE 10  'SET TEXT CURSOR
  195.          'set: bx=cursor select
  196.          '     cx=screen mask value or scan line start
  197.          '     dx=cursor mask value or scan line start
  198.          'rtn: nothing
  199.    xreg.ax = 10
  200.    xreg.bx = IM.bx
  201.    xreg.cx = IM.cx
  202.    xreg.dx = IM.dx
  203. CASE 11  'READ MOUSE MOTION COUNTERS
  204.          'set: nothing
  205.          'rtn: cx=horz mickey count
  206.          '     dx=vert mickey count
  207.    xreg.ax = 11
  208. CASE 12  'SET INTERRUPT SUBROUTINE CALL MASK AND ADDRESS
  209.          'set: ax=segment of subroutine (NEVER DEFAULT)
  210.          '     cx=call mask.........bit 0-cursor pos changed
  211.          '     dx=offset of subroutine '1-left button pressed
  212.          'rtn: nothing                 '2-left button released
  213.    xreg.ax = 12                        '3-right button pressed
  214.    xreg.cx = IM.cx                     '4-right button released
  215.    xreg.dx = IM.dx                     '5-15 not used
  216.    xreg.es = IM.ax
  217. CASE 13  'LIGHT PEN EMULATION MODE ON
  218.          'set: nothing
  219.          'rtn: nothing
  220.    xreg.ax = 13
  221. CASE 14  'LIGHT PEN EMULATION MODE OFF
  222.          'set: nothing
  223.          'rtn: nothing
  224.    xreg.ax = 14
  225. CASE 15  'SET MICKEY/PIXEL RATIO
  226.          'set: cx=horz mickey to pixel ratio
  227.          '     dx=vert mickey to pixel ratio
  228.          'rtn: nothing
  229.    xreg.ax = 15
  230.    xreg.cx = IM.cx
  231.    xreg.dx = IM.dx
  232. CASE 16  'CONDITIONAL OFF
  233.          'set: ax=left x (slightly different than regular calling registers)
  234.          '     bx=upper y
  235.          '     cx=right x
  236.          '     dx=lower y
  237.          'rtn: nothing
  238.    xreg.ax = 16
  239.    xreg.cx = IM.ax
  240.    xreg.dx = IM.bx
  241.    xreg.si = IM.cx
  242.    xreg.di = IM.dx
  243. CASE 17, 18
  244. CASE 19  'SET DOUBLE-SPEED THRESHOLD
  245.          'set: dx=threshold speed in mickeys/seconds
  246.          'rtn: nothing
  247.    xreg.ax = 19
  248.    xreg.dx = IM.dx
  249. CASE 20  'SWAP INTERRUPT ROUTINES
  250.          'set: ax=segment of subroutine (NEVER DEFAULT)
  251.          '     cx=call mask (as in func 12 above)
  252.          '     dx=offset of subroutine        ***********************
  253.          'rtn: bx=segment of old subroutine   *Rtn values valid only*
  254.          '     cx=call mask of old subroutine *if previous interrupt*
  255.          '     dx=offset of old subroutine    *was created          *
  256.    xreg.ax = 20                              '***********************
  257.    xreg.cx = IM.cx
  258.    xreg.dx = IM.dx
  259.    xreg.es = IM.ax
  260.    INTERRUPTX &H33, xreg, xreg
  261.    OM.ax = 0
  262.    OM.bx = xreg.es
  263.    OM.cx = xreg.cx
  264.    OM.dx = xreg.dx
  265.    EXIT SUB
  266. CASE 21  'GET MOUSE DRIVER STATE STORAGE REQUIREMENTS
  267.          'set: nothing
  268.          'rtn: bx=buffer size in bytes
  269.    xreg.ax = 21
  270. CASE 22  'SAVE MOUSE DRIVER STATE
  271.          'set: ax=segment of buffer
  272.          '     dx=offset of buffer
  273.          'rtn: nothing
  274.    xreg.ax = 22
  275.    xreg.dx = IM.dx
  276.    xreg.es = IM.ax
  277. CASE 23  'RESTORE MOUSE DRIVER STATE
  278.          'set: ax=segment of buffer
  279.          '     dx=offset of buffer
  280.          'rtn: nothing
  281.    xreg.ax = 23
  282.    xreg.dx = IM.dx
  283.    xreg.es = IM.ax
  284. CASE 24  'SET ALTERNATE SUBROUTINE CALL MASK AND ADDRESS
  285.          'set: ax=segment of user subroutine
  286.          '     cx=call mask.........bit 0-cursor pos changed
  287.          '     dx=offset of subroutine '1-left button pressed
  288.          'rtn: ax=error status (-1)    '2-left button released
  289.    xreg.ax = 24                        '3-right button pressed
  290.    xreg.cx = IM.cx                     '4-right button released
  291.    xreg.dx = IM.dx                     '5-shift key down w/button
  292.    xreg.es = IM.ax                     '6-ctrl key down w/button
  293.                                        '7-alt key down w/button
  294.                                        '8-15 not used
  295. CASE 25  'GET USER ALTERNATE INTERRUPT ADDRESS
  296.          'set: cx=user interrupt call mask
  297.          'rtn: ax=error status (-1)
  298.          '     bx=segment of user subroutine
  299.          '     cx=call mask of user interrupt
  300.          '     dx=offset of subroutine
  301.    xreg.ax = 25
  302.    xreg.cx = IM.cx
  303. CASE 26  'SET MOUSE SENSITIVITY
  304.          'set: bx=horz mickey sensitivity (0 to 100)  these all
  305.          '     cx=vert mickey sensitivity (0 to 100)   have default
  306.          '     dx=threshold for double speed (0 to 100) values=50
  307.          'rtn: nothing
  308.    xreg.ax = 26
  309.    xreg.bx = IM.bx
  310.    xreg.cx = IM.cx
  311.    xreg.dx = IM.dx
  312. CASE 27  'GET MOUSE SENSITIVITY
  313.          'set: nothing
  314.          'rtn: bx=horz mickey sensitivity (0 to 100)
  315.          '     cx=vert mickey sensitivity (0 to 100)
  316.          '     dx=threshold for double speed (0 to 100)
  317.    xreg.ax = 27
  318. CASE 28  'SET MOUSE INTERRUPT RATE (InPort mouse ONLY)
  319.          'set: bx=rate number (0 (0/sec) to 4 (200/sec))
  320.          'rtn: nothing
  321.    xreg.ax = 28
  322.    xreg.bx = IM.bx
  323. CASE 29  'SET CRT PAGE NUMBER
  324.          'set: bx=CRT page for mouse cursor display
  325.          'rtn: nothing
  326.    xreg.ax = 29
  327.    xreg.bx = IM.bx
  328. CASE 30  'GET CRT PAGE NUMBER
  329.          'set: nothing
  330.          'rtn: bx=CRT page for current mouse cursor display
  331.    xreg.ax = 30
  332. CASE 31  'DISABLE MOUSE DRIVER
  333.          'set: nothing
  334.          'rtn: ax=error status (-1)
  335.          '     bx=segment of old int 33h
  336.          '     dx=offset of old int 33h
  337.    xreg.ax = 31
  338.    INTERRUPTX &H33, xreg, xreg
  339.    OM.ax = xreg.ax
  340.    OM.bx = xreg.es
  341.    OM.cx = 0
  342.    OM.dx = xreg.bx
  343.    EXIT SUB
  344. CASE 32  'ENABLE MOUSE DRIVER
  345.          'set: nothing
  346.          'rtn: nothing
  347.    xreg.ax = 32
  348. CASE 33  'SOFTWARE RESET
  349.          'set: nothing
  350.          'rtn: ax=-1 (or 33 if mouse drive not installed)
  351.          '     bx=2 (if ax=-1. Must=2 for a valid reset)
  352.    xreg.ax = 33
  353. CASE 34  'SET LANGUAGE FOR MESSAGES (International MOUSE.xxx ONLY)
  354.          'set: bx=language number
  355.          'rtn: nothing
  356.    xreg.ax = 34
  357.    xreg.bx = IM.bx
  358. CASE 35  'GET LANGUAGE NUMBER
  359.          'set: nothing
  360.          'rtn: bx=language number
  361.    xreg.ax = 35
  362. CASE 36  'GET DRIVER VERSION,MOUSE TYPE,AND IRQ NUMBER
  363.          'set: nothing
  364.          'rtn: bx=mouse driver version number
  365.          '        bh=major
  366.          '        bl=minor
  367.          '     cx=mouse type and IRQ number
  368.          '        ch=mouse type (1=bus,2=serial,3=InPort,4=PS/2,5=HP)
  369.          '        cl=IRQ number (0=PS/2, 2-5 or 7=mouse IRQ)
  370.    xreg.ax = 36
  371. CASE ELSE
  372.    OM.ax = 0
  373.    OM.bx = 0
  374.    OM.cx = 0
  375.    OM.dx = 0
  376.    EXIT SUB
  377. END SELECT
  378.  
  379. INTERRUPTX &H33, xreg, xreg
  380. OM.ax = xreg.ax
  381. OM.bx = xreg.bx
  382. OM.cx = xreg.cx
  383. OM.dx = xreg.dx
  384.  
  385. END SUB
  386.