Deja Vu #09
13 ноября 1999 |
|
Coding - Hrust Library svobodnopasppostpanyaemaya library window procedure by means of eccentricity can be packaged and paspakovyvat VARIOUS data.
(C) Dmitry Pyankov, 07/23/1999 __________________________________________ Especialy for DEJA VU # 09! Hrust Library 2.02 - is this free library of procedures that can help you pack and unpack different data, add and extract files from Hrust2-archives. Moreover, everyone on the basis of these procedures and respecting the format of the header can write your own logger, which would fully meets the needs of the author archiver like the interface and on functionality. Package Contents: HRUSTNFO.C - this file; CRC16S.C - procedure for calculating the CRC; CRC16F2.C - fast calculation procedure leniya CRC; DEHR22.C - extractor; HRUST22.C - packer. Distribution of this Libraries in the original version - that is, change the library and set of procedures impossible. Indicate the use of library Hrust Library 2.02 is mandatory. When designing format headings were considered valuable ideas of Alexander Grimalovskogo (Flying), Sergei Mullin (Simm), Ivan Roshchina. Thank you! ----------------------------------------- Format headings: It was supposed to create a simple format headers, so that any coder (in its own program) is not particularly tortured could rip the files from (to) archive. Except This is possible under the same format, just burn the compressed files - in which there is no additional data on behalf of File, CRC, etc. File is divided into blocks. Each block a header. Blocks can be different lengths: either # 8000 or # 4000 (hereinafter see the installation of flags). The exceptions are simply compressed files (not in the game), their length is limited to # a000. Just compressed file length as a # a000 divided into blocks of length, or # 8000, or # 4000. Consistently recorded blocks form a compressed file, and the sequence of compressed files - archive. Header Block: --------------- 0 (5) - "Hrst2" - the signature 5 (1) - bytes of flags. (See below) 6 (2) - the length of the original block 8 (2) - the length of the packaged unit (with no long Ny title) +10 (1) - the length of additional information: ---- 11 (2) - CRC16 packaged unit (You can quickly check the Save sequence file) 13 (2) - CRC16 original block +15 (14) - a copy of the file header of the kata log 29 (1) - a pointer to a subdirectory, in which rum is a file +30 (Variable length) - a comment. ---- + [10] 11 (taken from bytes 10 bytes and diluted 11) - packed block. Length of additional information equals 0 for just packed files. = 2 if you want a byte and CRC16 IAN forged block = 4 + else and know CRC16 Source block = 18 + know the name of the file = 19 + know in which subdirectory is file > 19 + we also comment on the fi lu. The maximum length of comments we take equal to 255-30 = 225 characters. Byte flags: ----------- bit0 = 1 unit saved without compression bit1 = 1 block in the file was last. bit2 = 1 end archive. bit3 = 1 unit packed with the "support" for the previous duschy block (in the past 16 kb is On the same file). Block length is 16 KB. bit3 = 0 - reliance on previous block no. bit4 = a solid backup. When packing the current File rested at 16 kb from the previous duschih files. (Those files, in turn, In turn, too, relied on previous files). bit5 = 1 file deleted. bit6 = 1 file zaparolirovan. bit7 = 1 means that it does not file a subdirectory. Description subdirectory: 0 (5) - "Hrst2" 5 (1) - bytes of flags. Bit 7 is set. 6 (1) - the length of the additional information: ---- 7 (11) - the name of the subdirectory. (Name length can and can be less than 11). 18 (1) - a pointer to a subdirectory - "Rodi Tel. 19 (variable) - the comment to the rolled ravine. ---- Notes: I. At the moment, bits 3,4,6 are always reset. II. "A pointer to a subdirectory. In the first pores of the byte can be set to 0. In such a case is not supported by the subdirectories system. When writing razarhivatora can ignore the importance of this bytes - this will lead to that all the files will be at the root. In Later, with the help of this byte, we can organize files in subdirectories of virtually any nesting by the following method: 1. The pointer is 0: file or subdirectory in the root directory. 2. Each encountered (in order of succession) subdirectory assigned a number between 1 .. 255. 3. If the newly encountered a file or subdirectory has a byte pointer to a subdirectory of "the number N, this means: a) for file: the file is in a subdirectory number N; b) to subdirectories: a parent under this The directory is a subdirectory with the number N. III. If a subdirectory is marked as "deleted", it will still be assigned the appropriate number. If the file is marked as "Remote", and in the same subdirectory is file with the same name, it should perceived as a "previous version" file. During the operation MOVE for remote backup subdirectories pointers to directories recalculated. For solid archives MOVE operation is not applicable. IV. In the TR-DOS is that the length of the file bytes does not match the file length in sectors. Here you can provide different Options: 1. Always take the length of the file in the sectors. 2. Always take the length of the file in bytes. 3. If the file length in sectors of the length of the file in bytes, the length of the file taken as a byte. Otherwise - in both sectors. It is recommended to use the third option. Basic length files, apparently, we must take sectors. V. In what could be packed all the way TR-DOS disk. To to distinguish what is the image of the entire disc must be within 14 bytes of header ('copy header files from a directory ") put down the length of the sectors and the length in bytes = 0. When packing a TR-DOS disk, you can provide an option when packed not the entire disc, but only the part occupied by the files. VI. From the format of the header file that it can store files of any length. I do not know whether this can be useful. VII. Self-extracting archives. No problems. Immediately prior written basic archive file, which would unfold the archive, then we SFX archives. In this basic file, you can add additional features: for example - unpacking on another drive and other ... Names and file extensions in TR-DOS, Working with TR-DOS. First of file extensions: ". Zzz"-extension of the files, create archive. Extending just packed files (not archive): ". Zzz", as well as the following options: ". ZCz" if the file extension was "C". ". ZHz" if the file extension was "H". ". ZXz" if the file extension was "X", and so on. This will allow the program directly from the catalog to determine not only the fact that this file is packed, but also to determine the expansion source file. For example, music editors, meeting file with the extension ". Zmz" immediately determine that this file - bagged music. If you intend to work with the packed files from programs that work only with files with extension "C", then expansion will be respectively: ". CCz", ". CHz", "CXz" (example TASM 4.12). Because in TR-DOS maximum length of file 255 sectors, it will create several files. Their names will be different last character. In the first file the last character-space, the rest - 1,2 ... 9, A, B, C. .. These files may have a length of 255 sectors is not necessarily, and they can not go order - this will complement the archive In any case, not only in the case When the archive file is the latest in disk. Files from the archive may be removed. At the same time in flag byte corresponding bit is set. Well, as a TR-DOS, after deleting a file of possible operations on the "seal" the archive. Simplification: at first you do not use sub-directories, record files are archived one after another and not to add archive if the archive is written after any file. Naturally, the implementation of solid archives and archives where the file package block is carried out using the previous unit - a reserve for the near future. ----------------------------------------- Procedure HRUST Input parameters: HL - from packing DE - where to put the compressed file. BC - the length of the source file. A - length of the additional information. (In a head. For details, see Format Headers Cove.) HL> DE ever. Output parameters: BC - the length of the packaged unit, together with the title. Other parameters such as length of the source and packaged unit, CRC16 source and packaged unit (if it was set) are in the header. Likewise in header set aside a place in the comment (if it was specified). When packing is used in addition 3 cans. In this case, a search box as well # 4000 (16 kb). When packing therefore desirable to make the difference between HL and DE 16 kb. Can be used instead of 3, and 2 banks: setting USEBNK2 = VSEBNK1 and OKNO = # 2000. Difference between HL and DE can be set equal to 8 KB. Minimum difference between HL and DE depends on how long the file you pack, and what he content. To file length of 32768, containing a number of RND must specify the difference 32768 / 8 = 4096 plus place under the title. For well pakuemyh Files can be given the difference even For example, a length of 512 bytes. However, the decrease of this difference significantly affects the quality of compression. You can change the speed of packing: FSPEED. 1 .. 255. 1 - the highest rate of compression (Respectively, the quality is worst). 255 - the slowest speed. The packaging process otobrazhaetcya on the screen: an update occurs after every 256 packed bytes. Is responsible for this procedure PERCENT. Procedure is somewhat slow, so if you want to speed up a little bit of packing, replace it faster. For example, the "spinning rod" :-). PERCENT uses the procedure: PERC1: Output: C-as a percentage: the length of the OUTPUT file. A - as a percentage: the length of the INPUT file. PERC5: entry: what have PERC1 output. Displays a graphical representation of the package. PERC3: input: the same as that of PERC5. The mapping process of packing with the help of numbers. As long files are broken into blocks and each block is packaged separately, then for the proper display of the process introduced another 3 variables. If you pack one block, then there is always zero. But if you pack file length, for example, 65,280, and divide it into blocks of length 32768 and 32512 bytes, When packing the first block set: BLOCKP = 0; original length packed blocks BLOCKNP = 32512; length nepakovannyh blocks BLOCKPP = 0; length packaged blocks When packing the second block: BLOCKP = 32768 BLOCKNP = 0 BLOCKPP = length of packed first block. Unpacker DEHRUST Length of less than 256 bytes. Do not use stack. Relotsiruemy. If you need more speed, we can reveal the internal cycles and reveal PSEUDO-CALLR :-). Additionally, it is desirable to insert the top of the unpacker check that at the beginning File contains "Hrst2". Login: HL - whence, DE - where. The procedure for calculating CRC16 They are actually two. One - a short and slow, the second - fast, but uses additional memory size of 512 MB. CRC16S - Slow procedure. CRC16F2 - Fast. It must first integrate over ized (CRCINI - created Table 512 bytes). CRCCALC: Rin: HL - Home fayla.BC - length. OUT: DE - CRC. CRCUPD: Rin: HL - beginning of the file. BC - length. DE - CRC. OUT: DE - CRC. ----------------- Example ORG # 6000 LD HL, 0 LD DE, # C000 LD BC, # 4000 LDIR ; Threw ROM address # c000 ; Packing: LD HL, # C000; from LD DE, # 8000; to LD BC, # 4000; as LD A, 4; - CRC source and packaged ; Files are stored in the header. CALL HRUST And in BC we get the length of the file, along with Zago, deft ; Unpacking: LD HL, # 8000 LD DE, # 8000 CALL DEHRUST RET ----------------------------------------- A critical view. As a rule, in the author's descriptions emphasize the advantages and disadvantages of hiding programmy.Pora finish with this nehoroshey practice :-). On the format of the special headers are no comments, although a few words to say, you can: on each block is given a title, more addition, each block can be a comment. Yes, it's wasteful. But on the other hand, when the archive is corrupted you can restore the saved files or even save the file. The general format of the header makes it easy to format. Now about the procedure. It was not written specifically for the general public, so it can find a lot of "blunders". However, a workable procedure, I decided not to rewrite. There are some files, which in the end there are many "nepakuemyh" bytes. Such files can be correctly decompressed and the computer may stop responding. In such cases, recommend 2 methods: 1. To ensure that when unpacking "End" of the packed file is above the "End" of the decompressed file. 2. Add to extractor 3 lines for to the packed file copied to the higher memory area, in this case as there is an additional gap and uncompressed data does not bump on the packed. However, in this case the spoils contents of multiple cells after file. In future versions Hrum '& Hrust this will be fixed. And what about compression quality: The quality of both yourself ... ----------------------------------------- My coordinates: E-Mail: dp@fmf.gasu.gorny.ru IRCNET: # Z80, nick: Hrum ICQ: nick: Hrumer Tel: 8-( 38822) -24421 Post: 659700 Gorno-Altaisk st. Gurkin 49-6 Pyankov Dmitry Yu. More recent versions can be found on my HP: http://fmf.gasu.gorny.ru/ ~ dimanp
Other articles:
Similar articles:
В этот день... 21 November