-added Nintendont GC Loader support, so far you can use NMM, widescreen and progressive patch as settings, just make sure Nintendont is in apps/Nintendont/boot.dol, partition doesnt matter for that dol, just make sure you just try to start games from SD

-added yet another security check to prevent crashes
-added a new SOURCEFLOW option, remember_last_item (enabled by default), if disabled and you use another sourceflow, wiiflow will not jump back to the previously selected flow but to the first one again
This commit is contained in:
fix94.1 2013-09-24 21:24:03 +00:00
parent a780efc0cd
commit 1480483963
7 changed files with 194 additions and 43 deletions

View File

@ -1095,13 +1095,15 @@ u8 *Nand::GetEmuFile(const char *path, u32 *size, s32 len)
if(len > 0)
filesize = min(filesize, (u32)len);
u8 *tmp_buf = (u8*)MEM2_alloc(filesize);
if(tmp_buf != NULL)
{
FILE *f = fopen(tmp_path, "rb");
fread(tmp_buf, filesize, 1, f);
fclose(f);
MEM2_free(tmp_path);
DCFlushRange(tmp_buf, filesize);
*size = filesize;
fclose(f);
}
MEM2_free(tmp_path);
return tmp_buf;
}

View File

@ -148,6 +148,61 @@ void DML_New_WriteOptions()
}
// Nintendont
NIN_CFG NinCfg;
void Nintendont_SetOptions(const char *game, u8 NMM, u8 videoSetting, bool widescreen)
{
memset(&NinCfg, 0, sizeof(NIN_CFG));
NinCfg.Magicbytes = 0x01070CF6;
NinCfg.Version = 0x00000001;
NinCfg.Config |= NIN_CFG_AUTO_BOOT;
NinCfg.Config |= NIN_CFG_GAME_PATH; /* temporary */
if(videoSetting == 0)
NinCfg.VideoMode |= NIN_VID_NONE;
else if(videoSetting == 1)
NinCfg.VideoMode |= NIN_VID_AUTO;
else
NinCfg.VideoMode |= NIN_VID_FORCE;
if(widescreen)
NinCfg.Config |= NIN_CFG_FORCE_WIDE;
if(NMM > 0)
NinCfg.Config |= NIN_CFG_MEMCARDEMU;
strncpy(NinCfg.GamePath, strchr(game, '/') + 1, 254);
if(strstr(NinCfg.GamePath, "boot.bin") != NULL)
{
*strrchr(NinCfg.GamePath, '/') = '\0'; //boot.bin
*(strrchr(NinCfg.GamePath, '/')+1) = '\0'; //sys
}
gprintf("Nintendont Game Path: %s\n", NinCfg.GamePath);
}
void Nintendont_WriteOptions()
{
gprintf("Writing Nintendont CFG: %s\n", NIN_CFG_PATH);
fsop_WriteFile(NIN_CFG_PATH, &NinCfg, sizeof(NIN_CFG));
}
bool Nintendont_GetLoader()
{
bool ret = false;
for(u8 i = SD; i < MAXDEVICES; ++i)
{
const char *dol_path = fmt(NIN_LOADER_PATH, DeviceName[i]);
ret = (LoadHomebrew(dol_path) == 1);
if(ret == true)
{
gprintf("Nintendont loaded: %s\n", dol_path);
AddBootArgument(dol_path);
break;
}
}
return ret;
}
// Devolution
u8 *tmp_buffer = NULL;
u8 *loader_bin = NULL;
@ -317,7 +372,7 @@ u32 __SYS_UnlockSram(u32 write);
u32 __SYS_SyncSram(void);
}
void GC_SetVideoMode(u8 videomode, u8 videoSetting, bool DIOSMIOS)
void GC_SetVideoMode(u8 videomode, u8 videoSetting, u8 loader)
{
syssram *sram;
sram = __SYS_LockSram();
@ -343,33 +398,58 @@ void GC_SetVideoMode(u8 videomode, u8 videoSetting, bool DIOSMIOS)
if(videomode == 1)
{
if(DIOSMIOS && videoSetting == 2)
if(videoSetting == 2)
{
if(loader == 0)
DMLCfg.VideoMode |= DML_VID_FORCE_PAL50;
else if(loader == 2)
NinCfg.VideoMode |= NIN_VID_FORCE_PAL50;
}
vmode = &TVPal528IntDf;
}
else if(videomode == 2)
{
if(DIOSMIOS && videoSetting == 2)
if(videoSetting == 2)
{
if(loader == 0)
DMLCfg.VideoMode |= DML_VID_FORCE_NTSC;
else if(loader == 2)
NinCfg.VideoMode |= NIN_VID_FORCE_NTSC;
}
vmode = &TVNtsc480IntDf;
}
else if(videomode == 3)
{
if(DIOSMIOS && videoSetting == 2)
if(videoSetting == 2)
{
if(loader == 0)
DMLCfg.VideoMode |= DML_VID_FORCE_PAL60;
else if(loader == 2)
NinCfg.VideoMode |= NIN_VID_FORCE_PAL60;
}
vmode = &TVEurgb60Hz480IntDf;
vmode_reg = 5;
}
else if(videomode == 4 ||videomode == 6)
{
if(DIOSMIOS && videoSetting == 2)
if(videoSetting == 2)
{
if(loader == 0)
DMLCfg.VideoMode |= DML_VID_FORCE_PROG;
else if(loader == 2)
NinCfg.Config |= NIN_CFG_FORCE_PROG;
}
vmode = &TVNtsc480Prog;
}
else if(videomode == 5 || videomode == 7)
{
if(DIOSMIOS && videoSetting == 2)
if(videoSetting == 2)
{
if(loader == 0)
DMLCfg.VideoMode |= DML_VID_FORCE_PROG;
else if(loader == 2)
NinCfg.Config |= NIN_CFG_FORCE_PROG;
}
vmode = &TVNtsc480Prog;
vmode_reg = 5;
}

View File

@ -73,6 +73,15 @@ void DML_New_SetBootDiscOption(bool new_dm_cfg);
void DML_New_WriteOptions();
// Nintendont
#include "nin_cfg.h"
#define NIN_CFG_PATH "sd:/nincfg.bin"
#define NIN_LOADER_PATH "%s:/apps/Nintendont/boot.dol"
bool Nintendont_GetLoader();
void Nintendont_SetOptions(const char *game, u8 NMM, u8 videoSetting, bool widescreen);
void Nintendont_WriteOptions();
// Devolution
#define DEVO_LOADER_PATH "%s/loader.bin"
@ -102,8 +111,9 @@ void DEVO_SetOptions(const char *isopath, const char *gameID,
bool memcard_emum, bool widescreen, bool activity_led, bool wifi);
void DEVO_Boot();
// General
void GC_SetVideoMode(u8 videomode, u8 videoSetting, bool DIOSMIOS);
void GC_SetVideoMode(u8 videomode, u8 videoSetting, u8 loader);
void GC_SetLanguage(u8 lang);
#endif //_GC_HPP_

41
source/gc/nin_cfg.h Normal file
View File

@ -0,0 +1,41 @@
typedef struct NIN_CFG
{
u32 Magicbytes; // 0x01070CF6
u32 Version; // 0x00000001
u32 Config;
u32 VideoMode;
u32 Language; // NYI
char GamePath[255];
char CheatPath[255];
} NIN_CFG;
enum ninconfig
{
NIN_CFG_CHEATS = (1<<0), // NYI
NIN_CFG_DEBUGGER = (1<<1), // NYI
NIN_CFG_DEBUGWAIT = (1<<2), // NYI
NIN_CFG_MEMCARDEMU = (1<<3),
NIN_CFG_GAME_PATH = (1<<4),
NIN_CFG_CHEAT_PATH = (1<<5),
NIN_CFG_FORCE_WIDE = (1<<6),
NIN_CFG_FORCE_PROG = (1<<7),
NIN_CFG_AUTO_BOOT = (1<<8),
NIN_CFG_HID = (1<<9),
NIN_CFG_OSREPORT = (1<<10), // Only for Wii
};
enum ninvideomode
{
NIN_VID_AUTO = (0<<16),
NIN_VID_FORCE = (1<<16),
NIN_VID_NONE = (2<<16),
NIN_VID_MASK = NIN_VID_AUTO|NIN_VID_FORCE|NIN_VID_NONE,
NIN_VID_FORCE_PAL50 = (1<<0),
NIN_VID_FORCE_PAL60 = (1<<1),
NIN_VID_FORCE_NTSC = (1<<2),
NIN_VID_FORCE_MPAL = (1<<3),
NIN_VID_FORCE_MASK = NIN_VID_FORCE_PAL50|NIN_VID_FORCE_PAL60|NIN_VID_FORCE_NTSC|NIN_VID_FORCE_MPAL,
};

View File

@ -1174,8 +1174,8 @@ private:
static const SOption _AspectRatio[3];
static const SOption _NMM[4];
static const SOption _NoDVD[3];
static const SOption _GlobalGCLoaders[2];
static const SOption _GCLoader[3];
static const SOption _GlobalGCLoaders[3];
static const SOption _GCLoader[4];
static const SOption _vidModePatch[4];
static const SOption _debugger[3];
static const SOption _hooktype[8];

View File

@ -173,15 +173,17 @@ const CMenu::SOption CMenu::_NoDVD[3] = {
{ "NoDVDon", L"Enabled" },
};
const CMenu::SOption CMenu::_GlobalGCLoaders[2] = {
const CMenu::SOption CMenu::_GlobalGCLoaders[3] = {
{ "GC_Auto", L"Auto MIOS" },
{ "GC_Devo", L"Devolution" }
{ "GC_Devo", L"Devolution" },
{ "GC_Nindnt", L"Nintendont" },
};
const CMenu::SOption CMenu::_GCLoader[3] = {
const CMenu::SOption CMenu::_GCLoader[4] = {
{ "GC_Def", L"Default" },
{ "GC_Auto", L"Auto MIOS" },
{ "GC_Devo", L"Devolution" }
{ "GC_Devo", L"Devolution" },
{ "GC_Nindnt", L"Nintendont" },
};
const CMenu::SOption CMenu::_vidModePatch[4] = {
@ -888,12 +890,15 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
bool memcard_emu = m_gcfg2.getBool(id, "devo_memcard_emu", false);
bool widescreen = m_gcfg2.getBool(id, "dm_widescreen", false);
bool activity_led = m_gcfg2.getBool(id, "led", false);
u8 NMM = min((u32)m_gcfg2.getInt(id, "dml_nmm", 0), ARRAY_SIZE(CMenu::_NMM) - 1u);
NMM = (NMM == 0) ? m_cfg.getInt(GC_DOMAIN, "dml_nmm", 0) : NMM-1;
//if GC disc use DIOS MIOS to launch it
if(disc)
{
loader = 0;
gprintf("Booting GC Disc: %s\n", id);
DML_New_SetBootDiscOption(m_new_dm_cfg);
}
else
m_cfg.setString(GC_DOMAIN, "current_item", id);
@ -965,15 +970,11 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
currentPartition = SD;
}
_launchShutdown();
bool DIOSMIOS = false;
if(disc == true)
DIOSMIOS = true;
else if(loader == 0 || strcasestr(path, "boot.bin") != NULL)
DML_New_SetBootDiscOption(m_new_dm_cfg);
else if(loader == 0)
{
DIOSMIOS = true;
char CheatPath[256];
u8 NMM = min((u32)m_gcfg2.getInt(id, "dml_nmm", 0), ARRAY_SIZE(CMenu::_NMM) - 1u);
NMM = (NMM == 0) ? m_cfg.getInt(GC_DOMAIN, "dml_nmm", 0) : NMM-1;
u8 nodisc = min((u32)m_gcfg2.getInt(id, "no_disc_patch", 0), ARRAY_SIZE(CMenu::_NoDVD) - 1u);
nodisc = (nodisc == 0) ? m_cfg.getInt(GC_DOMAIN, "no_disc_patch", 0) : nodisc-1;
bool cheats = m_gcfg2.testOptBool(id, "cheat", m_cfg.getBool(GC_DOMAIN, "cheat", false));
@ -1002,8 +1003,10 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
if(!nodisc || !m_new_dml)
WDVD_StopMotor();
}
else
else if(loader == 1)
DEVO_GetLoader(m_dataDir.c_str());
else if(loader == 2)
Nintendont_SetOptions(path, NMM, videoSetting, widescreen);
m_gcfg1.save(true);
m_gcfg2.save(true);
@ -1011,20 +1014,20 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
m_cfg.save(true);
cleanup();
GC_SetVideoMode(videoMode, (disc ? 1 : videoSetting), DIOSMIOS);
GC_SetVideoMode(videoMode, (disc ? 1 : videoSetting), loader);
GC_SetLanguage(GClanguage);
/* NTSC-J Patch by FIX94 */
if(id[3] == 'J')
*HW_PPCSPEED = 0x0002A9E0;
if(DIOSMIOS)
if(loader == 0)
{
DML_New_WriteOptions();
ShutdownBeforeExit();
WII_Initialize();
WII_LaunchTitle(0x100000100LL);
}
else
else if(loader == 1)
{
if(AHBRPOT_Patched())
loadIOS(58, false);
@ -1035,6 +1038,17 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
widescreen, activity_led, m_use_wifi_gecko);
DEVO_Boot();
}
else
{
Nintendont_WriteOptions();
bool ret = Nintendont_GetLoader();
ShutdownBeforeExit();
if(ret == true)
{
loadIOS(58, false); //nintendont NEEDS ios58
BootHomebrew(); //regular dol
}
}
Sys_Exit();
}
@ -1607,13 +1621,13 @@ void CMenu::_gameSoundThread(CMenu *m)
char cached_banner[256];
cached_banner[255] = '\0';
strncpy(cached_banner, fmt("%s/%.6s.bnr", m->m_bnrCacheDir.c_str(), GameHdr->id), 255);
strncpy(cached_banner, fmt("%s/%s.bnr", m->m_bnrCacheDir.c_str(), GameHdr->id), 255);
cached_bnr_file = fsop_ReadFile(cached_banner, &cached_bnr_size);
if(cached_bnr_file == NULL)
{
char custom_banner[256];
custom_banner[255] = '\0';
strncpy(custom_banner, fmt("%s/%.6s.bnr", m->m_customBnrDir.c_str(), GameHdr->id), 255);
strncpy(custom_banner, fmt("%s/%s.bnr", m->m_customBnrDir.c_str(), GameHdr->id), 255);
custom_bnr_file = fsop_ReadFile(custom_banner, &custom_bnr_size);
if(custom_bnr_file == NULL)
{
@ -1638,8 +1652,6 @@ void CMenu::_gameSoundThread(CMenu *m)
}
}
u32 sndSize = 0;
u8 *soundBin = NULL;
if(cached_bnr_file != NULL)
CurrentBanner.SetBanner(cached_bnr_file, cached_bnr_size);
else if(custom_bnr_file != NULL)
@ -1660,8 +1672,9 @@ void CMenu::_gameSoundThread(CMenu *m)
if(cached_bnr_file == NULL && custom_bnr_file == NULL)
fsop_WriteFile(cached_banner, CurrentBanner.GetBannerFile(), CurrentBanner.GetBannerFileSize());
u32 sndSize = 0;
m_banner.LoadBanner(m->m_wbf1_font, m->m_wbf2_font);
soundBin = CurrentBanner.GetFile("sound.bin", &sndSize);
u8 *soundBin = CurrentBanner.GetFile("sound.bin", &sndSize);
CurrentBanner.ClearBanner();
if(soundBin != NULL)
@ -1672,6 +1685,7 @@ void CMenu::_gameSoundThread(CMenu *m)
u8 *newSound = DecompressCopy(soundBin, sndSize, &newSize);
if(newSound == NULL || newSize == 0 || !m->m_gameSound.Load(newSound, newSize))
{
free(soundBin);
m->m_gameSound.FreeMemory();
m_banner.DeleteBanner();
m->m_soundThrdBusy = false;

View File

@ -258,7 +258,11 @@ void CMenu::_sourceFlow()
m_plugin.EndAdd();
}
const dir_discHdr *hdr = CoverFlow.getHdr();
if(m_cfg.getBool("SOURCEFLOW", "remember_last_item", true))
m_cfg.setString("SOURCEFLOW", "current_item", strrchr(hdr->path, '/') + 1);
else
m_cfg.remove("SOURCEFLOW", "current_item");
memset(btn_selected, 0, 256);
strncpy(btn_selected, fmt("BUTTON_%i", hdr->settings[0]), 255);
string source = m_source.getString(btn_selected, "source", "");