*Added per game NandEmu, Hooktype, WiirdDebugger setting

*Disabled try to mount of drive when no disc is inserted
*Bug in NandEmu fat FD close was fixed with latest d2x, workaround removed
*Added create of nand emu path for rabbits go home to /title/00010004/ (Partial Nand Emu) (thx nic for the info)
*Fixed loading default values for new added game settings
This commit is contained in:
dimok321 2011-09-03 09:39:26 +00:00
parent a0a669a00a
commit e43c9b108d
13 changed files with 133 additions and 35 deletions

View File

@ -2,8 +2,8 @@
<app version="1"> <app version="1">
<name> USB Loader GX</name> <name> USB Loader GX</name>
<coder>USB Loader GX Team</coder> <coder>USB Loader GX Team</coder>
<version>2.2 r1109</version> <version>2.2 r1110</version>
<release_date>201108132358</release_date> <release_date>201109030839</release_date>
<!-- // remove this line to enable arguments <!-- // remove this line to enable arguments
<arguments> <arguments>
<arg>--ios=250</arg> <arg>--ios=250</arg>

View File

@ -1,12 +0,0 @@
#
# to use this file rename Make.config.default to Make.config
# or create a new Make.config
#
# you can here add defines
#
# in example i have included a switch to diseble
# the gecko-debug stuff. so also in source gecko.c+gecko.h
#
# NOTE when add, remove or change a define here then a "make clean" is needed
#
CFLAGS += -DNO_DEBUG DDEBUG_WBFS

View File

@ -1170,13 +1170,18 @@ void GameBrowseMenu::CheckDiscSlotUpdate()
else if (dvdBtn->GetState() == STATE_CLICKED) else if (dvdBtn->GetState() == STATE_CLICKED)
{ {
gprintf("\tdvdBtn Clicked\n"); gprintf("\tdvdBtn Clicked\n");
if(DiscDriveCover & 0x02)
{
if(!dvdheader) if(!dvdheader)
dvdheader = new struct discHdr; dvdheader = new struct discHdr;
mountMethod = DiscMount(dvdheader); mountMethod = DiscMount(dvdheader);
dvdBtn->ResetState();
rockout(GetSelectedGame()); rockout(GetSelectedGame());
} }
else
WindowPrompt(tr( "No disc inserted." ), 0, tr( "OK" ));
dvdBtn->ResetState();
}
if(DiscDriveCoverOld != DiscDriveCover) if(DiscDriveCoverOld != DiscDriveCover)
{ {

View File

@ -188,6 +188,9 @@ static const u32 dczeropatch[4] = {
void dogamehooks(u32 hooktype, void *addr, u32 len) void dogamehooks(u32 hooktype, void *addr, u32 len)
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
{ {
if(hooktype == 0x00)
return;
void *addr_start = addr; void *addr_start = addr;
void *addr_end = addr+len; void *addr_end = addr+len;
@ -195,7 +198,6 @@ void dogamehooks(u32 hooktype, void *addr, u32 len)
{ {
switch(hooktype) switch(hooktype)
{ {
default: default:
case 0x00: case 0x00:

View File

@ -189,6 +189,9 @@ bool CGameSettings::Save()
fprintf(f, "alternatedolname:%s; ", GameList[i].alternatedolname); fprintf(f, "alternatedolname:%s; ", GameList[i].alternatedolname);
fprintf(f, "returnTo:%d; ", GameList[i].returnTo); fprintf(f, "returnTo:%d; ", GameList[i].returnTo);
fprintf(f, "sneekVideoPatch:%d; ", GameList[i].sneekVideoPatch); fprintf(f, "sneekVideoPatch:%d; ", GameList[i].sneekVideoPatch);
fprintf(f, "NandEmuMode:%d; ", GameList[i].NandEmuMode);
fprintf(f, "Hooktype:%d; ", GameList[i].Hooktype);
fprintf(f, "WiirdDebugger:%d; ", GameList[i].WiirdDebugger);
fprintf(f, "Locked:%d;\n", GameList[i].Locked); fprintf(f, "Locked:%d;\n", GameList[i].Locked);
} }
fprintf(f, "# END\n"); fprintf(f, "# END\n");
@ -310,6 +313,30 @@ bool CGameSettings::SetSetting(GameCFG & game, char *name, char *value)
} }
return true; return true;
} }
else if(strcmp(name, "NandEmuMode") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.NandEmuMode = i;
}
return true;
}
else if(strcmp(name, "Hooktype") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.Hooktype = i;
}
return true;
}
else if(strcmp(name, "WiirdDebugger") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.WiirdDebugger = i;
}
return true;
}
else if(strcmp(name, "Locked") == 0) else if(strcmp(name, "Locked") == 0)
{ {
if (sscanf(value, "%d", &i) == 1) if (sscanf(value, "%d", &i) == 1)
@ -360,7 +387,7 @@ void CGameSettings::ParseLine(char *line)
return; return;
GameCFG NewCFG; GameCFG NewCFG;
memset(&NewCFG, 0, sizeof(GameCFG)); memcpy(&NewCFG, GetDefault(), sizeof(GameCFG));
strcpy(NewCFG.id, GameID); strcpy(NewCFG.id, GameID);
@ -433,6 +460,9 @@ GameCFG * CGameSettings::GetDefault()
DefaultConfig.alternatedolname[0] = '\0'; DefaultConfig.alternatedolname[0] = '\0';
DefaultConfig.returnTo = 1; DefaultConfig.returnTo = 1;
DefaultConfig.sneekVideoPatch = INHERIT; DefaultConfig.sneekVideoPatch = INHERIT;
DefaultConfig.NandEmuMode = INHERIT;
DefaultConfig.Hooktype = INHERIT;
DefaultConfig.WiirdDebugger = INHERIT;
DefaultConfig.Locked = OFF; DefaultConfig.Locked = OFF;
return &DefaultConfig; return &DefaultConfig;

View File

@ -24,6 +24,9 @@ typedef struct _GameCFG
char alternatedolname[40]; char alternatedolname[40];
short returnTo; short returnTo;
short sneekVideoPatch; short sneekVideoPatch;
short NandEmuMode;
short Hooktype;
short WiirdDebugger;
short Locked; short Locked;
} GameCFG; } GameCFG;

View File

@ -92,6 +92,25 @@ static const char * AlternateDOLText[] =
trNOOP( "Default" ), trNOOP( "Default" ),
}; };
static const char * NandEmuText[] =
{
trNOOP( "OFF" ),
trNOOP( "Partial" ),
trNOOP( "Full" )
};
static const char * HooktypeText[] =
{
trNOOP( "None" ),
trNOOP( "VBI (Default)" ),
trNOOP( "KPAD Read" ),
trNOOP( "Joypad" ),
trNOOP( "GXDraw" ),
trNOOP( "GXFlush" ),
trNOOP( "OSSleepThread" ),
trNOOP( "AXNextFrame" ),
};
GameLoadSM::GameLoadSM(const char * GameID) GameLoadSM::GameLoadSM(const char * GameID)
: SettingsMenu(tr("Game Load"), &GuiOptions, MENU_NONE) : SettingsMenu(tr("Game Load"), &GuiOptions, MENU_NONE)
{ {
@ -155,6 +174,9 @@ void GameLoadSM::SetOptionNames()
Options->SetName(Idx++, "%s", tr( "Alternate DOL" )); Options->SetName(Idx++, "%s", tr( "Alternate DOL" ));
Options->SetName(Idx++, "%s", tr( "Select DOL Offset" )); Options->SetName(Idx++, "%s", tr( "Select DOL Offset" ));
Options->SetName(Idx++, "%s", tr( "Block IOS Reload" )); Options->SetName(Idx++, "%s", tr( "Block IOS Reload" ));
Options->SetName(Idx++, "%s", tr( "Nand Emulation" ));
Options->SetName(Idx++, "%s", tr( "Hooktype" ));
Options->SetName(Idx++, "%s", tr( "Wiird Debugger" ));
Options->SetName(Idx++, "%s", tr( "Game Lock" )); Options->SetName(Idx++, "%s", tr( "Game Lock" ));
} }
@ -248,6 +270,24 @@ void GameLoadSM::SetOptionValues()
else else
Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.iosreloadblock]) ); Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.iosreloadblock]) );
//! Settings: Nand Emulation
if(GameConfig.NandEmuMode == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr( NandEmuText[GameConfig.NandEmuMode] ));
//! Settings: Hooktype
if(GameConfig.Hooktype == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr( HooktypeText[GameConfig.Hooktype] ));
//! Settings: Wiird Debugger
if(GameConfig.WiirdDebugger == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.WiirdDebugger] ));
//! Settings: Game Lock //! Settings: Game Lock
Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.Locked] )); Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.Locked] ));
} }
@ -397,6 +437,26 @@ int GameLoadSM::GetMenuInternal()
if(++GameConfig.iosreloadblock >= 3) GameConfig.iosreloadblock = INHERIT; if(++GameConfig.iosreloadblock >= 3) GameConfig.iosreloadblock = INHERIT;
} }
//! Settings: Nand Emulation
else if (ret == ++Idx)
{
if(!IosLoader::IsD2X())
WindowPrompt(tr("Error:"), tr("Nand Emulation is only available on D2X cIOS!"), tr("OK"));
else if (++GameConfig.NandEmuMode >= 3) GameConfig.NandEmuMode = INHERIT;
}
//! Settings: Hooktype
else if (ret == ++Idx)
{
if (++GameConfig.Hooktype >= 8) GameConfig.Hooktype = INHERIT;
}
//! Settings: Wiird Debugger
else if (ret == ++Idx)
{
if (++GameConfig.WiirdDebugger >= MAX_ON_OFF) GameConfig.WiirdDebugger = INHERIT;
}
//! Settings: Game Lock //! Settings: Game Lock
else if (ret == ++Idx) else if (ret == ++Idx)
{ {

View File

@ -134,15 +134,15 @@ void GameBooter::SetupAltDOL(u8 * gameID, u8 &alternatedol, u32 &alternatedoloff
alternatedol = OFF; alternatedol = OFF;
} }
void GameBooter::SetupNandEmu(struct discHdr &gameHeader) void GameBooter::SetupNandEmu(u8 NandEmuMode, struct discHdr &gameHeader)
{ {
if(Settings.NandEmuMode && strchr(Settings.NandEmuPath, '/')) if(NandEmuMode && strchr(Settings.NandEmuPath, '/'))
{ {
//! Create save game path and title.tmd for not existing saves //! Create save game path and title.tmd for not existing saves
CreateSavePath(&gameHeader); CreateSavePath(&gameHeader);
gprintf("Enabling Nand Emulation on: %s\n", Settings.NandEmuPath); gprintf("Enabling Nand Emulation on: %s\n", Settings.NandEmuPath);
Set_FullMode(Settings.NandEmuMode == 2); Set_FullMode(NandEmuMode == 2);
Set_Path(strchr(Settings.NandEmuPath, '/')); Set_Path(strchr(Settings.NandEmuPath, '/'));
//! Set which partition to use (USB only) //! Set which partition to use (USB only)
@ -234,6 +234,9 @@ int GameBooter::BootGame(const char * gameID)
u8 alternatedol = game_cfg->loadalternatedol; u8 alternatedol = game_cfg->loadalternatedol;
u32 alternatedoloffset = game_cfg->alternatedolstart; u32 alternatedoloffset = game_cfg->alternatedolstart;
u8 reloadblock = game_cfg->iosreloadblock == INHERIT ? Settings.BlockIOSReload : game_cfg->iosreloadblock; u8 reloadblock = game_cfg->iosreloadblock == INHERIT ? Settings.BlockIOSReload : game_cfg->iosreloadblock;
u8 NandEmuMode = game_cfg->NandEmuMode == INHERIT ? Settings.NandEmuMode : game_cfg->NandEmuMode;
u8 Hooktype = game_cfg->Hooktype == INHERIT ? Settings.Hooktype : game_cfg->Hooktype;
u8 WiirdDebugger = game_cfg->WiirdDebugger == INHERIT ? Settings.WiirdDebugger : game_cfg->WiirdDebugger;
u64 returnToChoice = game_cfg->returnTo ? NandTitles.FindU32(Settings.returnTo) : 0; u64 returnToChoice = game_cfg->returnTo ? NandTitles.FindU32(Settings.returnTo) : 0;
if(ocarinaChoice && Settings.Hooktype == OFF) if(ocarinaChoice && Settings.Hooktype == OFF)
@ -256,7 +259,7 @@ int GameBooter::BootGame(const char * gameID)
Playlog_Update((char *) gameHeader.id, BNRInstance::Instance()->GetIMETTitle(CONF_GetLanguage())); Playlog_Update((char *) gameHeader.id, BNRInstance::Instance()->GetIMETTitle(CONF_GetLanguage()));
//! Setup NAND emulation //! Setup NAND emulation
SetupNandEmu(gameHeader); SetupNandEmu(NandEmuMode, gameHeader);
//! Setup disc in cIOS and open it //! Setup disc in cIOS and open it
ret = SetupDisc(gameHeader.id); ret = SetupDisc(gameHeader.id);
@ -303,14 +306,14 @@ int GameBooter::BootGame(const char * gameID)
//! Do all the game patches //! Do all the game patches
gprintf("Applying game patches...\n"); gprintf("Applying game patches...\n");
gamepatches(videoChoice, languageChoice, countrystrings, viChoice, sneekChoice, Settings.Hooktype, fix002, reloadblock, iosChoice, returnToChoice); gamepatches(videoChoice, languageChoice, countrystrings, viChoice, sneekChoice, Hooktype, fix002, reloadblock, iosChoice, returnToChoice);
//! Load Ocarina codes //! Load Ocarina codes
if (ocarinaChoice) if (ocarinaChoice)
ocarina_load_code(Settings.Cheatcodespath); ocarina_load_code(Settings.Cheatcodespath);
//! Load Code handler if needed //! Load Code handler if needed
load_handler(Settings.Cheatcodespath, Settings.Hooktype, Settings.WiirdDebugger, Settings.WiirdDebuggerPause); load_handler(Settings.Cheatcodespath, Hooktype, WiirdDebugger, Settings.WiirdDebuggerPause);
//! Shadow mload - Only needed on some games with Hermes v5.1 (Check is inside the function) //! Shadow mload - Only needed on some games with Hermes v5.1 (Check is inside the function)
shadow_mload(); shadow_mload();

View File

@ -27,7 +27,7 @@ class GameBooter
private: private:
static int FindDiscHeader(const char * gameID, struct discHdr &gameHeader); static int FindDiscHeader(const char * gameID, struct discHdr &gameHeader);
static void SetupAltDOL(u8 * gameID, u8 &alternatedol, u32 &alternatedoloffset); static void SetupAltDOL(u8 * gameID, u8 &alternatedol, u32 &alternatedoloffset);
static void SetupNandEmu(struct discHdr &gameHeader); static void SetupNandEmu(u8 NandEmuMode, struct discHdr &gameHeader);
static int SetupDisc(u8 *gameID); static int SetupDisc(u8 *gameID);
static u32 BootPartition(char * dolpath, u8 videoselected, u8 alternatedol, u32 alternatedoloffset); static u32 BootPartition(char * dolpath, u8 videoselected, u8 alternatedol, u32 alternatedoloffset);
}; };

View File

@ -74,8 +74,7 @@ static s32 Nand_Mount(nandDevice *dev)
ret = IOS_Ioctlv(fd, dev->mountCmd, inlen, 0, vector); ret = IOS_Ioctlv(fd, dev->mountCmd, inlen, 0, vector);
/* Close FAT module */ /* Close FAT module */
//!TODO: Figure out why this causes a freeze IOS_Close(fd);
//IOS_Close(fd);
/* Free memory */ /* Free memory */
if(buffer != NULL) if(buffer != NULL)

View File

@ -96,10 +96,18 @@ void CreateSavePath(const struct discHdr *hdr)
snprintf(nandPath, sizeof(nandPath), "%s/tmp", Settings.NandEmuPath); snprintf(nandPath, sizeof(nandPath), "%s/tmp", Settings.NandEmuPath);
CreateNandPath(nandPath); CreateNandPath(nandPath);
snprintf(nandPath, sizeof(nandPath), "%s/title/00010000/%02x%02x%02x%02x/data", Settings.NandEmuPath, hdr->id[0], hdr->id[1], hdr->id[2], hdr->id[3]); const char *titlePath = "title/00010000";
if( memcmp(hdr->id, "RGWX41", 6) == 0 || memcmp(hdr->id, "RGWP41", 6) == 0 ||
memcmp(hdr->id, "RGWJ41", 6) == 0 || memcmp(hdr->id, "RGWE41", 6) == 0)
{
titlePath = "title/00010004";
}
snprintf(nandPath, sizeof(nandPath), "%s/%s/%02x%02x%02x%02x/data", Settings.NandEmuPath, titlePath, hdr->id[0], hdr->id[1], hdr->id[2], hdr->id[3]);
CreateNandPath(nandPath); CreateNandPath(nandPath);
snprintf(nandPath, sizeof(nandPath), "%s/title/00010000/%02x%02x%02x%02x/content", Settings.NandEmuPath, hdr->id[0], hdr->id[1], hdr->id[2], hdr->id[3]); snprintf(nandPath, sizeof(nandPath), "%s/%s/%02x%02x%02x%02x/content", Settings.NandEmuPath, titlePath, hdr->id[0], hdr->id[1], hdr->id[2], hdr->id[3]);
CreateNandPath(nandPath); CreateNandPath(nandPath);
strcat(nandPath, "/title.tmd"); strcat(nandPath, "/title.tmd");

View File

@ -267,7 +267,7 @@ s32 Disc_IsWii(void)
return 0; return 0;
} }
s32 Disc_JumpToEntrypoint(bool enablecheat, u32 dolparameter) s32 Disc_JumpToEntrypoint(s32 hooktype, u32 dolparameter)
{ {
/* Set an appropiate video mode */ /* Set an appropiate video mode */
__Disc_SetVMode(); __Disc_SetVMode();
@ -284,7 +284,7 @@ s32 Disc_JumpToEntrypoint(bool enablecheat, u32 dolparameter)
/* Originally from tueidj - taken from NeoGamme (thx) */ /* Originally from tueidj - taken from NeoGamme (thx) */
*(vu32*)0xCC003024 = dolparameter != 0 ? dolparameter : 1; *(vu32*)0xCC003024 = dolparameter != 0 ? dolparameter : 1;
if (enablecheat) if (hooktype)
{ {
__asm__( __asm__(
"lis %r3, AppEntrypoint@h\n" "lis %r3, AppEntrypoint@h\n"

View File

@ -53,7 +53,7 @@ extern "C"
s32 Disc_FindPartition(u64 *outbuf); s32 Disc_FindPartition(u64 *outbuf);
void PatchCountryStrings(void *Address, int Size); void PatchCountryStrings(void *Address, int Size);
void Disc_SelectVMode(u8 videoselected); void Disc_SelectVMode(u8 videoselected);
s32 Disc_JumpToEntrypoint(bool enablecheat, u32 dolparameter); s32 Disc_JumpToEntrypoint(s32 hooktype, u32 dolparameter);
#ifdef __cplusplus #ifdef __cplusplus
} }