*Found and fixed bug in the CleanUpTest source

*Merging CleanUp source into main.

NOTE: You might not want to update right away because there might still be some issues. New issue reports to this are of course welcome ;).
This commit is contained in:
dimok321 2009-06-04 22:13:39 +00:00
parent 8a2c5ee2ff
commit c2a20e4c83
17 changed files with 4397 additions and 4399 deletions

File diff suppressed because one or more lines are too long

2438
source/PromptWindows.cpp Normal file

File diff suppressed because it is too large Load Diff

25
source/PromptWindows.h Normal file
View File

@ -0,0 +1,25 @@
/****************************************************************************
* PromptWindows
* USB Loader GX 2009
*
* PromptWindows.h
***************************************************************************/
#ifndef _PROMPTWINDOWS_H_
#define _PROMPTWINDOWS_H_
#include "partition.h"
void WindowCredits();
int OnScreenKeyboard(char * var, u32 maxlen, int min);
int WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, const char *btn3Label, const char *btn4Label);
int WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, const char *btn3Label, const char *btn4Label);
int GameWindowPrompt();
int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait);
int FormatingPartition(const char *title, partitionEntry *entry);
int NetworkInitPromp(int choice2);
int ProgressWindow(const char *title, const char *msg);
int ProgressDownloadWindow(int choice2);
int ProgressUpdateWindow();
#endif

1341
source/Settings.cpp Normal file

File diff suppressed because it is too large Load Diff

14
source/Settings.h Normal file
View File

@ -0,0 +1,14 @@
/****************************************************************************
* Settings
* USB Loader GX 2009
*
* settings.h
***************************************************************************/
#ifndef _SETTINGS_H_
#define _SETTINGS_H_
int MenuSettings();
int GameSettings(struct discHdr * header);
#endif

View File

@ -30,7 +30,7 @@ u8 viChoice = 0;
u8 iosChoice = 0; u8 iosChoice = 0;
u8 parentalcontrolChoice = 0; u8 parentalcontrolChoice = 0;
u8 xflip = 0; u8 xflip = 0;
u8 sort = 0; u8 sort = 0;
u8 fave = 0; u8 fave = 0;
u8 qboot = 0; u8 qboot = 0;
u8 wsprompt = 0; u8 wsprompt = 0;
@ -253,7 +253,7 @@ void CFG_Default(int widescreen) // -1 = non forced Mode
THEME.clock_r = 138; THEME.clock_r = 138;
THEME.clock_g = 138; THEME.clock_g = 138;
THEME.clock_b = 138; THEME.clock_b = 138;
THEME.settingsTxt_r = 0; THEME.settingsTxt_r = 0;
THEME.settingsTxt_g = 0; THEME.settingsTxt_g = 0;
THEME.settingsTxt_b = 0; THEME.settingsTxt_b = 0;
THEME.cover_x = 26; THEME.cover_x = 26;
@ -309,8 +309,8 @@ void CFG_Default(int widescreen) // -1 = non forced Mode
THEME.favorite_x = 4; THEME.favorite_x = 4;
THEME.favorite_y = 13; THEME.favorite_y = 13;
THEME.abc_x = 36; THEME.abc_x = 36;
THEME.abc_y = 13; THEME.abc_y = 13;
THEME.list_x = 100; THEME.list_x = 100;
THEME.list_y = 13; THEME.list_y = 13;
THEME.grid_x = 132; THEME.grid_x = 132;
THEME.grid_y = 13; THEME.grid_y = 13;
@ -1156,7 +1156,7 @@ bool cfg_save_global()// save global settings
fprintf(f, "volume = %d\n ", Settings.volume); fprintf(f, "volume = %d\n ", Settings.volume);
fprintf(f, "tooltips = %d\n ", Settings.tooltips); fprintf(f, "tooltips = %d\n ", Settings.tooltips);
fprintf(f, "password = %s\n ", Settings.unlockCode); fprintf(f, "password = %s\n ", Settings.unlockCode);
fprintf(f, "sort = %d\n ", Settings.sort); fprintf(f, "sort = %d\n ", Settings.sort);
fprintf(f, "fave = %d\n ", Settings.fave); fprintf(f, "fave = %d\n ", Settings.fave);
fprintf(f, "cios = %d\n ", Settings.cios); fprintf(f, "cios = %d\n ", Settings.cios);
fprintf(f, "keyset = %d\n ", Settings.keyset); fprintf(f, "keyset = %d\n ", Settings.keyset);
@ -1521,7 +1521,7 @@ void CFG_Load(void)
snprintf(pathname, sizeof(pathname), "%stitles.txt", Settings.titlestxt_path); snprintf(pathname, sizeof(pathname), "%stitles.txt", Settings.titlestxt_path);
cfg_parsefile(pathname, &title_set); cfg_parsefile(pathname, &title_set);
cfg_parsefile("SD:/config/GXGameSettings.cfg", &parental_set); cfg_parsefile("SD:/config/GXGameSettings.cfg", &parental_set);
// load per-game settings // load per-game settings

174
source/getentries.cpp Normal file
View File

@ -0,0 +1,174 @@
#include <string.h>
#include "wbfs.h"
#include "cfg.h"
#include "main.h"
struct discHdr * gameList;
u32 gameCnt;
s32 gameSelected, gameStart;
/****************************************************************************
* EntryCmp
***************************************************************************/
s32 __Menu_EntryCmp(const void *a, const void *b)
{
struct discHdr *hdr1 = (struct discHdr *)a;
struct discHdr *hdr2 = (struct discHdr *)b;
/* Compare strings */
return stricmp(get_title(hdr1), get_title(hdr2));
}
s32 __Menu_EntryCmpCount(const void *a, const void *b)
{
s32 ret;
struct discHdr *hdr1 = (struct discHdr *)a;
struct discHdr *hdr2 = (struct discHdr *)b;
/* Compare Play Count */
u16 count1 = 0;
u16 count2 = 0;
struct Game_NUM* game_num1 = CFG_get_game_num(hdr1->id);
struct Game_NUM* game_num2 = CFG_get_game_num(hdr2->id);
if (game_num1) count1 = game_num1->count;
if (game_num2) count2 = game_num2->count;
ret = (s32) (count2-count1);
if (ret == 0) return stricmp(get_title(hdr1), get_title(hdr2));
return ret;
}
/****************************************************************************
* Get Gamelist
***************************************************************************/
s32 __Menu_GetEntries(void)
{
struct discHdr *buffer = NULL;
struct discHdr *buffer2 = NULL;
struct discHdr *header = NULL;
u32 cnt, len;
s32 ret;
/* Get list length */
ret = WBFS_GetCount(&cnt);
if (ret < 0)
return ret;
/* Buffer length */
len = sizeof(struct discHdr) * cnt;
/* Allocate memory */
buffer = (struct discHdr *)memalign(32, len);
if (!buffer)
return -1;
/* Clear buffer */
memset(buffer, 0, len);
/* Get header list */
ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr));
if (ret < 0) {
if(buffer) free(buffer);
return ret;
}
/* Filters */
if (Settings.fave) {
u32 cnt2 = 0;
for (u32 i = 0; i < cnt; i++)
{
header = &buffer[i];
u8 favorite = 0;
struct Game_NUM* game_num = CFG_get_game_num(header->id);
if (game_num) {
favorite = game_num->favorite;
}
if (favorite==1) {
buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr));
if (!buffer2)
{
free(buffer);
return -1;
}
memcpy((buffer2 + cnt2), (buffer + i), sizeof(struct discHdr));
cnt2++;
}
}
if (buffer2) {
free(buffer);
buffer = buffer2;
buffer2 = NULL;
} else {
memset(buffer, 0, len);
}
cnt = cnt2;
}
if (Settings.parentalcontrol && !Settings.godmode) {
u32 cnt2 = 0;
for (u32 i = 0; i < cnt; i++)
{
header = &buffer[i];
if (get_block(header) < Settings.parentalcontrol) {
buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr));
if (!buffer2)
{
free(buffer);
return -1;
}
memcpy((buffer2 + cnt2), (buffer + i), sizeof(struct discHdr));
cnt2++;
}
}
if (buffer2) {
free(buffer);
buffer = buffer2;
buffer2 = NULL;
} else {
memset(buffer, 0, len);
}
cnt = cnt2;
}
if (Settings.sort==pcount) {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount);
}
else {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
}
/* Free memory */
if (gameList)
free(gameList);
/* Set values */
gameList = buffer;
buffer = NULL;
gameCnt = cnt;
/* Reset variables */
gameSelected = gameStart = 0;
return 0;
}

13
source/getentries.h Normal file
View File

@ -0,0 +1,13 @@
/****************************************************************************
* PromptWindows
* USB Loader GX 2009
*
* PromptWindows.h
***************************************************************************/
#ifndef _GETENTRIES_H_
#define _GETENTRIES_H_
s32 __Menu_GetEntries(void);
#endif

View File

@ -4,13 +4,37 @@
#include <gccore.h> #include <gccore.h>
#include <fat.h> #include <fat.h>
#include <sys/dir.h> #include <sys/dir.h>
#include <dirent.h>
#include <unistd.h> #include <unistd.h>
#include "listfiles.h" #include "listfiles.h"
char alldirfiles[300][70];
char filename[80]; char filename[80];
bool findfile(const char * filename, const char * path)
{
DIR *dir;
struct dirent *file;
dir = opendir(path);
char temp[11];
while ((file = readdir(dir)))
{
snprintf(temp,sizeof(temp),"%s",file->d_name);
if (!strncmpi(temp,filename,11))
{
//WindowPrompt(path, filename,"go" ,0);
closedir(dir);
return true;
}
}
closedir(dir);
return false;
}
s32 filenamescmp(const void *a, const void *b) s32 filenamescmp(const void *a, const void *b)
{ {

View File

@ -6,8 +6,7 @@ extern "C"
{ {
#endif #endif
char alldirfiles[300][70]; bool findfile(const char * filename, const char * path);
int GetFiles(char * filespath); int GetFiles(char * filespath);

File diff suppressed because it is too large Load Diff

View File

@ -9,21 +9,15 @@
#ifndef _MENU_H_ #ifndef _MENU_H_
#define _MENU_H_ #define _MENU_H_
#include <ogcsys.h> #include <ogcsys.h>
#include "main.h"
#include "cfg.h"
#ifdef __cplusplus
//extern "C"
//{
#endif
void InitGUIThreads(void); void InitGUIThreads(void);
void ExitGUIThreads(void); void ExitGUIThreads(void);
#ifdef __cplusplus
//} int MainMenu (int menuitem);
#endif
int MainMenu (int menuitem);
void wiilight(int enable);
int GameSettings(struct discHdr *);
enum enum
{ {
MENU_EXIT = -1, MENU_EXIT = -1,

View File

@ -15,6 +15,14 @@
/* Constants */ /* Constants */
#define CERTS_LEN 0x280 #define CERTS_LEN 0x280
//Wiilight stuff
static vu32 *_wiilight_reg = (u32*)0xCD0000C0;
void wiilight(int enable) { // Toggle wiilight (thanks Bool for wiilight source)
u32 val = (*_wiilight_reg&~0x20);
if(enable && Settings.wiilight) val |= 0x20;
*_wiilight_reg=val;
}
/* Variables */ /* Variables */
static const char certs_fs[] ATTRIBUTE_ALIGN(32) = "/sys/cert.sys"; static const char certs_fs[] ATTRIBUTE_ALIGN(32) = "/sys/cert.sys";
u8 shutdown = 0; u8 shutdown = 0;
@ -87,7 +95,7 @@ int Sys_IosReload(int IOS)
if(ret < 0) { if(ret < 0) {
return ret; return ret;
} }
if(IOS == 249 || IOS == 222 || IOS == 223) { if(IOS == 249 || IOS == 222 || IOS == 223) {
ret = WBFS_Init(WBFS_DEVICE_USB); ret = WBFS_Init(WBFS_DEVICE_USB);
if(ret>=0) if(ret>=0)

View File

@ -1,5 +1,8 @@
#ifndef _SYS_H_ #ifndef _SYS_H_
#define _SYS_H_ #define _SYS_H_
void wiilight(int enable);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"

View File

@ -528,4 +528,11 @@ s32 WBFS_RenameGame(u8 *discid, const void *newname)
return ret; return ret;
return 0; return 0;
} }
f32 WBFS_EstimeGameSize(void)
{
return wbfs_estimate_disc(hdd, __WBFS_ReadDVD, NULL, ONLY_GAME_PARTITION);
}

View File

@ -33,6 +33,7 @@ s32 WBFS_RemoveGame(u8 *);
s32 WBFS_GameSize(u8 *, f32 *); s32 WBFS_GameSize(u8 *, f32 *);
s32 WBFS_DiskSpace(f32 *, f32 *); s32 WBFS_DiskSpace(f32 *, f32 *);
s32 WBFS_RenameGame(u8 *, const void *); s32 WBFS_RenameGame(u8 *, const void *);
f32 WBFS_EstimeGameSize(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -7,7 +7,7 @@
/* Constants */ /* Constants */
#define MAX_WIIMOTES 4 #define MAX_WIIMOTES 4
extern u8 shutdown; extern u8 shutdown;
void __Wpad_PowerCallback(s32 chan) void __Wpad_PowerCallback(s32 chan)
{ {