Hi folks, I finally found the time to add support for the infamous CPX file format to my MODE utility. The ZIP file includes a sample ega.cpx in the directory source/mode - you can see by doing upx -l ega.cpx that I have created it by ren ega.cpi ega.com upx --8086 ega.com ren ega.com ega.cpx ... Not exactly what UPX was originally written for but works great :-).
So now you can do: ... DISPLAY CON=(VGA,437,1) (or similar) and then: MODE CON CODEPAGE PREPARE=((858) x:ega.cpx) to load the compressed CPI file! MODE will decompress it in RAM and then ask DISPLAY to load it. Actually the CPX file will decompress itself. For that, MODE patches a RETF into the right place and CALL-FARs the CPX in RAM as if it would be a COM program. For a 6-codepage file like EGA.CPI, you can generally achieve UPX compression ratios close to 1:10, so the EGA.CPX is less than 7k in size. Codepage 858 is, by the way, codepage 850 plus the Euro currency symbol. http://www.coli.uni-sb.de/~eric/stuff/soft/ mode-29apr2004.zip Let me know if it works for you and when you have some more CPX files uploaded to some homepage out there :-). Note that without the --8086 option the CPX file will contain a 286+ "rol [...],8" command instead of a "mov / xchg bl,bh / mov" one to squeeze out a few bytes more. Such CPX files will not open properly on 8086 CPUs, obviously. Technical background on executable compression: All formats which I have seen by now (LZEXE, PKLITE, UPX) compress executables as a mix of bytes and bitstream-bytes. While LZEXE and PKLITE sometimes use tables to "inflate" values taken from the bitstream, UPX is more straightforward and has an highly optimized (both for size and speed) decompression stub. What happens when you "run" an UPXed COM file is: - check if SP is > (size of decompressed data + stub + 0x100 + 0x60) - copy compressed data and decompressor to where end-of-decompressed-data will be - jump to decompressor, run it - decompressed data is now at offsets 0x100 - just-before-the-decompressor - jump back to 0x100. The UPX compression format looks like this: 1. word bitstring bits 2. literal byte(s), because the first part of a COM cannot be compressed as repetition of something before, and because the bit string buffer will be empty at first. 3. after the initial literal bytes, you have more bitstring words (at all places where the bitstring buffer runs empty), more literal bytes and in addition distance bytes (the high half of the distance and the information about how many bytes have to be copied etc. are all encoded in the bit string). A great file format where the simple and effective encoding and decompressor is certainly nothing compared to the big efforts to convert a file into an encoded version with as few bytes as possible. I once wrote a few compressors myself years ago (one to try LZW algorithm, one to try "encode repeated strings as copy-n-bytes-from-distance-m" style algorithms). Both would compress CPI files from 60k to 20k or even (much) worse. Pretty much like the LZSS (only 500 lines of C) open source LZW+HuffmanCoding program (which claims to have limited MS EXPAND compatibility). UPX on the other hand compresses hardly any worse than GZIP / ZIP, with a decompressor which is only 100 bytes or something while GUNZIP/MINGZIP and even TUNZ are huge compared to that. Congrats! [Potential NEWS ITEM text: MODE 29apr2004 now supports UPX compressed CPI files. To convert CPI to CPX, 1. rename to com 2. compress with UPX 3. rename to CPX. The new file format helps you to save 80-90% of the disk space. Although it has more features, MODE is now smaller. Thanks to the prf.c tiny printf() replacement author for that.] Or compose some somehow bigger news item text. I can post a news item myself BUT I would like to wait with that until I get a) some "yes, it works" feedback and b) mail from people who have put collections of compressed CPI files on some homepage. Please do not send me files by mail, just send the URL. Thanks. Happy testing! Eric. ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ Freedos-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freedos-devel