Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / sources / new-s5r4 / graf / doc / gmouse.doc
1              PROGRAMMER'S  REFERENCE  FOR  GENIUS  MOUSE  DRIVER
2
3 *** 1 : BRIEF DESCRIPTION
4
5 The Genius Mouse Driver enables you to use mouse hardware to move an on-screen
6 cursor and control its movement through a software program.  Various functions
7 allow you to determine cursor placement, cursor shape, and button status.
8
9 In order for you to interface your Genius Mouse with an application program, the
10 following information on the Genius Driver has been provided.
11
12 *** 2 : GRAPHICS AND TEXT CURSORS
13
14 GMOUSE Driver supports a hardware text cursor,  a software  text   cursor, and
15 a graphics cursor. A hardware text cursor is a blinking cursor which moves from
16 one character to another on-screen. This blinking cursor may take the form of a
17 block or underscore. A software text cursor makes use of display attributes to
18 change the visual appearance of a character on-screen.  Movement is from
19 character to character. A graphics cursor is a shape that moves over on-screen
20 images.
21
22 You can choose any of these three cursors to use on-screen, however, only one
23 cursor can be displayed at a given time.  Also, within your application program,
24 you can switch back and forth between cursors.
25
26
27 Display the Graphics Cursor
28
29 The cursor appears on-screen or disappears from the screen through the calling
30 program.  This cursor consists of a block of pixels.  As this block moves
31 on-screen and affects the pixels beneath it, the cursor shape and background are
32 created. This interaction is defined by two 16-by-16 bit arrays;
33 one is the screen mask and the other is the cursor mask. The screen mask
34 determines what part of the cursor pixel is to be the shape, and what part  is
35 is to be the background. The cursor mask determines which pixels contribute to
36 the color of the cursor. Whenever changes are made to the screen which lie
37 directly  beneath the cursor, the cursor should be concealed so that old values
38 are not restored to the screen.
39
40 Please note that with a high resolution mode, you have a 16-by-16 pixel block;
41 with a medium resolution (four color) mode, you have a 8-by-16 pixel block; with
42 a medium resolution (sixteen color) mode, you have a 4-by-16 pixel block.
43
44 Refer to function 9.
45
46 To create the cursor, the software uses data from the computer's screen memory
47 which defines the color of each pixel on-screen.  Operations are performed that
48 affect individual screen bits.  Software ANDs the screen mask defining the
49 pixels under the cursor and XORs the cursor mask with the result of the AND
50 operation.
51
52 Note the results when:
53
54
55
56
57
58
59                                  page 1
60 \f
61 Screen Mask Bit is      Cursor Mask Bit is      Resulting Screen Bit is
62 ------------------      ------------------      -----------------------
63         0                        0                         0
64         0                        1                         1
65         1                        0                     unchanged
66         1                        1                      inverted
67
68 With each mouse function, a reference to the graphics cursor location is in
69 reference to a point on-screen directly beneath the cursor.  This point that the
70 mouse software uses to determine the cursor coordinates is known as the cursor's
71 hot spot.
72 Generally, the upper_left hand corner of the cursor block is designated as the
73 coordinates for the cursor default value. ((0,0) are the upper_left hand corner
74 coordinates.)
75
76 Software Text Cursor
77
78 You can use this text cursor when your computer is in one of the text modes.  By
79 changing the character attributes beneath the cursor, the appearance of the
80 character is influenced on-screen.  This effect on the text cursor can be
81 defined by two 16-bit mask values. These bits can be described as follows:
82 bit 15 sets the blinking (1) or non-blinking (0) character ; bit 12 - 14 set the
83 background (1); bits 8 - 10 set the foreground color; and bits 0 - 7 set the
84 character code. These values in the screen mask and the cursor mask
85 determine the character's new attributes when the cursor is covering the
86 character.  The screen mask decides which of the character's attributes are
87 maintained. The cursor mask decides in what manner the attributes are altered
88 to produce the cursor.
89
90 In creating this cursor, the software works from data which defines each
91 character on the screen.  The software first ANDs the screen mask and the screen
92 data bit for the character beneath the cursor.  Next, the software XORs the
93 cursor mask and the result of the AND operation.
94
95 When a function refers to the text cursor location, it gives the coordinates of
96 the character beneath the cursor.
97
98 Refer  to function 10.
99
100 Hardware Text Cursor
101
102 This cursor is also available when the computer is in one of the text modes.
103 This cursor is the one seen on-screen when the computer is powered on.  It
104 consists of 8 pixels wide and 8 to 14 pixels tall.  Software allows you to use
105 this cursor for your needs. Scan lines determine a cursor's appearance
106 on-screen. A scan line consists of a horizontal set of pixels.
107 If a line is on, there will be flashing on the screen. If a line is off, there
108 is no effect. Scan lines are numbered from 0 to 7, or 0 to 11 depending on the
109 type of display used. 0 indicates the top scan line.
110
111 Refer to function 10.
112
113 *** 2.1 : Mouse Buttons
114
115 Mouse functions can give the status of the mouse buttons and the number of times
116 a certain button has been pressed and released.  The button status is given as
117 an integer. If a bit is set to 1 the button is down; if a bit is set to 0, the
118 button is up.
119                                  page 2
120 \f
121       Bit 0 - Left Button Status
122       Bit 1 - Right Button Status
123       Bit 2 - Middle Button Status
124 Each time a mouse button is pressed, a counter records the number of presses and
125 releases.  The software sets the counter to zero once it has been read or after
126 a reset.
127
128 *** 2.2 : Unit of Distance - Mouse Motion
129
130 The motion of the mouse can be expressed in a unit of distance (mouse motion)
131 and is approximately 1/200 of an inch.
132
133 With mouse movement, mouse software determines a horizontal and vertical mouse
134 motion count.  This count is used by the software to move a cursor a certain
135 number of pixels on-screen.  Software defines mouse motion sensitivity (the
136 number of mouse motions needed to move the cursor 8 pixels on-screen) and this
137 sensitivity determines the rate at which the cursor moves on-screen.
138
139 Refer to function 15.
140
141 *** 2.3 : Internal Cursor Flag
142
143 Mouse software supports an internal flag.  This flag determines when the cursor
144 should appear on-screen.  If the flag equals 0, the cursor appears on-screen; if
145 the flag is any other number, the cursor disappears from the screen.
146
147 You can call functions 1 and 2 a number of times, however, if you call function
148 2, you must call function 1 later.  This is necessary to restore the flag's
149 previous value.
150
151 Refer to functions 1 and 2.
152
153 *** 3 : CALLING FROM ASSEMBLY LANGUAGE PROGRAMS
154
155 To make mouse function calls:
156
157 Load the appropriate registers (AX, BX, CX, DX) with the parameter values.
158 These correspond to G1%, G2%, G3%, and G4% as shown in the BASIC example to
159 follow.  Then execute software interrupt 51 (33H).  The values given by the
160 mouse functions will be installed in the registers.
161
162
163 Example:
164
165    ; * set cursor to location (150,100)
166    Mov AX,4    ;(function call 4)
167    Mov CX,150  ;(set horizontal to 150)
168    Mov DX,100  ;(set vertical to 100)
169    Int 51(33H) ;(interrupt to mouse)
170
171 It is important to note that before using INT 33H, one should verify the
172 presence of the mouse driver.  Executing an INT 33H will cause uncertain results
173 if the mouse driver is not loaded.  Assume a mouse driver is present when INT
174 33H vector is non-zero and the vector does not point to an IRET instruction.
175
176 Note:  When making a mouse call in Assembly Language, expect somewhat of a
177 different value for the fourth parameter (when compared with calls using a BASIC
178 program) involving functions 9, 12, and 16.
179                                  page 3
180 \f
181 *** 4 : CALLING FROM BASIC LANGUAGE PROGRAM
182
183 To make  mouse function calls:
184
185   Set a pair of integer variables in your program for the offset and the segment
186   of the mouse driver entry point.
187
188   In order to obtain the offset and segment values, the following statements
189   must be inserted into your program before any calls to mouse functions:
190
191 10 DEF SEG = 0
192 15 ' GET GMOUSE ENTRY POINT
193 20 GMSEG   = PEEK( 51*4 + 2 ) + 256 * PEEK( 51*4 + 3 )   ' GET SEGMENT ENTRY
194 30 GMOUSE  = 2 + PEEK( 51*4 ) + 256 * PEEK( 51*4 + 1 )   ' GET OFFSET  ENTRY
195 40 DEF SEG = GMSEG           ' SET SEGMENT REGISTER AS THE SEGMENT OF GMOUSE
196
197 To enter the mouse driver, use the CALL statement:
198
199   CALL GMOUSE (G1%, G2%, G3%, G4%)
200
201 GMOUSE contains the entry offset of the mouse driver.  G1%, G2%, G3%, and G4%
202 are the integer variables given in the call.  These four must be specified in
203 the CALL statement even if a value is not assigned.  When a value is assigned,
204 it must be an integer, that is, a whole number.
205
206 Example:
207
208 50  ' Find the Activated Mode of Genius Mouse
209 60  G1% = 0 : G2% = 0
210 70  CALL GMOUSE ( G1%, G2%, G3%, G4% )
211 80  IF G2% AND 2 THEN PRINT "Genius Mouse ( 2_Button Mode ) Enable"
212 90  IF G2% AND 3 THEN PRINT "Genius Mouse ( 3_Button Mode ) Enable"
213 100 IF NOT G1%   THEN PRINT "Can't Find Genius Mouse"
214
215 *** 5 : MOUSE FUNCTIONS
216
217 These functions listed apply to the Genius Mouse.  Further descriptions of each
218 mouse function will be given in the following pages.
219
220 Functions                                         Function Number
221 -----------------------------------------------------------------
222 Reset Genius Mouse Driver                                 0
223 Enable Cursor Display                                     1
224 Disable Cursor Display                                    2
225 Read Cursor Location & Button State of Genius Mouse       3
226 Set Cursor Location of Genius Mouse                       4
227 Read Button Press State of Genius Mouse                   5
228 Read Button Release State of Genius Mouse                 6
229 Define Horizontal (X) Range of Cursor Location            7
230 Define Vertical (Y) Range of Cursor Location              8
231 Define Graphics Mode Cursor Style                         9
232 Define Text Mode Cursor Style                            10
233 Read Genius Mouse Motion Number                          11
234 Define Event Handler Entry Location                      12
235 Enable Light Pen Emulation Function                      13
236 Disable Light Pen Emulation Function                     14
237 Define Sensitivity (Mouse Motion/Pixel) of Genius Mouse  15
238
239                                  page 4
240 \f
241 Disable Cursor Display in Special Range                  16
242 Define Double-Speed Threshold                            19
243
244 EGA functions are described in Section *** 7.
245
246 *** 6 : DESCRIPTION OF THE MOUSE FUNCTIONS
247
248 You'll notice that with the following mouse function descriptions, the
249 parameters needed to make the calls and the expected outcome (return) for each
250 is indicated. Also,  any special conditions regarding any of the mouse functions
251 have been included.  Further, an example of a program has been provided in order
252 for you to understand how to make the call.
253
254 The input and return values are presented for 8086 registers and for BASIC in
255 the following pages.
256
257 It is important to note that each mouse function call needs four parameters.
258 The Genius Mouse software does not verify any input values, and therefore, if
259 any incorrect values are given, uncertain results will occur.
260
261 Function 0: Reset Genius Mouse Driver
262
263 Function 0 gives the current status of the mouse hardware plus the current
264 status of the mouse software.  The calling program is able to determine the
265 presence of a mouse driver and/or a serial port.
266
267 This function resets the mouse driver to the following default status as
268 indicated:
269
270 Variable                                Value
271 ------------------------------------------------------------------------------
272 internal cursor flag                    -1 (cursor concealed)
273 graphics  cursor shape                  horizontal oval
274 text cursor                             reverse video
275 user-defined call mask                  all zeroes
276 light pen emulation mode                enabled
277 vertical mouse motion/pixel ratio       16 to 8
278 horizontal mouse motion/pixel ratio     8 to 8
279 vertical min/max cursor coordinates     0/current display mode y values minus 1
280 horizontal min/max cursor coordinates   0/current display mode x values minus 1
281
282 8086 Register
283 Input:  AX = 0
284 Return: AX = mouse state (-1: installed, 0: not installed)
285         BX = number of buttons (2 button mode, 3 button mode)
286
287 BASIC
288 Input:  G1% = 0
289 Return: G1% = mouse state (-1: installed, 0: not installed)
290         G2% = number of buttons (2 button mode, 3 button mode)
291
292 Example:  Used initially to determine if the GMOUSE driver is present and to
293           reset GMOUSE.
294
295
296
297
298
299                                  page 5
300 \f
301 50  ' Find the Actived Mode of Genius Mouse
302 60  G1% = 0 : G2% = 0
303 70  CALL GMOUSE ( G1%, G2%, G3%, G4% )
304 80  IF G2% AND 2 THEN PRINT "Genius Mouse ( 2_Button Mode ) Enable"
305 90  IF G2% AND 3 THEN PRINT "Genius Mouse ( 3_Button Mode ) Enable"
306 100 IF NOT G1%   THEN PRINT "Can't Find Genius Mouse"
307
308 Function 1: Enable Cursor Display
309
310 Function 1 increments the internal cursor flag counter.  If the counter is zero,
311 the cursor is enabled and appears on-screen.
312
313 The default value is -1 which indicates a concealed cursor.  Function 1 must be
314 called to display the cursor.  In case the internal cursor flag is already zero,
315 a call to this function produces no effect.
316
317 8086 Register
318 Input:  AX = 1
319 Return: none
320
321 BASIC
322 Input:  G1% = 1
323 Return: none
324
325 Example:
326
327 110  ' Enable Genius Mouse's Cursor
328 120  G1% = 1
329 130 CALL GMOUSE ( G1%, G2%, G3%, G4% )
330
331 Function 2: Disable Cursor Display
332
333 Function 2 disables the cursor by removing it from the screen and decrementing
334 the internal cursor flag.  Even though the cursor cannot be seen, it still
335 tracks any motion made with the mouse.
336
337 You should use this function before changing any portion of the screen
338 containing the cursor.  You will avoid the problem of the cursor affecting
339 screen data.
340
341 Keep in mind that whenever your program calls function 2, it must later call
342 function 1 to return the internal cursor flag to its default value.  In
343 addition, if your program changes the screen mode, function 2 is called
344 automatically. Therefore, the cursor's movement is enabled the next time it is
345 displayed.
346
347 Call function 2 at the end of a program in order to conceal the cursor.  This
348 ensures that nothing remains on-screen.
349
350 8086 Register
351 Input:  AX = 2
352 Return: none
353
354 BASIC
355 Input:  G1% = 2
356 Return: none
357
358 Example:
359                                  page 6
360 \f
361 110  ' Disable Genius Mouse's Cursor
362 120  G1% = 2
363 130 CALL GMOUSE ( G1%, G2%, G3%, G4% )
364
365 Function 3: Read Cursor Location & Button State of Genius Mouse
366
367 Function 3 gives the status of mouse buttons, plus cursor location.
368
369 Button status consists of a single integer value:
370   Bit 0 = left button (2 button mode, 3 button mode)
371   Bit 1 = right button (2 button mode, 3 button mode)
372   Bit 2 = middle button (3 button mode)
373
374 The bit is 1 when the button is pressed.  The bit is 0 when the button is
375 released.
376
377 8086 Register
378 Input:  AX = 3
379 Return: BX = button status
380         CX = horizontal cursor coordinate
381         DX = vertical cursor coordinate
382
383 BASIC
384 Input:  G1% = 3
385 Return: G2% = button status
386         G3% = horizontal cursor coordinate
387         G4% = vertical cursor coordinate
388
389 Example:
390
391 110  ' Read Genius Mouse Location & Button State
392 120  G1% = 3
393 130 CALL GMOUSE ( G1%, G2%, G3%, G4% )
394 140 PRINT "Genius Mouse Location : X_Coord=" G3% " Y_Coord=" G4%
395 150 IF G2% AND 1 THEN PRINT "Left Button"
396 160 IF G2% AND 2 THEN PRINT "Right Button"
397 170 IF G2% AND 4 THEN PRINT "Middle Button"
398 180 PRINT "Pressed"
399
400 Function 4: Set Cursor Location of Genius Mouse
401
402 Function 4 sets the current cursor location.  Values must be within the
403 coordinate ranges for the virtual screen and, if necessary, are rounded to the
404 nearest values allowed for the current screen mode.
405
406   Screen     Display        Virtual         Cell        Bits/Pixel
407    Mode      Adapter       Screen (XxY)     Size      Graphics Mode
408 ---------  ------------  ---------------  --------   ----------------
409     0      C, E, 3270     640 x 200        16 x 8          -
410     1      C, E, 3270     640 x 200        16 x 8          -
411     2      C, E, 3270     640 x 200         8 x 8          -
412     3      C, E, 3270     640 x 200         8 x 8          -
413     4      C, E, 3270     640 x 200         2 x 1          2
414     5      C, E, 3270     640 x 200         2 x 1          2
415     6      C, E, 3270     640 x 200         1 x 1          1
416     7      M, E, 3270     640 x 200         8 x 8          -
417
418
419                                  page 7
420 \f
421     D      E              640 x 200        16 x 8          2
422     E      E              640 x 200         1 x 1          1
423     F      E              640 x 350         1 x 1          1
424     10     E              640 x 350         1 x 1          1
425     30     3270           720 x 350         1 x 1          1
426            H              720 x 348         1 x 1          1
427
428 Display Adapter:
429   M = IBM Monochrome Display/Printer Adapter
430   C = IBM Color/Graphics Adapter
431   E = IBM Enhanced Graphics Adapter
432 3270 = IBM All Points Addressable Graphics Adapter (3270 PC)
433   H = Hercules Monochrome Graphics Card
434
435 8086 Register
436 Input:  AX = 4
437         CX = new horizontal cursor coordinate
438         DX = new vertical cursor coordinate
439 Return: none
440
441 BASIC
442 Input:  G1% = 4
443         G3% = new horizontal cursor coordinate
444         G4% = new vertical cursor coordinate
445 Return: none
446
447 Example:
448
449 110  ' Set Cursor Location at the Upper_Left Corner of Screen
450 120 G1% = 4
451 130 G3% = 0 : G4% = 0
452 140 CALL GMOUSE ( G1%, G2%, G3%, G4% )
453
454 Function 5: Read Button Press State of Genius Mouse
455
456 Function 5 provides status on the specified button, gives the number of button
457 presses since the last call, and produces the location of the cursor at last
458 button press.
459
460 Button status consists of a single integer value.  Again, as in function 3:
461              Bit 0 = left button (2 button mode, 3 button mode)
462              Bit 1 = right button (2 button mode, 3 button mode)
463              Bit 2 = middle button (3 button mode)
464
465 The bit is 1 when the button is pressed.  The bit is 0 when the button is
466 released.
467
468 The number of button presses will always fall in the range of 0 to 32767.  There
469 is no indicator for overflow.  Following this function call, the count is reset
470 to zero.
471
472 8086 Register
473 Input:  AX = 5
474         BX = button status (left = 0, right = 1, middle = 2)
475 Return: AX = button status
476         BX = number of button presses
477         CX = horizontal cursor coordinate at last press
478         DX = vertical cursor coordinate at last press
479                                  page 8
480 \f
481 BASIC
482 Input:  G1% = 5
483         G2% = button status (left = 0, right = 1, middle = 2)
484 Return: G1% = button status
485         G2% = number of button presses
486         G3% = horizontal cursor coordinate at last press
487         G4% = vertical cursor coordinate at last press
488
489 Example:
490
491 110 ' Read the Left Button Press State of Genius Mouse
492 120 G1% = 5 : G2% = 2
493 130 CALL GMOUSE ( G1%, G2%, G3%, G4% )
494 140 IF G1% AND 2 THEN PRINT "The Middle Button Pressed at X_loc=" G3%
495
496 Function 6: Read Button Release State of Genius Mouse
497
498 Function 6 provides status on the specified button, gives the number of button
499 releases since the last call, and provides the location of the cursor at the
500 last button release.
501
502 Button status consists of a single integer value.  Again, as in function 3:
503              Bit 0 = left button (2 button mode, 3 button mode)
504              Bit 1 = right button (2 button mode, 3 button mode)
505              Bit 2 = middle button (3 button mode)
506
507 The bit is 1 when the button is pressed.  The bit is 0 when the button is
508 released.
509
510 The number of button releases will always fall in the range of 0 to 32767.
511 There is no indicator for overflow.  Following this function call, the count is
512 reset to zero.
513
514 8086 Register
515 Input:  AX = 6
516         BX = button status (left = 0, right = 1, middle = 2)
517 Return: AX = button status
518         BX = number of button releases
519         CX = horizontal cursor coordinate at last release
520         DX = vertical cursor coordinate at last release
521
522 BASIC
523 Input:  G1% = 6
524         G2% = button status (left = 0, right = 1, middle = 2)
525 Return: G1% = button status
526         G2% = number of button releases
527         G3% = horizontal cursor coordinate at last release
528         G4% = vertical cursor coordinate at last release
529
530 Example:
531
532 110 ' Read the Left Button Release State of Genius Mouse
533 120 G1% = 6 : G2% = 2
534 130 CALL GMOUSE ( G1%, G2%, G3%, G4% )
535 140 IF NOT G1% OR &HFFFB THEN PRINT "The Middle Button Released at X_loc=" G3%
536
537
538
539                                  page 9
540 \f
541 Function 7: Define Horizontal (X) Range of Cursor Location
542
543 Function 7 defines the horizontal range of the cursor on-screen.  As a result,
544 cursor movement is limited to this specified area.  If a cursor happens to be
545 outside of this area when a call is made, the cursor is moved to just inside the
546 area.
547
548 8086 Register
549 Input:  AX = 7
550         CX = minimum horizontal cursor coordinate
551         DX = maximum horizontal cursor coordinate
552 Return: none
553
554 BASIC
555 Input:  G1% = 7
556         G3% = minimum horizontal cursor coordinate
557         G4% = maximum horizontal cursor coordinate
558 Return: none
559
560 Example:
561
562 110 ' Enable Cursor in Horizontal Range between 100 to 200
563 120 G1% = 7
564 130 G2% = 100 : G3% = 200
565 140 CALL GMOUSE ( G1%, G2%, G3%, G4% )
566
567 Function 8: Define Vertical (Y) Range of Cursor Location
568
569 Function 8 defines the vertical range of the cursor on-screen.  As a result,
570 cursor movement is limited to this specified area.  If a cursor happens to be
571 outside of this area when a call is made, the cursor is moved to just inside the
572 area.
573
574 8086 Register
575 Input:  AX = 8
576         CX = minimum vertical cursor coordinate
577         DX = maximum vertical cursor coordinate
578 Return: none
579
580 BASIC
581 Input:  G1% = 8
582         G3% = minimum vertical cursor coordinate
583         G4% = maximum vertical cursor coordinate
584 Return: none
585
586 Example:
587
588 110 ' Enable Cursor in Vertical Range between 100 to 200
589 120 G1% = 8
590 130 G2% = 100 : G3% = 200
591 140 CALL GMOUSE ( G1%, G2%, G3%, G4% )
592
593 Function 9: Define Graphics Mode Cursor Style
594
595 Function 9 defines the style of the cursor in terms of color, shape, and center
596 for the graphics.  As mentioned before, this cursor is a 16-by-16 pixel block
597 and is defined by two 16-bit arrays (the screen mask bit and the cursor mask
598 bit). Cursor coordinates for the hot spot must be in the range of -16 to +16.
599                                  page 10
600 \f
601 8086 Register
602 Input:  AX = 9
603         BX = horizontal cursor hot spot
604         CX = vertical cursor hot spot
605         DX = pointer to screen and cursor mask
606 Return: none
607
608 BASIC
609 Input:  G1% = 9
610         G2% = horizontal cursor hot spot
611         G3% = vertical cursor hot spot
612         G4% = pointer to screen and cursor mask
613 Return: none
614
615 Example:
616
617 10  ' Define the screen mask
618 20  '
619 30    cursor (0,0)  = &HFFFF       '1111111111111111
620 40    cursor (1,0)  = &HFFFF       '1111111111111111
621 50    cursor (2,0)  = &HFFFF       '1111111111111111
622 60    cursor (3,0)  = &HFFFF       '1111111111111111
623 70    cursor (4,0)  = &HFFFF       '1111111111111111
624 80    cursor (5,0)  = &HF00F       '1111000000001111
625 90    cursor (6,0)  = &H0000       '0000000000000000
626 100   cursor (7,0)  = &H0000       '0000000000000000
627 110   cursor (8,0)  = &H0000       '0000000000000000
628 120   cursor (9,0)  = &H0000       '0000000000000000
629 130   cursor (10,0) = &HF00F       '1111000000001111
630 140   cursor (11,0) = &HFFFF       '1111111111111111
631 150   cursor (12,0) = &HFFFF       '1111111111111111
632 160   cursor (13,0) = &HFFFF       '1111111111111111
633 170   cursor (14,0) = &HFFFF       '1111111111111111
634 180   cursor (15,0) = &HFFFF       '1111111111111111
635 190 '
636 200 ' Define the cursor mask
637 210 '
638 220   cursor (0,1)  = &H0000       '0000000000000000
639 230   cursor (1,1)  = &H0000       '0000000000000000
640 240   cursor (2,1)  = &H0000       '0000000000000000
641 250   cursor (3,1)  = &H0000       '0000000000000000
642 260   cursor (4,1)  = &H0000       '0000000000000000
643 270   cursor (5,1)  = &H0000       '0000000000000000
644 280   cursor (6,1)  = &H07E0       '0000011111100000
645 290   cursor (7,1)  = &H7FFE       '0111111111111110
646 300   cursor (8,1)  = &H7FFE       '0111111111111110
647 310   cursor (9,1)  = &H07E0       '0000011111100000
648 320   cursor (10,1) = &H0000       '0000000000000000
649 330   cursor (11,1) = &H0000       '0000000000000000
650 340   cursor (12,1) = &H0000       '0000000000000000
651 350   cursor (13,1) = &H0000       '0000000000000000
652 360   cursor (14,1) = &H0000       '0000000000000000
653 370   cursor (15,1) = &H0000       '0000000000000000
654 380 '
655 390 ' Set the cursor style and hot spot number of Genius Mouse
656 400 '
657
658
659                                  page 11
660 \f
661 410 '
662 420   G1% = 9
663 430   G2% = 6 ' horizontal hot spot
664 440   G3% = 5 ' vertical hot spot
665 450   CALL GMOUSE ( G1%, G2%, G3%, cursor (0,0))
666
667 Function 10: Define Text Mode Cursor Style
668
669 Function 10 chooses the hardware or the software text cursor.
670
671 For example, if BX (G2%) is 1, the hardware cursor is selected and the hardware
672 is set up with the first and last scan lines which define the cursor.
673 (Values for CX (G3%) and DX (G4%) range from 0 to 7 for the color display and 0
674 to 11 for the monochrome display.)
675
676 If BX (G2%) is 0, the software cursor is selected; and CX (G3%) and DX (G4%)
677 must specify the screen and cursor masks.  (These masks give the attributes and
678 character code of the cursor, and their values are dependent on the type of
679 display in use.)
680
681 8086 Register
682 Input:  AX = 10
683         BX = select cursor (0: software text, 1: hardware text)
684         CX = screen mask value/scan line start
685         DX = cursor mask value/scan line stop
686 Return: none
687
688 BASIC
689 Input:  G1% = 10
690         G2% = select cursor (0: software text, 1: hardware text)
691         G3% = screen mask value/scan line start
692         G4% = cursor mask value/scan line stop
693 Return: none
694
695 Example:
696
697 110 ' Enable an Inverting Cursor
698 120 G1% = 10
699 130 G2% = 0
700 140 G3% = &HFFFF  :  G4% = &H7700
701 150 CALL GMOUSE ( G1%, G2%, G3%, G4% )
702
703 Function 11: Read Genius Mouse Motion Number
704
705 Function 11 gives the mouse motion number since the last call.  A positive
706 horizontal number indicates rightward movement (negative shows leftward
707 movement).  A positive vertical number indicates downward movement (negative
708 shows upward movement).
709 The number is always in the range of -32768 to 32767.  Overflow is disregarded.
710 Once the call is completed, the number is set to 0.
711
712 8086 Registers
713 Input:  AX = 11
714 Return: CX = horizontal number
715         DX = vertical number
716
717
718
719                                  page 12
720 \f
721 BASIC
722 Input:  G1% = 11
723 Return: G3% = horizontal number
724         G4% = vertical number
725
726 Example:
727
728 110 ' Read Genius Mouse Motion Number
729 120 G1% = 11
730 130 CALL GMOUSE ( G1%, G2%, G3%, G4% )
731 140 IF G3% > 0 THEN PRINT "Genius Mouse is Moving to Right"
732 150 IF G4% > 0 THEN PRINT "Genius Mouse is Moving Down"
733
734 Function 12: Define Event Handler Entry Location
735
736 Function 12 defines the address entry location of an event handler routine which
737 is called when a certain event (defined by the call mask) occurs.  The program
738 is temporarily interrupted by the mouse driver. At the end of the event handler
739 routine  the program continues at the point it was interrupted.
740
741 The call mask is a single integer value defining the conditions which will cause
742 an interrupt.
743
744 A specific condition corresponds to a bit in the call mask:
745
746 Mask Bit                Condition
747 --------------------------------------------------
748    0                    cursor location changed
749    1                    left button pressed
750    2                    left button released
751    3                    right button pressed
752    4                    right button released
753    5                    middle button pressed
754    6                    middle button released
755    7 - 15               not used
756
757 In order to call the event handler routine, set the mask bit to 1 and put the
758 mask in at CX (G3%).  To disable, set the mask bit to 0 and put the mask in at
759 CX (G3%).  Always be sure to set the call mask to 0 before the program finishes.
760 (Leave the system in the same state upon exit as if was upon entrance.)
761
762 8086 Register
763 Input:  AX = 12
764         CX = call mask
765         ES:DX = pointer to event handler routine
766 Return: none
767
768 BASIC
769 Input:  G1% = 12
770         G3% = call mask
771         G4% = pointer to event handler routine
772 Return: none
773
774 Example:
775
776
777
778
779                                  page 13
780 \f
781 110 ' Active BUTTDOWN Event Handler Routine, When One or More Buttons Pressed
782 120 G1% = 12
783 130 G3% = &H002A  :  G4% = BUTTDOWN%
784 140 CALL GMOUSE ( G1%, G2%, G3%, G4% )
785
786 Function 13: Enable Light Pen Emulation Function
787
788 Function 13 permits the mouse to act like a light pen.  When in this mode, calls
789 to the pen function will give the cursor coordinates at the last pen down
790 location.
791
792 Note that the status of "pen down" and "pen off-screen" is controlled by the
793 mouse buttons:  all buttons up, pen off-screen; one button pressed, pen down.
794
795 Light pen emulation is ON after each call to function 0 (Reset Mouse Driver).
796
797 8086 Register
798 Input:  AX = 13
799 Return: none
800
801 BASIC
802 Input:  G1% = 13
803 Return: none
804
805 Example:
806
807 110 ' Enable Light Pen Emulation Function
808 120 G1% = 13
809 130 CALL GMOUSE ( G1%, G2%, G3%, G4% )
810
811 Function 14: Disable Light Pen Emulation Function
812
813 Function 14 turns off the light pen emulation mode.  When disabled, any call to
814 the pen function will give information only about a real light pen.
815
816 8086 Register
817 Input:  AX = 14
818 Return: none
819
820 BASIC
821 Input:  G1% = 14
822 Return: none
823
824 Example:
825
826 110 ' Disable Light Pen Emulation Function
827 120 G1% = 14
828 130 CALL GMOUSE ( G1%, G2%, G3%, G4% )
829
830 Function 15: Define Sensitivity (Mouse Motion/Pixel) of Genius Mouse
831
832 Function 15 defines mouse sensitivity as determined by the mouse motion/pixel
833 ratio.  This is a way of setting the amount of cursor motion wanted for mouse
834 movement.  These ratios specify mouse motion per 8 pixels.  These values must
835 be in the range of 1 to 32767.  With a larger ratio, the cursor movement is
836 shortened for each mouse movement.
837
838
839                                  page 14
840 \f
841 Default values:   horizontal ratio - 8  mouse motions to 8 pixels
842                   vertical ratio   - 16 mouse motions to 8 pixels
843
844 Note: 1 mouse motion = 1/200 of an inch increment
845
846 8086 Register
847 Input:  AX = 15
848         CX = horizontal mouse motion counts to pixel ratio
849         DX = vertical mouse motion counts to pixel ratio
850 Return: none
851
852 BASIC
853 Input:  G1% = 15
854         G3% = horizontal mouse motion counts to pixel ratio
855         G4% = vertical mouse motion counts to pixel ratio
856 Return: none
857
858 Example:
859
860 110 ' Define Horizontal Sensitivity as 8
861 120 ' Define Vertical Sensitivity as 16
862 130 G1% = 15
863 140 G3% =  8
864 150 G4% = 16
865 160 CALL GMOUSE ( G1%, G2%, G3%, G4% )
866
867 Function 16: Disable Cursor Display in Special Range
868
869 Function 16 sets up a special range on-screen.  If the cursor moves to this area
870 or is in this area, it will be disabled.  After a call is made to this function,
871 it is necessary to call function 1 to enable the cursor again.
872
873 Define the special range with screen location values using four components:
874
875 Components          Values
876 --------------------------------------------------------
877     1               Left horizontal screen location
878     2               Upper vertical screen location
879     3               Right horizontal screen location
880     4               Lower vertical screen location
881
882 8086 Register
883 Input:  AX = 16
884         ES:DX = pointer to special range
885 Return: none
886
887 BASIC
888 Input:  G1% = 16
889         G4% = pointer to special range
890 Return: none
891
892 Example:
893
894 110 ' Disable Cursor Display in (0,0) to (100,100) Range
895 120 G1% = 16
896 130 RANGE%(1) = 0   : RANGE%(2) = 0
897 140 RANGE%(3) = 100 : RANGE%(4) = 100
898 150 CALL GMOUSE ( G1%, G2%, G3%, RANGE%(0) )
899                                  page 15
900 \f
901  .
902  .
903  .
904
905 500 ' Enable Cursor Display Again
906 510 G1% = 1
907 520 CALL GMOUSE ( G1%, G2%, G3%, G4% )
908
909 Function 19: Define Double-Speed Threshold
910
911 Function 19 defines the threshold value (mouse motion per second) for doubling
912 the cursor's motion.  Should the mouse move faster than the DX (G4%) value, the
913 cursor motion doubles.  The default value is 64 mouse motions per second.
914
915 If you should want to disable double-speed, just set the threshold to 32767
916 (7FFFH) mouse motions/second.
917
918 8086 Register
919 Input:  AX = 19
920         DX = threshold speed in mouse motions/second
921 Return: none
922
923 BASIC
924 Input:  G1% = 19
925         G4% = threshold speed in mouse motions/second
926 Return: none
927
928 Example:
929
930 110 ' Define Double-Speed Threshold as 20 Mouse Motions/Second
931 120 G1% = 19
932 130 G4% = 20
933 140 CALL GMOUSE ( G1%, G2%, G3%, G4% )
934
935  .
936  .
937  .
938
939 500 ' Disable Double-Speed Threshold Function
940 510 G1% = 19
941 520 G4% = 256 'MAX. VALUE
942 530 CALL GMOUSE ( G1%, G2%, G3%, G4% )
943
944 *** 7 : USING GENIUS MOUSE WITH IBM ENHANCED GRAPHICS ADAPTER
945
946 Within the Genius Mouse driver, you'll find nine EGA functions.  These functions
947 permit your program to write to and read from write-only registers.
948
949 The cursor in use is defined as a monochrome cursor with one bit per pixel.  The
950 bit masks are determined by function 9 and apply to all active planes.
951
952 In order to make an EGA function call from an Assembly-Language program, first
953 load the AX, BX, CX, DX, and ES registers with the values indicated for the
954 parameters.  Note that five values must be given for a high level language
955 program.  Next, execute software interrupt 16 (10h). The values that are
956 returned are intalled in the registers by EGA functions.
957
958
959                                  page 16
960 \f
961 Upon start with DOS, PC BIOS will verify if the EGA BIOS exists.  When this is
962 verified, the PC will execute the EGA BIOS, booting up the program to write the
963 INT 10h entry vector to the address of the INT 42h vector.  Now, EGA BIOS
964 address will be written to INT 10h. Following this, you are able to call EGA
965 BIOS (by using INT 10h) and PC video BIOS (by using INT 42h).
966
967 There are twenty functions in EGA BIOS.  (PC BIOS has only 16.) The EGA BIOS
968 routines only intercept the BIOS ROM video routines (INT 10h, AH = 13h or less).
969
970 The following indicates nine EGA functions and the corresponding function
971 number:
972
973 Function                                             Number (HEX)
974 -----------------------------------------------------------------
975 Retrieve Single Data                                       F0
976 Save Single Data                                           F1
977 Retrieve Registers on a Specified Port                     F2
978 Save Registers on a Specified Port                         F3
979 Retrieve Several Registers Data                            F4
980 Save Several Registers Data                                F5
981 Reset All Registers as Initial Values                      F6
982 Set Initial Values                                         F7
983 Get Version Number of Genius Mouse Driver                  FA
984
985 In the above functions, the EGA I/O port number and address are as follows:
986
987 Port No.  Register Name   No. of Registers  Index No.  Address Select Register
988 ------------------------------------------------------------------------------
989  00H      CRT Controller         25           0 - 24            3x4H
990  08H      Sequencer               5           0 - 4             3C4H
991  10H      Graphics Controller     9           0 - 8             3CEH
992  18H      Attribute Controlle    20           0 - 19            3C0H
993           Singular Registers
994  20H      Miscellaneous Output    1           ignored           3C2H
995  28H      Feature Control         1           ignored           3xAH
996  30H      Graphics 1 Position     1           ignored           3CCH
997  38H      Graphics 2 Position     1           ignored           3CAH
998
999   Note: x = B or D depending on the base I/O address;
1000         determined by Miscellaneous Output Register bit 1.
1001
1002 Function F0: Retrieve Single Data
1003
1004 This function retrieves data from a single register.
1005
1006 Input:  AH = F0H
1007         BX = Index number
1008         DX = Port number
1009 Return: BL = Retrieved data from EGA register
1010
1011 Example:
1012
1013 FUN_F0     EQU     0f0H         ; Function F0
1014 ;
1015 GR_CONTR   EQU     010H         ; Graphics Controller
1016 MODE_REG   EQU     005H         ; Mode Regisiter
1017 ;
1018
1019                                  page 17
1020 \f
1021 GR1_PORT   EQU     030H         ; Graphics 1 Position Register
1022 GR2_PORT   EQU     038H         ; Graphics 2 Position Register
1023 ;
1024 VIDEO      EQU     010H         ; BIOS ROM Video Routine Entry
1025
1026
1027
1028            ; Retrieve the Mode Register in Graphics Controller
1029 MODE_REG   DB      00
1030            ;
1031            MOV     DX, GR_CONTR
1032            MOV     BX, MODE_REG
1033            MOV     AH, FUN_F0
1034            INT     VIDEO
1035            MOV     MODE_REG, BL
1036
1037
1038            ; Retrieve Graphics 1 Position Data
1039 GR1_POS    DB      00
1040            ;
1041            MOV     DX, GR1_POS
1042            MOV     AH, FUN_F0
1043            INT     VIDEO
1044            MOV     GR1_POS, NL
1045
1046
1047 Function F1: Save Single Data
1048
1049 This function saves data to an EGA register.  Upon finishing a call to this
1050 function, the BH and DX values are altered.
1051
1052 Input:  AH = F1H
1053         BL = Index number (Non-single register only)
1054            = Data (Single register only)
1055         BH = Data (Non-single register only)
1056            = Disregard (Single register only)
1057         DX = Port number
1058 Return: None
1059
1060 Example:
1061
1062 FUN_F1     EQU     0f1H         ; Function F1
1063 ;
1064 SEQUENCE   EQU     008H         ; Sequencer
1065 MASK_REG   EQU     002H         ; Map Mask Register
1066 ;
1067 FEAT_PORT  EQU     028H         ; Feature Control Register
1068 ;
1069 VIDEO      EQU     010H         ; BIOS ROM Video Routine Entry
1070            ; Save Map Mask Register of Sequencer
1071 MAP_MASK   EQU     03H
1072            ;
1073            MOV     DX, SEQUENCE
1074            MOV     BL, MASK_REG
1075            MOV     BH, MAP_MASK
1076            MOV     AH, FUN_F1
1077            INT     VIDEO
1078            MOV     MAP_MASK, BL
1079                                  page 18
1080 \f
1081
1082            ; Save Feature Control Register
1083 FEATURE    DB      02H
1084            ;
1085            MOV     DX, FEAT_PORT
1086            MOV     BL, FEATURE
1087            MOV     AH, FUN_F1
1088            INT     VIDEO
1089            MOV     FEATURE, BL
1090
1091 Function F2: Retrieve Registers on a Specified Port
1092
1093 This function retrieves data from registers on a specifiã port.  Upon finishing
1094 a call to this function, the CX value is altered.
1095
1096 Input:  AH = F3H
1097         CH = Starting index number
1098         CL = Number of registers
1099         DX = Port number
1100         ES:BX = Destination of returned data
1101 Return: Returned data to destination address
1102
1103 Example:
1104
1105 FUN_F2     EQU     0f2H         ; Function F2
1106 ;
1107 GR_CONTR   EQU     010H         ; Graphics Controller
1108 ;
1109 VIDEO      EQU     010H         ; BIOS ROM Video Routine Entry
1110
1111
1112
1113            ; Retrieve Four Registers Data from Graphics Controller
1114 GRAPH_POOL DB      04   DUP (0)
1115            ;
1116            MOV     DX, DS
1117            MOV     ES, DX
1118            ;
1119            MOV     DX, GR_CONTR
1120            MOV     BX, OFFSET GRAPH_POOL
1121            MOV     CX, 04H
1122            MOV     AH, FUN_F2
1123            INT     VIDEO
1124
1125 Function F3: Save Registers on a Specified Port
1126
1127 This function saves data from registers on a specifiã port.  Upon finishing a
1128 call to this function, the BX, CX, and DX values are altered.
1129
1130 Input:  AH = F3H
1131         CH = Starting index number
1132         CL = Number of register
1133         DX = Port number
1134         ES:BX = Address source of incoming data
1135 Return: None
1136
1137 Example:
1138
1139                                  page 19
1140 \f
1141 FUN_F3     EQU     0f3H         ; Function F3
1142 ;
1143 ATTR_CONTR EQU     018H         ; Attribute Controller
1144 ;
1145 VIDEO      EQU     010H         ; BIOS ROM Video Routine Entry
1146
1147
1148
1149            ; Save Four Registers Data into Attribute Controller
1150 PALET_DATA DB      1, 2, 4, 3
1151            ;
1152            MOV     DX, DS
1153            MOV     ES, DX
1154            ;
1155            MOV     DX, ATTR_CONTR
1156            MOV     BX, OFFSET PALET_DATA
1157            MOV     CX, 08
1158            MOV     AH, FUN_F3
1159            INT     VIDEO
1160
1161 Function F4: Retrieve Several Registers Data At The Same Time
1162
1163 This function retrieves data from several registers at the same time.  Upon
1164 finishing a call to this function, the CX value is altered.
1165
1166 Input:  AH = F4H
1167         CX = Number of registers (more than 1)
1168         ES:BX = Address of register packet (each consists of 4 bytes;
1169                 port  address,  byte 1-2;  index number,  byte 3;
1170                 returned data, byte 4)
1171 Return: Returned data is saved into byte 4
1172
1173 Example:
1174
1175 FUN_F4     EQU     0f4H         ; Function F4
1176 ;
1177 VIDEO      EQU     010H         ; BIOS ROM Video Routine Entry
1178             ; Retrieve Follow  Registers Data
1179 TABLE       DW     030H         ; Graphics 1 Position Register
1180             DB      00          ; Single Register
1181             DB      00          ; Retrieved Data
1182             ;
1183             DW     010H         ; Graphics Controller
1184             DB      05          ; Mode Register
1185             DB      00          ; Retrieved Data
1186             ;
1187             ;
1188             MOV    DX, DS
1189             MOV    ES, DX
1190             ;
1191             MOV    BX, OFFSET TABLE
1192             MOV    CX, 02
1193             MOV    AH, FUN_F4
1194             INT    VIDEO
1195
1196
1197 Function F5: Save Several Registers Data At The Same Time
1198
1199                                  page 20
1200 \f
1201 This function saves data from several registers at the same time.  Upon
1202 finishing a call to this function, the CX value is altered.
1203
1204 Input:  AH = F5H
1205         CX = Number of registers (more than 1)
1206         ES:BX = Address of register packet (each consists of 4 bytes;
1207                 port  number, byte 1-2;  index number,  byte 3;
1208                 output data, byte 4)
1209 Return: None
1210
1211 Example:
1212
1213 FUN_F5     EQU     0f5H         ; Function F5
1214 ;
1215 VIDEO      EQU     010H         ; BIOS ROM Video Routine Entry
1216
1217
1218             ; Save Follow Registers Data
1219 TABLE       DW      20H         ; Miscellaneous
1220             DB      00          ; Single Register
1221             DB      01          ; Data
1222             ;
1223             DW      18H         ; Attribute Controller
1224             DB      12H         ; Color Plane Enable
1225             DB      07H         ; Data
1226             ;
1227             ;
1228             MOV    DX, DS
1229             MOV    ES, DX
1230             ;
1231             MOV    BX, OFFSET TABLE
1232             MOV    CX, 02
1233             MOV    AH, FUN_F5
1234             INT    VIDEO
1235
1236 Function F6: Reset All Registers as Initial Values
1237
1238 This function resets all values to default values for the specific registers.
1239 Function 7 sets the default values.
1240
1241 Input:  AH = F6H
1242 Return: None
1243
1244 Example:
1245
1246 FUN_F6     EQU     0f6H         ; Function F6h
1247 ;
1248 VIDEO      EQU     010H         ; BIOS ROM Video Routine Entry
1249
1250
1251            MOV     AH, FUN_F6
1252            INT     VIDEO
1253
1254 Function F7: Set Initial Values
1255
1256 This function sets the initial default values.  Upon finishing a call to this
1257 function, the BX and DX values are altered.
1258
1259                                  page 21
1260 \f
1261 Input:  AH = F7H
1262         DX = Port number
1263         ES:BX = Table of output data
1264 Return: None
1265
1266 Example:
1267
1268 FUN_F7     EQU     0f7H         ; Function F7
1269 ;
1270 ATTR_CONTR EQU     018H         ; Attribute Controller
1271 ;
1272 VIDEO      EQU     010H         ; BIOS ROM Video Routine Entry
1273
1274
1275
1276            ; Setting Initial Values for the Attribute Controller
1277 ATTR_DATA  DB      1,  2,  4,  3,  5,  6,  0,  7
1278            DB      0,  0,  0,  0,  0,  0,  0,  0
1279            DB      0,  0, 0fh, 0
1280            ;
1281            MOV     DX, DS
1282            MOV     ES, DX
1283            ;
1284            MOV     DX, ATTR_CONTR
1285            MOV     BX, OFFSET ATTR_DATA
1286            MOV     AH, FUN_F7
1287            INT     VIDEO
1288
1289 Function FA: Get Version Number of Genius Mouse Driver
1290
1291 This function will give the Genius Mouse driver version number.
1292
1293 Input:  AH = FAH
1294         BX = 00H
1295 Return: ES:BX = Pointer to Genius Mouse driver version number.
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319                                  page 22
1320
1321