Today I'm going to be making a SmileBASIC compressor/decompressor that makes a 'zip' than can be 'unzipped'. It's going to be stored in an array of byte numbers (the ASC of each character).How will you be ZIPping it? I mean, just making a DAT file with ASCs will not make anything smaller. In fact, it will make everything bigger!
SmileBASIC File compression system
Root / Talk About Programs / [.]
chemicalexCreated:
Today I'm going to be making a SmileBASIC compressor/decompressor that makes a 'zip' than can be 'unzipped'. It's going to be stored in an array of byte numbers (the ASC of each character).
Fortunately my method has changed. If the command is larger than 3 characters, it converts to a 3-character value (such as !#( or #=- )Today I'm going to be making a SmileBASIC compressor/decompressor that makes a 'zip' than can be 'unzipped'. It's going to be stored in an array of byte numbers (the ASC of each character).How will you be ZIPping it? I mean, just making a DAT file with ASCs will not make anything smaller. In fact, it will make everything bigger!
Well that would be handy. 4 megs of upload space isn't very much.
Well that would be handy. 4 megs of upload space isn't very much.I've written down every command in the sb library (finally)... now for decompressimg
I would suggest starting with something like Huffman Coding https://en.m.wikipedia.org/wiki/Huffman_coding. Code is largely text so this should work well. Although, using it on a binary file will probably end up making the files larger. It may be awkward to do it without pointers to make a proper tree, but if you can manage to make a dictionary of sorts that maps characters to variable length bit patterns you should be set. I hope you are comfortable with bit masks and bit shifting.
If you can do that, the next step would be to look at something like https://en.m.wikipedia.org/wiki/LZ77_and_LZ78 LZW compression where you replace repeated patterns in a sliding window with back references. I haven't tried that one before but it shouldn't be much harder (I think).
Finally you could try marrying the two into something like the deflate algorithm https://en.m.wikipedia.org/wiki/DEFLATE. Which is the heart of gzip and of course actual zip files. Gzip is probably the simpler one to try to copy but only works on single files which is usually worked around by gathering things into a Tar (tape archive) file first.
Good luck.
in addition to the above, a reminder that an actual good file compression package already exists in http://wiki.hosiken.jp/petc3gou/?Toukou%2F%A5%D5%A5%A1%A5%A4%A5%EB%A4%F2%A4%DE%A4%C8%A4%E1%A4%C6%B0%B5%BD%CC
in case anyone thinks this should be done for anything other than fun