undo the code formatting. somehow it got screwed up

This commit is contained in:
giantpune 2010-02-09 10:59:55 +00:00
parent f988afc60d
commit bf03e49dc6
401 changed files with 61944 additions and 59427 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r908</version>
<release_date>201002090353</release_date>
<version>1.0 r909</version>
<release_date>201002091053</release_date>
<short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

View File

@ -67,7 +67,8 @@ typedef struct ftgxDataOffset_ {
FreeTypeGX::FreeTypeGX(uint8_t textureFormat, uint8_t vertexIndex, uint32_t compatibilityMode)
:
ftFace(NULL),
ftFace_fromFile(NULL) {
ftFace_fromFile(NULL)
{
FT_Init_FreeType(&this->ftLibrary);
this->textureFormat = textureFormat;
@ -260,8 +261,10 @@ void FreeTypeGX::clearGlyphData() {
GX_DrawDone();
GX_Flush();
for ( std::map<uint16_t, FTGX_Cache>::iterator i = this->fontDatas.begin(); i != this->fontDatas.end(); i++) {
for ( FTGX_Cache::iterator j = i->second.begin(); j != i->second.end(); j++) {
for ( std::map<uint16_t, FTGX_Cache>::iterator i = this->fontDatas.begin(); i != this->fontDatas.end(); i++)
{
for ( FTGX_Cache::iterator j = i->second.begin(); j != i->second.end(); j++)
{
free(j->second.glyphDataTexture);
}
i->second.clear();
@ -277,7 +280,8 @@ void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) {
if(hPointSize == 0) hPointSize = vPointSize;
if(vPointSize > 255) vPointSize = 255;// limit to 255
if(hPointSize > 255) hPointSize = 255;
if (this->ftPointSize_v != vPointSize || this->ftPointSize_h != hPointSize) {
if(this->ftPointSize_v != vPointSize || this->ftPointSize_h != hPointSize)
{
// this->clearGlyphData();
this->ftPointSize_v = vPointSize;
this->ftPointSize_h = hPointSize;
@ -356,11 +360,13 @@ uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t texture
* @param charCode The requested glyph's character code.
* @return A pointer to the allocated font structure.
*/
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) {
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode)
{
FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8];
return cacheGlyphData(charCode, fontData);
}
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, FTGX_Cache &fontData) {
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, FTGX_Cache &fontData)
{
FT_UInt gIndex;
uint16_t textureWidth = 0, textureHeight = 0;

View File

@ -203,7 +203,9 @@ typedef struct ftgxDataOffset_ ftgxDataOffset;
#define FTGX_COMPATIBILITY_GRRLIB FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE
#define FTGX_COMPATIBILITY_LIBWIISPRITE FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT
const GXColor ftgxWhite = (GXColor) {0xff, 0xff, 0xff, 0xff}
const GXColor ftgxWhite = (GXColor) {
0xff, 0xff, 0xff, 0xff
}
; /**< Constant color value used only to sanitize Doxygen documentation. */
/*! \class FreeTypeGX

View File

@ -39,21 +39,25 @@
#include "ZipFile.h"
#include "language/gettext.h"
ZipFile::ZipFile(const char *filepath) {
ZipFile::ZipFile(const char *filepath)
{
File = unzOpen(filepath);
if(File)
this->LoadList();
}
ZipFile::~ZipFile() {
ZipFile::~ZipFile()
{
unzClose(File);
}
bool ZipFile::LoadList() {
bool ZipFile::LoadList()
{
return true;
}
bool ZipFile::ExtractAll(const char *dest) {
bool ZipFile::ExtractAll(const char *dest)
{
if(!File)
return false;
@ -73,11 +77,13 @@ bool ZipFile::ExtractAll(const char *dest) {
if(ret != UNZ_OK)
Stop = true;
while (!Stop) {
while(!Stop)
{
if(unzGetCurrentFileInfo(File, &cur_file_info, filename, sizeof(filename), NULL, NULL, NULL, NULL) != UNZ_OK)
Stop = true;
if (!Stop && filename[strlen(filename)-1] != '/') {
if(!Stop && filename[strlen(filename)-1] != '/')
{
u32 uncompressed_size = cur_file_info.uncompressed_size;
u32 done = 0;
@ -95,10 +101,12 @@ bool ZipFile::ExtractAll(const char *dest) {
subfoldercreate(temppath);
if (ret == UNZ_OK) {
if(ret == UNZ_OK)
{
FILE *pfile = fopen(writepath, "wb");
do {
do
{
ShowProgress(tr("Extracting files..."), 0, pointer+1, done, uncompressed_size);
if(uncompressed_size - done < blocksize)

View File

@ -30,14 +30,16 @@
#include "unzip/unzip.h"
typedef struct {
typedef struct
{
u64 offset; // ZipFile offset
u64 length; // uncompressed file length in 64 bytes for sizes higher than 4GB
bool isdir; // 0 - file, 1 - directory
char filename[256]; // full filename
} FileStructure;
class ZipFile {
class ZipFile
{
public:
//!Constructor
ZipFile(const char *filepath);

View File

@ -110,14 +110,16 @@
* array. They're divided up into four groups of 16.
*/
static const uint8_t K[3][16] = {
static const uint8_t K[3][16] =
{
/* Round 1: skipped (since it is simply sequential). */
{ 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12 }, /* R2 */
{ 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2 }, /* R3 */
{ 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 } /* R4 */
};
static const uint8_t S[4][4] = {
static const uint8_t S[4][4] =
{
{ 7, 12, 17, 22 }, /* Round 1 */
{ 5, 9, 14, 20 }, /* Round 2 */
{ 4, 11, 16, 23 }, /* Round 3 */
@ -125,7 +127,8 @@ static const uint8_t S[4][4] = {
};
static const uint32_t T[4][16] = {
static const uint32_t T[4][16] =
{
{ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, /* Round 1 */
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
@ -224,7 +227,8 @@ static void Permute( uint32_t ABCD[4], const unsigned char block[64] )
* to read the block in Little Endian order (the algorithm assumes this).
* The uint32_t values are then handled in host order.
*/
for ( i = 0, j = 0; i < 16; i++ ) {
for( i = 0, j = 0; i < 16; i++ )
{
X[i] = (uint32_t)block[j++];
X[i] |= ((uint32_t)block[j++] << 8);
X[i] |= ((uint32_t)block[j++] << 16);
@ -245,8 +249,10 @@ static void Permute( uint32_t ABCD[4], const unsigned char block[64] )
* (My implementation appears to be a poor compromise between speed, size,
* and clarity. Ugh. [crh])
*/
for ( round = 0; round < 4; round++ ) {
for ( i = 0; i < 16; i++ ) {
for( round = 0; round < 4; round++ )
{
for( i = 0; i < 16; i++ )
{
j = (4 - (i % 4)) & 0x3; /* <j> handles the rotation of ABCD. */
s = S[round][i%4]; /* <s> is the bit shift for this iteration. */
@ -257,7 +263,8 @@ static void Permute( uint32_t ABCD[4], const unsigned char block[64] )
/* The actual perumation function.
* This is broken out to minimize the code within the switch().
*/
switch ( round ) {
switch( round )
{
case 0:
/* round 1 */
a = md5F( b, c, d ) + X[i];
@ -369,10 +376,12 @@ auth_md5Ctx *auth_md5SumCtx( auth_md5Ctx *ctx,
/* Copy the new block's data into the context block.
* Call the Permute() function whenever the context block is full.
*/
for ( i = 0; i < len; i++ ) {
for( i = 0; i < len; i++ )
{
ctx->block[ ctx->b_used ] = src[i];
(ctx->b_used)++;
if ( 64 == ctx->b_used ) {
if( 64 == ctx->b_used )
{
Permute( ctx->ABCD, ctx->block );
ctx->b_used = 0;
}
@ -423,7 +432,8 @@ auth_md5Ctx *auth_md5CloseCtx( auth_md5Ctx *ctx, unsigned char *dst )
/* We need 8 bytes to store the length field.
* If we don't have 8, call Permute() and reset the context block.
*/
if ( 56 < ctx->b_used ) {
if( 56 < ctx->b_used )
{
Permute( ctx->ABCD, ctx->block );
for( i = 0; i < 64; i++ )
ctx->block[i] = 0;
@ -442,7 +452,8 @@ auth_md5Ctx *auth_md5CloseCtx( auth_md5Ctx *ctx, unsigned char *dst )
/* Now copy the result into the output buffer and we're done.
*/
for ( i = 0; i < 4; i++ ) {
for( i = 0; i < 4; i++ )
{
dst[ 0+i] = GetLongByte( ctx->ABCD[0], i );
dst[ 4+i] = GetLongByte( ctx->ABCD[1], i );
dst[ 8+i] = GetLongByte( ctx->ABCD[2], i );
@ -564,7 +575,8 @@ unsigned char * MD5fromFile(unsigned char *dst, const char *src)
return NULL;
}
do {
do
{
read = fread(buffer, 1, blksize, file);
(void)auth_md5SumCtx( ctx, buffer, read ); /* Pass only one block. */
@ -579,11 +591,13 @@ unsigned char * MD5fromFile(unsigned char *dst, const char *src)
} /* auth_md5Sum */
const char * MD5ToString(const unsigned char * hash, char * dst) {
const char * MD5ToString(const unsigned char * hash, char * dst)
{
char hexchar[3];
short i = 0, n = 0;
for (i = 0; i < 16; i++) {
for (i = 0; i < 16; i++)
{
sprintf(hexchar, "%02X", hash[i]);
dst[n++] = hexchar[0];
@ -595,11 +609,13 @@ const char * MD5ToString(const unsigned char * hash, char * dst) {
return dst;
}
unsigned char * StringToMD5(const char * hash, unsigned char * dst) {
unsigned char * StringToMD5(const char * hash, unsigned char * dst)
{
char hexchar[2];
short i = 0, n = 0;
for (i = 0; i < 16; i++) {
for (i = 0; i < 16; i++)
{
hexchar[0] = hash[n++];
hexchar[1] = hash[n++];

View File

@ -2,7 +2,8 @@
#define MD5_H
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/* ========================================================================== **
*
@ -84,7 +85,8 @@ extern "C" {
* Typedefs:
*/
typedef struct {
typedef struct
{
unsigned int len;
unsigned int ABCD[4];
int b_used;

View File

@ -22,7 +22,8 @@
#include "patches/fst.h"
#include "usbloader/fstfile.h"
s32 dump_banner(const u8* discid,const char * dest) {
s32 dump_banner(const u8* discid,const char * dest)
{
// Mount the disc
//Disc_SetWBFS(1, (u8*)discid);
Disc_SetUSB(discid);
@ -46,7 +47,8 @@ s32 dump_banner(const u8* discid,const char * dest) {
// Read where to find the fst.bin
u32 *buffer = memalign(32, 0x20);
if (buffer == NULL) {
if (buffer == NULL)
{
//Out of memory
return -1;
}
@ -59,7 +61,8 @@ s32 dump_banner(const u8* discid,const char * dest) {
void *fstbuffer = memalign(32, buffer[2]*4);
FST_ENTRY *fst = (FST_ENTRY *)fstbuffer;
if (fst == NULL) {
if (fst == NULL)
{
//Out of memory
free(buffer);
return -1;
@ -76,13 +79,16 @@ s32 dump_banner(const u8* discid,const char * dest) {
int i;
u32 index = 0;
for (i=1;i<count;i++) {
if (strstr(fstfiles(fst, i), "opening.bnr") != NULL) {
for (i=1;i<count;i++)
{
if (strstr(fstfiles(fst, i), "opening.bnr") != NULL)
{
index = i;
}
}
if (index == 0) {
if (index == 0)
{
//opening.bnr not found
free(fstbuffer);
return -1;
@ -91,7 +97,8 @@ s32 dump_banner(const u8* discid,const char * dest) {
// Load the .bnr
u8 *banner = memalign(32, fst[index].filelen);
if (banner == NULL) {
if (banner == NULL)
{
//Out of memory
free(fstbuffer);
return -1;
@ -107,7 +114,8 @@ s32 dump_banner(const u8* discid,const char * dest) {
//SDCard_Init();
WDVD_SetUSBMode(NULL, 0);
FILE *fp = fopen(dest, "wb");
if (fp) {
if(fp)
{
fwrite(banner, 1, fst[index].filelen, fp);
fclose(fp);
}

View File

@ -9,7 +9,8 @@
#define BANNER_H
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
s32 dump_banner(const u8 *discid,const char * dest);

View File

@ -6,7 +6,8 @@
***************************************************************************/
#include "gui_banner.h"
GuiBanner::GuiBanner(const char *tplfilepath) {
GuiBanner::GuiBanner(const char *tplfilepath)
{
memory = NULL;
tplfilesize = 0;
width = 0;
@ -61,7 +62,8 @@ GuiBanner::GuiBanner(const char *tplfilepath) {
}
}
GuiBanner::GuiBanner(void *mem, u32 len, int w, int h) {
GuiBanner::GuiBanner(void *mem, u32 len, int w, int h)
{
if(!mem || !len)
return;
memory = mem;
@ -90,14 +92,16 @@ GuiBanner::GuiBanner(void *mem, u32 len, int w, int h) {
filecheck = true;
}
GuiBanner::~GuiBanner() {
GuiBanner::~GuiBanner()
{
if(memory != NULL) {
free(memory);
memory = NULL;
}
}
void GuiBanner::Draw() {
void GuiBanner::Draw()
{
LOCK(this);
if(!filecheck ||!this->IsVisible())
return;

View File

@ -10,7 +10,8 @@
#include "libwiigui/gui.h"
class GuiBanner : public GuiImage {
class GuiBanner : public GuiImage
{
public:
//!Constructor
//!\param tplfilepath Path of the tpl file

View File

@ -28,38 +28,46 @@
#include "../ramdisk/ramdisk.h"
#include "../listfiles.h"
u16 be16(const u8 *p) {
u16 be16(const u8 *p)
{
return (p[0] << 8) | p[1];
}
u32 be32(const u8 *p) {
u32 be32(const u8 *p)
{
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
}
u64 be64(const u8 *p) {
u64 be64(const u8 *p)
{
return ((u64)be32(p) << 32) | be32(p + 4);
}
u64 be34(const u8 *p) {
u64 be34(const u8 *p)
{
return 4 * (u64)be32(p);
}
void wbe16(u8 *p, u16 x) {
void wbe16(u8 *p, u16 x)
{
p[0] = x >> 8;
p[1] = x;
}
void wbe32(u8 *p, u32 x) {
void wbe32(u8 *p, u32 x)
{
wbe16(p, x >> 16);
wbe16(p + 2, x);
}
void wbe64(u8 *p, u64 x) {
void wbe64(u8 *p, u64 x)
{
wbe32(p, x >> 32);
wbe32(p + 4, x);
}
void md5(u8 *data, u32 len, u8 *hash) {
void md5(u8 *data, u32 len, u8 *hash)
{
MD5(hash, data, len);
}
@ -90,14 +98,16 @@ typedef struct {
u32 payload_data;
} imd5_header_t;
typedef struct {
typedef struct
{
u16 type;
u16 name_offset;
u32 data_offset; // == absolut offset från U.8- headerns början
u32 size; // last included file num for directories
} U8_node;
typedef struct {
typedef struct
{
u32 tag; // 0x55AA382D "U.8-"
u32 rootnode_offset; // offset to root_node, always 0x20.
u32 header_size; // size of header from root_node to end of string table.
@ -105,18 +115,21 @@ typedef struct {
u8 zeroes[16];
} U8_archive_header;
static int write_file(void* data, size_t size, char* name) {
static int write_file(void* data, size_t size, char* name)
{
size_t written=0;
FILE *out;
out = fopen(name, "wb");
if (out) {
if(out)
{
written = fwrite(data, 1, size, out);
fclose(out);
}
return (written == size) ? 1 : -1;
}
u8* decompress_lz77(u8 *data, size_t data_size, size_t* decompressed_size) {
u8* decompress_lz77(u8 *data, size_t data_size, size_t* decompressed_size)
{
u8 *data_end;
u8 *decompressed_data;
size_t unpacked_size;
@ -186,7 +199,8 @@ u8* decompress_lz77(u8 *data, size_t data_size, size_t* decompressed_size) {
return decompressed_data;
}
static int write_imd5_lz77(u8* data, size_t size, char* outname) {
static int write_imd5_lz77(u8* data, size_t size, char* outname)
{
imd5_header_t* header = (imd5_header_t*) data;
u32 tag;
u32 size_in_imd5;
@ -226,7 +240,8 @@ static int write_imd5_lz77(u8* data, size_t size, char* outname) {
return 0;
}
static int do_U8_archive(FILE *fp) {
static int do_U8_archive(FILE *fp)
{
U8_archive_header header;
U8_node root_node;
u32 tag;
@ -300,8 +315,8 @@ static int do_U8_archive(FILE *fp) {
//printf("%*s %s (%d bytes", dir_index, "", name, size);
int result;
result = write_imd5_lz77(file_data, size, name);
if (result < 0) {
free(string_table);
if(result < 0)
{free(string_table);
return result;
}
//printf(")\n");
@ -317,7 +332,8 @@ static int do_U8_archive(FILE *fp) {
return 0;
}
static void do_imet_header(FILE *fp) {
static void do_imet_header(FILE *fp)
{
imet_data_t header;
fread(&header, 1, sizeof header, fp);
@ -325,7 +341,8 @@ static void do_imet_header(FILE *fp) {
write_file(&header, sizeof(header), "header.imet");
}
void do_U8_archivebanner(FILE *fp) {
void do_U8_archivebanner(FILE *fp)
{
U8_archive_header header;
U8_node root_node;
u32 tag;
@ -397,10 +414,12 @@ void do_U8_archivebanner(FILE *fp) {
free(string_table);
}
int extractbnrfile(const char * filepath, const char * destpath) {
int extractbnrfile(const char * filepath, const char * destpath)
{
int ret = -1;
FILE *fp = fopen(filepath, "rb");
if (fp) {
if(fp)
{
subfoldercreate(destpath);
chdir(destpath);
@ -412,9 +431,11 @@ int extractbnrfile(const char * filepath, const char * destpath) {
return ret;
}
int unpackBin(const char * filename,const char * outdir) {
int unpackBin(const char * filename,const char * outdir)
{
FILE *fp = fopen(filename,"rb");;
if (fp) {
if(fp)
{
subfoldercreate(outdir);
chdir(outdir);
@ -428,66 +449,77 @@ int unpackBin(const char * filename,const char * outdir) {
#define TMP_PATH(s) "BANNER:/dump"s
//#define TMP_PATH(s) "SD:/dump"s
int unpackBanner(const u8 *gameid, int what, const char *outdir) {
int unpackBanner(const u8 *gameid, int what, const char *outdir)
{
char path[256];
if(!ramdiskMount("BANNER", NULL)) return -1;
subfoldercreate(TMP_PATH("/"));
s32 ret = dump_banner(gameid, TMP_PATH("/opening.bnr"));
if (ret != 1) {
if (ret != 1)
{
ret = -1;
goto error2;
}
ret = extractbnrfile(TMP_PATH("/opening.bnr"), TMP_PATH("/"));
if (ret != 0) {
if (ret != 0)
{
ret = -1;
goto error2;
}
if (what & UNPACK_BANNER_BIN) {
if(what & UNPACK_BANNER_BIN)
{
snprintf(path, sizeof(path),"%sbanner/", outdir);
ret = unpackBin(TMP_PATH("/meta/banner.bin"), path);
if (ret != 1) {
if (ret != 1)
{
ret = -1;
goto error2;
}
}
if (what & UNPACK_ICON_BIN) {
if(what & UNPACK_ICON_BIN)
{
snprintf(path, sizeof(path),"%sicon/", outdir);
ret = unpackBin(TMP_PATH("/meta/icon.bin"), path);
if (ret != 1) {
if (ret != 1)
{
ret = -1;
goto error2;
}
}
if (what & UNPACK_SOUND_BIN) {
if(what & UNPACK_SOUND_BIN)
{
snprintf(path, sizeof(path),"%ssound.bin", outdir);
FILE *fp = fopen(TMP_PATH("/meta/sound.bin"), "rb");
if (fp) {
if(fp)
{
size_t size;
u8 *data;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
if (!size) {
if(!size)
{
ret = -1;
goto error;
}
fseek(fp, 0, SEEK_SET);
data = (u8 *)malloc(size);
if (!data) {
if(!data)
{
ret = -1;
goto error;
}
if (fread(data, 1, size, fp) != size) {
if(fread(data, 1, size, fp) != size)
{
ret = -1;
goto error;
}
ret = write_file(data, size, path);
}
error:
fclose(fp);
error: fclose(fp);
}
ramdiskUnmount("BANNER");
error2:

View File

@ -9,7 +9,8 @@
#define _OPENINGBNR_H_
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/***********************************************************

View File

@ -11,14 +11,16 @@
#include "bannersound.h"
struct IMD5Header {
struct IMD5Header
{
u32 fcc;
u32 filesize;
u8 zeroes[8];
u8 crypto[16];
} __attribute__((packed));
struct IMETHeader {
struct IMETHeader
{
u8 zeroes[64];
u32 fcc;
u8 unk[8];
@ -31,7 +33,8 @@ struct IMETHeader {
u8 crypto[16];
} __attribute__((packed));
struct U8Header {
struct U8Header
{
u32 fcc;
u32 rootNodeOffset;
u32 headerSize;
@ -39,40 +42,44 @@ struct U8Header {
u8 zeroes[16];
} __attribute__((packed));
struct U8Entry {
struct {
u32 fileType :
8;
u32 nameOffset :
24;
struct U8Entry
{
struct
{
u32 fileType : 8;
u32 nameOffset : 24;
};
u32 fileOffset;
union {
union
{
u32 fileLength;
u32 numEntries;
};
} __attribute__((packed));
struct LZ77Info {
u16 length :
4;
u16 offset :
12;
struct LZ77Info
{
u16 length : 4;
u16 offset : 12;
} __attribute__((packed));
static char *u8Filename(const U8Entry *fst, int i) {
static char *u8Filename(const U8Entry *fst, int i)
{
return (char *)(fst + fst[0].numEntries) + fst[i].nameOffset;
}
inline u32 le32(u32 i) {
inline u32 le32(u32 i)
{
return ((i & 0xFF) << 24) | ((i & 0xFF00) << 8) | ((i & 0xFF0000) >> 8) | ((i & 0xFF000000) >> 24);
}
inline u16 le16(u16 i) {
inline u16 le16(u16 i)
{
return ((i & 0xFF) << 8) | ((i & 0xFF00) >> 8);
}
static u8 *uncompressLZ77(const u8 *inBuf, u32 inLength, u32 &size) {
static u8 *uncompressLZ77(const u8 *inBuf, u32 inLength, u32 &size)
{
u8 *buffer = NULL;
if (inLength <= 0x8 || *((const u32 *)inBuf) != 0x4C5A3737 /*"LZ77"*/ || inBuf[4] != 0x10)
return NULL;
@ -87,11 +94,14 @@ static u8 *uncompressLZ77(const u8 *inBuf, u32 inLength, u32 &size) {
u8 *bufCur = buffer;
u8 *bufEnd = buffer + uncSize;
while (bufCur < bufEnd && inBuf < inBufEnd) {
while (bufCur < bufEnd && inBuf < inBufEnd)
{
u8 flags = *inBuf;
++inBuf;
for (int i = 0; i < 8 && bufCur < bufEnd && inBuf < inBufEnd; ++i) {
if ((flags & 0x80) != 0) {
for (int i = 0; i < 8 && bufCur < bufEnd && inBuf < inBufEnd; ++i)
{
if ((flags & 0x80) != 0)
{
const LZ77Info &info = *(const LZ77Info *)inBuf;
inBuf += sizeof (LZ77Info);
int length = info.length + 3;
@ -99,7 +109,9 @@ static u8 *uncompressLZ77(const u8 *inBuf, u32 inLength, u32 &size) {
return buffer;
memcpy(bufCur, bufCur - info.offset - 1, length);
bufCur += length;
} else {
}
else
{
*bufCur = *inBuf;
++inBuf;
++bufCur;
@ -111,23 +123,27 @@ static u8 *uncompressLZ77(const u8 *inBuf, u32 inLength, u32 &size) {
return buffer;
}
const u8 *LoadBannerSound(const u8 *discid, u32 *size) {
const u8 *LoadBannerSound(const u8 *discid, u32 *size)
{
if(!discid)
return NULL;
Disc_SetUSB(NULL);
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) discid);
if (!disc) {
if(!disc)
{
// WindowPrompt(tr("Can't find disc"), 0, tr("OK"));
return NULL;
}
wiidisc_t *wdisc = wd_open_disc((int (*)(void *, u32, u32, void *))wbfs_disc_read, disc);
if (!wdisc) {
if(!wdisc)
{
//WindowPrompt(tr("Could not open Disc"), 0, tr("OK"));
return NULL;
}
u8 * opening_bnr = wd_extract_file(wdisc, ALL_PARTITIONS, (char *) "opening.bnr");
if (!opening_bnr) {
if(!opening_bnr)
{
//WindowPrompt(tr("ERROR"), tr("Failed to extract opening.bnr"), tr("OK"));
return NULL;
}
@ -138,7 +154,8 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size) {
const U8Entry *fst;
const IMETHeader *imetHdr = (IMETHeader *)opening_bnr;
if ( imetHdr->fcc != 0x494D4554 /*"IMET"*/ ) {
if ( imetHdr->fcc != 0x494D4554 /*"IMET"*/ )
{
// WindowPrompt(tr("IMET Header wrong."), 0, tr("OK"));
free(opening_bnr);
return NULL;
@ -150,14 +167,16 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size) {
for (i = 1; i < fst[0].numEntries; ++i)
if (fst[i].fileType == 0 && strcasecmp(u8Filename(fst, i), "sound.bin") == 0)
break;
if (i >= fst[0].numEntries) {
if (i >= fst[0].numEntries)
{
/* Not all games have a sound.bin and this message is annoying **/
//WindowPrompt(tr("sound.bin not found."), 0, tr("OK"));
free(opening_bnr);
return NULL;
}
const u8 *sound_bin = ((const u8 *)bnrArcHdr) + fst[i].fileOffset;
if ( ((IMD5Header *)sound_bin)->fcc != 0x494D4435 /*"IMD5"*/ ) {
if ( ((IMD5Header *)sound_bin)->fcc != 0x494D4435 /*"IMD5"*/ )
{
// WindowPrompt(tr("IMD5 Header not right."), 0, tr("OK"));
free(opening_bnr);
return NULL;
@ -165,10 +184,12 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size) {
const u8 *soundChunk = sound_bin + sizeof (IMD5Header);;
u32 soundChunkSize = fst[i].fileLength - sizeof (IMD5Header);
if ( *((u32*)soundChunk) == 0x4C5A3737 /*"LZ77"*/ ) {
if ( *((u32*)soundChunk) == 0x4C5A3737 /*"LZ77"*/ )
{
u32 uncSize = NULL;
u8 * uncompressed_data = uncompressLZ77(soundChunk, soundChunkSize, uncSize);
if (!uncompressed_data) {
if (!uncompressed_data)
{
// WindowPrompt(tr("Can't decompress LZ77"), 0, tr("OK"));
free(opening_bnr);
return NULL;
@ -178,7 +199,8 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size) {
return uncompressed_data;
}
u8 *out = new(std::nothrow) u8[soundChunkSize];
if (out) {
if(out)
{
memcpy(out, soundChunk, soundChunkSize);
if(size) *size=soundChunkSize;
}

View File

@ -71,11 +71,13 @@ int CheatMenu(const char * gameID) {
break;
case 0:
download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("Download Now"),tr("Cancel"));
if (download==1) {
if (download==1)
{
download = CodeDownload(gameID);
if(download < 0 || c.openTxtfile(txtfilename) != 1)
break;
} else
}
else
break;
case 1:
int cntcheats = c.getCnt();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -121,7 +121,8 @@ int SDCard_Init() {
fat_sd_sec = _FAT_startSector;
gprintf(":1");
return 1;
} else if (fatMount("SD", &__io_sdhc, 0, CACHE, SDHC_SECTOR_SIZE)) {
}
else if (fatMount("SD", &__io_sdhc, 0, CACHE, SDHC_SECTOR_SIZE)) {
fat_sd_mount = MOUNT_SDHC;
fat_sd_sec = _FAT_startSector;
gprintf(":1");
@ -142,7 +143,8 @@ void SDCard_deInit() {
void ntfsInit();
s32 MountNTFS(u32 sector) {
s32 MountNTFS(u32 sector)
{
s32 ret;
if (fs_ntfs_mount) return 0;
@ -190,7 +192,8 @@ s32 MountNTFS(u32 sector) {
return 0;
}
s32 UnmountNTFS(void) {
s32 UnmountNTFS(void)
{
/* Unmount device */
ntfsUnmount("NTFS:/", true);
@ -200,29 +203,36 @@ s32 UnmountNTFS(void) {
return 0;
}
void _FAT_mem_init() {
void _FAT_mem_init()
{
}
void* _FAT_mem_allocate(size_t size) {
void* _FAT_mem_allocate(size_t size)
{
return malloc(size);
}
void* _FAT_mem_align(size_t size) {
void* _FAT_mem_align(size_t size)
{
return memalign(32, size);
}
void _FAT_mem_free(void *mem) {
void _FAT_mem_free(void *mem)
{
free(mem);
}
void* ntfs_alloc (size_t size) {
void* ntfs_alloc (size_t size)
{
return _FAT_mem_allocate(size);
}
void* ntfs_align (size_t size) {
void* ntfs_align (size_t size)
{
return _FAT_mem_align(size);
}
void ntfs_free (void* mem) {
void ntfs_free (void* mem)
{
_FAT_mem_free(mem);
}

Binary file not shown.

Binary file not shown.

View File

@ -10,7 +10,8 @@ bool textVideoInit = false;
#include <stdarg.h>
//using the gprintf from crediar because it is smaller than mine
void gprintf( const char *str, ... ) {
void gprintf( const char *str, ... )
{
if (!(geckoinit))return;
char astr[4096];
@ -25,12 +26,15 @@ void gprintf( const char *str, ... ) {
usb_sendbuffer_safe( 1, astr, strlen(astr) );
}
bool InitGecko() {
bool InitGecko()
{
u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
if (geckoattached) {
if (geckoattached)
{
usb_flush(EXI_CHANNEL_1);
return true;
} else return false;
}
else return false;
}

View File

@ -852,7 +852,8 @@ int MenuHomebrewBrowse() {
sprintf((char *) &zippath, "%s%s", Settings.homebrewapps_path, filename);
FILE *fp = fopen(zippath, "wb");
if (fp != NULL) {
if (fp != NULL)
{
fwrite(temp, 1, infilesize, fp);
fclose(fp);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 B

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 937 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 B

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 841 B

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Some files were not shown because too many files have changed in this diff Show More