Jump to content
IGNORED

Graph2Font RLE


glurk

Recommended Posts

I looked at delta compression, but it was after I had already written the decompressor above.  And this may even work better, but I haven't done any extensive testing.  I have the encoder almost finished, and some of the SCR files are ideal for it.  The file "4thAndInches_C64_Tebe.scr" is 1200 bytes and consists of the sequence $00,$01...$77 repeated 10 times, and compresses into this:

 

.byte $F8,$00,$F8,$00,$F8,$00,$F8,$00,$F8,$00,$F8,$00,$F8,$00,$F8,$00,$F8,$00,$F8,$00,$00

 

So that's 1200 bytes down to 21 bytes, for 98.25% compression!  Even if no one else uses this, I'm going to.  The encoder is not ready yet, I'm doing it in QB64 (which I rather like) and I still have some bugs to work out...

 

 

 

 

 

Edited by glurk
  • Like 1
Link to comment
Share on other sites

So, I've "finished" this one I guess.  Not to say I won't still work on it, but it's completed, working, and bug-free as far as I can tell.  Includes a 6502 asm decompressor, and a QB64 (BASIC) compressor.

 

The ASM file uses 5 zero-page locations, one which does not require being zero-page.  It's 80 bytes assembled, relocatable, no self-modifying code, so will run from ROM.

 

The BAS program is semi-messy QB64 BASIC, but it works.  It's hard-coded to read a file named TEST.BIN, but this can be changed.  I don't know enough QB64 to make it accept drag-n-drop or command-line input.  I'll figure that out later, I first wanted to get it working.

 

The whole thing is "tuned" to compress Graph2Font SCR files, where it will work best.  It works on fonts, too, but the compression is not nearly as good for those, depending on the font itself.

 

GlurkRLE.zip

  • Like 4
Link to comment
Share on other sites

On 9/21/2021 at 6:47 AM, glurk said:

The BAS program is semi-messy QB64 BASIC, but it works.  It's hard-coded to read a file named TEST.BIN, but this can be changed.  I don't know enough QB64 to make it accept drag-n-drop or command-line input.  I'll figure that out later, I first wanted to get it working.

I found and fixed a couple bugs in your compressor (a couple missing GOTOs). I also wrote a version in Perl. I'm attaching both:

 

rle.zip

 

Both compressors reduce Gollum_C64_Rensoupp_Tebe.scr from 1200 bytes to 262 bytes, not the 253 you mentioned earlier. I'm curious if they are missing an optimization that you did in your hand encoding?

Link to comment
Share on other sites

It's possible that I made a mistake in hand encoding, which is an enormous task I undertook only because I had no compressor program at first.  But I believe that it did check out correct via binary compare...  I didn't save that data, however.

 

That said, and as you are probably aware, there is always more than one way to compress the same data.  If the compressor were multi-pass and tried a few different encodings, it might be possible to be more efficient.  The decompressor has some quirks, in that .byte $80,$00 will decompress into 255 incrementing bytes, and $40,...  will decompress 255 following "arbitrary" bytes.  At least I think that's correct, haha.

 

This was done more as an "experiment" than anything else.  It just sort of happened to have worked out well.  One big "happy accident" in a way.

 

  • Like 2
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...