-added custom wii game directory support via the ini option

"wii_games_dir", if you want for example use usb:/games, then set
this option to "%s:/games" etc, subdirs and stuff are supported
(issue 165)
This commit is contained in:
fix94.1 2013-02-07 12:25:39 +00:00
parent 1680e303c7
commit b2b2fe2ea1
9 changed files with 26 additions and 86 deletions

View File

@ -2,22 +2,7 @@
#include "text.hpp" #include "text.hpp"
#include "memory/mem2.hpp" #include "memory/mem2.hpp"
int currentStr = 0;
static char fmt_buffer[MAX_USES][MAX_MSG_SIZE];
static char general_buffer[MAX_MSG_SIZE * 2]; static char general_buffer[MAX_MSG_SIZE * 2];
// Simplified use of sprintf
char *fmt(const char *format, ...)
{
va_list va;
va_start(va, format);
currentStr = (currentStr + 1) % MAX_USES;
vsnprintf(fmt_buffer[currentStr], MAX_MSG_SIZE - 1, format, va);
fmt_buffer[currentStr][MAX_MSG_SIZE - 1] = '\0';
va_end(va);
return fmt_buffer[currentStr];
}
string sfmt(const char *format, ...) string sfmt(const char *format, ...)
{ {
va_list va; va_list va;
@ -458,47 +443,3 @@ string rtrim(string s)
s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end()); s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
return s; return s;
} }
void Asciify( wchar_t *str )
{
const wchar_t *ptr = str;
wchar_t *ctr = str;
while(*ptr != '\0')
{
switch(*ptr)
{
case 0x14c:
*ctr = 0x4f;
break;
}
*ctr = *ptr;
++ptr;
++ctr;
}
*ctr = '\0';
}
void Asciify2( char *str )
{
u8 i=0;
for( i=0; i < strlen(str); ++i )
{
if( str[i] < 0x20 || str[i] > 0x7F )
str[i] = '_';
else {
switch( str[i] )
{
case '*':
case '\"':
case '|':
case '<':
case '>':
case '?':
case ':':
str[i] = '_';
break;
}
}
}
}

View File

@ -5,6 +5,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "fmt.h"
#include "FreeTypeGX.h" #include "FreeTypeGX.h"
#include "video.hpp" #include "video.hpp"
#include "wstringEx/wstringEx.hpp" #include "wstringEx/wstringEx.hpp"
@ -56,12 +57,6 @@ private:
// Nothing to do with CText. Q&D helpers for string formating. // Nothing to do with CText. Q&D helpers for string formating.
enum {
MAX_MSG_SIZE = 1024,
MAX_USES = 8,
};
char *fmt(const char *format, ...);
std::string sfmt(const char *format, ...); std::string sfmt(const char *format, ...);
wstringEx wfmt(const wstringEx &format, ...); wstringEx wfmt(const wstringEx &format, ...);
bool checkFmt(const wstringEx &ref, const wstringEx &format); bool checkFmt(const wstringEx &ref, const wstringEx &format);
@ -73,7 +68,5 @@ std::string upperCase(std::string text);
std::string lowerCase(std::string text); std::string lowerCase(std::string text);
std::string ltrim(std::string s); std::string ltrim(std::string s);
std::string rtrim(std::string s); std::string rtrim(std::string s);
void Asciify( wchar_t *str );
void Asciify2( char *str );
#endif // !defined(__TEXT_HPP) #endif // !defined(__TEXT_HPP)

View File

@ -73,7 +73,7 @@ int SetupARGV(struct __argv * args)
if(!args) if(!args)
return -1; return -1;
bzero(args, sizeof(struct __argv)); memset(args, 0, sizeof(struct __argv));
args->argvMagic = ARGV_MAGIC; args->argvMagic = ARGV_MAGIC;
u32 argc = 0; u32 argc = 0;

View File

@ -157,7 +157,7 @@ int frag_remap(FragList *ff, FragList *log, FragList *phy)
int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size) int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
{ {
char fname[1024]; char fname[1024];
bzero(fname, 1024); memset(fname, 0, sizeof(fname));
u32 length = strlen(path); u32 length = strlen(path);
strcpy(fname, path); strcpy(fname, path);
@ -166,7 +166,7 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
if(fname[length-1] > '0' && fname[length-1] < '9') if(fname[length-1] > '0' && fname[length-1] < '9')
return 0; return 0;
bool isWBFS = wbfs_part_fs != PART_FS_WBFS && strcasestr(strrchr(fname,'.'), ".wbfs") != 0; bool isWBFS = strrchr(fname,'.') != NULL && strcasecmp(strrchr(fname,'.'), ".wbfs") == 0;
struct stat st; struct stat st;
FragList *fs = MEM1_lo_alloc(sizeof(FragList)); FragList *fs = MEM1_lo_alloc(sizeof(FragList));
@ -237,7 +237,6 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
for (j = 0; j < fs->num; j++) for (j = 0; j < fs->num; j++)
fs->frag[j].sector += wbfs_part_lba; fs->frag[j].sector += wbfs_part_lba;
} }
frag_concat(fa, fs); frag_concat(fa, fs);
} }

View File

@ -294,9 +294,9 @@ s32 GCDump::DumpGame()
char *FSTNameOff = NULL; char *FSTNameOff = NULL;
char folder[MAX_FAT_PATH]; char folder[MAX_FAT_PATH];
bzero(folder, MAX_FAT_PATH); memset(folder, 0, MAX_FAT_PATH);
char gamepath[MAX_FAT_PATH]; char gamepath[MAX_FAT_PATH];
bzero(gamepath, MAX_FAT_PATH); memset(gamepath, 0, MAX_FAT_PATH);
while(!gamedone) while(!gamedone)
{ {

View File

@ -23,6 +23,7 @@ bool reset = false;
bool shutdown = false; bool shutdown = false;
volatile u8 ExitOption = 0; volatile u8 ExitOption = 0;
const char *NeekPath = NULL; const char *NeekPath = NULL;
char wii_games_dir[64];
void __Wpad_PowerCallback() void __Wpad_PowerCallback()
{ {
@ -37,9 +38,7 @@ void Open_Inputs(void)
/* Set POWER button callback */ /* Set POWER button callback */
WPAD_SetPowerButtonCallback(__Wpad_PowerCallback); WPAD_SetPowerButtonCallback(__Wpad_PowerCallback);
WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
WPAD_SetIdleTimeout(60 * 2); // idle after 2 minutes WPAD_SetIdleTimeout(60 * 2); // idle after 2 minutes
} }

View File

@ -50,6 +50,7 @@ extern bool useMainIOS;
extern volatile bool NANDemuView; extern volatile bool NANDemuView;
extern volatile bool networkInit; extern volatile bool networkInit;
extern u8 currentPartition; extern u8 currentPartition;
extern char wii_games_dir[];
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -23,12 +23,13 @@
#include "fileOps/fileOps.h" #include "fileOps/fileOps.h"
#include "gecko/gecko.hpp" #include "gecko/gecko.hpp"
#include "libwbfs/libwbfs.h" #include "libwbfs/libwbfs.h"
#include "loader/utils.h"
#include "loader/sys.h"
#include "gui/fmt.h"
#define MAX_FAT_PATH 1024
#define TITLE_LEN 64 #define TITLE_LEN 64
char wbfs_fs_drive[16]; char wbfs_fs_drive[16];
char wbfs_ext_dir[16] = "/wbfs";
char invalid_path[] = "/\\:|<>?*\"'"; char invalid_path[] = "/\\:|<>?*\"'";
split_info_t split; split_info_t split;
@ -176,22 +177,22 @@ s32 WBFS_Ext_AddGame(progress_callback_t spinner, void *spinner_data)
char *cleantitle; char *cleantitle;
char folder[MAX_FAT_PATH]; char folder[MAX_FAT_PATH];
bzero(folder, MAX_FAT_PATH); memset(folder, 0, MAX_FAT_PATH);
char gamepath[MAX_FAT_PATH]; char gamepath[MAX_FAT_PATH];
bzero(gamepath, MAX_FAT_PATH); memset(gamepath, 0, MAX_FAT_PATH);
Disc_ReadHeader(&header); Disc_ReadHeader(&header);
asprintf(&cleantitle, header.title); asprintf(&cleantitle, header.title);
for(cp = strpbrk(cleantitle, illegal); cp; cp = strpbrk(cp, illegal)) for(cp = strpbrk(cleantitle, illegal); cp; cp = strpbrk(cp, illegal))
*cp = '_'; *cp = '_';
snprintf(folder, sizeof(folder), "%s%s", wbfs_fs_drive, wbfs_ext_dir); strncpy(folder, fmt(wii_games_dir, wbfs_fs_drive), sizeof(folder));
fsop_MakeFolder(folder); fsop_MakeFolder(folder);
snprintf(folder, sizeof(folder), "%s%s/%s [%s]", wbfs_fs_drive, wbfs_ext_dir, cleantitle, header.id); strncpy(folder, fmt("%s/%s [%s]", folder, cleantitle, header.id), sizeof(folder));
fsop_MakeFolder(folder); fsop_MakeFolder(folder);
free(cleantitle); free(cleantitle);
snprintf(gamepath, sizeof(gamepath), "%s/%s.wbfs", folder, header.id); strncpy(gamepath, fmt("%s/%s.wbfs", folder, header.id), sizeof(gamepath));
u64 size = (u64)143432*2*0x8000ULL; u64 size = (u64)143432*2*0x8000ULL;
u32 n_sector = size / 512; u32 n_sector = size / 512;

View File

@ -204,6 +204,12 @@ void CMenu::init()
useMainIOS = m_cfg.getBool("GENERAL", "force_cios_load", false); useMainIOS = m_cfg.getBool("GENERAL", "force_cios_load", false);
if(prevCios != mainIOS || prevForceCIOS != useMainIOS) if(prevCios != mainIOS || prevForceCIOS != useMainIOS)
InternalSave.SaveIOS(mainIOS, useMainIOS); InternalSave.SaveIOS(mainIOS, useMainIOS);
/* Our Wii game dir */
memset(wii_games_dir, 0, 64);
strncpy(wii_games_dir, m_cfg.getString("GENERAL", "wii_games_dir", GAMES_DIR).c_str(), 64);
if(strncmp(wii_games_dir, "%s:/", 4) != 0)
strcpy(wii_games_dir, GAMES_DIR);
gprintf("Wii Games Directory: %s\n", wii_games_dir);
/* Do our USB HDD Checks */ /* Do our USB HDD Checks */
bool onUSB = m_cfg.getBool("GENERAL", "data_on_usb", strncmp(drive, "usb", 3) == 0); bool onUSB = m_cfg.getBool("GENERAL", "data_on_usb", strncmp(drive, "usb", 3) == 0);
drive = check; //reset the drive variable for the check drive = check; //reset the drive variable for the check