*Seperated game settings from cfg.c into it's own class. Some stuff might be broken and need adjustments.

This commit is contained in:
dimok321 2010-09-24 21:22:01 +00:00
parent 88969ffb9f
commit e44e3c817c
17 changed files with 616 additions and 670 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r970</version>
<release_date>201009241642</release_date>
<version>1.0 r971</version>
<release_date>201009241958</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.

File diff suppressed because one or more lines are too long

View File

@ -19,6 +19,7 @@
#include "network/networkops.h"
#include "patches/patchcode.h"
#include "settings/Settings.h"
#include "settings/CGameSettings.h"
#include "themes/CTheme.h"
#include "themes/Theme_Downloader.h"
#include "usbloader/disc.h"
@ -417,7 +418,19 @@ int MainMenu(int menu)
int ret = 0;
header = (mountMethod ? dvdheader : gameList[gameSelected]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
u8 videoChoice = Settings.videomode;
u8 languageChoice = Settings.language;
u8 ocarinaChoice = Settings.ocarina;
u8 viChoice = Settings.videopatch;
u8 iosChoice = Settings.cios;
u8 fix002 = Settings.error002;
u8 countrystrings = Settings.patchcountrystrings;
u8 alternatedol = off;
u32 alternatedoloffset = 0;
u8 reloadblock = off;
u8 returnToLoaderGV = 1;
GameCFG * game_cfg = GameSettings.GetGameCFG(header->id);
if (game_cfg)
{
@ -436,23 +449,6 @@ int MainMenu(int menu)
reloadblock = game_cfg->iosreloadblock;
returnToLoaderGV = game_cfg->returnTo;
}
else
{
videoChoice = Settings.videomode;
languageChoice = Settings.language;
ocarinaChoice = Settings.ocarina;
viChoice = Settings.videopatch;
iosChoice = Settings.cios;
fix002 = Settings.error002;
countrystrings = Settings.patchcountrystrings;
if (!altdoldefault)
{
alternatedol = off;
alternatedoloffset = 0;
}
reloadblock = off;
returnToLoaderGV = 1;
}
if (!mountMethod)
{
@ -623,7 +619,7 @@ int MainMenu(int menu)
gprintf("\tDisc_wiiBoot\n");
ret = Disc_WiiBoot(Settings.dolpath, videoselected, cheat, vipatch, countrystrings, errorfixer002,
alternatedol, alternatedoloffset, channel);
alternatedol, alternatedoloffset, channel, fix002);
if (ret < 0)
{
Sys_LoadMenu();

View File

@ -9,6 +9,7 @@
#include "prompts/DiscBrowser.h"
#include "prompts/TitleBrowser.h"
#include "settings/Settings.h"
#include "settings/CGameSettings.h"
#include "themes/CTheme.h"
#include "wpad.h"
#include "sys.h"
@ -1656,7 +1657,9 @@ int MenuDiscList()
header = (mountMethod == 1 || mountMethod == 2 ? dvdheader : gameList[gameSelected]); //reset header
snprintf(IDfull, sizeof(IDfull), "%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],
header->id[3], header->id[4], header->id[5]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
GameCFG* game_cfg = GameSettings.GetGameCFG(header->id);
u8 alternatedol;
u8 ocarinaChoice;
if (game_cfg)
{
@ -1799,7 +1802,7 @@ int MenuDiscList()
//re-evaluate header now in case they changed games while on the game prompt
header = (mountMethod == 1 || mountMethod == 2 ? dvdheader : gameList[gameSelected]);
int settret = GameSettings(header);
int settret = MenuGameSettings(header);
/* unneeded for now, kept in case database gets a separate language setting
//menu = MENU_DISCLIST; // refresh titles (needed if the language setting has changed)
*/
@ -1885,44 +1888,6 @@ int MenuDiscList()
covertOld = covert;
}
// set alt dol default
if (menu == MENU_EXIT && altdoldefault)
{
struct discHdr *header = (mountMethod == 1 || mountMethod == 2 ? dvdheader : gameList[gameSelected]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
// use default only if no alt dol was selected manually
if (game_cfg)
{
if (game_cfg->alternatedolstart != 0) altdoldefault = false;
}
if (altdoldefault)
{
int autodol = autoSelectDol((char*) header->id, true);
if (autodol > 0)
{
alternatedol = 2;
alternatedoloffset = autodol;
char temp[20];
sprintf(temp, "%d", autodol);
}
else
{
// alt dol menu for games that require more than a single alt dol
int autodol = autoSelectDolMenu((char*) header->id, true);
if (autodol > 0)
{
alternatedol = 2;
alternatedoloffset = autodol;
}
}
}
}
//no need to close sd here. we still need to get settings and codes and shit
/*if (menu == MENU_EXIT) {
SDCard_deInit();
}*/
//if (Settings.gameDisplay==list) {startat=gameBrowser->GetOffset(), offset=startat;}//save the variables in case we are refreshing the list
//gprintf("\n\tstartat:%d offset:%d",startat,offset);
HaltGui();
mainWindow->RemoveAll();
mainWindow->Append(bgImg);

View File

@ -0,0 +1,387 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <ogcsys.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CGameSettings.h"
#include "listfiles.h"
CGameSettings GameSettings;
const char * VideoMap[] =
{
"system",
"game",
"patch",
"pal50",
"pal60",
"ntsc",
NULL
};
const char * LanguageMap[] =
{
"console",
"japanese",
"english",
"german",
"french",
"spanish",
"italian",
"dutch",
"schinese",
"tchinese",
"korean",
NULL
};
CGameSettings::CGameSettings()
{
}
CGameSettings::~CGameSettings()
{
}
GameCFG * CGameSettings::GetGameCFG(const char * id)
{
if(!id)
return NULL;
for(u32 i = 0; i < GameList.size(); ++i)
{
if(strncmp(id, GameList[i].id, 6) == 0)
{
return &GameList[i];
}
}
return NULL;
}
bool CGameSettings::AddGame(const GameCFG * NewGame)
{
if(!NewGame)
return false;
for(u32 i = 0; i < GameList.size(); ++i)
{
if(strncmp(NewGame->id, GameList[i].id, 6) == 0)
{
memcpy(&GameList[i], NewGame, sizeof(GameCFG));
return Save();
}
}
GameList.push_back(*NewGame);
return Save();
}
bool CGameSettings::RemoveAll()
{
GameList.clear();
std::vector<GameCFG>().swap(GameList);
return Save();
}
bool CGameSettings::Remove(const char * id)
{
if(!id)
return false;
for(u32 i = 0; i < GameList.size(); ++i)
{
if(strncmp(id, GameList[i].id, 6) == 0)
{
GameList.erase(GameList.begin()+i);
break;
}
}
return Save();
}
bool CGameSettings::Load(const char * path)
{
char line[1024];
char filepath[300];
snprintf(filepath, sizeof(filepath), "%s/config/GXCGameSettings.cfg", path);
ConfigPath = filepath;
FILE *file = fopen(filepath, "r");
if (!file) return false;
while (fgets(line, sizeof(line), file))
{
if (line[0] == '#')
continue;
this->ParseLine(line);
}
fclose(file);
return true;
}
bool CGameSettings::Save()
{
char filepath[300];
strcpy(filepath, ConfigPath.c_str());
char * ptr = strrchr(filepath, '/');
if(ptr)
ptr[0] = 0;
subfoldercreate(filepath);
FILE * f = fopen(ConfigPath.c_str(), "w");
if (!f) return false;
fprintf(f, "# USB Loader settings file\n");
fprintf(f, "# note: this file is automatically generated\n");
fprintf(f, "# Num Games: %d\n", GameList.size());
for (u32 i = 0; i < GameList.size(); ++i)
{
fprintf(f, "game:%s = ", GameList[i].id);
fprintf(f, "video:%s; ", VideoMap[GameList[i].video]);
fprintf(f, "language:%s; ", LanguageMap[GameList[i].language]);
fprintf(f, "ocarina:%d; ", GameList[i].ocarina);
fprintf(f, "vipatch:%d; ", GameList[i].vipatch);
fprintf(f, "ios:%d; ", GameList[i].ios);
fprintf(f, "parentalcontrol:%d; ", GameList[i].parentalcontrol);
fprintf(f, "errorfix002:%d; ", GameList[i].errorfix002);
fprintf(f, "iosreloadblock:%d; ", GameList[i].iosreloadblock);
fprintf(f, "patchcountrystrings:%d; ", GameList[i].patchcountrystrings);
fprintf(f, "loadalternatedol:%d; ", GameList[i].loadalternatedol);
fprintf(f, "alternatedolstart:%d; ", GameList[i].alternatedolstart);
fprintf(f, "alternatedolname:%s; ", GameList[i].alternatedolname);
fprintf(f, "returnTo:%d;\n", GameList[i].returnTo);
}
fprintf(f, "# END\n");
fclose(f);
return true;
}
bool CGameSettings::SetSetting(GameCFG & game, char *name, char *value)
{
int i = 0;
if (strcmp(name, "video") == 0)
{
for(i = 0; VideoMap[i] != NULL; ++i)
{
if(strcasecmp(value, VideoMap[i]) == 0)
{
game.video = i;
break;
}
}
return true;
}
else if(strcmp(name, "language") == 0)
{
for(i = 0; LanguageMap[i] != NULL; ++i)
{
if(strcasecmp(value, LanguageMap[i]) == 0)
{
game.language = i;
break;
}
}
return true;
}
else if(strcmp(name, "ocarina") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.ocarina = i;
}
return true;
}
else if(strcmp(name, "vipatch") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.vipatch = i;
}
return true;
}
else if(strcmp(name, "ios") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.ios = i;
}
return true;
}
else if(strcmp(name, "parentalcontrol") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.parentalcontrol = i;
}
return true;
}
else if(strcmp(name, "errorfix002") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.errorfix002 = i;
}
return true;
}
else if(strcmp(name, "iosreloadblock") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.iosreloadblock = i;
}
return true;
}
else if(strcmp(name, "loadalternatedol") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.loadalternatedol = i;
}
return true;
}
else if(strcmp(name, "alternatedolstart") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.alternatedolstart = i;
}
return true;
}
else if(strcmp(name, "patchcountrystrings") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.patchcountrystrings = i;
}
return true;
}
else if(strcmp(name, "alternatedolname") == 0)
{
snprintf(game.alternatedolname, sizeof(game.alternatedolname), value);
return true;
}
else if(strcmp(name, "returnTo") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
game.returnTo = i;
}
return true;
}
return false;
}
bool CGameSettings::ReadGameID(const char * src, char * GameID, int size)
{
if(strncasecmp(src, "game:", 5) != 0)
return false;
char * ptr = strchr(src, ':');
if(!ptr)
return false;
ptr++;
int i = 0;
for(i = 0; i < size; i++, ptr++)
{
if(*ptr == ' ' || *ptr == '\0')
break;
GameID[i] = *ptr;
}
GameID[i] = 0;
return true;
}
void CGameSettings::ParseLine(char *line)
{
char name[1024], value[1024];
char GameID[8];
if(!ReadGameID(line, GameID, 6))
return;
int pos = GameList.size();
GameList.resize(pos+1);
memset(&GameList[pos], 0, sizeof(GameCFG));
strcpy(GameList[pos].id, GameID);
char * LinePtr = strchr(line, '=');
while(LinePtr != NULL)
{
LinePtr++;
char * eq = strchr(LinePtr, ':');
if (!eq) return;
this->TrimLine(name, LinePtr, sizeof(name));
this->TrimLine(value, eq + 1, sizeof(value));
SetSetting(GameList[pos], name, value);
LinePtr = strchr(LinePtr, ';');
}
}
void CGameSettings::TrimLine(char *dest, const char *src, int size)
{
while (*src == ' ')
src++;
int i = 0;
for(i = 0; i < size; i++, src++)
{
if(*src == ';' || *src == '\n' ||
*src == '\r' || *src == '\0')
break;
dest[i] = *src;
}
dest[i] = '\0';
}

View File

@ -0,0 +1,68 @@
#ifndef _GAME_SETTINGS_H_
#define _GAME_SETTINGS_H_
#include <string>
#include <stdio.h>
#include <gctypes.h>
#include <vector>
#include "usbloader/disc.h"
typedef struct _GameCFG
{
char id[7];
u8 video;
u8 language;
u8 ocarina;
u8 vipatch;
u8 ios;
u8 parentalcontrol;
u8 errorfix002;
u8 iosreloadblock;
u8 loadalternatedol;
u32 alternatedolstart;
u8 patchcountrystrings;
char alternatedolname[40];
u8 returnTo;
} GameCFG;
class CGameSettings
{
public:
//!Constructor
CGameSettings();
//!Destructor
~CGameSettings();
//!Load
bool Load(const char * path);
//!Save
bool Save();
//!AddGame
bool AddGame(const GameCFG * NewGame);
//!Reset
bool RemoveAll();
//!Overload Reset for one Game
bool Remove(const char * id);
bool Remove(const u8 * id) { return Remove((const char *) id); };
bool Remove(const struct discHdr * game) { if(!game) return false; else return Remove(game->id); };
//!Get GameCFG
GameCFG * GetGameCFG(const char * id);
//!Overload
GameCFG * GetGameCFG(const u8 * id) { return GetGameCFG((const char *) id); };
//!Overload
GameCFG * GetGameCFG(const struct discHdr * game) { if(!game) return NULL; else return GetGameCFG(game->id); };
protected:
bool ReadGameID(const char * src, char * GameID, int size);
bool SetSetting(GameCFG & game, char *name, char *value);
//!Find the config file in the default paths
bool FindConfig();
void ParseLine(char *line);
void TrimLine(char *dest, const char *src, int size);
std::string ConfigPath;
std::vector<GameCFG> GameList;
};
extern CGameSettings GameSettings;
#endif

View File

@ -84,7 +84,7 @@ void CSettings::SetDefault()
parentalcontrol = 0;
cios = 249;
xflip = no;
qboot = no;
quickboot = no;
wiilight = 1;
autonetwork = 0;
discart = 0;
@ -204,7 +204,7 @@ bool CSettings::Save()
fprintf(file, "keyset = %d\n ", keyset);
fprintf(file, "xflip = %d\n ", xflip);
fprintf(file, "gridRows = %d\n ", gridRows);
fprintf(file, "qboot = %d\n ", qboot);
fprintf(file, "quickboot = %d\n ", quickboot);
fprintf(file, "wsprompt = %d\n ", wsprompt);
fprintf(file, "parentalcontrol = %d\n ", parentalcontrol);
fprintf(file, "cover_path = %s\n ", covers_path);
@ -372,9 +372,9 @@ bool CSettings::SetSetting(char *name, char *value)
if (sscanf(value, "%d", &i) == 1) gridRows = i;
return true;
}
else if (strcmp(name, "qboot") == 0)
else if (strcmp(name, "quickboot") == 0)
{
if (sscanf(value, "%d", &i) == 1) qboot = i;
if (sscanf(value, "%d", &i) == 1) quickboot = i;
return true;
}
else if (strcmp(name, "partition") == 0)

View File

@ -8,6 +8,7 @@
#include "prompts/PromptWindows.h"
#include "prompts/DiscBrowser.h"
#include "settings/SettingsPrompts.h"
#include "settings/CGameSettings.h"
#include "prompts/filebrowser.h"
#include "cheats/cheatmenu.h"
#include "themes/CTheme.h"
@ -2275,7 +2276,7 @@ int MenuSettings()
/********************************************************************************
*Game specific settings
*********************************************************************************/
int GameSettings(struct discHdr * header)
int MenuGameSettings(struct discHdr * header)
{
int menu = MENU_NONE;
int ret;
@ -2433,8 +2434,32 @@ int GameSettings(struct discHdr * header)
optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
GuiWindow w(screenwidth, screenheight);
//int opt_lang = languageChoice; // backup language setting
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
GameCFG game_cfg;
GameCFG* existCFG = GameSettings.GetGameCFG(header->id);
if (existCFG)
{
memcpy(&game_cfg, existCFG, sizeof(GameCFG));
}
else
{
snprintf(game_cfg.id, sizeof(game_cfg.id), "%s", (char *) header->id);
game_cfg.video = Settings.videomode;
game_cfg.language = Settings.language;
game_cfg.ocarina = Settings.ocarina;
game_cfg.vipatch = Settings.videopatch;
game_cfg.ios = Settings.cios;
game_cfg.parentalcontrol = 0;
game_cfg.errorfix002 = Settings.error002;
game_cfg.patchcountrystrings = Settings.patchcountrystrings;
game_cfg.loadalternatedol = off;
game_cfg.alternatedolstart = 0;
game_cfg.iosreloadblock = off;
strcpy(game_cfg.alternatedolname, "");
game_cfg.returnTo = 1;
}
int pageToDisplay = 1;
while (pageToDisplay > 0)
@ -2495,39 +2520,6 @@ int GameSettings(struct discHdr * header)
mainWindow->Append(&w);
if (game_cfg) //if there are saved settings for this game use them
{
videoChoice = game_cfg->video;
languageChoice = game_cfg->language;
ocarinaChoice = game_cfg->ocarina;
viChoice = game_cfg->vipatch;
iosChoice = game_cfg->ios;
parentalcontrolChoice = game_cfg->parentalcontrol;
fix002 = game_cfg->errorfix002;
countrystrings = game_cfg->patchcountrystrings;
alternatedol = game_cfg->loadalternatedol;
alternatedoloffset = game_cfg->alternatedolstart;
reloadblock = game_cfg->iosreloadblock;
strlcpy(alternatedname, game_cfg->alternatedolname, sizeof(alternatedname));
returnToLoaderGV = game_cfg->returnTo;
}
else
{
videoChoice = Settings.videomode;
languageChoice = Settings.language;
ocarinaChoice = Settings.ocarina;
viChoice = Settings.videopatch;
iosChoice = Settings.cios;
parentalcontrolChoice = 0;
fix002 = Settings.error002;
countrystrings = Settings.patchcountrystrings;
alternatedol = off;
alternatedoloffset = 0;
reloadblock = off;
strcpy(alternatedname, "");
returnToLoaderGV = 1;
}
ResumeGui();
while (MainButton1.GetEffect() > 0)
@ -2610,25 +2602,12 @@ int GameSettings(struct discHdr * header)
else if (saveBtn.GetState() == STATE_CLICKED)
{
if (isInserted(bootDevice))
if (GameSettings.AddGame(&game_cfg))
{
if (CFG_save_game_opt(header->id))
{
/* commented because the database language now depends on the main language setting, this could be enabled again if there is a separate language setting for the database
// if game language has changed when saving game settings, reload titles
int opt_langnew = 0;
game_cfg = CFG_get_game_opt(header->id);
if (game_cfg) opt_langnew = game_cfg->language;
if (Settings.titlesOverride==1 && opt_lang != opt_langnew)
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, true, false); // open file, reload titles, do not keep in memory
// titles are refreshed in menu.cpp as soon as this function returns
*/
game_cfg = CFG_get_game_opt(header->id); // needed here for "if (game_cfg)" earlier in case it's the first time settings are saved for a game
WindowPrompt(tr( "Successfully Saved" ), 0, tr( "OK" ));
}
else WindowPrompt(tr( "Save Failed" ), 0, tr( "OK" ));
}
else WindowPrompt(tr( "No SD-Card inserted!" ), tr( "Insert an SD-Card to save." ), tr( "OK" ));
else
WindowPrompt(tr( "Save Failed. No device inserted?" ), 0, tr( "OK" ));
saveBtn.ResetState();
optionBrowser2.SetFocus(1);
@ -2643,31 +2622,31 @@ int GameSettings(struct discHdr * header)
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Video Mode" ));
if (ret == Idx && ++videoChoice >= settings_video_max) videoChoice = 0;
options2.SetValue(Idx, "%s%s", opts_videomode[videoChoice][0],
tr( opts_videomode[videoChoice][1] ));
if (ret == Idx && ++game_cfg.video >= settings_video_max) game_cfg.video = 0;
options2.SetValue(Idx, "%s%s", opts_videomode[game_cfg.video][0],
tr( opts_videomode[game_cfg.video][1] ));
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "VIDTV Patch" ));
if (ret == Idx && ++viChoice >= settings_off_on_max) viChoice = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[viChoice] ));
if (ret == Idx && ++game_cfg.vipatch >= settings_off_on_max) game_cfg.vipatch = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[game_cfg.vipatch] ));
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Game Language" ));
if (ret == Idx && ++languageChoice >= settings_language_max) languageChoice = 0;
options2.SetValue(Idx, "%s", tr( opts_language[languageChoice] ));
if (ret == Idx && ++game_cfg.language >= settings_language_max) game_cfg.language = 0;
options2.SetValue(Idx, "%s", tr( opts_language[game_cfg.language] ));
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "Ocarina");
if (ret == Idx && ++ocarinaChoice >= settings_off_on_max) ocarinaChoice = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[ocarinaChoice] ));
if (ret == Idx && ++game_cfg.ocarina >= settings_off_on_max) game_cfg.ocarina = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[game_cfg.ocarina] ));
}
if (ret == ++Idx || firstRun)
@ -2675,54 +2654,54 @@ int GameSettings(struct discHdr * header)
if (firstRun) options2.SetName(Idx, "IOS");
if (ret == Idx)
{
switch (iosChoice)
switch (game_cfg.ios)
{
case 222:
iosChoice = 223;
game_cfg.ios = 223;
break;
case 223:
iosChoice = 224;
game_cfg.ios = 224;
break;
case 224:
iosChoice = 249;
game_cfg.ios = 249;
break;
case 249:
iosChoice = 250;
game_cfg.ios = 250;
break;
case 250:
iosChoice = 222;
game_cfg.ios = 222;
break;
default:
iosChoice = 222;
game_cfg.ios = 222;
break;
}
}
options2.SetValue(Idx, "IOS %i", iosChoice);
options2.SetValue(Idx, "IOS %i", game_cfg.ios);
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Parental Control" ));
if (ret == Idx && ++parentalcontrolChoice >= 5) parentalcontrolChoice = 0;
options2.SetValue(Idx, "%s", tr( opts_parentalcontrol[parentalcontrolChoice] ));
if (ret == Idx && ++game_cfg.parentalcontrol >= 5) game_cfg.parentalcontrol = 0;
options2.SetValue(Idx, "%s", tr( opts_parentalcontrol[game_cfg.parentalcontrol] ));
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Error 002 fix" ));
if (ret == Idx && ++fix002 >= 3) fix002 = 0;
options2.SetValue(Idx, "%s", tr( opts_error002[fix002] ));
if (ret == Idx && ++game_cfg.errorfix002 >= 3) game_cfg.errorfix002 = 0;
options2.SetValue(Idx, "%s", tr( opts_error002[game_cfg.errorfix002] ));
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Return To" ));
if (ret == Idx && ++returnToLoaderGV >= settings_off_on_max) returnToLoaderGV = 0;
if (ret == Idx && ++game_cfg.returnTo >= settings_off_on_max) game_cfg.returnTo = 0;
char text[IMET_MAX_NAME_LEN];
int channel = NandTitles.FindU32(Settings.returnTo);//is the channel set in the global settings actually installed?
if (!returnToLoaderGV || channel < 0)//channel is not installed or the uer wants to not use it
if (!game_cfg.returnTo || channel < 0)//channel is not installed or the uer wants to not use it
sprintf(text, "%s", tr( opts_off_on[ 0 ] ));
else snprintf(text, sizeof(text), "%s", NandTitles.NameFromIndex(channel));
@ -2733,19 +2712,19 @@ int GameSettings(struct discHdr * header)
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Patch Country Strings" ));
if (ret == Idx && ++countrystrings >= settings_off_on_max) countrystrings = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[countrystrings] ));
if (ret == Idx && ++game_cfg.patchcountrystrings >= settings_off_on_max) game_cfg.patchcountrystrings = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[game_cfg.patchcountrystrings] ));
}
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Alternate DOL" ));
int last_alternatedol = alternatedol;
if (ret == Idx && (alternatedol = (alternatedol + 2) % 3) >= 3) // 0->2->1->0
alternatedol = 0;
int last_alternatedol = game_cfg.loadalternatedol;
if (ret == Idx && (game_cfg.loadalternatedol = (game_cfg.loadalternatedol + 2) % 3) >= 3) // 0->2->1->0
game_cfg.loadalternatedol = 0;
static const char *opts[] = { trNOOP( "Default" ), trNOOP( "Load From SD/USB" ),
trNOOP( "Select a DOL" ) };
options2.SetValue(Idx, "%s", tr( opts[alternatedol] ));
options2.SetValue(Idx, "%s", tr( opts[game_cfg.loadalternatedol] ));
if (last_alternatedol != 1)
{
firstRun = true; // force re-init follow Entries
@ -2753,28 +2732,27 @@ int GameSettings(struct discHdr * header)
}
}
if (alternatedol == 2 && (ret == ++Idx || firstRun))
if (game_cfg.loadalternatedol == 2 && (ret == ++Idx || firstRun))
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Selected DOL" ));
if (ret == Idx)
{
if (alternatedol == 2)
if (game_cfg.loadalternatedol == 2)
{
char filename[10];
snprintf(filename, sizeof(filename), "%c%c%c%c%c%c", header->id[0], header->id[1],
header->id[2], header->id[3], header->id[4], header->id[5]);
snprintf(filename, 7, "%s", (char *) header->id);
int dolchoice = 0;
//alt dol menu for games that require more than a single alt dol
int autodol = autoSelectDolMenu(filename, false);
if (autodol > 0)
{
alternatedoloffset = autodol;
game_cfg.alternatedolstart = autodol;
snprintf(alternatedname, sizeof(alternatedname), "%s <%i>", tr( "AUTO" ),
autodol);
}
else if (autodol == 0)
alternatedol = 0; // default was chosen
game_cfg.loadalternatedol = 0; // default was chosen
else
{
//check to see if we already know the offset of the correct dol
@ -2788,10 +2766,10 @@ int GameSettings(struct discHdr * header)
tr( "Do you want to use the alternate DOL that is known to be correct?" ),
tr( "Yes" ), tr( "Pick from a list" ), tr( "Cancel" ));
if (dolchoice == 0)
alternatedol = 0;
game_cfg.loadalternatedol = 0;
else if (dolchoice == 1)
{
alternatedoloffset = autodol;
game_cfg.alternatedolstart = autodol;
snprintf(alternatedname, sizeof(alternatedname), "%s <%i>",
tr( "AUTO" ), autodol);
}
@ -2799,7 +2777,7 @@ int GameSettings(struct discHdr * header)
{
int res = DiscBrowse(header);
if ((res >= 0) && (res != 696969)) //if res==696969 they pressed the back button
alternatedoloffset = res;
game_cfg.alternatedolstart = res;
}
}
else
@ -2807,21 +2785,21 @@ int GameSettings(struct discHdr * header)
int res = DiscBrowse(header);
if ((res >= 0) && (res != 696969))
{
alternatedoloffset = res;
game_cfg.alternatedolstart = res;
char tmp[170];
snprintf(
tmp,
sizeof(tmp),
"%s %s - %i",
tr( "It seems that you have some information that will be helpful to us. Please pass this information along to the DEV team." ),
filename, alternatedoloffset);
filename, game_cfg.alternatedolstart);
WindowPrompt(0, tmp, tr( "OK" ));
}
}
}
}
}
if (alternatedol == 0)
if (game_cfg.loadalternatedol == 0)
{
firstRun = true; // force re-init follow Entries
options2.SetLength(Idx--); // remove this Entry
@ -2833,8 +2811,8 @@ int GameSettings(struct discHdr * header)
if (ret == ++Idx || firstRun)
{
if (firstRun) options2.SetName(Idx, "%s", tr( "Block IOS Reload" ));
if (ret == Idx && ++reloadblock >= settings_off_on_max) reloadblock = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[reloadblock] ));
if (ret == Idx && ++game_cfg.iosreloadblock >= settings_off_on_max) game_cfg.iosreloadblock = 0;
options2.SetValue(Idx, "%s", tr( opts_off_on[game_cfg.iosreloadblock] ));
}
firstRun = false;
@ -2926,7 +2904,7 @@ int GameSettings(struct discHdr * header)
tr( "Yes" ), tr( "Cancel" ));
if (choice1 == 1 && !mountMethod)
{
CFG_forget_game_opt(header->id);
GameSettings.Remove(header->id);
CFG_forget_game_num(header->id);
ret = WBFS_RemoveGame(header->id);
if (ret < 0)
@ -3057,20 +3035,20 @@ int GameSettings(struct discHdr * header)
int choice1 = WindowPrompt(tr( "Are you sure?" ), 0, tr( "Yes" ), tr( "Cancel" ));
if (choice1 == 1)
{
videoChoice = Settings.videomode;
viChoice = Settings.videopatch;
languageChoice = Settings.language;
ocarinaChoice = Settings.ocarina;
fix002 = Settings.error002;
countrystrings = Settings.patchcountrystrings;
alternatedol = off;
alternatedoloffset = 0;
reloadblock = off;
iosChoice = Settings.cios;
parentalcontrolChoice = 0;
strcpy(alternatedname, "");
returnToLoaderGV = 1;
CFG_forget_game_opt(header->id);
game_cfg.video = Settings.videomode;
game_cfg.vipatch = Settings.videopatch;
game_cfg.language = Settings.language;
game_cfg.ocarina = Settings.ocarina;
game_cfg.errorfix002 = Settings.error002;
game_cfg.patchcountrystrings = Settings.patchcountrystrings;
game_cfg.loadalternatedol = off;
game_cfg.alternatedolstart = 0;
game_cfg.iosreloadblock = off;
game_cfg.ios = Settings.cios;
game_cfg.parentalcontrol = 0;
strcpy(game_cfg.alternatedolname, "");
game_cfg.returnTo = 1;
GameSettings.Remove(header->id);
}
pageToDisplay = 1;

View File

@ -9,5 +9,6 @@
#define _SETTINGS_H_
int MenuSettings();
int GameSettings(struct discHdr * header);
int MenuGameSettings(struct discHdr * header);
#endif

View File

@ -55,102 +55,10 @@ struct ID_Title *cfg_title = NULL;
int num_control = 0;
struct ID_Control *cfg_control = NULL;
#define MAX_SAVED_GAMES 1000
#define MAX_SAVED_GAME_NUM 1000
int num_saved_games = 0;
int num_saved_game_num = 0;
struct Game_CFG cfg_game[MAX_SAVED_GAMES];
struct Game_NUM cfg_game_num[MAX_SAVED_GAME_NUM];
/* For Mapping */
static char *cfg_name, *cfg_val;
struct TextMap
{
char *name;
int id;
};
struct TextMap map_video[] = { { "system", CFG_VIDEO_SYS }, { "game", CFG_VIDEO_GAME }, { "patch", CFG_VIDEO_PATCH }, {
"pal50", CFG_VIDEO_PAL50 }, { "pal60", CFG_VIDEO_PAL60 }, { "ntsc", CFG_VIDEO_NTSC }, { NULL, -1 } };
struct TextMap map_language[] = { { "console", CFG_LANG_CONSOLE }, { "japanese", CFG_LANG_JAPANESE }, { "english",
CFG_LANG_ENGLISH }, { "german", CFG_LANG_GERMAN }, { "french", CFG_LANG_FRENCH },
{ "spanish", CFG_LANG_SPANISH }, { "italian", CFG_LANG_ITALIAN }, { "dutch", CFG_LANG_DUTCH }, { "schinese",
CFG_LANG_S_CHINESE }, // without a dot between s and chinese to match the language filename "schinese.lang"
{ "tchinese", CFG_LANG_T_CHINESE }, { "korean", CFG_LANG_KOREAN }, { NULL, -1 } };
int map_get_id(struct TextMap *map, char *name)
{
int i;
for (i = 0; map[i].name != NULL; i++)
{
if (strcmp(name, map[i].name) == 0) return map[i].id;
}
return -1;
}
char* map_get_name(struct TextMap *map, short id)
{
int i;
for (i = 0; map[i].name != NULL; i++)
{
if (id == map[i].id) return map[i].name;
}
return NULL;
}
bool map_auto(char *name, char *name2, char *val, struct TextMap *map, short *var)
{
if (strcmp(name, name2) != 0) return false;
int id = map_get_id(map, val);
if (id == -1)
{
//printf("MAP FAIL: %s=%s : %d\n", name, val, id); sleep(1);
return false;
}
*var = id;
//printf("MAP AUTO: %s=%s : %d\n", name, val, id); sleep(1);
return true;
}
bool cfg_map_auto(char *name, struct TextMap *map, short *var)
{
return map_auto(name, cfg_name, cfg_val, map, var);
}
bool cfg_map(char *name, char *val, short *var, short id)
{
if (strcmp(name, cfg_name) == 0 && strcmpi(val, cfg_val) == 0)
{
*var = id;
return true;
}
return false;
}
bool cfg_bool(char *name, short *var)
{
return (cfg_map(name, "0", var, 0) || cfg_map(name, "1", var, 1));
}
void cfg_int(char *name, short *var, int count)
{
char tmp[6];
short i;
if (count > 10) //avoid overflow
return;
for (i = 0; i < count; i++)
{
sprintf(tmp, "%d", i);
cfg_map(name, tmp, var, i);
}
}
char *cfg_get_title(u8 *id)
{
if (!id) return NULL;
@ -387,64 +295,6 @@ bool cfg_parsetitlefile(char *fname, void(*set_func)(char*, char*, u8))
return true;
}
/*
void cfg_parsearg(int argc, char **argv)
{
int i;
char *eq;
char pathname[200];
for (i=1; i<argc; i++) {
//printf("arg[%d]: %s\n", i, argv[i]);
eq = strchr(argv[i], '=');
if (eq) {
cfg_parseline(argv[i], &cfg_set);
} else {
snprintf(pathname, sizeof(pathname), "%s%s", cfg_path, argv[i]);
cfg_parsefile(pathname, &cfg_set);
}
}
}
*/
// PER-GAME SETTINGS
// return existing or new
struct Game_CFG* cfg_get_game(u8 *id)
{
struct Game_CFG *game = CFG_get_game_opt(id);
if (game) return game;
if (num_saved_games >= MAX_SAVED_GAMES) return NULL;
game = &cfg_game[num_saved_games];
num_saved_games++;
return game;
}
// current options to game
void cfg_set_game_opt(struct Game_CFG *game, u8 *id)
{
strncpy((char*) game->id, (char*) id, 6);
game->id[6] = 0;
game->video = videoChoice;
game->language = languageChoice;
game->ocarina = ocarinaChoice;
game->vipatch = viChoice;
game->ios = iosChoice;
game->parentalcontrol = parentalcontrolChoice;
game->errorfix002 = fix002;
game->iosreloadblock = reloadblock;
game->patchcountrystrings = countrystrings;
game->loadalternatedol = alternatedol;
if (game->loadalternatedol == 0)
{
alternatedoloffset = 0;
strcpy(alternatedname, "");
}
game->alternatedolstart = alternatedoloffset;
strlcpy(game->alternatedolname, alternatedname, sizeof(game->alternatedolname));
game->returnTo = returnToLoaderGV;
}
struct Game_NUM* cfg_get_game_num(u8 *id)
{
struct Game_NUM *game = CFG_get_game_num(id);
@ -464,187 +314,6 @@ void cfg_set_game_num(struct Game_NUM *game, u8 *id)
game->count = playcount;
}
void game_set(char *name, char *val)
{
// sample line:
// game:RTNP41 = video:game; language:english; ocarina:0;
// game:RYWP01 = video:patch; language:console; ocarina:1;
//printf("GAME: '%s=%s'\n", name, val);
u8 id[8];
struct Game_CFG *game;
if (strncmp(name, "game:", 5) != 0) return;
trimcopy((char*) id, name + 5, sizeof(id));
game = cfg_get_game(id);
// set id and current options as default
cfg_set_game_opt(game, id);
//printf("GAME(%s) '%s'\n", id, val); sleep(1);
// parse val
// first split options by ;
char opt[300], *p, *np;
p = val;
while (p)
{
np = strchr(p, ';');
if (np)
trim_n_copy(opt, p, np - p, sizeof(opt));
else trimcopy(opt, p, sizeof(opt));
//printf("GAME(%s) (%s)\n", id, opt); sleep(1);
// parse opt 'language:english'
char opt_name[200], opt_val[200];
if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name)))
{
//printf("GAME(%s) (%s=%s)\n", id, opt_name, opt_val); sleep(1);
short opt_v, opt_l, opt_c;
if (map_auto("video", opt_name, opt_val, map_video, &opt_v))
{
// valid option, assign
game->video = opt_v;
}
if (map_auto("language", opt_name, opt_val, map_language, &opt_l))
{
// valid option, assign
game->language = opt_l;
}
if (strcmp("ocarina", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->ocarina = opt_c;
}
}
if (strcmp("vipatch", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->vipatch = opt_c;
}
}
if (strcmp("ios", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->ios = opt_c;
}
}
if (strcmp("pctrl", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->parentalcontrol = opt_c;
}
}
if (strcmp("errorfix002", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->errorfix002 = opt_c;
}
}
if (strcmp("iosreloadblock", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->iosreloadblock = opt_c;
}
}
if (strcmp("patchcountrystrings", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->patchcountrystrings = opt_c;
}
}
if (strcmp("loadalternatedol", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->loadalternatedol = opt_c;
}
}
if (strcmp("alternatedolstart", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->alternatedolstart = opt_c;
}
}
if (strcmp("alternatedolname", opt_name) == 0)
{
strlcpy(game->alternatedolname, opt_val, sizeof(game->alternatedolname));
}
if (strcmp("returnTo", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
game->returnTo = opt_c;
}
}
}
// next opt
if (np)
p = np + 1;
else p = NULL;
}
}
void parental_set(char *name, char *val)
{
// sample line:
// game:RTNP41 = video:game; language:english; ocarina:0;
// game:RYWP01 = video:patch; language:console; ocarina:1;
//printf("GAME: '%s=%s'\n", name, val);
u8 id[8];
if (strncmp(name, "game:", 5) != 0) return;
trimcopy((char*) id, name + 5, sizeof(id));
// parse val
// first split options by ;
char opt[200], *p, *np;
p = val;
while (p)
{
np = strchr(p, ';');
if (np)
trim_n_copy(opt, p, np - p, sizeof(opt));
else trimcopy(opt, p, sizeof(opt));
//printf("GAME(%s) (%s)\n", id, opt); sleep(1);
// parse opt 'language:english'
char opt_name[200], opt_val[200];
if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name)))
{
//printf("GAME(%s) (%s=%s)\n", id, opt_name, opt_val); sleep(1);
short opt_c;
if (strcmp("pctrl", opt_name) == 0)
{
if (sscanf(opt_val, "%hd", &opt_c) == 1)
{
cfg_control = realloc(cfg_control, (num_control + 1) * sizeof(struct ID_Control));
if (!cfg_control)
{
// error
num_control = 0;
return;
}
// add
strcpy(cfg_control[num_control].id, (char*) id);
cfg_control[num_control].block = opt_c;
num_control++;
}
}
}
// next opt
if (np)
p = np + 1;
else p = NULL;
}
}
void game_set_num(char *name, char *val)
{
u8 id[8];
@ -694,13 +363,6 @@ void game_set_num(char *name, char *val)
}
}
bool cfg_load_games()
{
char GXGameSettings_cfg[32];
sprintf(GXGameSettings_cfg, "%s/config/GXGameSettings.cfg", bootDevice);
return cfg_parsefile(GXGameSettings_cfg, &game_set);
}
bool cfg_load_game_num()
{
char GXGameFavorites_cfg[32];
@ -708,55 +370,6 @@ bool cfg_load_game_num()
return cfg_parsefile(GXGameFavorites_cfg, &game_set_num);
}
bool cfg_save_games()
{
FILE *f;
int i;
char GXGameSettings_cfg[50];
sprintf(GXGameSettings_cfg, "%s/config", bootDevice);
mkdir(GXGameSettings_cfg, 0777);
sprintf(GXGameSettings_cfg, "%s/config/GXGameSettings.cfg", bootDevice);
f = fopen(GXGameSettings_cfg, "w");
if (!f)
{
printf("Error saving %s\n", "GXGameSettings.cfg");
sleep(1);
return false;
}
fprintf(f, "# USB Loader settings file\n");
fprintf(f, "# note: this file is automatically generated\n");
fclose(f);
/* Closing and reopening because of a write issue we are having right now */
f = fopen(GXGameSettings_cfg, "w");
fprintf(f, "# USB Loader settings file\n");
fprintf(f, "# note: this file is automatically generated\n");
fprintf(f, "# Num Games: %d\n", num_saved_games);
for (i = 0; i < num_saved_games; i++)
{
char *s;
fprintf(f, "game:%s = ", cfg_game[i].id);
s = map_get_name(map_video, cfg_game[i].video);
if (s) fprintf(f, "video:%s; ", s);
s = map_get_name(map_language, cfg_game[i].language);
if (s) fprintf(f, "language:%s; ", s);
fprintf(f, "ocarina:%d; ", cfg_game[i].ocarina);
fprintf(f, "vipatch:%d; ", cfg_game[i].vipatch);
fprintf(f, "ios:%d; ", cfg_game[i].ios);
fprintf(f, "pctrl:%d; ", cfg_game[i].parentalcontrol);
fprintf(f, "errorfix002:%d; ", cfg_game[i].errorfix002);
fprintf(f, "iosreloadblock:%d; ", cfg_game[i].iosreloadblock);
fprintf(f, "patchcountrystrings:%d; ", cfg_game[i].patchcountrystrings);
fprintf(f, "loadalternatedol:%d;", cfg_game[i].loadalternatedol);
fprintf(f, "alternatedolstart:%d;", cfg_game[i].alternatedolstart);
fprintf(f, "alternatedolname:%s;\n", cfg_game[i].alternatedolname);
fprintf(f, "returnTo:%d;\n", cfg_game[i].returnTo);
}
fprintf(f, "# END\n");
fclose(f);
return true;
}
bool cfg_save_game_num()
{
FILE *f;
@ -827,19 +440,6 @@ bool CFG_reset_all_playcounters()
return true;
}
struct Game_CFG* CFG_get_game_opt(const u8 *id)
{
int i;
for (i = 0; i < num_saved_games; i++)
{
if (memcmp(id, cfg_game[i].id, 6) == 0)
{
return &cfg_game[i];
}
}
return NULL;
}
struct Game_NUM* CFG_get_game_num(const u8 *id)
{
int i;
@ -853,14 +453,6 @@ struct Game_NUM* CFG_get_game_num(const u8 *id)
return NULL;
}
bool CFG_save_game_opt(u8 *id)
{
struct Game_CFG *game = cfg_get_game(id);
if (!game) return false;
cfg_set_game_opt(game, id);
return cfg_save_games();
}
bool CFG_save_game_num(u8 *id)
{
struct Game_NUM *game = cfg_get_game_num(id);
@ -869,21 +461,6 @@ bool CFG_save_game_num(u8 *id)
return cfg_save_game_num();
}
bool CFG_forget_game_opt(u8 *id)
{
struct Game_CFG *game = CFG_get_game_opt(id);
int i;
if (!game) return true;
// move entries down
num_saved_games--;
for (i = game - cfg_game; i < num_saved_games; i++)
{
cfg_game[i] = cfg_game[i + 1];
}
memset(&cfg_game[num_saved_games], 0, sizeof(struct Game_CFG));
return cfg_save_games();
}
bool CFG_forget_game_num(u8 *id)
{
struct Game_NUM *game = CFG_get_game_num(id);
@ -893,21 +470,14 @@ bool CFG_forget_game_num(u8 *id)
num_saved_game_num--;
for (i = game - cfg_game_num; i < num_saved_game_num; i++)
{
cfg_game[i] = cfg_game[i + 1];
cfg_game_num[i] = cfg_game_num[i + 1];
}
memset(&cfg_game[num_saved_game_num], 0, sizeof(struct Game_NUM));
memset(&cfg_game_num[num_saved_game_num], 0, sizeof(struct Game_NUM));
return cfg_save_game_num();
}
void CFG_LoadGameNum()
{
char pathname[200];
snprintf(pathname, sizeof(pathname), "%s/config/GXGameSettings.cfg", bootDevice);
cfg_parsefile(pathname, &parental_set);
// load per-game settings
cfg_load_games();
cfg_load_game_num();
}

View File

@ -37,29 +37,30 @@ extern "C"
extern char bootDevice[10];
extern u8 ocarinaChoice;
extern u16 playcnt;
extern u8 videoChoice;
extern u8 languageChoice;
extern u8 viChoice;
extern u8 iosChoice;
extern u8 parentalcontrolChoice;
extern u8 fix002;
extern u8 reloadblock;
extern u8 countrystrings;
extern u8 alternatedol;
extern u32 alternatedoloffset;
extern u8 xflip;
extern u8 qboot;
extern u8 sort;
extern u8 fave;
extern u8 wsprompt;
extern u8 keyset;
extern u8 gameDisplay;
// extern u8 ocarinaChoice;
// extern u16 playcnt;
//
// extern u8 videoChoice;
// extern u8 languageChoice;
// extern u8 viChoice;
// extern u8 iosChoice;
// extern u8 parentalcontrolChoice;
// extern u8 fix002;
// extern u8 reloadblock;
// extern u8 countrystrings;
// extern u8 alternatedol;
// extern u32 alternatedoloffset;
// extern u8 xflip;
// extern u8 qboot;
// extern u8 sort;
// extern u8 fave;
// extern u8 wsprompt;
// extern u8 keyset;
// extern u8 gameDisplay;
extern u16 playcount;
extern u8 favoritevar;
extern char alternatedname[40];
extern u8 returnToLoaderGV;
// extern u8 returnToLoaderGV;
enum
{
@ -67,23 +68,6 @@ extern "C"
// always the last entry
};
struct Game_CFG
{
u8 id[8];
u8 video;
u8 language;
u8 ocarina;
u8 vipatch;
u8 ios;
u8 parentalcontrol;
u8 errorfix002;
u8 iosreloadblock;
u8 loadalternatedol;
u32 alternatedolstart;
u8 patchcountrystrings;
char alternatedolname[40];
u8 returnTo;
};
struct Game_NUM
{
u8 id[8];
@ -92,12 +76,9 @@ extern "C"
};
void CFG_LoadGameNum(); // -1 = non forced mode
struct Game_CFG* CFG_get_game_opt(const u8 *id);
struct Game_NUM* CFG_get_game_num(const u8 *id);
bool CFG_save_game_opt(u8 *id);
bool CFG_save_game_num(u8 *id);
bool CFG_reset_all_playcounters();
bool CFG_forget_game_opt(u8 *id);
bool CFG_forget_game_num(u8 *id);
enum

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 load_dol_image(void *dolstart, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat, u8 fix002)
{
u32 i;
@ -121,7 +121,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,
vipatch, cheat);
vipatch, cheat, fix002);
Remove_001_Protection((void *) dolfile->data_start[i], dolfile->data_size[i]);
}
@ -131,7 +131,7 @@ u32 load_dol_image(void *dolstart, u8 videoSelected, u8 patchcountrystring, u8 v
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,
vipatch, cheat);
vipatch, cheat, 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 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat, 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);
gamepatches(offset, len, videoSelected, patchcountrystring, vipatch, cheat, fix002);
Remove_001_Protection(offset, len);

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)
void gamepatches(u8 * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat, u8 fix002)
{
VideoModePatcher(dst, len, videoSelected);
@ -55,7 +55,7 @@ void gamepatches(u8 * dst, int len, u8 videoSelected, u8 patchcountrystring, u8
}
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 error002fix, u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002)
{
app_entry appldr_entry;
app_init appldr_init;
@ -111,7 +111,7 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected
/* Read data from DVD */
WDVD_Read(dst, len, (u64) (offset << 2));
gamepatches(dst, len, videoSelected, patchcountrystring, vipatch, cheat);
gamepatches(dst, len, videoSelected, patchcountrystring, vipatch, cheat, fix002);
DCFlushRange(dst, len);
if ((u32) dst < dolStart) dolStart = (u32) dst;

View File

@ -11,8 +11,8 @@ extern "C"
/* 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);
void gamepatches(u8 * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch, u8 cheat);
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, u8 fix002);
#ifdef __cplusplus
}

View File

@ -287,7 +287,7 @@ s32 Disc_IsWii(void)
}
s32 Disc_BootPartition(u64 offset, char * dolpath, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring,
u8 error002fix, u8 alternatedol, u32 alternatedoloffset, u32 returnTo)
u8 error002fix, u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002)
{
gprintf("booting partition IOS %u v%u\n", IOS_GetVersion(), IOS_GetRevision());
entry_point p_entry;
@ -312,7 +312,7 @@ s32 Disc_BootPartition(u64 offset, char * dolpath, u8 videoselected, u8 cheat, u
/* Run apploader */
ret = Apploader_Run(&p_entry, dolpath, cheat, videoselected, vipatch, patchcountrystring, error002fix,
alternatedol, alternatedoloffset, returnTo);
alternatedol, alternatedoloffset, returnTo, fix002);
if (ret < 0) return ret;
free_wip();
@ -387,7 +387,7 @@ s32 Disc_BootPartition(u64 offset, char * dolpath, u8 videoselected, u8 cheat, u
}
s32 Disc_WiiBoot(char * dolpath, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 error002fix,
u8 alternatedol, u32 alternatedoloffset, u32 returnTo)
u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002)
{
u64 offset;
s32 ret;
@ -398,7 +398,7 @@ s32 Disc_WiiBoot(char * dolpath, u8 videoselected, u8 cheat, u8 vipatch, u8 patc
/* Boot partition */
return Disc_BootPartition(offset, dolpath, videoselected, cheat, vipatch, patchcountrystring, error002fix,
alternatedol, alternatedoloffset, returnTo);
alternatedol, alternatedoloffset, returnTo, fix002);
}
void PatchCountryStrings(void *Address, int Size)

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);
s32 Disc_WiiBoot(char *, u8, u8, u8, u8, u8, u8, u32, u32 returnTo);
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_FindPartition(u64 *outbuf);
void PatchCountryStrings(void *Address, int Size);
s32 __Disc_FindPartition(u64 *outbuf);

View File

@ -7,6 +7,7 @@
#include <malloc.h>
#include <unzip/unzip.h>
#include "settings/CSettings.h"
#include "settings/CGameSettings.h"
#include "xml/xml.h"
extern "C"
@ -189,8 +190,7 @@ bool OpenXMLFile(char *filename)
char *GetLangSettingFromGame(char *gameid)
{
int langcode;
struct Game_CFG *game_cfg = NULL;
game_cfg = CFG_get_game_opt((u8*) gameid);
GameCFG *game_cfg = GameSettings.GetGameCFG((u8*) gameid);
if (game_cfg)
{
langcode = game_cfg->language;