gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > BIOs unrlcomp request

#80505 - interdpth - Sun Apr 23, 2006 12:40 am

I'm working on an editor in Visual BASIC and i'd like to make an export function and have it export an BIO compatible RLE compressed file. I know that most of you will probably flame me for coding in VB but if anyone happens to have a BIOs compatatible UnRlComp function in VB could you please show it to me any help is appreciated it. :)

#80510 - tepples - Sun Apr 23, 2006 2:35 am

First off, do you know the basic concept behind run-length encoding? You need your program to take a byte array, recognize all runs of three-in-a-row pr more of one 8-bit symbol and "literal strings" (runs of no three-in-a-rows), and then output all such runs.

GBATEK says that the RLUncomp data stream starts with 1 byte of constant value 30 hex, then 3 bytes representing the length in bytes of uncompressed data (in little endian).

For a literal string of 1 to 128 bytes, write n - 1 followed by the bytes.
For a run of 3 to 130 copies of a repeated byte, write n + 125 followed by the byte which shall be repeated.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.