BASIC Initialization Code
PSS ID Number: Q19871
Article last modified on 05-14-1993
PSS database name: H_Mouse

1.x 2.x 3.x 4.x 5.x 6.x 7.x 8.x 9.00

MS-DOS


-------------------------------------------------------------------
The information in this article applies to:

 - Microsoft Mouse Driver for MS-DOS, versions 1.x, 2.x, 3.x, 4.x,  
   5.x, 6.x, 7.x, 8.x, and 9.0
------------------------------------------------------------------- 

Summary:

This article explains the BASIC interpreter standard mouse
initialization code as documented in the pre-Version 6.00 "Microsoft
Mouse User's Guide" and the "Microsoft Mouse Programmer's Reference." 

More Information:

The following is the standard initialization code:

   10 DEF SEG=0
   20 MSEG=256*PEEK(51*4+3)+PEEK(51*4+2)
   30 MOUSE=256*PEEK(51*4+1)+PEEK(51*4)+2
   40 IF MSEG OR (MOUSE - 2) THEN 50
   50 PRINT "Mouse Driver not found":END
   60 DEF SEG=MSEG
   70 IF PEEK(MOUSE-2) = 207 THEN 50 ' 207 is IRET
   80 M1% = 0
   90 CALL MOUSE(M1%,M2%,M3%,M4%)
   100 IF M1% = 0 then 50 ' Mouse Hardware not found
   110 'Continue

Each numbered line is explained below.

   Line(s)   Explanation
  ---------------------------------------------------------------------
   10        Sets the BASIC data segment to segment zero (0).

   20 - 30   Obtains the mouse driver's interrupt 33h (51d) vector 
             address PLUS 2, to get the CALL address for the driver.

   40        Checks to see if either the SEGMENT or OFFSET of the INT
             vector is zero (0), and sends the program to line 50 
             (mouse not found) if a zero (0) is found. Under MS-DOS 
             version 2.x, uninitialized interrupt vectors point at 
             zero (0).

   50        Prints the message "Mouse not found" and exits.

   60        Defines to BASIC data segment as the mouse driver segment.

   70        Checks to see if the INT vector points at an IRET 
             instruction (a byte value of 207). Under MS-DOS version 
             3.x, uninitialized vectors point at IRET instructions, 
             but not necessarily at zeros (0). Sends the program to 
             line 50 if 207 is found.

   90        Issues a function zero (0) call.

  100        If the answer to line 90 indicates "no mouse," sends the 
             program to line 50. 

  110        Continues if line 90 locates a mouse driver.

Additional reference words: 7.00 7.04 7.05 8.00 8.10 8.20 9.00

Copyright Microsoft Corporation 1993.