 Rem File: Detect4.bas - for Dndsic
 Rem $Include: 'dndsic.inc'

Function PI#
 PI# = Atn(1) * 4
End Function

Function YN$(I%)
 If I%=False Then
    YN$="No"
 Else
    YN$="Yes"
 Endif
End Function

Sub VideoInt(Var,Var1)
 On Local Error Goto ErrorExit1
 Select Case Var
 Case 2 ' set cursor
    InregsX.AX=&H0200
    InregsX.BX=Video.Page
    InregsX.DX=Var1
 Case 3 ' get cursor
    InregsX.AX=&H0300
    InregsX.BX=Video.Page
 Case 6 ' scroll
    InregsX.AX=&H0601
    InregsX.BX=&H0700
    InregsX.CX=&H0000
    InregsX.DX=Var1
 Case 15 ' get mode
    InregsX.AX=&H0F00
 End Select
 Call InterruptX(&H10,InregsX,OutregsX)
ErrorExit1:
 Exit Sub
End Sub

Sub StdinInt(Var,VarY)
 On Local Error Goto ErrorExit2
 Select Case Var
 Case 6 ' output
    InregsX.AX=&H0600
    InregsX.DX=VarY
 Case 7 ' input
    InregsX.AX=&H0600
    InregsX.DX=&H00FF
 Case 26 ' set dta
    InregsX.AX=&H1A00
 Case 47 ' get dta
    InregsX.AX=&H2F00
 Case 48 ' get os version
    InregsX.AX=&H3001
 Case 54 ' get disk space
    InregsX.AX=&H3600
    InregsX.DX=&H0000
 Case 55 ' get disk info
    InregsX.AX=&H3600
    InregsX.DX=&H0000+VarY
 Case 62 ' get psp segment
    InregsX.AX=&H6200
 Case 63 ' makedir
    InregsX.AX=&H3900
 Case 67 ' set file attr
    InregsX.AX=&H4301
 Case 68 ' get file attr
    InregsX.AX=&H4300
 Case 69 ' get volume
    InregsX.AX=&H6900
 Case 78 ' findfirst
    InregsX.AX=&H4E00
 Case 79 ' findnext
    InregsX.AX=&H4F00
 Case 113 ' 71h extended
    InregsX.AX=&H7100+VarY
 Case 115 ' 73h extended
    InregsX.AX=&H7300+VarY
 End Select
 Call InterruptX(&H21,InregsX,OutregsX)
ErrorExit2:
 Exit Sub
End Sub

Sub Mouse.Function(Var1,Var2)
 On Local Error Goto ErrorExit3
 InregsX.AX=Var1
 InregsX.BX=Var2
 Call InterruptX(&H33,InregsX,OutregsX)
ErrorExit3:
 Exit Sub
End Sub

Sub Mouse.Function2(Var1,Var2,Var3,Var4)
 On Local Error Goto ErrorExit4
 InregsX.AX=Var1
 InregsX.BX=Var2
 InregsX.CX=Var3
 InregsX.DX=Var4
 Call InterruptX(&H33,InregsX,OutregsX)
ErrorExit4:
 Exit Sub
End Sub

Sub Slice.Function
 On Local Error Goto ErrorExit5
 InregsX.AX=&H1680
 InregsX.BX=&H0000
 Call InterruptX(&H2F,InregsX,OutregsX)
ErrorExit5:
 Exit Sub
End Sub

Sub Plex.Function(Var1)
 On Local Error Goto ErrorExit6
 Select Case Var1
 Case 16 ' detect share
    InregsX.AX=&H1000
 Case 22 ' detect windows
    InregsX.AX=&H160A
 Case 26 ' detect ansi
    InregsX.AX=&H1A00
 Case 27 ' detect avatar
    InregsX.AX=&H1A00
    InregsX.BX=&H4156
    InregsX.CX=&H4154
    InregsX.DX=&H4152
 Case 74 ' detect dos
    InregsX.AX=&H4A33
 End Select
 Call InterruptX(&H2F,InregsX,OutregsX)
ErrorExit6:
 Exit Sub
End Sub

Sub Extended.Driver(Var)
 On Local Error Goto ErrorExit7
 If Local.Mode Then
    Exit Sub
 Endif
 If Fossil.Active=False Then
    OutregsX.AX=False
    Exit Sub
 Endif
 Select Case Var
 Case 9 ' purge output
    InregsX.AX=&H0900
 Case 10 ' purge input
    InregsX.AX=&H0A00
 Case 13 ' dcd watchdog on
    InregsX.AX=&H1401
 Case 14 ' dcd watchdog off
    InregsX.AX=&H1400
 Case 15 ' flow control
    InregsX.AX=&H0F00
 Case 16 ' set/check control-c/control-k
    InregsX.AX=&H1001
 Case 17 ' reboot
    InregsX.AX=&H1701
 Case 28 ' activate
    If Fossil.Version=1 Then
       InregsX.AX=&H1C00
    Else
       InregsX.AX=&H0400
    Endif
 Case 29 ' deactivate
    If Fossil.Version=1 Then
       InregsX.AX=&H1D00
    Else
       InregsX.AX=&H0500
    Endif
 End Select
 InregsX.DX=Port
 Call InterruptX(&H14,InregsX,OutregsX)
ErrorExit7:
 Exit Sub
End Sub

' lower/raise dtr, get x00 status
Sub Extended.Driver2(Var,Var2)
 On Local Error Goto ErrorExit8
 Select Case Var
 Case 4 ' detect
    InregsX.AX=&H0400
 Case 6 ' line
    InregsX.AX=&H0600+Var2
 Case 28 ' detect
    InregsX.AX=&H1C00
 Case 31 ' line
    InregsX.AX=&H1F01
    InregsX.BX=Var2
 End Select
 InregsX.DX=Port
 Call InterruptX(&H14,InregsX,OutregsX)
ErrorExit8:
 Exit Sub
End Sub

Sub SpecInt86X(Var)
 On Local Error Goto ErrorExit9
 CALL InterruptX(Var,InregsX,OutregsX)
ErrorExit9:
 Exit Sub
End Sub

Sub Driver(Var)
 On Local Error Goto ErrorExit10
 Select Case Var
 Case 1
    InregsX.AX=InregsX.AX Or &H0100
 Case 2
    InregsX.AX=&H0200
 Case 3
    InregsX.AX=&H0300
 End Select
 InregsX.DX=Port
 Call InterruptX(&H14,InregsX,OutregsX)
ErrorExit10:
 Exit Sub
End Sub

Sub Detect.Share
 On Local Error Goto ErrorExit11
 Call Plex.Function(16)
 If (OutregsX.AX And &HFF)=&HFF Then
    Share.Installed=True
 Else
    Share.Installed=False
 Endif
 Windows.Detected = False
 Call Plex.Function(22)
 If OutregsX.BX>0 Then
    Windows.Detected = True
    ' store windows version
    Win.Minor=OutregsX.BX And &HFF
    Win.Major=(OutregsX.BX And &HFF00)/256
 Endif
ErrorExit11:
 Exit Sub
End Sub

Sub Read.Rows(Var)
 On Local Error Goto ErrorTrap12
 Temp1=50
 Locate 50,1,0
 Var=50
 Exit Sub
Next.Trap1:
 Temp1=43
 Locate 43,1,0
 Var=43
 Exit Sub
Next.Trap2:
 Temp1=25
 Locate 25,1,0
 Var=25
 Exit Sub
Next.Trap3:
 Var=12
ErrorResume12:
 Exit Sub
ErrorTrap12:
 If Temp1=50 Then
    Resume Next.Trap1
 Endif
 If Temp1=43 Then
    Resume Next.Trap2
 Endif
 If Temp1=25 Then
    Resume Next.Trap3
 Endif
 Resume ErrorResume12
End Sub

Sub Release.Time(Var)
 On Local Error Goto Error.Trap6a
 If Supported.Call=False Then
    For Var1=1 To Var
       Call Slice.Function
       If (OutregsX.AX And &HFF)=&H80 Then
          Supported.Call=True
          Exit For
       Endif
    Next
 Endif
Error.Resume6a:
 Exit Sub
Error.Trap6a:
 Resume Error.Resume6a
End Sub

Function DateS$
 DateS$=Format$(Now,"mm-dd-yyyy")
End Function
