mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-16 00:15:08 +01:00
*fixed reading game titles from disc header on fat32/ntfs/ext (Issue 2034)
*moved low mem and video setup for channels after loading the dol (fixes/corrects video mode, little video flash on startup of channel and might fix some other stuff. hopefully doesn't brake some channels) *removed duplicate memory flush/patches *code optimizations
This commit is contained in:
parent
a1e6c04b89
commit
b9c86e8db9
@ -2,8 +2,8 @@
|
||||
<app version="1">
|
||||
<name> USB Loader GX</name>
|
||||
<coder>USB Loader GX Team</coder>
|
||||
<version>2.3 r1146</version>
|
||||
<release_date>201201041810</release_date>
|
||||
<version>2.3 r1147</version>
|
||||
<release_date>201201052225</release_date>
|
||||
<!-- // remove this line to enable arguments
|
||||
<arguments>
|
||||
<arg>--ios=250</arg>
|
||||
|
@ -293,6 +293,9 @@ u32 Channels::LoadChannel(const u64 &chantitle)
|
||||
|
||||
if(dolfile->bss_start)
|
||||
{
|
||||
if(!(dolfile->bss_start & 0x80000000))
|
||||
dolfile->bss_start |= 0x80000000;
|
||||
|
||||
ICInvalidateRange((void *)dolfile->bss_start, dolfile->bss_size);
|
||||
memset((void *)dolfile->bss_start, 0, dolfile->bss_size);
|
||||
DCFlushRange((void *)dolfile->bss_start, dolfile->bss_size);
|
||||
@ -303,7 +306,8 @@ u32 Channels::LoadChannel(const u64 &chantitle)
|
||||
{
|
||||
if (!dolfile->section_size[i]) continue;
|
||||
if (dolfile->section_pos[i] < sizeof(dolheader)) continue;
|
||||
if(!(dolfile->section_start[i] & 0x80000000)) dolfile->section_start[i] |= 0x80000000;
|
||||
if(!(dolfile->section_start[i] & 0x80000000))
|
||||
dolfile->section_start[i] |= 0x80000000;
|
||||
|
||||
u8 *dolChunkOffset = (u8 *)dolfile->section_start[i];
|
||||
u32 dolChunkSize = dolfile->section_size[i];
|
||||
@ -317,17 +321,18 @@ u32 Channels::LoadChannel(const u64 &chantitle)
|
||||
|
||||
u32 chanEntryPoint = dolfile->entry_point;
|
||||
|
||||
free(dolfile);
|
||||
|
||||
// IOS Version Check
|
||||
*(vu32*)0x80003140 = ((ios << 16)) | 0xFFFF;
|
||||
*(vu32*)0x80003188 = ((ios << 16)) | 0xFFFF;
|
||||
DCFlushRange((void *)0x80003140, 32);
|
||||
DCFlushRange((void *)0x80003188, 32);
|
||||
DCFlushRange((void *)0x80003140, 4);
|
||||
DCFlushRange((void *)0x80003188, 4);
|
||||
|
||||
// Game ID Online Check
|
||||
memset((void *)0x80000000, 0, 6);
|
||||
*(vu32 *)0x80000000 = TITLE_LOWER(chantitle);
|
||||
*(vu32 *)0x80003180 = TITLE_LOWER(chantitle);
|
||||
DCFlushRange((void *)0x80000000, 32);
|
||||
DCFlushRange((void *)0x80003180, 32);
|
||||
DCFlushRange((void *)0x80000000, 6);
|
||||
|
||||
ISFS_Deinitialize();
|
||||
|
||||
|
@ -44,12 +44,12 @@ u8 fi[24], ri[24];
|
||||
u32 fkey[120];
|
||||
u32 rkey[120];
|
||||
|
||||
static u32 pack(u8 *b)
|
||||
static inline u32 pack(u8 *b)
|
||||
{ /* pack bytes into a 32-bit Word */
|
||||
return ((u32 ) b[3] << 24) | ((u32 ) b[2] << 16) | ((u32 ) b[1] << 8) | (u32 ) b[0];
|
||||
}
|
||||
|
||||
static void unpack(u32 a, u8 *b)
|
||||
static inline void unpack(u32 a, u8 *b)
|
||||
{ /* unpack bytes from a word */
|
||||
b[0] = (u8 ) a;
|
||||
b[1] = (u8 ) (a >> 8);
|
||||
@ -57,7 +57,7 @@ static void unpack(u32 a, u8 *b)
|
||||
b[3] = (u8 ) (a >> 24);
|
||||
}
|
||||
|
||||
static u8 xtime(u8 a)
|
||||
static inline u8 xtime(u8 a)
|
||||
{
|
||||
u8 b;
|
||||
if (a & 0x80)
|
||||
@ -68,14 +68,14 @@ static u8 xtime(u8 a)
|
||||
return a;
|
||||
}
|
||||
|
||||
static u8 bmul(u8 x, u8 y)
|
||||
static inline u8 bmul(u8 x, u8 y)
|
||||
{ /* x.y= AntiLog(Log(x) + Log(y)) */
|
||||
if (x && y)
|
||||
return ptab[(ltab[x] + ltab[y]) % 255];
|
||||
else return 0;
|
||||
}
|
||||
|
||||
static u32 SubByte(u32 a)
|
||||
static inline u32 SubByte(u32 a)
|
||||
{
|
||||
u8 b[4];
|
||||
unpack(a, b);
|
||||
@ -86,7 +86,7 @@ static u32 SubByte(u32 a)
|
||||
return pack(b);
|
||||
}
|
||||
|
||||
static u8 product(u32 x, u32 y)
|
||||
static inline u8 product(u32 x, u32 y)
|
||||
{ /* dot product of two 4-byte arrays */
|
||||
u8 xb[4], yb[4];
|
||||
unpack(x, xb);
|
||||
@ -94,7 +94,7 @@ static u8 product(u32 x, u32 y)
|
||||
return bmul(xb[0], yb[0]) ^ bmul(xb[1], yb[1]) ^ bmul(xb[2], yb[2]) ^ bmul(xb[3], yb[3]);
|
||||
}
|
||||
|
||||
static u32 InvMixCol(u32 x)
|
||||
static inline u32 InvMixCol(u32 x)
|
||||
{ /* matrix Multiplication */
|
||||
u32 y, m;
|
||||
u8 b[4];
|
||||
@ -111,7 +111,7 @@ static u32 InvMixCol(u32 x)
|
||||
return y;
|
||||
}
|
||||
|
||||
u8 ByteSub(u8 x)
|
||||
static inline u8 ByteSub(u8 x)
|
||||
{
|
||||
u8 y = ptab[255 - ltab[x]]; /* multiplicative inverse */
|
||||
x = y;
|
||||
@ -127,7 +127,7 @@ u8 ByteSub(u8 x)
|
||||
return y;
|
||||
}
|
||||
|
||||
void gentables(void)
|
||||
static inline void gentables(void)
|
||||
{ /* generate tables */
|
||||
int i;
|
||||
u8 y, b[4];
|
||||
@ -181,7 +181,7 @@ void gentables(void)
|
||||
}
|
||||
}
|
||||
|
||||
void gkey(int nb, int nk, char *key)
|
||||
static inline void gkey(int nb, int nk, char *key)
|
||||
{ /* blocksize=32*nb bits. Key=32*nk bits */
|
||||
/* currently nb,bk = 4, 6 or 8 */
|
||||
/* key comes as 4*Nk bytes */
|
||||
|
@ -332,12 +332,12 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
|
||||
//! shutdown now and avoid later crashs with free if memory gets overwritten by channel
|
||||
ShutDownDevices(usbport);
|
||||
gprintf("\tChannel Boot\n");
|
||||
// Load dol
|
||||
AppEntrypoint = Channels::LoadChannel(gameHeader.tid);
|
||||
/* Setup low memory */
|
||||
Disc_SetLowMem();
|
||||
/* Setup video mode */
|
||||
Disc_SelectVMode(videoChoice);
|
||||
// Load dol
|
||||
AppEntrypoint = Channels::LoadChannel(gameHeader.tid);
|
||||
}
|
||||
|
||||
//! No entrypoint found...back to HBC/SystemMenu
|
||||
|
@ -53,9 +53,6 @@ void Disc_SetLowMem(void)
|
||||
|
||||
/* Copy disc ID */
|
||||
memcpy((void *) Online_Check, (void *) Disc_ID, 4);
|
||||
|
||||
/* Flush cache */
|
||||
DCFlushRange((void *) Disc_ID, 0x3F00);
|
||||
}
|
||||
|
||||
void Disc_SelectVMode(u8 videoselected)
|
||||
|
@ -447,10 +447,10 @@ s32 Wbfs_Fat::GetHeadersCount()
|
||||
// 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 || strlen(title) == 0) && *fname_title)
|
||||
if ((!title || *title == 0) && *fname_title != 0)
|
||||
title = fname_title;
|
||||
|
||||
if (title)
|
||||
if (title && *title != 0)
|
||||
{
|
||||
memset(&tmpHdr, 0, sizeof(tmpHdr));
|
||||
memcpy(tmpHdr.id, id, 6);
|
||||
@ -459,6 +459,7 @@ s32 Wbfs_Fat::GetHeadersCount()
|
||||
goto add_hdr;
|
||||
}
|
||||
|
||||
// Check for existing wbfs/iso/ciso file in the directory
|
||||
if(is_dir)
|
||||
{
|
||||
if (stat(fpath, &st) != 0)
|
||||
@ -474,8 +475,12 @@ s32 Wbfs_Fat::GetHeadersCount()
|
||||
}
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
if(!fileext)
|
||||
continue;
|
||||
|
||||
// else read it from file directly
|
||||
if (strcasecmp(strrchr(fpath, '.'), ".wbfs") == 0)
|
||||
if (strcasecmp(fileext, ".wbfs") == 0)
|
||||
{
|
||||
// wbfs file directly
|
||||
FILE *fp = fopen(fpath, "rb");
|
||||
@ -505,7 +510,7 @@ s32 Wbfs_Fat::GetHeadersCount()
|
||||
goto add_hdr;
|
||||
|
||||
}
|
||||
else if (strcasecmp(strrchr(fpath, '.'), ".iso") == 0)
|
||||
else if (strcasecmp(fileext, ".iso") == 0)
|
||||
{
|
||||
// iso file
|
||||
FILE *fp = fopen(fpath, "rb");
|
||||
@ -521,7 +526,7 @@ s32 Wbfs_Fat::GetHeadersCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(strrchr(fpath, '.'), ".ciso") == 0)
|
||||
else if (strcasecmp(fileext, ".ciso") == 0)
|
||||
{
|
||||
// ciso file
|
||||
FILE *fp = fopen(fpath, "rb");
|
||||
|
Loading…
Reference in New Issue
Block a user