home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mskermit / msulkv.asm < prev    next >
Assembly Source File  |  2020-01-01  |  10KB  |  259 lines

  1.         Name MSULKV
  2. ; Enable use of VAXmate LK250 keyboard under Kermit. Code mostly stolen from
  3. ; MSLK250.ASM - A simple driver program for the DEC LK250 keyboard on IBM AT's
  4. ; Original Author:  Terry Kennedy, St. Peter's College, Terry@spcvxa.Bitnet.
  5. ; This version: Trevor Warwick, Digital Equipment Co, Reading, England.
  6. ;                               warwick@marvin.enet.dec.com
  7. ; Edit history
  8. ; Last edit 5 Apr 1991
  9. ;  5 Apr 1991 1.0-01 Modify for VAXmate from LK250.ASM
  10. ; 16 Apr 1991 1.0-02 Add check for VAXmate system using MS-DOS OEM number
  11. ; 19 Apr 1991 1.0-03 Modify VAXmate check to look for key bytes in system
  12. ;                    ROM
  13. ;
  14. ; Purpose: Allow access to full set of LK250 keys from Kermit. A set of
  15. ;          key definitions is required, which are appended to the end of
  16. ;          the source below:
  17. ;
  18. ; Method:  Intercept INT 15 subfunction 50 (Control). If entered via
  19. ;          50, perform control function as follows:
  20. ;
  21. ;               AL=00 - Disable substitution (keyboard "Special" [IBM] mode)
  22. ;               AL=01 - Enable sunstitution (keyboard DEC mode)
  23. ;               AL=02 - Send the byte in BL to the keyboard (caution: sending
  24. ;                       "random" bytes with this function can lock the key-
  25. ;                       board, necessitating a reboot.
  26. ;
  27. ;
  28. ; After this program has been used by KERMIT, the keyboard will be reset to
  29. ; IBM mode, with any previously selected special modes turned off.
  30. ;
  31. ; The code checks that is running on a VAXmate system. If for some reason
  32. ; this check needs to be bypassed, uncomment the line flagged **HERE** below.
  33. ;
  34. ;
  35. ; Construct final file MSULKV.COM by
  36. ;  masm msulkv;
  37. ;  link msulkv;        expect and ignore statement about no stack segment
  38. ;  exe2bin msulkv
  39. ;  ren msulkv.bin msulkv.com    rename the result to our runnable filename
  40. ;  del msulkv.exe      delete non-runnable intermediate files .exe & .obj
  41. ;  del msulkv.obj
  42. ;
  43. ;  msulkv               run msulkv.com to install the driver
  44. ;
  45. ;
  46. ;
  47. main    group   code
  48. ;
  49. ;
  50. ;
  51. code    segment public para 'code'
  52. assume  cs:main,ds:nothing
  53. ;
  54.         org     100h                    ; making a.COM file
  55. ;
  56. begin:  jmp     start                   ; program starts here
  57. ;
  58. saved15 dd      ?                       ; previous int 15 vector
  59. active  db      0                       ; are we translating?
  60. ;
  61. ; This is the new interrupt 15 routine.
  62. ;
  63. newi15  proc    far
  64.  
  65.         cmp     ah,50h                  ; control function?
  66.         je      ctlfnc                  ; if so...
  67. ;
  68. bail:   jmp     [saved15]
  69. ;
  70. ; control functions: enable / disable translation, set LED's, set click
  71. ; volume, set auto-repeat rate
  72. ;
  73. ctlfnc: cmp     al,0                    ; disable translation?
  74.         jne     tst1                    ; no
  75.         mov     active,al               ; else do it
  76.         mov     al,00000000b            ; clear all bits
  77.         mov     ah,0d3h                 ; KB extensions
  78.         int     16h
  79. ;
  80. ; For some reason, the Num Lock LED gets left on, so now manually turn it off
  81. ;
  82.         mov     al,0edh                 ; set LEDs function
  83.         mov     ah,0d5h                 ; send KB command
  84.         int     16h
  85.         mov     al,0                    ; LEDs value (all off)
  86.         mov     ah,0d5h                 ; send KB command
  87.         int     16h
  88.         jmp     exit                    ; and exit
  89. ;
  90. tst1:   cmp     al,1                    ; enable translation?
  91.         jne     tst2                    ; no
  92.         mov     active,al               ; else do it
  93.         mov     al,00010001b            ; Digital extended, Disable state keys
  94.         mov     ah,0d3h                 ; KB extensions
  95.         int     16h
  96.         jmp     exit                    ; and exit
  97. ;
  98. tst2:   cmp     al,2                    ; send to keyboard?
  99.         jne     error                   ; nope, must be an error
  100.         mov     al,bl                   ; byte to [AL] for send
  101.         mov     ah,0d5h                 ; send to KB
  102.         int     16h
  103.         jmp     exit                    ; and exit
  104. ;
  105. error:  mov     ax,0                    ; say bad function
  106.         iret                            ; and exit
  107. ;
  108. exit:   mov     ax,1234h                ; say we did it
  109.         iret                            ; and exit
  110. ;
  111. newi15  endp
  112. ;
  113. endres  label   byte                    ; end of resident code
  114. ;
  115. ; Code after here will not remain resident
  116. ;  Cpu test uses DOS's stack [jrd]
  117. start:                                  ; begin with cpu test [jrd]
  118.         push    sp                      ; push DOS's SP, 8088's push old SP-2
  119.         pop     ax                      ; 286's and higher push old SP
  120.         mov     dx,offset main:cpumsg   ; prepare bad news message
  121.         cmp     ax,sp                   ; pre versus post push SP's
  122.         jne     start0                  ; ne = an 8088, sorry 'bout that [jrd]
  123.         mov     ax,5000h                ; see if we are already loaded
  124.         int     15h                     ; look for DOS->DEC mode driver
  125.         cmp     ax,1234h                ; find marker 1234h
  126.         jne     start1                  ; ne = marker not present, no driver
  127.         mov     dx,offset main:errmsg   ; say we're already loaded
  128. start0: mov     ah,9
  129.         int     21h
  130.         int     20h                     ; and bail out
  131. ;
  132. ; Check for a VAXmate
  133. ;
  134. ; Uncomment the jump to start2 to avoid VAXmate ROM code check
  135. ;
  136. start1:
  137. ;        jmp     start2                 ; un-comment **HERE** to run on anything
  138.         push    ds                      ; save current ds
  139.         mov     ax, 0ffffh
  140.         mov     ds, ax                  ; load ds with FFFF
  141.         mov     al, ds:000dh            ; get byte at FFFF:000D
  142.         cmp     al, 0d2h                ;  if it's D2
  143.         je      posvmt                  ;   this might be a VAXmate
  144.         cmp     al, 0d3h                ;  if it's not D3
  145.         jne     notvmt                  ;   this isn't a VAXmate
  146. posvmt:
  147.         mov     al, ds:000eh            ; get byte at FFFF:000E
  148.         cmp     al, 0fch                ;  if it's FC
  149.         je      isvmt                   ;   this is a VAXmate
  150. notvmt:
  151.         pop     ds
  152.         mov     dx,offset main:vaxmsg   ; say this isn't a VAXmate
  153.         jmp     start0
  154. isvmt:
  155.         pop     ds
  156. ;
  157. ; End of check for a VAXmate
  158. ;
  159. start2: mov     ax,3515h                ; get existing INT 15 vector
  160.         int     21h
  161.         mov     word ptr [saved15],bx   ; save it
  162.         mov     word ptr [saved15+2],es
  163.         mov     dx,offset main:newi15   ; set new INT 15 vector
  164.         mov     ax,2515h
  165.         int     21h                     ; set new vector from DS:DX
  166. ;
  167.         mov     dx,offset main:lodmsg   ; say we're loaded
  168.         mov     ah,9
  169.         int     21h
  170. ;
  171.         mov     ax,ds:[2ch]             ; de-allocate the environment
  172.         mov     es,ax                   ; load envirnoment segment into es
  173.         mov     ah,49h                  ; DOS function number
  174.         int     21h                     ; free the environment memory
  175. ;
  176.         mov     dx,offset main:endres   ; point to end of resident code
  177.         add     dx,0fh                  ; round up
  178.         mov     cl,4
  179.         shr     dx,cl                   ; convert to paragraphs (divide by 16)
  180.         mov     ax,3100h                ; DOS function 31h, error code=0
  181.         int     21h                     ; terminate and remain resident
  182. ;
  183. errmsg: db      0dh,0ah,'MSULKV is already loaded',0dh,0ah,07h,'$'
  184. lodmsg: db      0dh,0ah,'MSULKV V1.0-03 loaded',0dh,0ah,'$'
  185. vaxmsg: db      0dh,0ah,'MSULKV requires a VAXmate system',0dh,0ah,'$'
  186. cpumsg: db      0dh,0ah,'MSULKV requires a 286 (AT) machine or higher'
  187.         db      0dh,0ah,'$'             ; wrong cpu type msg  [jrd]
  188. ;
  189. code    ends
  190.         end     begin                   ; start execution at BEGIN
  191. COMMENT |
  192. ;
  193. ;
  194. ; The following key definitions are required, which should be put in the
  195. ; user's MSKERMIT.INI file. During terminal emulation, all keys should then
  196. ; work like on an LK201, with the exception of the "Enter" key, which issues
  197. ; the same code as "Return". Alt-Enter is used as the key combination to
  198. ; simulate the LK201 "Enter" key.
  199. ;
  200. set key \x1b    \KPF1       ; PF1 Esc
  201. set key \325    \KPF2       ; PF2 Num Lock
  202. set key \326    \KPF3       ; PF3 Scrl Lock
  203. set key \311    \KPF4       ; PF4 Prt Sc
  204.  
  205. SET KEY \339    \Kkpdot    ;    KP .    Delete
  206. SET KEY \338    \Kkp0      ;    KP 0    Install
  207. SET KEY \335    \Kkp1      ;    KP 1    End
  208. SET KEY \336    \Kkp2      ;    KP 2    Down Arrow
  209. SET KEY \337    \Kkp3      ;    KP 3    Page Down
  210. SET KEY \331    \Kkp4      ;    KP 4    Left Arrow
  211. SET KEY \332    \Kkp5      ;    KP 5    unused
  212. SET KEY \333    \Kkp6      ;    KP 6    Right Arrow
  213. SET KEY \327    \Kkp7      ;    KP 7    Home
  214. SET KEY \328    \Kkp8      ;    KP 8    Up Arrow
  215. SET KEY \329    \Kkp9      ;    KP 9    Page up
  216. SET KEY \330    \Kkpminus  ;    KP -    -
  217. SET KEY \334    \Kkpcoma   ;    KP ,    +
  218. SET KEY \2494   \Kkpenter  ;    Alt-Enter  (Enter just does Return it seems)
  219.  
  220. SET KEY \389    \kdecfind   ;     Find or Home
  221. SET KEY \390    \kdecinsert ;     Insert Here
  222. SET KEY \391    \kdecremove ;     Remove
  223. SET KEY \392    \kdecselect ;     Select or End
  224. SET KEY \393    \kdecprev   ;     Previous Screen
  225. SET KEY \394    \kdecnext   ;     Next Screen
  226. SET KEY \395    \Kuparr    ;     Up Arrow
  227. SET KEY \396    \Klfarr    ;     Left Arrow
  228. SET KEY \397    \Krtarr    ;     Right Arrow
  229. SET KEY \398    \Kdnarr    ;     Down Arrow
  230.  
  231. SET KEY \315    \Kholdscrn ;     F1  Toggle Hold Screen
  232. SET KEY \316    \Kprtscn   ;     F2  Print Screen;
  233. SET KEY \317    \Ktermtype ;     F3  Toggle Toggle Terminal Type
  234. SET KEY \318    \Klogoff   ;     F4  Turn Session Logging Off
  235. SET KEY \319    \Kbreak    ;     F5  Break
  236.  
  237. set key \x140 \kdecf6
  238. set key \x141 \kdecf7
  239. set key \x142 \kdecf8
  240. set key \x143 \kdecf9
  241. set key \x144 \kdecf10
  242. set key \399 \kdecf11
  243. set key \400 \kdecf12
  244. set key \401 \kdecf13
  245. set key \402 \kdecf14
  246. set key \403 \kdechelp
  247. set key \404 \kdecdo
  248. set key \405 \kdecf17
  249. set key \406 \kdecf18
  250. set key \407 \kdecf19
  251. set key \408 \kdecf20
  252.  
  253. comment shift-return
  254. set key \796 \13
  255. comment shift-delete
  256. set key \782 \127
  257. |
  258. ; End of File MSULKV.ASM
  259.