; JUSTIFY.Z80 ; ; Justifies ASCII and WordStar text files. ; Vers equ 13 SubVers equ ' ' ; ; HISTORY: ; ; Version 1.3 -- September 30, 1991 -- Gene Pizzetta ; Now checks for ambiguous filenames before doing anything. Made ; display of line count progress reports a configurable option. ; ; Version 1.2 -- September 10, 1991 -- Gene Pizzetta ; Separate assembly without video highlighting no longer supported, ; but now uses ZSLIB HIVON and HIVOFF instead of much larger VLIB ; routines. Since size was no longer a problem, some of the code ; was uncrunched to make it more straightforward. ; ; Version 1.1b -- September 4, 1991 -- Bruce Morgen ; Tweaked code and used VLIB11 (slower, but smaller when only a ; few routines are called). Video-enabled version now 32 records, ; vanilla version now 30 records. ; ; Version 1.1 -- August 31, 1991 -- Gene Pizzetta ; Disassembled enough to change to a relocatable file. Changed to ; Z80 opcodes to partially compensate for space used by additional ; features. Replaced some routines with library routines. Removed ; requirement for output filename. Changed key options to command ; line entry. Fixed bug that was eliminating soft hyphens at the ; end of a line, not just in the middle of the line. Changed some ; messages to make them more descriptive. Added DU support, ; intelligent usage screen, error flag setting, error handler ; invocation, quiet mode, command line column count entry, and ZCNFG ; configuration. Under ZSDOS and ZDDOS file create date stamps are ; transferred to the new file. ; ; Version 1.0 -- March 22, 1988 -- Irv Hoff ; Original release based on FILT7. ; ; Portions copyright (c) 1988, Irvin M. Hoff ; ; Please report any problems or suggestions: ; ; Gene Pizzetta ; 481 Revere St. ; Revere, MA 02151 ; ; Voice: (617) 284-0891 ; Newton Centre Z-Node: (617) 965-7259 ; Ladera Z-Node Central: (213) 670-9465 ; .request zslib,z3lib,syslib ; extrn eatspc,eatnspc,getstp,setstp,gcomnam,comnam ; ZSLIB extrn hvon,hvoff,hvtinit,hvdinit ; ZSLIB extrn z3init,zsyschk,getquiet,puter2,inverror ; Z3LIB extrn eprint,epstr,cout,condin,pafdc,phldc,pfn2 ; SYSLIB extrn bdos,isdigit,eval10,retud,logud,initfcb,codend ; SYSLIB ; BdosE equ 05h ; BDOS entry CpmFcb equ 5Ch ; default file control block AltFcb equ 6Ch ; alternate file control block CpmDma equ 80h ; default DMA buffer BufSiz equ 128*128 ; buffer size (16K) ; ; BDOS Functions ; FOpen equ 15 ; open file FClose equ 16 ; close file FErase equ 19 ; delete file FRead equ 20 ; read sequential FWrite equ 21 ; write sequential FMake equ 22 ; create file FName equ 23 ; rename file SetDma equ 26 ; set DMA address ; ; ASCII ; CtrlC equ 03h ; ^C TAB equ 09h ; tab LF equ 0Ah ; line feed FF equ 0Ch ; form feed CR equ 0Dh ; carriage return CtrlZ equ 1Ah ; ^Z (CP/M EOF) ; jp Start ; db 'Z3ENV',1 Z3EAdr: dw 0 ; ; Configuration area . . . ; dw 0 ; filler db 'JUST' ; for ZCNFG db Vers/10+'0',Vers mod 10+'0',' ' ColDft: db 65 ; line width for justifying SpcFlg: db 0 ; FFh=justify lines starting with space, 0=no LngFlg: db 0 ; FFh=justify regardless of length, 0=no FFFlag: db 0 ; FFh=retain form feeds, 0=no QtFlag: db 0 ; FFh=default to quiet mode LinFlg: db 0 ; 0=show progress reports, FFh=don't RemSpc: db 3 ; nbr of spaces to fill last line of paragraph LnStep: db 0Fh ; rate of screen updates (0F, 1F, or 3F) ; ; Program begins . . . ; Start: ld hl,(Z3EAdr) call zsyschk ; ZCPR3? ret nz ; (nope) call z3init ; initialize environment ld (Stack),sp ; save stack pointer ld sp,Stack ; ..and set up new stack call codend ; set up buffers ld (BufBeg),hl ld de,BufSiz add hl,de ld (BufEnd),hl ld hl,BufOff ; initialize data segment ld b,OutBuf-BufOff xor a FillLp: ld (hl),a inc hl djnz FillLp call hvtinit ; initialize terminal call getquiet ; check quiet flag rra sbc a,a jr nz,SetQt ld a,(QtFlag) SetQt: ld (OpQFlg),a ld hl,DftNam call gcomnam ; get disk name ld a,(CpmFcb+1) cp ' ' jp z,Usage cp '/' jp z,Usage ld hl,AltFcb+1 ; check for output file ld bc,11 ld a,(hl) cp ' ' jr z,Start1 cp '/' jr nz,Start2 Start1: ld hl,JusTyp ; none, so use JUS filetype ld de,OutFn+8 ld c,3 ldir ld hl,CpmFcb+1 ; ..and source filename ld c,8 ; Start2: ld de,OutFn ; move final filename to storage ldir ld hl,OutFn ld de,OutFcb+1 ; move to output FCB ld c,8 ldir ld hl,TmpTyp ; with $$$ filetype ld c,3 ldir ld ix,CpmFcb ; get input and output DU's call GetDU ld (InDir),bc ld ix,AltFcb call GetDU ld (OutDir),bc call GetOpt ; ld bc,(InDir) ; get DU ld de,CpmFcb+1 ; point to filename ld a,(OpQFlg) or a jr nz,SkipIF call eprint db ' Justifying ',0 call PrtFn SkipIF: call InDU ; set up of opening source file push de ; point HL to filename pop hl call chkamb dec de ; point to source FCB call initfcb ld c,FOpen call BdosE inc a jr nz,OpenOK ld a,10 ; error code call eprint db ' File not found.',0 jp Exit ; OpenOK: ld hl,0 ld (BufOff),hl ; zero buffer offset ld a,(OpQFlg) or a jr nz,SkipOF ld bc,(OutDir) ld de,OutFn ; point to final output filename call eprint db ' to ',0 call PrtFn call eprint db ' ..',0 SkipOF: call OutDU ld de,OutFcb push de ; point HL to filename pop hl inc hl call chkamb call initfcb ld c,FErase ; blind erase file call bdos ld c,FMake ; create new file call BdosE inc a jr nz,MakeOK ld a,11 ; error code call eprint db ' No directory space.',0 jp Abort ; MakeOK: ld a,(OpQFlg) or a jr nz,SkipCR call eprint db CR,LF,0 SkipCR: ld de,OutBuf ld b,255 L0508: push bc push de ld c,SetDma ld de,CpmDma call bdos call InDU ld c,FRead ld e,CpmFcb ; D = 0 call BdosE pop de ; DE = address of OutBuf pop bc ; B = 255 or a jr z,ReadOK cp 1 jp z,Done ; end of file ld a,4 ; error code call eprint db ' File read error.',0 jp ErExit ; ReadOK: ld hl,CpmDma ; move bytes from input buf to output buf L054F: ld a,(L0F28) ; this is the loop re-entry point or a jp nz,L0613 ld a,(hl) ; get character cp 8Dh ; soft carriage return? call z,IncSCr bit 7,a ; high bit character? call nz,IncHBt ; (yes, count it) and 7Fh ; zero high bit cp 7Fh ; delete character? jp z,DoIt cp CtrlZ ; ^Z ? jp z,Done ; (end of file) cp ' ' ; control character? jr nc,NmlChr ; (no) cp CR ; carriage return? jr z,NmlChr cp LF ; line feed? jr z,NmlChr cp FF ; form feed? jp z,DoFF cp TAB ; tab? jr z,NmlChr cp 0Fh ; hard space? jr z,NmlChr cp 1Fh ; soft hyphen? jp nz,DoCtrl ; (handle other control characters) ; NmlChr: inc b ld c,a ld a,b cp 0FFh ld a,c jr nc,L05DD cp 0Fh ; binding space? jp z,DoBSpc ; (yes, handle it) cp ' ' ; space? jr nz,NotSpc ; (no) L05A4: push hl ld hl,(OSpCnt) ; yes, increment space count inc hl ld (OSpCnt),hl pop hl NotSpc: cp TAB ; a tab? jr nz,NotTab ; (no) push hl ld hl,(TabCnt) ; yes, increment tab count inc hl ld (TabCnt),hl pop hl XpndLp: ld a,' ' ; expand tab to spaces ld (de),a inc de inc b ld a,b and 7 or a jr nz,XpndLp dec b jp DoIt ; NotTab: call L085A ld (de),a inc de cp LF jp nz,DoIt call condin call nz,ChkCon jr L05E4 ; L05DD: ld a,CR ld (de),a inc de ld a,LF ld (de),a L05E4: dec b jr z,L0608 dec de dec de L05EA: dec de ld a,(de) cp 1Fh ; soft hyphen? call z,DoSHy ; (yes, handle it) cp ' ' jr z,L05F6 cp TAB jr nz,L0600 L05F6: call IncTSp djnz L05EA dec de ; L0600: inc de L0601: ld a,CR ld (de),a inc de ld a,LF ld (de),a L0608: ld a,b or a jr z,L0613 ld (L0F28),a jp DoIt ; L0613: ld a,(hl) inc de ld (de),a push hl call CkPrgs ; xor a ld a,L0F2B-L0F26 ld hl,L0F26 zrolp1: ld (hl),0 inc hl dec a jr nz,zrolp1 ld hl,OutBuf ld a,b ld (L0F27),a or a jp z,L0791 L0638: ld a,(hl) cp ' ' jr nz,L0658 inc hl dec b ld a,(hl) cp ' ' jr nz,L0651 L0646: inc hl dec b ld a,(hl) cp ' ' jr z,L0646 jr L0658 ; L0651: ld a,(L0F29) inc a ld (L0F29),a L0658: inc hl djnz L0638 ld a,(L0F27) ld b,a ld a,(OpCFlg) sub b jp z,L0791 jp c,L0791 ld (L0F26),a ld b,a ; last line of paragraph ld a,(RemSpc) ; do we fill it? cp b ld bc,0 jr nc,L067F ; (no) dec hl ld b,(hl) inc hl inc hl inc hl ld c,(hl) L067F: ld hl,OutBuf ld a,(hl) cp ')' jp z,L0772 cp ';' jp z,L078D cp ']' jr nz,L06A4 inc hl ld a,(hl) cp ' ' dec hl jr z,L06A4 ld a,(L0F26) inc a ld (L0F26),a jr L06E5 ; L06A4: ld a,c cp CR jp z,L078D cp LF jp z,L078D cp ' ' jp z,L078D cp ';' jp z,L078D cp CtrlZ jp z,L078D cp FF jr nz,L06D8 ld a,b cp '.' jp z,L078D cp '?' jp z,L078D cp ':' jp z,L078D cp '!' jp z,L078D L06D8: ld a,(OpSFlg) or a jr nz,L06E5 ld a,(hl) cp ' ' jp z,L078D L06E5: ld a,(L0F29) or a jp z,L078D ld b,a ld a,(L0F26) cp b jr z,L0753 jr nc,L0714 ld c,a ld a,b sub c ld b,a dec a ; 1? jr z,L0736 dec a ; 2? jr z,L075A ld a,(L0F24) or a jr z,L075A dec a ; 1? jr z,L077D jr L0767 ; L0714: ld a,(OpLFlg) or a jr z,L078D ld a,(L0F26) L071E: sub b ld c,a ld a,(L0F25) inc a ld (L0F25),a ld a,c cp b jr nc,L071E ld (L0F26),a ld c,a ld a,b sub c ld b,a jr L075A ; L0736: ld a,(L0F24) or a jr nz,L0748 inc a ld (L0F2B),a inc a ld (L0F24),a jr L079E ; L0748: xor a ld (L0F2B),a inc a ld (L0F24),a jr L079E ; L0753: xor a ld (L0F2B),a jr L079E ; L075A: ld a,1 ld (L0F24),a ld a,b rra ld (L0F2B),a jr L079E ; L0767: xor a ld (L0F24),a inc a ld (L0F2B),a jr L079E ; L0772: ld a,(L0F26) inc a rra ld (L0F2A),a jr L078D ; L077D: ld a,b dec a ld (L0F2B),a jr z,L079E ld a,2 ld (L0F24),a jr L079E ; L078D: xor a ld (L0F24),a L0791: xor a ld (L0F26),a ld (L0F25),a ld (L0F29),a ld (L0F2B),a L079E: ld hl,OutBuf ld a,(hl) cp ';' jr z,L07BE cp ')' jr z,L07BE cp ']' jr nz,L07BF inc hl ld a,(hl) cp ' ' jr nz,L0822 dec hl ld a,' ' jr L07D8 ; L07BE: inc hl L07BF: ld a,(L0F2A) or a jr z,L07D2 dec a ld (L0F2A),a ld a,' ' call L0825 jr L07BF ; L07D2: ld a,(hl) cp ' ' jr nz,L0822 L07D8: call L0825 inc hl ld a,(hl) cp ' ' jr nz,L07EF L07E2: call L0825 inc hl ld a,(hl) cp ' ' jr nz,L0822 jr L07E2 ; L07EF: push af ld a,(L0F25) or a jr z,L0803 ld c,a L07F8: ld a,' ' push bc call L0825 pop bc dec c jr nz,L07F8 L0803: ld a,(L0F2B) or a jr z,L0811 dec a ld (L0F2B),a jr L0821 ; L0811: ld a,(L0F26) or a jr z,L0821 dec a ld (L0F26),a ld a,' ' call L0825 ; L0821: pop af L0822: jr L082B ; L0825: push hl call L0967 pop hl ret ; L082B: call L0825 inc hl cp LF jr nz,L07D2 ld de,OutBuf ld b,0FFh pop hl ld a,(L0F2B) or a ret nz ld a,LF ld (L0F2C),a ld a,(L0F27) or a jp nz,L054F ; DoIt: ld (L0F2C),a inc l jp z,L0508 jp L054F ; L085A: ld c,a ld a,(L0F2C) cp CR ld a,c jr nz,L087A cp LF ret z pop af call IncSCr dec b ld a,CR jr DoIt ; ld a,l or a jr z,L0877 dec l L0877: ld a,LF ret ; L087A: cp LF ; line feed? ret nz ; (no) ld a,CR ; yes, put a carriage return ld (de),a inc de push hl ld hl,(OphCnt) ; increment orphan line feed count inc hl ld (OphCnt),hl pop hl ld a,c ret ; IncSCr: push hl ; increment soft carriage return count ld hl,(SCrCnt) inc hl ld (SCrCnt),hl pop hl ret ; DoCtrl: push hl ; increment control character count ld hl,(CtlCnt) inc hl ld (CtlCnt),hl pop hl jr DoIt ; DoFF: ld a,(OpFFlg) ; are we eliminating form feeds? or a ld a,FF jr z,DoIt ; (yes) push hl ld hl,(FFCnt) ; increment form feed count inc hl ld (FFCnt),hl push bc push de call L0967 pop de pop bc pop hl jr DoIt ; IncHBt: push hl ; increment count of high bit characters ld hl,(HBtCnt) inc hl ld (HBtCnt),hl pop hl ret ; DoSHy: ld a,'-' ; handle soft hyphens at end of line ld (de),a ; make it a "real" hyphen push hl ld hl,(SHyCnt) ; increment count of soft hyphens fixed inc hl ld (SHyCnt),hl pop hl ret ; DoBSpc: push hl ; handle binding space ld hl,(BSpCnt) inc hl ld (BSpCnt),hl pop hl ld a,' ' jp L05A4 ; IncTSp: push hl ; increment count of trailing spaces ld hl,(TSpCnt) inc hl ld (TSpCnt),hl pop hl ret ; IncLns: ld hl,(LinCnt) inc hl ld (LinCnt),hl ret ; IncNSp: ld hl,(NSpCnt) inc hl ld (NSpCnt),hl ret ; ErExit: push af ; save error code call OutDU ld de,OutFcb ld c,FClose ; close output file call bdos ld c,FErase ; ..and erase it call BdosE pop af ; retrieve error code Abort: push af call InDU ld de,CpmFcb ld c,FClose call BdosE pop af Exit: call puter2 ; set error flag ld b,a ; put error code in B or a call nz,inverror ; (if error, call error handler) call hvdinit ; de-initialize terminal ld sp,(Stack) ; restore stack ret ; return to Z-System ; CkPrgs: ld a,(LinFlg) or a ret nz ; (no progress reports) ld a,(OpQFlg) or a ret nz ld hl,(LinCnt) ; compare number of lines so far ld a,(LnStep) ; ..with step rate and l ret nz ; (not there yet) ld a,CR call cout ld hl,(LinCnt) ; print line progress report jp phldc ; L0967: cp ' ' call z,IncNSp cp LF call z,IncLns push af ld hl,(BufEnd) ; get buffer end address in HL L097A: ex de,hl ; end address in DE ld hl,(BufOff) ; buffer offset in HL ld a,l ; end of buffer? sub e ld a,h sbc a,d jr c,L09E4 ; (?) ld hl,0 ; zero buffer offset ld (BufOff),hl L098B: ex de,hl ; buffer offset in DE ld hl,(BufEnd) ; buffer end in HL ld a,e ; end of buffer? sub l ld a,d sbc a,h jr nc,L09D6 ; (?) ld hl,(BufBeg) ; get buffer start address add hl,de ; add offset ex de,hl ; pointer in DE ld c,SetDma call BdosE call OutDU ld de,OutFcb ld c,FWrite call BdosE or a jr nz,DskFul ld de,128 ; add sector to offset ld hl,(BufOff) add hl,de ld (BufOff),hl jr L098B ; DskFul: ld a,11 ; error code call eprint db ' Disk full.',0 jp ErExit ; L09D6: ld c,SetDma ld de,CpmDma call BdosE ld hl,0 ld (BufOff),hl ; zero buffer offset L09E4: ex de,hl ; buffer offset in DE ld hl,(BufBeg) ; get buffer address add hl,de ; add offset ex de,hl ; pointer address in DE pop af ; recover character ld (de),a ; store in buffer ld hl,(BufOff) ; get offset inc hl ; increment offset ld (BufOff),hl ; and store it ret ; ChkCon: sub CtrlC ; ^C ? ret nz ; (anything else, continue) cpl ; error code (0FFh) call eprint db ' Aborted.',0 jp ErExit ; Done: ld (L0F2B),a ; end of file, so finish up inc de inc b call nz,L05DD ld a,(LinFlg) or a jr nz,L0A82 ; (no progress reports) ld a,(OpQFlg) or a jr nz,L0A82 ld a,CR call cout ld hl,(LinCnt) call phldc L0A82: ld hl,(BufOff) ; check for end of sector ld a,l and 7Fh jr nz,L0A8E ; (?) ld (BufEnd),hl L0A8E: ld a,CtrlZ push af call L0967 pop af jr nz,L0A82 call InDU ld de,CpmFcb ld c,FClose call bdos call OutDU ld de,OutFcb call BdosE inc a jr nz,Finish ld a,4 ; error code call eprint db ' Cannot close output file.',0 jp ErExit ; Finish: call DatStp ; move date stamps ld a,(OpQFlg) or a jp nz,Finis1 ld a,CR call cout ld hl,(LinCnt) call phldc ; print total lines call eprint db ' lines',CR,LF,0 ld hl,(OSpCnt) call phldc ; print count of original spaces call eprint db ' original spaces',CR,LF,0 ld hl,(TabCnt) call phldc ; print count of original tabs call eprint db ' tabs expanded',CR,LF,0 ld hl,(NSpCnt) call phldc ; print count of new spaces call eprint db ' current spaces',CR,LF,LF,0 ld hl,(FFCnt) call phldc ; print count of form feeds call eprint db ' form feeds present',CR,LF,0 ld hl,(HBtCnt) call phldc ; print high bit character count call eprint db ' high bits zeroed',CR,LF,0 ld hl,(CtlCnt) call phldc ; print control character count call eprint db ' control characters deleted',CR,LF,0 ld hl,(OphCnt) call phldc ; print orphan line feed count call eprint db ' orphan line feeds fixed',CR,LF,0 ld hl,(TSpCnt) call phldc ; print trailing spaces count call eprint db ' trailing spaces deleted',CR,LF,0 ld hl,(SCrCnt) call phldc ; print soft carriage return count call eprint db ' soft carriage returns fixed',CR,LF,0 ld hl,(SHyCnt) call phldc ; print soft hyphen count call eprint db ' soft hyphens fixed',CR,LF,0 ld hl,(BSpCnt) call phldc ; print binding space count call eprint db ' binding spaces fixed',0 Finis1: ld hl,OutFn ; move original filename ld de,OutFcb+1 ; to rename filename ld bc,11 ldir ld hl,OutFn ; and move it to rename filename ld de,OutFcb+17 ld c,8 ldir ld hl,BakTyp ; move filetype BAK (DE = OutFcb+25) ld c,3 ldir ld de,OutFcb+16 xor a ld (de),a ; zero drive byte (just in case) ld c,FErase ; blind erase any existing BAK file call bdos ld de,OutFcb ; Blind rename any existing file to fn.BAK ld c,FName call BdosE ld hl,TmpTyp ; move $$$ type to output FCB ld de,OutFcb+9 ld bc,3 ldir ld hl,OutFn+8 ; move final filetype to rename filetype ld de,OutFcb+25 ld c,3 ldir ld de,OutFcb ld c,FName call BdosE xor a ; error code (no error) jp Exit ; ; ChkAmb -- check for ambiguous filename at address in HL. ; ChkAmb: ld bc,11 ld a,'?' cpir ret nz ; (okay) call eprint ; ambiguous filenames not allowed db ' Ambiguous filename.',0 ld a,8 ; set error code jp Abort ; GetDU: call retud ; B=current drive, C=current user ld a,(ix+0) ; get drive byte or a jr z,GetDU1 ; (none) dec a ; make A=0, etc. ld b,a ; ..and put drive in B GetDU1: ld c,(ix+13) ; put user in C ld a,(ix+15) ; get error byte or a ret z ld a,2 ; error code call eprint db ' Invalid directory.',0 jp Abort ; InDU: push bc ld bc,(InDir) jr SetDU ; OutDU: push bc ld bc,(OutDir) SetDU: call logud pop bc ret ; PrtFn: call hvon ; start highlighting ld a,b ; print drive add a,'A' call cout ld a,c ; print user call pafdc ld a,':' call cout call pfn2 jp hvoff ; end highlighting ; GetOpt: ld hl,ColDft ; move defaults ld de,OpCFlg ld bc,4 ldir ld hl,CpmDma+1 call eatspc ; move past first token call eatnspc call eatspc ret z ; (no options) cp '/' ; slash? inc hl ; move past it jr z,GotOpt ; (we've got options) call eatnspc ; move past second token call eatspc ret z ; (no options) cp '/' jr nz,GotOpt ; (we've got options) inc hl ; move past slash GotOpt: ld a,(hl) ; get option inc hl ; point to next or a ret z ; end of options call isdigit ; column count? jr z,OptC cp 'S' jr z,OptS cp 'L' jr z,OptL cp 'F' jr z,OptF cp 'Q' jr z,OptQ cp ' ' ; skip intervening and trailing spaces jr z,GotOpt ld a,19 ; error code call eprint db ' Invalid option.',0 jp Abort ; OptC: dec hl ; point back to option character call eval10 ld (OpCFlg),a jr GotOpt ; OptS: ld de,OpSFlg jr DoOpt ; OptL: ld de,OpLFlg jr DoOpt ; OptF: ld de,OpFFlg jr DoOpt ; OptQ: ld de,OpQFlg ; DoOpt: ld a,(de) cpl ld (de),a jr GotOpt ; ; DatStp -- Get create stamp from original file, if available, and ; transfer it to new file. ; DatStp: call InDU ; setup for input file ld de,CpmFcb call initfcb ; initialize FCB ld hl,CpmDma ; point to DMA buffer call getstp ; get ZSDOS file stamp ret nz ; (error) ld a,(CpmDma+1) ; check for create date or a jr nz,DatSt1 ; (we've got a create date) ld a,(CpmDma+11) ; none, so check for modify date or a ret z ; (no date stamp) ld hl,CpmDma+10 ; point to modify date jr DatSt2 DatSt1: ld hl,CpmDma ; point to create date DatSt2: ld de,StpTmp ; move date to storage ld bc,5 ldir call OutDU ; setup for output file ld de,OutFcb call initfcb ld hl,CpmDma ; point to DMA buffer call getstp ; get file stamp ret nz ; (error) ld hl,StpTmp ld de,CpmDma ; move old stamp to create date ld bc,5 ldir ld de,OutFcb ; setup for file stamping ld hl,CpmDma jp setstp ; set file stamp and return ; Usage: call eprint DftNam: db 'JUSTIFY Version ' db Vers/10+'0','.',Vers mod 10+'0',SubVers db ' Copyright (c) 1988 by Irv Hoff',CR,LF db 'Usage:',CR,LF,' ',0 ld hl,comnam call epstr call eprint db ' {dir:}infile {dir:}{outfile} {{/}options}',CR,LF db 'If no outfile is given, default is filetype "JUS".',CR,LF db 'In-Text Options, in first column of source file:',CR,LF db ' ) center this line',CR,LF db ' ] justify this indented paragraph',CR,LF db ' ; do not justify this line',CR,LF db 'Command Line Options:',CR,LF db ' n line width for justifying (default ',0 ld a,(ColDft) call pafdc call eprint db ')',CR,LF db ' S ',0 ld a,(SpcFlg) or a call nz,PrDont call eprint db 'justify lines starting with space',CR,LF db ' L ',0 ld a,(LngFlg) or a call nz,PrDont call eprint db 'justify lines regardless of length',CR,LF db ' F ',0 ld a,(FFFlag) or a call nz,PrDont call eprint db 'retain form feeds',CR,LF db ' Q quiet mode o',0 ld a,(OpQFlg) or a ld a,'n' jr z,PrtOn ld a,'f' call cout PrtOn: call cout xor a ; error code (no error) jp Exit ; PrDont: call eprint db 'don''t ',0 ret ; TmpTyp: db '$$$' JusTyp: db 'JUS' BakTyp: db 'BAK' ; DSEG ; OpCFlg: ds 1 ; number of characters per line OpSFlg: ds 1 ; option S flag OpLFlg: ds 1 ; option L flag OpFFlg: ds 1 ; option F flag OpQFlg: ds 1 ; option Q flag InDir: ds 2 ; source user and drive OutDir: ds 2 ; destination user and drive OutFn: ds 11 ; final output filename OutFcb: ds 36 ; output file control block StpTmp: ds 5 ; create date storage BufBeg: ds 2 ; buffer start address BufEnd: ds 2 ; buffer end address BufOff: ds 2 ; current buffer offset L0F24: ds 1 L0F25: ds 1 L0F26: ds 1 L0F27: ds 1 L0F28: ds 1 L0F29: ds 1 L0F2A: ds 1 L0F2B: ds 1 L0F2C: ds 1 SCrCnt: ds 2 ; count of soft carriage returns fixed CtlCnt: ds 2 ; count of control characters eliminated FFCnt: ds 2 ; count of form feeds left in HBtCnt: ds 2 ; count of zeroed high bits SHyCnt: ds 2 ; count of soft hyphens fixed LinCnt: ds 2 ; lines in file OphCnt: ds 2 ; count of orphan line feeds removed OSpCnt: ds 2 ; count of spaces in original file BSpCnt: ds 2 ; count of binding spaces replaced NSpCnt: ds 2 ; count of spaces in new file TabCnt: ds 2 ; count of tabs expanded TSpCnt: ds 2 ; count of trailing spaces removed OutBuf: ds 255 ; output buffer ds 184 ; stack Stack: ds 2 ; stack pointer storage ; end