Talk:Content.bin file structure: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 10: | Line 10: | ||
: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. | :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. | ||
Revision as of 11:32, 1 March 2008
"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 XX XX XX XX XX XX
- 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.