home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / GKBD.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  5.1 KB  |  249 lines

  1.         page    58,132
  2.  
  3. ; gkbd.asm
  4. ; contains: ggetkey()
  5. ;
  6. ;
  7.         ifndef    _LCODE
  8.          include    model.h
  9.         endif
  10.         include    prologue.h
  11.         name    kbd
  12.  
  13. ;;
  14. ;      Copyright (C)1984-1990 Greenleaf Software Inc. All Rights Reserved.
  15. ;
  16. ;;    MODIFICATIONS:
  17. ;
  18. ;;;
  19.  
  20. ;==>--    Translation tables for getkey()
  21. ;
  22.     dseg    kbd
  23.         ; 0, ALTESC, 0, CTRL2, then nulls up to 13 (decimal)
  24. trans    db    0,0fbh,0,0fch,0,0,0,0,0,0,0,0,0,0
  25.  
  26.     ;==>--    ALTBS,REVTAB Alt-Q, W, E, R, T, Y, U, I, O, P (14-25)
  27.  
  28.      db      0deh,08Fh,0D1h,0D7h,0C5h,0D2h,0D4h,0D9h,0D5h,0C9h,0CFh,0D0h
  29.  
  30.     ;==>--    ALTLFBRAK,ALTRTBRAK,ALTCR (26..28, and pad to 29
  31.  
  32.     db    0fdh,0feh,0c0h,0
  33.  
  34.     ;==>--    Alt-A, S, D, F, G, H, J, K, L,  (30-38)
  35.      db      0C1h,0D3h,0C4h,0C6h,0C7h,0C8h,0CAh,0CBh,0CCh
  36.  
  37.     ;==>--  ALTSEMI, 0, ALTACCE, 0 (39-40-41-42)
  38.  
  39.     db    0dfh,0,0f8h,0
  40.  
  41.     ;==>--    Alt-Z X C V B N M  (43-49) + pads to 58
  42.      db      0DAh,0D8h,0C3h,0D6h,0C2h,0CEh,0CDh,0,0,0,0,0,0,0,0,0
  43.  
  44.     ;==>--    unshifted F1..F10 (59-68) + pads to 70
  45.      db      080h,081h,082h,083h,084h,085h,086h,087h,088h,089h,0,0
  46.  
  47.  
  48.  
  49.     ;==>--    HOME, CURUP, PGUP, 0,CURLF,CENTERKEY,CURRT,ALTGREYPLUS
  50.     ;    71   72   73   74 75, 76   77   78  
  51.      db      08Ah,08Dh,09Ah,0,08Bh,0f9h,09Bh,0fah
  52.  
  53.     ;==>--    ENDKEY,CURDN,PGDN,INSERT,DELETE
  54.     ;    79   80   81   82   83
  55.     db    08Ch,08Eh,09Ch,09Dh,09Eh
  56.  
  57.     ;==>--    SF1..SF10 (84-93)
  58.      db      090h,091h,092h,093h,094h,095h,096h,097h,098h,099h
  59.  
  60.     ;==>--    CF1..CF10 (94-103)
  61.      db      0A0h,0A1h,0A2h,0A3h,0A4h,0A5h,0A6h,0A7h,0A8h,0A9h
  62.  
  63.     ;==>--    AF1..AF10 (104-113)
  64.      db      0E0h,0E1h,0E2h,0E3h,0E4h,0E5h,0E6h,0E7h,0E8h,0E9h
  65.  
  66.     ;==>--    CTRLPRTSC, CTRLCURLF, CTRLCURRT, CTRLEND, CTRLPGDN, CTRLHOME
  67.     ;    114   115  116  117  118  119
  68.      db      0AEh ,0ABh,0BBh,0ACh,0BCh,0AAh
  69.  
  70.     ;==>--    Alt 1,2,3,4,5,6,7,8,9,0
  71.     ;    120..129
  72.      db    0B1h,0B2h,0B3h,0B4h,0B5h,0B6h,0B7h,0B8h,0B9h,0B0h
  73.  
  74.     ;==>--    Alt--, Alt-=, CTRLPGUP
  75.     ;    130  131  132
  76.     db    0BDh,0BEh,0BAh
  77.  
  78.     ;==>--    F11,F12,SF11,SF12,CF11,CF12,AF11,AF12, nulls to 147
  79.     ;       133 .. 140, nulls to 147
  80.     db      0f0h,0f1h,0f2h,0f3h,0f4h,0f5h,0f6h,0f7h,0,0,0,0,0,0,0
  81.  
  82.     ;==>--  CTRLTAB,CTRLSLASH,CTRLASTER, ALTHOME,ALTCURUP,nulls to 158
  83.     ;    148  149  150  151  152, nulls for 153..158
  84.     db    0ech,0edh,0eeh,0efh,0bfh,0,0,0,0,0,0
  85.  
  86.     ;==>--    ALTENDKEY, ALTCURDN, ALTPGDN, ALTINSERT, ALTDELETE, ALTENTER
  87.     ;    159             164
  88.     db    09fh,0adh,0afh,0dbh,0dch,0ddh
  89.  
  90.     ;==>--    ALTTAB,ALTKEY45
  91.     ;    165  166
  92.     db    0eah,0ebh,0,0
  93.  
  94. kstfunc    db    1        ;keyboard status function #
  95. sstfunc    db    2        ;shift status function #
  96. kinfunc    db    0        ;input function #
  97.  
  98. trapptr    dw    offset trfunc
  99.  
  100.      endds
  101.  
  102.     pseg    getkey
  103.  
  104. bchkv    db    0ffh        ;keeps track of last breakchk() value
  105.                 ;SET.  When 0FFH it means vector has
  106.                 ;not yet been re-directed.  If
  107.                 ;it == 0 then don't abort, if == 1
  108.                 ;abort.
  109.  
  110. ;==>--    unsigned ggetkey(void)
  111. ;
  112. ;;    ARGUMENTS:
  113. ;     (none)
  114. ;
  115. ;;    DESCRIPTION:
  116. ;      Get keyboard code without echo.
  117. ;
  118. ;;    SIDE EFFECTS:
  119. ;      none
  120. ;
  121. ;;    RETURNS:
  122. ;      8-bit standard ASCII code (0x00-0x7f) or predefined extended code
  123. ;      per gibmkeys.h
  124. ;
  125. ;;    AUTHOR:
  126. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  127. ;
  128. ;;    MODIFICATIONS:
  129. ;
  130. ;      DK    14-Jan-1989  16:47:07
  131. ;        Added codes in conversion tables for IBM 101/102 Key, Extended
  132. ;        Function key set.
  133. ;
  134. ;;;
  135.     cproc    ggetkey
  136.     call    [trapptr]
  137.     mov    ah,kinfunc
  138.     int    16h        ;rom bios keyboard input
  139.     or    ax,ax        ;is it Ctrl-Break ?
  140.     jz    short gtkyex     ;if so return ax=0 for control break
  141. ;
  142. ; A few special cases for Enhanced Keyboard only.
  143. ;
  144.     cmp    ax,2800h
  145.     jz    adde0        ; these get 0e000h added to them
  146.     cmp    ax,2b00h
  147.     jz    adde0
  148.     cmp    ax,3300h
  149.     jz    adde0
  150.     cmp    ax,3400h
  151.     jz    adde0
  152.     cmp    ax,3500h
  153.     jz    adde0
  154.     cmp    ax,3700h
  155.     jz    adde0
  156.     cmp    ax,4a00h
  157.     jz    adde0
  158.     cmp    ax,9900h
  159.     jz    adde0
  160.     cmp    ax,9b00h
  161.     jz    adde0
  162.     cmp    ax,8d00h
  163.     jz    adde0
  164.     cmp    ax,8e00h
  165.     jz    adde0
  166.     cmp    ax,8f00h
  167.     jz    adde0
  168.     cmp    ax,9000h
  169.     jz    adde0
  170.     cmp    ax,9100h
  171.     jz    adde0
  172.     cmp    ax,9200h
  173.     jz    adde0
  174.     cmp    ax,9300h
  175.     jz    adde0
  176.     cmp    ax,9d00h
  177.     jz    adde0
  178.  
  179.     cmp    al,0e0h
  180.     jz    adde0        ; and these just get AH=0e0h
  181.  
  182.     or    al,al        ;is it extended ?
  183.     jz    xltkey        ;translate it if so
  184.     xor    ah,ah        ;else return character in AL, clear AH
  185.     jmp    short gtkyex
  186. xltkey:    mov    al,ah
  187.     lea    bx,trans
  188.     ifdef    AZTEC
  189.      xlat    [bx]
  190.     else
  191.      xlat
  192.     endif
  193.     xor    ah,ah
  194. ;    xchg    ah,al        ;return extended code in AH, AL==0
  195.     jmp    short gtkyex
  196.  
  197. ;
  198. ; Come here to add 0xe000 to codes in AL
  199. ;
  200. adde0:    xchg    ah,al
  201.     mov    ah,0e0h        ; return 0xe0xx
  202.  
  203. gtkyex: 
  204.     call    doschk
  205.     cproce
  206.  
  207. ;==>--    doschk    is a procedure used only by functions in this file
  208. ;    it makes a dos call to give dos an oppurtunity to terminate
  209. ;    the current program.
  210. ;
  211. doschk    proc    near
  212.     cmp    byte ptr cs:bchkv,0
  213.     je    doscex
  214.     push    ax
  215.     mov    ah,0bh        ;check keyboard status via DOS
  216.     int    21h        ;this gives dos an oppurtunity to exit
  217.     pop    ax
  218. doscex:    ret
  219. doschk    endp
  220.  
  221.  
  222. enkbck    proc    near
  223.     push    ds
  224.     mov    ax,40h
  225.     mov    ds,ax
  226.     mov    bx,96h
  227.     mov    bl,[bx]
  228.     pop    ds
  229.     xor    ax,ax        ;assume not installed
  230.     and    bl,10h
  231.     jz    enot
  232.     inc    ax
  233. enot:    ret
  234. enkbck    endp
  235.  
  236. trfunc    proc    near
  237.     mov    trapptr,offset trfret
  238.     call    enkbck
  239.     or    ax,ax            ;if enhanced kbd not installed skip
  240.     jz    trfret
  241.     mov    ah,10h
  242.     or    kstfunc,ah
  243.     or    sstfunc,ah
  244.     or    kinfunc,ah
  245. trfret:    ret
  246. trfunc    endp
  247.     endps
  248.     end
  249.