- added support for Yaz0 decompression on banners and system menu resources (This is needed by some Custom Wii System Menu Themes like the DarkWii Theme. Hopefully now all System Menu Themes are supported as layout.) (thx darkwii and atymick for the info about the used Yaz0 compression in those themes.)

This commit is contained in:
dimok789 2012-07-15 05:43:23 +00:00
parent d5baaa39e6
commit 2300f6d872
2 changed files with 22 additions and 2 deletions

View File

@ -23,6 +23,7 @@
#include "lz77.h"
#include "gecko.h"
#include "U8Archive.h"
#include "uncompress.h"
#define RU(N, S) ((((N) + (S) - 1) / (S)) * (S))
@ -160,6 +161,22 @@ u8 *U8Archive::DecompressCopy( const u8 * stuff, u32 len, u32 *size ) const
return NULL;
}
}
else if( (len > 8) && *(u32*)( stuff ) == 0x59617a30 )// Yaz0
{
// Yaz0 with a magic word
Yaz0_Header *header = (Yaz0_Header *) stuff;
// set decompress length
len = header->decompressed_size;
// allocate memory
ret = (u8*) memalign(32, ALIGN32(len));
if(!ret)
{
gprintf("out of memory\n");
return NULL;
}
// function can not fail at this point
uncompressYaz0(stuff, ret, len);
}
else if( isLZ77compressed( stuff ) )
{
// LZ77 with no magic word
@ -179,7 +196,7 @@ u8 *U8Archive::DecompressCopy( const u8 * stuff, u32 len, u32 *size ) const
else
{
// just copy the data out of the archive
ret = (u8*)memalign( 32, len );
ret = (u8*)memalign( 32, ALIGN32( len ) );
if( !ret )
{
gprintf( "out of memory\n" );

View File

@ -49,9 +49,12 @@ u8 * uncompressLZ77(const u8 *inBuf, u32 inLength, u32 * size)
//the second 4 bytes in the Yaz0 header).
void uncompressYaz0(const u8* srcBuf, u8* dst, int uncompressedSize)
{
if(!srcBuf || !dst)
return;
const u8 * src = srcBuf;
if(memcmp(src, "Yaz0", 4) == 0)
if(*((u32*)src) == 'Yaz0')
{
src += sizeof(Yaz0_Header);
}