home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / CT / CT9401 / SMRTCAPS / SMRTCAPS.ASM next >
Assembly Source File  |  1993-12-26  |  3KB  |  92 lines

  1.  
  2.         TITLE    SMRTCAPS.ASM
  3.  
  4. ;If Capslock is pressed together with another key take this as Shifted version
  5. ; of key, don't set Capslock active
  6. ;Transformation into assembler of Pascal program by Aart Spek as published
  7. ; in C!T januari 1994 on page 136
  8.  
  9. ;MASM 6.0 used, takes 176 + 16 bytes (for MCB) memory when loaded as TSR
  10.  
  11. ; E.P. van Westendorp  Reigerslaan 22  2215 NN  Voorhout  Tel. 02522 10579
  12.  
  13. _TEXT        SEGMENT
  14.         ASSUME  DS:_TEXT,ES:_TEXT,SS:_TEXT
  15.         .RADIX    16
  16.         ORG    0100H
  17.  
  18. ;Minimum of PSP that has to stay unchanged is 6 paragraph's, 96 bytes
  19. ;(See MS-DOS Encyclopedia page 1279 and MS-DOS Programmers Reference page 263)
  20. ;Move INT 09 handler code to offset 0060 in PSP, this is behind reserved part
  21. START:        MOV    SI,OFFSET HANDLER_09    ;Move handler code
  22.         MOV    DI,STORE_OFS        ;       to position in PSP
  23.         MOV    CX,HANDLER_LEN        ;Length of handler code
  24.         REP    MOVSB
  25.  
  26. ;Save old INT 09 vector at end of handler in PSP, set INT 09 vector to handler
  27. ;Release environment, stay resident
  28.         MOV    AX,3509            ;Get interrupt vector INT 09
  29.         INT    21
  30.         MOV    [DI],BX            ;Save in variables
  31.         MOV    [DI+02],ES        ;        at end handler in PSP
  32.         
  33.         MOV    BYTE PTR[DI+04],00    ;Clear byte to be used as flag
  34.         
  35.         MOV    AX,2509            ;Set INT 09 to new handler
  36.         MOV    DX,STORE_OFS        ;Offset handler
  37.         INT    21
  38.         
  39.         MOV    AH,49            ;Free allocated memory
  40.         MOV    ES,DS:[002C]        ;Segment environment
  41.         INT    21
  42.         
  43.         MOV    DX,PARS_RES        ;Paragraphs to stay resident
  44.         MOV    AX,3100            ;Keep program
  45.         INT    21
  46.  
  47. ;New INT 09 handler, is moved into free space in PSP upon install
  48. ;First save registers, get bios data segment into DS
  49. HANDLER_09:    PUSHF                ;Save registers
  50.         PUSH    AX
  51.         PUSH    DS
  52.         MOV    AX,0040            ;Bios data segment
  53.         MOV    DS,AX            ;In DS
  54.  
  55. ;If press of a key occurred before together with Capslock press and the
  56. ; Capslock key is now released then deactivate Capslock and clear CAPSKEY_FLAG
  57.         OR    CS:BYTE PTR[CAPSKEY_FLAG],00;Caps-key flag clear?
  58.         JZ    CHK_CAPSKEY        ;Yes, go check keypress
  59.         TEST    DS:BYTE PTR[0018],01000000Y;No, is Capslock released?
  60.         JNZ    CHK_CAPSKEY        ;No, go check keypress
  61.  
  62. ;CAPSKEY_FLAG set but Capslock now released, deactivate Capslock, clear flag
  63.         AND    DS:BYTE PTR[0017],10111111Y;Yes, deactivate capslock
  64.         MOV    CS:BYTE PTR[CAPSKEY_FLAG],00;Clear CAPSKEY_FLAG
  65.         JMP    CONT_OLDINT09        ;Continue old INT 09 ISR
  66.  
  67. ;Check for Capslock being pressed together with another key
  68. CHK_CAPSKEY:    TEST    DS:BYTE PTR[0018],01000000Y;Capslock being pressed?
  69.         JZ    CONT_OLDINT09        ;No, handle normal
  70.         IN    AL,60            ;Get scancode
  71.         CMP    AL,80            ;128 or higher?
  72.         JNC    CONT_OLDINT09        ;Yes, special or release code
  73.         CMP    AL,3A            ;Scan code for Capslock?
  74.         JZ    CONT_OLDINT09        ;Yes, handle normally
  75.  
  76. ;Capslock is pressed together with another key, set CAPSKEY_FLAG
  77.         MOV    CS:BYTE PTR[CAPSKEY_FLAG],0FF;Set flag
  78.  
  79. ;Restore registers and continue original INT 09 ISR
  80. CONT_OLDINT09:    POP    DS            ;Restore registers
  81.         POP    AX
  82.         POPF
  83.         DB    0EA            ;Direct FAR JMP
  84.         
  85. HANDLER_LEN    EQU    $-OFFSET HANDLER_09    ;Length handler above in bytes
  86. STORE_OFS    EQU    0060            ;Offset 0060 in PSP
  87. CAPSKEY_FLAG    EQU    STORE_OFS+HANDLER_LEN+04;Offset Caps-key flag byte
  88. PARS_RES    EQU    (CAPSKEY_FLAG+01+0F) SHR 04;Paragraph's resident
  89.  
  90. _TEXT        ENDS
  91.         END    START
  92.