REM $DYNAMIC

TYPE RegTypeX
 AX AS INTEGER
 BX AS INTEGER
 CX AS INTEGER
 DX AS INTEGER
 BP AS INTEGER
 SI AS INTEGER
 DI AS INTEGER
 Flags AS INTEGER
 DS AS INTEGER
 ES AS INTEGER
END TYPE

DIM InregsX AS RegTypeX
DIM OutregsX AS RegTypeX

 DECLARE SUB InterruptX (N AS INTEGER, I AS RegTypeX, O AS RegTypeX)

 ' call plex
 InregsX.AX = &H1000
 CALL InterruptX(&H2F, InregsX, OutregsX)
 PRINT "AX="; HEX$(OutregsX.AX)
 IF (OutregsX.AX AND &HFF) = &HFF THEN
    Share.Installed = -1
 ELSE
    Share.Installed = 0
 END IF
 IF Share.Installed THEN
    PRINT "Share installed."
 ELSE
    PRINT "Share not installed."
 END IF

 ' detect ansi
 InregsX.AX = &H1A00
 CALL InterruptX(&H2F, InregsX, OutregsX)
 PRINT "AX="; HEX$(OutregsX.AX)
 IF (OutregsX.AX AND &HFF) = &HFF THEN
    Ansi.Installed = -1
 ELSE
    Ansi.Installed = 0
 END IF
 IF Ansi.Installed THEN
    PRINT "Ansi installed."
 ELSE
    PRINT "Ansi not installed."
 END IF

 ' detect mouse
 InregsX.AX = 0
 InregsX.BX = 0
 CALL InterruptX(&H33, InregsX, OutregsX)
 PRINT "AX="; HEX$(OutregsX.AX)
 If OutregsX.AX=&HFFFF Then
    Mouse.Present = -1
 Else
    Mouse.Present = 0
 Endif
 IF Mouse.Present THEN
    PRINT "Mouse installed."
 ELSE
    PRINT "Mouse not installed."
 END IF

 ' detect windows
 InregsX.AX=&H160A
 Call InterruptX(&H2F,InregsX,OutregsX)
 If OutregsX.BX>0 Then
    Windows.Detected = -1
    ' store windows version
    Win.Minor=OutregsX.BX And &HFF
    Win.Major=(OutregsX.BX And &HFF00)/256
 Endif
 If Windows.Detected Then
    Print "Windows v";Win.Major;".";Win.Minor
 Else
    Print "Windows not detected."
 Endif

 ' detect os
 InregsX.AX = &H3001
 InregsX.BX = 0
 CALL InterruptX(&H21, InregsX, OutregsX)
 Print "DOS version:"
 PRINT " OS AX="; HEX$(OutregsX.AX)
 PRINT " OS BX="; HEX$(OutregsX.BX)
 PRINT " OS CX="; HEX$(OutregsX.CX)
 PRINT " OS DX="; HEX$(OutregsX.DX)
 END
