UNARCZ ZCPR3 Archive File Extractor Modification History Version 1.3 -- December 9, 1990 -- Gene Pizzetta Carson Wilson reported a bug in version 1.2 to me some time ago that didn't allow him to extract files to a different drive under his Z3PLUS system. I could not duplicate the problem under ZCPR34, so he found coding error and corrected it himself. In addition, I have corrected a bug in the CFG file that did not allow setting CCPSAV option to 0. Converted source to Zilog mnemonics. Version 1.2 -- September 1, 1990 -- Gene Pizzetta Now writes archive file create dates to output file date stamps under ZSDOS. Gets its name for usage message from external file control block. Retains EFCB name for subsequent execution with GO command. Screen display is slightly more compact and easier to read, including a new usage message. Command line options N and C can now be given with preceding slash as second command line parameter ("*.*", all member files is assumed for missing second parameter). Added E option to erase an existing file of the same name without asking during extraction to disk. Now correctly parses command line options when more than one option is given, allowing use of N and C options together. Removed code relating to several configuration options: CP/M-68K CP/M-80 emulator support and high user and high drive for both input and output directories (now depends on the CPR's bad directory flag at FCB+15). Added configuration options to change default for E and N command line options. Current default is shown by usage message. Configuration options can now be changed using ZCNFG, eliminating need for an overlay file. Version 1.1 -- May 21, 1990 -- Gene Pizzetta Turns off screen paging during disk file extraction. Also, obtains number of screen lines from environment. (This version was never released.) Version 1.0 -- March 11, 1990 -- Gene Pizzetta This version is for ZCPR3 only. Added ability to use DU and DIR in file specifications. Added HIUSR and HOUSR configuration bytes to allow restricting user access. Added automatic use of WHEEL byte. Removed version history from source file to make it easier to handle. Also removed all long comment sections not directly pertaining to the coding. These two deletions cut the size of the source file by 35K. Many of the comments removed were quite interesting, however. Those interested in reading them should check the version 1.6 source code in UNARC16S.ARK. That version will continue to be required by those not using ZCPR3. Previous versions by Robert A. Freed, released as UNARC: Version 1.6 -- March 27, 1987 -- Robert A. Freed Murphy's Law strikes again: Within hours after the release of version 1.5, a bug was discovered. Incorrect CRC error messages are generated during file extraction in some situations. This was caused by failure to clear carry before a 16-bit subtract (SBC HL,DE), which we changed inadvertantly in 1.42. (So much for Beta-testing!) Such faulty error messages occur only for disk file extraction, not when the 'C' command option is used to check an archive. Furthermore, the bug occurs only when (1) a file contains an odd number of 128-byte records and (2) the BDOS returns from the last write-record call with carry set. [Note of interest: The CP/M 2.2 BDOS returns with carry set only if the output drive is different than the current default drive. This assumes, of course, that no RSX-type system extensions are in place to intercept BDOS calls: We would have caught this bug, but for such a system extension which always clears carry before returning from BDOS calls.] Our thanks to Tom Brady for reporting this one. Zero-fills last record of .COM file. (Not needed with Z80ASM and/or SLRNK, but provided so that M80/L80 will generate identical output to that produced by the SLR Systems' tools.) Version 1.5 -- March 24, 1987 -- Robert A. Freed UNARC is now distributed as a self-unpacking archive, UNARC15.ARK. This requires: (1) the non-z80 version (UNARCA.COM) must be the FIRST file in the archive, (2) UNARCA.COM must be stored in UNPACKED form using compression version 1, (3) the header for UNARCA.COM must be preceded by the SINGLE byte, 0C3H (opcode for unconditional jump), and (4) the archive must be copied or renamed to UNARCxx.COM on the current disk drive (xx = current version, i.e. UNARC15.COM for this release). Then, the file is executed with a single optional parameter specifying the disk drive to use for extracting all files (defaults to current drive). For example, assuming UNARC15.ARK is on drive B: A>B: ; Set current drive for UNARC15.ARK B>REN UNARC15.COM=UNARC15.ARK ; Rename it to UNARC15.COM B>UNARC15 [d:] ; Extract files to current drive [or d:] Corrects non-Z80 version emulation of the Z80 16-bit add and subtract instructions (ADC_HL and SBC_HL macros), to properly set the Z(ero) condition flag. Previously, Z reflected only the upper byte of the 16-bit result and was incorrect for non-zero results less than 256. This caused a serious bug (in the non-Z80 version, UNARCA.COM, only): Failure to output the last 1-255 bytes of an extracted file in cases where the final output buffer size was less than 256 bytes. (In particular, ALL files less than 256 bytes in length could not be extracted.) Thanks to Barry Kaufman (Multipath, Inc., P.O. Box 395, Montville, NJ 07045) for bringing this to our attention. [This tends to confirm our opinion regarding the prevalence of non-Z80 systems, since this bug has been present but unreported since the release of UNARC 1.2.] Alters the interpretation of the USELUX definition in the UNARCOVL.ASM overlay file. USELUX = YES now restricts file typeout buffering to one page (equivalent to TYPGS = 1) instead of altering the upper TPA limit (CCPSV value). This eliminates the LUXSIZ definition (which specified the size of the LUX RSX-type resident code) and avoids the confusion introduced by recent multiple new versions of LUX from different authors. Corrects CP/M 2.2 tab alignment for the first displayed line of file typeout after continuing from a screen pause ([more] message). Adds explicit check for CTRL-S (suspend output) in CABORT, to handle cases where standard CP/M 2.2 BDOS misses these. (Also masks console input characters to 7 bits, in case this is not done, as it should be, by BIOS. This is an attempt to solve reports of failure to recognize CTRL-C and CTRL-S on some systems.) Allows 0-length "crunched" files (i.e. with no code size byte). [The various MS-DOS ARC utilities differ in their handling of 0-length files. SEA's ARC generates unpacked (version 2), which we feel is esthetically best, and ARCA generates packed (version 3). But PKARC generates crunched (version 8), which was regurgitated by earlier UNARC versions due to the absence of the code size byte.] Minor code improvements for version 1.42 changes. Eliminates DS directives at end of file to avoid wasted space when linked with L80 (as opposed to SLRNK, which handles trailing uninitialized data intelligently). This also permits overlaying of the self-unpacking initialization code by data in the non-Z80 version. Version 1.42 -- January 7, 1987 -- Robert A. Freed Interim Beta-test release: Supports 'squashed' files (compression version 9) generated by PKARC version 2.0, as defined by Phil Katz' document file SQSHINFO.DOC, dated 12/27/86. (Katz is certainly doing his best to make life interesting for us.) Note: We've made an educated guess that Katz' handling of bypassed output codes after adaptive reset is identical to that of crunched (version 8) files. (Since there is no requirement for ARC512 compatibility here, he could have handled this in a less brain-damaged manner. However, on the basis of two very limited test examples, our assumption appears to be true.) This compression method requires a minimum TPA size of 30K (Z80) or 31K (8080) for extraction (worst case yet). Lists total of CRC values (mod 64K), as per suggestion of Steven Greenberg. This provides a simple single checksum value for comparing files created by different archive programs. (Since the CRC is computed over the UNcompressed files, this value should be the same for all archives created from the same set of input files, independent of any particular variations in file order or compression methods.) Adds trailing command line option 'C' to check the validity of one or more (or all, via *.*) archive members (i.e. to extract them for purposes of CRC and length checking, without storing them as disk files). This is a quick hack, in response to a suggestion by Keith Petersen. This option is currently allowed only if the wheel byte is non-zero. I.e., it is ignored in restricted RCP/M versions (although there is no reason why this could not be allowed, subject to a Sysop-definable patch byte). Also, the limited command line syntax prevents the simultaneous use of the 'N' option for non-paged typeout (i.e. screen pauses will always occur). Both of these limitations will be eliminated with addition of enhanced command line processing (including du: user area syntax) in a future release. Disallows use of 'P' option for printing files in restricted (RCP/M) versions. (We inadvertantly failed to implement this as intended in the 1.41 release. Hopefully, the recipients of that release will honor our limited- distribution request!) Note that the statement accompanying the 1.41 release is slightly incorrect: Both 'P' and 'C' options are processed ONLY if the wheel byte is non-zero (and in the absence of an output file drive, which always causes extraction to a disk file); a zero HODRV byte does not, in itself, inhibit these. Makes .ARK the preferred default archive filetype. I.e., first open attempt uses .ARK; second attempt tries .ARC if first is unsuccessful. Expands help message usage examples a bit (now that 4K limit is not a concern). Note: The additions in 1.41 and 1.42 have pushed the size of the Z80 version UNARC.COM file above 4K (which means 6K or 8K disk space on most systems). Such is life (and progress): We've resisted this for a long time, but it now seems unavoidable. The UNARCOVL.ASM overlay file distributed with UNARC 1.4 remains applicable for these releases. Version 1.41 -- December 14, 1986 -- Robert A. Freed Special limited-distribution release: Adds trailing command line option 'P' to allow printing of an archive member file on CP/M list device. This is a quick hack, in response to a user request (Craig Arno, Seattle), to allow direct printing of highly-compressed binary plot images (e.g., 1+ MB files which crunch to < 5% of their original size). Accordingly, ALL data is passed to the printer in 8-bit form, with no filtering by UNARC (including ^Z). This option is allowed under the same conditions as disk extraction (non-zero HODRV and wheel byte), and the files which may be printed are subject to the filetype exclusion table for typeout. Defers initializing listing totals until after CHECK is called. (This moved in 1.4 to accomodate LPS, without realizing it might cause a problem, albeit with an insignificant probability. LPS is now allocated in code and cleared by CHECK.) Version 1.4 -- November 21, 1986 -- Robert A. Freed We had hoped NOT to release another update of this program, but to replace it entirely by three new programs with enhanced functionality (UNARK, ADIR, and ATYPE), in conjunction with the upcoming release of the CP/M archive file builder (NOAH). However, (sigh)..... Corrects bug (exhibited with .ARC's created by version 1.1 or later of Phil Katz' PKARC program for MS-DOS) which caused files to be extracted incorrectly (with output file length and CRC warnings) due to string table reset codes appearing early in crunched files (i.e. before the output code length reaches 12 bits). Thanks to Keith Petersen for identifying and notifying us of this problem. And, while we're at it . . . Adds paging of all displayed output, controlled by non-zero patch byte specifying screen lines between pauses (TYLPS, default value = 23). This is essentially the feature added by 'Larry Smith' (see version 1.3 below), but we've been able to do it (with enhancements) and still keep the (Z80 version) .COM file below 4K (just!). Causes '[more]' message to appear at bottom of screen. Space bar scrolls one more line, ^C aborts, anything else scrolls one more screenful. (LINE FEED may be used to avoid overprinting the '[more]' line.) May be defeated for continuous typeout by trailing 'N' (after a blank) on command line. Also: If archive filetype omitted, and the default .ARC filetype not found, tries .ARK as an alternate default. (Anticipates NOAH, and compatible with Irv Hoff's KMD22.) Incorporates option to bypass BDOS function 31 call (Get DPB Address), for non-std CP/M clones such as Cromemco CDOS and CP/M-68K emulator for 8080 CP/M 2.2. (Eliminates UNARC12 patch notice, UNARC-P1.NOT.) Allows program name to be patched (at start of USAGE message). Affects all help screen references and abort message. (E.g., RCP/M sysops may prefer 'ADIR' to 'UNARC'.) Corrects count of bytes skipped due to invalid header when processing 'self-unpacking' archives with more than 3 preliminary bytes. Enhances recovery processing for invalid archive headers, and merges 'invalid format' and 'unexpected eof' errors. This change tends to cause display of a garbage directory entry (before abort) for non-ARC files, but it does allow processing of certain new self-unpacking archives, such as Phil Katz' PKX32A11.COM. Changes the replacement for an invalid filename char from '_' to '$' (since underline is not allowed as a filename char by CP/M CCP, and '$' usually carries a 'temporary' significance in CP/M). Reduces directory listing width by one column (78 now), to allow one more char without extra blank line on terminals which autowrap after column 80 (e.g. allows leading semicolon generated by MDM7 and IMP during disk file capture of terminal output). Adds a few bells to warning and fatal messages, along with a patch byte to disable these (for those who prefer solitude). Allows ^K in addition to ^C for program abort requests. (For certain ancient RCP/M systems which never pass ^C back to user programs.) Adds .ARK and .?Z? (CP/M CRUNCH or MS-DOS ZOO 'Z format' files) to list of excluded typeout extensions, and eliminates .CMD (since that might be a readable dBASE command file instead of CP/M-86 binary). Simplifies the Z80 CPU check and removes the 'Z80 Version' message in the help display, to save a few bytes in that version. (Alternate version, UNARCA.COM, now displays '8080 Version'.) Adds 8080 version message recommending Z80 version, when run on a Z80. Version 1.3 -- none -- Robert A. Freed This version bypassed due to appearance of several unauthorized updates with the name UNARC13 (and not because of superstition). Most notably, these include Steve Sanders' unnecessary addition of ^S and ^C checking during file typeout (because TurboDOS does not properly emulate CP/M's handling of these in BDOS function 2 calls), and the addition of paged typeout by 'Larry Smith' (whoever he is; a worthwhile enhancement, but the release was deficient in several other respects). WHY CAN'T THESE 'CONTRIBUTORS' SIMPLY CONTACT THE AUTHOR BEFORE RELEASING THEIR CHANGES TO THE PUBLIC?! Version 1.2 -- June 24, 1986 -- Robert A. Freed Modified to allow assembly of a version which will execute on 8080/8085 CPU's. (We resisted this initially but have been made to realize that this is necessary to achieve true acceptance of UNARC by the full CP/M user community. Non- Z80 users, particularly RCP/M sysops, still exert considerable influence in the world of public domain software. This, we believe, is out of proportion to their numbers, since almost all CP/M systems sold in the last five years are Z80-based. Nevertheless, we've accommodated the needs of these users by extensive use of macros which serve to emulate Z80 instructions on non-Z80 machines.) However, no attempt has been made to optimize for either size or speed in the non-Z80 version (which is 1K larger and 50% or more slower than its Z80-only counterpart). Also: Implements a "wheel" byte to simplify use and installation on RCP/M's. Lines up file types in directory listing. Permits processing of "self-unpacking" archives such as the MS-DOS ARC51.COM file (anticipates a future scheme for distributing UNARC). Attempts to recover from bad archive headers by skipping extra bytes. Eliminates archaic "T:" syntax completely for file typeout. Version 1.1 -- May 24, 1986 -- Robert A. Freed Minor change to allow file typeout without the "T:" syntax (which didn't work with almost ANY CCP replacement)... File will be typed if it: (1) has no disk drive name, (2) is a single (UNambiguous) file, and (3) is not an excluded filetype. (Else, file will simply be listed with no error message.) This change was suggested by Irv Hoff's mod to UNARC10, which he called ADIR. (Previous "T:" method can still be enabled, but it is now undocumented since we will probably drop it altogether in future.) Also shortened on-line help message, so that COM file size is now reduced to 4K. (For RCP/M systems, if HODRV = 0 and/or TYFLG = 0, the help information relating to disk extraction and/or file typeout, respectively, is automatically removed.) Version 1.0 -- May 3, 1986 -- Robert A. Freed First public release. Supports file formats generated by all versions of MS-DOS ARC through (at least) version 5.12 dated February 7, 1986. Version 0.0 -- March 1, 1986 -- Robert A. Freed I undertook writing this program to satisfy my curiosity about software developments in the MS-DOS/PC-DOS world. The ARC "freeware" program (copyright by System Enhancement Associates) has been around for over a year now and has achieved enormous popularity in the 16-bit community. Unfortunately, the lack of a compatible equivalent for CP/M systems renders a large amount of public domain software inaccessible to 8-bit users such as myself. (Note that 16- bit software can indeed be usable on 8-bit systems, e.g. Pascal and C language programs.) Also, an increasing number of RCP/M systems are catering to both 8-bit and 16-bit users, and it is my hope that UNARC may find a welcome home on such systems. Note that I was not (initially) a fan of the sequential .ARC file format, which is less flexible and slower to process (though certainly more compact) than the random-access format which Novosielski .LBR libraries have provided for years. Therefore, I stopped short of producing a complete ARC program equivalent which includes creation of .ARC files. The LZW "crunching" algorithm is impressive though (see my editorial comments preceeding the UCR routine), and I now believe there is a place for .ARC files in the CP/M world (particularly on RCP/M's, where the name of the game is reducing upload/download time). But that's the domain of another program (i.e. my next project: NARC). - Bob Freed Copyright (C) 1986, 1987 by Robert A. Freed Bob Freed 62 Miller Rd. Newton Centre, MA 02159 Telephone (617) 332-3533