ToD and LZSS compression
Posted: Mon Feb 08, 2010 12:10 am
I've been reading through the Tales of Dagur source code to help learn NDS homebrew programming. I have a few questions about the compression in ToD. I've read that ToD isn’t playable on a emulator because it “uses LZ77 compression which none of the emulators support”. There is a example that comes with libnds called 16bit_color_bmp that uses LZ77 that runs in no$gba. So I'm wondering what the whole reason for ToD not working in a emulator.
The 16bit_color_bmp uses grit instead of gfx2gba.exe and GBACrusher.exe. Also there is this code from ToD in background.cpp that I'm unable to understand.
The 16bit_color_bmp example has this code instead from decompress.c from libnds
They are both put into the decStream structure that swiDecompressLZSSVram uses in the first position.
GetSize is where getHeader is.
Could you explain what those shifts and OR are doing in getSize? I haven't done much low level memory programming so they are beyond me.
The reason I'm asking about this is I plan to make something in a rpg style and was hoping to make it work in a emulator so that people without a flash cart could play it. I'm assuming compression is important in a game with many sprites. I don't completely understand the memory limits yet.
The 16bit_color_bmp uses grit instead of gfx2gba.exe and GBACrusher.exe. Also there is this code from ToD in background.cpp that I'm unable to understand.
Code: Select all
int getSize(uint8 * source, uint16 * dest, uint32 r2)
{
u32 size = *((u32*)source) >> 8;
return (size<<8) | 16;
}
Code: Select all
int getHeader(uint8 *source, uint16 *dest, uint32 arg) {
return *(uint32*)source;
}
Code: Select all
int getHeader(uint8 *source, uint16 *dest, uint32 arg) {
return *(uint32*)source;
}
uint8 readByte(uint8 *source) {
return *source;
}
TDecompressionStream decomStream = {
getHeader,
0,
readByte
};
swiDecompressLZSSVram((void*)data, (void*)dst, 0, &decomStream);
Could you explain what those shifts and OR are doing in getSize? I haven't done much low level memory programming so they are beyond me.
The reason I'm asking about this is I plan to make something in a rpg style and was hoping to make it work in a emulator so that people without a flash cart could play it. I'm assuming compression is important in a game with many sprites. I don't completely understand the memory limits yet.