[comp.sys.ibm.pc] CCAP: change capslock into ctrl on AT keyboards

sperling@acf8.UUCP (George Sperling) (02/26/88)

The following is a small TSR, which changes the capslock key on AT
style keyboards into another CTRL key. I know that another CapsCtrl
program was posted recently. It used the INT 15 keyboard hook, which
is supplied by the IBM BIOS keyboard handler. Some clone BIOSes don't
have that hook, and the previously posted program doesn't work on these
machines. This program works even if the keyboard hook is not
provided. If you have an IBM AT, or a clone with a truely compatible
BIOS, I recommend the previously posted program.
Note that this program doesn't update the Leds. This is not necessary,
because the BIOS updates Leds all the time in INT 09 and INT 16.

To get the program running,
	MASM ccap;
	LINK ccap;
	EXE2BIN ccap.exe ccap.com
	DEL ccap.exe
Put ccap.com in your autoexec.bat file, *before* any other TSR's.


Karl Gegenfurtner

arpa:	karl@hipl.psych.nyu.edu
uucp:	...{seismo|ihnp4|allegra}!cmcl2!xp!hipl!karl
usps:	Department of Psychology, NYU
	6 Washington Place, 8th fl.
	New York, NY 10003

--------- CUT HERE ---------
cseg segment
	assume cs: cseg, ds: cseg, es: nothing
	org 100h

program proc far

	jmp install

program endp

old_kb_int	dd		?

;**************************************
;  Replacement code for BIOS INT 09H
;**************************************

kb_int proc far
	push ax
	in al, 60H		; get scan code
	pushf
	cli
	call cs:[old_kb_int]
	cli			; don't let another int 09H screw us up

; check for capslock

	cmp al, 3AH
	jne tm2

; capslock was pressed

	push es
	push bx
	mov bx, 0
	mov es, bx

	
; undo BIOS action: capslock inactive, ctrl depressed

	or byte ptr es:[417H], 00000100B	; ctrl active
	and byte ptr es:[417H], 10111111B	; capslock inactive

; Peter Norton says we shouldn't touch this. It seems to work
; without, so I don't bother.

;	and byte ptr es:[418H], 10111111B	; capslock not pressed

	jmp tm4

tm2:

; check if it's caplock release

	cmp al, 3AH + 80H
	jne tm5

; capslock was released

	push es
	push bx
	xor bx, bx
	mov es, bx

; inactivate control

	and byte ptr es:[417H], 11111011B		; ctrl inactive

tm4:

; done with that stuff

	pop bx
	pop es

tm5:

	pop ax
	sti
	iret

kb_int endp

lastbyte label byte

onmessage	db		"ccap installed kg 02/16/88", 13, 10, "$"

;**************************************
;         installation routine
;**************************************

install proc near

; get keyboard int vector

	mov ax, 3509h
	int 21h

	mov word ptr old_kb_int, bx
	mov word ptr old_kb_int[2], es
	mov dx, offset kb_int
	mov ax, 2509h; set vector
	int 21h

	mov dx, offset onmessage
	mov ah, 09h
	int 21h

; terminate and stay resident

	mov dx, offset lastbyte
	int 27h

install endp

cseg ends
	end program