*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

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

@ -10,20 +10,14 @@
#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
//}
#endif
int MainMenu (int menuitem); 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;

View File

@ -1,6 +1,9 @@
#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

@ -529,3 +529,10 @@ s32 WBFS_RenameGame(u8 *discid, const void *newname)
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
} }