home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / KAYPRO / HOTKEY11.LBR / HK101.AZM / HK101.ASM
Assembly Source File  |  2000-06-30  |  12KB  |  333 lines

  1. ;
  2. ; *****************************************************************************
  3. ;
  4. ;                 H O T K E Y S
  5. ;                    v. 1.01
  6. ;                  (c) 1988 J.W. Olsen
  7. ;                          15 May 1988
  8. ;
  9. ;       May be used for noncommercial purposes without permission
  10. ;             Inquire for all other purposes
  11. ; If given or sold with any other product, the price for which is more than $10
  12. ; inclusive of all charges, including but not limited to "shipping & handling,"
  13. ; such gift or sale is considered commercial use for purposes of the above.
  14. ;
  15. ; *****************************************************************************
  16. ;
  17. ; Allows redefintion of arrow and numeric-keypad keys. Two sets of redefinition
  18. ; are permitted in a single, assembled HK program. A run-time, command-line
  19. ; toggle key determines which redefinition will be activated. You may freely
  20. ; switch between the two configurations at any time. 
  21.  
  22. ; HK simply pokes the copy of CP/M in memory. Thus, it's transitory and won't
  23. ; affect disk copies. When you turn off the computer or press the reset button,
  24. ; the effects of HK are gone until you run the program again.
  25. ;
  26. ; HK is run by typing its name, followed by a "toggle" key of your choice, as
  27. ; in "HK W" (e.g., I use "HK B" to run my BBS, "HK W" for word processing with
  28. ; with  WordStar or VDE.) You may want to set one configuration for "vanilla" 
  29. ; CP/M--info to do so is provided.
  30. ;
  31. ; This version works on CP/M Kaypros, except those with U-ROMS. Users with
  32. ; U-ROMs should use HKxxx-U.ASM. For other machines, see HKxxx.INF file.
  33. ;
  34. ; When invoked, HK first installs single-byte values for each of the 4 arrow 
  35. ; keys and the 14 numeric-keypad keys.
  36. ;
  37. ; Later Kaypros also permit assignment of 4-character strings to any or all of
  38. ; the arrow/numeric-keypad keys, activated if the "normal" byte for a given
  39. ; key is set to a null (00H). You'll have to see if this applies to you. My
  40. ; '83 Kaypro II (CP/M 2.2) doesn't permit this. My '84 Kaypro 10 (CP/M 2.2G) 
  41. ; does. If in doubt, first try it with the STRINGS equate set to YES. If the 
  42. ; strings work when you press corresponding keys, you're in business. If not, 
  43. ; RESET YOUR MACHINE BEFORE USING AGAIN. (An unintended area in high memory 
  44. ; will have been overwritten.) In that case, try again with STRINGS set to NO.
  45. ; If you have a non-U-ROM Kaypro, you should at least be able to get the
  46. ; 1-character redefinitions to work. (But if even this doesn't work on your
  47. ; hardware, RESET and feel free to contact me.)
  48. ;
  49. ; NOTE: Only the arrow keys above the main keyboard and the numeric keypad
  50. ; keys are redefined. All other keys are unaffected, including the number keys
  51. ; on the main keypad.
  52. ;
  53. ; Run your favorite assembler/linker. ASM and MLOAD work fine. 
  54. ;
  55. ; Thanx to Eric Bohlman for tips related to memory addresses on this version
  56. ; of HK.
  57. ;
  58. ; This was a quickie effort to meet a special need, but performs its function
  59. ; fully. Experienced 8080 programmers (of which it will be readily apparent
  60. ; I'm not one) undoubtedly will be able to reduce code size and suggest
  61. ; further improvements. That would be welcomed. But if in the meantime you
  62. ; too find HK useful, enjoy. Please direct comments, or check for any updates
  63. ; on my BBS.
  64. ;       Jerry Olsen
  65. ;    Sysop, The Advocate/NOWAR RCP/M
  66. ;    312.939.4411
  67. ;    24 hrs., 300/1200/2400, 8/n/1
  68. ; ----- Preliminaries
  69. ;    ASEG            ; Comment out if assembling with other than M80
  70. ;
  71. NO    EQU    0        ; Leave these alone
  72. YES    EQU    NOT NO
  73. ;
  74. ; ----- User-settable equates
  75. ;
  76. TOGGLE1 EQU    'B'        ; Specify two characters as command-line
  77. TOGGLE2    EQU    'W'        ; toggles to invoke your configurations.
  78.                 ; A toggle may be any single letter, number
  79.                 ; or punctuation. But LOWER CASE letters are
  80.                 ; *NOT* allowed. You might want to set one
  81.                 ; to "V" for "vanilla" CP/M settings.
  82. OFFSET    EQU    35H        ; Offset to first byte of arrows configuration
  83.                 ; from the beginning of the first page of
  84.                 ; memory pointed to by location 02H.
  85.                 ; Neither OFFSET nor OFFST2 should require
  86.                 ; any change for non-U-ROM Kaypros. 
  87. STRINGS EQU    YES        ; *** See headnotes about this ***
  88. OFFST2    EQU    61H        ; Offset to where 4-char strings can be stored
  89.                 ; if bytes in area following OFFSET are nulls.
  90.                 ; (Only active if STRINGS is set YES--for later
  91.                 ; vintage Kaypros.)
  92. ;
  93. ; *** You also need to set up the arrays toward the end of this file ***
  94. ;
  95. ; ----- Miscellaneous equates (leave alone)
  96. ;
  97. WBOOT    EQU    0        ; Warm boot location
  98. BDOS    EQU    5        ; BDOS entry point
  99. PRINTF    EQU    9        ; Print-a-string function
  100. BUFF    EQU    80H        ; Command line buffer
  101. CR    EQU    0DH        ; Carriage return
  102. LF    EQU    0AH        ; Linefeed
  103. SPACE    EQU    20H        ; Ordinary blank space
  104. NULL    EQU    0        ; May be used in arrays if desired
  105. ;
  106. ; ----- Begin
  107. ;
  108.     ORG    100H        ; Normal TPA entry point
  109. ;
  110.     LXI    D,SIGNON    ; Point to sign-on msg
  111.     MVI    C,PRINTF    ; Tell BDOS we want to print a string
  112.     CALL    BDOS        ; and do it
  113. ;
  114. ;    LXI    H,BUFF        ; Get address of command-line buffer
  115.     MOV    A,M        ; Get buffer length
  116.     CPI    NULL        ; Is it a null?
  117.     JZ    ERROR1        ; Yep, so print error msg & quit
  118. ;
  119.     MOV    B,A        ; Nope, so save command-line length
  120.     LXI    H,BUFF+1    ; Point to first char of command line
  121. GETIT:    DCR    B        ; Decrement our length counter
  122.     MVI    A,NULL        ; Prepare for comparison
  123.     CMP    B        ; Is counter now a null?
  124.     JZ    ERROR1        ; Yep, so print error msg & quit
  125.     MOV    A,M        ; Nope, so fetch char
  126.     INX    H        ; & increment pointer
  127.     CPI    SPACE        ; Is it a space?
  128.     JZ    GETIT        ; Yep, try again
  129. ;
  130.     CPI    TOGGLE1        ; Is it first legal toggle?
  131.     JZ    SAVEIT        ; Yep, so skip loop
  132.     CPI    TOGGLE2        ; Is it second legal toggle?
  133.     JZ    SAVEIT        ; Yep
  134.     JMP    ERROR1        ; Nope,so print error msg & quit
  135. ;
  136. SAVEIT:    STA    OPTION        ; We need it later too
  137. ;
  138.     LHLD    WBOOT+1        ; See if we're really pointing to where should
  139.     MOV    L,NULL        ; Will look at first byte of memory page
  140.     MOV    A,M        ; Snatch the byte
  141.     CPI    0C3H        ; A JMP instruction?
  142.     JZ    ERROR2        ; Nope, something's wrong--abort (might be a
  143.                 ; problem with another program trapping WBOOT)
  144. ;
  145.     MVI    L,OFFSET    ; Offset to first arrow char byte    
  146.     XCHG            ; Save pointer while freeing (HL)
  147.     LDA    OPTION        ; Get user choice back
  148.     CPI    TOGGLE1        ; Was it first choice?
  149.     JNZ    ALT        ; Nope, so skip to it
  150.     LXI    H,KEYS1        ; Yep, so point to first set-up
  151.     JMP    DOIT        ; and begin
  152. ALT:    LXI    H,KEYS2        ; Point to second set-up
  153. ;
  154. DOIT:    MVI    B,18        ; Counter = # of arrow + numeric keypad keys
  155. DOIT2:    MOV    A,M        ; Fetch first byte
  156.     STAX    D        ; and poke it
  157.     DCR    B        ; See if counter is done
  158.     MVI    A,NULL
  159.     CMP    B        ; If done...
  160. ;
  161.     IF    STRINGS
  162.     JZ    DOIT3        ; all direct key values are poked
  163.                 ; so go do 4-char strings (if STRINGS YES)...
  164.     ENDIF            ; STRINGS
  165. ;
  166.     IF    NOT STRINGS
  167.     JZ    DONE        ; ... or tell 'em what we've done & quit
  168.     ENDIF            ; NOT STRINGS
  169. ;
  170.     INX    D        ; If not done with direct key values
  171.     INX    H        ; increment both pointers
  172.     JMP    DOIT2        ; and keep truckin' 
  173. ;
  174.     IF    STRINGS
  175. DOIT3:    LHLD    WBOOT+1        ; Set up pointer again--
  176.     MVI    L,OFFST2    ; this time to where CP/M stores strings
  177.     XCHG            ; Free up (HL)
  178.     LDA    OPTION        ; Get choice back
  179.     CPI    TOGGLE1        ; First choice?
  180.     JNZ    ALT2        ; Nope
  181.     LXI    H,STR1        ; Yep
  182.     JMP    DOIT4
  183. ALT2:    LXI    H,STR2
  184. ;
  185. DOIT4:    MVI    B,18*4        ; Counter = # keys * 4-char strings    
  186. DOIT5:    MOV    A,M        ; Fetch first byte
  187.     STAX    D        ; and poke it
  188.     DCR    B        ; See if counter is done
  189.     MVI    A,NULL
  190.     CMP    B        ; 
  191.     JZ    DONE        ; Yep, so tell 'em what we've done & quit
  192.     INX    D        ; If not
  193.     INX    H        ; increment both pointers
  194.     JMP    DOIT5        ; and continue
  195.     ENDIF            ; STRINGS
  196. ;
  197. DONE:    LXI    D,OKMSG        ; Point to successful sign-off msg & ...
  198. ;
  199. EXIT:    MVI    C,PRINTF    ; Tell BDOS to print a string
  200.     CALL    BDOS        ; & do it
  201.     RET            ; then quit
  202. ;    
  203. ; ----- Subroutine to print error msg if invalid command-line toggle
  204. ;
  205. ERROR1:    LXI    D,ERR1        ; Point to error msg
  206.     JMP    EXIT        ; Go print it & quit
  207. ;
  208. ; ---- Error msg if can't find correct page of memory to use
  209. ;
  210. ERROR2:    LXI    D,ERR2        ; Point to error msg
  211.     JMP    EXIT        ; Go print it & quit
  212. ;
  213. ; ----- Storage Area
  214. ;
  215. SIGNON:    DB    CR,LF,'HOTKEYS v. 1.01, (c) 1988, J.W. Olsen',CR,LF,'$'
  216. ERR1:    DB    CR,LF,'Syntax: HK ',TOGGLE1,' or HK ',TOGGLE2,CR,LF,'$'
  217. ERR2:    DB    7,CR,LF,'++ Valid memory locations not found ++',CR,LF,'$'
  218. OKMSG:    DB    '"'    ; Printing of exit msg begins here, continues thru...
  219. OPTION: DS    1    ; User choice (filled when TOGGLE1 or TOGGLE2 selected)
  220. OKMSG2:    DB    '" configuration INSTALLED',CR,LF
  221.     DB    '$'     ; ...end of exit msg (used only if HK is successful)
  222. ;
  223. ; Enter your 1-character preferences for each keystroke below. (For nonprintable
  224. ; characters, use hex. For others, use either hex or alphanumeric. Examples of
  225. ; both below.)
  226. ;
  227. ; "What Is" reflects current values. (Replace with your description if 
  228. ; changes are made.) "Original" indicates vanilla CP/M. "Name" describes the 
  229. ; function of the original key. 
  230. ;
  231. ; "KEYS1" relate to your TOGGLE1 selection, "KEYS2" to TOGGLE2. If you want
  232. ; to substitute a 4-character substitute for any key, enter 00H or NULL for
  233. ; it & see "STR" (string) discussion, below--IF you set "STRINGS" to YES. As
  234. ; released, TOGGLE1 represents my configuration for running a BBS. Toggle 2 
  235. ; is my personal, albeit at first glance seemingly weird preferences for word
  236. ; processing with WordStar/VDE.
  237. ;
  238. ;              What Is    Original    Name
  239. ;              =========    ========    ========
  240. KEYS1:    DB    NULL    ; Uses STR1    05H        Up arrow
  241.     DB    NULL    ; Uses STR1    18H        Down arrow
  242.     DB    NULL    ; Uses STR1    13H        Left arrow
  243.     DB    NULL    ; Uses STR1    04H        Right arrow
  244.     DB    '0'    ; keypad 0    30H        0 (keypad)
  245.     DB    '1'    ; 1        31H        1 "
  246.     DB    '2'    ; 2        32H        2 "
  247.     DB    '3'    ; 3        33H        3 "
  248.     DB    '4'    ; 4        34H        4 "
  249.     DB    '5'    ; 5        35H        5 "
  250.     DB    '6'    ; 6        36H        6 "
  251.     DB    '7'    ; 7        37H        7 "
  252.     DB    '8'    ; 8        38H        8 "
  253.     DB    '9'    ; 9        39H        9 "
  254.     DB    '-'    ; Hyphen    2DH        Hyphen (keypad)
  255.     DB    03H    ; control-C    2CH        Comma    "
  256.     DB    0DH    ; Enter        0DH        Enter    "
  257.     DB    '.'    ; period    2EH        Period    "
  258. ;
  259. ;              What Is    Original    Name
  260. ;              =========    ========    ========
  261. KEYS2:    DB    10H    ; control-P    05H        Up arrow
  262.     DB    0FH    ; control-O    18H        Down arrow
  263.     DB    0BH    ; control-K    13H        Left arrow
  264.     DB    02H    ; control-B    04H        Right arrow
  265.     DB    07H    ; control-G    30H        0 (on KEYPAD)
  266.     DB    19H    ; control-Y    31H        1    
  267.     DB    18H    ; control-X    32H        2    
  268.     DB    06H    ; control-F    33H        3
  269.     DB    13H    ; control-S    34H        4
  270.     DB    11H    ; control-Q    35H        5
  271.     DB    04H    ; control-D    36H        6
  272.     DB    15H    ; control-U    37H        7
  273.     DB    05H    ; control-E    38H        8
  274.     DB    01H    ; control-A    39H        9
  275.     DB    12H    ; control-R    2DH        Hyphen    "
  276.     DB    03H    ; control-C    2CH        Comma    "
  277.     DB    16H    ; control-V    0DH        Enter     "
  278.     DB    14H    ; control-T    2EH        Period    "
  279. ;
  280.     IF    STRINGS
  281. ; For anything that's a NULL above, the corresponding key is replaced by the
  282. ; related string below--if you set STRINGS to YES.
  283. ;
  284. ;              What Is    Original    Name
  285. ;              =========    ========    ========
  286. STR1:    DB    'BYE',CR ; [normally    [all NULLs]    Expands Up arrow
  287.     DB    'CHAT'    ; nulls, but               " downn arrow
  288.     DB    'HELP'    ; set as               " Left arrow
  289.     DB    '`SD '    ; blank spaces               " Right arrow
  290.     DB    '    '    ; here to                " KEYPAD 0
  291.     DB    '    '  ; facilitate                         1
  292.     DB    '    '  ; filling in                        2
  293.     DB    '    '  ; with alpha                    3
  294.     DB    '    '  ; characters]                      4
  295.     DB    '    '  ;                        5
  296.     DB    '    '  ;                        6
  297.     DB    '    '  ;                        7
  298.     DB    '    '  ;                        8
  299.     DB    '    '  ;                        9
  300.     DB    '    '  ;                   "    Hyphen
  301.     DB    '    '  ;                   "    Comma
  302.     DB    '    '  ;                   "    Enter 
  303.     DB    '    '  ;                   "    Period
  304. ;
  305. ;              What Is    Original    Name
  306. ;              =========    ========    ========
  307. STR2:    DB    '    '    ; [all unused]    [all NULLs]    Expands Up arrow
  308.     DB    '    '    ;                   " downn arrow
  309.     DB    '    '    ;                   " Left arrow
  310.     DB    '    '    ;                   " Right arrow
  311.     DB    '    '    ;                   " KEYPAD 0
  312.     DB    '    '  ;                            1
  313.     DB    '    '  ;                            2
  314.     DB    '    '  ;                        3
  315.     DB    '    '  ;                          4
  316.     DB    '    '  ;                        5
  317.     DB    '    '  ;                        6
  318.     DB    '    '  ;                        7
  319.     DB    '    '  ;                        8
  320.     DB    '    '  ;                        9
  321.     DB    '    '  ;                   "     Hyphen
  322.     DB    '    '  ;                   "     Comma
  323.     DB    '    '  ;                   "    Enter 
  324.     DB    '    '  ;                   "    Period
  325.     ENDIF        ; STRINGS
  326. ;
  327. ; ----- That's all, folks
  328. ;
  329.     END
  330.