'===========================================================================
' Subject: EXTRACT INFO FROM BIOS             Date: 06-25-98 (00:51)       
'  Author: Marc van den Dikkenberg            Code: PB                     
'  Origin: excel@xs4all.nl                  Packet: PB.ABC
'===========================================================================
' Some information that can be extracted from the BIOS...
' Diskdrives, communication ports, screenmodes, etc.
' PowerBasic 3.x
'
' Notice: on some systems, the BIOS may return data
' that is not completely accurate.
'
' Just something I put together on a rainy day.
' (C) 1998, Marc van den Dikkenberg
'
' The PowerBasic Archives -- http://www.xs4all.nl/~excel/pb.html
' PowerBasic 3.x
'
CLS

dim high as integer
dim low as integer

Print String$(40,"-")

DEF SEG=&H40

Print "Current Video Mode  : " Peek(&H49)
'
' This one can be usefull - PB's build-in PbvScrnMode
' only updates when you use the SCREEN <x> command,
' and will not be correct once you use different methods,
' for example to get SCREEN 13 to work. The above _will_
' work in that case, too. But don't forget the DEF SEG=&H40
'
Print "Columns on Screen   : " Peek(&H4A)
Print "Base Memory         : " Peeki(&H13)"KB"
Print "Extended Memory     : " ;
	Out &H70,&H18
	temp=Inp(&H71)
	Out &H70,&H17
	? temp*256+Inp(&H71)"KB"

high% = peekl(&H10) \ 256
low%  = peekl(&H10) MOD 256

if bit(low%,1)=1 then
	print "Math Co-processor   :  Installed    "
else
   print "Math Co-processor   :  Not Available"
end if

if bit(low%,4)=0 and bit(low%,5)=0 then print"Initial videomode   :  EGA/VGA/PGA Color"
if bit(low%,4)=0 and bit(low%,5)=1 then print"Initial Videomode   :  80 x 25 CGA Color"
if bit(low%,4)=1 and bit(low%,5)=0 then print"Initial Videomode   :  40 x 25 CGA Color"
if bit(low%,4)=1 and bit(low%,5)=1 then print"Initial Videomode   :  Monochrome Text  "

Print String$(40,"-")
Print "Gameport            :  ";:if bit(high%,4)=1 then print "Yes" else print "No "
print "Serial Ports        : "val("&B"+left$(right$(bin$(high%),4),3))

for temp=1 to 4
   ' Communication Port addresses are stored at the following locations:
   ' COM1: &H00
   ' COM2: &H02
   ' COM3: &H04
   ' COM4: &H06
   if peeki(&H0+(temp-1)*2)<>0 then
      Print "COM"temp"              :  &H";
      print hex$(peeki(&H0+(temp-1)*2))
   end if
next temp

for temp=1 to 4
   ' Printer Port addresses are stored at the following locations:
   ' LPT1: &H08
   ' LPT2: &H0A
   ' LPT3: &H0C
   ' LPT4: &H0E
   if peeki(&H08+(temp-1)*2)<>0 then
      print "LPT"temp"              :  &H";
      print hex$(peeki(&H08+(temp-1)*2))
   end if
next temp

Print String$(40,"-")


REG 1,&H3305
Call Interrupt &H21
Print "Booted From Device  :  "chr$((reg(4) mod 256)+64)


high% = peekl(&H10) \ 256
low%  = peekl(&H10) MOD 256

print "Floppydrive         :  ";
if bit(low%,0)=1 then
	print "Installed    "
else
	print "Not Available"
end if

if bit(low%,6)=0 and bit(low%,7)=0 then print"Number of Drives    :  1"
if bit(low%,6)=0 and bit(low%,7)=1 then print"Number of Drives    :  2"
if bit(low%,6)=1 and bit(low%,7)=0 then print"Number of Drives    :  3"
if bit(low%,6)=1 and bit(low%,7)=1 then print"Number of Drives    :  4"

Out &H70,&H10
x=Inp(&H71)
Print "Drive A:            :  ";

if x\16=0 Then Print "Not Available"
if x\16=1 Then Print "5.25"chr$(34)" 360 KB"
if x\16=2 Then Print "5.25"chr$(34)" 1.2 MB"
if x\16=3 Then Print "3.5"chr$(34)"  720 KB"
if x\16=4 Then Print "3.5"chr$(34)" 1.44 MB"
if x\16=5 Then Print "3.5"chr$(34)" 2.88 KB"

Print "Drive B:            :  ";

if (x And &H0F)=0 Then Print "Not Available"
if (x And &H0F)=1 Then Print "5.25"chr$(34)" 360 KB"
if (x And &H0F)=2 Then Print "5.25"chr$(34)" 1.2 MB"
if (x And &H0F)=3 Then Print "3.5"chr$(34)"  720 KB"
if (x And &H0F)=4 Then Print "3.5"chr$(34)" 1.44 MB"
if (x And &H0F)=5 Then Print "3.5"chr$(34)" 2.88 KB"
Print String$(40,"-")

Def Seg=61440      ' &HF000
Print "Bios Date           :  " Peek$(65525,8)


REG 1,&HB101
REG 6,0
Call Interrupt &H1A
IF REG(1)\256 = 0 then
	Print "PCI Bus Version     : "REG(2)\256+(REG(2) mod 256)/100
	Print "Last PCI Bus        : "REG(3)
End IF

end
