;======================================================================= ; ; ; 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 ; Zee-Machine.... (408) 245-1420 ; Ladera Znode... (213) 670-9465 ; ;======================================================================= ; ; Revision History ; ---------------- ; ; 10/05/91 Added configurable printer BIOS status check. Converted ; v1.6 i/o from direct console i/o to BIOS i/o. ; - Terry Hazen ; ; 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.HLP for more information. ; ;======================================================================= ; ; IMPORTANT: ; ========= ; ; The PRNTXT code was written in a manner so that when the PRNTXT.COM ; file is called up on a word processor (such as WordStar), it will ; produce an accurate display. PRNTXT.COM may NOT be edited with ZDE, ; which filters all hi bits. The resulting edited COM file will not ; work and may cause undetermined actions! ; ; 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! ; ;======================================================================= ; ; Assemble directly to a COM file with Z80ASM or equivalent: ; ; A0>z80asm prntxt ; ; When assembling PRNTXT, you will be asked to specify which type of ; file you with to assemble. Choose 1 if you want to assemble the ; normal COM file. ; ; 2 will produce a file that quits at the point of normal message ; insertion, suitable for renaming to PRNTXT.TOP. ; ; 3 will produce a file that contains the null that is used to ; terminate the message, suitable for renaming to PRNTXT.BOT. ; ; You may use CONCAT.COM to produce a message COM file from a message ; text file and the files PRNTXT.TOP and PRNTXT.BOT: ; ; A0>concat message.com=prntxt.top,message.ws,prntxt.bot ; ; 4 will produce a file containing a '$' as the message text, ; suitable for renaming to ECHO.COM. ; .accept ' Enter 1=COM file, 2=Top Segment, 3=Bottom Segment, 4=ECHO: ',type ;======================================================================= ; ; System Equates ; on equ 0ffh off equ 0 yes equ 0ffh no equ 0 ; ; Version ; vers equ 16 ; Version number month equ 10 ; Current month day equ 06 ; Day year equ 91 ; Year ; ; ASCII Characters ; cntrlc equ 3 ; ^C bell equ 7 ; Bell bs equ 8 ; Backspace cr equ 0dh ; Carriage return lf equ 0ah ; Line feed cntrls equ 13h ; ^S eof equ 1ah ; End of file marker space equ 20h ; Space character ; ; CP/M Equates ; cmdbuf equ 080h ; Command buffer ;================================================================ ; ; Program Start ; entry: if type=1 or type=2 or type=4 ; jp start ; ; Configuration area ; ; lstchk: db on ; ON to use BIOS printer status check ; control:db '^' ; Control character flag ; printer:db '\' ; 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: db '~' ; Paging character for console display ; maxline:db 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:db '$' ; Command line tail parameter passing ; flag character ; casesw: db '%' ; Command line tail text upper/lower ; case switch prefix character ; lcsw: db '>' ; Lower case switch character ; ucsw: db '<' ; Upper case switch character ; db cr db 'PRNTXT' ; Default ZCNFG filename db vers/10+'0',vers mod 10+'0' ; db ' - ' db month/10+'0',month mod 10+'0','/' db day/10+'0',day mod 10+'0','/' db year/10+'0',year mod 10+'0' ; newline:db lf ; msg1: db '[more] ',0 ; Console paging message ; msg2: db bs,bs,bs,bs,bs,bs,bs ; Delete paging message db ' ' ; and reset the cursor db bs,bs,bs,bs,bs,bs,bs,bs,bs,0 ; prnflg: db off ; ON to send text to printer cbuflg: db off ; ON if CMDBUF has text parflg: db off ; ON to display CMDBUF text par1flg:db off ; ON to display first param in CMDBUF parxflg:db off ; ON to display first CMDBUF parameter caseflg:db off ; ON to display CMDBUF text in lower case ; noptrmsg: db cr,lf,'No Printer!',bell,cr,lf,0 ;---------------------------------------------------------------- ; start: ld (stack),sp ; 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 (cbuflg),a ; ldbuffer: ld a,(maxline) ; Set line count ld b,a ld hl,buffer ; Point to message text ; loop: push hl ; Save pointer ld a,(parflg) ; Are we on CMDBUF loop? or a jp z,msgchk ; No, 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,(par1flg) ; '$1'? or a ld a,e ; Restore character jp z,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: push hl ld hl,paramchr ; Check for parameter character cp (hl) pop hl jp nz,cntrlchk ; No, go check for control character ; param: ld a,(cbuflg) ; 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 '1' ; '$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 (par1flg),a jp paramset ; And continue ; paramx1:cp '-' ; Everything but the first parameter? jp nz,paramset ; No, continue ; inc hl ; Get next character ld a,(hl) cp '1' ; '$-1'? jp nz,paramset ; No, continue ; ld a,on ld (parxflg),a ; Set flag ; pop de ; Discard '-1' push hl ; Save new message pointer ; paramset: ld a,on ; Set CMDBUF loop flag ld (parflg),a ; ld hl,cmdbuf ; Point to command tail inc hl ; Point to first character inc hl push hl ; Save pointer ; ld a,(parxflg) ; '$-1'? or a jp z,loop ; No, go process CMDBUF ; skip: dec e ; Number of remaining characters jp nz,skip0 ; pop hl xor a ; Reset CMDBUF loop flags ld (parflg),a ld (par1flg),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 ; xor a ; Reset flag ld (parxflg),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: xor a ; Reset CMDBUF loop flags ld (parflg),a ld (par1flg),a ; pop hl ; Discard CMDBUF pointer pop hl ; Restore message pointer jp loopend ; Resume text processing ; casechk:push hl ld hl,casesw ; Case switching prefix character? cp (hl) pop hl jp nz,convert ; No, continue ; inc hl ; Point to next character call getchr ; Get it push hl ld hl,lcsw ; Lower case switch? cp (hl) pop hl jp nz,ucchk ; No, check for upper case switch ; ld a,on ; Set case flag for lower case ld (caseflg),a jp newchr ; Get next character ; ucchk: push hl ld hl,ucsw ; Upper case switch? cp (hl) pop hl jp nz,getlast ; No, just display the '%' ; xor a ; Reset case flag for upper case ld (caseflg),a ; 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:ld c,a ; Save character ld a,(parflg) ; CMDBUF loop? or a ld a,c ; Restore character jp z,cntrlchk ; No, leave it alone ; ld a,(caseflg) or a ; Convert to lower case? ld a,c ; Restore character jp z,cntrlchk ; No, leave it alone ; 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 ; cntrlchk: push hl ld hl,control ; Control character flag? cp (hl) pop hl 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 ; and 1fh ; Synthesize the control character ; prnswchk: push hl ld hl,printer ; Printer switch character cp (hl) pop hl jp nz,prnchk ; No, check printer flag ; ld a,(prnflg) ; Point to printer flag cpl ; Toggle flag ld (prnflg),a ; Save new flag or a ; Setting flag? jp z,loopend ; No ; call ptrrdy ; Yes, check for printer jp nz,loopend ; Ok jp noptr ; No printer ; prnchk: ld c,a ; Save character ld a,(prnflg) ; Check printer flag or a ; Send character to printer? ld a,c ; Restore character jp z,pagechk ; No ; listout:push hl ; Save pointers push de push bc ld de,15-3 ; BIOS list out call bios pop bc ; Restore pointers pop de pop hl jp keychk ; And continue ; pagechk:push hl ld hl,page ; Is it the page character? cp (hl) pop hl jp z,paging ; Yes, then pause ; linechk:push hl ; Save pointer ld hl,newline ; Line feed? cp (hl) pop hl ; Restore pointer jp nz,showit ; No, go display it ; linecnt:dec b ; Adjust line count jp z,pageit ;----------------------------------------------------------------------- ; showit: call cout ; Display character ;----------------------------------------------------------------------- ; keychk: call const ; Look for key jp z,loopend ; Nothing pending ; call conin ; Get key 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 ; noptr: ld hl,noptrmsg call getchr call display ; Display no-printer message and quit ; exit: ld hl,80h ld de,8000h ld bc,80h ldir ld sp,(stack) ; Restore stack pointer ret ;================================================================ ; ; Return keyboard character in A ; conin: push hl ; Save pointers push de push bc ld de,9-3 ; BIOS console input call bios pop bc ; Restore pointers pop de pop hl ret ; ; Get console status ; const: push hl ; Save pointers push de push bc ld de,6-3 ; BIOS console status call bios pop bc ; Restore pointers pop de pop hl or a ; Set flags ret ; ; ; Enter with character in A ; cout: push hl ; Save pointers push de push bc ld c,a ; Character in C ld de,12-3 ; BIOS console out call bios pop bc ; Restore pointers pop de pop hl ret ; pause: call conin ; Wait for keypress cp cntrlc ; Is it a ^C? jp z,exit ; If so, exit ; ret ; pageit: call cout ; 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 hl,maxline ; Initialize line counter ld b,(hl) pop hl ; Restore pointer inc hl ; Bump it jp loopend ; And return to the message text ; getchr: ld a,(hl) ; Get character and 07fh ; Strip hi-order bit or a ; Check for end ret ; display:call cout ; Display character in A inc hl ; Point to next character ld a,(hl) ; Get next character or a ; End? ret z ; Quit at 0 jp display ; ; Check to see if printer is ready ; ptrrdy: ld a,(lstchk) ; Use BIOS list status check? or a ret z ; No, just fire away blindly ; push hl ; Save registers push de push bc ; call blstat ; Check printer status jp z,blsdun ; Whoops! No printer ; call lout ; Send CR to flush buffer call blstat ; And try again ; blsdun: pop bc ; Restore registers pop de pop hl ret ; blstat: ld de,45-3 ; BIOS list status call bios or a ; Set status flag ret ; lout: ld c,cr ; Send CR ld de,15-3 ; bios: ld hl,(0001) ; BIOS address add hl,de jp (hl) ; Call function ; insertmsg: db cr,lf,lf db '- Insert your text starting on the next line. ' db 'RETAIN THE ENDING ^@:' stack: db cr,lf ;================================================================ ; ; Message space starts here, and is as large as TPA-xxx bytes ; ;================================================================ ; buffer: endif ; if type=4 ; For ECHO.COM db '$' endif ; if type=1 db cr,lf ; Add blank line to make insertion easier endif ; if type=1 or type=3 or type=4 db 0,cr,lf ; Add a terminating NULL endif ; ; Finish the rest of the record with eof's ; ds 128-($-entry) and 127,eof ; end