*fixed possible crash in grid layout

*change default virtual pointer speed to 0.18
*added instruction invalidation of dol areas before starting them
*corrected PAL60 system default video mode set
*fixed loading titles when titles from wiitdb is OFF
*removed buggy lz77 implementation and use the one known working
*fix small scrollbar bug when having only 1 item
*fix launch of dollz compressed dol files (thx FIX94)
This commit is contained in:
strtoul 2012-01-23 21:26:41 +00:00
parent 63631b8028
commit b78388e779
12 changed files with 85 additions and 111 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>2.3 r1148</version>
<release_date>201201081807</release_date>
<version>2.3 r1149</version>
<release_date>201201232120</release_date>
<!-- // remove this line to enable arguments
<arguments>
<arg>--ios=250</arg>

View File

@ -366,7 +366,7 @@ void GuiGameGrid::SetSelectedOption(int ind)
void GuiGameGrid::Draw()
{
LOCK( this );
if (!this->IsVisible() || !gameList.size()) return;
if (!this->IsVisible() || !gameList.size() || !game.size()) return;
if (goLeft > 0)
{
@ -436,7 +436,7 @@ void GuiGameGrid::ChangeRows(int n)
void GuiGameGrid::Update(GuiTrigger * t)
{
if (state == STATE_DISABLED || !t || !gameList.size()) return;
if (state == STATE_DISABLED || !t || !gameList.size() || !game.size()) return;
LOCK( this );
if (!(game[0]->GetEffect() || game[0]->GetEffectOnOver()))

View File

@ -412,8 +412,8 @@ void GuiScrollbar::CheckDPadControls(GuiTrigger *t)
SelInd += PageSize;
if(SelInd+PageSize >= EntrieCount)
{
SelInd = EntrieCount-PageSize;
SelItem = PageSize-1;
SelInd = MAX(EntrieCount-PageSize, 0);
SelItem = LIMIT(PageSize-1, 0, EntrieCount-1);
}
listChanged(SelItem, SelInd);
}

View File

@ -51,6 +51,11 @@ void FreeHomebrewBuffer()
Arguments.clear();
}
static inline bool IsDollZ (const u8 *buf)
{
return (buf[0x100] == 0x3C);
}
static int SetupARGV(struct __argv * args)
{
if (!args) return -1;
@ -109,14 +114,16 @@ static int RunAppbooter()
memcpy(BOOTER_ADDR, app_booter_bin, app_booter_bin_size);
DCFlushRange(BOOTER_ADDR, app_booter_bin_size);
ICInvalidateRange(BOOTER_ADDR, app_booter_bin_size);
entrypoint entry = (entrypoint) BOOTER_ADDR;
if (args.argvMagic == ARGV_MAGIC)
{
memmove(ARGS_ADDR, &args, sizeof(args));
DCFlushRange(ARGS_ADDR, sizeof(args) + args.length);
}
if (!IsDollZ(homebrewbuffer))
memcpy(ARGS_ADDR, &args, sizeof(struct __argv));
else
memset(ARGS_ADDR, 0, sizeof(struct __argv));
DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + args.length);
u64 currentStub = getStubDest();
loadStub();

View File

@ -669,10 +669,8 @@ void GameBrowseMenu::ReloadBrowser()
gameBrowser->SetSelectedOption(Settings.SelectedGame);
//! Setup optional background image
const u8 *backgroundImgData = Resources::GetFile("listBackground.png");
u32 backgroundImgDataSize = Resources::GetFileSize("listBackground.png");
if(backgroundImgData && !listBackground)
listBackground = new GuiImageData(backgroundImgData, backgroundImgDataSize);
if(!listBackground)
listBackground = Resources::GetImageData("listBackground.png");
if(listBackground)
bgImg->SetImage(listBackground);
else
@ -715,10 +713,8 @@ void GameBrowseMenu::ReloadBrowser()
gameBrowser->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE);
//! Setup optional background image
const u8 *backgroundImgData = Resources::GetFile("gridBackground.png");
u32 backgroundImgDataSize = Resources::GetFileSize("gridBackground.png");
if(backgroundImgData && !gridBackground)
gridBackground = new GuiImageData(backgroundImgData, backgroundImgDataSize);
if(!gridBackground)
gridBackground = Resources::GetImageData("gridBackground.png");
if(gridBackground)
bgImg->SetImage(gridBackground);
else
@ -761,10 +757,8 @@ void GameBrowseMenu::ReloadBrowser()
gameBrowser->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE);
//! Setup optional background image
const u8 *backgroundImgData = Resources::GetFile("carouselBackground.png");
u32 backgroundImgDataSize = Resources::GetFileSize("carouselBackground.png");
if(backgroundImgData && !carouselBackground)
carouselBackground = new GuiImageData(backgroundImgData, backgroundImgDataSize);
if(!carouselBackground)
carouselBackground = Resources::GetImageData("carouselBackground.png");
if(carouselBackground)
bgImg->SetImage(carouselBackground);
else

View File

@ -91,6 +91,7 @@ void gamepatches(u8 videoSelected, u8 aspectForce, u8 languageChoice, u8 patchco
PatchAspectRatio(dst, len, aspectForce);
DCFlushRange(dst, len);
ICInvalidateRange(dst, len);
}
/* ERROR 002 fix (thanks to WiiPower for sharing this)*/

View File

@ -140,7 +140,7 @@ void CSettings::SetDefault()
LoaderMode = MODE_WIIGAMES;
SearchMode = SEARCH_BEGINNING;
GameAspectRatio = ASPECT_SYSTEM_DEFAULT;
PointerSpeed = 0.15f;
PointerSpeed = 0.18f;
UseChanLauncher = OFF;
}

View File

@ -83,7 +83,11 @@ GuiImageData * Resources::GetImageData(const char * filename)
{
const u8 * buff = RecourceFiles[i].CustomFile ? RecourceFiles[i].CustomFile : RecourceFiles[i].DefaultFile;
const u32 size = RecourceFiles[i].CustomFile ? RecourceFiles[i].CustomFileSize : RecourceFiles[i].DefaultFileSize;
if(buff != NULL)
return (new GuiImageData(buff, size));
else
return NULL;
}
}

View File

@ -14,8 +14,8 @@
#include "alternatedol.h"
#include "memory/memory.h"
#include "wbfs.h"
#include "../settings/SettingsEnums.h"
#include "../gecko.h"
#include "settings/SettingsEnums.h"
#include "gecko.h"
// Global app entry point
extern u32 AppEntrypoint;
@ -69,6 +69,8 @@ void Disc_SelectVMode(u8 videoselected)
{
case CONF_VIDEO_PAL:
vmode_reg = PAL60 ? VI_EURGB60 : VI_PAL;
if(PAL60)
vmode = progressive ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf;
break;
case CONF_VIDEO_MPAL:

View File

@ -353,17 +353,37 @@ bool Wbfs_Fat::CheckLayoutB(char *fname, int len, u8* id, char *fname_title)
return true;
}
void Wbfs_Fat::AddHeader(struct discHdr *discHeader)
{
//! First allocate before reallocating
if(!fat_hdr_list)
fat_hdr_list = (struct discHdr *) malloc(sizeof(struct discHdr));
struct discHdr *tmpList = (struct discHdr *) realloc(fat_hdr_list, (fat_hdr_count+1) * sizeof(struct discHdr));
if(!tmpList)
return; //out of memory, keep the list until now and stop
for(int j = 0; j < 6; ++j)
discHeader->id[j] = toupper((int) discHeader->id[j]);
fat_hdr_list = tmpList;
memcpy(&fat_hdr_list[fat_hdr_count], discHeader, sizeof(struct discHdr));
GameTitles.SetGameTitle(discHeader->id, discHeader->title);
fat_hdr_count++;
}
s32 Wbfs_Fat::GetHeadersCount()
{
char path[MAX_FAT_PATH];
char fname[MAX_FAT_PATH];
char fpath[MAX_FAT_PATH];
char fname_title[TITLE_LEN];
struct discHdr tmpHdr;
struct stat st;
u8 id[8];
int is_dir;
int len;
char fname_title[TITLE_LEN];
u8 id[8];
memset(id, 0, sizeof(id));
const char *title;
DIR *dir_iter;
struct dirent *dirent;
@ -381,7 +401,7 @@ s32 Wbfs_Fat::GetHeadersCount()
{
if (dirent->d_name[0] == '.') continue;
snprintf(fname, sizeof(fname), dirent->d_name);
snprintf(fname, sizeof(fname), "%s", dirent->d_name);
// reset id and title
memset(id, 0, sizeof(id));
@ -414,7 +434,7 @@ s32 Wbfs_Fat::GetHeadersCount()
is_dir = S_ISDIR( st.st_mode );
if(!is_dir) continue;
snprintf(fname, sizeof(fname), dirent->d_name);
snprintf(fname, sizeof(fname), "%s", dirent->d_name);
len = strlen(fname);
if (len < 8) continue; // "GAMEID_x"
@ -441,22 +461,23 @@ s32 Wbfs_Fat::GetHeadersCount()
if (!lay_a && !lay_b) continue;
// check ahead, make sure it succeeds
snprintf(fpath, sizeof(fpath), "%s/%s/%.6s.wbfs", path, fname, (char *) id);
snprintf(fpath, sizeof(fpath), "%s/%s/%.6s.wbfs", path, dirent->d_name, (char *) id);
}
// if we have titles.txt entry use that
title = GameTitles.GetTitle(id);
// if no titles.txt get title from dir or file name
if ((!title || *title == 0) && *fname_title != 0 && Settings.titlesOverride)
if (strlen(title) == 0 && Settings.titlesOverride && strlen(fname_title) > 0)
title = fname_title;
if (title && *title != 0)
if (strlen(title) > 0)
{
memset(&tmpHdr, 0, sizeof(tmpHdr));
memcpy(tmpHdr.id, id, 6);
snprintf(tmpHdr.title, sizeof(tmpHdr.title), title);
strncpy(tmpHdr.title, title, sizeof(tmpHdr.title)-1);
tmpHdr.magic = 0x5D1C9EA3;
goto add_hdr;
AddHeader(&tmpHdr);
continue;
}
// Check for existing wbfs/iso/ciso file in the directory
@ -475,6 +496,7 @@ s32 Wbfs_Fat::GetHeadersCount()
}
}
fileext = strrchr(fpath, '.');
// Sanity check
if(!fileext)
continue;
@ -492,7 +514,8 @@ s32 Wbfs_Fat::GetHeadersCount()
tmpHdr.is_ciso = 0;
if ((tmpHdr.magic == 0x5D1C9EA3) && (memcmp(tmpHdr.id, id, 6) == 0))
{
goto add_hdr;
AddHeader(&tmpHdr);
continue;
}
}
// no title found, read it from wbfs file
@ -507,7 +530,10 @@ s32 Wbfs_Fat::GetHeadersCount()
int ret = wbfs_get_disc_info(part, 0, (u8*) &tmpHdr, sizeof(struct discHdr), &size);
ClosePart(part);
if (ret == 0)
goto add_hdr;
{
AddHeader(&tmpHdr);
continue;
}
}
else if (strcasecmp(fileext, ".iso") == 0)
@ -522,7 +548,8 @@ s32 Wbfs_Fat::GetHeadersCount()
tmpHdr.is_ciso = 0;
if ((tmpHdr.magic == 0x5D1C9EA3) && (memcmp(tmpHdr.id, id, 6) == 0))
{
goto add_hdr;
AddHeader(&tmpHdr);
continue;
}
}
}
@ -538,31 +565,11 @@ s32 Wbfs_Fat::GetHeadersCount()
tmpHdr.is_ciso = 1;
if ((tmpHdr.magic == 0x5D1C9EA3) && (memcmp(tmpHdr.id, id, 6) == 0))
{
goto add_hdr;
}
}
}
// fail:
AddHeader(&tmpHdr);
continue;
// success: add tmpHdr to list:
add_hdr:
//! First allocate before reallocating
if(!fat_hdr_list)
fat_hdr_list = (struct discHdr *) malloc(sizeof(struct discHdr));
fat_hdr_count++;
struct discHdr *tmpList = (struct discHdr *) realloc(fat_hdr_list, fat_hdr_count * sizeof(struct discHdr));
if(!tmpList)
break; //out of memory, keep the list until now and stop
for(int j = 0; j < 6; ++j)
tmpHdr.id[j] = toupper((int) tmpHdr.id[j]);
fat_hdr_list = tmpList;
memcpy(&fat_hdr_list[fat_hdr_count - 1], &tmpHdr, sizeof(struct discHdr));
GameTitles.SetGameTitle(tmpHdr.id, tmpHdr.title);
}
}
}
}
closedir(dir_iter);

View File

@ -30,10 +30,13 @@ class Wbfs_Fat: public Wbfs
u64 EstimateGameSize();
void AddHeader(struct discHdr *discHeader);
virtual int GetFragList(u8 *);
virtual u8 GetFSType(void) { return PART_FS_FAT; }
protected:
split_info_t split;
struct discHdr *fat_hdr_list;

View File

@ -27,62 +27,18 @@
#include <string.h>
#include "uncompress.h"
struct _LZ77Info
{
u16 length : 4;
u16 offset : 12;
} __attribute__((packed));
typedef struct _LZ77Info LZ77Info;
#include "lz77.h"
u8 * uncompressLZ77(const u8 *inBuf, u32 inLength, u32 * size)
{
u8 *buffer = NULL;
if (inLength <= 0x8 || *((const u32 *)inBuf) != 0x4C5A3737 /*"LZ77"*/ || inBuf[4] != 0x10)
if(!inBuf)
return NULL;
u32 uncSize = le32(((const u32 *)inBuf)[1] << 8);
u8 *buffer = NULL;
if (*((const u32 *)inBuf) != 0x4C5A3737 /*"LZ77"*/)
return NULL;
const u8 *inBufEnd = inBuf + inLength;
inBuf += 8;
buffer = (u8 *) malloc(uncSize);
if (!buffer)
return buffer;
u8 *bufCur = buffer;
u8 *bufEnd = buffer + uncSize;
while (bufCur < bufEnd && inBuf < inBufEnd)
{
u8 flags = *inBuf;
++inBuf;
int i = 0;
for (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;
if (bufCur - info->offset - 1 < buffer || bufCur + length > bufEnd)
return buffer;
memcpy(bufCur, bufCur - info->offset - 1, length);
bufCur += length;
}
else
{
*bufCur = *inBuf;
++inBuf;
++bufCur;
}
flags <<= 1;
}
}
*size = uncSize;
decompressLZ77content(inBuf + 4, inLength - 4, &buffer, size);
return buffer;
}