'===========================================================================
' Subject: TIME SLICING                       Date: 10-29-95 (10:52)       
'  Author: Jack Hudgions                      Code: QB, PDS                
'  Origin: FidoNet QUIK_BAS Echo            Packet: DATETIME.ABC
'===========================================================================
'These routines assume the declarations for the interrupt structures are
'present (QB.BI or QBX.BI), and that the QB.QLB or QBX.QLB quick library
'is loaded.

'For Windows, it's first necessary to retrieve the DOS version:

' Get DOS version
InReg.AX = &H3306
CALL Interrupt(&H21, InReg, OutReg)
DOSver = ((OutReg.BX AND 255) * 100) + (OutReg.BX \ 256)
IF DOSver = 0 THEN
  InReg.AX = &H3000
  CALL Interrupt(&H21, InReg, OutReg)
  DOSver = ((OutReg.AX AND 255) * 100) + (OutReg.AX \ 256)
END IF

'This returns the version as an integer for simplicity (300 = DOS 3.00,
'620 = DOS 6.20, etc.).

'Next, call the following function to detect Windows (If you attempt to
'execute this code under DOS 2.x, it will lock up):

' Check for Windows
IF DOSver >= 300 THEN
  InReg.AX = &H160A
  CALL Interrupt(&H2F, InReg, OutReg)
  IF OutReg.AX <> 0 THEN
    WinMode = 0
  ELSE
    WinMode = OutReg.CX
  END IF
END IF

'The variable WinMode will be set as follows:

'  0 = Windows not detected
'  1 = Real mode detected (Win 3.0 and earlier only)
'  2 = Standard mode detected.
'  3 = 386 enhanced mode detected.

'For OS/2, check the DOS version, and if it's 20 or higher, your program
'is running under OS/2 2.0 or later:

' Check for OS/2 by checking if DOS ver >= 20.
IsOS2 = DOSver >= 2000

'The variable IsOS2 will be zero (false) if OS/2 is not detected, or -1
'(true) if OS/2 is detected.  You can also use the DOS version to
'determine the OS/2 version.  I believe these are correct:

'  OS/2 version   DOS version returned
'     2.0               20.0
'     2.1               20.1
'     2.11              20.2
'     3.0               20.3

'Once you have this information, giving up timeslices is a snap.  Simply
'insert this code wherever your program awaits input:

' Give up timeslices under Windows or OS/2
IF WinMode = 3 OR IsOS2 THEN
  InReg.AX = &H1680
  CALL Interrupt(&H2F, InReg, OutReg)
END IF

