| |
Karoshier Account closed
Registered: May 2010 Posts: 15 |
Koala compression
Hi there,
out of simple curiosity I'm digging into the .gg file format and its compression algo.
Unfortunately, codebase64 does not report information on how gg files are packed. Therefore, with a brief search, I've managed to find the following file, which is a test image ($175A bytes) written in such format.
http://www.editorix.org/congo/html/examples/test.gg
By looking into the file with an hex editor, it seems to me that it's a simple RLE packed stuff (which still loads at $6000 by the way), with escape code $FE followed a byte indicating the value to repeat and a further byte indicating the amount of repetitions.
Does anybody know whether I am correct in my assumption and whether there is anything I'm missing?
Cheers |
|
| |
Skate
Registered: Jul 2003 Posts: 490 |
yeah, it looks like RLE but magic byte can be $AA as well as $FE. |
| |
MagerValp
Registered: Dec 2001 Posts: 1056 |
#!/usr/bin/env python
with open("test.gg", "rb") as infile:
with open("test.koa", "wb") as outfile:
loadaddr = infile.read(2)
outfile.write(loadaddr)
while True:
c = infile.read(1)
if not c:
break
if c == "\xfe":
c = infile.read(1)
count = ord(infile.read(1))
if count == 0:
count = 256
else:
count = 1
outfile.write(c * count)
|
| |
Karoshier Account closed
Registered: May 2010 Posts: 15 |
Thanks MagerValp for the quick script.
I've found out that the very same packing algo is also used for doodle; even the escape/magic byte is the same.
I'll try to update the corresponding article by groepaz/hitmen on codebase64, or have one of the admins do that if I don't have permission for it. |
| |
Frantic
Registered: Mar 2003 Posts: 1627 |
@Karoshier: All you need to do to update an article on codebase is to register. No special permissions needed.
//FTC (Codebase admin) |
| |
Karoshier Account closed
Registered: May 2010 Posts: 15 |
I've noticed that, thanks Frantic.
The page has been updated. I hope that'll be useful to other sceners as well.
Here's the link, just for the sake of completeness.
http://www.codebase64.org/doku.php?id=base:c64_grafix_files_spe.. |