mirror/dolphin-emu — pull request #34 by john-peterson (2013-06-06 07:03:08+00:00)
Title: Making the 32 and 64 bit state compression equal

### Problem

The LZO block size value bit length is different in 32 and 64 bit with the result that a 64 bit state can't be loaded in a 32 bit build and vice versa

### Solution

### Discussion

>[06:48] <_RachelB> JPeterson: oh, if you're going to do anything with the compression, something to keep in mind is that states created in 64 bit builds cannot be extracted in 32 bit builds, and vice versa. Uncompressed save states work perfectly. That might be worth fixing if you're making changes anyway

printf test>file.bin

# compress with `lzo_uint src_len` instead of `lzo_uint32 src_len`

$ xxd -i 32.lzo
unsigned char __32_lzo[] = {
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x74, 0x65, 0x73, 0x74,
0x00, 0x00, 0x00, 0x00
};
unsigned int __32_lzo_len = 16;

$ xxd -i 64.lzo
unsigned char __64_lzo[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00
};
unsigned int __64_lzo_len = 24;

This mirror the lzop code for [`lzo1x_1_compress`](https://github.com/mirror/lzop/blob/master/src/p_lzo.c#L322) and [`lzo1x_decompress`](https://github.com/mirror/lzop/blob/master/src/p_lzo.c#L538)

the block length doesn't exceed the u32 max value because of these limits

* [lzop](https://github.com/mirror/lzop/blob/master/src/lzop.c#L429): 0x80000000
* [dolphin-emu](https://github.com/mirror/dolphin-emu/blob/master/Source/Core/Core/Src/State.cpp#L34): 0x80