TITLE COP - Console Output Processor SUBTTL Author: Mike Freeman 1-Apr-89 ; ;Copyright 1989 by Michael Freeman; 301 N.E. 107th Street; ;Vancouver, Wa 98685; Telephone (206)574-8221 ;Permission is hereby granted to use and/or modify this code and its ;accompanying documentation for noncomercial purposes as long as such ;modified code and/or documentation is not distributed in any form without ;the written permission of the copyright holder. Commercial use and/or sale of ;this code or its documentation is expressly prohibited. ; The code which relocates the program to high-memory (just below the CCP) ; is copyrighted 1982, 1984 by John Hastwell-Batten of Australia. ; ; This program relocates itself into high memory just below the CCP. ; It then acts as a preprocessor for characters destined for Console output. ; It allows repeated characters being typed to the Console to be displayed ; as single characters and characters to be suppressed from Console output. ;This is useful for blind computer users employing Braille output devices ;or voice synthesizers to access the computer screen. Ruled lines of ;equals signs (=) or asterisk borders (*), used by the; sighted to ;prettify and/or clarify their computer output can be tamed. ; ; To install the RSX, run COP. It will ask for characters to ; suppress/compress and exit to the CCP with the RSX installed. ; To remove the RSX, just run COP again. ; ; To compile/link COP using M80/L80: ; Obtain a copy of RELOC23.LBR and extract the files RELOC.ABS, ; RELOC.REL and RELOC.COM ; Extract RELOC.SUB from this archive ; Compile COPxx.MAC: ; A>M80 =COPxx.MAC ; Making sure all files are on drive A (or the default drive if ; you've modified your CCP/SUBMIT/XSUB accordingly, type: ; A>SUBMIT RELOC COPxx - ; The result will be a copy of COPxx.COM (where xx is version-number) ; This .COM-file is ready for execution ; .Z80 ;Use Zilog mnemonics ; ; BDOS EQUATES ; WBT EQU 0H ;Warm-boot to CP/M BDOS EQU 05H ;Jump to BDOS WSC EQU 09H ;Write String to Console RSC EQU 0AH ;Read String from Console RDS EQU 0DH ;Reset Disk System ; ; ASCII equates ; CR EQU 0DH ; LF EQU 0AH ; ; ; Miscellaneous symbols ; CMPLEN EQU 40 ;Length of compression buffer SUPLEN EQU 40 ;Length of suppression buffer ; SUBTTL Revision History ; ;Version Description ; ;1.0 Initial Release 01/15/89 ;1.1 Maintainence release 04/01/89; fixed a bug wherein Warm-boot ; and BDOS addresses were not being restored during ; warm-boots after installation of COP. This prevented ; removal of COP after running DDT. Thanks to Howard ; Goldstein of New Haven, CT, for pointing out this one. ; SUBTTL Main program ; DSEG ;Data segment ; $MEMRY:: ;Here for L80 to put address of DEFW 0 ;First Free Location in memory JP START ;Vector to start of program after relocation ;$MEMRY and the vector to START **MUST** ;be in the order here shown in order for ;the relocator module to relocate ;this program to high-memory (see ;RELOC.DOC from RELOC23.LBR) ; ; Here after program has been relocated ; START: LD IX,(BDOS+1) ;Point to vector into BDOS LD A,(IX+3) ;Get 1st byte beyond jump CP 'C' ;If COP not already present, JR NZ,INITOK ;Go set things up LD A,(IX+4) ;COP possibly here, get next character CP 'O' ;If COP not here, JR NZ,INITOK ;Go set things up LD A,(IX+5) ;COP may still be present, get next char CP 'P' ;If COP not present, JR NZ,INITOK ;Go init things, else PUSH IX ;Save register IX LD DE,FINMSG ;Type termination message LD C,WSC ;... CALL BDOS ;... POP IX ;Restore register IX LD IY,(WBT+1) ;Point into BIOS dispatch table LD E,(IX+9) ;Get real CP/M Console output routine address LD D,(IX+10) ;... LD (IY+10),E ;and restore real Console output address LD (IY+11),D ;... LD L,(IX+1) ;Get real BDOS address LD H,(IX+2) ;... LD (BDOS+1),HL ;and restore it LD L,(IX+6) ;Get real CP/M warm-boot address LD H,(IX+7) ;... LD (IY+1),L ;and restore it LD (IY+2),H ;... JP WBT ;and exit to CP/M ;Here to initialize various pointers and buffers INITOK: LD DE,HELLO ;Type sign-on message LD C,WSC ;... CALL BDOS ;... LD DE,CMPBUF ;Point to compression buffer LD C,RSC ;Set to read string from Console CALL BDOS ;Get user's answer LD DE,SUPMSG ;Ask user about suppressed chars LD C,WSC ;... CALL BDOS ;... LD DE,SUPBUF ;Get user's answer LD C,RSC ;... CALL BDOS ;... LD IX,(WBT+1) ;Point into BIOS jump table LD (BTADR),IX ;and remember it LD L,(IX+1) ;Get real CP/M warm-boot address LD H,(IX+2) ;... LD (WBTADR),HL ;and remember for later LD L,(IX+10) ;Get address of Console output routine LD H,(IX+11) ;... LD (JPCONO+1),HL ;and remember for later LD HL,CONOUT ;Substitute our own routine LD (IX+10),L ;... LD (IX+11),H ;... LD HL,(BDOS+1) ;Get BDOS entry address LD (JPBDOS+1),HL ;and remember it LD HL,JPBDOS ;Substitute our own branch LD (BDOS+1),HL ;... EX (SP),HL ;Get CP/M's CCP address LD (CPMRET),HL ;and remember it EX (SP),HL ;Restore HL-return address LD HL,NWBOOT ;Use our own warm-boot routine LD (IX+1),L ;... LD (IX+2),H ;... LD DE,INIMSG ;Say COP is installed LD C,WSC ;... JP BDOS ;and return to CP/M CCP ; HELLO: DEFB CR,LF,'Console Output Processor Version 1.1' DEFB ' 04/01/89' DEFB CR,LF,'Copyright 1989 by Michael Freeman' DEFB CR,LF,'Program Relocation Module copyright 1984 by ' DEFB 'John Hastwell-Batten' ;Sign-on message DEFB CR,LF,'Enter characters to compress ';Compression message DEFB '(end with ): $' FINMSG: DEFB CR,LF,'Removing Console Output Processor',CR,LF,'$' ;Termination message INIMSG: DEFB CR,LF,'Console Output Processor is installed' DEFB CR,LF,'$' ;Installation announcement SUPMSG: DEFB CR,LF,'Enter characters to suppress ';Suppression prompt DEFB '(end with ): $' ; ; Console Output Processor RSX begins here ; JPBDOS: DEFB 0C3H,0,0 ;Vector to BDOS ; DEFB 'COP' ;Identifying characters ; WBTADR: DEFW 0 ;Holds address of CP/M's warm-boot routine JPCONO: JP $-$ ;Holds jump to Console output routine BTADR: DEFW 0 ;Holds address of BIOS jump to boot CPMRET: DEFW 0 ;Holds return address of CCP ; WBTMSG: DEFB CR,LF,'Console Output Processor active',CR,LF,'$' ;Warm-boot message ; CMPBUF: DEFB CMPLEN,0 ;Compression buffer DEFS CMPLEN ;... SUPBUF: DEFB SUPLEN,0 ;Suppression buffer DEFS SUPLEN ;... ; LSTCHR: DEFB 0 ;Holds last character processed ; CPMSTK: DEFW 0 ;Holds CP/M's stack pointer DEFS 32 ;Local stack LOCSTK: ;... ; ;CONOUT - Console Output Routine ;Preserves all registers ; CONOUT: LD (CPMSTK),SP ;Save current stack pointer LD SP,LOCSTK ;Use local stack PUSH AF ;Save AF-IY PUSH BC ;... PUSH DE ;... PUSH HL ;... PUSH IX ;... PUSH IY ;... LD A,(LSTCHR) ;Get last character processed LD E,A ;and salt it away for checking LD A,C ;Get current character in process LD (LSTCHR),A ;and make it last character processed LD HL,SUPBUF+1 ;Point to number of characters to be ignored LD A,(HL) ;Get number of characters to be suppressed OR A ;Did user specify any? JR Z,CONOU1 ;Nope, either output character or check more LD B,A ;Prepare to go thru suppressed chars CONOU0: INC HL ;Point to a character LD A,(HL) ;Get a character CP C ;Same as current one? JR Z,CONOUX ;Yes, just exit without typing it DJNZ CONOU0 ;No, keep looking CONOU1: LD A,C ;Character not suppressed, get current one CP E ;Different from last character processed? JR NZ,CCOUT ;Yes, type it and exit LD HL,CMPBUF+1 ;Point to # of chars being compressed LD A,(HL) ;Get this number OR A ;Did user specify any? JR Z,CCOUT ;No, just type character and exit LD B,A ;Yes, prepare to go thru compressed chars CONOU2: INC HL ;Point to a character LD A,(HL) ;Get a compressed character CP C ;Same as current one? JR Z,CONOUX ;Yes, don't type it DJNZ CONOU2 ;Check all compressed characters CCOUT: CALL JPCONO ;Type character in C to Console CONOUX: POP IY ;Restore registers POP IX ;... POP HL ;... POP DE ;... POP BC ;... POP AF ;... LD SP,(CPMSTK) ;Restore original stack pointer RET ;and return ; ;NWBOOT - Substitute warm-boot routine ; NWBOOT: LD SP,WBTSTK ;Use our own stack LD HL,(BTADR) ;Restore address in BIOS jumping to warm-boot LD (WBT+1),HL ;... LD HL,JPBDOS ;Reset our BDOS entry vector LD (BDOS+1),HL ;... LD C,RDS ;Reset disk system CALL BDOS ;... LD DE,WBTMSG ;Type warm-boot message LD C,WSC ;to tell user COP RSX is loaded CALL BDOS ;... LD HL,(CPMRET) ;Get CCP entry address JP (HL) ;and go to CCP ; DEFS 16 ;Boot stack WBTSTK: ;... ; END START ;End of program