; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; * * ; * P R N T X T * ; * * ; * A Console/Printer Message Utility Program * ; * * ; * by * ; * Terry Hazen * ; * 21460 Bear Creek Road * ; * Los Gatos, CA 95030 * ; * * ; * Voice.......... (408) 354-7188 * ; * Saratoga RBBS.. (408) 354-5934 * ; * Z-NODE Central. (408) 432-0821 * ; * Zee-Machine.... (408) 245-1420 * ; * * ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ; Revision History ; ---------------- ; ; 11/20/88 Added '$1', '$-1' parameters to increase the ; v1.5 flexibility of parameter passing. '$' still ; represents the entire command line tail, '$1' ; represents the first parameter in the command line ; tail, and '$-1' represents the remainder of the ; command line tail after the first parameter. ; - Terry Hazen ; ; 11/06/87 Bug fix only. Corrected a bug that tried to ; v1.4 interpret a '$' found in the command line tail ; instead of just displaying it. Only Z80, COM, TOP, ; HIS files are affected. DOC, HLP, BOT files remain ; the same (with the version number bumped for ; consistency.) ; - Terry Hazen ; ; 09/14/87 Added command line parameter commands to toggle ; v1.3 display of command line tail on both console and ; printer between upper and lower case. Display of ; regular message text is unaffected. ; - Terry Hazen ; ; 04/05/87 Added '$' command line parameter passing to ; v1.1 message display based on suggestions by Rick ; Charnes. The command line tail will be processed ; the same way as the message text except that it ; will only display '$' instead of interpreting it. ; Therefore you can include things like '^G' to ring ; the bell or strings to clear your screen or to set ; reverse video and restore normal video in your ; command line tail (depending on your terminal, of ; course.) ; - Terry Hazen ; ; 12/03/86 Initial release. ; v1.0 - Terry Hazen ; ;======================================================================= ; ; Overview ; -------- ; ; PRNTXT is a message display utility designed to assist in the ; creation of 'instant' text display COM files which send text ; added to PRNTXT.COM by the user with a word processor such as ; WordStar or contained in the command line tail to the console or ; printer. ; ; See PRNTXT.DOC for more information. ; ;======================================================================= ; ; Assemble with Z80ASM or equivalent (A0>z80asm prntxt) ; ;======================================================================= ; ; IMPORTANT: ; ========= ; ; The PRNTXT code was written in a manner so that when the PRNTXT.COM ; file is called up on a word processor (WordStar 3.0) it will display ; as desired. Modifications to the code, such as the use of JR's in ; place of JPs, and certain arrangements of the code, may result in ; MAJOR changes in the word processor display even though the code will ; operate correctly. For example, you may even be unable to display ; the section where text insertion is to be done! The results of ; small code changes may not be obvious until PRNTXT.COM is displayed ; on a word processor. Therefore, if you make ANY modifications, be ; sure you test them thoroughly before you delete the previous version! ; ;======================================================================= ; ; User Modifiable Equates ; ----------------------- ; CONTROL EQU '^' ; Control character ; PRINTER EQU '\' ; This character toggles the printer ; flag, which, while set, will send ; characters to the printer instead ; of the console. Default is console ; (flag not set). Flag may be toggled ; repeatedly in the text, dividing text ; between printer and console. ; PAGE EQU '~' ; Paging character for console display ; MAXLINE EQU 22 ; Max number of lines before page break ; for console text display only. ; Resets on each page break, whether ; triggered by the PAGE character ; or by MAXLINE ; PARAMCHR EQU '$' ; Command line tail parameter passing ; flag character ; PARAM1 EQU '1' ; First command line parameter ; PARAMX EQU '-' ; Flag representing $-1, the command ; line tail after the first parameter ; CASESW EQU '%' ; Command line tail text upper/lower ; case switch prefix character ; LCSW EQU '>' ; Lower case switch character ; UCSW EQU '<' ; Upper case switch character ;------------------------------------------------------------------ ; ; System Equates ; -------------- ON EQU 0FFH OFF EQU 0 YES EQU 0FFH NO EQU 0 ; ; Version ; ------- ; VERS EQU 15 ; Version number INTERNAL EQU NO ; Internal unreleased version INTVERS EQU 08 ; Internal version number THISMONTH EQU 11 ; Current month THISDAY EQU 22 ; ...day THISYEAR EQU 88 ; ...year ; ; ASCII Characters ; ---------------- ; CR EQU 0DH ; Carriage return LF EQU 0AH ; Line feed CNTRLC EQU 03H ; Control C (quit) CNTRLS EQU 13H ; Control S (pause) EOF EQU 1AH ; End of file marker SPACE EQU 20H ; Space character ; ; CP/M Equates ; ------------ ; BDOS EQU 5 ; Bdos entry point LIST EQU 5 ; List device output function DIRIO EQU 6 ; Direct console i/o function CMDBUF EQU 080H ; Command tail buffer ; ;================================================================ ; ; Program Start ; ------------- ; ORG 100H JP START ; OLDSP: DEFB ' PRNTXT vers ' ; DEFB VERS/10+'0','.' DEFB VERS MOD 10+'0' DEFB ' - Copyright (c) 19' DEFB THISYEAR/10+'0',THISYEAR MOD 10+'0' DEFB ' by Terry Hazen' ; IF INTERNAL ; Display internal revision number DEFB CR,LF,'[Internal Revision ' DEFB INTVERS/10+'0','.',INTVERS MOD 10+'0',', ' DEFB THISMONTH/10+'0',THISMONTH MOD 10+'0','/' DEFB THISDAY/10+'0',THISDAY MOD 10+'0','/' DEFB THISYEAR/10+'0',THISYEAR MOD 10+'0',']' ENDIF ; Internal ; STACK: DEFB CR,LF ; NEWLINE: DEFB LF ; MSG1: DEFB '[more] ',0 ; Console paging message ; MSG2: DEFB 8,8,8,8,8,8,8 ; Delete paging message DEFB ' ' ; and reset the cursor DEFB 8,8,8,8,8,8,8,8,8,0 ; PRNFLAG: DEFB OFF ; Set this flag to send text to printer ; CMDBUFLAG: DEFB OFF ; Set this flag if CMDBUF has text ; PARAMFLAG: DEFB OFF ; Set this flag to display CMDBUF text ; PARAM1FLAG: DEFB OFF ; Set this flag to display first param ; in CMDBUF ; PARAMXFLAG: DEFB OFF ; Set this flag to display CMDBUF - the ; first parameter ; CASEFLAG: DEFB OFF ; Set this flag to display CMDBUF text ; in lower case ;---------------------------------------------------------------- ; START: LD HL,0 ; Save old stack pointer ADD HL,SP LD (OLDSP),HL ; Overwrite ID text LD SP,STACK ; LD HL,CMDBUF ; Point to command tail LD A,(HL) ; Get length of command tail OR A ; Anything there? JP Z,LDBUFFER ; No, so point to buffer ; LD A,ON ; Yes, set flag LD (CMDBUFLAG),A ; LDBUFFER: LD HL,BUFFER ; Point to message text LD B,MAXLINE ; Initialize line count register JP LOOP ; GETCHR: LD A,(HL) ; Get character AND 07FH ; Strip hi-order bit CP 0 ; Check for end RET ; LOOP: PUSH HL ; Save pointer ; LD A,(PARAMFLAG) ; Are we on CMDBUF loop? CP ON ; JP NZ,MSGCHK ; Message loop, so get character ; CALL GETCHR ; CMDBUF loop, so get next character JP Z,PARAMEND ; End of CMDBUF loop, so end it ; LD E,A ; Save character LD A,(PARAM1FLAG) ; '$1'? CP ON LD A,E ; Restore character JP NZ,CASECHK ; Not '$1', display character ; CP SPACE ; Space? JP Z,PARAMEND ; Yes, end of first parameter JP CASECHK ; No, display character ; MSGCHK: CALL GETCHR ; Get next character JP Z,EXIT ; End, so exit ; PARAMCHK: CP PARAMCHR ; Check for parameter character JP NZ,CNTRLCHK ; No, go check for control character ; PARAM: LD A,(CMDBUFLAG) ; Check CMDBUF flag OR A JP Z,PARAMIGN ; No text, so ignore parameter char ; INC HL ; Look at next message character LD A,(HL) CP PARAM1 ; '$1'? JP NZ,PARAMX1 ; No, check for '$-1' ; PARAM1SET: POP DE ; Discard '1' PUSH HL ; Save new message pointer ; LD A,ON ; '$1', so set flag LD (PARAM1FLAG),A JP PARAMSET ; And continue ; PARAMX1: CP PARAMX ; Everything but the first parameter? JP NZ,PARAMSET ; No, continue ; INC HL ; Get next character LD A,(HL) CP PARAM1 ; '$-1'? JP NZ,PARAMSET ; No, continue ; LD A,ON LD (PARAMXFLAG),A ; Set flag ; POP DE ; Discard '-1' PUSH HL ; Save new message pointer ; PARAMSET: LD A,ON ; Set CMDBUF loop flag LD (PARAMFLAG),A ; LD HL,CMDBUF ; Point to command tail INC HL ; Point to first character INC HL PUSH HL ; Save pointer ; LD A,(PARAMXFLAG) ; '$-1'? CP ON JP NZ,LOOP ; No, go process CMDBUF ; SKIP: DEC E ; Number of remaining characters JP NZ,SKIP0 ; POP HL LD A,OFF ; Reset CMDBUF loop flags LD (PARAMFLAG),A LD (PARAM1FLAG),A JP PARAMIGN ; End of CMDBUF already ; SKIP0: LD A,(HL) ; Get character INC HL ; Point to next ; CP SPACE ; Skip to end of first parameter JP NZ,SKIP ; POP DE ; Discard old CMDBUF pointer PUSH HL ; And save new one ; LD A,OFF ; Reset flag LD (PARAMXFLAG),A JP LOOP ; And go process rest of CMDBUF ; PARAMIGN: LD A,PARAMCHR ; Get back parameter character POP HL ; Get back old message pointer PUSH HL ; Save a copy JP CNTRLCHK ; And continue ; PARAMEND: LD A,OFF ; Reset CMDBUF loop flags LD (PARAMFLAG),A LD (PARAM1FLAG),A ; POP HL ; Discard CMDBUF pointer POP HL ; Restore message pointer JP LOOPEND ; Resume text processing ; CASECHK: CP CASESW ; Case switching prefix character? JP NZ,CONVERT ; No, continue ; INC HL ; Point to next character CALL GETCHR ; Get it CP LCSW ; Lower case switch? JP NZ,UCCHK ; No, check for upper case switch LD A,ON ; Set case flag LD (CASEFLAG),A JP NEWCHR ; Get next character ; UCCHK: CP UCSW ; Upper case switch? JP NZ,GETLAST ; No, just display the '%' LD A,OFF ; False alarm, so reset the flag LD (CASEFLAG),A ; and continue ; NEWCHR: POP HL ; Get back original pointer INC HL ; Point to the next text character INC HL JP LOOP ; And go process it ; GETLAST: DEC HL ; Point to the original character CALL GETCHR ; And go get it ; CONVERT: PUSH AF ; Save it LD A,(PARAMFLAG) ; CMDBUF loop? CP ON JP NZ,SAMECASE ; No, leave it alone ; LD A,(CASEFLAG) CP ON ; Convert to lower case? JP NZ,SAMECASE ; No, leave it alone ; POP AF ; Restore character CP '[' ; Make sure it's a cap letter first JP NC,CNTRLCHK ; No, leave it alone CP 'A' JP C,CNTRLCHK ; No, leave it alone ADD A,20H ; Make it lower case JR CNTRLCHK ; And continue on ; SAMECASE: POP AF ; Restore character ; CNTRLCHK: CP CONTROL ; Is it the control character? JP NZ,PRNSWCHK ; No, check for printer toggle character ; POP HL ; Get message pointer INC HL ; Point to next character PUSH HL ; Save pointer CALL GETCHR ; Get next character JP Z,EXIT ; Nothing there, so exit SUB 40H ; Synthesize the control character ; PRNSWCHK: CP PRINTER ; Printer switch character JP NZ,PRNCHK ; No, check printer flag ; TOGGLE: LD A,(PRNFLAG) ; Point to printer flag CPL ; Toggle bits LD (PRNFLAG),A ; And store the new flag JP LOOPEND ; And do it all again ; PRNCHK: PUSH AF ; Save character LD A,(PRNFLAG) ; Check printer flag CP ON ; Send character to printer? JP Z,LISTOUT ; Yes POP AF ; Otherwise, restore character ; PAGECHK: CP PAGE ; Is it the page character? JP Z,PAGING ; Yes, then pause ; LINECHK: PUSH HL ; Save pointer LD HL,NEWLINE ; Get LF this way for better .com file ; display on word processor - helps ; keep the garbage display to one line ; for some reason CP (HL) ; Is character a LF? POP HL ; Restore pointer JP NZ,SHOWIT ; No, go display it ; LINECNT: DEC B ; Adjust line count JP Z,PAGEIT ;----------------------------------------------------------------------- ; SHOWIT: CALL CHRDISP ; Display character ;----------------------------------------------------------------------- ; KEYCHK: CALL CONIN ; Check for key pressed JP Z,LOOPEND ; If no key then continue CP CNTRLC ; Is it a ^C? JP Z,EXIT ; If so, exit CP CNTRLS ; Is it ^S? CALL Z,PAUSE ; Yes, pause for keypress ; LOOPEND: POP HL ; Restore pointer INC HL ; Point to next character JP LOOP ; And go around again ; EXIT: LD HL,(OLDSP) ; Fix up stack pointer LD SP,HL CALL CONIN ; Mop up any stray characters pending RET ; And quit ; DEFB 'PRNTXT' ; Text used here to force a good .com ; file display on the word processor ;================================================================ ; ; Subroutines ; ----------- ; CONIN: PUSH HL ; Save pointers PUSH BC LD E,0FFH ; Conin LD C,DIRIO ; Direct console routine CALL BDOS ; POP BC ; Restore pointers POP HL OR A ; Set flags RET ; ; PAUSE: CALL CONIN ; Check for key pressed JP Z,PAUSE ; Loop until key pressed CP CNTRLC ; Is it a ^C? JP Z,EXIT ; If so, exit RET ; PAGEIT: CALL CHRDISP ; Display character ; PAGING: PUSH HL ; Save message text pointer LD HL,MSG1 ; Point to the paging message LD A,(HL) ; Get first character CALL DISPLAY ; Print message CALL PAUSE ; Wait for keypress LD HL,MSG2 ; Point to blankout message LD A,(HL) ; Get first character CALL DISPLAY ; Wipe out [more] msg LD B,MAXLINE ; Initialize line counter POP HL ; Restore pointer INC HL ; Bump it JP LOOPEND ; And return to the message text RET ; CHRDISP: PUSH HL ; Save pointers PUSH BC LD E,A ; Move character to E LD C,DIRIO ; Console out CALL BDOS POP BC ; Restore pointers POP HL RET ; DISPLAY: CALL CHRDISP ; Display character INC HL ; Point to next character LD A,(HL) ; Get next character CP 0 ; End? JP NZ,DISPLAY ; Not yet RET ; Go back for more ; LISTOUT: POP AF ; Restore character PUSH HL ; Save pointers PUSH BC LD E,A ; Character in E LD C,LIST ; List device out function CALL BDOS ; Print it POP BC ; Restore pointers POP HL JP KEYCHK ; And continue ; INSERTMSG: DEFB CR,LF,LF DEFB '- Insert your text starting on the next line. ' DEFB 'RETAIN THE ENDING ^@:' DEFB CR,LF ;================================================================ ; ; Message space starts here, and is as large as TPA-512 bytes ; ;================================================================ ; BUFFER: DEFB CR,LF ; Add blank line to make ; ; insertion easier DEFB 0,CR,LF,EOF ; Force a NULL and an EOF ; ; marker to keep the WordStar END ; file clean