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 > LZSS decompress

#175867 - brave_orakio - Mon Feb 21, 2011 5:34 am

Hi, I'm gonna make an LZSS decompressor but my compressed data isn't vram safe because... I fail at it. The data is correctly compressed though cause I tried using the GBA built in decompressor (decompressed to EWRAM) and the image that I got was correct when I transferred it to vram.

so I decided to try to make the decompression vram safe by buffering to 8 or 16 word chunks and then copy these to vram as they get filled up and then repeat the preocess till the whole image is decompressed. Question is, are these 8 or 16 word chunks better being copied to vram through dma or am I better off using stmia/ldmia using C asm function?

Also does reading data from ROM have a huge performance hit? I plan to put the decompress function in IWRAM but the compressed data will be read straight from ROM into 8 or 16 word buffer(Technically still IWRAM) and then to vram.
_________________
help me

#175870 - Miked0801 - Mon Feb 21, 2011 3:57 pm

For such small xfers, don't use DMA. ldmia/stmia will be much more efficient. Better yet, have your algorithm copy directly to VRAM or wherever instead of to a staging buffer. If you output at least 16-bits of data at a time, then you can copy directly to VRAM without issue. Or if you need the staging buffer and don't want to use asm, do something like this:

struct Generic_32_bytes
{
unsigned int word1;
unsigned int word2;
unsigned int word3;
unsigned int word4;
unsigned int word5;
unsigned int word6;
unsigned int word7;
unsigned int word8;
};

void copy32Bytes(u8 *inputPtr, u8 *outputPtr)
{
Generic_32_bytes *src, *dest;

src = (Generic_32_bytes *)inputPtr;
dest = (Generic_32_bytes *)outputPtr;

*dest = *src;
}

The above should translate nicely into the asm instructions you want. Be sure to tell it to compile as ARM and to place it in fast RAM as well.

#175872 - brave_orakio - Tue Feb 22, 2011 1:22 am

Ah yes! Thank you that sounds much easier to do. I am ashamed to admit that I am not very comfortable with ASM! I probably need/want the buffer since it might make things faster especially when copying in chunks like this.

But then I'll also try your suggestion to copy directly, I could definitely be wrong about copying in chunks being faster since the algorithm will definitely be a little complicated thanks to the buffer.
_________________
help me