home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / sysutl / cop11.lbr / COP11.MZC / COP11.MAC
Encoding:
Text File  |  1989-04-11  |  8.8 KB  |  257 lines

  1.     TITLE    COP - Console Output Processor
  2.     SUBTTL    Author:  Mike Freeman 1-Apr-89
  3. ;
  4. ;Copyright 1989 by Michael Freeman; 301 N.E. 107th Street;
  5. ;Vancouver, Wa 98685; Telephone (206)574-8221
  6. ;Permission is hereby granted to use and/or modify this code and its
  7. ;accompanying documentation for noncomercial purposes as long as such
  8. ;modified code and/or documentation is not distributed in any form without
  9. ;the written permission of the copyright holder.  Commercial use and/or sale of
  10. ;this code or its documentation is expressly prohibited.
  11. ; The code which relocates the program to high-memory (just below the CCP)
  12. ; is copyrighted 1982, 1984 by John Hastwell-Batten of Australia.
  13. ;
  14. ; This program relocates itself into high memory just below the CCP.
  15. ; It then acts as a preprocessor for characters destined for Console output.
  16. ; It allows repeated characters being typed to the Console to be displayed
  17. ; as single characters and characters to be suppressed from Console output.
  18. ;This is useful for blind computer users employing Braille output devices
  19. ;or voice synthesizers to access the computer screen.  Ruled lines of
  20. ;equals signs (=) or asterisk borders (*), used by the; sighted to
  21. ;prettify and/or clarify their computer output can be tamed.
  22. ;
  23. ; To install the RSX, run COP.  It will ask for characters to
  24. ; suppress/compress and exit to the CCP with the RSX installed.
  25. ; To remove the RSX, just run COP again.
  26. ;
  27. ; To compile/link COP using M80/L80:
  28. ; Obtain a copy of RELOC23.LBR and extract the files RELOC.ABS,
  29. ; RELOC.REL and RELOC.COM
  30. ; Extract RELOC.SUB from this archive
  31. ; Compile COPxx.MAC:
  32. ; A>M80 =COPxx.MAC
  33. ; Making sure all files are on drive A (or the default drive if
  34. ; you've modified your CCP/SUBMIT/XSUB accordingly, type:
  35. ; A>SUBMIT RELOC COPxx -
  36. ; The result will be a copy of COPxx.COM (where xx is version-number)
  37. ; This .COM-file is ready for execution
  38. ;
  39.     .Z80            ;Use Zilog mnemonics
  40. ;
  41. ; BDOS EQUATES
  42. ;
  43. WBT    EQU    0H        ;Warm-boot to CP/M
  44. BDOS    EQU    05H        ;Jump to BDOS
  45. WSC    EQU    09H        ;Write String to Console
  46. RSC    EQU    0AH        ;Read String from Console
  47. RDS    EQU    0DH        ;Reset Disk System
  48. ;
  49. ; ASCII equates
  50. ;
  51. CR    EQU    0DH        ;<cr>
  52. LF    EQU    0AH        ;<lf>
  53. ;
  54. ; Miscellaneous symbols
  55. ;
  56. CMPLEN    EQU    40        ;Length of compression buffer
  57. SUPLEN    EQU    40        ;Length of suppression buffer
  58. ;
  59.     SUBTTL    Revision History
  60. ;
  61. ;Version    Description
  62. ;
  63. ;1.0        Initial Release 01/15/89
  64. ;1.1        Maintainence release 04/01/89; fixed a bug wherein Warm-boot
  65. ;        and BDOS addresses were not being restored during
  66. ;        warm-boots after installation of COP.  This prevented 
  67. ;        removal of COP after running DDT.  Thanks to Howard
  68. ;        Goldstein of New Haven, CT, for pointing out this one.
  69. ;
  70.     SUBTTL    Main program
  71. ;
  72.     DSEG            ;Data segment
  73. ;
  74. $MEMRY::            ;Here for L80 to put address of
  75.     DEFW    0        ;First Free Location in memory
  76.     JP    START        ;Vector to start of program after relocation
  77.                 ;$MEMRY and the vector to START **MUST**
  78.                 ;be in the order here shown in order for
  79.                 ;the relocator module to relocate
  80.                 ;this program to high-memory (see
  81.                 ;RELOC.DOC from RELOC23.LBR)
  82. ;
  83. ; Here after program has been relocated
  84. ;
  85. START:    LD    IX,(BDOS+1)    ;Point to vector into BDOS
  86.     LD    A,(IX+3)    ;Get 1st byte beyond jump
  87.     CP    'C'        ;If COP not already present,
  88.     JR    NZ,INITOK    ;Go set things up
  89.     LD    A,(IX+4)    ;COP possibly here, get next character
  90.     CP    'O'        ;If COP not here,
  91.     JR    NZ,INITOK    ;Go set things up
  92.     LD    A,(IX+5)    ;COP may still be present, get next char
  93.     CP    'P'        ;If COP not present,
  94.     JR    NZ,INITOK    ;Go init things, else
  95.     PUSH    IX        ;Save register IX
  96.     LD    DE,FINMSG    ;Type termination message
  97.     LD    C,WSC        ;...
  98.     CALL    BDOS        ;...
  99.     POP    IX        ;Restore register IX
  100.     LD    IY,(WBT+1)    ;Point into BIOS dispatch table
  101.     LD    E,(IX+9)    ;Get real CP/M Console output routine address
  102.     LD    D,(IX+10)    ;...
  103.     LD    (IY+10),E    ;and restore real Console output address
  104.     LD    (IY+11),D    ;...
  105.     LD    L,(IX+1)    ;Get real BDOS address
  106.     LD    H,(IX+2)    ;...
  107.     LD    (BDOS+1),HL    ;and restore it
  108.     LD    L,(IX+6)    ;Get real CP/M warm-boot address
  109.     LD    H,(IX+7)    ;...
  110.     LD    (IY+1),L    ;and restore it
  111.     LD    (IY+2),H    ;...
  112.     JP    WBT        ;and exit to CP/M
  113. ;Here to initialize various pointers and buffers
  114. INITOK:    LD    DE,HELLO    ;Type sign-on message
  115.     LD    C,WSC        ;...
  116.     CALL    BDOS        ;...
  117.     LD    DE,CMPBUF    ;Point to compression buffer
  118.     LD    C,RSC        ;Set to read string from Console
  119.     CALL    BDOS        ;Get user's answer
  120.     LD    DE,SUPMSG    ;Ask user about suppressed chars
  121.     LD    C,WSC        ;...
  122.     CALL    BDOS        ;...
  123.     LD    DE,SUPBUF    ;Get user's answer
  124.     LD    C,RSC        ;...
  125.     CALL    BDOS        ;...
  126.     LD    IX,(WBT+1)    ;Point into BIOS jump table
  127.     LD    (BTADR),IX    ;and remember it
  128.     LD    L,(IX+1)    ;Get real CP/M warm-boot address
  129.     LD    H,(IX+2)    ;...
  130.     LD    (WBTADR),HL    ;and remember for later
  131.     LD    L,(IX+10)    ;Get address of Console output routine
  132.     LD    H,(IX+11)    ;...
  133.     LD    (JPCONO+1),HL    ;and remember for later
  134.     LD    HL,CONOUT    ;Substitute our own routine
  135.     LD    (IX+10),L    ;...
  136.     LD    (IX+11),H    ;...
  137.     LD    HL,(BDOS+1)    ;Get BDOS entry address
  138.     LD    (JPBDOS+1),HL    ;and remember it
  139.     LD    HL,JPBDOS    ;Substitute our own branch
  140.     LD    (BDOS+1),HL    ;...
  141.     EX    (SP),HL        ;Get CP/M's CCP address
  142.     LD    (CPMRET),HL    ;and remember it
  143.     EX    (SP),HL    ;Restore HL-return address
  144.     LD    HL,NWBOOT    ;Use our own warm-boot routine
  145.     LD    (IX+1),L    ;...
  146.     LD    (IX+2),H    ;...
  147.     LD    DE,INIMSG    ;Say COP is installed
  148.     LD    C,WSC        ;...
  149.     JP    BDOS        ;and return to CP/M CCP
  150. ;
  151. HELLO:    DEFB    CR,LF,'Console Output Processor Version 1.1'
  152.     DEFB    ' 04/01/89'
  153.     DEFB    CR,LF,'Copyright 1989 by Michael Freeman'
  154.     DEFB    CR,LF,'Program Relocation Module copyright 1984 by '
  155.     DEFB    'John Hastwell-Batten'    ;Sign-on message
  156.     DEFB    CR,LF,'Enter characters to compress ';Compression message
  157.     DEFB    '(end with <CR>):  $'
  158. FINMSG:    DEFB    CR,LF,'Removing Console Output Processor',CR,LF,'$'
  159.                 ;Termination message
  160. INIMSG:    DEFB    CR,LF,'Console Output Processor is installed'
  161.     DEFB    CR,LF,'$'    ;Installation announcement
  162. SUPMSG:    DEFB    CR,LF,'Enter characters to suppress ';Suppression prompt
  163.     DEFB    '(end with <CR>):  $'
  164. ;
  165. ; Console Output Processor RSX begins here
  166. ;
  167. JPBDOS:    DEFB    0C3H,0,0    ;Vector to BDOS
  168. ;
  169.     DEFB    'COP'        ;Identifying characters
  170. ;
  171. WBTADR:    DEFW    0        ;Holds address of CP/M's warm-boot routine
  172. JPCONO:    JP    $-$        ;Holds jump to Console output routine
  173. BTADR:    DEFW    0        ;Holds address of BIOS jump to boot
  174. CPMRET:    DEFW    0        ;Holds return address of CCP
  175. ;
  176. WBTMSG:    DEFB    CR,LF,'Console Output Processor active',CR,LF,'$'
  177.                 ;Warm-boot message
  178. ;
  179. CMPBUF:    DEFB    CMPLEN,0    ;Compression buffer
  180.     DEFS    CMPLEN        ;...
  181. SUPBUF:    DEFB    SUPLEN,0    ;Suppression buffer
  182.     DEFS    SUPLEN        ;...
  183. ;
  184. LSTCHR:    DEFB    0        ;Holds last character processed
  185. ;
  186. CPMSTK:    DEFW    0        ;Holds CP/M's stack pointer
  187.     DEFS    32        ;Local stack
  188. LOCSTK:                ;...
  189. ;
  190. ;CONOUT - Console Output Routine
  191. ;Preserves all registers
  192. ;
  193. CONOUT:    LD    (CPMSTK),SP    ;Save current stack pointer
  194.     LD    SP,LOCSTK    ;Use local stack
  195.     PUSH    AF        ;Save AF-IY
  196.     PUSH    BC        ;...
  197.     PUSH    DE        ;...
  198.     PUSH    HL        ;...
  199.     PUSH    IX        ;...
  200.     PUSH    IY        ;...
  201.     LD    A,(LSTCHR)    ;Get last character processed
  202.     LD    E,A        ;and salt it away for checking
  203.     LD    A,C        ;Get current character in process
  204.     LD    (LSTCHR),A    ;and make it last character processed
  205.     LD    HL,SUPBUF+1    ;Point to number of characters to be ignored
  206.     LD    A,(HL)        ;Get number of characters to be suppressed
  207.     OR    A        ;Did user specify any?
  208.     JR    Z,CONOU1    ;Nope, either output character or check more
  209.     LD    B,A        ;Prepare to go thru suppressed chars
  210. CONOU0:    INC    HL        ;Point to a character
  211.     LD    A,(HL)        ;Get a character
  212.     CP    C        ;Same as current one?
  213.     JR    Z,CONOUX    ;Yes, just exit without typing it
  214.     DJNZ    CONOU0        ;No, keep looking
  215. CONOU1:    LD    A,C        ;Character not suppressed, get current one
  216.     CP    E        ;Different from last character processed?
  217.     JR    NZ,CCOUT    ;Yes, type it and exit
  218.     LD    HL,CMPBUF+1    ;Point to # of chars being compressed
  219.     LD    A,(HL)        ;Get this number
  220.     OR    A        ;Did user specify any?
  221.     JR    Z,CCOUT    ;No, just type character and exit
  222.     LD    B,A        ;Yes, prepare to go thru compressed chars
  223. CONOU2:    INC    HL        ;Point to a character
  224.     LD    A,(HL)        ;Get a compressed character
  225.     CP    C        ;Same as current one?
  226.     JR    Z,CONOUX    ;Yes, don't type it
  227.     DJNZ    CONOU2        ;Check all compressed characters
  228. CCOUT:    CALL    JPCONO        ;Type character in C to Console
  229. CONOUX:    POP    IY        ;Restore registers
  230.     POP    IX        ;...
  231.     POP    HL        ;...
  232.     POP    DE        ;...
  233.     POP    BC        ;...
  234.     POP    AF        ;...
  235.     LD    SP,(CPMSTK)    ;Restore original stack pointer
  236.     RET            ;and return
  237. ;
  238. ;NWBOOT - Substitute warm-boot routine
  239. ;
  240. NWBOOT:    LD    SP,WBTSTK    ;Use our own stack
  241.     LD    HL,(BTADR)    ;Restore address in BIOS jumping to warm-boot
  242.     LD    (WBT+1),HL    ;...
  243.     LD    HL,JPBDOS    ;Reset our BDOS entry vector
  244.     LD    (BDOS+1),HL    ;...
  245.     LD    C,RDS        ;Reset disk system
  246.     CALL    BDOS        ;...
  247.     LD    DE,WBTMSG    ;Type warm-boot message
  248.     LD    C,WSC        ;to tell user COP RSX is loaded
  249.     CALL    BDOS        ;...
  250.     LD    HL,(CPMRET)    ;Get CCP entry address
  251.     JP    (HL)        ;and go to CCP
  252. ;
  253.     DEFS    16        ;Boot stack
  254. WBTSTK:                ;...
  255. ;
  256.     END    START            ;End of program
  257.