home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / kaypro / uromkeys.asm < prev    next >
Assembly Source File  |  1994-07-13  |  6KB  |  190 lines

  1. ;
  2. ; UROMKEYS.ASM -- Program to set/reset the Kaypro Universal ROM
  3. ;          BIOS function keys to a given set of keys.
  4. ;
  5. ;
  6. ; By    Tim Farley            Copyright (c) 1986, Tim Farley
  7. ;    415 Ethel St, N.W.        All Rights Reserved.
  8. ;    Atlanta, GA  30318-7942        License granted for free non-
  9. ;                    commercial use ONLY.
  10. ;
  11. ; NOTE: only good with Kaypro version 2.2u.  Do not even attempt
  12. ;    to use this program with any other version of CP/M, nor
  13. ;    with any other computer than a Kaypro, version 2.2u.
  14. ;
  15. ;
  16. ; Problem:    How to dynamically redefine the function keys on
  17. ;        a Kaypro using the new 'universal ROMs' without
  18. ;        running CONFIG and rebooting the machine.  EXKKEYS
  19. ;        does not support the U-ROM's, and AUTOKEYS 4.0, though
  20. ;        it claims to support them, does not work properly,
  21. ;        especially if you have changed your memory size
  22. ;        or installed a CCP replacement.
  23. ;
  24. ; Solution:    Edit the vector keys and function (keypad) keys
  25. ;        in the areas below to suit any given application
  26. ;        you may have in mind.  Assemble this program using
  27. ;        ASM, LASM or MAC; and name it anything you like.
  28. ;        Now you have a 1K .COM file that you can run just
  29. ;        prior to running some other program, to reset
  30. ;        the vector or keypad keys to anything you like.
  31. ;
  32. ; How it works:    The program uses the largely undocumented Kaypro
  33. ;        Universal ROM calls which are accessible by an
  34. ;        'extra' jump vector in the BIOS table, which is
  35. ;        located by examining the WBOOT vector at location
  36. ;        0 in memory.  Several other ROM calls are available
  37. ;        that are of use--look for documentation about them
  38. ;        from me in the future.
  39. ;
  40. ;                    --Tim Farley
  41. ;                      Atlanta, GA
  42. ;
  43. ; Ascii equates
  44. ;
  45. CTRL    EQU    1FH
  46. ;
  47. CR    EQU    CTRL AND 'M'
  48. LF    EQU    CTRL AND 'J'
  49. bell    equ    7
  50. ;
  51. FS    EQU    1CH    ; Form separator, used for function keys
  52. ;
  53. ;
  54. ; Kaypro U-ROM equates
  55. ;
  56. ROMJMP    EQU    037H    ; Offset from start of BIOS that is a JMP
  57. ;              leading directly into Kaypro ROM handler.
  58. ;
  59. CFGOFF    EQU    03AH    ; Offset from start of BIOS that is a word
  60. ;              value (0224H in 2.2u1).  Add this to base
  61. ;              of BIOS table to find CONFIG area.
  62. ;
  63. ROMVER    EQU    0FFF8H    ; ROM version # in ASCII (4 chars) at this
  64. ;              location.  4 bytes sum up to byte following
  65. ;              the string in 2.00+ ROM's.
  66. ;
  67. ;
  68. ; CP/M Equates
  69. ;
  70. prstr    equ    9    ; BDOS print string call
  71. bdos    equ    5    ; Standard CP/M entry
  72. ;
  73. ;
  74.     ORG    100H
  75. ;
  76.     JMP    START
  77. ;
  78. ; Here is where the Vector keys are defined.
  79. ;    One byte per key only, total of four bytes.
  80. ;
  81. VECKEYS:
  82.     DB    CTRL AND 'K'    ; Up Arrow    (Default: 0BH, or ^K)
  83.     DB    CTRL AND 'J'    ; Down Arrow    (Default: 0AH, or ^J)
  84.     DB    CTRL AND 'H'    ; Left Arrow    (Default: 08H, or ^H)
  85.     DB    CTRL AND 'L'    ; Right Arrow    (Default: 0CH, or ^L)
  86. ;
  87. ; Here is a pre-built function key table.
  88. ;    Only define the key strings in the DB's starting
  89. ;    at KEY0: and proceeding to ENDKEY:, all the other
  90. ;    values are built automatically.
  91. ;
  92. FNKEYS:
  93.     DB    KEY1-KEY0,KEY0-FNKEYS
  94.     DB    KEY2-KEY1,KEY1-FNKEYS
  95.     DB    KEY3-KEY2,KEY2-FNKEYS
  96.     DB    KEY4-KEY3,KEY3-FNKEYS
  97.     DB    KEY5-KEY4,KEY4-FNKEYS
  98.     DB    KEY6-KEY5,KEY5-FNKEYS
  99.     DB    KEY7-KEY6,KEY6-FNKEYS
  100.     DB    KEY8-KEY7,KEY7-FNKEYS
  101.     DB    KEY9-KEY8,KEY8-FNKEYS
  102.     DB    KEY10-KEY9,KEY9-FNKEYS
  103.     DB    KEY11-KEY10,KEY10-FNKEYS
  104.     DB    KEY12-KEY11,KEY11-FNKEYS
  105.     DB    KEY13-KEY12,KEY12-FNKEYS
  106.     DB    ENDKEY-KEY13,KEY13-FNKEYS
  107. ;
  108. ; Just modify the below strings to suit, any length such that total
  109. ;    length is less than 241 bytes (so complete table fits in
  110. ;    255 bytes).
  111. ;
  112. KEY0:    DB    '0'    ; 0 on keypad
  113. KEY1:    DB    '1'    ; 1 on keypad
  114. KEY2:    DB    '2'    ; 2 on keypad
  115. KEY3:    DB    '3'    ; 3 on keypad
  116. KEY4:    DB    '4'    ; 4 on keypad
  117. KEY5:    DB    '5'    ; 5 on keypad
  118. KEY6:    DB    '6'    ; 6 on keypad
  119. KEY7:    DB    '7'    ; 7 on keypad
  120. KEY8:    DB    '8'    ; 8 on keypad
  121. KEY9:    DB    '9'    ; 9 on keypad
  122. KEY10:    DB    '-'    ; Dash key on keypad
  123. KEY11:    DB    ','    ; Comma key on keypad
  124. KEY12:    DB    CR    ; ENTER key on keypad
  125. KEY13:    DB    '.'    ; Period key on keypad
  126. ENDKEY:    DB    0
  127. ;
  128. ;
  129. ; Actual start of program here, function table above for easy
  130. ;    patching and the like.
  131. ;
  132.     ORG    FNKEYS+0100H
  133. ;
  134. START:    lxi    d,signon
  135.     mvi    c,prstr        ; print sign-on to user
  136.     call    bdos
  137. ;
  138. ; The code between here and the 'jz doit' is taken
  139. ;    from Kaypro's own PUTSYSU program, and is present
  140. ;    in several other universal-ROM utility programs.
  141. ;    It is the 'official' way to determine whether a
  142. ;    Kaypro has the a U-ROM installed.
  143. ;
  144.     mvi    b,4        ; 4 chars in string: '2.00'
  145.     lxi    h,romver
  146.     xra    a        ; sum = 0 to start
  147. next:    adc    m        ; build checksum
  148.     inx    h
  149.     dcr    b        ; next byte
  150.     jnz    next
  151.     cmp    m
  152.     jz    doit        ; Checksum matches--go ahead
  153. ;
  154. ;
  155.     lxi    d,error        ; Checksum did not match: wrong ROM!
  156.     mvi    c,prstr        ;    Print error and return to CCP
  157.     call    bdos
  158.     ret
  159. ;
  160. signon:    db    cr,lf,'Replacing Kaypro CP/M 2.2u''s function keys....'
  161.     db    cr,lf,'$'
  162. ;
  163. error:    db    cr,lf,'ERROR!  Program requires 2.00 ROM or higher!',bell,'$'
  164. ;
  165. ;
  166. ; Now that we are sure that this is a 2.00+ ROM, let's
  167. ;    go ahead and do it.
  168. ;
  169. doit:
  170.     lhld    0001H        ; get warm boot vector
  171.     xra    a        ; a=0
  172.     mov    l,a        ; set low byte to 0 (base of BIOS)
  173.     mvi    e,romjmp    ; offset to Kaypro ROM jump
  174.     mov    d,a
  175.     dad    d        ; Add to BIOS base to find jump
  176.     shld    jpat1+1        ; Put address into first CALL
  177.     shld    jpat2+1        ;    and into second CALL
  178. ;
  179.     lxi    b,veckeys    ; BC points to vector keys (4 bytes)
  180.     mvi    d,31H        ; ROM function 31h: new vector keys
  181. jpat1:    call    0        ; <-- vector here gets patched above
  182. ;
  183.     lxi    b,fnkeys    ; BC points to function keys (255 bytes)
  184.     mvi    d,32H        ; ROM function 32h: new keypad keys
  185. jpat2:    call    0        ; <-- vector here gets patched above
  186. ;
  187.     ret            ; Return to CCP
  188. ;
  189.     END    
  190. º