'===========================================================================
' Subject: KEYBOARD LIGHT CONTROL             Date: 06-12-96 (08:05)       
'  Author: Jason Laviska                      Code: QB, QBasic, PDS        
'  Origin: jason.laviska@outdoor.com        Packet: KEYBOARD.ABC
'===========================================================================
'Controlling the keyboard light indicators by Jason Laviska.
'LaserArts' Library Function K-02-B
'--- Public Domain --- Use at your own risk ---

'     This is a very short subprogram I made that will enable/disable
'the Num, Caps, and Scroll lock indicators on your keyboard.  All you
'have to do is to call the Keylite subprogram with a integer from 0 to
'7 and your keyboard lights will automatically adjust.  If you enter
'any other number using this subprogram, it will not do anything.  I
'have found that Keylite works successfully if the user presses a key,
'if Basic askes for a key (such as using Inkey$), or any other way you
'can think of to talk to the 8042-based keyboard controller chip.
'This has been successfully tested using a 101-key enhanced keyboard.
'This will not work on the original 83-key PC/XT keyboards that are
'not bidirectional.

CLS
PRINT "Press any key to begin keyboard demostration. :)"
SLEEP
CLS
FOR Temp% = 0 TO 7
  Keylite Temp%
  Temp$ = INKEY$
  PRINT "Mode"; Temp%, "Press any key."
  SOUND 1000, .3
  SLEEP (5)
NEXT Temp%

SUB Keylite (KeyMode%)

'KeyMode% ... Valid values must be in the range of 0 to 7.

'Cap   Num   Scr = KeyMode%
'---   ---   ---   --------
' 0     0     0       0
' 0     0     1       1
' 0     1     0       2
' 0     1     1       3
' 1     0     0       4
' 1     0     1       5
' 1     1     0       6
' 1     1     1       7

' 0 = Inactive
' 1 = Active

IF KeyMode% > -1 AND KeyMode% < 8 THEN
  DEF SEG = 0
  POKE &H417, (KeyMode% * 16) + 128
  DEF SEG
END IF

END SUB
