'===========================================================================
' Subject: BIOS MEMORY USAGE SUMMARY          Date: 10-20-97 (10:34)       
'  Author: William A. Deer                    Code: QB, QBasic, PDS        
'  Origin: ag312350@student.uq.edu.au       Packet: DOS.ABC
'===========================================================================
DECLARE SUB ConvDec2Bin (Dec!, Bit1%, Bit2%, Bit3%, Bit4%, Bit5%, Bit6%, Bit7%, Bit8%)
'                                                       7th May, 1997
'                                                       BIOSCALL.BAS
'
'       This file is a simple collection of usefull rountines, mainly
'   obtained from The Programmers PC SourceBook, by Thom Hogan. These
'   were originally for my own use, but I never found a real use for them
'       If anyone does find a cure for the left alt and ctrl button stuffup,
'       then please let me know.
'
'       You might find them usefull, so enjoy.
'
'       William c/o ag312350@student.uq.oz.au
'
'
' BIOS Memory Usage Summary
'
CLS
' Get the Base Addresses of each Com Port 1-4
DEF FnCom1Address$ : DEF SEG = &H40: FnCom1Address$ = HEX$(PEEK(&H1)) + (HEX$(PEEK(&H0))): END DEF
DEF FnCom2Address$ : DEF SEG = &H40: FnCom2Address$ = HEX$(PEEK(&H2)) + (HEX$(PEEK(&H3))): END DEF
DEF FnCom3Address$ : DEF SEG = &H40: FnCom3Address$ = HEX$(PEEK(&H4)) + (HEX$(PEEK(&H5))): END DEF
DEF FnCom4Address$ : DEF SEG = &H40: FnCom4Address$ = HEX$(PEEK(&H6)) + (HEX$(PEEK(&H7))): END DEF

' Get the Base Addresses of each LPTn Port 1-4
DEF FnLPT1Address$ : DEF SEG = &H40: FnLPT1Address$ = HEX$(PEEK(&H8)) + (HEX$(PEEK(&H9))): END DEF
DEF FnLPT2Address$ : DEF SEG = &H40: FnLPT2Address$ = HEX$(PEEK(&HA)) + (HEX$(PEEK(&HB))): END DEF
DEF FnLPT3Address$ : DEF SEG = &H40: FnLPT3Address$ = HEX$(PEEK(&HC)) + (HEX$(PEEK(&HD))): END DEF
DEF FnLPT4Address$ : DEF SEG = &H40: FnLPT4Address$ = HEX$(PEEK(&HE)) + (HEX$(PEEK(&HF))): END DEF
' Installed Hardware
DEF FnFloppyNo% : DEF SEG = &H40: FnFloppyNo% = 1 + (PEEK(&H10) AND &H1) + (PEEK(&H10) AND &H2): END DEF
' Keyboard Rountine
DEF FnCapsLockStatus% : DEF SEG = &H40: FnCapsLockStatus% = ((PEEK(&H17) AND &H40) / &H40): END DEF
DEF FnNumbLockStatus% : DEF SEG = &H40: FnNumbLockStatus% = ((PEEK(&H17) AND &H20) / &H20): END DEF
DEF FnScrlLockStatus% : DEF SEG = &H40: FnScrlLockStatus% = ((PEEK(&H17) AND &H10) / &H10): END DEF

DEF FnInsertMode% : DEF SEG = &H40: FnInsertMode% = ((PEEK(&H17) AND &H80) / &H80): END DEF
DEF FnR.AltKeyStatus% : DEF SEG = &H40: FnR.AltKeyStatus% = ((PEEK(&H17) AND &H8) / &H8): END DEF
DEF FnRCtrlKeyStatus% : DEF SEG = &H40: FnRCtrlKeyStatus% = ((PEEK(&H17) AND &H4) / &H4): END DEF
DEF FnRShftKeyStatus% : DEF SEG = &H40: FnRShftKeyStatus% = ((PEEK(&H17) AND &H1) / &H1): END DEF
DEF FnLShftKeyStatus% : DEF SEG = &H40: FnLShftKeyStatus% = ((PEEK(&H17) AND &H2) / &H2): END DEF
DEF FnL.AltKeyStatus% : DEF SEG = &H40: FnL.AltKeyStatus% = ((PEEK(&H18) AND &H2) / &H2): END DEF
DEF FnLCtrlKeyStatus% : DEF SEG = &H40: FnLCtrlKeyStatus% = ((PEEK(&H18) AND &H1) / &H1): END DEF

DEF FnPrnAdaptors% :    DEF SEG = &H40: FnPrnAdaptors% = ((PEEK(&H11) AND &H80) / &H40) + ((PEEK(&H11) AND &H40) / &H40): END DEF
DEF FnInternalModem% :  DEF SEG = &H40: FnInternalModem% = ((PEEK(&H11) AND &H20) / &H20): END DEF
DEF FnComPorts% :       DEF SEG = &H40: FnComPorts% = ((PEEK(&H11) AND &H8) / &H2) + ((PEEK(&H11) AND &H4) / &H2) + ((PEEK(&H11) AND &H2) / &H2): END DEF

DEF FnTotalMemory$ :    DEF SEG = &H40: FnTotalMemory$ = HEX$(PEEK(&H14)) + (HEX$(PEEK(&H13))): END DEF







PRINT "Com 1 Address = &H"; FnCom1Address$
PRINT "Com 2 Address = &H"; FnCom2Address$
PRINT "Com 3 Address = &H"; FnCom3Address$
PRINT "Com 4 Address = &H"; FnCom4Address$
PRINT "LPT:1 Address = &H"; FnLPT1Address$
PRINT "LPT:2 Address = &H"; FnLPT2Address$
PRINT "LPT:3 Address = &H"; FnLPT3Address$
PRINT "LPT:4 Address = &H"; FnLPT4Address$

PRINT "Number of Floppy Drives is "; FnFloppyNo%
PRINT "Number of Printer Adapters ="; FnPrnAdaptors%
PRINT "Internal modem ? = "; FnInternalModem%
PRINT "Com Ports = "; FnComPorts%
PRINT "Memory Size = "; FnTotalMemory$; "Kb, or "; VAL("&H" + FnTotalMemory$); "Kbytes"

starty = 15
WHILE INKEY$ <> "1"
 LOCATE starty + 0, 1: PRINT "Caps Lock Status 0=off, 1 = on "; FnCapsLockStatus%
 LOCATE starty + 1, 1: PRINT "Numb Lock Status 0=off, 1 = on "; FnNumbLockStatus%
 LOCATE starty + 2, 1: PRINT "Scrl Lock Status 0=off, 1 = on "; FnScrlLockStatus%
 LOCATE starty + 3, 1: PRINT "Insert Mode Active ? "; FnInsertMode%
 LOCATE starty + 4, 1: PRINT "Alt Keys  :Left"; FnL.AltKeyStatus%; " Right"; FnR.AltKeyStatus%
 LOCATE starty + 5, 1: PRINT "Crtl Keys :Left"; FnLCtrlKeyStatus%; " Right"; FnRCtrlKeyStatus%
 LOCATE starty + 6, 1: PRINT "Shft Keys :Left"; FnLShftKeyStatus%; " Right"; FnRShftKeyStatus%
 LOCATE starty + 8, 1: PRINT "Hit '1' to exit";
WEND

END

SUB ConvDec2Bin (Dec, Bit1%, Bit2%, Bit3%, Bit4%, Bit5%, Bit6%, Bit7%, Bit8%)

DIM value AS INTEGER
value = ABS(INT(Dec))

Bit8% = (Dec AND &H1) / &H1
Bit7% = (Dec AND &H2) / &H2
Bit6% = (Dec AND &H4) / &H4
Bit5% = (Dec AND &H8) / &H8
Bit4% = (Dec AND &H10) / &H10
Bit3% = (Dec AND &H20) / &H20
Bit2% = (Dec AND &H40) / &H40
Bit1% = (Dec AND &H80) / &H80
'
' This subrountine will convert the last 8 bits of an integer into
' its bits, stored as follows
'
'  Dec  MSB     .       .       .       .       .       .       LSB
'
'   1   0       0       0       0       0       0       0       1
'   2   0       0       0       0       0       0       1       0
'  255  1       1       1       1       1       1       1       1

' The Bit Values must be Integer values, but the Decimal value can be
' nearly anything.

END SUB
