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-U.AZM / HK101-U.ASM
Assembly Source File  |  2000-06-30  |  13KB  |  416 lines

  1. ;
  2. ; *****************************************************************************
  3. ;
  4. ;                 H O T K E Y S
  5. ;                   v. 1.01-U
  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 disks. When you turn off the computer or press the reset button, the
  24. ; 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 with U-ROMs. Those with other CP/M Kaypros
  32. ; should use HKxxx.ASM, distributed with this file. For other machines, see 
  33. ; the HKxxx.INF file. The "non-U-ROM" version employs some checks when invoked 
  34. ; not contained herein due to some elusiveness in the logic (maybe illogic) of 
  35. ; the U-ROM. But try it. If it works once on your U-ROM Kaypro, it can be 
  36. ; expected to work consistently.
  37. ;
  38. ; You can reassign one character for each of the normal arrow keys above your
  39. ; main keyboard. And you can assign strings up to EIGHTY characters for each of
  40. ; your numeric-keypad keys--up to a maximum of 225 total characters for all
  41. ; 14 numeric keys together.
  42. ;
  43. ; Run your favorite assembler/linker. ASM and MLOAD work fine. 
  44. ;
  45. ; After assembling, test by first invoking your newly configured "period" key 
  46. ; on the numeric keypad. If that works, HK will work on your machine. If it 
  47. ; misbehaves, you may have a U-ROM version sufficiently different from mine 
  48. ; that some recoding may be needed. If so, outline your experiences and I'll 
  49. ; try to help. If ANYTHING doesn't seem to work correctly, RESET YOUR MACHINE
  50. ; BEFORE USING AGAIN. An unintended area in high memory will have been
  51. ; overwritten, and could consistently or unpredictably produce weird results.
  52. ;
  53. ; NOTE: Only the arrow keys above the main keyboard and the numeric keypad
  54. ; keys are redefined. All other keys are unaffected, including the number keys
  55. ; on the main keypad.
  56. ;
  57. ; This was a quickie effort to meet a special need, but performs its function
  58. ; fully. Experienced 8080 programmers (of which it will be readily apparent
  59. ; I'm not one) undoubtedly will be able to reduce the code further and suggest
  60. ; further improvements. That would be welcomed. But if in the meantime you
  61. ; too find HK useful, enjoy. Please direct comments, or check for any updates
  62. ; on my BBS.
  63. ;       Jerry Olsen
  64. ;    Sysop, The Advocate/NOWAR RCP/M
  65. ;    312.939.4411
  66. ;    24 hrs., 300/1200/2400, 8/n/1
  67. ; ----- Preliminaries
  68. ;    ASEG            ; Comment out if assembling with other than M80
  69. ;
  70. NO    EQU    0        ; Leave these alone
  71. YES    EQU    NOT NO
  72. ;
  73. ; ----- User-settable equates
  74. ;
  75. TOGGLE1 EQU    'B'        ; Specify two characters as command-line
  76. TOGGLE2    EQU    'W'        ; toggles for configurations you desire.
  77.                 ; A toggle may be any single letter, number
  78.                 ; or punctuation. LOWER CASE letters are NOT
  79.                 ; allowed. You might want to set one to "V"
  80.                 ; for "vanilla" CP/M settings.
  81. ; *** You also need to set up the arrays toward the end of this file ***
  82. ;
  83. ; ----- System-specific equates (change ONLY if these prove incorrect for
  84. ;       your system after testing)
  85. ;
  86. AROVEC    EQU    0F143H        ; Location of first byte of arrow keys
  87.                 ; are stored.
  88. NUMVEC    EQU    0F060H        ; Similarly, for numeric keys
  89. NUMLEN    EQU    0F044H        ; Lengths of each numeric-keypad definition
  90.                 ; are poked beginning here, skipping one byte
  91.                 ; between addresses to poke (i.e., F044H,
  92.                 ; F046H, etc.)
  93. MAXLEN    EQU    225        ; Max. # of all numeric-keypad reconfiguration
  94.                 ; strings combined as allowed by U-ROM Kaypros
  95. ;
  96. ; ----- Miscellaneous equates (leave alone)
  97. ;
  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        ; Save it for later
  137. ;
  138.     LXI    D,AROVEC    ; Point to first location to poke with
  139.                 ; arrow configuration
  140.     LDA    OPTION        ; Get user choice back
  141.     CPI    TOGGLE1        ; Was it first choice?
  142.     JNZ    ALT        ; Nope, so skip to it
  143.     LXI    H,ARO1        ; Yep, so point to first set-up
  144.     JMP    DOIT        ; and begin
  145. ALT:    LXI    H,ARO2        ; Point to second set-up
  146. ;
  147. DOIT:    MVI    B,4        ; Counter for # of arrow keys
  148. DOIT2:    MOV    A,M        ; Fetch first byte
  149.     STAX    D        ; and poke it
  150.     DCR    B        ; See if counter is done
  151.     MVI    A,NULL
  152.     CMP    B        ; If done...
  153.     JZ    DOIT3        ; go deal with numeric-keypad configurations
  154. ;
  155.     INX    D        ; If not done 
  156.     INX    H        ; increment both pointers
  157.     JMP    DOIT2        ; and keep truckin' 
  158. ;
  159. DOIT3:    LXI    D,NUMVEC    ; Point to first location to poke with
  160.                 ; numeric keypad strings
  161.     LDA    OPTION        ; Get choice back
  162.     CPI    TOGGLE1        ; First choice?
  163.     JNZ    ALT2        ; Nope
  164.     LXI    H,NUM1        ; Yep, so point to its numeric configs
  165.     JMP    DOIT4
  166. ALT2:    LXI    H,NUM2        ; Point to 2nd numeric configs
  167. ;
  168. DOIT4:    MVI    B,NULL        ; We'll use (B) as a counter
  169. DOIT5:    MOV    A,M        ; Fetch first byte
  170.     CPI    0FFH        ; Reached our end-of-strings indicator?
  171.     JZ    DOIT6        ; Yep
  172.     STAX    D        ; Nope, so poke it
  173.     INR    B        ; Count # of bytes poked,
  174.     INX    D        ; increment both pointers,
  175.     INX    H        ; 
  176.     JMP    DOIT5        ; & continue
  177. ;
  178. DOIT6:    MVI    A,0FFH        ; The U-ROM expects 2 0FFh chars after our
  179.     STAX    D        ; string
  180.     INX    D
  181.     STAX    D
  182. ;
  183.     MOV    A,B        ; Prepare to save counter
  184.     STA    COUNT        ; & do it
  185. ;
  186.     LXI    D,NUMLEN    ; Point to first location to poke with LENGTH
  187.                 ; of each numeric-keypad definition
  188.     LDA    OPTION        ; Get choice back
  189.     CPI    TOGGLE1        ; First choice?
  190.     JNZ    ALT3        ; Nope
  191.     LXI    H,NLEN1        ; Yep, so point to 1st set of string lengths
  192.     JMP    DOIT7
  193. ALT3:    LXI    H,NLEN2        ; Point to 2nd set
  194. ;
  195. DOIT7:    MVI    B,NULL        ; Again, our counter
  196. ;
  197.     MOV    A,M        ; Fetch first byte
  198.     PUSH    A        ; Save it for a moment
  199.     ADD    B        ; Our # of bytes counter
  200.     MOV    B,A        ; Save byte counter
  201.     POP    A        ; Get our character back again
  202.     MOV    C,A        ; Start an offset value CP/M needs
  203.     STAX    D        ; Poke it
  204.     INX    D        ; Increment both of our pointers
  205.     INX    H        ; 
  206.     LDAX    D        ; Grab following byte
  207.     ADD    C        ; Add it to CP/M's offset value 
  208.     MOV    C,A        ; & save it
  209.     INX    D        ; Bump (DE) once again
  210. ;
  211. ; Repeat for succeeding bytes, with variations on the theme
  212. ;
  213. DOIT8:    MOV    A,M        ; Fetch next byte
  214.     CPI    0FFH        ; Reached our end-of-strings indicator?
  215.     JZ    DOIT9        ; Yep
  216.     PUSH    A        ; Nope, so deal with our byte counter 
  217.     ADD    B
  218.     MOV    B,A
  219.     POP    A
  220.     STAX    D        ; Poke our NLEN byte
  221.     PUSH    A        ; Save again
  222.     MOV    A,C        ; Get CP/M's current running offset
  223.     INX    D        ; Increment our pointer
  224.     STAX    D        ; & poke CP/M's offset now
  225.     POP    A        ; OK, get value back
  226.     ADD    C        ; & add it to the running CP/M offset
  227.     MOV    C,A        ; ... which needs to be saved again
  228.     INX    H        ; Now increment (HL) pointer
  229.     INX    D        ; & bump (DE) again
  230.     JMP    DOIT8        ; ... & finally, time to fetch next
  231. ;
  232. DOIT9:    LDA    COUNT        ; Get our 1st counter back
  233.     CMP    B         ; Is it the same?
  234.     JNZ    ERROR2        ; Nope, so tell 'em & quit
  235.     MVI    A,MAXLEN    ; Max. # of bytes allowed for all numeric-
  236.                 ; keypad reconfigs allowed by U-ROM Kaypros
  237.     CMP    B        ; Too many bytes? 
  238.     JC    ERROR3        ; Yep, so tell 'em & quit
  239.     LXI    D,OKMSG        ; Otherwise, point to "all's OK" sign-off msg
  240.                 ; and...
  241. ;
  242. EXIT:    MVI    C,PRINTF    ; Tell BDOS to print a string
  243.     CALL    BDOS        ; & do it
  244.     RET            ; then quit
  245. ;    
  246. ; ----- Subroutine to print error msg if invalid command-line toggle
  247. ;
  248. ERROR1:    LXI    D,ERR1        ; Point to error msg
  249.     JMP    EXIT        ; Go print it & quit
  250. ;
  251. ; ----- Exit routines if assembly-time error detected
  252. ;
  253. ERROR2:    LXI    D,ERR2        ; Point to error msg
  254.     JMP    EXIT        ; Go print & exit
  255. ;
  256. ERROR3:    LXI    D,ERR3        ; Point to error msg and...
  257.     JMP    EXIT        ; Go print & exit
  258. ;
  259. ; ----- Storage Area
  260. ;
  261. SIGNON:    DB    CR,LF,'HOTKEYS v. 1.00U, (c) 1988, J.W. Olsen',CR,LF,'$'
  262. ERR1:    DB    CR,LF,'Syntax: HK ',TOGGLE1,' or HK ',TOGGLE2,CR,LF,'$'
  263. ERR2    DB    CR,LF,7,'ASSEMBLY-TIME ERROR: For the selected option,'
  264.     DB    CR,LF,'number of bytes for "NUM" and "NLEN" don''t match'
  265.     DB    CR,LF,'$'
  266. ERR3:    DB    CR,LF,7,'ASSEMBLY-TIME ERROR: For the selected option,'
  267.     DB    CR,LF,'combined length of numeric-keypad definitions too long'
  268.     DB    CR,LF,'$'
  269. OKMSG:    DB    '"'    ; Printing of exit msg begins here, continues thru...
  270. OPTION: DS    1    ; User choice (filled when TOGGLE1 or TOGGLE2 selected)
  271. OKMSG2:    DB    '" configuration INSTALLED',CR,LF
  272.     DB    '$'    ; ...end of exit msg (used only if HK is successful)
  273. COUNT:    DS    1    ; Will be filled with # of numeric-keypad bytes poked
  274. ;
  275. ; Enter your 1-character preferences for each arrow key below. (For nonprintable
  276. ; characters, which you'll almost sure want, use hex. For others, use either hex
  277. ; or alphanumeric. Alphanumeric characters may be placed within SINGLE quote
  278. ; marks, as in: DB    'A'.)
  279. ;
  280. ; FOR TOGGLE1
  281. ;
  282. ARO1:    DB    05H    ; Value for UP arrow key
  283.     DB    18H    ; DOWN arrow
  284.     DB    13H    ; LEFT arrow
  285.     DB    04H    ; RIGHT arrow
  286.     DB    0FFH    ; Don't alter this
  287. ;
  288. ; FOR TOGGLE2
  289. ;
  290. ARO2:    DB    05H    ; UP arrow
  291.     DB    18H    ; DOWN arrow
  292.     DB    13H    ; LEFT arrow
  293.     DB    04H    ; RIGHT arrow
  294.     DB    0FFH    ; Don't alter this
  295. ;
  296. ; Enter your strings for each numeric-keypad character below. For alphanumeric
  297. ; redefinitions, place between single quote marks. For control characters,
  298. ; enter hex values. They may be combined, if separated by commas. Example:
  299. ; 'this is a sample of alphanumeric characters',0DH,0AH,'separated by hex'
  300. ; The MAXIMUM length of EACH string is 80 characters. The maximum TOTAL length
  301. ; of ALL strings for "NUM1" strings is 225 characters. Same for "NUM2" strings.
  302. ; Enter each string on the line following the comment designating the key that
  303. ; it will redefine.
  304. ;
  305. ; FOR TOGGLE1
  306. ;
  307. ; "0" key on numeric keypad:
  308. NUM1:    DB    '0'
  309. ; "1":
  310.     DB    '1'
  311. ; "2":
  312.     DB    '2'
  313. ; "3":
  314.     DB    '3'
  315. ; "4":
  316.     DB    '4'
  317. ; "5":
  318.     DB    '5'
  319. ; "6":
  320.     DB    '6'
  321. ; "7":    
  322.     DB    '7'
  323. ; "8"
  324.     DB    '8'
  325. ; "9":
  326.     DB    '9'
  327. ; Hyphen key on numeric keypad:
  328.     DB    '-'
  329. ; Comma:
  330.     DB    ','
  331. ; Enter key:
  332.     DB    0DH
  333. ; Period:
  334.     DB    '.'
  335. ; Don't alter next line
  336.     DB    0FFH
  337. ;
  338. ; FOR TOGGLE2
  339. ;
  340. ; "0" key on numeric keypad:
  341. NUM2:    DB    '0'
  342. ; "1":
  343.     DB    '1'
  344. ; "2":
  345.     DB    '2'
  346. ; "3":
  347.     DB    '3'
  348. ; "4":
  349.     DB    '4'
  350. ; "5":
  351.     DB    '5'
  352. ; "6":
  353.     DB    '6'
  354. ; "7":    
  355.     DB    '7'
  356. ; "8"
  357.     DB    '8'
  358. ; "9":
  359.     DB    '9'
  360. ; Hyphen key on numeric keypad:
  361.     DB    '-'
  362. ; Comma:
  363.     DB    ','
  364. ; Enter key:
  365.     DB    0DH
  366. ; Period:
  367.     DB    '.'
  368. ; Don't alter next line
  369.     DB    0FFH
  370. ;
  371. ; Enter the LENGTH of each "NUM1" string above, in HEX. Be sure the total
  372. ; doesn't exceed 225 bytes.
  373. ;
  374. ; FOR TOGGLE1:
  375. ;
  376. NLEN1:    DB    01H    ; For 0 key
  377.     DB    01H    ; For 1 key
  378.     DB    01H    ; For 2 key
  379.     DB    01H    ; For 3 key
  380.     DB    01H    ; For 4 key
  381.     DB    01H    ; For 5 key
  382.     DB    01H    ; For 6 key
  383.     DB    01H    ; For 7 key
  384.     DB    01H    ; For 8 key
  385.     DB    01H    ; For 9 key
  386.     DB    01H    ; For hyphen
  387.     DB    01H    ; For comma 
  388.     DB    01H    ; For enter 
  389.     DB    01H    ; For period 
  390.     DB    0FFH    ; Don't alter this
  391. ;
  392. ; FOR TOGGLE2:
  393. ;
  394. NLEN2:    DB    01H    ; For 0 key
  395.     DB    01H    ; For 1 key
  396.     DB    01H    ; For 2 key
  397.     DB    01H    ; For 3 key
  398.     DB    01H    ; For 4 key
  399.     DB    01H    ; For 5 key
  400.     DB    01H    ; For 6 key
  401.     DB    01H    ; For 7 key
  402.     DB    01H    ; For 8 key
  403.     DB    01H    ; For 9 key
  404.     DB    01H    ; For hyphen
  405.     DB    01H    ; For comma 
  406.     DB    01H    ; For enter 
  407.     DB    01H    ; For period 
  408.     DB    0FFH    ; Don't alter this
  409. ;
  410. ; ----- That's all, folks
  411. ;
  412.     END
  413.