mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 09:05:06 +01:00
* setting.txt and SYSCONF for temp region nand emulation are now readed from nand (not written to)
* It will now create the path to setting.txt and SYSCONF if they don't exist * It will now create setting.txt and SYSCONF if they don't exist
This commit is contained in:
parent
36f75ca434
commit
a6709f71cf
@ -1,5 +1,5 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2011 by Miigotu
|
* Copyright (C) 2011 by Miigotu for wiiflow 2011
|
||||||
* (C) 2012 by OverjoY for Wiiflow-mod
|
* (C) 2012 by OverjoY for Wiiflow-mod
|
||||||
*
|
*
|
||||||
* Rewritten code from Mighty Channels and Triiforce
|
* Rewritten code from Mighty Channels and Triiforce
|
||||||
@ -25,7 +25,6 @@
|
|||||||
*
|
*
|
||||||
* Nand/Emulation Handling Class
|
* Nand/Emulation Handling Class
|
||||||
*
|
*
|
||||||
* for wiiflow 2011
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -33,16 +32,21 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
#include "nand.hpp"
|
#include "nand.hpp"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
#include "mem2.hpp"
|
#include "mem2.hpp"
|
||||||
|
|
||||||
u8 *confbuffer;
|
#define SYSCONFPATH "/shared2/sys/SYSCONF"
|
||||||
|
#define TXTPATH "/title/00000001/00000002/data/setting.txt"
|
||||||
|
|
||||||
|
u8 *confbuffer ATTRIBUTE_ALIGN(32);
|
||||||
u8 CCode[0x1008];
|
u8 CCode[0x1008];
|
||||||
char SCode[4];
|
char SCode[4];
|
||||||
char *txtbuffer;
|
char *txtbuffer ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
config_header *cfg_hdr;
|
config_header *cfg_hdr;
|
||||||
|
|
||||||
@ -232,21 +236,28 @@ s32 Nand::__configread(void)
|
|||||||
txtbuffer = (char *)MEM2_alloc(0x100);
|
txtbuffer = (char *)MEM2_alloc(0x100);
|
||||||
cfg_hdr = (config_header *)NULL;
|
cfg_hdr = (config_header *)NULL;
|
||||||
|
|
||||||
FILE *f = fopen(cfgpath, "rb");
|
ISFS_Deinitialize();
|
||||||
if(f)
|
ISFS_Initialize();
|
||||||
{
|
|
||||||
fread(confbuffer, 1, 0x4000, f);
|
s32 fd = IOS_Open(SYSCONFPATH, IPC_OPEN_READ);
|
||||||
gprintf("SYSCONF readed from: %s \n", cfgpath);
|
if(fd < 0)
|
||||||
fclose(f);
|
return 0;
|
||||||
}
|
|
||||||
|
s32 ret = IOS_Read(fd, confbuffer, 0x4000);
|
||||||
|
if(ret < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
IOS_Close(fd);
|
||||||
|
|
||||||
|
fd = IOS_Open(TXTPATH, IPC_OPEN_READ);
|
||||||
|
if(fd < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ret = IOS_Read(fd, txtbuffer, 0x100);
|
||||||
|
if(ret < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
f = fopen(settxtpath, "rb");
|
IOS_Close(fd);
|
||||||
if(f)
|
|
||||||
{
|
|
||||||
fread(txtbuffer, 1, 0x100, f);
|
|
||||||
gprintf("setting.txt readed from: %s \n", settxtpath);
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg_hdr = (config_header *)confbuffer;
|
cfg_hdr = (config_header *)confbuffer;
|
||||||
|
|
||||||
@ -264,7 +275,7 @@ s32 Nand::__configwrite(void)
|
|||||||
{
|
{
|
||||||
if(configloaded)
|
if(configloaded)
|
||||||
{
|
{
|
||||||
__Dec_Enc_TB();
|
__Dec_Enc_TB();
|
||||||
|
|
||||||
if(!tbdec)
|
if(!tbdec)
|
||||||
{
|
{
|
||||||
@ -272,15 +283,15 @@ s32 Nand::__configwrite(void)
|
|||||||
if(f)
|
if(f)
|
||||||
{
|
{
|
||||||
fwrite(confbuffer, 1, 0x4000, f);
|
fwrite(confbuffer, 1, 0x4000, f);
|
||||||
gprintf("SYSCONF written to: %s \n", cfgpath);
|
gprintf("SYSCONF written to:\"%s\"\n", cfgpath);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
f = fopen(settxtpath, "wb");
|
f = fopen(settxtpath, "wb");
|
||||||
if(f)
|
if(f)
|
||||||
{
|
{
|
||||||
fwrite(txtbuffer, 1, 0x100, f);
|
fwrite(txtbuffer, 1, 0x100, f);
|
||||||
gprintf("setting.txt written to: %s \n", settxtpath);
|
gprintf("setting.txt written to: \"%s\"\n", settxtpath);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,11 +345,11 @@ u32 Nand::__configsetsetting(const char *item, const char *val)
|
|||||||
curstrt = strchr(curitem, '=');
|
curstrt = strchr(curitem, '=');
|
||||||
curend = strchr(curitem, 0x0d);
|
curend = strchr(curitem, 0x0d);
|
||||||
|
|
||||||
if( curstrt && curend )
|
if(curstrt && curend)
|
||||||
{
|
{
|
||||||
curstrt += 1;
|
curstrt += 1;
|
||||||
u32 len = curend - curstrt;
|
u32 len = curend - curstrt;
|
||||||
if( strlen( val ) > len )
|
if(strlen(val) > len)
|
||||||
{
|
{
|
||||||
static char buffer[0x100];
|
static char buffer[0x100];
|
||||||
u32 nlen;
|
u32 nlen;
|
||||||
@ -360,13 +371,50 @@ u32 Nand::__configsetsetting(const char *item, const char *val)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Nand::Do_Region_Change(string id, char *path)
|
void Nand::__CreatePath(const char *path, ...)
|
||||||
{
|
{
|
||||||
bzero(cfgpath, MAX_FAT_PATH);
|
char *folder = NULL;
|
||||||
bzero(settxtpath, MAX_FAT_PATH);
|
va_list args;
|
||||||
|
va_start(args, path);
|
||||||
|
if((vasprintf(&folder, path, args) >= 0) && folder)
|
||||||
|
{
|
||||||
|
DIR *d;
|
||||||
|
|
||||||
|
d = opendir(folder);
|
||||||
|
if(!d)
|
||||||
|
{
|
||||||
|
gprintf("Creating folder: \"%s\"\n", folder);
|
||||||
|
makedir(folder);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gprintf("Folder \"%s\" exists\n", folder);
|
||||||
|
closedir(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
va_end(args);
|
||||||
|
SAFE_FREE(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 Nand::CreateConfig(const char *path)
|
||||||
|
{
|
||||||
|
__CreatePath(path);
|
||||||
|
__CreatePath("%s/shared2", path);
|
||||||
|
__CreatePath("%s/shared2/sys", path);
|
||||||
|
__CreatePath("%s/title", path);
|
||||||
|
__CreatePath("%s/title/00000001", path);
|
||||||
|
__CreatePath("%s/title/00000001/00000002", path);
|
||||||
|
__CreatePath("%s/title/00000001/00000002/data", path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 Nand::Do_Region_Change(string id, const char *path)
|
||||||
|
{
|
||||||
|
bzero(cfgpath, ISFS_MAXPATH);
|
||||||
|
bzero(settxtpath, ISFS_MAXPATH);
|
||||||
|
|
||||||
snprintf(cfgpath, sizeof(cfgpath), "%s/shared2/sys/SYSCONF", path);
|
snprintf(cfgpath, sizeof(cfgpath), "%s%s", path, SYSCONFPATH);
|
||||||
snprintf(settxtpath, sizeof(settxtpath), "%s/title/00000001/00000002/data/setting.txt", path);
|
snprintf(settxtpath, sizeof(settxtpath), "%s%s", path, TXTPATH);
|
||||||
|
|
||||||
if(__configread())
|
if(__configread())
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,8 @@ class Nand
|
|||||||
|
|
||||||
void Set_NandPath(string path);
|
void Set_NandPath(string path);
|
||||||
|
|
||||||
s32 Do_Region_Change(string id, char *path);
|
s32 CreateConfig(const char *path);
|
||||||
|
s32 Do_Region_Change(string id, const char *path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Nand() : MountedDevice(0), EmuDevice(REAL_NAND), Disabled(true), Partition(0), FullMode(0x100), NandPath() {}
|
Nand() : MountedDevice(0), EmuDevice(REAL_NAND), Disabled(true), Partition(0), FullMode(0x100), NandPath() {}
|
||||||
@ -74,6 +75,8 @@ class Nand
|
|||||||
u32 __configsetbyte(const char *item, u8 val);
|
u32 __configsetbyte(const char *item, u8 val);
|
||||||
u32 __configsetbigarray(const char *item, void *val, u32 size);
|
u32 __configsetbigarray(const char *item, void *val, u32 size);
|
||||||
u32 __configsetsetting(const char *item, const char *val);
|
u32 __configsetsetting(const char *item, const char *val);
|
||||||
|
void __CreatePath(const char *path, ...);
|
||||||
|
|
||||||
|
|
||||||
u32 MountedDevice;
|
u32 MountedDevice;
|
||||||
u32 EmuDevice;
|
u32 EmuDevice;
|
||||||
|
@ -1014,7 +1014,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
|||||||
}
|
}
|
||||||
if(emuSave > 2)
|
if(emuSave > 2)
|
||||||
{
|
{
|
||||||
//Nand::Instance()->CreateConfig(basepath); // TODO: Write config files if they don't excist
|
Nand::Instance()->CreateConfig(basepath);
|
||||||
Nand::Instance()->Do_Region_Change(id, basepath);
|
Nand::Instance()->Do_Region_Change(id, basepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user