[comp.sys.ibm.pc] Setting/resetting caps/num/scroll lock

sword@vu-vlsi.UUCP (Ronin) (05/22/87)

In article <3267@islenet.UUCP>, jons@islenet.UUCP (Jonathan Spangler) writes:
> In article <1845@vax3.COM> limey@tc.fluke.COM (Paul Baldock) writes:
> >I would like to write a program that will reset the LOCK INDICATORS on my
> >BTC (IBM Clone) Enhanced Keyboard.
> >
>>Does anybody know if this is possible, and if so how it should be done (memory
> >locations to write to etc)
> >
> >Thanks,
> >
> >Paul Baldock
> 
 
Okay.  It really isn't too hard to do.  

  There are two bytes in memory at 0000:0417 (1047 in dec.) and
0000:0418 (1048 in dec.) which are used to determine the states
of the several keys, including Ctrl, Alt, left & right shifts,
NumLock, ScrollLock and CapsLock.
 
  The layout is like this:


                0000:0417 
 

 bit   7   6   5   4   3   2   1   0        
       ^   ^   ^   ^   ^   ^   ^   ^
       |   |   |   |   |   |   |   |
      Ins  |  Num  |  Alt  | Left  |
           |  Lock | Shift | Shift |
         Caps      |       |       |
         Lock   Scroll   Ctrl    Right
                Lock     Shift   Shift


  When any of the bits in the respective position is "on" (=1) then
that key is considered active.  (e.g. if the byte at 0000:0417 has
a value of 128 (80h) then the [Ins] key is active, but CapsLock, 
ScrollLock, etc are not active).
 
  If you just want to do a general reset of all the keys, the send
a "0" to this location.  Here are several examples in different
langauges:

IBM Basic              |   Turbo Pascal
                       |
10  def seg = &h0      |   Program ResetKeys;
15  poke &h417,0       |
20  end                |   Begin                   
                       |     mem[$0000:$0417] := 0;
                       |   End.
                       |
-----------------------+------------------------------

IBM Assembly

STACK     SEGEMENT PARA STACK 'STACK'
          DB       256 DUP (0)
STACK     ENDS
;
BIOS      SEGMENT  AT 0000H
          ORG      417H
KEYS      DB       ?
BIOS      ENDS
;
CODE      SEGMENT  PARA PUBLIC 'CODE'
ASSUME    CS:CODE
START     PROC     FAR
          PUSH     DS
          MOV      AX,0
          PUSH     AX
          MOV      AX,BIOS
          MOV      DS,AX
          ASSUME   DS:BIOS
          MOV      AL,0   			; set all lock keys off
          MOV      KEYS,AL
          RET
START     ENDP
CODE      ENDS
          END      START

--------------------------------------------------  

  While I'm not exactly sure of the coding for the assembly routine,
that's the basic idea.  All these programs will turn off everything
and leave it in the "boot-time" state. 

  Also if you wish to turn some on and some off, using the above
"bit-map", set up the "1"s in the proper bit positions for "on"
and the "0"s in the proper bit positions for "off".  The
determine the hex or dec value from the resulting binary number
and then "poke" it to 0000:0417.

  Hope this helps.   

..lar

-----
Larry Esmonde, Director of SWORD (Students Working on R&D)
UUCP: {cbmvax,psuvax1,bpa}!vu-vlsi!sword 
      {cbmvax,psuvax1,bpa}!vu-vlsi!excalibur!sword
BITNET: sword@vuvaxcom, larry@villvm