home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / ctmous18.zip / TECHNOTE.TXT < prev   
Text File  |  2000-12-31  |  17KB  |  321 lines

  1. Mouse driver services
  2. ---------------------
  3.  
  4. Functions implemented in CTMOUSE:
  5.  
  6. INT 33/0000 - MS MOUSE - RESET DRIVER AND READ STATUS
  7. INT 33/0001 - MS MOUSE v1.0+ - SHOW MOUSE CURSOR
  8. INT 33/0002 - MS MOUSE v1.0+ - HIDE MOUSE CURSOR
  9. INT 33/0003 - MS MOUSE v1.0+ - GET CURSOR POSITION AND BUTTONS STATUS
  10. INT 33/0004 - MS MOUSE v1.0+ - POSITION MOUSE CURSOR
  11. INT 33/0005 - MS MOUSE v1.0+ - GET BUTTON PRESS DATA
  12. INT 33/0006 - MS MOUSE v1.0+ - GET BUTTON RELEASE DATA
  13. INT 33/0007 - MS MOUSE v1.0+ - SET HORIZONTAL CURSOR RANGE
  14. INT 33/0008 - MS MOUSE v1.0+ - SET VERTICAL CURSOR RANGE
  15. INT 33/0009 - MS MOUSE v3.0+ - DEFINE GRAPHICS CURSOR
  16. INT 33/000A - MS MOUSE v3.0+ - DEFINE TEXT CURSOR
  17. INT 33/000B - MS MOUSE v1.0+ - GET MOTION COUNTERS
  18. INT 33/000C - MS MOUSE v1.0+ - DEFINE USER INTERRUPT ROUTINE
  19. INT 33/000F - MS MOUSE v1.0+ - SET MICKEYS/8 PIXELS RATIOS
  20. INT 33/0010 - MS MOUSE v1.0+ - DEFINE SCREEN REGION FOR UPDATING
  21. INT 33/0014 - MS MOUSE v3.0+ - EXCHANGE USER INTERRUPT ROUTINES
  22. INT 33/0015 - MS MOUSE v6.0+ - GET DRIVER STORAGE REQUIREMENTS
  23. INT 33/0016 - MS MOUSE v6.0+ - SAVE DRIVER STATE
  24. INT 33/0017 - MS MOUSE v6.0+ - RESTORE DRIVER STATE
  25. INT 33/001A - MS MOUSE v6.0+ - SET MOUSE SENSITIVITY
  26. INT 33/001B - MS MOUSE v6.0+ - GET MOUSE SENSITIVITY
  27. INT 33/001E - MS MOUSE v6.0+ - GET DISPLAY PAGE
  28. INT 33/001F - MS MOUSE v6.0+ - DISABLE MOUSE DRIVER
  29. INT 33/0020 - MS MOUSE v6.0+ - ENABLE MOUSE DRIVER
  30. INT 33/0021 - MS MOUSE v6.0+ - SOFTWARE RESET
  31. INT 33/0023 - MS MOUSE v6.0+ - GET LANGUAGE FOR MESSAGES
  32. INT 33/0024 - MS MOUSE v6.26+ - GET SOFTWARE VERSION, MOUSE TYPE AND IRQ
  33. INT 33/0026 - MS MOUSE v6.26+ - GET MAXIMUM VIRTUAL SCREEN COORDINATES
  34. INT 33/002A - MS MOUSE v7.02+ - GET CURSOR HOT SPOT
  35. INT 33/0032 - MS MOUSE v7.05+ - GET ACTIVE ADVANCED FUNCTIONS
  36. INT 33/004D - MS MOUSE - GET POINTER TO COPYRIGHT STRING
  37. INT 33/006D - MS MOUSE - GET POINTER TO VERSION
  38.  
  39. Video functions implemented in CTMOUSE:
  40.  
  41. INT 10/F0 - EGA Register Interface Library - READ ONE REGISTER
  42. INT 10/F1 - EGA Register Interface Library - WRITE ONE REGISTER
  43. INT 10/F2 - EGA Register Interface Library - READ REGISTER RANGE
  44. INT 10/F3 - EGA Register Interface Library - WRITE REGISTER RANGE
  45. INT 10/F4 - EGA Register Interface Library - READ REGISTER SET
  46. INT 10/F5 - EGA Register Interface Library - WRITE REGISTER SET
  47. INT 10/F6 - EGA Register Interface Library - REVERT REGISTERS TO DEFAULT
  48. INT 10/F7 - EGA Register Interface Library - DEFINE REGISTERS DEFAULT
  49. INT 10/FA - EGA Register Interface Library - INTERROGATE DRIVER
  50.  
  51. The following functions are not implemented but they don't return
  52. anything and can be counted as implemented:
  53.  
  54. INT 33/000D - MS MOUSE v1.0+ - LIGHT PEN EMULATION ON
  55. INT 33/000E - MS MOUSE v1.0+ - LIGHT PEN EMULATION OFF
  56. INT 33/0013 - MS MOUSE v5.0+ - DEFINE DOUBLE-SPEED THRESHOLD
  57. INT 33/001C - MS MOUSE v6.0+ - SET INTERRUPT RATE
  58. INT 33/001D - MS MOUSE v6.0+ - SET DISPLAY PAGE
  59. INT 33/0022 - MS MOUSE v6.0+ - SET LANGUAGE FOR MESSAGES
  60.  
  61. The following functions are not implemented:
  62.  
  63. INT 10/04 - VIDEO - GET LIGHT PEN POSITION (except VGA)
  64. INT 33/0011 - Genius Mouse 9.06 - GET NUMBER OF BUTTONS
  65. INT 33/0012 - MS MOUSE - SET LARGE GRAPHICS CURSOR BLOCK
  66. INT 33/0018 - MS MOUSE v6.0+ - SET ALTERNATE USER INTERRUPT HANDLER
  67. INT 33/0019 - MS MOUSE v6.0+ - GET ALTERNATE USER INTERRUPT HANDLER
  68. INT 33/0025 - MS MOUSE v6.26+ - GET GENERAL DRIVER INFORMATION
  69. INT 33/0027 - MS MOUSE v7.01+ - GET SCREEN/CURSOR MASKS AND MICKEY COUNTERS
  70. INT 33/0028 - MS MOUSE v7.0+ - SET VIDEO MODE
  71. INT 33/0029 - MS MOUSE v7.0+ - ENUMERATE VIDEO MODES
  72. INT 33/002B - MS MOUSE v7.0+ - LOAD ACCELERATION PROFILES
  73. INT 33/002C - MS MOUSE v7.0+ - GET ACCELERATION PROFILES
  74. INT 33/002D - MS MOUSE v7.0+ - SELECT ACCELERATION PROFILE
  75. INT 33/002E - MS MOUSE v8.10+ - SET ACCELERATION PROFILE NAMES
  76. INT 33/002F - MS MOUSE v7.02+ - MOUSE HARDWARE RESET
  77. INT 33/0030 - MS MOUSE v7.04+ - GET/SET BallPoint INFORMATION
  78. INT 33/0031 - MS MOUSE v7.05+ - GET MIN/MAX VIRTUAL CURSOR COORDINATES
  79. INT 33/0033 - MS MOUSE v7.05+ - GET SWITCH SETTINGS AND ACCELERATION PROFILE DATA
  80. INT 33/0034 - MS MOUSE v8.0+ - GET INITIALIZATION FILE
  81. INT 33/0035 - MS MOUSE v8.10+ - LCD SCREEN LARGE POINTER SUPPORT
  82.  
  83.  
  84. Details of driver operation
  85. ---------------------------
  86.  
  87. CTMOUSE displays the cursor only in standard video modes of CGA, EGA and
  88.   VGA; Hercules Graphics/InColor Card or SVGA/VESA extended video modes
  89.   are not supported but an application can display the cursor by itself in
  90.   a user interrupt routine (may be installed by INT 33/000C function) or
  91.   when idle. Remember to remove calls to INT 33/0001 (Show cursor) and
  92.   define cursor movement limits (INT 33/0007 and INT 33/0008).
  93. Some applications call INT 33/0001 (Show cursor), INT 33/0009 (Define
  94.   graphics cursor) and INT 33/000A (Define text cursor) in loops. To
  95.   prevent cursor flickering INT 33/0001 function redraws cursor only if it
  96.   was hidden before and INT 33/0004 (Position cursor), INT 33/0009 and
  97.   INT 33/000A functions redraw cursor only if its position or pattern
  98.   has changed.
  99. Unlike many other mouse drivers, CTMOUSE doesn't require call INT 33/0002
  100.   (Hide cursor) or INT 33/0010 (Define region for updating) before writing
  101.   to the screen in text mode because screen under cursor isn't restored if
  102.   cursor is overwritten. However CTMOUSE can't correct all cases of cursor
  103.   overwriting: when a character is written at the cursor position without
  104.   an attribute, (through INT 10/0E (Teletype output) or INT 21), then it
  105.   gets the cursor's attribute. Also, if cursor is overwritten by character
  106.   with attribute which is equal to cursor's character/attribute then
  107.   CTMOUSE restores the old character/attribute.
  108. Unlike Microsoft's specification, CTMOUSE always displays cursor on the
  109.   active video page and doesn't require call INT 33/001D (Set display
  110.   page) at all; this function is, anyway, a dummy.
  111.  
  112. Below is a table of virtual screen size, cursor movement granularity and
  113.   minimum/maximum cursor size in positions (actual for INT 33/0010) for
  114.   each video mode:
  115.                  min     max
  116.     mode     screen  cell    shape    shape
  117.      *0    640x200  16x8    16x8    16x8
  118.      *1    640x200  16x8    16x8    16x8
  119.      *2    640x200   8x8     8x8     8x8
  120.      *3    640x200   8x8     8x8     8x8
  121.       4    640x200   2x1    16x16    24x16
  122.       5    640x200   2x1    16x16    24x16
  123.       6    640x200   1x1    16x16    24x16
  124.      *7    640x200   8x8     8x8     8x8
  125.      0Dh    640x200   2x1    32x16    48x16
  126.      0Eh    640x200   1x1    16x16    24x16
  127.      0Fh    640x350   1x1    16x16    24x16
  128.      10h    640x350   1x1    16x16    24x16
  129.      11h    640x480   1x1    16x16    24x16
  130.      12h    640x480   1x1    16x16    24x16
  131.      13h    640x200   2x1    32x16    32x16
  132.     other    640x200   1x1      -      -
  133.  
  134.   * for text modes virtual screen size given for standard screen sizes
  135.   40x25 and 80x25; for nonstandard screen sizes virtual screen size is
  136.   changed accordingly.
  137. In standard text modes CTMOUSE supports any screen size beside 40x25 and
  138.   80x25 and sets virtual screen size as (screen width in characters)*8 by
  139.   (screen height in characters)*8 (except video modes 0-1, when width is
  140.   multiplied by 16) each time when INT 33/0000 (Reset driver), INT 33/0020
  141.   (Enable driver) or INT 33/0021 (Software reset) is called or the video
  142.   mode is changed.
  143. If screen size in text mode is changed, then INT 33/0000 (Reset driver),
  144.   INT 33/0020 (Enable driver) or INT 33/0021 (Software reset) must be
  145.   called to renew virtual screen size. If INT 33/0020 only is called then
  146.   INT 33/0007 (Set horizontal range) and INT 33/0008 (Set vertical range)
  147.   functions also should be called with min=0 and max=[8*screen width-1,
  148.   8*screen height-1] to enable the complete screen for cursor movement.
  149. CTMOUSE intercepts only INT 10/0 (Set video mode) video function and no
  150.   other function, such as 4Fh (VESA/SVGA functions), 1Ch (VGA state
  151.   save/restore) or 11h (EGA/VGA character generation functions), so INT
  152.   33/0000 (Reset driver), INT 33/0021 (Software reset) or INT 33/0020
  153.   (Enable driver) must be called after these video functions.
  154.  
  155. INT 33/0007 (Set horizontal range) and INT 33/0008 (Set vertical range)
  156.   functions setup cursor movement area but cursor will be seen on the
  157.   screen only in standard video modes and when cursor shape intersects
  158.   with virtual screen coordinates.
  159. All driver's coordinates (ranges, cursor positions, regions) interpreted
  160.   as signed values, also as cursor hot spot or mickey counts.
  161.  
  162.  
  163. Notes for mouse driver services
  164. -------------------------------
  165.  
  166. For bitmapped graphics modes 4-6 and 0Dh-12h a peculiarity of INT 33/0010
  167.   (Define region for updating) function should be noted: horizontal cursor
  168.   position is always aligned by modulo 8 or 16 and cursor occupies 24 or
  169.   48 positions, unlike mode 13h, where start position is unchanged and
  170.   cursor occupies 32 positions; i.e. for left limit L and right limit R in
  171.   modes 4-6, 0Eh-12h cursor will be hidden between (L-L%8)-16 and
  172.   [R/8+1]*8-1 positions, in mode 0Dh cursor will be hidden between
  173.   (L-L%16)-32 and [R/16+1]*16-1 positions and in mode 13h cursor will be
  174.   hidden between L-32 and R positions.
  175. To set update region via INT 33/0010 in terms of character positions you
  176.   must compute arguments as CX=left*W, DX=top*8, SI=(right+1)*W-1 and
  177.   DI=(bottom+1)*W-1, where W=16 for modes 0-1, 4-5, 0Dh and 13h and W=8
  178.   for all other modes.
  179. Size of buffer, required to save driver state by INT 33/0016, in CTMOUSE
  180.   is less than 180 bytes; exact buffer size is returned by INT 33/0015
  181.   (Get driver storage requirements).
  182. INT 33/0016 (Save driver state) and INT 33/0017 (Restore driver state)
  183.   functions save and restore user defined variables (mickeys per 8 pixels,
  184.   user interrupt routine call mask and address), cursor definition (cursor
  185.   type, text and graphics shape, visibility, position, ranges and update
  186.   region) and mouse access state (mickeys mouse moved, buttons press and
  187.   release status since last access). These functions don't affect driver
  188.   state (disabled flag, resolution level), mouse definition (mouse type,
  189.   buttons count, IO address and interrupt), video mode definition (maximum
  190.   virtual screen coordinates, EGA RIL register values) and dummy variables
  191.   (lightpen emulation status and double speed threshold).
  192. When the video mode is changed (through INT 10/0) CTMOUSE hides cursor so
  193.   that it can be shown by next INT 33/0001, recalculates screen sizes,
  194.   sets cursor ranges to virtual screen sizes and centers cursor.
  195. INT 33/0000 (Reset driver) and INT 33/0021 (Software reset) functions hide
  196.   cursor (so that it can be shown by next INT 33/0001), recalculate screen
  197.   sizes, set cursor ranges to screen sizes, center cursor and clear mickey
  198.   counts, user interrupt routine call mask and button press/release data.
  199.   In addition, horizontal mickeys per 8 pixels ratio is set to 8, vertical
  200.   mickeys per 8 pixels ratio is set to 16, software text mode cursor is
  201.   set with reverse video shape (screen mask 77FFh, cursor mask 7700h) and
  202.   graphics mode cursor shape is set to arrow with zero hot spot.
  203. INT 33/001F (Disable driver) function hides cursor so that it can be shown
  204.   by next INT 33/0001, disables mouse, restores IRQ interrupt (for serial
  205.   mouse) and returns in ES:BX the old INT 33 interrupt handler address. If
  206.   INT 33 or INT 10 interrupt was intercepted by another program then on
  207.   exit AX will contain -1, else if INT 10 interrupt handler was not
  208.   restored yet then it will be restored.
  209. INT 33/0020 (Enable driver) function installs IRQ handler (if serial mouse
  210.   is active) and INT 10 handler (if it is not yet installed), enables
  211.   mouse interrupts, recalculates screen sizes, sets cursor ranges to
  212.   screen sizes and centers cursor.
  213. CTMOUSE supports INT 33/0022 and 0023 (Set/get language for messages)
  214.   functions, but only for English.
  215. When you have to deal with RIL, keep in mind that RIL is unprotected from
  216.   wrong user input - RIL functions should be called only in standard video
  217.   modes and on EGA or later video adapters, and RIL doesn't check if group
  218.   index, register number or count of registers are valid.
  219.  
  220.  
  221. Asynchronous execution and User Interrupt Routine (UIR)
  222. ------------------------------------------------------
  223.  
  224. UIR installed via INT 33/000C (Define UIR) or INT 33/0014 (Exchange UIRs)
  225.   must use far RET (not IRET) for return and it is not required to keep
  226.   any register value.
  227. Mouse interrupt handler (IH) redraws cursor on the screen only when the
  228.   called UIR returns to IH. If new mouse events occur before UIR returns
  229.   to IH then IH will not redraw cursor and call UIR again (i.e. UIR is not
  230.   required to be re-enterable), however mouse events themselves will be
  231.   parsed and reflected in driver state, so driver state (cursor position,
  232.   buttons state) may be changed before UIR returns and UIR should access
  233.   driver with care.
  234. When bit 0 ("call if mouse moves") is set in the UIR call mask then UIR
  235.   will be called when any mickey count is changed. Note: cursor position
  236.   usually changes less often than mickey counts because mickeys per 8
  237.   pixels ratios can reduce mickeys change to zero and cursor position
  238.   change can be hidden by granulation (in text modes cursor positions are
  239.   always factor of 8 or 16; in some graphics modes X cursor positions are
  240.   always factor of two).
  241.  
  242.  
  243. Used BIOS variables
  244. -------------------
  245.  
  246. 0:449h    bits 0-6 used to determine the current video mode (when driver
  247.     enabled by INT 33/0020 or video mode changed)
  248. 0:44Ah    screen width in text columns (used to compute offset in video
  249.     memory in text video modes)
  250. 0:44Eh    offset in video segment of active video memory page
  251. 0:462h    current video page (returned by INT 33/001E)
  252. 0:463h    used to compute CRTC base and Feature Control video ports addresses
  253.     (when driver enabled by INT 33/0020 or video mode changed)
  254. 0:46Ch    timer used in mouse detection routine to make timing
  255. 0:487h    bits 5-6 used to determine RAM size on video adapter (when driver
  256.     enabled by INT 33/0020 or video mode changed)
  257. 0:488h    bits 0-3 used to get video configuration switches (when driver
  258.     enabled by INT 33/0020 or video mode changed)
  259. 0:4A8h    used to get default video registers values for RIL (when driver
  260.     enabled by INT 33/0020 or video mode changed)
  261.  
  262.  
  263. Used interrupts
  264. ---------------
  265.  
  266. INT 10/01    setup text-mode hardware cursor shape, when hardware
  267.         cursor selected
  268. INT 10/1A00    get DCC to check VGA presence
  269. INT 15/C200    enable/disable PS/2 pointing device
  270. INT 15/C203    set resolution of PS/2 pointing device [when PS/2 checking]
  271. INT 15/C205    initialize PS/2 pointing device [when PS/2 checking]
  272. INT 15/C207    set handler for PS/2 pointing device
  273. INT 21/09    output all strings to standard output
  274. INT 21/25    install interrupt handlers for INT 33, INT 10 and IRQ
  275.         handler, also restore those interrupts
  276. INT 21/26    create new PSP for driver image in the UMB [when trying    to
  277.         install driver high]
  278. INT 21/31    remain TSR when driver not copied to other UMB segment
  279. INT 21/35    save old INT 33, INT 10 and IRQ handlers addresses
  280. INT 21/48    allocate UMB memory [when trying to install driver high]
  281. INT 21/49    free memory used by environment and by unloaded TSR
  282. INT 21/4C    terminate program with nonzero errorlevel if some error
  283.         found or with zero errorlevel when no errors
  284. INT 21/58    modify memory allocation strategy [when trying to install
  285.         driver high]
  286. INT 2F/4310    get XMS driver entry [when trying to install driver high]
  287. INT 33/001F    disable previous mouse driver, if one is present
  288. INT 33/0020    enable previous mouse driver after unloading CuteMouse
  289. INT 33/004D    check if installed driver is CuteMouse
  290.  
  291.  
  292. Techniques used
  293. ---------------
  294.  
  295. 1. Two writes to adjacent I/O ports are combined into one write "out dx,ax"
  296.    (used for most video registers, divisor latch of COM port, etc).
  297. 2. For interrupt handler's address comparision only segment of address is
  298.    used, because usually different programs reside in different segments
  299.    and no one program is pointed to by zero segment.
  300. 3. CuteMouse uses a lot of self-modifying code and many variables are
  301.    placed in the code instructions; most of code modification is grouped
  302.    in the setupdriver and softreset_21 procedures.
  303. 4. To use free part of PSP and thus minimize memory footprint, CuteMouse
  304.    source includes corresponding "ORG" statement before uninitialized
  305.    variables, for which only offsets are computed and no data is generated.
  306.    Note: in TASM, a structure instance with "DUP" modifier generates data,
  307.    so buttpress and buttrelease arrays are defined without "DUP" as series
  308.    of BUTTLASTSTATE structure insertions instead.
  309. 5. CuteMouse is written using TASM and makes use some of TASM features:
  310.    for example, multiple "push" and "pop" in one line ("push ax bx") and
  311.    shifts with an immediate value >1 ("shl ax,2"), which are converted
  312.    into several opcodes valid for 8086/8088 CPUs (i.e. for shifts, TASM
  313.    simply duplicates them - "shl ax,1/shl ax,1"), because there is no
  314.    ".186" or higher statement.
  315. 6. Often instructions with shorter opcode but slightly different behavior
  316.    than assumed instruction are used to minimize code; each such use is
  317.    marked by "OPTIMIZE" comment. In addition, instructions for which
  318.    functions are performed by previous code remain in the source as
  319.    comments; this is done for greater readability and to ease code
  320.    carrying.
  321.