*removed all the switches at the end of menu.cpp

* removed duplicate 002 parameter in constructors
* pass setting parameter directly to the patching functions instead of making another variable just for this
* probably broke something
This commit is contained in:
giantpune 2010-09-30 05:45:21 +00:00
parent 74fa0a40be
commit 444d2dbe79
11 changed files with 120 additions and 206 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r983</version>
<release_date>201009300328</release_date>
<version>1.0 r984</version>
<release_date>201009300423</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

@ -469,127 +469,9 @@ int MainMenu(int menu)
{
mload_close();
}
}
}
u8 errorfixer002 = fix002;
switch (languageChoice)
{
case ConsoleLangDefault:
configbytes[0] = 0xCD;
break;
case jap:
configbytes[0] = 0x00;
break;
case eng:
configbytes[0] = 0x01;
break;
case ger:
configbytes[0] = 0x02;
break;
case fren:
configbytes[0] = 0x03;
break;
case esp:
configbytes[0] = 0x04;
break;
case it:
configbytes[0] = 0x05;
break;
case dut:
configbytes[0] = 0x06;
break;
case schin:
configbytes[0] = 0x07;
break;
case tchin:
configbytes[0] = 0x08;
break;
case kor:
configbytes[0] = 0x09;
break;
//wenn nicht genau klar ist welches
default:
configbytes[0] = 0xCD;
break;
}
u8 videoselected = 0;
switch (videoChoice)
{
case discdefault:
videoselected = 0;
break;
case pal50:
videoselected = 1;
break;
case pal60:
videoselected = 2;
break;
case ntsc:
videoselected = 3;
break;
case systemdefault:
videoselected = 4;
break;
case patch:
videoselected = 5;
break;
default:
videoselected = 0;
break;
}
u32 cheat = 0;
switch (ocarinaChoice)
{
case on:
cheat = 1;
break;
case off:
cheat = 0;
break;
default:
cheat = 1;
break;
}
u8 vipatch = 0;
switch (viChoice)
{
case on:
vipatch = 1;
break;
case off:
vipatch = 0;
break;
default:
vipatch = 0;
break;
}
u32 channel = 0;
u32 channel = 0;
if (returnToLoaderGV)
{
int idx = NandTitles.FindU32(Settings.returnTo);
@ -602,7 +484,7 @@ int MainMenu(int menu)
gprintf("\tDisc_wiiBoot\n");
ret = Disc_WiiBoot(Settings.dolpath, videoselected, cheat, vipatch, countrystrings, errorfixer002,
ret = Disc_WiiBoot(Settings.dolpath, videoChoice, languageChoice, ocarinaChoice, viChoice, countrystrings,
alternatedol, alternatedoloffset, channel, fix002);
if (ret < 0)
{

View File

@ -4,6 +4,7 @@
#include "dolpatcher.h"
#include "wip.h"
#include "gecko.h"
#include "../settings/cfg.h"
/** Anti 002 fix for IOS 249 rev > 12 thanks to WiiPower **/
bool Anti_002_fix(u8 * Address, int Size)
@ -237,7 +238,7 @@ static bool Search_and_patch_Video_Modes(u8 * Address, u32 Size, GXRModeObj* Tab
void VideoModePatcher(u8 * dst, int len, u8 videoSelected)
{
GXRModeObj** table = NULL;
if (videoSelected == 5) // patch
if (videoSelected == patch) // patch enum'd in cfg.h
{
switch (CONF_GetVideo())

View File

@ -319,8 +319,48 @@ bool dogamehooks(void *addr, u32 len)
}
}
*/
void langpatcher(void *addr, u32 len)
void langpatcher(void *addr, u32 len, u8 languageChoice)
{
u8 ocarinaLangPatchByte = 1;
switch (languageChoice)
{
case jap:
ocarinaLangPatchByte = 0x00;
break;
case eng:
ocarinaLangPatchByte = 0x01;
break;
case ger:
ocarinaLangPatchByte = 0x02;
break;
case fren:
ocarinaLangPatchByte = 0x03;
break;
case esp:
ocarinaLangPatchByte = 0x04;
break;
case it:
ocarinaLangPatchByte = 0x05;
break;
case dut:
ocarinaLangPatchByte = 0x06;
break;
case schin:
ocarinaLangPatchByte = 0x07;
break;
case tchin:
ocarinaLangPatchByte = 0x08;
break;
case kor:
ocarinaLangPatchByte = 0x09;
break;
case ConsoleLangDefault:
default:
return;
break;
}
void *addr_start = addr;
void *addr_end = addr + len;
@ -330,10 +370,7 @@ void langpatcher(void *addr, u32 len)
if (memcmp(addr_start, langpatch, sizeof(langpatch)) == 0)
{
if (configbytes[0] != 0xCD)
{
langvipatch((u32) addr_start, len, configbytes[0]);
}
langvipatch((u32) addr_start, len, ocarinaLangPatchByte);
}
addr_start += 4;
}

View File

@ -29,12 +29,12 @@ extern "C"
// Globals
u32 hooktype;
int patched;
u8 configbytes[2];
u32 regionfree;
//u8 configbytes[2];
//u32 regionfree;
// Function prototypes
bool dogamehooks(void *addr, u32 len);
void langpatcher(void *addr, u32 len);
void langpatcher(void *addr, u32 len, u8 languageChoice);
void vidolpatcher(void *addr, u32 len);
void patchdebug(void *addr, u32 len);

View File

@ -106,7 +106,7 @@ typedef struct _dolheader
static dolheader *dolfile;
u32 load_dol_image(void *dolstart, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo, u8 fix002)
u32 load_dol_image(void *dolstart, u8 videoSelected, u8 languageChoice, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo, u8 fix002)
{
u32 i;
@ -120,7 +120,7 @@ u32 load_dol_image(void *dolstart, u8 videoSelected, u8 patchcountrystring, u8 v
ICInvalidateRange((void *) dolfile->text_start[i], dolfile->text_size[i]);
memmove((void *) dolfile->text_start[i], dolstart + dolfile->text_pos[i], dolfile->text_size[i]);
gamepatches((void *) dolfile->text_start[i], dolfile->text_size[i], videoSelected, patchcountrystring,
gamepatches((void *) dolfile->text_start[i], dolfile->text_size[i], videoSelected, languageChoice, patchcountrystring,
vipatch, cheat, returnTo, fix002);
Remove_001_Protection((void *) dolfile->data_start[i], dolfile->data_size[i]);
}
@ -130,7 +130,7 @@ u32 load_dol_image(void *dolstart, u8 videoSelected, u8 patchcountrystring, u8 v
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
memmove((void *) dolfile->data_start[i], dolstart + dolfile->data_pos[i], dolfile->data_size[i]);
gamepatches((void *) dolfile->data_start[i], dolfile->data_size[i], videoSelected, patchcountrystring,
gamepatches((void *) dolfile->data_start[i], dolfile->data_size[i], videoSelected, languageChoice, patchcountrystring,
vipatch, cheat, returnTo, fix002);
Remove_001_Protection((void *) dolfile->data_start[i], dolfile->data_size[i]);
DCFlushRangeNoSync((void *) dolfile->data_start[i], dolfile->data_size[i]);
@ -224,7 +224,7 @@ void __dvd_readidcb(s32 result)
{
dvddone = result;
}
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo, u8 fix002)
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 languageChoice, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo, u8 fix002)
{
int ret;
void *dol_header;
@ -265,7 +265,7 @@ u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u
{
ret = WDVD_Read(offset, len, (doloffset << 2) + pos);
gamepatches(offset, len, videoSelected, patchcountrystring, vipatch, cheat, returnTo, fix002);
gamepatches(offset, len, videoSelected, languageChoice, patchcountrystring, vipatch, cheat, returnTo, fix002);
Remove_001_Protection(offset, len);

View File

@ -8,11 +8,11 @@ extern "C"
/* not the full path is needed here, the path where the dol is */
bool Load_Dol(void **buffer, int* dollen, char * path, u8 videoSelected, u8 patchcountrystring, u8 vipatch,
bool Load_Dol(void **buffer, int* dollen, char * path, u8 videoSelected, u8 languageChoice, u8 patchcountrystring, u8 vipatch,
u8 cheat, u32 returnTo);
bool Remove_001_Protection(void *Address, int Size);
u32 load_dol_image(void * dolstart);
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo);
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 languageChoice, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo);
#ifdef __cplusplus
}

View File

@ -33,7 +33,7 @@ static u8 *appldr = (u8 *) 0x81200000;
/* Variables */
static u32 buffer[0x20] ATTRIBUTE_ALIGN( 32 );
void gamepatches( u8 * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo, u8 fix002 )
void gamepatches( u8 * dst, int len, u8 videoSelected, u8 languageChoice, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo, u8 fix002 )
{
VideoModePatcher( dst, len, videoSelected );
@ -44,7 +44,7 @@ void gamepatches( u8 * dst, int len, u8 videoSelected, u8 patchcountrystring, u8
vidolpatcher( dst, len );
/*LANGUAGE PATCH - FISHEARS*/
langpatcher( dst, len );
langpatcher( dst, len, languageChoice );
/*Thanks to WiiPower*/
if ( patchcountrystring == 1 ) PatchCountryStrings( dst, len );
@ -59,8 +59,8 @@ void gamepatches( u8 * dst, int len, u8 videoSelected, u8 patchcountrystring, u8
PatchReturnTo( dst, len, returnTo );
}
s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected, u8 vipatch, u8 patchcountrystring,
u8 error002fix, u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002)
s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected, u8 languageChoice, u8 vipatch, u8 patchcountrystring,
u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002)
{
app_entry appldr_entry;
app_init appldr_init;
@ -71,10 +71,6 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected
s32 ret;
gprintf("\nApploader_Run() started\n");
//u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
//if (geckoattached)usb_flush(EXI_CHANNEL_1);
geckoinit = InitGecko();
/* Read apploader header */
ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET);
if (ret < 0) return ret;
@ -95,7 +91,7 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected
/* Initialize apploader */
appldr_init(gprintf);
if (error002fix != 0)
if (fix002 != 0)
{
/* ERROR 002 fix (thanks to WiiPower for sharing this)*/
*(u32 *) 0x80003188 = *(u32 *) 0x80003140;
@ -114,7 +110,7 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected
WDVD_Read(dst, len, (u64) (offset << 2));
if( !alternatedol )
gamepatches(dst, len, videoSelected, patchcountrystring, vipatch, cheat, returnTo, fix002 );
gamepatches(dst, len, videoSelected, languageChoice, patchcountrystring, vipatch, cheat, returnTo, fix002 );
DCFlushRange(dst, len);
}
@ -128,7 +124,7 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected
void *dolbuffer = NULL;
int dollen = 0;
bool dolloaded = Load_Dol(&dolbuffer, &dollen, dolpath, videoSelected, patchcountrystring, vipatch, cheat, returnTo);
bool dolloaded = Load_Dol(&dolbuffer, &dollen, dolpath, videoSelected, languageChoice, patchcountrystring, vipatch, cheat, returnTo);
if (dolloaded)
{
*entry = (entry_point) load_dol_image(dolbuffer);
@ -141,7 +137,7 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected
wip_reset_counter();
FST_ENTRY *fst = (FST_ENTRY *) *(u32 *) 0x80000038;
*entry = (entry_point) Load_Dol_from_disc(fst[alternatedoloffset].fileoffset, videoSelected,
*entry = (entry_point) Load_Dol_from_disc(fst[alternatedoloffset].fileoffset, videoSelected, languageChoice,
patchcountrystring, vipatch, cheat, returnTo);
if (*entry == 0) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);

View File

@ -10,9 +10,9 @@ extern "C"
typedef void (*entry_point)(void);
/* Prototypes */
s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected, u8 vipatch,
u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002);
void gamepatches( u8 * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo, u8 fix002 );
s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected, u8 languageChoice, u8 vipatch,
u8 patchcountrystring, u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002);
void gamepatches( u8 * dst, int len, u8 videoSelected, u8 languageChoice, u8 patchcountrystring, u8 vipatch, u8 cheat, u32 returnTo, u8 fix002 );
#ifdef __cplusplus
}

View File

@ -15,6 +15,7 @@
#include "alternatedol.h"
#include "memory.h"
#include "wbfs.h"
#include "../settings/cfg.h"
#include "../gecko.h"
#include "../fatmounter.h"
@ -91,62 +92,59 @@ void __Disc_SetVMode(u8 videoselected)
switch (videoselected)
{
case 0:
/* Select video mode */
switch (diskid[3])
{
/* PAL */
case 'P':
case 'D':
case 'F':
case 'I':
case 'S':
case 'H':
case 'X':
case 'Y':
case 'Z':
if (tvmode != CONF_VIDEO_PAL)
{
vmode_reg = 5;
vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf;
}
break;
/* NTSC or unknown */
case 'E':
case 'J':
case 'K':
case 'W':
if (tvmode != CONF_VIDEO_NTSC)
{
vmode_reg = 0;
vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf;
}
break;
}
break;
case 1:
case pal50:
vmode = &TVPal528IntDf;
vmode_reg = (vmode->viTVMode) >> 2;
break;
case 2:
progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable();
case pal60:
vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf;
vmode_reg = (vmode->viTVMode) >> 2;
break;
case 3:
progressive = (CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable();
case ntsc:
vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf;
vmode_reg = (vmode->viTVMode) >> 2;
break;
case 4:
case systemdefault:
// vmode = VIDEO_GetPreferredMode(NULL);
break;
}
case discdefault:
default:
/* Select video mode */
switch (diskid[3])
{
/* PAL */
case 'P':
case 'D':
case 'F':
case 'I':
case 'S':
case 'H':
case 'X':
case 'Y':
case 'Z':
if (tvmode != CONF_VIDEO_PAL)
{
vmode_reg = 5;
vmode = (progressive) ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf;
}
break;
/* NTSC or unknown */
case 'E':
case 'J':
case 'K':
case 'W':
if (tvmode != CONF_VIDEO_NTSC)
{
vmode_reg = 0;
vmode = (progressive) ? &TVNtsc480Prog : &TVNtsc480IntDf;
}
break;
}
break;
}
/* Set video mode register */
*Video_Mode = vmode_reg;
@ -286,8 +284,8 @@ s32 Disc_IsWii(void)
return 0;
}
s32 Disc_BootPartition(u64 offset, char * dolpath, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring,
u8 error002fix, u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002)
s32 Disc_BootPartition(u64 offset, char * dolpath, u8 videoselected, u8 languageChoice, u8 cheat, u8 vipatch, u8 patchcountrystring,
u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002)
{
gprintf("booting partition IOS %u v%u\n", IOS_GetVersion(), IOS_GetRevision());
entry_point p_entry;
@ -311,7 +309,7 @@ s32 Disc_BootPartition(u64 offset, char * dolpath, u8 videoselected, u8 cheat, u
PoPPatch();
/* Run apploader */
ret = Apploader_Run(&p_entry, dolpath, cheat, videoselected, vipatch, patchcountrystring, error002fix,
ret = Apploader_Run(&p_entry, dolpath, cheat, videoselected, languageChoice, vipatch, patchcountrystring,
alternatedol, alternatedoloffset, returnTo, fix002);
if (ret < 0) return ret;
@ -386,7 +384,7 @@ s32 Disc_BootPartition(u64 offset, char * dolpath, u8 videoselected, u8 cheat, u
return 0;
}
s32 Disc_WiiBoot(char * dolpath, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix,
s32 Disc_WiiBoot(char * dolpath, u8 videoselected, u8 languageChoice, u8 cheat, u8 vipatch, u8 patchcountrystring,
u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002)
{
u64 offset;
@ -397,7 +395,7 @@ s32 Disc_WiiBoot(char * dolpath, u8 videoselected, u8 cheat, u8 vipatch, u8 patc
if (ret < 0) return ret;
/* Boot partition */
return Disc_BootPartition(offset, dolpath, videoselected, cheat, vipatch, patchcountrystring, error002fix,
return Disc_BootPartition(offset, dolpath, videoselected, languageChoice, cheat, vipatch, patchcountrystring,
alternatedol, alternatedoloffset, returnTo, fix002);
}

View File

@ -50,8 +50,8 @@ extern "C"
s32 Disc_SetUSB(const u8 *);
s32 Disc_ReadHeader(void *);
s32 Disc_IsWii(void);
s32 Disc_BootPartition(u64, char *, u8, u8, u8, u8, u8, u8, u32, u32 returnTo, u8 fix002);
s32 Disc_WiiBoot(char *, u8, u8, u8, u8, u8, u8, u32, u32 returnTo, u8 fix002);
s32 Disc_BootPartition(u64, char *, u8, u8 languageChoice, u8, u8, u8, u8, u32, u32 returnTo, u8 fix002);
s32 Disc_WiiBoot(char *, u8, u8 languageChoice, u8, u8, u8, u8, u32, u32 returnTo, u8 fix002);
s32 __Disc_FindPartition(u64 *outbuf);
void PatchCountryStrings(void *Address, int Size);
s32 __Disc_FindPartition(u64 *outbuf);