Harry Potter Posted September 18, 2021 Share Posted September 18, 2021 Hi! I have my own version of the Stac technique at c65 additions - Manage /compress at SourceForge.net and am wondering how I can enhance it. I added code to the compressor to make sure lz77 gets best usage. It worked. I tried other ideas, including MTF and some of my own strategies. The best I got was to break even. I could try Adaptive Huffman Code, but the version I have is buggy. Does anybody out there have any ideas on how to better the Stac technique? Quote Link to comment Share on other sites More sharing options...
vitoco Posted September 18, 2021 Share Posted September 18, 2021 I think it depends on what do you want to compress. A simple RLE could be enough for some types of images, while LZSS could apply for other. I really don't know which is the best algorithm for random assembly code. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 18, 2021 Author Share Posted September 18, 2021 I am looking to compress documents. I am coding compression for Template Creator, which is a utility for multiple platforms to handle template files. I will try wikipedia.com again now. Quote Link to comment Share on other sites More sharing options...
xxl Posted September 18, 2021 Share Posted September 18, 2021 look over there, you will find links to decompressors in 6502. I recommend getting interested in ZX0 the last few files in ATR from this thread are compressed in ZX0 with on-the-fly decompression by the loader: Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 18, 2021 Author Share Posted September 18, 2021 Thank you. I'm looking at it now. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 18, 2021 Author Share Posted September 18, 2021 I tried it. It unrealistically back-fired on me. I assume I'm doing something wrong. I attached the code here, but it was created on cc65 for CBM targets, so it needs some translation. Also, I didn't add quick LZ blocks. compress_zx0_001.zip Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 20, 2021 Author Share Posted September 20, 2021 I got the technique to work, but it worked worse than Stac. I didn't try the quick-LZ77 technique, though. Quote Link to comment Share on other sites More sharing options...
xxl Posted September 20, 2021 Share Posted September 20, 2021 3 hours ago, Harry Potter said: I got the technique to work, but it worked worse than Stac. I didn't try the quick-LZ77 technique, though. Stac = LZS? if so, could you make an example, because I checked before and LZS is much worse, so there must be an error somewhere - probably in my test - so make the test and put the result here. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 20, 2021 Author Share Posted September 20, 2021 I have my version of Stac at c65 additions - Manage /compress at SourceForge.net, but it requires cc65 and a CBM emulator. To compress a file, open the file as #10, call CompStac, close file #10 and save the contents of OutBuffer len. OutPos to the destination file. To decompress, load the file to InBuffer, open the output as file #10, run DecoStac and close file #10. Quote Link to comment Share on other sites More sharing options...
xxl Posted September 20, 2021 Share Posted September 20, 2021 5 minutes ago, Harry Potter said: I have my version of Stac at c65 additions - Manage /compress at SourceForge.net, but it requires cc65 and a CBM emulator. To compress a file, open the file as #10, call CompStac, close file #10 and save the contents of OutBuffer len. OutPos to the destination file. To decompress, load the file to InBuffer, open the output as file #10, run DecoStac and close file #10. unfortunately, I can't handle c64, so clean data is enough: file, source length, compressed length for your STAC and ZX0 versions - it will be decisive. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 20, 2021 Author Share Posted September 20, 2021 (edited) I attached the test file I'm using here. Your technique gave me 31 blocks. Stac gives me 28 blocks. I enhanced Stac using a quick LZ77 variant where the last LZ77 block was shortened further and got 25 blocks. I admit I didn't use the quick-LZ77 technique in ZX0. trim.sh.prg Edited September 20, 2021 by Harry Potter Forgot the attachment! :( Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 20, 2021 Author Share Posted September 20, 2021 BTW, on a Commodore, a block is 254 btyes. Quote Link to comment Share on other sites More sharing options...
xxl Posted September 20, 2021 Share Posted September 20, 2021 14 minutes ago, Harry Potter said: I attached the test file I'm using here. Your technique gave me 31 blocks. Stac gives me 28 blocks. I enhanced Stac using a quick LZ77 variant where the last LZ77 block was shortened further and got 25 blocks. I admit I didn't use the quick-LZ77 technique in ZX0. trim.sh.prg 16.04 kB · 0 downloads I think I wrote it not clearly: put the source file and write how many bytes has after your Stac compression. otherwise we won't get anywhere. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 20, 2021 Author Share Posted September 20, 2021 I gave the example test file I'm using and the compressed sizes using the different compression techniques. I don't understand your latest comment. BTW, the test input file is worth 65 blocks. If you want the size in bytes, I have to do more to get them, as I killed some of the information while enhancing Stac. Quote Link to comment Share on other sites More sharing options...
xxl Posted September 20, 2021 Share Posted September 20, 2021 2 hours ago, Harry Potter said: I gave the example test file I'm using and the compressed sizes using the different compression techniques. I don't understand your latest comment. BTW, the test input file is worth 65 blocks. If you want the size in bytes, I have to do more to get them, as I killed some of the information while enhancing Stac. so this file is 16 425 bytes long you packed it into 25 blocks that is 6 350 bytes ZX0 pack it to 22 blocks that is 5 750 bytes so the ZX0 is better. are these calculations wrong? Are you getting different results? weird. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 20, 2021 Author Share Posted September 20, 2021 Sorry. Should I attach my source code so you can see what I did wrong? Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 21, 2021 Author Share Posted September 21, 2021 I got it down to 23 blocks. One of the things I was doing wrong was writing an extra 1-bit to an Elias output. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 21, 2021 Author Share Posted September 21, 2021 Uhh...what is the LZ77 sliding dictionary size of LZ0? My version is 2k. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 21, 2021 Author Share Posted September 21, 2021 I increased the sliding LZ77 dictionary to 3k and got 22 blocks. I tried other ways to improve ZX0, including MTF and techniques I wouldn't mind revealing too much and at best broke even. Quote Link to comment Share on other sites More sharing options...
xxl Posted September 21, 2021 Share Posted September 21, 2021 2 hours ago, Harry Potter said: I increased the sliding LZ77 dictionary to 3k and got 22 blocks. I tried other ways to improve ZX0, including MTF and techniques I wouldn't mind revealing too much and at best broke even. great, compress this file ( https://atariage.com/forums/applications/core/interface/file/attachment.php?id=807550 ) so that you can compare the results with other compressors - give the result in bytes, not blocks. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 23, 2021 Author Share Posted September 23, 2021 I really want to improve ZX0. I can try Adaptive Huffman Codes, but my current version is buggy. I'm also writing the bit stream in the wrong direction, i.e. starting at bit 0, not 7. How do I do the latter correctly? Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 25, 2021 Author Share Posted September 25, 2021 I just implemented one of my compression techniques and cut down the size of the compressed file to 17 blocks , but I first need to debug it. Again, how do I implement the bit stream the right way? Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 25, 2021 Author Share Posted September 25, 2021 BTW, it's doing better than my technique. May I use ZX0 as a backdrop to my compression technique? Quote Link to comment Share on other sites More sharing options...
ivop Posted September 25, 2021 Share Posted September 25, 2021 (edited) On 9/23/2021 at 4:35 PM, Harry Potter said: I'm also writing the bit stream in the wrong direction, i.e. starting at bit 0, not 7. How do I do the latter correctly? Shift out your bits at the other end of the byte? In 6502 assembly it's either ASL or LSR to shift out bits to the carry bit, which can the be shifted into the output stream with LSR or ASL respectively. You can do similar things in C, like bit=byte&1; byte >>=1; output<<=1; output|=bit; and loop. Or the reverse with &0x80 and reversed shifts, depending on if you want LE or BE output. Edited September 25, 2021 by ivop Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 25, 2021 Author Share Posted September 25, 2021 I know how to do the shifting. I just need the algorithm to get the shift value, i.e. the number of bits to shift the value. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.