home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
C!T
/
C!T01_94
/
SMRTCAPS
/
SMRTCAPS.ASM
next >
Wrap
Assembly Source File
|
1993-12-26
|
3KB
|
92 lines
TITLE SMRTCAPS.ASM
;If Capslock is pressed together with another key take this as Shifted version
; of key, don't set Capslock active
;Transformation into assembler of Pascal program by Aart Spek as published
; in C!T januari 1994 on page 136
;MASM 6.0 used, takes 176 + 16 bytes (for MCB) memory when loaded as TSR
; E.P. van Westendorp Reigerslaan 22 2215 NN Voorhout Tel. 02522 10579
_TEXT SEGMENT
ASSUME DS:_TEXT,ES:_TEXT,SS:_TEXT
.RADIX 16
ORG 0100H
;Minimum of PSP that has to stay unchanged is 6 paragraph's, 96 bytes
;(See MS-DOS Encyclopedia page 1279 and MS-DOS Programmers Reference page 263)
;Move INT 09 handler code to offset 0060 in PSP, this is behind reserved part
START: MOV SI,OFFSET HANDLER_09 ;Move handler code
MOV DI,STORE_OFS ; to position in PSP
MOV CX,HANDLER_LEN ;Length of handler code
REP MOVSB
;Save old INT 09 vector at end of handler in PSP, set INT 09 vector to handler
;Release environment, stay resident
MOV AX,3509 ;Get interrupt vector INT 09
INT 21
MOV [DI],BX ;Save in variables
MOV [DI+02],ES ; at end handler in PSP
MOV BYTE PTR[DI+04],00 ;Clear byte to be used as flag
MOV AX,2509 ;Set INT 09 to new handler
MOV DX,STORE_OFS ;Offset handler
INT 21
MOV AH,49 ;Free allocated memory
MOV ES,DS:[002C] ;Segment environment
INT 21
MOV DX,PARS_RES ;Paragraphs to stay resident
MOV AX,3100 ;Keep program
INT 21
;New INT 09 handler, is moved into free space in PSP upon install
;First save registers, get bios data segment into DS
HANDLER_09: PUSHF ;Save registers
PUSH AX
PUSH DS
MOV AX,0040 ;Bios data segment
MOV DS,AX ;In DS
;If press of a key occurred before together with Capslock press and the
; Capslock key is now released then deactivate Capslock and clear CAPSKEY_FLAG
OR CS:BYTE PTR[CAPSKEY_FLAG],00;Caps-key flag clear?
JZ CHK_CAPSKEY ;Yes, go check keypress
TEST DS:BYTE PTR[0018],01000000Y;No, is Capslock released?
JNZ CHK_CAPSKEY ;No, go check keypress
;CAPSKEY_FLAG set but Capslock now released, deactivate Capslock, clear flag
AND DS:BYTE PTR[0017],10111111Y;Yes, deactivate capslock
MOV CS:BYTE PTR[CAPSKEY_FLAG],00;Clear CAPSKEY_FLAG
JMP CONT_OLDINT09 ;Continue old INT 09 ISR
;Check for Capslock being pressed together with another key
CHK_CAPSKEY: TEST DS:BYTE PTR[0018],01000000Y;Capslock being pressed?
JZ CONT_OLDINT09 ;No, handle normal
IN AL,60 ;Get scancode
CMP AL,80 ;128 or higher?
JNC CONT_OLDINT09 ;Yes, special or release code
CMP AL,3A ;Scan code for Capslock?
JZ CONT_OLDINT09 ;Yes, handle normally
;Capslock is pressed together with another key, set CAPSKEY_FLAG
MOV CS:BYTE PTR[CAPSKEY_FLAG],0FF;Set flag
;Restore registers and continue original INT 09 ISR
CONT_OLDINT09: POP DS ;Restore registers
POP AX
POPF
DB 0EA ;Direct FAR JMP
HANDLER_LEN EQU $-OFFSET HANDLER_09 ;Length handler above in bytes
STORE_OFS EQU 0060 ;Offset 0060 in PSP
CAPSKEY_FLAG EQU STORE_OFS+HANDLER_LEN+04;Offset Caps-key flag byte
PARS_RES EQU (CAPSKEY_FLAG+01+0F) SHR 04;Paragraph's resident
_TEXT ENDS
END START