Talk:Content.bin file structure

From WiiBrew
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

"This code is NOT fully functional, because sometimes the algorithm request data not present in the buffer, and fills it with 'X' instead. Maybe someone can fix it, I think it's not difficult ;)"

I noticed this myself when writing a decompressor for a format similar to LZ77. Sometimes it will do things like request 8 bytes from only 2 bytes before the end of the buffer. This can be very difficult to emulate if you're decompressing file-to-file, but easy if you actually decompress to a buffer in RAM and then dump the buffer to disk. The trick is it ends up repeating those 2 bytes. To help visualize the process, imagine the contents of the buffer as you do this:

01 02 01 XX XX XX XX XX copy first byte to end of buffer
01 02 01 02 XX XX XX XX copy second byte
01 02 01 02 01 XX XX XX when you reach the third byte, it's no longer past the end of the buffer, because you just copied 2 more bytes into it.