imported rev0

This commit is contained in:
Christopher Roy Bratusek 2012-04-07 19:35:07 +02:00
parent 0fd4e0a3c5
commit f445948857
45 changed files with 1292 additions and 1829 deletions

View File

@ -228,6 +228,8 @@ int BootGameCubeHomebrew()
ES_GetTicketViews(BC, &view, 1);
int ret = ES_LaunchTitle(BC, &view);
if(ret < 0)
LoadHBC();
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@ -39,11 +39,11 @@ int MenuSettingsFile()
int i = 0;
bool firstRun = true;
int focus = 0;
int last_category = Options.last_category;
bool quick_start = Options.quick_start;
bool show_all = Options.show_all;
int device_icon = Options.device_icon;
int last_category = Options.last_category;
bool quick_start = Options.quick_start;
bool show_all = Options.show_all;
int device_icon = Options.device_icon;
bool childlock;
if(strcasecmp(Settings.code,"NULL") == 0 )
childlock = 0;
@ -56,17 +56,17 @@ int MenuSettingsFile()
device_dat = "SD";
else if(Settings.device_dat == "usb1")
device_dat = "USB";
OptionList options;
sprintf(options.name[i++], tr("Theme"));
sprintf(options.name[i++], tr("Language"));
sprintf(options.name[i++], tr("Font"));
sprintf(options.name[i++], tr("Storage Device"));
sprintf(options.name[i++], tr("Slide Effect"));
sprintf(options.name[i++], tr("Category remember"));
sprintf(options.name[i++], tr("Number of Apps"));
sprintf(options.name[i++], tr("Quick Start"));
sprintf(options.name[i++], tr("Show All"));
sprintf(options.name[i++], tr("Storage Device"));
sprintf(options.name[i++], tr("Device icon"));
sprintf(options.name[i++], tr("Childlock"));
sprintf(options.name[i++], tr("Navigation key exchange"));
@ -115,7 +115,7 @@ int MenuSettingsFile()
optionBrowser.SetPosition(0, 108);
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
optionBrowser.SetCol2Position(280);
optionBrowser.Col2Scroll(280);
optionBrowser.Col2Scroll(230);
HaltGui();
GuiWindow w(screenwidth, screenheight);
@ -130,7 +130,7 @@ int MenuSettingsFile()
while(menu == MENU_NONE)
{
usleep(100);
ret = optionBrowser.GetChangedOption();
ret2 = optionBrowser.GetClickedOption();
@ -146,7 +146,7 @@ int MenuSettingsFile()
change = 5;
sprintf (options.value[ret], "%i", change);
break;
case CATEGORY_REMEMBER:
change = last_category;
change++;
@ -154,7 +154,7 @@ int MenuSettingsFile()
change = AvailableCategory.categories.size();
last_category = change;
break;
case NUMBER_OF_APPS:
change = atoi(options.value[ret]);
change++;
@ -162,15 +162,15 @@ int MenuSettingsFile()
change = 5;
sprintf (options.value[ret], "%i", change);
break;
case QUICK_START:
quick_start = 1;
break;
case SHOW_ALL:
show_all = 1;
break;
case DEVICE_ICON:
change = device_icon;
change++;
@ -178,12 +178,12 @@ int MenuSettingsFile()
change = 3;
device_icon = change;
break;
case STORAGE_DEVICE:
device_dat = "USB";
sprintf (options.value[STORAGE_DEVICE], device_dat.c_str());
break;
case NAVIGATION:
navigation = 1;
break;
@ -191,7 +191,7 @@ int MenuSettingsFile()
HaltResumeGui();
optionBrowser.TriggerUpdate();
}
if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) || PAD_ButtonsDown(0) & PAD_BUTTON_LEFT)
{
change = 0;
@ -204,7 +204,7 @@ int MenuSettingsFile()
change = 0;
sprintf (options.value[ret], "%i", change);
break;
case CATEGORY_REMEMBER:
change = last_category;
change--;
@ -212,7 +212,7 @@ int MenuSettingsFile()
change = 0;
last_category = change;
break;
case NUMBER_OF_APPS:
change = atoi(options.value[ret]);
change--;
@ -220,15 +220,15 @@ int MenuSettingsFile()
change = 4;
sprintf (options.value[ret], "%i", change);
break;
case QUICK_START:
quick_start = 0;
break;
case SHOW_ALL:
show_all = 0;
break;
case DEVICE_ICON:
change = device_icon;
change--;
@ -236,12 +236,12 @@ int MenuSettingsFile()
change = 0;
device_icon = change;
break;
case STORAGE_DEVICE:
device_dat = "SD";
sprintf (options.value[STORAGE_DEVICE], device_dat.c_str());
break;
case NAVIGATION:
navigation = 0;
break;
@ -249,58 +249,58 @@ int MenuSettingsFile()
HaltResumeGui();
optionBrowser.TriggerUpdate();
}
if(ret2 != -1)
{
// einstellungen temporär speichern
/******************************************************************************/
Options.temp_theme = options.value[THEME];
Options.temp_language = options.value[LANGUAGE];
Options.temp_language = options.value[LANGUAGE];
Options.temp_font = options.value[FONT];
temp_slide_effect = atoi(options.value[SLIDE_EFFECT]);
temp_last_category = last_category;
temp_apps = atoi(options.value[NUMBER_OF_APPS]);
temp_apps = atoi(options.value[NUMBER_OF_APPS]);
temp_quick_start = quick_start;
temp_show_all = show_all;
temp_device_icon = device_icon;
temp_device_dat = device_dat;
temp_navigation = navigation;
/******************************************************************************/
// in weitere einstellungen gehen
switch (ret2)
{
case THEME:
menu = MENU_SETTINGS_THEME;
break;
case LANGUAGE:
menu = MENU_SETTINGS_LANGUAGE;
break;
case FONT:
menu = MENU_SETTINGS_FONT;
break;
case CHILDLOCK:
menu = MENU_SETTINGS_CHILDLOCK;
break;
case DISPLAY:
menu = MENU_SETTINGS_DISPLAY;
break;
case NETWORK:
menu = MENU_SETTINGS_NETWORK;
break;
}
}
if(firstRun)
{
firstRun = false;
if(Options.temp_last_setting == 1)
{
sprintf (options.value[THEME], Options.temp_theme.c_str());
@ -311,11 +311,11 @@ int MenuSettingsFile()
sprintf (options.value[STORAGE_DEVICE], temp_device_dat.c_str());
sprintf (options.value[DISPLAY], " ");
sprintf (options.value[NETWORK], " ");
last_category = temp_last_category;
quick_start = temp_quick_start;
show_all = temp_show_all;
device_icon = temp_device_icon;
last_category = temp_last_category;
quick_start = temp_quick_start;
show_all = temp_show_all;
device_icon = temp_device_icon;
if(strcasecmp(Options.temp_code,"NULL") == 0 )
childlock = 0;
else
@ -338,27 +338,27 @@ int MenuSettingsFile()
if(change != -1)
{
change = -1;
if(!last_category)
sprintf (options.value[CATEGORY_REMEMBER], tr("last"));
else
sprintf (options.value[CATEGORY_REMEMBER], AvailableCategory.categories[last_category - 1].c_str());
if(!quick_start)
sprintf (options.value[QUICK_START], tr("No"));
else
sprintf (options.value[QUICK_START], tr("Yes"));
if(!show_all)
sprintf (options.value[SHOW_ALL], tr("No"));
else
sprintf (options.value[SHOW_ALL], tr("Yes"));
if(!childlock)
sprintf (options.value[CHILDLOCK], tr("No"));
else
sprintf (options.value[CHILDLOCK], tr("Yes"));
if(device_icon == 0)
sprintf (options.value[DEVICE_ICON], tr("Off"));
else if(device_icon == 1)
@ -367,15 +367,15 @@ int MenuSettingsFile()
sprintf (options.value[DEVICE_ICON], tr("Dialog box"));
else if(device_icon == 3)
sprintf (options.value[DEVICE_ICON], tr("All"));
if(!navigation)
sprintf (options.value[NAVIGATION], tr("No"));
else
sprintf (options.value[NAVIGATION], tr("Yes"));
optionBrowser.TriggerUpdate();
}
if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B)
{
if(focus == 0)
@ -390,7 +390,7 @@ int MenuSettingsFile()
}
HaltResumeGui();
}
if(backBtn.GetState() == STATE_CLICKED)
{
strcpy (Options.temp_code, Settings.code);
@ -398,7 +398,7 @@ int MenuSettingsFile()
Options.temp_newrevtext = Options.newrevtext;
menu = MENU_SETTINGS;
}
if(saveBtn.GetState() == STATE_CLICKED)
{
// Theme ändern
@ -407,17 +407,17 @@ int MenuSettingsFile()
sprintf (Options.theme, options.value[THEME]);
DefaultTheme();
if(stricmp(Options.theme, tr("STANDARD")) != 0)
theme(Settings.device_dat + ":/config/HBF/themes/" + Options.theme + "/");
theme(Settings.device_dat + ":/config/Homebrew Filter/themes/" + Options.theme + "/");
// Cursor und Hintergrund ändern
#ifdef HW_RVL
pointer = new GuiImageData(Theme.player_point);
#endif
mainWindow->Remove(bgImg);
bgImg = new GuiImage(new GuiImageData(Theme.background));
mainWindow->Append(bgImg);
}
// Schriftart ändern
if(stricmp(Options.font, options.value[FONT]) != 0 || GetMenuSettingsFontDL())
{
@ -427,64 +427,64 @@ int MenuSettingsFile()
SetFont();
ResumeGui();
}
strcpy(Settings.code, Options.temp_code);
Options.slide_effect = atoi(options.value[SLIDE_EFFECT]);
Options.last_category = last_category;
Options.slide_effect = atoi(options.value[SLIDE_EFFECT]);
Options.last_category = last_category;
Options.apps = atoi(options.value[NUMBER_OF_APPS]);
Options.quick_start = quick_start;
Options.show_all = show_all;
Options.device_icon = device_icon;
device_dat = options.value[STORAGE_DEVICE];
device_dat = options.value[STORAGE_DEVICE];
Options.navigation = navigation;
Options.network = Options.temp_network;
Options.newrevtext = Options.temp_newrevtext;
if(device_dat == "SD")
Settings.device_dat = "sd1";
else if(device_dat == "USB")
Settings.device_dat = "usb1";
// Sprache ändern zum schluss wegen STANDARD
if(stricmp(Options.language, options.value[LANGUAGE]) != 0 || GetMenuSettingsLanguageDL())
{
sprintf (Options.language, options.value[LANGUAGE]);
bool theme = 0, language = 0, font = 0;
if(stricmp(Options.theme, tr("STANDARD")) == 0)
theme = 1;
if(stricmp(Options.language, tr("STANDARD")) == 0)
language = 1;
if(stricmp(Options.font, tr("STANDARD")) == 0)
font = 1;
/*********************************************************************/
if(stricmp(Options.language, tr("STANDARD")) == 0)
translate();
else
ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + Options.language + ".lang");
ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + Options.language + ".lang");
/*********************************************************************/
AvailableCategory.categories[0] = tr(Settings.category_name_all);
if(theme)
sprintf(Options.theme, tr("STANDARD"));
if(language)
sprintf(Options.language, tr("STANDARD"));
if(font)
sprintf(Options.font, tr("STANDARD"));
}
menu = MENU_SETTINGS;
}
}
HaltGui();
Options.temp_last_setting = 0;
mainWindow->Remove(&optionBrowser);
mainWindow->Remove(&w);
return menu;

View File

@ -46,7 +46,7 @@ int MenuSettingsFont()
DIR *dirHandle;
struct dirent * dirEntry;
dirHandle = opendir(check_path(Settings.device_dat + ":/config/HBF/Fonts").c_str());
dirHandle = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Fonts").c_str());
if (dirHandle) {
while (0 != (dirEntry = readdir(dirHandle)))
{

View File

@ -46,7 +46,7 @@ int MenuSettingsLanguage()
DIR *dirHandle;
struct dirent * dirEntry;
dirHandle = opendir(check_path(Settings.device_dat + ":/config/HBF/Languages").c_str());
dirHandle = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Languages").c_str());
if (dirHandle)
{
while (0 != (dirEntry = readdir(dirHandle)))

View File

@ -46,7 +46,7 @@ int MenuSettingsTheme()
DIR *dirHandle;
struct dirent * dirEntry;
dirHandle = opendir(check_path(Settings.device_dat + ":/config/HBF/Themes").c_str());
dirHandle = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Themes").c_str());
if (dirHandle) {
while (0 != (dirEntry = readdir(dirHandle)))
{

View File

@ -21,12 +21,12 @@ enum
THEME,
LANGUAGE,
FONT,
STORAGE_DEVICE,
SLIDE_EFFECT,
CATEGORY_REMEMBER,
NUMBER_OF_APPS,
QUICK_START,
SHOW_ALL,
STORAGE_DEVICE,
DEVICE_ICON,
CHILDLOCK,
NAVIGATION,
@ -41,4 +41,4 @@ enum
DISPLAY_BOTTOM,
DISPLAY_LEFT,
DISPLAY_RIGHT
};
};

View File

@ -20,7 +20,7 @@ void Category_rename_move(string button)
Settings.unassigned = false;
else
Settings.unassigned = true;
Settings.current_page = 1;
}
// Kategorie umbenennen
@ -29,7 +29,7 @@ void Category_rename_move(string button)
char new_category_name[256];
sprintf (new_category_name, Settings.category_name.c_str());
OnScreenKeyboard(new_category_name, 256, false);
if(strcasecmp(new_category_name,"NULL") != 0 )
KategorieUmbenennen(Settings.category_name, new_category_name);
}
@ -55,29 +55,22 @@ void Category_rename_move(string button)
void Next_Category()
{
int prev_cat = Settings.current_category;
Settings.current_category++;
if(Settings.current_category > (signed)AvailableCategory.categories.size() -1)
Settings.current_category = 0;
// Kategorie Alle nur anzeigen, wenn aktiviert oder keine andere vorhanden ist
if(!Options.show_all && Settings.current_category == 0 && AvailableCategory.categories.size() -1 > 0)
Settings.current_category++;
if(Settings.current_category != prev_cat)
{
if(Settings.current_category > (signed)AvailableCategory.categories.size() -1)
Settings.current_category = 0;
// Kategorie Alle nur anzeigen, wenn aktiviert oder keine andere vorhanden ist
if(!Options.show_all && Settings.current_category == 0 && AvailableCategory.categories.size() -1 > 0)
Settings.current_category++;
Settings.current_page = 1;
Settings.unassigned = false;
if(Settings.current_category != 0)
copy_app_in_category();
Settings.Apps_from = EFFECT_SLIDE_RIGHT;
Settings.Apps_to = EFFECT_SLIDE_LEFT;
}
Settings.current_page = 1;
Settings.unassigned = false;
if(Settings.current_category != 0)
copy_app_in_category();
Settings.Apps_from = EFFECT_SLIDE_RIGHT;
Settings.Apps_to = EFFECT_SLIDE_LEFT;
}
void Previous_Category()
@ -87,16 +80,16 @@ void Previous_Category()
// Kategorie Alle nur anzeigen, wenn aktiviert oder keine andere vorhanden ist
if(!Options.show_all && Settings.current_category == 0)
Settings.current_category--;
if(Settings.current_category < 0)
Settings.current_category = AvailableCategory.categories.size() -1;
Settings.current_page = 1;
Settings.unassigned = false;
if(Settings.current_category != 0)
copy_app_in_category();
Settings.Apps_from = EFFECT_SLIDE_LEFT;
Settings.Apps_to = EFFECT_SLIDE_RIGHT;
}
@ -116,9 +109,9 @@ void AppEraseDelate(int choice, const char* name, const char* foldername)
if( eraseDir(name) )
{
DeleteDir(foldername);
app_list();
if(Settings.current_category != 0)
copy_app_in_category();
else

View File

@ -54,7 +54,7 @@ void CheckVersion(void)
{
if(Settings.checkrev == -1)
{
struct block file = downloadfile("http://download.tuxfamily.org/hbf/DOL/revisions");
struct block file = downloadfile("http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/version.txt");
if (file.data != NULL)
{
revs = (char*)file.data;

View File

@ -16,7 +16,6 @@ u8 *data = (u8 *)0x92000000;
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern bool boot_buffer;
extern bool wiiload;
/*** Extern functions ***/
extern void ResumeGui();
@ -114,7 +113,7 @@ void HaltTcpThread()
static void * tcp_callback(void *arg)
{
u32 offset, read, size, client, uncfilesize;
u32 offset, read, size, ip, client, uncfilesize;
u8 *bfr[READ_SIZE];
bool compress = false;
struct sockaddr_in addr;
@ -207,14 +206,16 @@ static void * tcp_callback(void *arg)
Percent = 100.0f * offset/size;
progressbarImg->SetSize(Percent*3.27f, 38);
char buffer[6];
char buffer[7];
sprintf(buffer, "%i %%", (int)Percent);
PercentTxt->SetText(buffer);
}
usleep(100000);
net_close(client);
net_close(listen);
// retry:
if(compress)
{
u8 *zdata = (u8 *) malloc(uncfilesize);
@ -222,14 +223,17 @@ static void * tcp_callback(void *arg)
return NULL;
uLongf zdatalen = uncfilesize;
int res = uncompress (zdata, &zdatalen, data, (uLongf)size);
if (res != Z_OK)
{
free(zdata);
// fprintf (stderr, "error decompressing data: %d\n", res);
return NULL;
// debug("error");
// PercentTxt->SetText("error");
// return NULL;
// goto retry;
// fprintf (stderr, "error decompressing data: %d\n", res);
// return NULL;
}
else
{
@ -252,7 +256,6 @@ static void * tcp_callback(void *arg)
ResumeGui();
boot_buffer = true;
wiiload = true;
break;
}
}

View File

@ -12,7 +12,7 @@ bool readrev = true;
string CheckNewVersions()
{
string revs = "error";
struct block file = downloadfile("http://download.tuxfamily.org/hbf/DOL/revisions");
struct block file = downloadfile("http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/version.txt");
if (file.data != NULL)
{
revs = (char*)file.data;
@ -24,7 +24,7 @@ string CheckNewVersions()
string NewVersionsText()
{
string text = "error";
struct block file = downloadfile("http://download.tuxfamily.org/hbf/DOL/updates");
struct block file = downloadfile("http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/version_text.txt");
if (file.data != NULL)
{
text = (char*)file.data;
@ -38,9 +38,9 @@ string new_update(string rev, string filename)
{
char url[100];
if(rev == "Beta")
sprintf(url, "http://download.tuxfamily.org/hbf/DOL/Beta/%s", filename.c_str());
sprintf(url, "http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/Beta/%s", filename.c_str());
else
sprintf(url, "http://download.tuxfamily.org/hbf/DOL/rev%s/%s", rev.c_str(), filename.c_str());
sprintf(url, "http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/rev%s/%s", rev.c_str(), filename.c_str());
file = downloadfile(url);
if (file.data && file.size > 0)
@ -56,7 +56,7 @@ string new_update(string rev, string filename)
string new_theme(string themename, string filename)
{
char url[100];
sprintf(url, "http://www.nanolx.org/hbf/Themes/%s/%s", themename.c_str(), filename.c_str());
sprintf(url, "http://hbf.hamachi-mp.bplaced.net/Themes/%s/%s", themename.c_str(), filename.c_str());
file = downloadfile(url);
if (file.data && file.size > 0)
@ -73,7 +73,7 @@ void update(string filename)
{
if (file.data && file.size > 0)
{
FILE * data = fopen((Settings.device_dat + ":/config/HBF/"+ filename).c_str(), "wb");
FILE * data = fopen((Settings.device_dat + ":/config/Homebrew Filter/"+ filename).c_str(), "wb");
if(data)
{
fwrite(file.data, 1, file.size, data);

View File

@ -3,20 +3,67 @@
#include <fstream>
#include "libwiigui/gui.h"
#include "main.h"
#include "menu.h"
#include "Menus/menus_command.h"
#include "Tools/copy_app_in_category.h"
#include "Tools/parser.h"
#include "Tools/textline.h"
#include "Tools/load_channel.h"
#include "Tools/SelectIos.h"
#include "Prompts/prompts.h"
#include "prompts.h"
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern bool boothomebrew;
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
extern void HaltResumeGui();
int ChoiceAppInfo(vector<homebrew_list> list, int i)
{
int menu = MENU_NONE;
again:
int choice;
if(Options.quick_start == 0)
choice = AppInfo(list[i].name.c_str(), list[i].foldername, list[i].icon);
else
choice = 1;
if(choice == 1) // App starten
{
Settings.forwarder_path = list[i].pathboot;
Settings.forwarder_arg = list[i].arg.c_str();
boothomebrew = true;
menu = MENU_EXIT;
}
else if(choice == 2) // App Einfügen
{
string app_in_kategorie = AddApp(list[i].name.c_str());
if( app_in_kategorie != "NULL" )
{
AppEinfuegen(app_in_kategorie, list[i].foldername.c_str());
copy_app_in_unassigned();
// temp_slide = false;
menu = MENU_MAIN;
}
}
else if(choice == 3 || choice == 4)
{
AppEraseDelate(choice, list[i].name.c_str(), list[i].foldername.c_str());
// temp_slide = false;
menu = MENU_MAIN;
}
else if(choice == 5)
{
MetaEdit(list[i].foldername);
// temp_slide = false;
goto again;
}
return menu;
}
/****************************************************************************
* AppInfo
*
@ -31,16 +78,26 @@ AppInfo(const char *title, string dir, u8* icon)
dir += "meta.xml";
string line, quelltext = "", version, coder, descriptionTxt;
ifstream in(dir.c_str());
while(getline(in, line))
quelltext = quelltext + line + "\n";
string space = " ";
version = tr("Version:") + space + parser(quelltext, "<version>", "</version>");
coder = tr("Coder:") + space + parser(quelltext, "<coder>", "</coder>");
descriptionTxt = parser(quelltext, "<long_description>", "</long_description>");
if(strcasecmp(title, "the homebrew channel") == 0)
{
string space = " ";
version = tr("Version:") + space + HBC_version;
coder = tr("Coder:") + space + "HBC Team";
descriptionTxt = "The Homebrew Channel is a channel for launching Wii homebrew applications. It will list homebrew applications stored and organised on an SD card or USB mass storage device in a nice little GUI, which you can very easily customise with descriptions and shiny little icons all by yourself. You can also launch applications via TCP (with a correctly configured PC) or a USBGecko. Both of those built in options make it extremely convenient for testing out new code, as well as a general purpose homebrew launcher.";
}
else
{
ifstream in(dir.c_str());
while(getline(in, line))
quelltext = quelltext + line + "\n";
string space = " ";
version = tr("Version:") + space + parser(quelltext, "<version>", "</version>");
coder = tr("Coder:") + space + parser(quelltext, "<coder>", "</coder>");
descriptionTxt = parser(quelltext, "<long_description>", "</long_description>");
}
GuiWindow promptWindow(520, 360);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
@ -57,10 +114,10 @@ AppInfo(const char *title, string dir, u8* icon)
GuiImage viewicon(&icon_data);
viewicon.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
viewicon.SetPosition(40, 54);
GuiImage * viewdevice = NULL;
if((Options.device_icon == 2 || Options.device_icon == 3) && (Settings.device == "sd_usb" || Settings.device == "all"))
if((Options.device_icon == 2 || Options.device_icon == 3) && Settings.device == "sd_usb")
{
bool icon = false;
if(strncmp(dir.c_str(), "sd", 2) == 0)
@ -73,12 +130,7 @@ AppInfo(const char *title, string dir, u8* icon)
viewdevice = new GuiImage(new GuiImageData(Theme.usb_inactive));
icon = true;
}
else if(strncmp(dir.c_str(), "dvd", 3) == 0)
{
viewdevice = new GuiImage(new GuiImageData(Theme.dvd_inactive));
icon = true;
}
if(icon)
{
viewdevice->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
@ -86,7 +138,7 @@ AppInfo(const char *title, string dir, u8* icon)
viewdevice->SetScale(0.8);
}
}
GuiText titleTxt(title, 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0, 20);
@ -105,19 +157,19 @@ AppInfo(const char *title, string dir, u8* icon)
int i = 0;
int y = 125;
int place = 25;
int number = 5;
GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
upTxt.SetFont(symbol_ttf, symbol_ttf_size);
upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
upTxt.SetPosition(0, y -20);
GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
downTxt.SetFont(symbol_ttf, symbol_ttf_size);
downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
downTxt.SetPosition(0, y + (place * (number-1)) + 15);
GuiText * Entrie[number];
for(i=0; i < number && i < (signed)description.line.size(); i++)
{
@ -138,7 +190,7 @@ AppInfo(const char *title, string dir, u8* icon)
GuiImage btn1Img(&btn);
GuiImage btn2Img(&btn);
GuiImage eraseImg(&btn);
// image over
GuiImageData cancelBtn_over(Theme.cancel_active);
GuiImage cancelBtnImgOver(&cancelBtn_over);
@ -150,18 +202,15 @@ AppInfo(const char *title, string dir, u8* icon)
GuiImage btn1ImgOver(&btn_over);
GuiImage btn2ImgOver(&btn_over);
GuiImage eraseImgOver(&btn_over);
// Edit
GuiButton edit(editBtn.GetWidth(), editBtn.GetHeight());
edit.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
if((Options.device_icon == 2 || Options.device_icon == 3) && (Settings.device == "sd_usb" || Settings.device == "all"))
edit.SetPosition(48, 15);
else
edit.SetPosition(10, 10);
edit.SetPosition(10, 10);
edit.SetImage(&editBtnImg);
edit.SetImageOver(&editBtnImgOver);
edit.SetTrigger(&trigA);
// Cancel
GuiButton cancel(cancelBtn.GetWidth(), cancelBtn.GetHeight());
cancel.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
@ -171,7 +220,7 @@ AppInfo(const char *title, string dir, u8* icon)
cancel.SetTrigger(&trigA);
cancel.SetTrigger(&trigB);
// cancel.SetState(STATE_SELECTED);
// Laden
GuiButton btn1(btn.GetWidth(), btn.GetHeight());
GuiText btn1Txt(tr("Loading"), 22, (GXColor){Theme.button_tiny_text_1, Theme.button_tiny_text_2, Theme.button_tiny_text_3, 255});
@ -229,7 +278,7 @@ AppInfo(const char *title, string dir, u8* icon)
startingAppName.erase(startingAppName.rfind("/"));
startingAppName.erase(0, startingAppName.rfind("/") +1);
sprintf(SelectIos, tr("Start with IOS %i (-/+)"), SearchAppIOS(startingAppName));
GuiText SelectIosTxt(SelectIos, 18, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
SelectIosTxt.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
SelectIosTxt.SetPosition(0, -15);
@ -239,20 +288,20 @@ AppInfo(const char *title, string dir, u8* icon)
promptWindow.Append(&versionTxt);
promptWindow.Append(&coderTxt);
promptWindow.Append(viewdevice);
for(int x=0; x < i; x++)
promptWindow.Append(Entrie[x]);
if((signed)description.line.size() >= number)
{
promptWindow.Append(&upTxt);
promptWindow.Append(&downTxt);
}
if(quelltext != "")
promptWindow.Append(&edit);
promptWindow.Append(&btn1);
if(strcasecmp(Settings.code,"NULL") == 0 && strncmp(dir.c_str(), "dvd", 3) != 0)
if(strcasecmp(title, "the homebrew channel") != 0 && strcasecmp(Settings.code,"NULL") == 0)
promptWindow.Append(&erase);
if(AvailableCategory.categories.size() != 1 && strcasecmp(Settings.code,"NULL") == 0)
promptWindow.Append(&btn2);
@ -276,14 +325,14 @@ AppInfo(const char *title, string dir, u8* icon)
if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP)
{
int z = description.text_up();
for(int x=0; x < i; x++)
Entrie[x]->SetText(description.line[x + z].c_str());
HaltResumeGui();
}
if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)
{
int z = description.text_down(number);
@ -291,7 +340,6 @@ AppInfo(const char *title, string dir, u8* icon)
for(int x=0; x < i; x++)
Entrie[x]->SetText(description.line[x + z].c_str());
HaltResumeGui();
}
@ -301,15 +349,14 @@ AppInfo(const char *title, string dir, u8* icon)
SelectIosTxt.SetText(SelectIos);
HaltResumeGui();
}
if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) || PAD_ButtonsDown(0) & PAD_TRIGGER_L)
{
sprintf(SelectIos, tr("Start with IOS %i (-/+)"), previousIos());
SelectIosTxt.SetText(SelectIos);
HaltResumeGui();
}
if(cancel.GetState() == STATE_CLICKED) // Zurück
choice = 0;
else if(btn1.GetState() == STATE_CLICKED) // Laden

View File

@ -22,16 +22,18 @@ int devicePrompt()
bool stop = false;
int device = -1;
GuiWindow promptWindow(232,64);
GuiWindow promptWindow(144,64);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
promptWindow.SetPosition(-135, 280);
if(Options.apps == 5)
promptWindow.SetPosition(-135, 307);
GuiTrigger trigA;
GuiTrigger trigB;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
// Hintergrund
GuiImageData dialogBox(Theme.choice_large);
GuiImageData dialogBox(Theme.choice);
GuiImage dialogBoxImg(&dialogBox);
// button data
@ -41,60 +43,38 @@ int devicePrompt()
GuiImageData usb_BtnImgDataOver(Theme.usb_active);
GuiImageData sd_usb_BtnImgData(Theme.sd_usb_inactive);
GuiImageData sd_usb_BtnImgDataOver(Theme.sd_usb_active);
GuiImageData dvd_BtnImgData(Theme.dvd_inactive);
GuiImageData dvd_BtnImgDataOver(Theme.dvd_active);
GuiImageData all_BtnImgData(Theme.all_inactive);
GuiImageData all_BtnImgDataOver(Theme.all_active);
// button
GuiImage sd_BtnImg(&sd_BtnImgData);
GuiImage usb_BtnImg(&usb_BtnImgData);
GuiImage sd_usb_BtnImg(&sd_usb_BtnImgData);
GuiImage dvd_BtnImg(&dvd_BtnImgData);
GuiImage all_BtnImg(&all_BtnImgData);
// button over
GuiImage sd_BtnImgOver(&sd_BtnImgDataOver);
GuiImage usb_BtnImgOver(&usb_BtnImgDataOver);
GuiImage sd_usb_BtnImgOver(&sd_usb_BtnImgDataOver);
GuiImage dvd_BtnImgOver(&dvd_BtnImgDataOver);
GuiImage all_BtnImgOver(&all_BtnImgDataOver);
GuiButton sd_Btn(sd_BtnImgData.GetWidth(), sd_BtnImgData.GetHeight());
sd_Btn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
sd_Btn.SetPosition(8, 0);
sd_Btn.SetImage(&sd_BtnImg);
sd_Btn.SetImageOver(&sd_BtnImgOver);
sd_Btn.SetTrigger(&trigA);
GuiButton usb_Btn(usb_BtnImgData.GetWidth(), usb_BtnImgData.GetHeight());
usb_Btn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
usb_Btn.SetPosition(52, 0);
usb_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
usb_Btn.SetPosition(0, 0);
usb_Btn.SetImage(&usb_BtnImg);
usb_Btn.SetImageOver(&usb_BtnImgOver);
usb_Btn.SetTrigger(&trigA);
GuiButton sd_usb_Btn(sd_usb_BtnImgData.GetWidth(), sd_usb_BtnImgData.GetHeight());
sd_usb_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
sd_usb_Btn.SetPosition(0, 0);
sd_usb_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
sd_usb_Btn.SetPosition(-8, 0);
sd_usb_Btn.SetImage(&sd_usb_BtnImg);
sd_usb_Btn.SetImageOver(&sd_usb_BtnImgOver);
sd_usb_Btn.SetTrigger(&trigA);
GuiButton dvd_Btn(dvd_BtnImgData.GetWidth(), dvd_BtnImgData.GetHeight());
dvd_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
dvd_Btn.SetPosition(-52, 0);
dvd_Btn.SetImage(&dvd_BtnImg);
dvd_Btn.SetImageOver(&dvd_BtnImgOver);
dvd_Btn.SetTrigger(&trigA);
GuiButton all_Btn(all_BtnImgData.GetWidth(), all_BtnImgData.GetHeight());
all_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
all_Btn.SetPosition(-8, 0);
all_Btn.SetImage(&all_BtnImg);
all_Btn.SetImageOver(&all_BtnImgOver);
all_Btn.SetTrigger(&trigA);
GuiButton back(0, 0);
back.SetTrigger(&trigB);
@ -102,8 +82,6 @@ int devicePrompt()
promptWindow.Append(&sd_Btn);
promptWindow.Append(&usb_Btn);
promptWindow.Append(&sd_usb_Btn);
promptWindow.Append(&dvd_Btn);
promptWindow.Append(&all_Btn);
promptWindow.Append(&back);
HaltGui();
@ -121,31 +99,19 @@ int devicePrompt()
device = 1;
stop = true;
}
if(usb_Btn.GetState() == STATE_CLICKED)
{
device = 2;
stop = true;
}
if(sd_usb_Btn.GetState() == STATE_CLICKED)
{
device = 3;
stop = true;
}
if(dvd_Btn.GetState() == STATE_CLICKED)
{
device = 4;
stop = true;
}
if(all_Btn.GetState() == STATE_CLICKED)
{
device = 5;
stop = true;
}
if(back.GetState() == STATE_CLICKED)
stop = true;
}
@ -154,7 +120,7 @@ int devicePrompt()
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
ResumeGui();
return device;
}

View File

@ -43,7 +43,7 @@ endPrompt()
GuiImage bootmiiImg(&btn);
GuiImage shutdownImg(&btn);
GuiImage backImg(&btn);
// Buttons over data
GuiImageData btn_over(Theme.button_focus);
GuiImage bootmiiImgOver(&btn_over);
@ -59,7 +59,7 @@ endPrompt()
bootmii.SetImage(&bootmiiImg);
bootmii.SetImageOver(&bootmiiImgOver);
bootmii.SetTrigger(&trigA);
GuiText systemmenuTxt(tr("Exit to System Menu"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
GuiButton systemmenu(btn.GetWidth(), btn.GetHeight());
systemmenu.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -70,7 +70,7 @@ endPrompt()
systemmenu.SetImage(&systemmenuImg);
systemmenu.SetImageOver(&systemmenuImgOver);
systemmenu.SetTrigger(&trigA);
GuiText shutdownTxt(tr("Shutdown"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
GuiButton shutdown(btn.GetWidth(), btn.GetHeight());
shutdown.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -81,7 +81,7 @@ endPrompt()
shutdown.SetImage(&shutdownImg);
shutdown.SetImageOver(&shutdownImgOver);
shutdown.SetTrigger(&trigA);
GuiText backTxt(tr("Back"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
GuiButton back(btn.GetWidth(), btn.GetHeight());
back.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -121,21 +121,21 @@ endPrompt()
menu = MENU_EXIT;
stop = true;
}
if(systemmenu.GetState() == STATE_CLICKED)
{
PowerOff = SYS_RETURNTOMENU;
menu = MENU_EXIT;
stop = true;
}
if(shutdown.GetState() == STATE_CLICKED)
{
PowerOff = SYS_POWEROFF_STANDBY;
menu = MENU_EXIT;
stop = true;
}
if(back.GetState() == STATE_CLICKED || back2.GetState() == STATE_CLICKED)
stop = true;
}

View File

@ -86,11 +86,11 @@ void fontDownload(string fontname)
char buffer[100];
msgTxt.SetText(fontname.c_str());
sprintf(buffer, "http://www.nanolx.org/hbf/Fonts/%s", fontname.c_str());
sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Fonts/%s", fontname.c_str());
struct block file = downloadfile(buffer);
if (file.data && file.size > 0 && folder_exists())
{
FILE * data = fopen((Settings.device_dat + ":/config/HBF/Fonts/"+ fontname).c_str(), "wb");
FILE * data = fopen((Settings.device_dat + ":/config/Homebrew Filter/Fonts/"+ fontname).c_str(), "wb");
if(data)
{
fwrite(file.data, 1, file.size, data);
@ -126,7 +126,7 @@ string FontList()
bool stop = false;
char buffer[100];
sprintf(buffer, "http://www.nanolx.org/hbf/Fonts/");
sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Fonts/");
struct block file = downloadfile(buffer);
if (file.data != NULL)
@ -373,4 +373,4 @@ string checkFontsPrompt()
ResumeGui();
return downloadfont;
}
}

View File

@ -40,18 +40,18 @@ infoPrompt()
int y = 40;
GuiText * Entrie[20];
Entrie[i] = new GuiText(tr("About HomebrewFilter"), 28, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
Entrie[i] = new GuiText(tr("Credits"), 28, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
Entrie[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
Entrie[i]->SetPosition(0, y);
i++;
y += 50;
Entrie[i] = new GuiText(tr("Developer:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
Entrie[i] = new GuiText(tr("Coder:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
Entrie[i]->SetPosition(x, y);
i++;
Entrie[i] = new GuiText("Christopher Roy Bratusek", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
Entrie[i] = new GuiText("hamachi-mp", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
Entrie[i]->SetPosition(x+200, y);
i++;

View File

@ -86,11 +86,11 @@ void languageDownload(string languagename)
char buffer[100];
msgTxt.SetText(languagename.c_str());
sprintf(buffer, "http://www.nanolx.org/hbf/Languages/%s", languagename.c_str());
sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Languages/%s", languagename.c_str());
struct block file = downloadfile(buffer);
if (file.data && file.size > 0 && folder_exists())
{
FILE * data = fopen((Settings.device_dat + ":/config/HBF/Languages/"+ languagename).c_str(), "wb");
FILE * data = fopen((Settings.device_dat + ":/config/Homebrew Filter/Languages/"+ languagename).c_str(), "wb");
if(data)
{
fwrite(file.data, 1, file.size, data);
@ -126,7 +126,7 @@ string LanguageList()
bool stop = false;
char buffer[100];
sprintf(buffer, "http://www.nanolx.org/hbf/Languages/");
sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Languages/");
struct block file = downloadfile(buffer);
if (file.data != NULL)
@ -374,4 +374,4 @@ string checkLanguagesPrompt()
ResumeGui();
return downloadlanguage;
}
}

View File

@ -25,6 +25,8 @@ int systemPrompt()
GuiWindow promptWindow(144,64);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
promptWindow.SetPosition(-185, 280);
if(Options.apps == 5)
promptWindow.SetPosition(-185, 307);
GuiTrigger trigA;
GuiTrigger trigB;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

View File

@ -6,7 +6,6 @@
#include "main.h"
#include "Tools/textline.h"
#include "Tools/save.h"
#include "Network/network.h"
#include "Network/update.h"
@ -85,28 +84,36 @@ void themeDownload(string themename)
ResumeGui();
char buffer[100];
sprintf(buffer, "http://www.nanolx.org/hbf/Themes/%s/filelist", themename.c_str());
// download counter
sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Themes/counter.php?theme=%s", themename.c_str());
struct block file = downloadfile(buffer);
sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Themes/index.php?path=Themes/%s", themename.c_str());
file = downloadfile(buffer);
if (file.data != NULL)
{
string source_themes = (char*)file.data;
vector<string> themes;
source_themes.erase(0, source_themes.find("?path=Themes"));
while(1)
{
if((signed)source_themes.find(themename.c_str()) == -1)
break;
source_themes.erase(0, source_themes.find(themename.c_str()) + themename.length() +6);
source_themes.erase(0, source_themes.find(themename.c_str()) + themename.length() +1);
if(source_themes.substr(0, source_themes.find("\"")) == "amp;name=settings.xml")
themes.push_back(source_themes.substr(9, source_themes.find("\"") -9));
else
themes.push_back(source_themes.substr(0, source_themes.find("\"")));
themes.push_back(source_themes.substr(0, source_themes.find("+")));
source_themes.erase(0, source_themes.find("+"));
source_themes.erase(0, source_themes.find("\""));
}
for(int i = 0; i < (signed)themes.size(); i++)
{
msgTxt.SetText(themes[i].c_str());
@ -116,8 +123,7 @@ void themeDownload(string themename)
free(file.data);
}
msgTxt.SetText("");
downloadTxt.SetText(tr("finished"));
@ -144,7 +150,7 @@ string ThemeList()
bool stop = false;
char buffer[100];
sprintf(buffer, "http://www.nanolx.org/hbf/Themes/");
sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Themes/");
struct block file = downloadfile(buffer);
if (file.data != NULL)
@ -154,16 +160,16 @@ string ThemeList()
while(1)
{
if((signed)source_themes.find("../Themes/") == -1)
if((signed)source_themes.find("?path=Themes/") == -1)
break;
source_themes.erase(0, source_themes.find("../Themes/"));
source_themes.erase(0, source_themes.find("s/") +2);
source_themes.erase(0, source_themes.find("?path=Themes/"));
source_themes.erase(0, source_themes.find("/") +1);
if(source_themes.substr(0, source_themes.find("\"")) != "_HBF_")
themes.push_back(source_themes.substr(0, source_themes.find("\"")));
source_themes.erase(0, source_themes.find("<"));
source_themes.erase(0, source_themes.find("download.php"));
}
free(file.data);
@ -395,4 +401,4 @@ string checkThemesPrompt()
ResumeGui();
return downloadtheme;
}
}

View File

@ -14,10 +14,8 @@
#include "Network/update.h"
#include "Network/http.h"
#include <fstream>
#include <ios>
/*** Extern variables ***/
#/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern bool boot_buffer;
@ -101,33 +99,15 @@ updatePrompt(string rev)
ResumeGui();
char url[100];
if(rev == "Beta")
sprintf(url, "http://download.tuxfamily.org/hbf/DOL/Beta/boot.dol");
else
sprintf(url, "http://download.tuxfamily.org/hbf/DOL/rev%s/boot.dol", rev.c_str());
// copy boot.dol to prev.dol
std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), std::ios_base::binary);
std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter/prev.dol").c_str(), std::ios_base::binary);
outfile << infile.rdbuf();
sprintf(url, "http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/rev%s/boot.dol", rev.c_str());
struct block file = downloadfile(url);
if (file.data && file.size > 0)
{
// write file
FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), "wb");
if(data)
{
fwrite(file.data, 1, file.size, data);
fclose(data);
}
CopyHomebrewMemory(file.data, 0, file.size);
if(file.data)
free(file.data);
LoadHomebrew ((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str());
BootHomebrew ();
boot_buffer = true;
}
else
{
@ -365,4 +345,4 @@ string checkUpdatePrompt()
ResumeGui();
return rev;
}
}

View File

@ -2,6 +2,8 @@
#ifndef _PROMPTS_H_
#define _PROMPTS_H_
#include "main.h"
#include <string>
using namespace std;
@ -16,11 +18,15 @@ bool RemoveApp(const char *AppName);
bool MetaEdit(string dir);
int AppInfo(const char *title, string dir, u8* icon);
int ChoiceAppInfo(vector<homebrew_list> list, int i);
int devicePrompt();
int loaderPrompt();
int endPrompt();
int menuPrompt();
int sortPrompt();
int startmenuPrompt(int &CategoryNr, int &AppNr);
int startmenu2Prompt();
int systemPrompt();
int viewPrompt();
int WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label = NULL);
void debug(const char *msg);
@ -42,4 +48,4 @@ void fontDownload(string font);
string checkLanguagesPrompt();
void languageDownload(string language);
#endif
#endif

View File

@ -72,7 +72,7 @@ float GetFontScale()
void SetFont()
{
SetupDefaultFont((check_path(Settings.device_dat + ":/config/HBF/fonts/") + Options.font).c_str());
SetupDefaultFont((check_path(Settings.device_dat + ":/config/Homebrew Filter/fonts/") + Options.font).c_str());
SetFontScale( (float)51 / (float)fontSystem->getWidth(charToWideChar("a"), 100) ); // 51 -> breite von "a" mit standart schrift
}
@ -83,7 +83,7 @@ bool font_folder_exists()
{
DIR *pDir;
pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Fonts").c_str());
pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Fonts").c_str());
if(pDir != NULL)
{
@ -92,7 +92,7 @@ bool font_folder_exists()
}
else
{
if (mkdir((Settings.device_dat + ":/config/HBF/Fonts").c_str(), 0777) != -1)
if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Fonts").c_str(), 0777) != -1)
{
closedir (pDir);
return true;

View File

@ -8,14 +8,6 @@
#define MEM_PROT 0xD8B420A
const u8 di_readlimit_old[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0A, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x7E, 0xD4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08
};
const u8 di_readlimit_patch[] = { 0x7e, 0xd4 };
const u8 isfs_permissions_old[] = { 0x42, 0x8B, 0xD0, 0x01, 0x25, 0x66 };
const u8 isfs_permissions_patch[] = { 0x42, 0x8B, 0xE0, 0x01, 0x25, 0x66 };
const u8 setuid_old[] = { 0xD1, 0x2A, 0x1C, 0x39 };
@ -24,7 +16,6 @@ const u8 es_identify_old[] = { 0x28, 0x03, 0xD1, 0x23 };
const u8 es_identify_patch[] = { 0x00, 0x00 };
const u8 hash_old[] = { 0x20, 0x07, 0x4B, 0x0B };
const u8 hash_patch[] = { 0x00 };
const u8 new_hash_old[] = { 0x20, 0x07, 0x4B, 0x0B };
const u8 addticket_vers_check[] = { 0xD2, 0x01, 0x4E, 0x56 };
const u8 addticket_patch[] = { 0xE0 };
@ -34,7 +25,7 @@ u32 apply_patch(const char *name, const u8 *old, u32 old_size, const u8 *patch,
u8 *ptr = (u8 *) 0x93400000;
u32 i, found = 0;
u8 *start;
while ((u32) ptr < (0x94000000 - old_size))
{
if(!memcmp(ptr, old, old_size))
@ -62,19 +53,17 @@ u32 runtimePatchApply()
write16(MEM_PROT, 0);
count += apply_patch("Trucha", hash_old,
sizeof(hash_old), hash_patch, sizeof(hash_patch), 1);
count += apply_patch("New Trucha", new_hash_old,
sizeof(new_hash_old), hash_patch, sizeof(hash_patch), 1);
count += apply_patch("ES_Identify", es_identify_old,
sizeof(es_identify_old), es_identify_patch, sizeof(es_identify_patch), 2);
sizeof(es_identify_old), es_identify_patch, sizeof(es_identify_patch),
2);
count += apply_patch("NAND Permissions", isfs_permissions_old,
sizeof(isfs_permissions_old), isfs_permissions_patch,
sizeof(isfs_permissions_patch), 0);
count += apply_patch("add ticket patch", addticket_vers_check,
sizeof(addticket_vers_check), addticket_patch, sizeof(addticket_patch), 0);
sizeof(addticket_vers_check), addticket_patch, sizeof(addticket_patch),
0);
count += apply_patch("ES_SetUID", setuid_old, sizeof(setuid_old),
setuid_patch, sizeof(setuid_patch), 0);
count += apply_patch("DI ReadLimit", di_readlimit_old, sizeof(di_readlimit_old),
di_readlimit_patch, sizeof(di_readlimit_patch), 12);
write16(MEM_PROT, 1);
return count;
}

View File

@ -12,170 +12,6 @@ std::vector<int> ioslist;
int selectedIos = IOS_GetVersion();
int ios_pos = 0;
int bootmii = 0;
int nandemu = 0;
int priiloader = 0;
s32 NandReadFile(char *filepath, u8 **buffer, u32 *filesize)
{
s32 Fd;
int ret;
if (buffer == NULL)
{
printf("NULL Pointer\n");
return -1;
}
Fd = ISFS_Open(filepath, ISFS_OPEN_READ);
if (Fd < 0)
{
printf("ISFS_Open %s failed %d\n", filepath, Fd);
return Fd;
}
fstats *status;
status = (fstats *)memalign(32, ((sizeof(fstats))+31)&(~31));
if (status == NULL)
{
printf("Out of memory for status\n");
return -1;
}
ret = ISFS_GetFileStats(Fd, status);
if (ret < 0)
{
printf("ISFS_GetFileStats failed %d\n", ret);
ISFS_Close(Fd);
free(status);
return -1;
}
*buffer = (u8 *)memalign(32, ((status->file_length)+31)&(~31));
if (*buffer == NULL)
{
printf("Out of memory for buffer\n");
ISFS_Close(Fd);
free(status);
return -1;
}
ret = ISFS_Read(Fd, *buffer, status->file_length);
if (ret < 0)
{
printf("ISFS_Read failed %d\n", ret);
ISFS_Close(Fd);
free(status);
free(*buffer);
return ret;
}
ISFS_Close(Fd);
*filesize = status->file_length;
free(status);
if (*filesize > 0)
{
DCFlushRange(*buffer, *filesize);
ICInvalidateRange(*buffer, *filesize);
}
return 0;
}
s32 GetTMD(u64 TicketID, signed_blob **Output, u32 *Length)
{
signed_blob* TMD = NULL;
u32 TMD_Length;
s32 ret;
/* Retrieve TMD length */
ret = ES_GetStoredTMDSize(TicketID, &TMD_Length);
if (ret < 0)
return ret;
/* Allocate memory */
TMD = (signed_blob*)memalign(32, (TMD_Length+31)&(~31));
if (!TMD)
return IPC_ENOMEM;
/* Retrieve TMD */
ret = ES_GetStoredTMD(TicketID, TMD, TMD_Length);
if (ret < 0)
{
free(TMD);
return ret;
}
/* Set values */
*Output = TMD;
*Length = TMD_Length;
return 0;
}
int check_priiloader() {
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(0x20);
static u64 titleId ATTRIBUTE_ALIGN(32) = 0x0000000100000002LL;
int ret = 0;
tmd *ptmd = NULL;
u32 TMD_size = 0;
signed_blob *stmd = NULL;
u32 i = 0;
u32 filesize = 0;
u8 *buffer = NULL;
const char* checkStr = "priiloader";
int retValue = -1;
ret = GetTMD(titleId, &stmd, &TMD_size);
if (ret < 0)
goto end;
if (!stmd)
{
ret = -1;
goto end;
}
ptmd = (tmd*)SIGNATURE_PAYLOAD(stmd);
for (i = 0; i < ptmd->num_contents; i++)
{
if (ptmd->contents[i].index == ptmd->boot_index)
{
sprintf(filepath, "/title/%08x/%08x/content/%08x.app" , 0x00000001, 0x00000002, ptmd->contents[i].cid);
ret = NandReadFile(filepath, &buffer, &filesize);
if (ret < 0 || filesize < 0) {
retValue = -2;
goto end;
}
break;
}
}
for (i = 0; i < filesize - strlen(checkStr); i++)
{
if (!strncmp((char*)buffer + i, checkStr, strlen(checkStr)))
{
retValue = 1;
break;
}
}
end:
free(buffer);
free(stmd);
ptmd = NULL;
priiloader = retValue;
return retValue;
}
// Check if this is an IOS stub (according to WiiBrew.org)
bool IsKnownStub(u32 noIOS, s32 noRevision)
@ -201,12 +37,9 @@ bool IsKnownStub(u32 noIOS, s32 noRevision)
if (noIOS == 254 && noRevision == 3) return true;
if (noIOS == 254 && noRevision == 260) return true;
// BootMii As IOS is installed on IOS254 rev 31338
// BootMii As IOS is installed on IOS254 rev 31338
if (noIOS == 254 && noRevision == 31338) return true;
// NAND Emu
if (noIOS == 253 && noRevision == 65535) return true;
return false;
}
@ -230,10 +63,10 @@ int nextIos()
ios_pos++;
if(ios_pos > (signed)ioslist.size() -1)
ios_pos = ioslist.size() -1;
selectedIos= ioslist[ios_pos];
}
return selectedIos;
}
int previousIos()
@ -243,10 +76,10 @@ int previousIos()
ios_pos--;
if(ios_pos < 0)
ios_pos = 0;
selectedIos= ioslist[ios_pos];
}
return selectedIos;
}
@ -254,12 +87,12 @@ bool listIOS()
{
if(ios_pos > 0)
return true;
ioslist.clear();
u32 nbTitles;
if (ES_GetNumTitles(&nbTitles) < 0)
return false;
// Allocate the memory for titles
u64 *titles = (u64*)memalign(32, nbTitles*sizeof(u64));
@ -268,7 +101,7 @@ bool listIOS()
if (ES_GetTitles(titles, nbTitles) < 0)
return false;
int i;
u32 titleID;
@ -280,7 +113,7 @@ bool listIOS()
// Skip the system menu
titleID = titles[i] & 0xFFFFFFFF;
if (titleID == 2) continue;
// Skip BC, MIOS and possible other non-IOS titles
@ -288,14 +121,7 @@ bool listIOS()
// Skip the running IOS
if (titleID == 0) continue;
// Skip NAND-Emu IOS
if (titleID == 253)
{
nandemu = 1;
continue;
}
// Skip bootmii IOS
if (titleID == 254)
{
@ -319,13 +145,13 @@ bool listIOS()
return false;
iosTMD = (tmd *)SIGNATURE_PAYLOAD(iosTMDBuffer);
free(iosTMDBuffer);
// Get the title version
u8 noVersion = iosTMD->title_version;
bool isStub = false;
// Check if this is an IOS stub (according to WiiBrew.org)
if (IsKnownStub(titleID, iosTMD->title_version))
isStub = true;
@ -338,7 +164,7 @@ bool listIOS()
// - Stub have one app of their own (type 0x1) and 2 shared apps (type 0x8001).
if (noVersion == 0)
isStub = ((iosTMD->num_contents == 3) && (iosTMD->contents[0].type == 1 && iosTMD->contents[1].type == 0x8001 && iosTMD->contents[2].type == 0x8001));
else
else
isStub = false;
}
@ -348,7 +174,6 @@ bool listIOS()
}
std::sort( ioslist.begin(), ioslist.end() ); // sortieren
return true;
}
int SelectedIOS()
@ -374,32 +199,28 @@ int SearchAppIOS(std::string foldername)
selectedIos = IOS_GetVersion();
getIosPos(selectedIos);
}
return selectedIos;
}
int GetAppIOS(std::string foldername)
{
int GetIos = selectedIos;
if(listIOS())
{
bool found = false;
for(int i = 0; i < (signed)appios.size(); i++)
{
if(appios[i].foldername == foldername)
return appios[i].ios;
{
GetIos = appios[i].ios;
found = true;
break;
}
}
}
return selectedIos;
}
int get_priiloader()
{
return priiloader;
}
void set_priiloader(int choice)
{
priiloader = choice;
return GetIos;
}
int get_bootmii()
@ -411,13 +232,3 @@ void set_bootmii(int choice)
{
bootmii = choice;
}
int get_nandemu()
{
return nandemu;
}
void set_nandemu(int choice)
{
nandemu = choice;
}

View File

@ -7,12 +7,5 @@ int previousIos();
int SelectedIOS();
int SearchAppIOS(std::string foldername);
int GetAppIOS(std::string foldername);
int check_priiloader();
s32 GetTMD(u64 TicketID, signed_blob **Output, u32 *Length);
s32 NandReadFile(char *filepath, u8 **buffer, u32 *filesize);
int get_priiloader();
int get_bootmii();
int get_nandemu();
void set_priiloader(int choice);
void set_bootmii(int choice);
void set_nandemu(int choice);
void set_bootmii(int choice);

View File

@ -15,7 +15,7 @@ void Screenshot()
bool Exists = false;
folder_exists();
pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Screenshots").c_str());
pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Screenshots").c_str());
if(pDir != NULL)
{
@ -23,14 +23,14 @@ void Screenshot()
closedir (pDir);
}
else
if(mkdir((Settings.device_dat + ":/config/HBF/Screenshots").c_str(), 777) != -1)
if(mkdir((Settings.device_dat + ":/config/Homebrew Filter/Screenshots").c_str(), 777) != -1)
Exists = true;
if(Exists)
{
while(!stop)
{
sprintf (temp, "%s/%i.png", check_path(Settings.device_dat + ":/config/HBF/Screenshots").c_str(), i);
sprintf (temp, "%s/%i.png", check_path(Settings.device_dat + ":/config/Homebrew Filter/Screenshots").c_str(), i);
FILE * f= fopen (temp,"r");
if (!f)
stop = true;

View File

@ -13,6 +13,7 @@
#include "libwiigui/gui.h"
#include "Prompts/prompts.h"
/*** Extern variables ***/
extern GuiWindow * mainWindow;
@ -23,53 +24,55 @@ extern void HaltGui();
void add(string device, string apps_path)
{
DIR *pdir;
char dirname[MAXPATHLEN];
DIR* dir;
struct dirent *pent;
struct stat statbuf;
char pathnameelf[200];
char pathname[200];
char pathmeta[200];
char pFilename[200];
string pathboot;
pdir=opendir((device + ":/" + apps_path).c_str());
if(pdir != NULL)
dir = opendir ((device + ":/" + apps_path).c_str());
/*
if(dir != NULL)
{
while ((pent=readdir(pdir))!=NULL)
//get all dir names
while( (pent=readdir(dir)) !=NULL)
// while( dirnext (dir, dirname, &st) != -1 )
{
sprintf(pathnameelf, (device + ":/" + apps_path + "%s/boot.elf").c_str() ,pent->d_name);
sprintf(pathname, (device + ":/" + apps_path + "%s/boot.dol").c_str() ,pent->d_name);
// stat(pent->d_name,&statbuf);
sprintf(pathnameelf, (device + ":/" + apps_path + "%s/boot.elf").c_str() ,dirname);
sprintf(pathname, (device + ":/" + apps_path + "%s/boot.dol").c_str() ,dirname);
if(fopen(pathnameelf, "rb") != NULL) pathboot = pathnameelf;
if(fopen(pathname, "rb") != NULL) pathboot = pathname;
if((fopen(pathname, "rb") || fopen(pathnameelf, "rb")) && strstr(pathname, (apps_path + "./").c_str()) == 0
&& strstr(pathname, (apps_path + "../").c_str()) == 0 && strcmp(pent->d_name, "NANDEmu-Boot") != 0)
if((fopen(pathname, "rb") || fopen(pathnameelf, "rb")) && strstr(pathname, (apps_path + "./").c_str()) == 0 && strstr(pathname, (apps_path + "../").c_str()) == 0 )
{
sprintf(pathmeta, (device + ":/" + apps_path + "%s/meta.xml").c_str() ,pent->d_name);
sprintf(pFilename, (device + ":/" + apps_path + "%s/meta.xml").c_str() ,dirname);
string line, quelltext, name, info, foldername, iconpath, arg;
ifstream in(pathmeta);
ifstream in(pFilename);
while(getline(in, line))
quelltext = quelltext + line + "\n";
name = parser(quelltext, "<name>", "</name>");
if(name == "\0") name = pent->d_name;
if(name == "\0") name = dirname;
info = parser(quelltext, "<short_description>", "</short_description>");
if(info == "\0") info = tr("<no description>");
foldername = device + ":/" + apps_path + pent->d_name + "/";
foldername = device + ":/" + apps_path + dirname + "/";
transform(foldername.begin(), foldername.end(), foldername.begin(),::tolower); // in kleinebuchstaben umwandeln
u8 *tempicon;
u8 *icon = NULL;
iconpath = foldername + "icon.png";
arg = parser(quelltext, "<arguments>", "</arguments>");
size_t amount_read;
FILE *fp = fopen(iconpath.c_str(),"r"); //open the png file
if(fp) //make sure the file exists
@ -78,7 +81,7 @@ void add(string device, string apps_path)
fseek (fp , 0 , SEEK_END);
filesize = ftell(fp); //find the file size
rewind(fp);
tempicon = new u8 [filesize]; //allocate memory for your image buffer
if(tempicon) //make sure memory allocated
{
@ -87,19 +90,19 @@ void add(string device, string apps_path)
}
}
fclose(fp); //close file
vechomebrew_list_category[0].push_back(homebrew_list(name, info, foldername, icon, pathboot, arg));
}
}
closedir(pdir);
}
closedir(dir);
}*/
}
void app_list()
{
vechomebrew_list_category[0].clear();
if(Settings.device == "sd1" || Settings.device == "usb1" || Settings.device == "dvd")
if(Settings.device == "sd1" || Settings.device == "usb1")
{
if(Settings.system == 1)
add(Settings.device, "apps/");
@ -131,33 +134,12 @@ void app_list()
add("usb1", "gc_apps/");
}
}
else if(Settings.device == "all")
{
if(Settings.system == 1)
{
add("sd1", "apps/");
add("usb1", "apps/");
add("dvd", "apps/");
}
else if(Settings.system == 0)
{
add("sd1", "gc_apps/");
add("usb1", "gc_apps/");
add("dvd", "gc_apps/");
}
else if(Settings.system == 2)
{
add("sd1", "apps/");
add("sd1", "gc_apps/");
add("usb1", "apps/");
add("usb1", "gc_apps/");
add("dvd", "apps/");
add("dvd", "gc_apps/");
}
}
// sortieren
std::sort(vechomebrew_list_category[0].begin(),vechomebrew_list_category[0].end(), sort_name_a_z);
// suchen nach hbc
if(DetectHBC() != 0 && Settings.system != 0)
vechomebrew_list_category[0].insert(vechomebrew_list_category[0].begin(), homebrew_list("the homebrew channel", "the homebrew channel", "the homebrew channel", (u8*)hbc_icon_png, "the homebrew channel", ""));
}

View File

@ -46,7 +46,7 @@ void AvailableCategoryLoad(string pfad)
AvailableCategory.apps[i].clear();
// Kategorie durchsuchen
temp = source.erase(0,source.find("[") +1);
AvailableCategory.categories.push_back(source.substr(0, source.find("]")));
AvailableCategory.categories.push_back(source.substr(0, source.find("]")).c_str());
temp = source.erase(0,source.find("]") +1);
if((signed)temp.find("[") != -1)
temp.erase(temp.find("["));

View File

@ -6,31 +6,29 @@ void copy_app_in_unassigned()
{
vector<string> apps;
vechomebrew_list_unassigned.clear();
for(int a = 1; a < (signed)AvailableCategory.categories.size(); a++)
for(int b = 0; b < (signed)AvailableCategory.apps[a].size(); b++)
apps.push_back(AvailableCategory.apps[a][b]);
for(int i = 0; i < (signed)vechomebrew_list_category[0].size(); i++)
{
bool present = true;
int anzahl_device = 0, anzahl_ordner = 0;
// Geräte SD, USB
if(Settings.device == "sd1" || Settings.device == "usb1")
anzahl_device = 1;
else if(Settings.device == "sd_usb")
anzahl_device = 2;
else if(Settings.device == "all")
anzahl_device = 3;
// Ordner APPS, GC_APPS
if(Settings.system == 1 || Settings.system == 0)
anzahl_ordner = 1;
else if(Settings.system == 2)
anzahl_ordner = 2;
for(int x = 0; x < anzahl_device; x++)
{
for(int y = 0; y < anzahl_ordner; y++)
@ -46,7 +44,7 @@ void copy_app_in_unassigned()
ordner = ":/apps/";
else if(Settings.system == 2 && y == 1)
ordner = ":/gc_apps/";
if(anzahl_device == 1)
foldername = Settings.device + ordner + apps[a] + "/";
else
@ -55,10 +53,8 @@ void copy_app_in_unassigned()
foldername = "sd1" + ordner + apps[a] + "/";
else if(x == 1)
foldername = "usb1" + ordner + apps[a] + "/";
else if(x == 2)
foldername = "dvd" + ordner + apps[a] + "/";
}
if(
strcasecmp(vechomebrew_list_category[0][i].foldername.c_str(), foldername.c_str()) == 0 ||
strcasecmp(vechomebrew_list_category[0][i].foldername.c_str(), "the homebrew channel") == 0
@ -67,7 +63,7 @@ void copy_app_in_unassigned()
}
}
}
if(present)
{
vechomebrew_list_unassigned.push_back(homebrew_list(
@ -86,27 +82,26 @@ void copy_app_in_category(int category) //Apps im Kategorie kopieren
{
copy_app_in_unassigned();
vechomebrew_list_category[category].clear();
bool hbc = false;
for(int a = 0; a < (signed)AvailableCategory.apps[category].size(); a++)
{
{
for(int i = 0; i < (signed)vechomebrew_list_category[0].size(); i++)
{
int anzahl_device = 0, anzahl_ordner = 0;
// Geräte SD, USB
if(Settings.device == "sd1" || Settings.device == "usb1")
anzahl_device = 1;
else if(Settings.device == "sd_usb")
anzahl_device = 2;
else if(Settings.device == "all")
anzahl_device = 3;
// Ordner APPS, GC_APPS
if(Settings.system == 1 || Settings.system == 0)
anzahl_ordner = 1;
else if(Settings.system == 2)
anzahl_ordner = 2;
for(int x = 0; x < anzahl_device; x++ )
{
for(int y = 0; y < anzahl_ordner; y++ )
@ -120,7 +115,7 @@ void copy_app_in_category(int category) //Apps im Kategorie kopieren
ordner = ":/apps/";
else if(Settings.system == 2 && y == 1)
ordner = ":/gc_apps/";
if(anzahl_device == 1)
foldername = Settings.device + ordner + AvailableCategory.apps[category][a] + "/";
else
@ -129,16 +124,18 @@ void copy_app_in_category(int category) //Apps im Kategorie kopieren
foldername = "sd1" + ordner + AvailableCategory.apps[category][a] + "/";
else if(x == 1)
foldername = "usb1" + ordner + AvailableCategory.apps[category][a] + "/";
else if(x == 2)
foldername = "dvd" + ordner + AvailableCategory.apps[category][a] + "/";
}
if(
strcasecmp(vechomebrew_list_category[0][i].foldername.c_str(), foldername.c_str()) == 0 ||
strcasecmp(AvailableCategory.apps[category][a].c_str(), "the homebrew channel") == 0
)
{
if(strcasecmp(AvailableCategory.apps[category][a].c_str(), "the homebrew channel") == 0 && !hbc)
hbc = true;
else if(strcasecmp(AvailableCategory.apps[category][a].c_str(), "the homebrew channel") == 0 && hbc)
break;
vechomebrew_list_category[category].push_back(homebrew_list(
vechomebrew_list_category[0][i].name,
vechomebrew_list_category[0][i].info,
@ -147,7 +144,7 @@ void copy_app_in_category(int category) //Apps im Kategorie kopieren
vechomebrew_list_category[0][i].pathboot,
vechomebrew_list_category[0][i].arg
));
break;
}
}

View File

@ -1,3 +1,4 @@
void copy_app_in_unassigned();
void copy_app_in_category();
void copy_app_in_category(int category);

View File

@ -13,29 +13,23 @@
#include <ogc/machine/processor.h>
#include <ntfs.h>
#include <fat.h>
#include <ext2.h>
#include <sdcard/wiisd_io.h>
#include <ogc/usbstorage.h>
#include <dirent.h>
#include <di/di.h>
#include "fileop.h"
#include "main.h"
#include "Tools/app_list.h"
#include "Tools/copy_app_in_category.h"
#include "Tools/throbber.h"
#include "DiskOperations/iso.h"
#include "DiskOperations/di2.h"
static const DISC_INTERFACE* sd = &__io_wiisd;
static const DISC_INTERFACE* usb = &__io_usbstorage;
static const DISC_INTERFACE* dvd = &__io_wiidvd;
enum
{
DEVICE_SD,
DEVICE_USB,
DEVICE_DVD
DEVICE_USB
};
static char prefix[2][4] = { "sd", "usb" };
@ -48,7 +42,7 @@ static char prefix[2][4] = { "sd", "usb" };
#define le32_to_cpu(x) bswap32(x)
#define BYTES_PER_SECTOR 4096
#define BYTES_PER_SECTOR 512
#define NTFS_OEM_ID (0x4e54465320202020ULL)
#define PARTITION_TYPE_EMPTY 0x00 /* Empty */
@ -56,11 +50,6 @@ static char prefix[2][4] = { "sd", "usb" };
#define PARTITION_TYPE_NTFS 0x07 /* Windows NT NTFS */
#define PARTITION_TYPE_WIN95_EXTENDED 0x0F /* Windows 95 extended partition */
#define PARTITION_TYPE_LINUX 0x83 /* GNU/Linux partition */
#define PARTITION_TYPE_LINUX_SWAP 0x82 /* GNU/Linux Swap partition */
#define PARTITION_TYPE_LINUX_LVM 0x8e /* GNU/Linux logical volume manager partition */
#define PARTITION_TYPE_LINUX_LUKS 0xe8 /* GNU/Linux LUKS partition */
#define PARTITION_STATUS_NONBOOTABLE 0x00 /* Non-bootable */
#define PARTITION_STATUS_BOOTABLE 0x80 /* Bootable (active) */
@ -70,10 +59,8 @@ static char prefix[2][4] = { "sd", "usb" };
#define BPB_FAT16_fileSysType 0x36
#define BPB_FAT32_fileSysType 0x52
#define T_FAT 1
#define T_NTFS 2
#define T_EXT2 3
#define T_ISO9660 4
#define T_FAT 1
#define T_NTFS 2
static const char FAT_SIG[3] = {'F', 'A', 'T'};
@ -169,14 +156,8 @@ static void AddPartition(sec_t sector, int device, int type, int *devnum)
DISC_INTERFACE *disc = (DISC_INTERFACE *)sd;
if (device == DEVICE_USB)
{
if(device == DEVICE_USB)
disc = (DISC_INTERFACE *)usb;
}
else if (device == DEVICE_DVD)
{
disc = (DISC_INTERFACE *)dvd;
}
char mount[10];
sprintf(mount, "%s%i", prefix[device], *devnum+1);
@ -187,7 +168,7 @@ static void AddPartition(sec_t sector, int device, int type, int *devnum)
return;
fatGetVolumeLabel(mount, part[device][*devnum].name);
}
else if (type == T_NTFS)
else
{
if(!ntfsMount(mount, disc, sector, 8, 64, NTFS_DEFAULT | NTFS_RECOVER))
return;
@ -199,27 +180,6 @@ static void AddPartition(sec_t sector, int device, int type, int *devnum)
else
part[device][*devnum].name[0] = 0;
}
else if (type == T_EXT2)
{
if(!ext2Mount(mount, disc, sector, 8, 64, EXT2_FLAG_64BITS | EXT2_FLAG_JOURNAL_DEV_OK))
return;
const char *name = ext2GetVolumeName(mount);
if(name)
strcpy(part[device][*devnum].name, name);
else
part[device][*devnum].name[0] = 0;
}
else if (type == T_ISO9660)
{
if (!MountDVD())
return;
strcpy(part[device][*devnum].name, "DVD");
}
strcpy(part[device][*devnum].mount, mount);
part[device][*devnum].type = type;
@ -284,7 +244,7 @@ static int FindPartitions(int device)
part_lba = le32_to_cpu(mbr.partitions[i].lba_start);
debug_printf(
"Partition %i: %s, sector %u, type 0x%x\n",
"Partition %i: %s, sector %lu, type 0x%x\n",
i + 1,
partition->status == PARTITION_STATUS_BOOTABLE ? "bootable (active)"
: "non-bootable", part_lba, partition->type);
@ -332,7 +292,7 @@ static int FindPartitions(int device)
if (sector.ebr.signature == EBR_SIGNATURE)
{
debug_printf(
"Logical Partition @ %d: %s type 0x%x\n",
"Logical Partition @ %d: type 0x%x\n",
ebr_lba + next_erb_lba,
sector.ebr.partition.status
== PARTITION_STATUS_BOOTABLE ? "bootable (active)"
@ -347,13 +307,8 @@ static int FindPartitions(int device)
next_erb_lba = le32_to_cpu(
sector.ebr.next_ebr.lba_start);
if(sector.ebr.partition.type==PARTITION_TYPE_LINUX)
{
debug_printf("Partition : type EXT2/3/4 found\n");
AddPartition(part_lba, device, T_EXT2, &devnum);
}
// Check if this partition has a valid NTFS boot record
else if (interface->readSectors(part_lba, 1, &sector))
if (interface->readSectors(part_lba, 1, &sector))
{
if (sector.boot.oem_id == NTFS_OEM_ID)
{
@ -392,15 +347,6 @@ static int FindPartitions(int device)
break;
}
case PARTITION_TYPE_LINUX:
{
debug_printf("Partition %i: Claims to be LINUX\n", i + 1);
// Read and validate the EXT2 partition
AddPartition(part_lba, device, T_EXT2, &devnum);
break;
}
// Ignore empty partitions
case PARTITION_TYPE_EMPTY:
debug_printf("Partition %i: Claims to be empty\n", i + 1);
@ -431,11 +377,6 @@ static int FindPartitions(int device)
debug_printf("Partition : Valid FAT boot sector found\n");
AddPartition(part_lba, device, T_FAT, &devnum);
}
else
{
debug_printf("Trying : EXT partition\n");
AddPartition(part_lba, device, T_EXT2, &devnum);
}
}
break;
}
@ -465,11 +406,6 @@ static int FindPartitions(int device)
AddPartition(i, device, T_FAT, &devnum);
break;
}
else
{
debug_printf("Trying : EXT partition\n");
AddPartition(part_lba, device, T_EXT2, &devnum);
}
}
}
}
@ -485,29 +421,14 @@ static void UnmountPartitions(int device)
{
if(part[device][i].type == T_FAT)
{
sprintf(mount, "VFAT: %s:", part[device][i].mount);
sprintf(mount, "%s:", part[device][i].mount);
fatUnmount(mount);
break;
}
else if(part[device][i].type == T_NTFS)
{
sprintf(mount, "NTFS: %s:", part[device][i].mount);
ntfsUnmount(part[device][i].mount, false);
break;
}
else if(part[device][i].type == T_EXT2)
{
sprintf(mount, "EXT2: %s:", part[device][i].mount);
ext2Unmount(part[device][i].mount);
break;
}
else if(part[device][i].type == T_ISO9660)
{
sprintf(mount, "ISO9660: %s:", part[device][i].mount);
UnMountDVD();
break;
}
part[device][i].name[0] = 0;
part[device][i].mount[0] = 0;
part[device][i].sector = 0;
@ -515,18 +436,24 @@ static void UnmountPartitions(int device)
part[device][i].type = 0;
}
if(device == DEVICE_SD)
sd->shutdown();
else
{
usb->shutdown();
USB_Deinitialize();
}
}
/****************************************************************************
* MountPartitions
*
*
* Shuts down the device
* Attempts to startup the device specified and mounts all partitions
***************************************************************************/
static bool MountPartitions(int device)
{
const DISC_INTERFACE* disc = NULL;
switch(device)
@ -537,9 +464,6 @@ static bool MountPartitions(int device)
case DEVICE_USB:
disc = usb;
break;
case DEVICE_DVD:
disc = dvd;
break;
default:
return false; // unknown device
}
@ -554,72 +478,11 @@ void MountAllDevices()
{
if(sd->startup() && sd->isInserted())
MountPartitions(DEVICE_SD);
usleep(250000); // 1/4 sec
if(usb->startup() && usb->isInserted())
MountPartitions(DEVICE_USB);
usleep(250000); // 1/4 sec
if(dvd->startup() && dvd->isInserted())
MountDVD();
}
bool MountDVDFS()
{
bool devicemounted = ISO9660_Mount();
/*if(!devicemounted)
devicemounted = FST_Mount();
if(!devicemounted)
devicemounted = GCFST_Mount();*/
return devicemounted;
}
void UnMountDVD()
{
ISO9660_Unmount();
}
bool MountDVD()
{
if(!DVD_Inserted())
return false;
char read_buffer[2048];
if(DI2_ReadDVD(read_buffer, 1, 0) == 0)
return true;
UnMountDVD();
DI2_Mount();
time_t timer1, timer2;
timer1 = time(0);
while(DI2_GetStatus() & DVD_INIT)
{
timer2 = time(0);
if(timer2-timer1 > 15)
return false;
usleep(5000);
}
return MountDVDFS();
}
bool DVD_Inserted()
{
uint32_t cover = 0;
DI2_GetCoverRegister(&cover);
if(cover & DVD_COVER_DISC_INSERTED)
return true;
return false;
}
void UnmountAllDevices()
@ -637,7 +500,7 @@ void check_sd()
{
if(Settings.sd_insert <= 0)
{
if(sd->startup() && sd->isInserted()) // wenn sd karte gefunden, neu einlesen
{
MountPartitions(DEVICE_SD);
@ -646,7 +509,7 @@ void check_sd()
}
else if(Settings.sd_insert == 1)
{
if(!SDCard_Inserted()) // wenn sd karte nicht gefunden, beenden
if(!SDCard_Inserted()) // wenn sd karte nicht gefunden, beenden
{
UnmountPartitions(DEVICE_SD);
Settings.sd_insert = -1;
@ -663,7 +526,7 @@ void check_usb()
{
if(Settings.usb_insert <= 0)
{
if(usb->startup() && usb->isInserted()) // wenn usb gerät gefunden, neu einlesen
if(usb->startup() && usb->isInserted()) // wenn usb gerät gefunden, neu einlesen
{
MountPartitions(DEVICE_USB);
Settings.usb_insert = 2;
@ -671,7 +534,7 @@ void check_usb()
}
else if(Settings.usb_insert == 1)
{
if(!USBDevice_Inserted()) // wenn usb gerät nicht mehr gefunden, beenden
if(!USBDevice_Inserted()) // wenn usb gerät nicht mehr gefunden, beenden
{
UnmountPartitions(DEVICE_USB);
Settings.usb_insert = -1;
@ -679,27 +542,6 @@ void check_usb()
}
}
void check_dvd()
{
if(Settings.dvd_insert <= 0)
{
if(DVD_Inserted()) // wenn dvd gefunden, neu einlesen
{
MountDVD();
Settings.dvd_insert = 2;
}
}
else if(Settings.dvd_insert == 1)
{
if(!DVD_Inserted()) // wenn dvd nicht gefunden, beenden
{
UnMountDVD();
Settings.dvd_insert = -1;
}
}
}
void check_device()
{
ResumeThrobberThread();
@ -710,37 +552,32 @@ void check_device()
copy_app_in_category();
else
copy_app_in_unassigned();
if(Settings.sd_insert == 2)
Settings.sd_insert = 1;
else if(Settings.sd_insert == -1)
Settings.sd_insert = 0;
if(Settings.usb_insert == 2)
Settings.usb_insert = 1;
else if(Settings.usb_insert == -1)
Settings.usb_insert = 0;
if(Settings.dvd_insert == 2)
Settings.dvd_insert = 1;
else if(Settings.dvd_insert == -1)
Settings.dvd_insert = 0;
HaltThrobberThread();
}
string check_path(string old_path)
{
{
DIR *dirHandle;
struct dirent * dirEntry;
if(old_path.length() > 0 && old_path.substr(old_path.length() -1) != "/")
old_path += "/";
string new_path = old_path.substr(0, old_path.find(":/") +2);
old_path.erase(0, old_path.find("/") +1);
string search;
while((signed)old_path.find("/") != -1)
{
search = old_path.substr(0, old_path.find("/"));
@ -759,7 +596,7 @@ string check_path(string old_path)
new_path += "/";
closedir(dirHandle);
}
old_path.erase(0, old_path.find("/") +1);
}

View File

@ -34,12 +34,6 @@ extern DEVICE_STRUCT part[2][MAX_DEVICES];
void MountAllDevices();
void UnmountAllDevices();
bool MountDVD();
bool MountDVDFS();
void UnMountDVD();
bool DVD_Inserted();
void check_dvd();
/*
//!USB FAT Controls
int USBDevice_Init();

View File

@ -53,13 +53,13 @@ void load()
if (get_setting(source, "theme") != "")
{
sprintf (Options.theme, get_setting(source, "theme").c_str());
theme(check_path(Settings.device_dat + ":/config/HBF/themes/") + Options.theme + "/");
theme(check_path(Settings.device_dat + ":/config/Homebrew Filter/themes/") + Options.theme + "/");
}
if(get_setting(source, "language") != "")
{
sprintf (Options.language, get_setting(source, "language").c_str());
ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + Options.language + ".lang");
ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + Options.language + ".lang");
AvailableCategory.categories[0] = tr(Settings.category_name_all);
}
@ -96,10 +96,10 @@ void load()
if(get_setting(source, "quick_start") != "")
Options.quick_start = atoi(get_setting(source, "quick_start").c_str());
if(get_setting(source, "show_all") != "")
Options.show_all = atoi(get_setting(source, "show_all").c_str());
if(get_setting(source, "navigation") != "")
Options.navigation = atoi(get_setting(source, "navigation").c_str());
@ -122,7 +122,7 @@ void load()
}
if(get_setting(source, "grid") != "")
Settings.grid = atoi(get_setting(source, "grid").c_str());
Settings.view = atoi(get_setting(source, "grid").c_str());
if(get_setting(source, "device") != "")
Settings.device = get_setting(source, "device");

View File

@ -8,6 +8,8 @@
#include "filelist.h"
using namespace std;
string HBC_version;
template <class pointer>
s8 free_pointer(pointer*& ptr)
{
@ -18,7 +20,7 @@ s8 free_pointer(pointer*& ptr)
//protection incase empty type was given
memset(ptr,0,sizeof(pointer));
}
free(ptr);
free(ptr);
ptr = NULL;
return 0;
}
@ -28,6 +30,108 @@ s8 free_pointer(pointer*& ptr)
}
}
char * DetectHBC_version(const tmd *t)
{
static char desc[10];
if (t->title_version)
snprintf(desc, sizeof(desc), "%d.%d", t->title_version >> 8, t->title_version & 0xFF);
/* if (t->sys_version)
snprintf(desc, sizeof(desc), "%s FW: IOS%llu ", desc, t->sys_version & 0xff);
*/
return desc;
}
u64 DetectHBC()
{
u64 *list;
u32 titlecount;
s32 ret;
vector<u64> TitleID;
TitleID.push_back(0x0001000148415858LL); //HAXX
TitleID.push_back(0x000100014A4F4449LL); //JODI
TitleID.push_back(0x00010001AF1BF516LL); //>=0.7
ret = ES_GetNumTitles(&titlecount);
if(ret < 0)
{
printf("DetectHBC: ES_GetNumTitles Fehler\n");
return 0;
}
list = (u64*)memalign(32, titlecount * sizeof(u64) + 32);
ret = ES_GetTitles(list, titlecount);
if(ret < 0) {
printf("DetectHBC: ES_GetTitles Error\n");
free_pointer(list);
return 0;
}
ret = 0;
//lets check for known HBC title id's.
for(u32 i=0; i<titlecount; i++)
{
u32 tmd_size;
ES_GetStoredTMDSize(list[i], &tmd_size);
static u8 tmd_buf[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
signed_blob *s_tmd = (signed_blob *)tmd_buf;
ES_GetStoredTMD(list[i], s_tmd, tmd_size);
if (list[i] == TitleID[0]) //HAXX
{
if (ret < 1)
{
ret = 1;
HBC_version = "HAXX";
}
}
if (list[i] == TitleID[1]) //JODI
{
if (ret < 2)
{
ret = 2;
HBC_version = "JODI";
}
}
if (list[i] == TitleID[2]) //>=0.7
{
if(ret < 3)
{
ret = 3;
HBC_version = DetectHBC_version((tmd *)SIGNATURE_PAYLOAD(s_tmd));
}
}
}
free_pointer(list);
if(ret != 0)
return TitleID[ret -1];
else
printf("ERROR_FIND_HBC\n");
return 0;
}
void LoadHBC()
{
u64 TitleID = DetectHBC();
if(TitleID != 0)
{
u32 cnt ATTRIBUTE_ALIGN(32);
ES_GetNumTicketViews(TitleID, &cnt);
tikview *views = (tikview *)memalign( 32, sizeof(tikview)*cnt );
ES_GetTicketViews(TitleID, views, cnt);
ES_LaunchTitle(TitleID, &views[0]);
}
else
{
//well that went wrong
printf("ERROR_BOOT_HBC\n");
}
}
bool CheckAppFound(u64 title)
{
@ -67,7 +171,7 @@ int DetectHBF()
u64 *list;
u32 titlecount;
int ret;
vector<u64> TitleID;
TitleID.push_back(0x0001000154484246LL); //THBF
// TitleID.push_back(0x0001000148424630LL); //HBF0
@ -88,9 +192,9 @@ int DetectHBF()
return 0;
}
ret = 0;
//lets check for known HBF title id's.
for(u32 i=0; i<titlecount; i++)
for(u32 i=0; i<titlecount; i++)
{
u32 tmd_size;
ES_GetStoredTMDSize(list[i], &tmd_size);
@ -110,12 +214,11 @@ int DetectHBF()
}
*/ }
free_pointer(list);
if(ret != 0)
if(ret != 0)
{
memcpy((void*)0x80001800, stub_bin, stub_bin_size);
DCFlushRange((void*)0x80001800,stub_bin_size);
hbcStubAvailable();
return ret;
}
@ -137,4 +240,4 @@ void LoadHBF()
*(vu16*)0x800024D2 = 0x4630;//"F0";
}
*/
}
}

View File

@ -1 +1,6 @@
extern string HBC_version;
u64 DetectHBC();
void LoadHBC();
void LoadHBF();

View File

@ -24,7 +24,7 @@ bool folder_exists()
if(pDir != NULL)
{
pDir = opendir(check_path(Settings.device_dat + ":/config/HBF").c_str());
pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter").c_str());
if(pDir != NULL)
{
closedir (pDir);
@ -32,7 +32,7 @@ bool folder_exists()
}
else
{
if (mkdir((Settings.device_dat + ":/config/HBF").c_str(), 0777) != -1)
if (mkdir((Settings.device_dat + ":/config/Homebrew Filter").c_str(), 0777) != -1)
return true;
}
}
@ -40,7 +40,7 @@ bool folder_exists()
{
if (mkdir((Settings.device_dat + ":/config").c_str(), 0777) != -1)
{
if (mkdir((Settings.device_dat + ":/config/HBF").c_str(), 0777) != -1)
if (mkdir((Settings.device_dat + ":/config/Homebrew Filter").c_str(), 0777) != -1)
return true;
}
}
@ -100,12 +100,12 @@ void save()
save_settings << "last_app_name = \"" << Settings.startingAppName << "\"" << endl;
save_settings << "apps_nr = \"" << Options.apps << "\"" << endl;
save_settings << "quick_start = \"" << Options.quick_start << "\"" << endl;
save_settings << "show_all = \"" << Options.show_all << "\"" << endl;
save_settings << "show_all = \"" << Options.show_all << "\"" << endl;
save_settings << "navigation = \"" << Options.navigation << "\"" << endl;
save_settings << "network = \"" << Options.network << "\"" << endl;
save_settings << "newrevtext = \"" << Options.newrevtext << "\"" << endl;
save_settings << "code = \"" << Settings.code << "\"" << endl;
save_settings << "grid = \"" << Settings.grid << "\"" << endl;
save_settings << "grid = \"" << Settings.view << "\"" << endl;
save_settings << "device = \"" << Settings.device << "\"" << endl;
save_settings << "device_dat = \"" << Settings.device_dat << "\"" << endl;
save_settings << "device_icon = \"" << Options.device_icon << "\"" << endl;

View File

@ -37,25 +37,20 @@ DefaultTheme()
Theme.dialog_background = dialog_background_png;
Theme.throbber = throbber_png;
Theme.choice = choice_png;
Theme.choice_large = choice_large_png;
Theme.sd_active = sd_active_png;
Theme.sd_inactive = sd_inactive_png;
Theme.usb_active = usb_active_png;
Theme.usb_inactive = usb_inactive_png;
Theme.sd_usb_active = sd_usb_active_png;
Theme.sd_usb_inactive = sd_usb_inactive_png;
Theme.dvd_active = dvd_active_png;
Theme.dvd_inactive = dvd_inactive_png;
Theme.all_active = all_active_png;
Theme.all_inactive = all_inactive_png;
Theme.sd_usb_inactive = sd_usb_inactive_png;
Theme.wii_active = wii_active_png;
Theme.wii_inactive = wii_inactive_png;
Theme.gc_active = gc_active_png;
Theme.gc_inactive = gc_inactive_png;
Theme.pc_active = pc_active_png;
Theme.pc_inactive = pc_inactive_png;
Theme.wii_gc_active = wii_gc_active_png;
Theme.wii_gc_inactive = wii_gc_inactive_png;
Theme.loader_active = loader_active_png;
Theme.loader_inactive = loader_inactive_png;
Theme.power_active = power_active_png;
Theme.power_inactive = power_inactive_png;
Theme.settings_active = settings_active_png;
@ -76,12 +71,17 @@ DefaultTheme()
Theme.player_grab = player_grab_png;
Theme.bg_options = bg_options_png;
Theme.bg_options_entry = bg_options_entry_png;
Theme.bar = bar_png;
Theme.desktop = desktop_png;
Theme.startmenu = startmenu_png;
Theme.startmenu_top = startmenu_top_png;
Theme.menu_selection = menu_selection_png;
Theme.scrollbar = scrollbar_png;
Theme.scrollbar_arrowdown = scrollbar_arrowdown_png;
Theme.scrollbar_arrowdown_over = scrollbar_arrowdown_over_png;
Theme.scrollbar_arrowup = scrollbar_arrowup_png;
Theme.scrollbar_arrowup_over = scrollbar_arrowup_over_png;
// color
Theme.category_1 = 0;
Theme.category_2 = 0;
@ -118,7 +118,7 @@ DefaultTheme()
const u8* load_data(const u8* image, string path)
{
u8 *tempicon;
size_t amount_read;
FILE *fp = fopen(path.c_str(),"r"); //open the png file
if(fp) { //make sure the file exists
@ -145,19 +145,19 @@ int split(string to_share, int share)
{
int number = 0;
string temp;
for(int i=0; i < share; i++)
{
temp = to_share.substr(0, to_share.find(","));
to_share.erase(0, to_share.find(",") +1);
if(i == share -1)
{
number = atoi(temp.c_str());
break;
}
}
return number;
}
@ -188,23 +188,18 @@ void theme(string path)
Theme.dialog_background = load_data(Theme.dialog_background , path + "dialog_background.png");
Theme.throbber = load_data(Theme.throbber , path + "throbber.png");
Theme.choice = load_data(Theme.choice , path + "choice.png");
Theme.choice = load_data(Theme.choice ,path + "choice_large.png");
Theme.sd_active = load_data(Theme.sd_active , path + "sd_active.png");
Theme.sd_inactive = load_data(Theme.sd_inactive , path + "sd_inactive.png");
Theme.usb_active = load_data(Theme.usb_active , path + "usb_active.png");
Theme.usb_inactive = load_data(Theme.usb_inactive , path + "usb_inactive.png");
Theme.sd_usb_active = load_data(Theme.sd_usb_active , path + "sd_usb_active.png");
Theme.sd_usb_inactive = load_data(Theme.sd_usb_inactive , path + "sd_usb_inactive.png");
Theme.dvd_active = load_data(Theme.dvd_active , path + "dvd_active.png");
Theme.dvd_inactive = load_data(Theme.dvd_inactive , path + "dvd_inactive.png");
Theme.all_active = load_data(Theme.all_active , path + "all_active.png");
Theme.all_inactive = load_data(Theme.all_inactive , path + "all_inactive.png");
Theme.loader_active = load_data(Theme.loader_active , path + "loader_active.png");
Theme.loader_inactive = load_data(Theme.loader_inactive , path + "loader_inactive.png");
Theme.wii_active = load_data(Theme.wii_active , path + "wii_active.png");
Theme.wii_inactive = load_data(Theme.wii_inactive , path + "wii_inactive.png");
Theme.gc_active = load_data(Theme.gc_active , path + "gc_active.png");
Theme.gc_inactive = load_data(Theme.gc_inactive , path + "gc_inactive.png");
Theme.pc_active = load_data(Theme.pc_active , path + "pc_active.png");
Theme.pc_inactive = load_data(Theme.pc_inactive , path + "pc_inactive.png");
Theme.wii_gc_active = load_data(Theme.wii_gc_active , path + "wii_gc_active.png");
Theme.wii_gc_inactive = load_data(Theme.wii_gc_inactive , path + "wii_gc_inactive.png");
Theme.power_active = load_data(Theme.power_active , path + "power_active.png");
@ -227,6 +222,11 @@ void theme(string path)
Theme.player_grab = load_data(Theme.player_grab , path + "player_grab.png");
Theme.bg_options = load_data(Theme.bg_options , path + "bg_options.png");
Theme.bg_options_entry = load_data(Theme.bg_options_entry , path + "bg_options_entry.png");
Theme.bar = load_data(Theme.bar , path + "bar.png");
Theme.desktop = load_data(Theme.desktop , path + "desktop.png");
Theme.startmenu = load_data(Theme.startmenu , path + "startmenu.png");
Theme.startmenu_top = load_data(Theme.startmenu_top , path + "startmenu_top.png");
Theme.menu_selection = load_data(Theme.menu_selection , path + "menu_selection.png");
Theme.scrollbar = load_data(Theme.scrollbar , path + "scrollbar.png");
Theme.scrollbar_arrowdown = load_data(Theme.scrollbar_arrowdown , path + "scrollbar_arrowdown.png");
Theme.scrollbar_arrowdown_over = load_data(Theme.scrollbar_arrowdown_over , path + "scrollbar_arrowdown_over.png");
@ -247,80 +247,80 @@ void theme(string path)
fseek (fp , 0, SEEK_END);
long settings_size = ftell (fp);
rewind (fp);
if (settings_size > 0)
{
tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
fclose(fp);
data = mxmlFindElement(tree, tree, "#color#", NULL, NULL, MXML_DESCEND);
if (mxmlElementGetAttr(data,"category")) {
Theme.category_1 = split(mxmlElementGetAttr(data,"category"), 1);
Theme.category_2 = split(mxmlElementGetAttr(data,"category"), 2);
Theme.category_3 = split(mxmlElementGetAttr(data,"category"), 3);
}
if (mxmlElementGetAttr(data,"page")) {
Theme.page_1 = split(mxmlElementGetAttr(data,"page"), 1);
Theme.page_2 = split(mxmlElementGetAttr(data,"page"), 2);
Theme.page_3 = split(mxmlElementGetAttr(data,"page"), 3);
}
if (mxmlElementGetAttr(data,"owner")) {
Theme.owner_1 = split(mxmlElementGetAttr(data,"owner"), 1);
Theme.owner_2 = split(mxmlElementGetAttr(data,"owner"), 2);
Theme.owner_3 = split(mxmlElementGetAttr(data,"owner"), 3);
}
if (mxmlElementGetAttr(data,"title")) {
Theme.title_1 = split(mxmlElementGetAttr(data,"title"), 1);
Theme.title_2 = split(mxmlElementGetAttr(data,"title"), 2);
Theme.title_3 = split(mxmlElementGetAttr(data,"title"), 3);
}
if (mxmlElementGetAttr(data,"program_name")) {
Theme.program_name_1 = split(mxmlElementGetAttr(data,"program_name"), 1);
Theme.program_name_2 = split(mxmlElementGetAttr(data,"program_name"), 2);
Theme.program_name_3 = split(mxmlElementGetAttr(data,"program_name"), 3);
}
if (mxmlElementGetAttr(data,"apps")) {
Theme.apps_1 = split(mxmlElementGetAttr(data,"apps"), 1);
Theme.apps_2 = split(mxmlElementGetAttr(data,"apps"), 2);
Theme.apps_3 = split(mxmlElementGetAttr(data,"apps"), 3);
}
if (mxmlElementGetAttr(data,"text")) {
Theme.text_1 = split(mxmlElementGetAttr(data,"text"), 1);
Theme.text_2 = split(mxmlElementGetAttr(data,"text"), 2);
Theme.text_3 = split(mxmlElementGetAttr(data,"text"), 3);
}
if (mxmlElementGetAttr(data,"button_small_text")) {
Theme.button_small_text_1 = split(mxmlElementGetAttr(data,"button_small_text"), 1);
Theme.button_small_text_2 = split(mxmlElementGetAttr(data,"button_small_text"), 2);
Theme.button_small_text_3 = split(mxmlElementGetAttr(data,"button_small_text"), 3);
}
if (mxmlElementGetAttr(data,"button_tiny_text")) {
Theme.button_tiny_text_1 = split(mxmlElementGetAttr(data,"button_tiny_text"), 1);
Theme.button_tiny_text_2 = split(mxmlElementGetAttr(data,"button_tiny_text"), 2);
Theme.button_tiny_text_3 = split(mxmlElementGetAttr(data,"button_tiny_text"), 3);
}
if (mxmlElementGetAttr(data,"progressbar_color1")) {
Theme.progressbar_color1_1 = split(mxmlElementGetAttr(data,"progressbar_color1"), 1);
Theme.progressbar_color1_2 = split(mxmlElementGetAttr(data,"progressbar_color1"), 2);
Theme.progressbar_color1_3 = split(mxmlElementGetAttr(data,"progressbar_color1"), 3);
}
if (mxmlElementGetAttr(data,"progressbar_color2")) {
Theme.progressbar_color2_1 = split(mxmlElementGetAttr(data,"progressbar_color2"), 1);
Theme.progressbar_color2_2 = split(mxmlElementGetAttr(data,"progressbar_color2"), 2);
Theme.progressbar_color2_3 = split(mxmlElementGetAttr(data,"progressbar_color2"), 3);
}
mxmlDelete(data);
mxmlDelete(tree);
}
@ -338,11 +338,11 @@ bool theme_folder_exists(string theme)
DIR *pDir;
folder_exists();
pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Themes").c_str());
pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Themes").c_str());
if(pDir != NULL)
{
pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Themes/" + theme).c_str());
pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Themes/" + theme).c_str());
if(pDir != NULL)
{
closedir (pDir);
@ -350,7 +350,7 @@ bool theme_folder_exists(string theme)
}
else
{
if (mkdir((Settings.device_dat + ":/config/HBF/Themes/" + theme).c_str(), 0777) != -1)
if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Themes/" + theme).c_str(), 0777) != -1)
{
closedir (pDir);
return true;
@ -359,9 +359,9 @@ bool theme_folder_exists(string theme)
}
else
{
if (mkdir((Settings.device_dat + ":/config/HBF/Themes").c_str(), 0777) != -1)
if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Themes").c_str(), 0777) != -1)
{
if (mkdir((Settings.device_dat + ":/config/HBF/Themes/" + theme).c_str(), 0777) != -1)
if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Themes/" + theme).c_str(), 0777) != -1)
{
closedir (pDir);
return true;
@ -370,4 +370,4 @@ bool theme_folder_exists(string theme)
}
closedir (pDir);
return false;
}
}

View File

@ -32,23 +32,18 @@ struct STheme
const u8* dialog_background;
const u8* throbber;
const u8* choice;
const u8* choice_large;
const u8* sd_active;
const u8* sd_inactive;
const u8* usb_active;
const u8* usb_inactive;
const u8* sd_usb_active;
const u8* sd_usb_inactive;
const u8* dvd_active;
const u8* dvd_inactive;
const u8* all_active;
const u8* all_inactive;
const u8* loader_active;
const u8* loader_inactive;
const u8* wii_active;
const u8* wii_inactive;
const u8* gc_active;
const u8* gc_inactive;
const u8* pc_active;
const u8* pc_inactive;
const u8* wii_gc_active;
const u8* wii_gc_inactive;
const u8* power_active;
@ -71,6 +66,11 @@ struct STheme
const u8* player_grab;
const u8* bg_options;
const u8* bg_options_entry;
const u8* bar;
const u8* desktop;
const u8* startmenu;
const u8* startmenu_top;
const u8* menu_selection;
const u8* scrollbar;
const u8* scrollbar_arrowdown;
const u8* scrollbar_arrowdown_over;

View File

@ -69,15 +69,15 @@ const char* tr(string translate)
void translate()
{
if(CONF_GetLanguage() == JAPANESE)
ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "japanese.lang");
ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "japanese.lang");
else if(CONF_GetLanguage() == ENGLISH)
ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "english.lang");
ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "english.lang");
else if(CONF_GetLanguage() == GERMAN)
ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "german.lang");
ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "german.lang");
else if(CONF_GetLanguage() == FRENCH)
ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "french.lang");
ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "french.lang");
else if(CONF_GetLanguage() == SPANISH)
ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "spanish.lang");
ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "spanish.lang");
}
bool language_folder_exists()
@ -87,7 +87,7 @@ bool language_folder_exists()
{
DIR *pDir;
pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Languages").c_str());
pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Languages").c_str());
if(pDir != NULL)
{
@ -96,7 +96,7 @@ bool language_folder_exists()
}
else
{
if (mkdir((Settings.device_dat + ":/config/HBF/Languages").c_str(), 0777) != -1)
if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Languages").c_str(), 0777) != -1)
{
closedir (pDir);
return true;

View File

@ -38,12 +38,6 @@ extern const u32 button_square_png_size;
extern const u8 button_square_focus_png[];
extern const u32 button_square_focus_png_size;
extern const u8 button_large_png[];
extern const u32 button_large_png_size;
extern const u8 button_large_over_png[];
extern const u32 button_large_over_png_size;
extern const u8 dialog_background_png[];
extern const u32 dialog_background_png_size;
@ -170,9 +164,6 @@ extern const u32 throbber_png_size;
extern const u8 choice_png[];
extern const u32 choice_png_size;
extern const u8 choice_large_png[];
extern const u32 choice_large_png_size;
extern const u8 sd_active_png[];
extern const u32 sd_active_png_size;
@ -191,24 +182,6 @@ extern const u32 sd_usb_active_png_size;
extern const u8 sd_usb_inactive_png[];
extern const u32 sd_usb_inactive_png_size;
extern const u8 dvd_active_png[];
extern const u32 dvd_active_png_size;
extern const u8 all_active_png[];
extern const u32 all_active_png_size;
extern const u8 dvd_inactive_png[];
extern const u32 dvd_inactive_png_size;
extern const u8 all_inactive_png[];
extern const u32 all_inactive_png_size;
extern const u8 loader_active_png[];
extern const u32 loader_active_png_size;
extern const u8 loader_inactive_png[];
extern const u32 loader_inactive_png_size;
extern const u8 wii_active_png[];
extern const u32 wii_active_png_size;
@ -221,6 +194,12 @@ extern const u32 gc_active_png_size;
extern const u8 gc_inactive_png[];
extern const u32 gc_inactive_png_size;
extern const u8 pc_active_png[];
extern const u32 pc_active_png_size;
extern const u8 pc_inactive_png[];
extern const u32 pc_inactive_png_size;
extern const u8 wii_gc_active_png[];
extern const u32 wii_gc_active_png_size;
@ -269,12 +248,30 @@ extern const u32 edit_active_png_size;
extern const u8 edit_inactive_png[];
extern const u32 edit_inactive_png_size;
extern const u8 hbc_icon_png[];
extern const u32 hbc_icon_png_size;
extern const u8 recycle_bin_png[];
extern const u32 recycle_bin_png_size;
extern const u8 progress_png[];
extern const u32 progress_png_size;
extern const u8 bar_png[];
extern const u32 bar_png_size;
extern const u8 desktop_png[];
extern const u32 desktop_png_size;
extern const u8 startmenu_png[];
extern const u32 startmenu_png_size;
extern const u8 startmenu_top_png[];
extern const u32 startmenu_top_png_size;
extern const u8 menu_selection_png[];
extern const u32 menu_selection_png_size;
extern const u8 LogoHomebrewFilter_png[];
extern const u32 LogoHomebrewFilter_png_size;

View File

@ -15,7 +15,6 @@
#include <ogcsys.h>
#include <unistd.h>
#include <wiiuse/wpad.h>
#include <dirent.h>
//#include "audio.h"
#include "filelist.h"
@ -31,11 +30,10 @@
#include "Tools/save.h"
#include "Tools/SelectIos.h"
#include "Tools/throbber.h"
//#include "Memory/mem2.h"
#include "Network/network.h"
#include "Network/tcp.h"
#include "BootHomebrew/BootHomebrew.h"
#include "BootHomebrew/dolloader.h"
#include "DiskOperations/di2.h"
#define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0)
@ -49,6 +47,7 @@ extern void ResumeGui();
std::vector<homebrew_list> vechomebrew_list_category[99];
std::vector<homebrew_list> vechomebrew_list_unassigned;
std::vector<homebrew_list> vechomebrew_list_choice;
//std::vector<homebrew_list> vechomebrew_list_pc;
std::vector<app_ios> appios;
struct SSettings Settings;
@ -58,7 +57,6 @@ int ExitRequested = 0;
s8 PowerOff = -1;
bool boothomebrew = false;
bool boot_buffer = false;
bool wiiload = false;
// kopiere ios für app in einen vector
void addAppIos(string foldername, int ios)
@ -80,7 +78,7 @@ void addAppIos(string foldername, int ios)
if(found)
appios[i].ios = ios;
if(!found)
appios.push_back(app_ios(foldername, ios));
appios.push_back(app_ios(foldername, ios));
}
}
@ -88,10 +86,11 @@ void ExitApp()
{
ShutdownPads();
StopGX();
//if(strcasecmp(Settings.code,"NULL") == 0)
if(strcasecmp(Settings.code,"NULL") == 0)
save();
UnmountAllDevices();
UnmountAllDevices();
ISFS_Deinitialize();
// MEM2_cleanup();
}
static void WiiResetPressed()
@ -114,7 +113,6 @@ DefaultSettings()
{
Settings.sd_insert = SDCard_Inserted();
Settings.usb_insert = USBDevice_Inserted();
Settings.dvd_insert = DVD_Inserted();
Settings.category_name_all = "All";
sprintf (Settings.new_category_name, "New Category");
Settings.current_category = 0;
@ -122,19 +120,10 @@ DefaultSettings()
Settings.last_app_pos = -1;
Settings.checkrev = -1;
sprintf (Settings.code, "NULL");
// in kleinbuchstaben umwandeln
/* transform(Settings.MyDir.begin(),Settings.MyDir.end(),Settings.MyDir.begin(),::tolower);
if(Settings.MyDir.substr(0, Settings.MyDir.find(":/")) == "sd")
Settings.MyPath = "sd1" + Settings.MyDir.substr(Settings.MyDir.find(":/"), Settings.MyDir.rfind("/") - Settings.MyDir.find(":/") +1);
else if(Settings.MyDir.substr(0, Settings.MyDir.find(":/")) == "usb")
Settings.MyPath = "usb1" + Settings.MyDir.substr(Settings.MyDir.find(":/"), Settings.MyDir.rfind("/") - Settings.MyDir.find(":/") +1);
else
Settings.MyPath = Settings.MyDir.substr(0, Settings.MyDir.rfind("/") +1);
*/
Settings.Apps_from = EFFECT_SLIDE_TOP; // Apps kommen von "EFFECT_SLIDE_TOP", "EFFECT_SLIDE_BOTTOM", "EFFECT_SLIDE_RIGHT", "EFFECT_SLIDE_LEFT"
Settings.Apps_to = 0; // Apps geht nach "EFFECT_SLIDE_TOP", "EFFECT_SLIDE_BOTTOM", "EFFECT_SLIDE_RIGHT", "EFFECT_SLIDE_LEFT"
Settings.grid = false;
Settings.view = 0;
Settings.system = 1;
Settings.device = "sd1";
Settings.device_dat = "sd1";
@ -147,13 +136,13 @@ DefaultOptions()
sprintf (Options.language, tr("STANDARD"));
sprintf (Options.font, tr("STANDARD"));
sprintf (Options.temp_code, "NULL");
Options.slide_effect = 1;
Options.last_category = 1;
Options.apps = 4;
Options.quick_start = 0;
Options.show_all = 1;
Options.navigation = 0;
Options.apps = 4;
Options.quick_start = 0;
Options.show_all = 1;
Options.navigation = 0;
Options.temp_network = 0;
Options.temp_newrevtext = 1;
}
@ -161,7 +150,6 @@ DefaultOptions()
int
main(int argc, char *argv[])
{
SYS_SetResetCallback(WiiResetPressed);
SYS_SetPowerCallback(WiiPowerPressed);
WPAD_SetPowerButtonCallback(WiimotePowerPressed);
@ -170,15 +158,15 @@ main(int argc, char *argv[])
SetupPads(); // Initialize input
// InitAudio(); // Initialize audio
InitGUIThreads(); // Initialize GUI
//DI2_Init(); // Initialize DVD
MountAllDevices();
InitNetworkThread(); // Initialize Network
InitTcpThread();
InitThrobberThread(); // Initialize Throbber
ISFS_Initialize(); // Initialize Nand
// MEM2_init(52); // Initialize 52 MB (max is 53469152 bytes though)
LoadHBF();
// LoadHBF();
DefaultSettings();
DefaultOptions();
DefaultTheme();
@ -188,77 +176,71 @@ main(int argc, char *argv[])
ResumeNetworkThread();
SetFont();
#ifdef HW_RVL
pointer = new GuiImageData(Theme.player_point);
#endif
mainWindow = new GuiWindow(screenwidth, screenheight);
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
ResumeGui();
debug("test1");
stretch(Settings.top, Settings.bottom, Settings.left, Settings.right);
if(HAVE_AHBPROT)
runtimePatchApply();
DI2_Init(); // Init DVD
if(strstr(Options.language, tr("STANDARD")))
translate();
AvailableCategory.categories[0] = tr(Settings.category_name_all);
check_device();
/* while(1)
{
WPAD_ScanPads();
if(PowerOff != -1)
{
char buffer[20];
sprintf(buffer, "%i", PowerOff);
PowerOff = -1;
debug(buffer);
// menu = MENU_EXIT;
}
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_A)
break;
}
*/
MainMenu(MENU_NONE);
if(boothomebrew)
{
if(SelectedIOS() != IOS_GetVersion())
IOS_ReloadIOS(SelectedIOS());
if(strstr(Settings.forwarder_path.c_str(), ":/apps/") != 0)
BootHomebrew();
else if(strstr(Settings.forwarder_path.c_str(), ":/gc_apps/") != 0)
BootGameCubeHomebrew();
}
if(Settings.forwarder_path != "the homebrew channel")
{
if(strstr(Settings.forwarder_path.c_str(), ":/apps/") != 0)
BootHomebrew();
else if(strstr(Settings.forwarder_path.c_str(), ":/gc_apps/") != 0)
BootGameCubeHomebrew();
}
else
LoadHBC();
}
else if(boot_buffer)
if(wiiload)
BootHomebrew();
if(get_bootmii() == 2)
IOS_ReloadIOS(254);
if(get_nandemu() == 2)
{
if (opendir(check_path("sd1:/apps/NANDEmu-Boot").c_str()) != NULL)
{
LoadHomebrew ("sd1:/apps/NANDEmu-Boot/boot.dol");
BootHomebrew ();
}
else if (opendir(check_path("usb1:/apps/NANDEmu-Boot").c_str()) != NULL)
{
LoadHomebrew ("usb1:/apps/NANDEmu-Boot/boot.dol");
BootHomebrew ();
}
}
if(get_priiloader() == 2)
{
*(vu32*)0x8132FFFB = 0x4461636f;
DCFlushRange((void*)0x8132FFFB, 4);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
if(PowerOff == SYS_RETURNTOMENU)
{
*(vu32*)0x8132FFFB = 0x50756E65;
DCFlushRange((void*)0x8132FFFB, 4);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
else if(PowerOff != -1)
if(PowerOff != -1)
SYS_ResetSystem(PowerOff, 0, 0);
return 0;

View File

@ -17,7 +17,7 @@
#include "Tools/theme.h"
#include "Tools/translate.h"
#include "Tools/fileop.h"
#include "../svnrev/svnrev.h"
#include "../../svnrev/svnrev.h"
#define HW_REG_BASE 0xcd800000
#define HW_ARMIRQMASK (HW_REG_BASE + 0x03c)
@ -48,6 +48,7 @@ public:
extern std::vector<homebrew_list> vechomebrew_list_category[99];
extern std::vector<homebrew_list> vechomebrew_list_unassigned;
extern std::vector<homebrew_list> vechomebrew_list_choice;
extern std::vector<homebrew_list> vechomebrew_list_pc;
class app_ios
{
@ -68,7 +69,6 @@ struct SSettings
string device;
int sd_insert;
int usb_insert;
int dvd_insert;
string category_name_all;
string category_name;
char new_category_name[256];
@ -90,15 +90,10 @@ struct SSettings
int Apps_from;
int Apps_to;
bool grid;
int view;
bool unassigned;
int system; // 0 = GC / 1 = Wii / 2 = Wii/GC
int temp_width;
int temp_height;
int temp_horizontal;
int temp_vertical;
int left, right, bottom, top;
};
extern struct SSettings Settings;
@ -118,10 +113,10 @@ struct SOptions
char theme[256];
char language[256];
char font[256];
int apps;
int apps;
bool quick_start;
bool show_all;
int device_icon;
int device_icon;
bool navigation;
bool network;
bool newrevtext;

View File

@ -161,16 +161,6 @@ UpdateGUI (void *arg)
check_sd();
check_usb();
}
else if(Settings.device == "dvd")
check_dvd();
else if(Settings.device == "all")
{
check_sd();
check_usb();
check_dvd();
}
// screenshoot
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_1 && WPAD_ButtonsDown(0) & WPAD_BUTTON_2)
@ -215,6 +205,8 @@ void MainMenu(int menu)
bgImg = new GuiImage(new GuiImageData(Theme.background));
mainWindow->Append(bgImg);
debug("test");
while(currentMenu != MENU_EXIT)
{

View File

@ -6,28 +6,23 @@ Coder : frontier
More info : http://frontier-dev.net
Modified by Tantric, 2009
********************************************************************************************/
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include "png.h"
#include "pngu.h"
#include "pngu_impl.h"
#include "png.h"
#ifndef SAFE_FREE
#define SAFE_FREE(p) if(p){free(p);p=NULL;}
#endif
#if 0
// moved to pngu_impl.h
// Constants
#define PNGU_SOURCE_BUFFER 1
#define PNGU_SOURCE_DEVICE 2
// Prototypes of helper functions
int pngu_info (IMGCTX ctx);
int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha);
int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha, int force32bit);
void pngu_free_info (IMGCTX ctx);
void pngu_read_data_from_buffer (png_structp png_ptr, png_bytep data, png_size_t length);
void pngu_write_data_to_buffer (png_structp png_ptr, png_bytep data, png_size_t length);
@ -42,7 +37,6 @@ struct _IMGCTX
void *buffer;
char *filename;
PNGU_u32 cursor;
PNGU_u32 buf_size; // buffer size
PNGU_u32 propRead;
PNGUPROP prop;
@ -55,19 +49,18 @@ struct _IMGCTX
png_bytep *row_pointers;
png_bytep img_data;
};
#endif
// PNGU Implementation //
IMGCTX PNGU_SelectImageFromBufferX (const void *buffer, int size)
IMGCTX PNGU_SelectImageFromBuffer (const void *buffer)
{
IMGCTX ctx = NULL;
if (!buffer)
return NULL;
ctx = calloc (sizeof (struct _IMGCTX), 1);
ctx = malloc (sizeof (struct _IMGCTX));
if (!ctx)
return NULL;
@ -77,16 +70,10 @@ IMGCTX PNGU_SelectImageFromBufferX (const void *buffer, int size)
ctx->filename = NULL;
ctx->propRead = 0;
ctx->infoRead = 0;
ctx->buf_size = size;
return ctx;
}
IMGCTX PNGU_SelectImageFromBuffer (const void *buffer)
{
return PNGU_SelectImageFromBufferX(buffer, 0);
}
IMGCTX PNGU_SelectImageFromDevice (const char *filename)
{
@ -95,7 +82,7 @@ IMGCTX PNGU_SelectImageFromDevice (const char *filename)
if (!filename)
return NULL;
ctx = calloc (sizeof (struct _IMGCTX), 1);
ctx = malloc (sizeof (struct _IMGCTX));
if (!ctx)
return NULL;
@ -698,361 +685,6 @@ int PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
}
//########################################################################################
//---------- Start CMPR added section ---------------------------------------------------
//########################################################################################
static inline PNGU_u16 rgb8ToRGB565(PNGU_u8 *color)
{
return ((color[0] >> 3) << 11) | ((color[1] >> 2) << 5) | (color[2] >> 3);
}
static int colorDistance(const PNGU_u8 *c0, const PNGU_u8 *c1)
{
return (c1[0] - c0[0]) * (c1[0] - c0[0]) + (c1[1] - c0[1]) * (c1[1] - c0[1]) + (c1[2] - c0[2]) * (c1[2] - c0[2]);
}
static void getBaseColors(PNGU_u8 *color0, PNGU_u8 *color1, const PNGU_u8 *srcBlock)
{
int maxDistance = -1;
int i;
int j;
for (i = 0; i < 15; ++i)
for (j = i + 1; j < 16; ++j)
{
int distance = colorDistance(srcBlock + i * 4, srcBlock + j * 4);
if (distance > maxDistance)
{
maxDistance = distance;
*(PNGU_u32 *)color0 = ((PNGU_u32 *)srcBlock)[i];
*(PNGU_u32 *)color1 = ((PNGU_u32 *)srcBlock)[j];
}
}
if (rgb8ToRGB565(color0) < rgb8ToRGB565(color1))
{
PNGU_u32 tmp;
tmp = *(PNGU_u32 *)color0;
*(PNGU_u32 *)color0 = *(PNGU_u32 *)color1;
*(PNGU_u32 *)color1 = tmp;
}
}
static PNGU_u32 colorIndices(const PNGU_u8 *color0, const PNGU_u8 *color1, const PNGU_u8 *srcBlock)
{
PNGU_u16 colors[4][4];
PNGU_u32 res = 0;
int i;
// Make the 4 colors available in the block
colors[0][0] = (color0[0] & 0xF8) | (color0[0] >> 5);
colors[0][1] = (color0[1] & 0xFC) | (color0[1] >> 6);
colors[0][2] = (color0[2] & 0xF8) | (color0[2] >> 5);
colors[1][0] = (color1[0] & 0xF8) | (color1[0] >> 5);
colors[1][1] = (color1[1] & 0xFC) | (color1[1] >> 6);
colors[1][2] = (color1[2] & 0xF8) | (color1[2] >> 5);
colors[2][0] = (2 * colors[0][0] + 1 * colors[1][0]) / 3;
colors[2][1] = (2 * colors[0][1] + 1 * colors[1][1]) / 3;
colors[2][2] = (2 * colors[0][2] + 1 * colors[1][2]) / 3;
colors[3][0] = (1 * colors[0][0] + 2 * colors[1][0]) / 3;
colors[3][1] = (1 * colors[0][1] + 2 * colors[1][1]) / 3;
colors[3][2] = (1 * colors[0][2] + 2 * colors[1][2]) / 3;
for (i = 15; i >= 0; --i)
{
int c0 = srcBlock[i * 4 + 0];
int c1 = srcBlock[i * 4 + 1];
int c2 = srcBlock[i * 4 + 2];
int d0 = abs(colors[0][0] - c0) + abs(colors[0][1] - c1) + abs(colors[0][2] - c2);
int d1 = abs(colors[1][0] - c0) + abs(colors[1][1] - c1) + abs(colors[1][2] - c2);
int d2 = abs(colors[2][0] - c0) + abs(colors[2][1] - c1) + abs(colors[2][2] - c2);
int d3 = abs(colors[3][0] - c0) + abs(colors[3][1] - c1) + abs(colors[3][2] - c2);
int b0 = d0 > d3;
int b1 = d1 > d2;
int b2 = d0 > d2;
int b3 = d1 > d3;
int b4 = d2 > d3;
int x0 = b1 & b2;
int x1 = b0 & b3;
int x2 = b0 & b4;
res |= (x2 | ((x0 | x1) << 1)) << ((15 - i) << 1);
}
return res;
}
int PNGU_DecodeToCMPR_Trim(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer)
{
int result;
PNGU_u8 srcBlock[16 * 4];
PNGU_u8 color0[4];
PNGU_u8 color1[4];
PNGU_u8 *outBuf = (PNGU_u8 *)buffer;
int ii;
int jj;
int k;
//check for alpha channel
result = pngu_decode_add_alpha (ctx, width, height, 0, 1);
if (result != PNGU_OK)
return result;
// trim down
width = width & ~7u;
height = height & ~7u;
// Alpha channel present, copy image to the output buffer
for (jj = 0; jj < height; jj += 8)
for (ii = 0; ii < width; ii += 8)
for (k = 0; k < 4; ++k)
{
int j = jj + ((k >> 1) << 2); // jj + 0, jj + 0, jj + 4, jj + 4
int i = ii + ((k & 1) << 2); // ii + 0, ii + 4, ii + 0, ii + 4
memcpy(srcBlock, ctx->row_pointers[j] + i * 4, 16);
memcpy(srcBlock + 4 * 4, ctx->row_pointers[j + 1] + i * 4, 16);
memcpy(srcBlock + 8 * 4, ctx->row_pointers[j + 2] + i * 4, 16);
memcpy(srcBlock + 12 * 4, ctx->row_pointers[j + 3] + i * 4, 16);
getBaseColors(color0, color1, srcBlock);
*(PNGU_u16 *)outBuf = rgb8ToRGB565(color0);
outBuf += 2;
*(PNGU_u16 *)outBuf = rgb8ToRGB565(color1);
outBuf += 2;
*(PNGU_u32 *)outBuf = colorIndices(color0, color1, srcBlock);
outBuf += 4;
}
// Free resources
free (ctx->img_data);
free (ctx->row_pointers);
// Success
return PNGU_OK;
}
// if width or height is not divisible by 8
// then the remaining will be padded with last row/column
// buffer must be allocated with width and height rounded up
int PNGU_DecodeToCMPR_Pad(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer)
{
int result;
PNGU_u8 srcBlock[16 * 4];
PNGU_u8 color0[4];
PNGU_u8 color1[4];
PNGU_u8 *outBuf = (PNGU_u8 *)buffer;
int ii;
int jj;
int k;
//check for alpha channel
result = pngu_decode_add_alpha (ctx, width, height, 0, 1);
if (result != PNGU_OK)
return result;
// Alpha channel present, copy image to the output buffer
for (jj = 0; jj < height; jj += 8) {
for (ii = 0; ii < width; ii += 8) {
for (k = 0; k < 4; ++k) {
// k(i,j)
// 0(0,0) 1(4,0)
// 2(4,0) 3(4,4)
int i = ii + ((k & 1) << 2); // ii + 0, ii + 4, ii + 0, ii + 4
int j = jj + ((k >> 1) << 2); // jj + 0, jj + 0, jj + 4, jj + 4
int ny; // 4 lines
int px = 4; // num columns to copy
if (i >= width) i = width - 1;
if (i + px > width) px = width - i;
for (ny=0; ny<4; ny++) {
if (j >= height) j = height - 1;
memcpy(srcBlock + ny * 4 * 4,
ctx->row_pointers[j] + i * 4, px * 4);
if (px < 4) {
// repeat last column (4-px) times
int x = width - 1;
int nx;
for (nx = px; nx < 4; nx++) {
memcpy(srcBlock + ny * 4 * 4 + nx * 4,
ctx->row_pointers[j] + x * 4, 4);
}
}
j++;
}
getBaseColors(color0, color1, srcBlock);
*(PNGU_u16 *)outBuf = rgb8ToRGB565(color0);
outBuf += 2;
*(PNGU_u16 *)outBuf = rgb8ToRGB565(color1);
outBuf += 2;
*(PNGU_u32 *)outBuf = colorIndices(color0, color1, srcBlock);
outBuf += 4;
}
}
}
// Free resources
free (ctx->img_data);
free (ctx->row_pointers);
// Success
return PNGU_OK;
}
void ExtractBlock( PNGU_u8 *inPtr, int y, int x, PNGU_u32 width, int i, PNGU_u8 colorBlock[] ) {
PNGU_u32 offset;
PNGU_u8 r, g, b, a;
offset = (((y >> 2)<<4)*width) + ((x >> 2)<<6) + ((((y&3) << 2) + (x&3) ) << 1);
//offset = (((y >> 2) << 4)*width) + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1);
//get rgba values based on the RGBA8 offsets
a = *(inPtr+offset);
r = *(inPtr+offset+1);
g = *(inPtr+offset+32);
b = *(inPtr+offset+33);
colorBlock[i*4] = r;
colorBlock[i*4+1] = g;
colorBlock[i*4+2] = b;
colorBlock[i*4+3] = a;
}
/**
* by usptactical
* Converts a 4x4 RGBA8 image to CMPR.
*/
int PNGU_4x4RGBA8_To_CMPR(void *buf_rgb, PNGU_u32 width, PNGU_u32 height, void *buf_cmpr)
{
PNGU_u8 srcBlock[16 * 4];
PNGU_u8 color0[4];
PNGU_u8 color1[4];
PNGU_u8 *outBuf = (PNGU_u8 *)buf_cmpr;
PNGU_u8 *rgba = (PNGU_u8 *)buf_rgb;
int jj, ii, i, j, k;
width = width & ~7u;
height = height & ~7u;
// loop over blocks
//CMPR needs 4x4 block of pixels:
//image row 0: 0, 1, 2, 3 (first 16 block)
//image row 1: 0, 1, 2, 3 (second 16 block)
//image row 2: 0, 1, 2, 3 (third 16 block)
//image row 3: 0, 1, 2, 3 (last 16 block)
//image row 0: 4, 5, 6, 7 (first 16 block)
//image row 1: 4, 5, 6, 7 (second 16 block)
//image row 2: 4, 5, 6, 7 (third 16 block)
//image row 3: 4, 5, 6, 7 (last 16 block)
//image row 4: 0, 1, 2, 3 (first 16 block)
//image row 5: 0, 1, 2, 3 (second 16 block)
//image row 6: 0, 1, 2, 3 (third 16 block)
//image row 7: 0, 1, 2, 3 (last 16 block)
//image row 4: 4, 5, 6, 7 (first 16 block)
//image row 5: 4, 5, 6, 7 (second 16 block)
//image row 6: 4, 5, 6, 7 (third 16 block)
//image row 7: 4, 5, 6, 7 (last 16 block)
for(jj = 0; jj < height; jj += 8)
for(ii = 0; ii < width; ii += 8)
for (k=0; k < 4; k++)
{
j = jj + ((k >> 1) << 2); // jj + 0, jj + 0, jj + 4, jj + 4
i = ii + ((k & 1) << 2); // ii + 0, ii + 4, ii + 0, ii + 4
ExtractBlock(rgba, j, i, width, 0, srcBlock);
ExtractBlock(rgba, j, i+1, width, 1, srcBlock);
ExtractBlock(rgba, j, i+2, width, 2, srcBlock);
ExtractBlock(rgba, j, i+3, width, 3, srcBlock);
ExtractBlock(rgba, j+1, i, width, 4, srcBlock);
ExtractBlock(rgba, j+1, i+1, width, 5, srcBlock);
ExtractBlock(rgba, j+1, i+2, width, 6, srcBlock);
ExtractBlock(rgba, j+1, i+3, width, 7, srcBlock);
ExtractBlock(rgba, j+2, i, width, 8, srcBlock);
ExtractBlock(rgba, j+2, i+1, width, 9, srcBlock);
ExtractBlock(rgba, j+2, i+2, width, 10, srcBlock);
ExtractBlock(rgba, j+2, i+3, width, 11, srcBlock);
ExtractBlock(rgba, j+3, i, width, 12, srcBlock);
ExtractBlock(rgba, j+3, i+1, width, 13, srcBlock);
ExtractBlock(rgba, j+3, i+2, width, 14, srcBlock);
ExtractBlock(rgba, j+3, i+3, width, 15, srcBlock);
getBaseColors(color0, color1, srcBlock);
*(PNGU_u16 *)outBuf = rgb8ToRGB565(color0);
outBuf += 2;
*(PNGU_u16 *)outBuf = rgb8ToRGB565(color1);
outBuf += 2;
*(PNGU_u32 *)outBuf = colorIndices(color0, color1, srcBlock);
outBuf += 4;
}
// Success
return PNGU_OK;
}
// if width or height is not divisible by 8
// then the remaining will be padded with last row/column
// buffer must be allocated with width and height rounded up
int PNGU_RGBA8_To_CMPR(void *buf_rgb, PNGU_u32 width, PNGU_u32 height, void *buf_cmpr)
{
PNGU_u8 srcBlock[16 * 4];
PNGU_u8 color0[4];
PNGU_u8 color1[4];
PNGU_u8 *src, *block;
PNGU_u8 *cmpr = (PNGU_u8 *)buf_cmpr;
PNGU_u8 *rgba = (PNGU_u8 *)buf_rgb;
int jj, ii, i, j, k;
int x, y; // counter
int px, py; // pixel coord
for(jj = 0; jj < height; jj += 8) {
for(ii = 0; ii < width; ii += 8) {
for (k=0; k < 4; k++) {
i = ii + ((k & 1) << 2); // ii + 0, ii + 4, ii + 0, ii + 4
j = jj + ((k >> 1) << 2); // jj + 0, jj + 0, jj + 4, jj + 4
block = srcBlock;
for (y=0; y<4; y++) {
py = j + y;
if (py >= height) py = height - 1;
src = rgba + py * width * 4;
for (x=0; x<4; x++) {
px = i + x;
if (px >= width) px = width - 1;
memcpy(block, src + px * 4, 4);
block += 4;
}
}
getBaseColors(color0, color1, srcBlock);
*(PNGU_u16 *)cmpr = rgb8ToRGB565(color0);
cmpr += 2;
*(PNGU_u16 *)cmpr = rgb8ToRGB565(color1);
cmpr += 2;
*(PNGU_u32 *)cmpr = colorIndices(color0, color1, srcBlock);
cmpr += 4;
}
}
}
// Success
return PNGU_OK;
}
/**
* added by usptactical
* handles png error messages
*/
void user_error (png_structp png_ptr, png_const_charp c)
{
longjmp(png_jmpbuf(png_ptr), 1);
}
//########################################################################################
//---------- End CMPR added section -----------------------------------------------------
//########################################################################################
int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride)
{
png_uint_32 rowbytes;
@ -1077,21 +709,21 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
// Allocation of libpng structs
ctx->png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!(ctx->png_ptr))
if (!(ctx->png_ptr))
{
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
return PNGU_LIB_ERROR;
return PNGU_LIB_ERROR;
}
ctx->info_ptr = png_create_info_struct (ctx->png_ptr);
if (!(ctx->info_ptr))
{
ctx->info_ptr = png_create_info_struct (ctx->png_ptr);
if (!(ctx->info_ptr))
{
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
return PNGU_LIB_ERROR;
}
return PNGU_LIB_ERROR;
}
if (ctx->source == PNGU_SOURCE_BUFFER)
{
@ -1106,7 +738,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
}
// Setup output file properties
png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB,
png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
// Allocate memory to store the image in RGB format
@ -1165,6 +797,138 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
return PNGU_OK;
}
int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride)
{
png_uint_32 rowbytes;
PNGU_u32 y;
// Erase from the context any readed info
pngu_free_info (ctx);
ctx->propRead = 0;
// Check if the user has selected a file to write the image
if (ctx->source == PNGU_SOURCE_BUFFER);
else if (ctx->source == PNGU_SOURCE_DEVICE)
{
// Open file
if (!(ctx->fd = fopen (ctx->filename, "wb")))
return PNGU_CANT_OPEN_FILE;
}
else
return PNGU_NO_FILE_SELECTED;
// Allocation of libpng structs
ctx->png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!(ctx->png_ptr))
{
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
return PNGU_LIB_ERROR;
}
ctx->info_ptr = png_create_info_struct (ctx->png_ptr);
if (!(ctx->info_ptr))
{
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
return PNGU_LIB_ERROR;
}
if (ctx->source == PNGU_SOURCE_BUFFER)
{
// Installation of our custom data writer function
ctx->cursor = 0;
png_set_write_fn (ctx->png_ptr, ctx, pngu_write_data_to_buffer, pngu_flush_data_to_buffer);
}
else if (ctx->source == PNGU_SOURCE_DEVICE)
{
// Default data writer uses function fwrite, so it needs to use our FILE*
png_init_io (ctx->png_ptr, ctx->fd);
}
// Setup output file properties
png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
// Allocate memory to store the image in RGB format
rowbytes = width * 3;
if (rowbytes % 4)
rowbytes = ((rowbytes / 4) + 1) * 4; // Add extra padding so each row starts in a 4 byte boundary
ctx->img_data = malloc(rowbytes * height);
memset(ctx->img_data, 0, rowbytes * height);
if (!ctx->img_data)
{
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
return PNGU_LIB_ERROR;
}
ctx->row_pointers = malloc (sizeof (png_bytep) * height);
memset(ctx->row_pointers, 0, sizeof (png_bytep) * height);
if (!ctx->row_pointers)
{
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
return PNGU_LIB_ERROR;
}
for (y = 0; y < height; y++)
{
ctx->row_pointers[y] = buffer + (y * rowbytes);
}
// Tell libpng where is our image data
png_set_rows (ctx->png_ptr, ctx->info_ptr, ctx->row_pointers);
// Write file header and image data
png_write_png (ctx->png_ptr, ctx->info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
// Tell libpng we have no more data to write
png_write_end (ctx->png_ptr, (png_infop) NULL);
// Free resources
free (ctx->img_data);
free (ctx->row_pointers);
png_destroy_write_struct (&(ctx->png_ptr), &(ctx->info_ptr));
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
// Success
return ctx->cursor;
}
int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride)
{
int x,y,res;
unsigned char * ptr = (unsigned char*)buffer;
unsigned char * tmpbuffer = (unsigned char *)malloc(width*height*3);
memset(tmpbuffer, 0, width*height*3);
png_uint_32 offset;
for(y=0; y < height; y++)
{
for(x=0; x < width; x++)
{
offset = (((y >> 2)<<4)*width) + ((x >> 2)<<6) + (((y%4 << 2) + x%4 ) << 1);
tmpbuffer[y*640*3+x*3] = ptr[offset+1]; // R
tmpbuffer[y*640*3+x*3+1] = ptr[offset+32]; // G
tmpbuffer[y*640*3+x*3+2] = ptr[offset+33]; // B
}
}
res = PNGU_EncodeFromRGB (ctx, width, height, tmpbuffer, stride);
free(tmpbuffer);
return res;
}
// This function is taken from a libogc example
PNGU_u32 PNGU_RGB8_TO_YCbYCr (PNGU_u8 r1, PNGU_u8 g1, PNGU_u8 b1, PNGU_u8 r2, PNGU_u8 g2, PNGU_u8 b2)
@ -1226,7 +990,7 @@ int pngu_info (IMGCTX ctx)
return PNGU_CANT_OPEN_FILE;
// Load first 8 bytes into magic buffer
if (fread (magic, 1, 8, ctx->fd) != 8)
if (fread (magic, 1, 8, ctx->fd) != 8)
{
fclose (ctx->fd);
return PNGU_CANT_READ_FILE;
@ -1245,21 +1009,21 @@ int pngu_info (IMGCTX ctx)
// Allocation of libpng structs
ctx->png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!(ctx->png_ptr))
if (!(ctx->png_ptr))
{
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
return PNGU_LIB_ERROR;
return PNGU_LIB_ERROR;
}
ctx->info_ptr = png_create_info_struct (ctx->png_ptr);
if (!(ctx->info_ptr))
{
ctx->info_ptr = png_create_info_struct (ctx->png_ptr);
if (!(ctx->info_ptr))
{
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose (ctx->fd);
png_destroy_read_struct (&(ctx->png_ptr), (png_infopp)NULL, (png_infopp)NULL);
return PNGU_LIB_ERROR;
}
png_destroy_read_struct (&(ctx->png_ptr), (png_infopp)NULL, (png_infopp)NULL);
return PNGU_LIB_ERROR;
}
if (ctx->source == PNGU_SOURCE_BUFFER)
{
@ -1376,15 +1140,10 @@ int pngu_info (IMGCTX ctx)
}
int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha, int force32bit)
int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha)
{
png_uint_32 rowbytes;
int i;
int chunk;
int rowsLeft;
png_bytep *curRow;
int mem_err = 0;
// Read info if it hasn't been read before
if (!ctx->infoRead)
@ -1402,43 +1161,22 @@ int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32
if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_PALETTE) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_UNKNOWN) )
return PNGU_UNSUPPORTED_COLOR_TYPE;
//*************************************************
//* added by usptactical to catch corrupted pngs *
jmp_buf save_jmp;
memcpy(save_jmp, png_jmpbuf(ctx->png_ptr), sizeof(save_jmp));
if (setjmp(png_jmpbuf(ctx->png_ptr))) {
error:
memcpy(png_jmpbuf(ctx->png_ptr), save_jmp, sizeof(save_jmp));
SAFE_FREE(ctx->row_pointers);
SAFE_FREE(ctx->img_data);
pngu_free_info (ctx);
//printf("*** This is a corrupted image!!\n"); sleep(5);
return (mem_err)?PNGU_LIB_ERROR:-666;
}
//override default error handler to suppress warning messages from libpng
png_set_error_fn (ctx->png_ptr, NULL, user_error, user_error);
//*************************************************
// Scale 16 bit samples to 8 bit
if (ctx->prop.imgBitDepth == 16)
png_set_strip_16 (ctx->png_ptr);
png_set_strip_16 (ctx->png_ptr);
// Remove alpha channel if we don't need it
if (stripAlpha && ((ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB_ALPHA) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA)))
png_set_strip_alpha (ctx->png_ptr);
png_set_strip_alpha (ctx->png_ptr);
// Expand 1, 2 and 4 bit samples to 8 bit
if (ctx->prop.imgBitDepth < 8)
png_set_packing (ctx->png_ptr);
png_set_packing (ctx->png_ptr);
// Transform grayscale images to RGB
if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA) )
png_set_gray_to_rgb (ctx->png_ptr);
// Transform RBG images to RGBA
if (force32bit && (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY || ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB))
png_set_filler(ctx->png_ptr, 0xFF, PNG_FILLER_AFTER);
// Flush transformations
png_read_update_info (ctx->png_ptr, ctx->info_ptr);
@ -1450,44 +1188,23 @@ int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32
ctx->img_data = malloc (rowbytes * ctx->prop.imgHeight);
if (!ctx->img_data)
{
//pngu_free_info (ctx);
//return PNGU_LIB_ERROR;
mem_err = 1;
goto error;
pngu_free_info (ctx);
return PNGU_LIB_ERROR;
}
ctx->row_pointers = malloc (sizeof (png_bytep) * ctx->prop.imgHeight);
if (!ctx->row_pointers)
{
//free (ctx->img_data);
//pngu_free_info (ctx);
//return PNGU_LIB_ERROR;
mem_err = 1;
goto error;
free (ctx->img_data);
pngu_free_info (ctx);
return PNGU_LIB_ERROR;
}
for (i = 0; i < (int)ctx->prop.imgHeight; i++)
for (i = 0; i < ctx->prop.imgHeight; i++)
ctx->row_pointers[i] = ctx->img_data + (i * rowbytes);
// Transform the image and copy it to our allocated memory
if (png_get_interlace_type(ctx->png_ptr, ctx->info_ptr) != PNG_INTERLACE_NONE)
png_read_image (ctx->png_ptr, ctx->row_pointers);
else
{
rowsLeft = ctx->prop.imgHeight;
curRow = ctx->row_pointers;
while (rowsLeft > 0)
{
chunk = rowsLeft > 0x80 ? 0x80 : rowsLeft;
png_read_rows(ctx->png_ptr, curRow, NULL, chunk);
//usleep(1000);
curRow += chunk;
rowsLeft -= chunk;
}
}
// restore default error handling
memcpy(png_jmpbuf(ctx->png_ptr), save_jmp, sizeof(save_jmp));
png_read_image (ctx->png_ptr, ctx->row_pointers);
// Free resources
pngu_free_info (ctx);
@ -1496,11 +1213,6 @@ int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32
return PNGU_OK;
}
int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha)
{
return pngu_decode_add_alpha(ctx, width, height, stripAlpha, 0);
}
void pngu_free_info (IMGCTX ctx)
{
@ -1520,13 +1232,6 @@ void pngu_free_info (IMGCTX ctx)
void pngu_read_data_from_buffer (png_structp png_ptr, png_bytep data, png_size_t length)
{
IMGCTX ctx = (IMGCTX) png_get_io_ptr (png_ptr);
if (ctx->buf_size && (ctx->cursor + length > ctx->buf_size))
{
static char err_str[40];
snprintf(err_str, sizeof(err_str), "read error (%x/%x)",
ctx->cursor + length, ctx->buf_size);
png_error(png_ptr, err_str);
}
memcpy (data, ctx->buffer + ctx->cursor, length);
ctx->cursor += length;
}

View File

@ -6,6 +6,8 @@ Coder : frontier
More info : http://frontier-dev.net
Modified by Tantric, 2009
********************************************************************************************/
#ifndef __PNGU__
#define __PNGU__
@ -90,7 +92,6 @@ void PNGU_YCbYCr_TO_RGB8 (PNGU_u32 ycbycr, PNGU_u8 *r1, PNGU_u8 *g1, PNGU_u8 *b1
// Selects a PNG file, previosly loaded into a buffer, and creates an image context for subsequent procesing.
IMGCTX PNGU_SelectImageFromBuffer (const void *buffer);
IMGCTX PNGU_SelectImageFromBufferX (const void *buffer, int size);
// Selects a PNG file, from any devoptab device, and creates an image context for subsequent procesing.
IMGCTX PNGU_SelectImageFromDevice (const char *filename);
@ -139,17 +140,12 @@ int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe
// Macro for decoding an image inside a buffer at given coordinates.
#define PNGU_DECODE_TO_COORDS_RGBA8(ctx,coordX,coordY,imgWidth,imgHeight,default_alpha,bufferWidth,bufferHeight,buffer) \
\
PNGU_DecodeToRGBA8 (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 4 + \
(coordX) * 4, (bufferWidth) - (imgWidth), default_alpha)
PNGU_DecodeToRGBA8 (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \
(coordX) * 2, (bufferWidth) - (imgWidth), default_alpha)
// Expands selected image into a 4x4 tiled RGB565 buffer. You need to specify context, image dimensions
// and destination address.
int PNGU_DecodeTo4x4RGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer);
// Compressed version (DXT1/CMPR)
int PNGU_DecodeToCMPR_Trim(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer);
int PNGU_DecodeToCMPR_Pad(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer);
int PNGU_4x4RGBA8_To_CMPR(void *buf_rgb, PNGU_u32 width, PNGU_u32 height, void *buf_cmpr);
int PNGU_RGBA8_To_CMPR(void *buf_rgb, PNGU_u32 width, PNGU_u32 height, void *buf_cmpr);
// Expands selected image into a 4x4 tiled RGB5A3 buffer. You need to specify context, image dimensions,
// destination address and default alpha value, which is used if the source image doesn't have an alpha channel.
@ -163,16 +159,15 @@ int PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
// specify context, image dimensions, destination address and stride in pixels (stride = buffer width - image width).
int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride);
int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride);
int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride);
// Macro for encoding an image stored into an YCbYCr buffer at given coordinates.
#define PNGU_ENCODE_TO_COORDS_YCbYCr(ctx,coordX,coordY,imgWidth,imgHeight,bufferWidth,bufferHeight,buffer) \
\
PNGU_EncodeFromYCbYCr (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \
(coordX) * 2, (bufferWidth) - (imgWidth))
PNGU_u8 * PNGU_DecodeTo4x4RGBA8_EX (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight, PNGU_u8 *dstPtr);
int PNGU_EncodeFromEFB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stride);
#ifdef __cplusplus
}
#endif