* Removed limitations for MEM1 usage

* Moved lots of stuff from MEM1 to MEM2
* Made it possible to select partition for nand emulation (first time config)
* On clean install it will find valid emu nands if they are present in the default folder
* Fixed GameTDB for nand emulation
* Broke background music
* Probably even more
This commit is contained in:
overjoy.psm 2012-06-07 00:34:47 +00:00
parent 76cea9fa42
commit 102157431e
20 changed files with 441 additions and 412 deletions

View File

@ -26,7 +26,8 @@ extern void __exception_closeall();
typedef void (*entrypoint) (void);
typedef struct _dolheader{
typedef struct _dolheader
{
u32 section_pos[18];
u32 section_start[18];
u32 section_size[18];
@ -67,9 +68,9 @@ s32 BootChannel(u32 entry, u64 chantitle, u32 ios, u8 vidMode, bool vipatch, boo
DCFlushRange((void *)0x80003188, 4);
// Game ID Online Check
memset((void *)0x80000000, 0, 6);
memset((void *)0x80000000, 0, 4);
*(vu32 *)0x80000000 = TITLE_LOWER(chantitle);
DCFlushRange((void *)0x80000000, 6);
DCFlushRange((void *)0x80000000, 4);
gprintf("Jumping to entrypoint %08x\n", entryPoint);
@ -85,7 +86,7 @@ s32 BootChannel(u32 entry, u64 chantitle, u32 ios, u8 vidMode, bool vipatch, boo
{
if(hooktype != 0)
{
__asm__(
asm volatile (
"lis %r3, entryPoint@h\n"
"ori %r3, %r3, entryPoint@l\n"
"lwz %r3, 0(%r3)\n"
@ -102,7 +103,7 @@ s32 BootChannel(u32 entry, u64 chantitle, u32 ios, u8 vidMode, bool vipatch, boo
}
else if(hooktype != 0)
{
__asm__(
asm volatile (
"lis %r3, returnpoint@h\n"
"ori %r3, %r3, returnpoint@l\n"
"mtlr %r3\n"

View File

@ -949,12 +949,45 @@ s32 Nand::CreateConfig(const char *path)
snprintf(cfgpath, sizeof(cfgpath), "%s%s", path, SYSCONFPATH);
snprintf(settxtpath, sizeof(settxtpath), "%s%s", path, TXTPATH);
snprintf(settxtpath, sizeof(settxtpath), "%s%s", path, TXTPATH);
__DumpNandFile(SYSCONFPATH, cfgpath);
__DumpNandFile(TXTPATH, settxtpath);
return 0;
}
s32 Nand::PreNandCfg(const char *path, bool miis)
{
CreatePath(path);
CreatePath("%s/shared2", path);
CreatePath("%s/shared2/sys", path);
if(miis)
{
CreatePath("%s/shared2/menu", path);
CreatePath("%s/shared2/menu/FaceLib", path);
}
CreatePath("%s/title", path);
CreatePath("%s/title/00000001", path);
CreatePath("%s/title/00000001/00000002", path);
CreatePath("%s/title/00000001/00000002/data", path);
char dest[MAX_FAT_PATH];
fake = false;
showprogress = false;
snprintf(dest, sizeof(dest), "%s%s", path, SYSCONFPATH);
__DumpNandFile(SYSCONFPATH, dest);
snprintf(dest, sizeof(dest), "%s%s", path, TXTPATH);
__DumpNandFile(TXTPATH, dest);
if(miis)
{
snprintf(dest, sizeof(dest), "%s%s", path, MIIPATH);
__DumpNandFile(MIIPATH, dest);
}
return 0;
}
s32 Nand::Do_Region_Change(string id)
{
if(__configread())

View File

@ -20,6 +20,7 @@
#define RF_FORECAST_CHANNEL 0x48414641
#define SYSCONFPATH "/shared2/sys/SYSCONF"
#define MIIPATH "/shared2/menu/FaceLib/RFL_DB.dat"
#define TXTPATH "/title/00000001/00000002/data/setting.txt"
#define BLOCK 2048
@ -75,6 +76,7 @@ class Nand
void CreateTitleTMD(const char *path, dir_discHdr *hdr);
s32 CreateConfig(const char *path);
s32 PreNandCfg(const char *path, bool miis);
s32 Do_Region_Change(string id);
s32 FlashToNAND(const char *source, const char *dest, dump_callback_t i_dumper, void *i_data);
s32 DoNandDump(const char *source, const char *dest, dump_callback_t i_dumper, void *i_data);

View File

@ -14,11 +14,11 @@
#define wbfs_fatal(x) do { gprintf(x); wd_last_error = 1; } while(0)
#define wbfs_error(x) do { gprintf(x); wd_last_error = 2; } while(0)
#define wbfs_malloc(x) MEM1_alloc(x)
#define wbfs_free(x) MEM1_free(x)
#define wbfs_malloc(x) MEM2_alloc(x)
#define wbfs_free(x) MEM2_free(x)
#define wbfs_ioalloc(x) MEM1_memalign(32, x)
#define wbfs_iofree(x) MEM1_free(x)
#define wbfs_ioalloc(x) MEM2_memalign(32, x)
#define wbfs_iofree(x) MEM2_free(x)
#define wbfs_be16(x) (*((u16*)(x)))
#define wbfs_be32(x) (*((u32*)(x)))

View File

@ -72,7 +72,7 @@ void ClearLogBuffer()
{
if(tmpfilebuffer == NULL)
return;
MEM1_free(tmpfilebuffer);
MEM2_free(tmpfilebuffer);
tmpfilebuffer = NULL;
}
@ -88,7 +88,7 @@ void WriteToFile(char* tmp)
}
else
{
MEM1_free(tmpfilebuffer);
MEM2_free(tmpfilebuffer);
tmpfilebuffer = NULL;
return;
}
@ -168,7 +168,7 @@ bool InitGecko()
USBGeckoOutput();
tmpfilebuffer = (char*)MEM1_alloc(filebuffer + 1 * sizeof(char));
tmpfilebuffer = (char*)MEM2_alloc(filebuffer + 1 * sizeof(char));
if(tmpfilebuffer != NULL)
memset(tmpfilebuffer, 0, sizeof(tmpfilebuffer));

View File

@ -247,11 +247,15 @@ void CVideo::cleanup(void)
{
if(m_aaBuffer[i].get())
m_aaBuffer[i].release();
m_aaBufferSize[i] = 0;
}
for(u8 i = 0; i < m_defaultWaitMessages.size(); i++)
{
m_defaultWaitMessages[i].data.release();
free(MEM_K1_TO_K0(m_frameBuf[0]));
free(MEM_K1_TO_K0(m_frameBuf[1]));
}
//free(MEM_K1_TO_K0(m_frameBuf[0]));
//free(MEM_K1_TO_K0(m_frameBuf[1]));
MEM1_free(m_stencil);
MEM1_free(m_fifo);
}

View File

@ -37,7 +37,8 @@ void CachedList<T>::Load(string path, string containing, string m_lastLanguage,
m_discinf = sfmt("%s/disc.info", path.c_str());
struct stat filestat, discinfo, cache;
gprintf("%s\n", path.c_str());
if(stat(path.c_str(), &filestat) == -1) return;
if(stat(path.c_str(), &filestat) == -1)
return;
bool update_lang = m_lastLanguage != m_curLanguage;
bool noDB = stat(m_database.c_str(), &cache) == -1;
@ -46,12 +47,16 @@ void CachedList<T>::Load(string path, string containing, string m_lastLanguage,
ditimes = discinfo.st_mtime > cache.st_mtime;
m_update = update_lang || noDB || mtimes || ditimes;
if(m_update) gprintf("Cache of %s is being updated because:\n", path.c_str());
if(update_lang) gprintf("Languages are different!\nOld language string: %s\nNew language string: %s\n", m_lastLanguage.c_str(), m_curLanguage.c_str());
if(noDB) gprintf("A database was not found!\n");
if(mtimes || ditimes) gprintf("The WBFS folder was modified!\nCache date: %i\nFolder date: %i\n", cache.st_mtime, filestat.st_mtime);
if(m_update)
gprintf("Cache of %s is being updated because:\n", path.c_str());
if(update_lang)
gprintf("Languages are different!\nOld language string: %s\nNew language string: %s\n", m_lastLanguage.c_str(), m_curLanguage.c_str());
if(noDB)
gprintf("A database was not found!\n");
if(mtimes || ditimes)
gprintf("The WBFS folder was modified!\nCache date: %i\nFolder date: %i\n", cache.st_mtime, filestat.st_mtime);
if(m_extcheck && !m_update && strcasestr(path.c_str(), "wbfs") != NULL)
if(m_extcheck && !m_update && !music)
{
bool m_chupdate = false;
DIR *dir = opendir(path.c_str());
@ -68,9 +73,12 @@ void CachedList<T>::Load(string path, string containing, string m_lastLanguage,
}
}
if(update_games) force_update[COVERFLOW_USB] = false;
if(update_homebrew) force_update[COVERFLOW_HOMEBREW] = false;
if(update_dml) force_update[COVERFLOW_DML] = false;
if(update_games)
force_update[COVERFLOW_USB] = false;
if(update_homebrew)
force_update[COVERFLOW_HOMEBREW] = false;
if(update_dml)
force_update[COVERFLOW_DML] = false;
if(m_update || m_wbfsFS || music)
{

View File

@ -173,8 +173,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
if((*itr).find_last_of('.') != string::npos)
(*itr).erase((*itr).find_last_of('.'), (*itr).size() - (*itr).find_last_of('.'));
strncpy(tempname, (*itr).c_str(), sizeof(tempname));
//mbstowcs(tmp.title, tempname, sizeof(tmp.title));
//Asciify(tmp.title);
wstringEx tmpString;
tmpString.fromUTF8(tempname);
wcsncpy(tmp.title, tmpString.c_str(), 64);
@ -211,8 +209,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
if( GTitle.size() > 0 || ( gameTDB.IsLoaded() && gameTDB.GetTitle( (char *)tmp.hdr.id, GTitle ) ) )
{
//mbstowcs( tmp.title, GTitle.c_str(), sizeof(tmp.title) );
//Asciify( tmp.title );
wstringEx tmpString;
tmpString.fromUTF8(GTitle.c_str());
wcsncpy(tmp.title, tmpString.c_str(), 64);
@ -247,8 +243,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
if (tmp.hdr.gc_magic == GC_MAGIC)
{
//mbstowcs( tmp.title, (const char *)tmp.hdr.title, sizeof( tmp.hdr.title ) );
//Asciify(tmp.title);
wstringEx tmpString;
tmpString.fromUTF8((const char *)tmp.hdr.title);
wcsncpy(tmp.title, tmpString.c_str(), 64);
@ -304,8 +298,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
if(GTitle.size() > 0 || (gameTDB.IsLoaded() && gameTDB.GetTitle((char *)tmp.hdr.id, GTitle)))
{
//mbstowcs(tmp.title, GTitle.c_str(), sizeof(tmp.title));
//Asciify(tmp.title);
wstringEx tmpString;
tmpString.fromUTF8(GTitle.c_str());
wcsncpy(tmp.title, tmpString.c_str(), 64);
@ -330,8 +322,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
if (tmp.hdr.magic == WII_MAGIC)
{
//mbstowcs(tmp.title, (const char *)tmp.hdr.title, sizeof(tmp.hdr.title));
//Asciify(tmp.title);
wstringEx tmpString;
tmpString.fromUTF8((const char *)tmp.hdr.title);
wcsncpy(tmp.title, tmpString.c_str(), 64);
@ -340,23 +330,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
continue;
}
/*if(wbfs)
{
wbfs_t *part = WBFS_Ext_OpenPart((char *)(*itr).c_str());
if (!part) continue;
// Get header
if(wbfs_get_disc_info(part, 0, (u8*)&tmp.hdr, sizeof(discHdr), NULL) == 0
&& memcmp(tmp.hdr.id, "__CFG_", sizeof tmp.hdr.id) != 0)
{
mbstowcs(tmp.title, (const char *)tmp.hdr.title, sizeof(tmp.title));
Asciify(tmp.title);
headerlist.push_back(tmp);
}
WBFS_Ext_ClosePart(part);
continue;
}*/
}
else if((*itr).rfind(".dol") != string::npos || (*itr).rfind(".DOL") != string::npos
|| (*itr).rfind(".elf") != string::npos || (*itr).rfind(".ELF") != string::npos)
@ -396,17 +369,14 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, tmp.hdr.casecolor).intVal();
if(GTitle.size() > 0 || (gameTDB.GetTitle((char *)tmp.hdr.id, GTitle)))
{
//mbstowcs(tmp.title, GTitle.c_str(), sizeof(tmp.title));
tmpString.fromUTF8(GTitle.c_str());
tmp.hdr.casecolor = ccolor != 1 ? ccolor : gameTDB.GetCaseColor((char *)tmp.hdr.id);
}
else
{
//mbstowcs(tmp.title, (*itr).c_str(), sizeof(tmp.title));
tmpString.fromUTF8((*itr).c_str());
tmp.hdr.casecolor = ccolor != 1 ? ccolor : 1;
}
//Asciify(tmp.title);
wcsncpy(tmp.title, tmpString.c_str(), 64);
headerlist.push_back(tmp);
continue;
@ -429,7 +399,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
wstringEx tmpString;
if(GTitle.size() > 0 || (gameTDB.IsLoaded() && gameTDB.GetTitle((char *)tmp.hdr.id, GTitle)))
{
//mbstowcs(tmp.title, GTitle.c_str(), sizeof(tmp.title));
tmpString.fromUTF8(GTitle.c_str());
tmp.hdr.casecolor = ccolor != 1 ? ccolor : gameTDB.GetCaseColor((char *)tmp.hdr.id);
tmp.hdr.wifi = gameTDB.GetWifiPlayers((char *)tmp.hdr.id);
@ -438,7 +407,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
//tmp.hdr.controllers = gameTDB.GetAccessories((char *)tmp.hdr.id);
if (tmp.hdr.magic == WII_MAGIC)
{
//Asciify(tmp.title);
wcsncpy(tmp.title, tmpString.c_str(), 64);
headerlist.push_back(tmp);
}
@ -447,8 +415,6 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
if (tmp.hdr.magic == WII_MAGIC)
{
//mbstowcs(tmp.title, (const char *)tmp.hdr.title, sizeof(tmp.hdr.title));
//Asciify(tmp.title);
tmpString.fromUTF8((const char *)tmp.hdr.title);
wcsncpy(tmp.title, tmpString.c_str(), 64);
tmp.hdr.casecolor = ccolor != 1 ? ccolor : 1;
@ -491,7 +457,8 @@ void CList<dir_discHdr>::GetChannels(vector<dir_discHdr> &headerlist, string set
{
Channel *chan = m_channels.GetChannel(i);
if (chan->id == NULL) continue; // Skip invalid channels
if (chan->id == NULL)
continue; // Skip invalid channels
dir_discHdr tmp;
bzero(&tmp, sizeof(dir_discHdr));
@ -504,9 +471,11 @@ void CList<dir_discHdr>::GetChannels(vector<dir_discHdr> &headerlist, string set
int ccolor = custom_titles.getColor("COVERS", (const char *) tmp.hdr.id, tmp.hdr.casecolor).intVal();
if(GTitle.size() > 0 || (gameTDB.IsLoaded() && gameTDB.GetTitle((char *)tmp.hdr.id, GTitle)))
mbstowcs(tmp.title, GTitle.c_str(), sizeof(tmp.title));
Asciify(tmp.title);
{
wstringEx tmpString;
tmpString.fromUTF8(GTitle.c_str());
wcsncpy(tmp.title, tmpString.c_str(), 64);
}
tmp.hdr.casecolor = ccolor != 1 ? ccolor : gameTDB.GetCaseColor((char *)tmp.hdr.id);

View File

@ -189,7 +189,7 @@ s32 Disc_FindPartition(u64 *outbuf)
u64 offset = 0;
u32 cnt;
u32 *TMP_Buffer = (u32*)MEM1_alloc(0x20);
u32 *TMP_Buffer = (u32*)MEM2_alloc(0x20);
if(!TMP_Buffer)
return -1;
@ -197,7 +197,7 @@ s32 Disc_FindPartition(u64 *outbuf)
s32 ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, PTABLE_OFFSET);
if(ret < 0)
{
MEM1_free(TMP_Buffer);
MEM2_free(TMP_Buffer);
return ret;
}
@ -207,7 +207,7 @@ s32 Disc_FindPartition(u64 *outbuf)
if(nb_partitions > 8)
{
MEM1_free(TMP_Buffer);
MEM2_free(TMP_Buffer);
return -1;
}
@ -217,7 +217,7 @@ s32 Disc_FindPartition(u64 *outbuf)
ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, table_offset);
if (ret < 0)
{
MEM1_free(TMP_Buffer);
MEM2_free(TMP_Buffer);
return ret;
}
@ -230,7 +230,7 @@ s32 Disc_FindPartition(u64 *outbuf)
if(!type)
offset = TMP_Buffer[cnt * 2] << 2;
}
MEM1_free(TMP_Buffer);
MEM2_free(TMP_Buffer);
/* No game partition found */
if (!offset)

View File

@ -36,7 +36,6 @@ extern "C"
int main(int argc, char **argv)
{
__exception_setreload(5);
MEM1_init((void*)0x80004000, (void*)0x80b00000);
// Init video
CVideo vid;
@ -44,6 +43,7 @@ int main(int argc, char **argv)
geckoinit = InitGecko();
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
MEM2_init(49); //Thats everything we can get anyways
vid.waitMessage(0.2f);

View File

@ -11,11 +11,8 @@
// Forbid the use of MEM2 through malloc
u32 MALLOC_MEM2 = 0;
static CMEM2Alloc g_mem1gp;
static CMEM2Alloc g_mem2gp;
bool WrapMEM1 = true;
extern "C"
{
@ -26,58 +23,35 @@ extern __typeof(memalign) __real_memalign;
extern __typeof(free) __real_free;
extern __typeof(malloc_usable_size) __real_malloc_usable_size;
void MEM1_init(void *addr, void *end)
{
g_mem1gp.init(addr, end);
g_mem1gp.clear();
}
void MEM1_cleanup(void)
{
g_mem1gp.cleanup();
}
void MEM1_clear(void)
{
g_mem1gp.clear();
}
void *MEM1_alloc(unsigned int s)
{
return g_mem1gp.allocate(s);
return __real_malloc(s);
}
void *MEM1_memalign(unsigned int a, unsigned int s)
{
return g_mem1gp.allocate(ALIGN(a, s));
return __real_memalign(a, s);
}
void *MEM1_realloc(void *p, unsigned int s)
{
return g_mem1gp.reallocate(p, s);
return __real_realloc(p, s);
}
void MEM1_free(void *p)
{
g_mem1gp.release(p);
}
void MEM1_wrap(unsigned int enable)
if(p != NULL)
{
WrapMEM1 = enable;
free(p);
p = NULL;
}
unsigned int MEM1_usableSize(void *p)
{
return g_mem1gp.usableSize(p);
}
unsigned int MEM1_freesize()
{
return g_mem1gp.FreeSize();
return SYS_GetArena1Size();
}
void MEM2_init(unsigned int mem2Size)
{
g_mem2gp.init(mem2Size);
@ -127,7 +101,7 @@ unsigned int MEM2_freesize()
void *__wrap_malloc(size_t size)
{
void *p;
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE || !WrapMEM1)
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE)
{
p = g_mem2gp.allocate(size);
if(p != 0)
@ -143,7 +117,7 @@ void *__wrap_malloc(size_t size)
void *__wrap_calloc(size_t n, size_t size)
{
void *p;
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || (n * size) >= MEM2_PRIORITY_SIZE || !WrapMEM1)
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || (n * size) >= MEM2_PRIORITY_SIZE)
{
p = g_mem2gp.allocate(n * size);
if (p != 0)
@ -166,7 +140,7 @@ void *__wrap_calloc(size_t n, size_t size)
void *__wrap_memalign(size_t a, size_t size)
{
void *p;
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE || !WrapMEM1)
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE)
{
p = MEM2_memalign(a, size);
if (p != 0)
@ -186,8 +160,6 @@ void __wrap_free(void *p)
if(((u32)p & 0x10000000) != 0)
g_mem2gp.release(p);
else if((u32)p < (u32)0x80b00000 && (u32)p >= (u32)0x80003f00)
g_mem1gp.release(p);
else
__real_free(p);
}

View File

@ -12,17 +12,11 @@ extern "C"
#define MAX_MEM1_ARENA_LO ((void *)(0x81700000-size))
#define MEM2_PRIORITY_SIZE 0x1000
void MEM1_init(void *addr, void *end);
void MEM1_cleanup(void);
void MEM1_clear(void);
void *MEM1_alloc(unsigned int s);
void *MEM1_memalign(unsigned int a, unsigned int s);
void *MEM1_realloc(void *p, unsigned int s);
void MEM1_free(void *p);
void MEM1_wrap(unsigned int enable);
unsigned int MEM1_usableSize(void *p);
unsigned int MEM1_freesize();
void MEM2_init(unsigned int mem2Size);
void MEM2_cleanup(void);
void MEM2_clear(void);

View File

@ -392,7 +392,8 @@ void CMenu::init(void)
m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str()));
}
bool extcheck = m_cfg.getBool("GENERAL", "extended_list_check", false);
bool extcheck = m_cfg.getBool("GENERAL", "extended_list_check", true);
m_tempView = false;
m_gameList.Init(m_listCacheDir, m_settingsDir, m_loc.getString(m_curLanguage, "gametdb_code", "EN"), m_DMLgameDir, extcheck);
@ -1971,65 +1972,36 @@ const wstringEx CMenu::_fmt(const char *key, const wchar_t *def)
bool CMenu::_loadChannelList(void)
{
currentPartition = m_cfg.getInt("NAND", "partition", 0);
static u8 lastPartition = currentPartition;
string emuPath;
m_partRequest = m_cfg.getInt("NAND", "partition", 0);
int emuPartition = _FindEmuPart(&emuPath, m_partRequest, false);
bool disable_emu = m_cfg.getBool("NAND", "disable", true);
static bool last_emu_state = disable_emu;
if(!disable_emu && !DeviceHandler::Instance()->IsInserted(currentPartition))
if(emuPartition < 0)
emuPartition = _FindEmuPart(&emuPath, m_partRequest, true);
if(emuPartition < 0)
return false;
else
currentPartition = emuPartition;
static u8 lastPartition = currentPartition;
static bool first = true;
static bool failed = false;
bool changed = lastPartition != currentPartition || last_emu_state != disable_emu || first || failed;
gprintf("%s, which is %s\n", disable_emu ? "NAND" : DeviceName[currentPartition], changed ? "refreshing." : "cached.");
string path = m_cfg.getString("NAND", "path", STDEMU_DIR);
gprintf("%s, which is %s\n", disable_emu ? "NAND" : DeviceName[emuPartition], changed ? "refreshing." : "cached.");
if(first && !disable_emu)
{
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
u32 sysconf_size, meez_size;
sprintf(filepath, "/shared2/sys/SYSCONF");
u8 *sysconf = ISFS_GetFile((u8 *) &filepath, &sysconf_size, -1);
if(sysconf != NULL && sysconf_size > 0)
{
sprintf(filepath, "%s:%s/shared2/sys/SYSCONF", DeviceName[currentPartition], path.c_str());
FILE *file = fopen(filepath, "wb");
if(file)
{
fwrite(sysconf, 1, sysconf_size, file);
gprintf("Written SYSCONF to: %s\n", filepath);
fclose(file);
}
else
gprintf("Openning %s failed returning %i\n", filepath, file);
MEM2_free(sysconf);
}
sprintf(filepath, "/shared2/menu/FaceLib/RFL_DB.dat");
u8 *meez = ISFS_GetFile((u8 *) &filepath, &meez_size, -1);
if(meez != NULL && meez_size > 0)
{
sprintf(filepath, "%s:%s/shared2/menu/FaceLib/RFL_DB.dat", DeviceName[currentPartition], path.c_str());
FILE *file = fopen(filepath, "wb");
if(file)
{
fwrite(meez, 1, meez_size, file);
gprintf("Written Mii's to: %s\n", filepath);
fclose(file);
}
else
gprintf("Openning %s failed returning %i\n", filepath, file);
MEM2_free(meez);
}
char basepath[64];
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[currentPartition], emuPath.c_str());
Nand::Instance()->PreNandCfg(basepath, m_cfg.getBool("NAND", "miis_from_real", true));
first = false;
}
@ -2041,7 +2013,7 @@ bool CMenu::_loadChannelList(void)
DeviceHandler::Instance()->UnMount(currentPartition);
Nand::Instance()->Init(path.c_str(), currentPartition, disable_emu);
Nand::Instance()->Init(emuPath.c_str(), currentPartition, disable_emu);
if(Nand::Instance()->Enable_Emu() < 0)
{
Nand::Instance()->Disable_Emu();
@ -2054,7 +2026,7 @@ bool CMenu::_loadChannelList(void)
if(!DeviceHandler::Instance()->IsInserted(currentPartition))
DeviceHandler::Instance()->Mount(currentPartition);
string nandpath = sfmt("%s:%s/", DeviceName[currentPartition], path.empty() ? "" : path.c_str());
string nandpath = sfmt("%s:%s/", DeviceName[currentPartition], emuPath.empty() ? "" : emuPath.c_str());
gprintf("nandpath = %s\n", nandpath.c_str());
if(!failed)

View File

@ -576,7 +576,8 @@ private:
bool m_sgdump;
bool m_saveall;
bool m_forceext;
//int m_saveExtMode;
bool m_tempView;
int m_partRequest;
u32 m_nandemuLblTitle;
u32 m_nandemuBtnBack;
u32 m_nandemuLblEmulationVal;
@ -597,6 +598,7 @@ private:
u32 m_nandemuPBar;
u32 m_nandemuBtnExtract;
u32 m_nandemuBtnDisable;
u32 m_nandemuBtnPartition;
u32 m_nandemuLblInit;
u32 m_nandemuLblUser[4];
STexture m_nandemuBg;
@ -1088,7 +1090,9 @@ private:
void _stopSounds(void);
static int _NandDumper(void *obj);
static int _NandFlasher(void *obj);
int _FindEmuPart(string *emuPath, int part, bool searchvalid);
bool _checkSave(string id, bool nand);
bool _TestEmuNand(int epart, const char *path, bool indept);
static u32 _downloadCheatFileAsync(void *obj);
@ -1109,7 +1113,7 @@ private:
static const SOption _DMLvideoModes[7];
static const SOption _GClanguages[8];
static const SOption _NandEmu[3];
static const SOption _NandEmu[2];
static const SOption _SaveEmu[5];
static const SOption _GlobalSaveEmu[4];
static const SOption _AspectRatio[3];

View File

@ -62,11 +62,8 @@ void CMenu::_showConfig(void)
m_btnMgr.show(m_configLblDownload);
m_btnMgr.show(m_configBtnDownload);
bool disable = true;
int i = m_current_view == COVERFLOW_CHANNEL && min(max(0, m_cfg.getInt("NAND", "emulation", 0)), (int)ARRAY_SIZE(CMenu::_NandEmu) - 1);
if (i>0 || m_current_view != COVERFLOW_CHANNEL)
disable = false;
char *partitionname = disable ? (char *)"NAND" : (char *)DeviceName[m_cfg.getInt(_domainFromView(), "partition", 0)];
bool disable = m_cfg.getBool("NAND", "disable", true) && m_current_view == COVERFLOW_CHANNEL && !m_tempView;
char *partitionname = disable ? (char *)"NAND" : (char *)DeviceName[m_tempView ? m_cfg.getInt("GAMES", "savepartition", 0) : m_cfg.getInt(_domainFromView(), "partition", 0)];
for(u8 i = 0; strncmp((const char *)&partitionname[i], "\0", 1) != 0; i++)
partitionname[i] = toupper(partitionname[i]);
@ -215,15 +212,14 @@ int CMenu::_config1(void)
}
}
}
if (currentPartition != bCurrentPartition)
{
bool disable = true;
int i = m_current_view == COVERFLOW_CHANNEL && min(max(0, m_cfg.getInt("NAND", "emulation", 0)), (int)ARRAY_SIZE(CMenu::_NandEmu) - 1);
if (i>0 || m_current_view != COVERFLOW_CHANNEL)
disable = false;
bool disable = m_cfg.getBool("NAND", "disable", true) && m_current_view == COVERFLOW_CHANNEL && !m_tempView;
if(!disable)
{
char *newpartition = disable ? (char *)"NAND" : (char *)DeviceName[m_cfg.getInt(_domainFromView(), "partition", currentPartition)];
char *newpartition = (char *)DeviceName[m_cfg.getInt(m_tempView ? "GAMES" : _domainFromView(), m_tempView ? "savepartition" : "partition", currentPartition)];
for(u8 i = 0; strncmp((const char *)&newpartition[i], "\0", 1) != 0; i++)
newpartition[i] = toupper(newpartition[i]);

View File

@ -146,8 +146,7 @@ const CMenu::SOption CMenu::_GClanguages[8] = {
{ "lngdut", L"Dutch" }
};
const CMenu::SOption CMenu::_NandEmu[3] = {
{ "NANDoff", L"Off" },
const CMenu::SOption CMenu::_NandEmu[2] = {
{ "NANDpart", L"Partial" },
{ "NANDfull", L"Full" },
};
@ -885,8 +884,6 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
Channels channel;
u32 ios = 0;
u32 entry = 0;
MEM1_wrap(0);
Nand::Instance()->Disable_Emu();
string id = string((const char *) hdr->hdr.id);
@ -917,11 +914,14 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
hooktype = (u32) m_gcfg2.getInt(id, "hooktype", 0);
debuggerselect = m_gcfg2.getBool(id, "debugger", false) ? 1 : 0;
if ((debuggerselect || cheat) && hooktype == 0) hooktype = 1;
if (!debuggerselect && !cheat) hooktype = 0;
if (videoMode == 0) videoMode = (u8)min((u32)m_cfg.getInt("GENERAL", "video_mode", 0), ARRAY_SIZE(CMenu::_videoModes) - 1);
if (language == 0) language = min((u32)m_cfg.getInt("GENERAL", "game_language", 0), ARRAY_SIZE(CMenu::_languages) - 1);
if ((debuggerselect || cheat) && hooktype == 0)
hooktype = 1;
if (!debuggerselect && !cheat)
hooktype = 0;
if (videoMode == 0)
videoMode = (u8)min((u32)m_cfg.getInt("GENERAL", "video_mode", 0), ARRAY_SIZE(CMenu::_videoModes) - 1);
if (language == 0)
language = min((u32)m_cfg.getInt("GENERAL", "game_language", 0), ARRAY_SIZE(CMenu::_languages) - 1);
}
m_cfg.setString("NAND", "current_item", id);
@ -931,10 +931,12 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
if(!forwarder && has_enabled_providers() && _initNetwork() == 0)
add_game_to_card(id.c_str());
string emuPath = m_cfg.getString("NAND", "path", "");
int emuPartition = m_cfg.getInt("NAND", "partition", 0);
string emuPath;
m_partRequest = m_cfg.getInt("NAND", "partition", 0);
int emuPartition = _FindEmuPart(&emuPath, m_partRequest, false);
bool emu_disabled = m_cfg.getBool("NAND", "disable", true);
int emulate_mode = min(max(0, m_cfg.getInt("NAND", "emulation", 0)), (int)ARRAY_SIZE(CMenu::_NandEmu) - 1);
int emulate_mode = min(max(0, m_cfg.getInt("NAND", "emulation", 1)), (int)ARRAY_SIZE(CMenu::_NandEmu) - 1);
int userIOS = m_gcfg2.getInt(id, "ios", 0);
@ -943,14 +945,26 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
m_cat.save(true);
m_cfg.save(true);
/*if(!emu_disabled && emulate_mode == 1)
{
char basepath[64];
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str());
Nand::Instance()->CreateConfig(basepath);
Nand::Instance()->Do_Region_Change(id);
}*/
CheckGameSoundThread();
m_vid.CheckWaitThread(true);
cleanup();
USBStorage_Deinit();
Close_Inputs();
if(!emu_disabled)
{
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
DeviceHandler::Instance()->UnMount(emuPartition);
if(emulate_mode == 3)
Nand::Instance()->Set_RCMode(true);
else if(emulate_mode == 2)
if(emulate_mode == 1)
Nand::Instance()->Set_FullMode(true);
else
Nand::Instance()->Set_FullMode(false);
@ -962,7 +976,6 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
return;
}
DeviceHandler::Instance()->Mount(emuPartition);
}
if(!forwarder)
@ -977,11 +990,11 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
ocarina_load_code(cheatFile.get(), cheatSize);
int gameIOS = userIOS == 0 ? channel.GetRequestedIOS(hdr->hdr.chantitle) : userIOS;
int gameIOS = userIOS == 0 ? ios : userIOS;
gprintf("%s IOS %u\n", userIOS == 0 ? "Game requested" : "User requested", gameIOS);
if (gameIOS != mainIOS)
if (gameIOS != mainIOS && gameIOS <= 0x50)
{
u8 IOS[3];
IOS[0] = gameIOS;
@ -1025,9 +1038,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
DeviceHandler::Instance()->UnMount(emuPartition);
if(emulate_mode == 3)
Nand::Instance()->Set_RCMode(true);
else if(emulate_mode == 2)
if(emulate_mode == 1)
Nand::Instance()->Set_FullMode(true);
else
Nand::Instance()->Set_FullMode(false);
@ -1039,7 +1050,6 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
Sys_LoadMenu();
return;
}
DeviceHandler::Instance()->Mount(emuPartition);
}
}
}
@ -1059,23 +1069,14 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
IOS_Close(ESHandle);
}
IOSReloadBlock(IOS_GetVersion(), true);
CheckGameSoundThread();
cleanup();
Close_Inputs();
USBStorage_Deinit();
if(currentPartition == 0 && !forwarder)
SDHC_Init();
if(forwarder)
{
WII_Initialize();
if (WII_LaunchTitle(hdr->hdr.chantitle) < 0)
Sys_LoadMenu();
}
else if(!BootChannel(entry, hdr->hdr.chantitle, ios, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio))
if(!BootChannel(entry, hdr->hdr.chantitle, ios, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio))
Sys_LoadMenu();
}
@ -1144,88 +1145,56 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
const char *rtrn = m_gcfg2.getBool(id, "returnto", true) ? m_cfg.getString("GENERAL", "returnto").c_str() : NULL;
int aspectRatio = min((u32)m_gcfg2.getInt(id, "aspect_ratio", 0), ARRAY_SIZE(CMenu::_AspectRatio) - 1u)-1;
int emuPartition = m_cfg.getInt("GAMES", "savepartition", -1);
if(emuPartition == -1)
emuPartition = m_cfg.getInt("NAND", "partition", 0);
string emuPath;
m_partRequest = m_cfg.getInt("GAMES", "savepartition", -1);
if(m_partRequest == -1)
m_partRequest = m_cfg.getInt("NAND", "partition", 0);
int emuPartition = _FindEmuPart(&emuPath, m_partRequest, false);
u8 emulate_mode = min((u32)m_gcfg2.getInt(id, "emulate_save", 0), ARRAY_SIZE(CMenu::_SaveEmu) - 1u);
if (emulate_mode == 0)
{
emulate_mode = min(max(0, m_cfg.getInt("GAMES", "save_emulation", 0)), (int)ARRAY_SIZE(CMenu::_GlobalSaveEmu) - 1);
if(emulate_mode != 0)
emulate_mode++;
}
else if(emulate_mode == 1)
emulate_mode = 0;
if(!dvd && emulate_mode)
{
if(emuPartition < 0)
{
if(emulate_mode == 4)
{
_hideWaitMessage();
while(true)
{
_AutoCreateNand();
if(_TestEmuNand(m_cfg.getInt("GAMES", "savepartition", 0), emuPath.c_str(), true))
{
emuPartition = m_cfg.getInt("GAMES", "savepartition", -1);
string emuPath = m_cfg.getString("GAMES", "savepath", m_cfg.getString("NAND", "path", ""));
u8 emuSave = min((u32)m_gcfg2.getInt(id, "emulate_save", 0), ARRAY_SIZE(CMenu::_SaveEmu) - 1u);
if (emuSave == 0)
{
emuSave = min(max(0, m_cfg.getInt("GAMES", "save_emulation", 0)), (int)ARRAY_SIZE(CMenu::_GlobalSaveEmu) - 1);
if (emuSave != 0)
emuSave++;
}
else if (emuSave == 1)
emuSave = 0;
if(!dvd && emuSave)
{
bool emuPartIsValid = false;
for(u8 i = emuPartition; i <= USB8; ++i)
{
if(!DeviceHandler::Instance()->IsInserted(emuPartition) || DeviceHandler::Instance()->GetFSType(emuPartition) != PART_FS_FAT)
{
emuPartition++;
continue;
}
else
{
emuPartIsValid = true;
break;
}
}
if(!emuPartIsValid)
{
error(sfmt("No valid FAT partition found for nandemulation!"));
return;
}
bool createnand = false;
char basepath[64];
if(emuPath.size() == 0)
{
Nand::Instance()->CreatePath("%s:/wiiflow", DeviceName[emuPartition]);
Nand::Instance()->CreatePath("%s:/wiiflow/nandemu", DeviceName[emuPartition]);
m_cfg.setString("GAMES", "savepath", STDEMU_DIR);
emuPath = m_cfg.getString("GAMES", "savepath", STDEMU_DIR);
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str());
if(emuSave == 4)
createnand = true;
}
else
{
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str());
if(emuSave == 4)
{
DIR *d;
d = opendir(basepath);
if(!d)
{
Nand::Instance()->CreatePath("%s:/wiiflow", DeviceName[emuPartition]);
Nand::Instance()->CreatePath("%s:/wiiflow/nandemu", DeviceName[emuPartition]);
createnand = true;
}
else
{
closedir(d);
}
}
}
if(createnand)
{
_hideWaitMessage();
_AutoCreateNand();
_showWaitMessage();
}
if(emuSave == 2 || emuSave > 3)
else
{
if(emuSave == 2)
emuPartition = _FindEmuPart(&emuPath, 1, true);
Nand::Instance()->CreatePath("%s:/wiiflow", DeviceName[emuPartition]);
Nand::Instance()->CreatePath("%s:/wiiflow/nandemu", DeviceName[emuPartition]);
}
}
char basepath[64];
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str());
if(emulate_mode == 2 || emulate_mode > 3)
{
if(emulate_mode == 2)
{
m_forceext = false;
_hideWaitMessage();
@ -1234,7 +1203,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
_showWaitMessage();
}
}
if(emuSave > 2)
if(emulate_mode > 2)
{
Nand::Instance()->CreateConfig(basepath);
Nand::Instance()->Do_Region_Change(id);
@ -1300,14 +1269,14 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
iosLoaded = true;
}
if(emuSave)
if(emulate_mode)
{
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
DeviceHandler::Instance()->UnMount(emuPartition);
if(emuSave == 3)
if(emulate_mode == 3)
Nand::Instance()->Set_RCMode(true);
else if(emuSave == 4)
else if(emulate_mode == 4)
Nand::Instance()->Set_FullMode(true);
else
Nand::Instance()->Set_FullMode(false);
@ -1374,9 +1343,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
if(currentPartition == 0)
SDHC_Init();
/* Clear Memory */
MEM1_wrap(0);
/* Find game partition offset */
u64 offset;
s32 ret = Disc_FindPartition(&offset);
@ -1521,7 +1487,7 @@ void CMenu::_playGameSound(void)
CheckGameSoundThread();
if(!gameSoundThreadStack.get())
gameSoundThreadStack = smartMem1Alloc(gameSoundThreadStackSize);
gameSoundThreadStack = smartMem2Alloc(gameSoundThreadStackSize);
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, gameSoundThreadStack.get(), gameSoundThreadStackSize, 60);
}

View File

@ -630,7 +630,8 @@ int CMenu::main(void)
{
_hideMain();
_about();
if(m_exit)break;
if(m_exit)
break;
_showMain();
}
else if (m_btnMgr.selected(m_mainBtnDVD))

View File

@ -13,6 +13,141 @@ static inline int loopNum(int i, int s)
return i < 0 ? (s - (-i % s)) % s : i % s;
}
static bool __FileExists(const char *path)
{
FILE *f = fopen(path, "rb");
if (f != 0)
{
//gprintf("File \"%s\" exists\n", path);
fclose(f);
return true;
}
return false;
}
static bool _saveExists(const char *path)
{
DIR *d;
d = opendir(path);
if(!d)
{
return false;
}
else
{
closedir(d);
return true;
}
}
bool CMenu::_TestEmuNand(int epart, const char *path, bool indept)
{
bool haveValidENand = true;
char basepath[64];
char testpath[MAX_FAT_PATH];
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[epart], path);
DIR *d;
d = opendir(basepath);
if(!d)
haveValidENand = false;
else
closedir(d);
if(indept)
{
// Check Wiimotes && Region
snprintf(testpath, sizeof(testpath), "%s:%s/shared2/sys/SYSCONF", DeviceName[epart], path);
if(!__FileExists(testpath))
{
//gprintf("Nandcheck: SYSCONF not found\n");
haveValidENand = false;
}
snprintf(testpath, sizeof(testpath), "%s:%s/title/00000001/00000002/data/setting.txt", DeviceName[epart], path);
if(!__FileExists(testpath))
{
//gprintf("Nandcheck: setting.txt not found\n");
haveValidENand = false;
}
// Check Mii's
snprintf(testpath, sizeof(testpath), "%s:%s/shared2/menu/FaceLib/RFL_DB.dat", DeviceName[epart], path);
if(!__FileExists(testpath))
{
//gprintf("Nandcheck: Mii's not found\n");
haveValidENand = false;
}
}
return haveValidENand;
}
int CMenu::_FindEmuPart(string *emuPath, int part, bool searchvalid)
{
int emuPartition = -1;
string tmpPath;
if(m_current_view == COVERFLOW_CHANNEL)
{
emuPartition = m_cfg.getInt("NAND", "partition", 0);
tmpPath = m_cfg.getString("NAND", "path", "");
if(tmpPath.size() == 0)
{
m_cfg.setString("NAND", "path", STDEMU_DIR);
tmpPath = m_cfg.getString("NAND", "path", STDEMU_DIR);
}
}
else if(m_current_view == COVERFLOW_USB)
{
emuPartition = m_cfg.getInt("GAMES", "savepartition", -1);
if(emuPartition == -1)
emuPartition = m_cfg.getInt("NAND", "partition", 0);
tmpPath = m_cfg.getString("GAMES", "savepath", m_cfg.getString("NAND", "path", ""));
if(tmpPath.size() == 0)
{
m_cfg.setString("GAMES", "savepath", STDEMU_DIR);
tmpPath = m_cfg.getString("GAMES", "savepath", STDEMU_DIR);
}
}
if(_TestEmuNand(emuPartition, tmpPath.c_str(), true) && DeviceHandler::Instance()->IsInserted(emuPartition) && DeviceHandler::Instance()->GetFSType(emuPartition) == PART_FS_FAT)
{
*emuPath = tmpPath;
return emuPartition;
}
else
{
emuPartition = part;
bool fllscn = emuPartition == -1;
for(u8 i = emuPartition; i <= USB8; ++i)
{
if(!DeviceHandler::Instance()->IsInserted(emuPartition) || DeviceHandler::Instance()->GetFSType(emuPartition) != PART_FS_FAT)
{
emuPartition++;
continue;
}
else
{
if(_TestEmuNand(i, tmpPath.c_str(), true) || searchvalid)
{
if(m_current_view == COVERFLOW_CHANNEL)
m_cfg.setInt("NAND", "partition", i);
else if(m_current_view == COVERFLOW_USB)
m_cfg.setInt("GAMES", "savepartition", i);
*emuPath = tmpPath;
m_cfg.save();
return i;
}
}
if(i == USB8 && !fllscn)
{
i = 0;
fllscn = true;
}
}
}
return -1;
}
bool CMenu::_checkSave(string id, bool nand)
{
@ -39,29 +174,11 @@ bool CMenu::_checkSave(string id, bool nand)
return true;
}
static bool _saveExists(const char *path)
{
DIR *d;
d = opendir(path);
if(!d)
{
return false;
}
else
{
closedir(d);
return true;
}
}
void CMenu::_enableNandEmu(bool fromconfig)
{
_cfNeedsUpdate();
bool disable = true;
int i = m_current_view == COVERFLOW_CHANNEL && min(max(0, m_cfg.getInt("NAND", "emulation", 0)), (int)ARRAY_SIZE(CMenu::_NandEmu) - 1);
gprintf("i: %i\n",i);
if (i>0 || m_current_view != COVERFLOW_CHANNEL)
disable = false;
bool disable = m_cfg.getBool("NAND", "disable", true) && m_current_view == COVERFLOW_CHANNEL && !m_tempView;
if(!disable)
{
Nand::Instance()->Disable_Emu();
@ -69,7 +186,7 @@ void CMenu::_enableNandEmu(bool fromconfig)
iosinfo_t * iosInfo = cIOSInfo::GetInfo(mainIOS);
if (iosInfo->version > 6)
isD2XnewerThanV6 = true;
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0) > 0)
if(m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool("NAND", "disable", true) && !m_tempView)
Nand::Instance()->Enable_Emu();
u8 limiter = 0;
s8 direction = m_btnMgr.selected(m_configBtnPartitionP) ? 1 : -1;
@ -88,6 +205,9 @@ void CMenu::_enableNandEmu(bool fromconfig)
}
gprintf("Next item: %s\n", DeviceName[currentPartition]);
if(m_tempView)
m_cfg.setInt("GAMES", "savepartition", currentPartition);
else
m_cfg.setInt(_domainFromView(), "partition", currentPartition);
}
}
@ -139,6 +259,7 @@ void CMenu::_hideNandEmu(bool instant)
m_btnMgr.hide(m_nandemuLblNandDump, instant);
m_btnMgr.hide(m_nandemuBtnNandDump, instant);
m_btnMgr.hide(m_nandemuBtnExtract, instant);
m_btnMgr.hide(m_nandemuBtnPartition, instant);
m_btnMgr.hide(m_nandemuBtnDisable, instant);
m_btnMgr.hide(m_nandemuLblInit, instant);
}
@ -150,12 +271,16 @@ void CMenu::_showNandEmu(void)
m_btnMgr.show(m_nandemuLblTitle);
m_btnMgr.show(m_nandemuBtnBack);
int i;
if((m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_USB) && !m_locked)
if(((m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool("NAND", "disable", true)) || m_current_view == COVERFLOW_USB) && !m_locked)
{
m_btnMgr.show(m_nandemuLblEmulation);
m_btnMgr.show(m_nandemuLblEmulationVal);
m_btnMgr.show(m_nandemuBtnEmulationP);
m_btnMgr.show(m_nandemuBtnEmulationM);
}
if((m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_USB) && !m_locked)
{
m_btnMgr.show(m_nandemuLblSaveDump);
m_btnMgr.show(m_nandemuBtnAll);
m_btnMgr.show(m_nandemuBtnMissing);
@ -347,19 +472,16 @@ int CMenu::_FlashSave(string gameId)
int CMenu::_AutoExtractSave(string gameId)
{
int emuPartition = m_cfg.getInt("GAMES", "savepartition", m_cfg.getInt("NAND", "partition", 0));
string emuPath;
if(m_current_view == COVERFLOW_CHANNEL)
m_partRequest = m_cfg.getInt("NAND", "partition", -1);
else if(m_current_view == COVERFLOW_USB)
m_partRequest = m_cfg.getInt("GAMES", "savepartition", -1);
int emuPartition = _FindEmuPart(&emuPath, m_partRequest, false);
if(emuPartition < 0)
emuPartition = 0;
char basepath[MAX_FAT_PATH];
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], m_cfg.getString("GAMES", "savepath", m_cfg.getString("NAND", "path", "")).c_str());
Nand::Instance()->CreatePath("%s/import", basepath);
Nand::Instance()->CreatePath("%s/meta", basepath);
Nand::Instance()->CreatePath("%s/shared1", basepath);
Nand::Instance()->CreatePath("%s/shared2", basepath);
Nand::Instance()->CreatePath("%s/sys", basepath);
Nand::Instance()->CreatePath("%s/title", basepath);
Nand::Instance()->CreatePath("%s/ticket", basepath);
Nand::Instance()->CreatePath("%s/tmp", basepath);
emuPartition = _FindEmuPart(&emuPath, m_partRequest, true);
if(!_checkSave(gameId, true))
return 1;
@ -413,6 +535,16 @@ int CMenu::_AutoExtractSave(string gameId)
}
else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnDisable)))
{
char basepath[MAX_FAT_PATH];
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str());
Nand::Instance()->CreatePath("%s/import", basepath);
Nand::Instance()->CreatePath("%s/meta", basepath);
Nand::Instance()->CreatePath("%s/shared1", basepath);
Nand::Instance()->CreatePath("%s/shared2", basepath);
Nand::Instance()->CreatePath("%s/sys", basepath);
Nand::Instance()->CreatePath("%s/title", basepath);
Nand::Instance()->CreatePath("%s/ticket", basepath);
Nand::Instance()->CreatePath("%s/tmp", basepath);
_hideNandEmu();
return 0;
}
@ -455,15 +587,19 @@ int CMenu::_AutoCreateNand(void)
{
lwp_t thread = 0;
SetupInput();
string emuPath;
m_thrdStop = false;
m_thrdMessageAdded = false;
m_nandext = false;
m_tempView = false;
m_btnMgr.setText(m_nandemuBtnExtract, _t("cfgne5", L"Extract NAND"));
m_btnMgr.setText(m_nandemuBtnDisable, _t("cfgne22", L"Disable NAND Emulation"));
m_btnMgr.setText(m_nandemuBtnPartition, _t("cfgne31", L"Select Partition"));
m_btnMgr.setText(m_nandemuLblInit, _t("cfgne23", L"Welcome to WiiFlow. I have not found a valid NAND for NAND Emulation. Click Extract to extract your NAND, or click disable to disable NAND Emulation."));
m_btnMgr.show(m_nandemuBtnExtract);
m_btnMgr.show(m_nandemuBtnDisable);
m_btnMgr.show(m_nandemuBtnPartition);
m_btnMgr.show(m_nandemuLblInit);
while(true)
@ -474,6 +610,7 @@ int CMenu::_AutoCreateNand(void)
m_fulldump = true;
m_btnMgr.hide(m_nandemuBtnExtract);
m_btnMgr.hide(m_nandemuBtnDisable);
m_btnMgr.hide(m_nandemuBtnPartition);
m_btnMgr.hide(m_nandemuLblInit);
m_btnMgr.show(m_nandemuLblTitle);
m_btnMgr.show(m_nandfilePBar);
@ -496,6 +633,23 @@ int CMenu::_AutoCreateNand(void)
_hideNandEmu();
return 0;
}
else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnPartition)))
{
if(m_current_view == COVERFLOW_USB)
{
m_tempView = true;
m_current_view = COVERFLOW_CHANNEL;
}
_hideNandEmu();
_config(1);
if(m_tempView)
{
m_current_view = COVERFLOW_USB;
m_tempView = false;
return 0;
}
return 1;
}
else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnBack)))
{
m_cfg.save();
@ -535,23 +689,16 @@ int CMenu::_NandFlasher(void *obj)
{
CMenu &m = *(CMenu *)obj;
string emuPath;
int emuPartition = -1;
char source[MAX_FAT_PATH];
char dest[ISFS_MAXPATH];
if(m.m_current_view == COVERFLOW_CHANNEL)
{
emuPartition = m.m_cfg.getInt("NAND", "partition", 0);
emuPath = m.m_cfg.getString("NAND", "path", "");
}
m.m_partRequest = m.m_cfg.getInt("NAND", "partition", -1);
else if(m.m_current_view == COVERFLOW_USB)
{
emuPartition = m.m_cfg.getInt("GAMES", "savepartition", -1);
if(emuPartition == -1)
emuPartition = m.m_cfg.getInt("NAND", "partition", 0);
emuPath = m.m_cfg.getString("GAMES", "savepath", m.m_cfg.getString("NAND", "path", ""));
}
m.m_partRequest = m.m_cfg.getInt("GAMES", "savepartition", -1);
int emuPartition = m._FindEmuPart(&emuPath, m.m_partRequest, false);
int flashID = m.m_saveExtGameId.c_str()[0] << 24 | m.m_saveExtGameId.c_str()[1] << 16 | m.m_saveExtGameId.c_str()[2] << 8 | m.m_saveExtGameId.c_str()[3];
if(_saveExists(sfmt("%s:%s/title/00010000/%08x", DeviceName[emuPartition], emuPath.c_str(), flashID).c_str()))
@ -584,7 +731,6 @@ int CMenu::_NandDumper(void *obj)
CMenu &m = *(CMenu *)obj;
string emuPath;
int emuPartition = -1;
bool emuPartIsValid = false;
m.m_nandext = false;
m.m_sgdump = false;
m.m_dumpsize = 0;
@ -594,67 +740,25 @@ int CMenu::_NandDumper(void *obj)
Nand::Instance()->ResetCounters();
if(m.m_current_view == COVERFLOW_CHANNEL)
{
emuPartition = m.m_cfg.getInt("NAND", "partition", 0);
emuPath = m.m_cfg.getString("NAND", "path", "");
}
m.m_partRequest = m.m_cfg.getInt("NAND", "partition", -1);
else if(m.m_current_view == COVERFLOW_USB)
{
emuPartition = m.m_cfg.getInt("GAMES", "savepartition", -1);
if(emuPartition == -1)
emuPartition = m.m_cfg.getInt("NAND", "partition", 0);
emuPath = m.m_cfg.getString("GAMES", "savepath", m.m_cfg.getString("NAND", "path", ""));
}
m.m_partRequest = m.m_cfg.getInt("GAMES", "savepartition", -1);
for(u8 i = emuPartition; i <= USB8; ++i)
{
if(!DeviceHandler::Instance()->IsInserted(emuPartition) || DeviceHandler::Instance()->GetFSType(emuPartition) != PART_FS_FAT)
{
emuPartition++;
continue;
}
else
{
emuPartIsValid = true;
if(m.m_current_view == COVERFLOW_CHANNEL)
m.m_cfg.setInt("NAND", "partition", emuPartition);
else if(m.m_current_view == COVERFLOW_USB)
m.m_cfg.setInt("GAMES", "savepartition", emuPartition);
break;
}
}
emuPartition = m._FindEmuPart(&emuPath, m.m_partRequest, true);
if(!emuPartIsValid)
if(emuPartition < 0)
{
m.error(m._t("cfgne8", L"No valid FAT partition found for NAND Emulation!"));
m.m_thrdWorking = false;
m.m_btnMgr.hide(m.m_nandfilePBar);
m.m_btnMgr.hide(m.m_nandfileLblMessage);
LWP_MutexLock(m.m_mutex);
m._setDumpMsg(m._t("cfgne20", L"Extraction failed!"), 1.f, 1.f);
LWP_MutexUnlock(m.m_mutex);
m._hideNandEmu();
//m.m_thrdWorking = false;
//m.m_btnMgr.hide(m.m_nandfilePBar);
//m.m_btnMgr.hide(m.m_nandfileLblMessage);
//LWP_MutexLock(m.m_mutex);
//m._setDumpMsg(m._t("cfgne20", L"Extraction failed!"), 1.f, 1.f);
//LWP_MutexUnlock(m.m_mutex);
//m._hideNandEmu();
return 0;
}
if(emuPath.size() == 0)
{
Nand::Instance()->CreatePath("%s:/wiiflow", DeviceName[emuPartition]);
Nand::Instance()->CreatePath("%s:/wiiflow/nandemu", DeviceName[emuPartition]);
if(m.m_current_view == COVERFLOW_CHANNEL)
{
m.m_cfg.setString("NAND", "path", STDEMU_DIR);
emuPath = m.m_cfg.getString("NAND", "path", STDEMU_DIR);
}
else if(m.m_current_view == COVERFLOW_USB)
{
m.m_cfg.setString("GAMES", "savepath", STDEMU_DIR);
emuPath = m.m_cfg.getString("GAMES", "savepath", STDEMU_DIR);
}
}
m.m_cfg.save();
char basepath[64];
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str());
@ -757,7 +861,8 @@ void CMenu::_initNandEmuMenu(CMenu::SThemeData &theme)
m_nandemuBtnNandDump = _addButton(theme, "NANDEMU/NAND_DUMP_BTN", theme.btnFont, L"", 350, 310, 250, 56, theme.btnFontColor);
m_nandemuBtnBack = _addButton(theme, "NANDEMU/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 56, theme.btnFontColor);
m_nandemuBtnExtract = _addButton(theme, "NANDEMU/EXTRACT", theme.titleFont, L"", 72, 180, 496, 56, theme.titleFontColor);
m_nandemuBtnDisable = _addButton(theme, "NANDEMU/DISABLE", theme.titleFont, L"", 72, 290, 496, 56, theme.titleFontColor);
m_nandemuBtnDisable = _addButton(theme, "NANDEMU/DISABLE", theme.titleFont, L"", 72, 270, 496, 56, theme.titleFontColor);
m_nandemuBtnPartition = _addButton(theme, "NANDEMU/PARTITION", theme.titleFont, L"", 72, 360, 496, 56, theme.titleFontColor);
m_nandemuLblInit = _addLabel(theme, "NANDEMU/INIT", theme.lblFont, L"", 40, 40, 560, 140, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
_setHideAnim(m_nandemuLblTitle, "NANDEMU/TITLE", 0, 0, -2.f, 0.f);
@ -779,6 +884,7 @@ void CMenu::_initNandEmuMenu(CMenu::SThemeData &theme)
_setHideAnim(m_nandemuBtnNandDump, "NANDEMU/NAND_DUMP_BTN", 0, 0, -2.f, 0.f);
_setHideAnim(m_nandemuBtnBack, "NANDEMU/BACK_BTN", 0, 0, -2.f, 0.f);
_setHideAnim(m_nandemuBtnExtract, "NANDEMU/EXTRACT", 0, 0, -2.f, 0.f);
_setHideAnim(m_nandemuBtnPartition, "NANDEMU/PARTITION", 0, 0, -2.f, 0.f);
_setHideAnim(m_nandemuBtnDisable, "NANDEMU/DISABLE", 0, 0, -2.f, 0.f);
_setHideAnim(m_nandemuLblInit, "NANDEMU/INIT", 100, 0, -2.f, 0.f);

View File

@ -51,8 +51,9 @@ void BufferCircle::SetBufferBlockSize(int size)
for(int i = 0; i < Size(); i++)
{
if(SoundBuffer[i] != NULL)
MEM1_free(SoundBuffer[i]);
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
MEM2_free(SoundBuffer[i]);
SoundBuffer[i] = (u8 *)MEM2_memalign(32, BufferBlockSize);
BufferSize[i] = 0;
BufferReady[i] = false;
}
@ -72,7 +73,7 @@ void BufferCircle::Resize(int size)
for(int i = oldSize; i < Size(); i++)
{
if(BufferBlockSize > 0)
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
SoundBuffer[i] = (u8 *)MEM2_memalign(32, BufferBlockSize);
else
SoundBuffer[i] = NULL;
BufferSize[i] = 0;
@ -86,7 +87,7 @@ void BufferCircle::RemoveBuffer(int pos)
return;
if(SoundBuffer[pos] != NULL)
MEM1_free(SoundBuffer[pos]);
MEM2_free(SoundBuffer[pos]);
SoundBuffer.erase(SoundBuffer.begin()+pos);
BufferSize.erase(BufferSize.begin()+pos);
@ -108,7 +109,7 @@ void BufferCircle::FreeBuffer()
for(int i = 0; i < Size(); i++)
{
if(SoundBuffer[i] != NULL)
MEM1_free(SoundBuffer[i]);
MEM2_free(SoundBuffer[i]);
BufferSize[i] = 0;
BufferReady[i] = false;
}

View File

@ -43,7 +43,7 @@ SoundHandler::SoundHandler()
for(u32 i = 0; i < MAX_DECODERS; ++i)
DecoderList[i] = NULL;
ThreadStack = (u8 *)MEM1_alloc(32768);
ThreadStack = (u8 *)MEM2_memalign(32, 32768);
if(!ThreadStack)
return;
@ -61,7 +61,7 @@ SoundHandler::~SoundHandler()
SoundThread = LWP_THREAD_NULL;
if(ThreadStack != NULL)
{
MEM1_free(ThreadStack);
MEM2_free(ThreadStack);
ThreadStack = NULL;
}