; FILT.Z80 ; ; Tabs or detabs ASCII text and assembler source files, filtering ; out control characters, high-bits, and other unwanted characters. ; Vers equ 81 SubVers equ ' ' ; ; HISTORY: ; ; Version 8.1 -- September 30, 1991 -- Gene Pizzetta ; FILT did not check (and never has) for ambiguous filenames, which ; could cause a small disaster. It checks now. Made display of ; line count progress reports into configurable option. ; ; Version 8.0 -- September 10, 1991 -- Gene Pizzetta ; Disassembled enough to change to a relocatable file (it was easy ; after working on JUSTIFY). Changed to Z80 opcodes to partially ; compensate for space used by additional features. Replaced some ; routines with library routines. Now allows destination directory ; without destination filename. Changed key options to command ; line entry. Changed some messages to make them more descriptive. ; Added DU support, intelligent usage screen, error flag setting, ; error handler invocation, quiet mode, and ZCNFG configuration. ; Under ZSDOS and ZDDOS file create date stamps are transferred to ; the new file. Incorporates some code efficiencies suggested by ; Bruce Morgen for JUSTIFY. The hardest part of this conversion ; was deciding how to make those various modes chosen interactively ; into a group of logical command line options. I hope I've ; succeeded. ; ; Version 7.0a -- May 11, 1986 -- Irv Hoff W6FFC ; When filtering WordStar files FILT7 was checking for unwanted ; control characters too soon, thus ignoring space breaks and ; soft-hyphens. The summary report then indicated none were ; found. That has been fixed with FILT7A. Evidently these ; characters are seldom used in WordStar files, as I had to ; make some special files to even test this feature. This would ; be verified to some extent by nobody calling this to our ; attention even though the program has been available for ; several years now. (WordStar uses 0Fh for space breaks and ; 1Fh for soft-hyphens.) ; ; Version 7.0 -- April 27, 1985 -- Irv Hoff ; Accepts lines up to 255 characters long (vice 128). Insures ; last line has CR-LF to allow normal processing. ; ; Version 6.0 -- March 7, 1985 -- Irv Hoff ; Added tab option if in Text mode. Fixed ERXIT so external file ; is not deleted unless a 'Y' is used. ; ; Version 5.0 -- November 20, 1984 -- Irv Hoff ; Initial version, similar style to FORM5, NEAT5 and TABS5. ; ; Please report bugs or make 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 ; 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) ; .request zslib,z3lib,syslib ; extrn gcomnam,comnam,hvtinit,hvdinit,hvon,hvoff ; ZSLIB extrn eatspc,eatnspc,getstp,setstp ; ZSLIB extrn z3init,zsyschk,getquiet,puter2,inverror ; Z3LIB extrn eprint,epstr,cout,condin,pafdc,phldc,pfn2 ; SYSLIB extrn bdos,retud,logud,initfcb,codend ; SYSLIB ; jp Start ; db 'Z3ENV',1 Z3EAdr: dw 0 ; ; Configuration area . . . ; dw 0 ; filler db 'FILT' ; for ZCNFG db Vers/10+'0',Vers mod 10+'0',' ' ; Mode: 00000001b = b0 = source code ; 00000010b = b1 = ASCII text (default) ; 00000100b = b2 = WordStar document (remove dot commands) ; 00001000b = b3 = WordStar document (retain dot commands) Mode: db 00000010b TabFlg: db 0 ; 0=tabs, FFh=no tabs QtFlag: db 0 ; 0=verbose, FFh=quiet LinFlg: db 0 ; 0=report progress, FFh=don't 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) ; help request? cp ' ' jp z,Usage cp '/' jp z,Usage ; (yep) ; 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,CpmFcb+1 ; none, so use input filename 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 ; get options ; ld bc,(InDir) ; get DU ld de,CpmFcb+1 ; point to filename ld a,(OpQFlg) or a jr nz,SkipIF call eprint db ' Filtering ',0 ld a,(OpMFlg) and 00000001b ; source code mode? ld hl,AsmMsg jr nz,PrtMod ; (yes) ld a,(OpMFlg) and 00001100b ; WordStar mode? ld hl,WSMsg jr nz,PrtMod ; (yep) ld hl,TxtMsg ; no, ASCII text mode PrtMod: call epstr call PrtFn SkipIF: push de ; copy filename pointer to HL pop hl call ChkAmb ; check for ambiguous filename call InDU ; set up for opening source file 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 ; check for ambiguous filename call initfcb ld c,FErase ; blind erase file call bdos ld de,OutFcb ld c,FMake 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 call z,CrLf ld de,OutBuf ld b,255 L03F0: 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 ; (read okay) cp 1 ; end of file? jp z,Done ; (yep) 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 L0437: ld a,(hl) ; get character cp 8Dh ; soft carriage return? call z,IncSCr bit 7,a ; high bit character? call nz,IncHBt and 7Fh ; reset 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? jr z,NmlChr cp TAB ; tab? jr z,NmlChr cp 0Fh ; binding space? jr z,NmlChr cp 1Fh ; soft hyphen? jp nz,DoCtrl ; handle other control characters ; NmlChr: inc b ; increment counter ld c,a ; save character in C ld a,b ; end of buffer? cp 0FFh ld a,c ; recover character jr nc,L04BE ; (end of buffer) cp 0Fh ; binding space? jp z,DoBSpc ; (yes, handle it) cp ' ' ; space? jr nz,L0490 ; (no) L0485: push hl ld hl,(OSpCnt) ; yes, increment space count inc hl ld (OSpCnt),hl pop hl L0490: cp TAB ; tab? jr nz,NotTab ; (no) push hl ld hl,(OTbCnt) ; yes, increment tab count inc hl ld (OTbCnt),hl pop hl XpndLp: ld a,' ' ; expand tab ld (de),a inc de inc b ld a,b and 7 or a jr nz,XpndLp dec b jp DoIt ; NotTab: call L0602 ld (de),a inc de cp LF jp nz,DoIt call condin call nz,ChkCon jr L04C5 ; L04BE: ld a,CR ld (de),a inc de ld a,LF ld (de),a L04C5: dec b jr z,L04E9 dec de dec de L04CB: dec de ld a,(de) cp ' ' jr z,L04D7 cp TAB jr nz,L04E1 L04D7: call IncTSp djnz L04CB dec de ; L04E1: inc de L04E2: ld a,CR ld (de),a inc de ld a,LF ld (de),a L04E9: push hl call CkPrgs ; give progress report ld hl,OutBuf L04F0: ld a,(hl) cp ' ' jr c,L0558 jp nz,L0598 ld a,(OpTFlg) or a ld a,(hl) jp nz,L0598 ld a,(OpMFlg) and 00000001b ; source code mode? jr z,L051C ; (no) ld a,(L0C56) or a jr nz,L051C ld a,(L0C55) or a jr z,L051C ld a,' ' push af jp L05C1 ; L051C: ld a,(L0C57) inc a ld (L0C57),a ld a,(L0C51) inc a ld (L0C51),a and 7 or a jp nz,L05E5 ld a,(L0C57) cp 1 jr nz,L054F ld a,(OpMFlg) and 00000001b ; source code mode? jr z,L0546 ; (no) ld a,(L0C56) or a jr z,L054F L0546: xor a ld (L0C57),a ld a,' ' jp L05E0 ; L054F: xor a ld (L0C57),a ld a,TAB jr L05E0 ; L0558: cp CR jr z,L0587 cp LF jr z,L0587 cp TAB jr nz,L057A xor a ld (L0C57),a ld a,(L0C51) add a,8 and 0F8h ld (L0C51),a ld a,TAB jr L05E0 ; L057A: cp FF ; form feed jp z,DoFF cp 1Fh ; soft hyphen? jp z,DoSHy jr L05E5 ; L0587: push af xor a ld (L0C51),a ld (L0C55),a ld (L0C56),a ld (L0C57),a jr L05DF ; L0598: push af cp '.' jp z,L06D3 cp '''' jr nz,L05AA ld a,(L0C55) cpl ld (L0C55),a L05AA: cp ';' jr nz,L05C1 ld a,(L0C56) or a jr nz,L05C1 ld a,(L0C55) or a jr nz,L05C1 inc a ld (L0C56),a L05C1: ld a,(L0C51) inc a ld (L0C51),a ld a,(L0C57) or a jr z,L05DF L05CF: push af ld a,' ' push hl call L0762 pop hl pop af dec a ld (L0C57),a jr nz,L05CF L05DF: pop af L05E0: push hl call L0762 pop hl L05E5: inc hl cp LF jp nz,L04F0 L05EB: ld de,OutBuf ld b,0FFh pop hl ld a,(L0C52) or a ret nz ld a,LF DoIt: ld (L0C53),a ; save last character inc l ; end of buffer? jp z,L03F0 ; (yes, read more) jp L0437 ; continue ; L0602: ld c,a ld a,(L0C53) cp CR ld a,c jr nz,L0618 cp LF ret z ld a,l or a jr z,L0615 dec l L0615: ld a,LF ret ; L0618: cp LF ret nz ld a,CR 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 ld hl,(SCrCnt) ; increment soft carriage return count inc hl ld (SCrCnt),hl pop hl ret ; DoCtrl: push hl ld hl,(CtlCnt) ; increment control character count inc hl ld (CtlCnt),hl pop hl jr DoIt ; DoFF: push hl ld hl,(FFCnt) ; increment form feed count inc hl ld (FFCnt),hl pop hl ld a,(OpMFlg) and 00001100b ; WordStar mode? jr z,L0656 ; (nope) ld a,FF jr L05E0 ; L0656: jr L05E5 ; IncHBt: push hl ld hl,(HBtCnt) ; increment high-bit character count inc hl ld (HBtCnt),hl pop hl ret ; DoSHy: push hl ; handle soft hyphens ld hl,(SHyCnt) inc hl ld (SHyCnt),hl pop hl ld a,(OpMFlg) and 00001100b ; WordStar mode? jp z,L05E5 ; (nope) ld a,'-' jp L05E0 ; DoBSpc: push hl ; handle binding spaces ld hl,(BSpCnt) inc hl ld (BSpCnt),hl pop hl ld a,(OpMFlg) and 00001100b ; WordStar mode? jp z,DoIt ; (nope) ld a,' ' jp L0485 ; IncTSp: push hl ld hl,(TSpCnt) ; increment trailing space count inc hl ld (TSpCnt),hl pop hl ret ; IncLns: ld hl,(LinCnt) ; increment line count inc hl ld (LinCnt),hl ret ; IncNSp: ld hl,(NSpCnt) ; increment new file space count inc hl ld (NSpCnt),hl ret ; IncNTb: ld hl,(NTbCnt) ; increment new file tab count inc hl ld (NTbCnt),hl ret ; L06D3: ld a,(L0C51) or a jp nz,L05C1 ld a,(OpMFlg) and 00001100b ; WordStar mode? jp z,L05C1 ; (nope) ld a,(OpMFlg) and 00001000b ; retaining dot commands? jr nz,L070F ; (yep) pop af inc hl ld a,(hl) and 5Fh cp 'P' jr nz,L070F inc hl ld a,(hl) and 5Fh cp 'A' jr nz,L070F inc hl ld a,(hl) cp CR jr nz,L070F ld a,FF call L0762 push hl ld hl,(FFCnt) ; increment form feed count inc hl ld (FFCnt),hl pop hl L070F: push hl ld hl,(DotCnt) ; increment dot command count inc hl ld (DotCnt),hl pop hl ld a,(OpMFlg) and 00001000b ; retaining dot commands? jp nz,L05C1 ; (yep) jp L05EB ; ErExit: push af ; save error code call OutDU ld de,OutFcb ld c,FClose ; close output file call BdosE ld de,OutFcb ld c,FErase ; and erase it call BdosE pop af Abort: push af call InDU ld de,CpmFcb ld c,FClose ; existing file abort 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 ; ..and return to caller ; L0762: cp ' ' call z,IncNSp cp LF ; line feed? call z,IncLns ; (yes, increment line count) cp TAB ; tab? call z,IncNTb ; (yes, increment new tab count) push af ld hl,(BufEnd) ; buffer end address in HL 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,L07DF ld hl,0 ; zero buffer offset ld (BufOff),hl L0786: 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,L07D1 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 L0786 ; DskFul: ld a,11 ; error code call eprint db ' Disk full.',0 jp ErExit ; L07D1: ld c,SetDma ld de,CpmDma call BdosE ld hl,0 ld (BufOff),hl ; zero buffer offset L07DF: 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 it in buffer ld hl,(BufOff) ; get offset inc hl ; increment it 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 (L0C52),a ; end of file, so finish up inc de inc b call nz,L04BE ld a,(OpQFlg) or a jr nz,L0866 ld a,CR call cout ld hl,(LinCnt) call phldc L0866: ld hl,(BufOff) ; check for end of sector ld a,l and 7Fh jr nz,L0872 ld (BufEnd),hl L0872: ld a,CtrlZ push af call L0762 pop af jr nz,L0866 call InDU ld de,CpmFcb ld c,FClose call bdos call OutDU ld de,OutFcb ld c,FClose 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,Finis5 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,(OTbCnt) call phldc ; print count of original tabs call eprint db ' original tabs',CR,LF,0 ld hl,(NSpCnt) call phldc ; print count of new spaces call eprint db ' current spaces',CR,LF,0 ld hl,(NTbCnt) call phldc ; print count of new tabs call eprint db ' current tabs',CR,LF,LF,0 ld hl,(FFCnt) call phldc ; print count of form feeds kept/deleted call eprint db ' form feeds ',0 ld a,(OpMFlg) and 00001100b ; WordStar mode? jr nz,Finis1 ; (yep) call eprint db 'deleted',0 jr Finis2 ; Finis1: call eprint db 'present',0 Finis2: ld hl,(HBtCnt) call CrLf 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',0 ld a,(OpMFlg) and 00001100b ; WordStar mode? jp z,Finis5 ; (nope) call CrLf call CrLf ld hl,(DotCnt) call phldc ; print count of dot commands kept/deleted call eprint db ' dot commands ',0 ld a,(OpMFlg) and 00001000b ; retaining dot commands? jr z,Finis3 ; (nope) call eprint db 'retained',0 jr Finis4 ; Finis3: call eprint db 'deleted ',0 Finis4: call CrLf 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 spaces count call eprint db ' binding spaces fixed',0 Finis5: ld hl,OutFn ; move original filename ld de,OutFcb+1 ; to output FCB 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) ld a,8 ; error code call eprint ; ambiguous filenames not allowed db ' Ambiguous filename.',0 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 and return ; GetOpt: ld a,(Mode) ; move defaults ld (OpMFlg),a ld a,(TabFlg) ld (OpTFlg),a 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) cp 'S' jr z,OptS cp 'A' jr z,OptA cp 'D' jr z,OptD cp 'Q' jr z,OptQ cp 'T' jr z,OptT cp 'W' jr z,OptW cp ' ' ; skip intervening and trailing spaces jr z,GotOpt ld a,19 ; error code call eprint db ' Invalid option.',0 jp Abort ; OptS: ld a,00000001b jr DoMode ; OptA: ld a,00000010b jr DoMode ; OptW: ld a,00000100b jr DoMode ; OptD: ld a,00001000b ; DoMode: ld (OpMFlg),a jr GotOpt ; OptQ: ld de,OpQFlg jr DoOpt ; OptT: ld de,OpTFlg ; 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 ; re-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 create stamp to date string 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 'FILT Version ' db Vers/10+'0','.',Vers mod 10+'0',SubVers db ' Copyright (c) 1986 by Irv Hoff',CR,LF db 'Usage:',CR,LF db ' ',0 ld hl,comnam call epstr call eprint db ' {dir:}infile {{dir:}outfile} {{/}options}',CR,LF db 'The outfile defaults to the name of the infile.',CR,LF db 'Mode Options:',CR,LF db ' S Source Code',0 ld a,(Mode) and 00000001b call nz,PrtDft call eprint db CR,LF db ' A ASCII Text',0 ld a,(Mode) and 00000010b call nz,PrtDft call eprint db CR,LF db ' W WordStar-remove dot commands',0 ld a,(Mode) and 00000100b call nz,PrtDft call eprint db CR,LF db ' D WordStar-retain dot commands',0 ld a,(Mode) and 00001000b call nz,PrtDft call eprint db CR,LF db 'Other Options:',CR,LF db ' T ',0 ld a,(TabFlg) or a call z,PrDont call eprint db 'use tabs',CR,LF db ' Q quiet mode o',0 ld a,(OpQFlg) or a ld a,'n' jr z,Usage1 ld a,'f' call cout Usage1: call cout xor a ; no error jp Exit ; PrtDft: call eprint db ' [default]',0 ret ; PrDont: call eprint db 'don''t ',0 ret ; CrLf: call eprint db CR,LF,0 ret ; AsmMsg: db 'Source Code ',0 TxtMsg: db 'ASCII Text ',0 WSMsg: db 'WordStar Document ',0 TmpTyp: db '$$$' BakTyp: db 'BAK' ; DSEG ; OpMFlg: ds 1 ; Mode: source code, ASCII, WS/no dot, WS/dot OpTFlg: ds 1 ; Tab flag OpQFlg: ds 1 ; Quiet 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 L0C51: ds 1 L0C52: ds 1 L0C53: ds 1 L0C55: ds 1 L0C56: ds 1 L0C57: ds 1 SCrCnt: ds 2 ; count of soft carriage returns CtlCnt: ds 2 ; count of control characters DotCnt: ds 2 ; count of dot commands FFCnt: ds 2 ; count of form feeds HBtCnt: ds 2 ; count of zeroed high bits SHyCnt: ds 2 ; count of soft hyphens LinCnt: ds 2 ; lines in file OphCnt: ds 2 ; count of orphan line feeds OSpCnt: ds 2 ; count of spaces in original file BSpCnt: ds 2 ; count of binding spaces NSpCnt: ds 2 ; count of spaces in new file OTbCnt: ds 2 ; count of tabs in original file NTbCnt: ds 2 ; count of tabs in new file TSpCnt: ds 2 ; count of trailing spaces OutBuf: ds 256 ; output buffer ds 138 ; stack Stack: ds 2 ; stack pointer storage ; end