*using new app_booter for homebrew booting (see WiiXplorer changelog)

*reload back to entry ios when starting homebrew instead of starting it in cIOS
*removed limit of .csv and .txt gamelist creation
*fixed META.XML format
*Added use of the internal Wii System Menu font (removed old one) (thx to giantpune and r-win)
*Changed default Font Scale to 0.8 to fit with the new font. If you don't reset configs it's recommended to change it manually in the settings to 0.8.
This commit is contained in:
dimok321 2011-07-23 19:49:51 +00:00
parent f8ae27c2e2
commit 4a2899ac38
24 changed files with 208 additions and 190 deletions

View File

@ -2,14 +2,14 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>2.2 r1099</version>
<release_date>201106272106</release_date>
<version>2.2 r1101</version>
<release_date>201106301853</release_date>
<!-- // remove this line to enable arguments
<arguments>
<arg>--ios=250</arg>
<arg>--usbport=0</arg>
</arguments>
--> // remove this line to enable arguments
// remove this line to enable arguments -->
<no_ios_reload/>
<short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.

BIN
data/app_booter.bin Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -63,15 +63,23 @@ wchar_t* charToWideChar(const char* strChar)
/**
* Default constructor for the FreeTypeGX class for WiiXplorer.
*/
FreeTypeGX::FreeTypeGX(const uint8_t* fontBuffer, FT_Long bufferSize)
FreeTypeGX::FreeTypeGX(const uint8_t* fontBuffer, FT_Long bufferSize, bool lastFace)
{
int faceIndex = 0;
ftPointSize = 0;
FT_Init_FreeType(&ftLibrary);
FT_New_Memory_Face(ftLibrary, (FT_Byte *) fontBuffer, bufferSize, 0, &ftFace);
if(lastFace)
{
FT_New_Memory_Face(ftLibrary, (FT_Byte *)fontBuffer, bufferSize, -1, &ftFace);
faceIndex = ftFace->num_faces - 1; // Use the last face
FT_Done_Face(ftFace);
ftFace = NULL;
}
FT_New_Memory_Face(ftLibrary, (FT_Byte *) fontBuffer, bufferSize, faceIndex, &ftFace);
setVertexFormat(GX_VTXFMT1);
ftKerningEnabled = false;
ftKerningEnabled = false;//FT_HAS_KERNING(ftFace);
}
/**

View File

@ -132,7 +132,7 @@ class FreeTypeGX
int16_t screenZ, GXColor color);
public:
FreeTypeGX(const uint8_t* fontBuffer, FT_Long bufferSize);
FreeTypeGX(const uint8_t* fontBuffer, FT_Long bufferSize, bool lastFace = false);
~FreeTypeGX();
void setVertexFormat(uint8_t vertexIndex);

View File

@ -312,7 +312,7 @@ void Text::Draw()
GXColor c = color;
c.a = this->GetAlpha();
int newSize = (int) (size * GetScale() * Settings.FontScaleFactor);
int newSize = (int) (size * GetScale());
if (newSize != currentSize)
{

View File

@ -32,7 +32,7 @@ static GXColor presetColor = (GXColor) {255, 255, 255, 255};
GuiText::GuiText(const char * t, int s, GXColor c)
{
text = NULL;
size = s;
size = (int) (s * Settings.FontScaleFactor);
currentSize = size;
color = c;
alpha = c.a;
@ -61,7 +61,7 @@ GuiText::GuiText(const char * t, int s, GXColor c)
GuiText::GuiText(const wchar_t * t, int s, GXColor c)
{
text = NULL;
size = s;
size = (int) (s * Settings.FontScaleFactor);
currentSize = size;
color = c;
alpha = c.a;
@ -95,7 +95,7 @@ GuiText::GuiText(const wchar_t * t, int s, GXColor c)
GuiText::GuiText(const char * t)
{
text = NULL;
size = presetSize;
size = (int) (presetSize * Settings.FontScaleFactor);
currentSize = size;
color = presetColor;
alpha = presetColor.a;
@ -531,7 +531,7 @@ void GuiText::Draw()
GXColor c = color;
c.a = GetAlpha();
int newSize = (int) (size * GetScale() * Settings.FontScaleFactor);
int newSize = (int) (size * GetScale());
if (newSize != currentSize)
{

View File

@ -158,6 +158,7 @@ int StartUpProcess::Run(int argc, char *argv[])
int StartUpProcess::Execute()
{
Settings.EntryIOS = IOS_GetVersion();
SetTextf("Start up\n");
if(IosLoader::LoadAppCios() < 0)

View File

@ -5,44 +5,6 @@
#include "utils/uncompress.h"
#include "OpeningBNR.hpp"
typedef struct _IMD5Header
{
u32 fcc;
u32 filesize;
u8 zeroes[8];
u8 crypto[16];
} __attribute__((packed)) IMD5Header;
typedef struct _U8Header
{
u32 fcc;
u32 rootNodeOffset;
u32 headerSize;
u32 dataOffset;
u8 zeroes[16];
} __attribute__((packed)) U8Header;
typedef struct _U8Entry
{
struct
{
u32 fileType :8;
u32 nameOffset :24;
};
u32 fileOffset;
union
{
u32 fileLength;
u32 numEntries;
};
} __attribute__( ( packed ) ) U8Entry;
static inline const char * u8Filename(const U8Entry *fst, int i)
{
return (char *) (fst + fst[0].numEntries) + fst[i].nameOffset;
}
BNRInstance * BNRInstance::instance = NULL;
OpeningBNR::OpeningBNR()

View File

@ -17,6 +17,44 @@ typedef struct _IMETHeader
u8 crypto[16];
} __attribute__((packed)) IMETHeader;
typedef struct _IMD5Header
{
u32 fcc;
u32 filesize;
u8 zeroes[8];
u8 crypto[16];
} __attribute__((packed)) IMD5Header;
typedef struct _U8Header
{
u32 fcc;
u32 rootNodeOffset;
u32 headerSize;
u32 dataOffset;
u8 zeroes[16];
} __attribute__((packed)) U8Header;
typedef struct _U8Entry
{
struct
{
u32 fileType :8;
u32 nameOffset :24;
};
u32 fileOffset;
union
{
u32 fileLength;
u32 numEntries;
};
} __attribute__( ( packed ) ) U8Entry;
static inline const char * u8Filename(const U8Entry *fst, int i)
{
return (char *) (fst + fst[0].numEntries) + fst[i].nameOffset;
}
class OpeningBNR
{
public:

View File

@ -9,18 +9,25 @@
#include <vector>
#include <string>
#include "Controls/DeviceHandler.hpp"
#include "../lstub.h"
#include "../sys.h"
#include "../gecko.h"
#include "settings/CSettings.h"
#include "lstub.h"
#include "sys.h"
#include "gecko.h"
#include "dolloader.h"
#define EXECUTE_ADDR ((u8 *) 0x92000000)
#define BOOTER_ADDR ((u8 *) 0x93000000)
#define ARGS_ADDR ((u8 *) 0x93200000)
static u8 *homebrewbuffer = (u8 *) 0x92000000;
extern const u8 app_booter_bin[];
extern const u32 app_booter_bin_size;
typedef void (*entrypoint) (void);
extern "C" { void __exception_closeall(); }
static u8 *homebrewbuffer = EXECUTE_ADDR;
static u32 homebrewsize = 0;
static std::vector<std::string> Arguments;
extern const u8 app_booter_dol[];
void AddBootArgument(const char * argv)
{
std::string arg(argv);
@ -37,7 +44,7 @@ int CopyHomebrewMemory(u8 *temp, u32 pos, u32 len)
void FreeHomebrewBuffer()
{
homebrewbuffer = (u8 *) 0x92000000;
homebrewbuffer = EXECUTE_ADDR;
homebrewsize = 0;
Arguments.clear();
@ -91,17 +98,23 @@ static int RunAppbooter()
ExitApp();
if(Settings.EntryIOS != IOS_GetVersion())
IOS_ReloadIOS(Settings.EntryIOS);
struct __argv args;
SetupARGV(&args);
u32 cpu_isr;
entrypoint entry = (entrypoint) load_dol((void*) app_booter_dol, &args);
memcpy(BOOTER_ADDR, app_booter_bin, app_booter_bin_size);
DCFlushRange(BOOTER_ADDR, app_booter_bin_size);
if (!entry)
entrypoint entry = (entrypoint) BOOTER_ADDR;
if (args.argvMagic == ARGV_MAGIC)
{
FreeHomebrewBuffer();
return -1;
memmove(ARGS_ADDR, &args, sizeof(args));
DCFlushRange(ARGS_ADDR, sizeof(args));
}
u64 currentStub = getStubDest();

View File

@ -1,64 +0,0 @@
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <ogc/machine/processor.h>
#include <gccore.h>
#include <dirent.h>
#include <string.h>
#include "dolloader.h"
typedef struct _dolheader {
u32 text_pos[7];
u32 data_pos[11];
u32 text_start[7];
u32 data_start[11];
u32 text_size[7];
u32 data_size[11];
u32 bss_start;
u32 bss_size;
u32 entry_point;
} dolheader;
u32 load_dol(const void *dolstart, struct __argv *argv)
{
u32 i;
dolheader *dolfile;
if (dolstart)
{
dolfile = (dolheader *) dolstart;
for (i = 0; i < 7; i++)
{
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100))
continue;
memmove((void *) dolfile->text_start[i], dolstart
+ dolfile->text_pos[i], dolfile->text_size[i]);
DCFlushRange ((void *) dolfile->text_start[i], dolfile->text_size[i]);
ICInvalidateRange((void *) dolfile->text_start[i], dolfile->text_size[i]);
}
for (i = 0; i < 11; i++)
{
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100))
continue;
memmove((void *) dolfile->data_start[i], dolstart
+ dolfile->data_pos[i], dolfile->data_size[i]);
DCFlushRange((void *) dolfile->data_start[i],
dolfile->data_size[i]);
}
if (argv && argv->argvMagic == ARGV_MAGIC)
{
void *new_argv = (void *) (dolfile->entry_point + 8);
memmove(new_argv, argv, sizeof(*argv));
DCFlushRange(new_argv, sizeof(*argv));
}
return dolfile->entry_point;
}
return 0;
}

View File

@ -1,18 +0,0 @@
#ifndef _DOLLOADER_H_
#define _DOLLOADER_H_
#ifdef __cplusplus
extern "C" {
#endif
extern void __exception_closeall();
typedef void (*entrypoint) (void);
u32 load_dol(const void *dolstart, struct __argv *argv);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -29,8 +29,7 @@
#include "utils/StringTools.h"
#include "mload/mload.h"
#include "FileOperations/fileops.h"
#include "menu.h"
#include "menu.h"
#include "menu/menus.h"
#include "sys.h"
#include "wpad.h"
#include "wad/wad.h"
@ -42,11 +41,6 @@
#include "gecko.h"
#include "lstub.h"
/*** Extern variables ***/
s32 gameStart = 0;
extern u8 shutdown;
extern u8 reset;
/****************************************************************************
* OnScreenNumpad
*
@ -237,9 +231,9 @@ void WindowCredits()
char SvnRev[80];
#ifdef FULLCHANNEL
snprintf(SvnRev, sizeof(SvnRev), "V2.2c IOS%u (Rev %u)", IOS_GetVersion(), IOS_GetRevision());
snprintf(SvnRev, sizeof(SvnRev), "Rev%sc IOS%u (Rev %u)", GetRev(), IOS_GetVersion(), IOS_GetRevision());
#else
snprintf(SvnRev, sizeof(SvnRev), "V2.2 IOS%u (Rev %u)", IOS_GetVersion(), IOS_GetRevision());
snprintf(SvnRev, sizeof(SvnRev), "Rev%s IOS%u (Rev %u)", GetRev(), IOS_GetVersion(), IOS_GetRevision());
#endif
char IosInfo[80] = "";

View File

@ -1114,13 +1114,10 @@ bool save_gamelist(int txt) // save gamelist
{
struct discHdr* header = gameList[i];
WBFS_GameSize(header->id, &size);
if (i < 500)
{
fprintf(f, "%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2], header->id[3], header->id[4],
header->id[5]);
fprintf(f, " [%.2f] ", size);
fprintf(f, " %s", GameTitles.GetTitle(header));
}
fprintf(f, "\n");
}
}
@ -1132,13 +1129,10 @@ bool save_gamelist(int txt) // save gamelist
{
struct discHdr* header = gameList[i];
WBFS_GameSize(header->id, &size);
if (i < 500)
{
fprintf(f, "\"%c%c%c%c%c%c\",\"%.2f\",\"%s\"\n", header->id[0], header->id[1], header->id[2],
header->id[3], header->id[4], header->id[5], size, GameTitles.GetTitle(header));
}
}
}
fclose(f);
gameList.FilterList();

View File

@ -119,7 +119,7 @@ void CSettings::SetDefault()
USBPort = 0;
CacheTitles = ON;
WSFactor = 0.8f; //actually should be 0.75 for real widescreen
FontScaleFactor = 1.0f;
FontScaleFactor = 0.8f; //it's a work around to not have to change ALL fonts now
EnabledCategories.resize(1);
EnabledCategories[0] = 0;
Wiinnertag = OFF;

View File

@ -125,6 +125,7 @@ class CSettings
short GameListOffset;
short sneekVideoPatch;
std::vector<u32> EnabledCategories;
u8 EntryIOS;
protected:
bool ValidVersion(FILE * file);
bool SetSetting(char *name, char *value);

View File

@ -29,13 +29,27 @@
#include "CTheme.h"
#include "GUI/gui.h"
#include "settings/CSettings.h"
#include "banner/OpeningBNR.hpp"
#include "FileOperations/fileops.h"
#include "menu/menus.h"
#include "wad/nandtitle.h"
#include "FreeTypeGX.h"
typedef struct map_entry
{
char name[8];
u8 hash[20];
} __attribute__((packed)) map_entry_t;
static const char contentMapPath[] ATTRIBUTE_ALIGN(32) = "/shared1/content.map";
static const u8 WIIFONT_HASH[] = {0x32, 0xb3, 0x39, 0xcb, 0xbb, 0x50, 0x7d, 0x50, 0x27, 0x79, 0x25, 0x9a, 0x78, 0x66, 0x99, 0x5d, 0x03, 0x0b, 0x1d, 0x88};
static const u8 WIIFONT_HASH_KOR[] = {0xb7, 0x15, 0x6d, 0xf0, 0xf4, 0xae, 0x07, 0x8f, 0xd1, 0x53, 0x58, 0x3e, 0x93, 0x6e, 0x07, 0xc0, 0x98, 0x77, 0x49, 0x0e};
FreeTypeGX * fontSystem = NULL;
static FT_Byte * MainFont = NULL;
static u32 MainFontSize = 0;
static FT_Byte * systemFont = NULL;
static u32 systemFontSize = 0;
static FT_Byte * customFont = NULL;
static u32 customFontSize = 0;
bool Theme::ShowTooltips = true;
@ -149,13 +163,76 @@ bool Theme::Load(const char * theme_file_path)
return result;
}
bool Theme::loadSystemFont(bool korean)
{
u8 *contentMap = NULL;
u32 mapsize = 0;
NandTitle::LoadFileFromNand(contentMapPath, &contentMap, &mapsize);
if(!contentMap)
return false;
int fileCount = mapsize / sizeof(map_entry_t);
map_entry_t *mapEntryList = (map_entry_t *) contentMap;
for (int i = 0; i < fileCount; i++)
{
if (memcmp(mapEntryList[i].hash, korean ? WIIFONT_HASH_KOR : WIIFONT_HASH, 20) != 0)
continue;
// Name found, load it and unpack it
char font_filename[32] ATTRIBUTE_ALIGN(32);
snprintf(font_filename, sizeof(font_filename), "/shared1/%.8s.app", mapEntryList[i].name);
u8 *fontArchive = NULL;
u32 filesize = 0;
NandTitle::LoadFileFromNand(font_filename, &fontArchive, &filesize);
if(!fontArchive)
continue;
const U8Header *u8Archive = (U8Header *) fontArchive;
const U8Entry *fst = (const U8Entry *) (((const u8 *) u8Archive) + u8Archive->rootNodeOffset);
if(fst[0].numEntries < 1)
{
free(fontArchive);
continue;
}
if(systemFont)
delete [] systemFont;
systemFontSize = fst[1].fileLength;
systemFont = new (std::nothrow) FT_Byte[systemFontSize];
if(!systemFont)
{
free(fontArchive);
continue;
}
memcpy(systemFont, fontArchive + fst[1].fileOffset, systemFontSize);
free(fontArchive);
free(contentMap);
gprintf("Loaded Wii System Font: %s\n", u8Filename(fst, 1));
return true;
}
free(contentMap);
return false;
}
bool Theme::LoadFont(const char *path)
{
char FontPath[300];
bool result = false;
FILE *pfile = NULL;
ClearFontData();
delete [] customFont;
customFont = NULL;
snprintf(FontPath, sizeof(FontPath), "%s/font.ttf", path);
@ -164,22 +241,32 @@ bool Theme::LoadFont(const char *path)
if (pfile)
{
fseek(pfile, 0, SEEK_END);
MainFontSize = ftell(pfile);
customFontSize = ftell(pfile);
rewind(pfile);
MainFont = new (std::nothrow) FT_Byte[MainFontSize];
if (MainFont)
customFont = new (std::nothrow) FT_Byte[customFontSize];
if (customFont)
{
fread(MainFont, 1, MainFontSize, pfile);
fread(customFont, 1, customFontSize, pfile);
result = true;
}
fclose(pfile);
}
FT_Byte * loadedFont = MainFont ? MainFont : (FT_Byte *) Resources::GetFile("font.ttf");
u32 loadedFontSize = MainFont ? MainFontSize : Resources::GetFileSize("font.ttf");
FT_Byte *loadedFont = customFont;
u32 loadedFontSize = customFontSize;
fontSystem = new FreeTypeGX(loadedFont, loadedFontSize);
if(!loadedFont)
{
if(!systemFont)
loadSystemFont(CONF_GetLanguage() == CONF_LANG_KOREAN);
//! Default to system font if no custom is loaded
loadedFont = systemFont;
loadedFontSize = systemFontSize;
}
fontSystem = new FreeTypeGX(loadedFont, loadedFontSize, loadedFont == systemFont);
return result;
}
@ -190,7 +277,11 @@ void Theme::ClearFontData()
delete fontSystem;
fontSystem = NULL;
if (MainFont)
delete [] MainFont;
MainFont = NULL;
if(customFont)
delete [] customFont;
customFont = NULL;
if (systemFont)
delete [] systemFont;
systemFont = NULL;
}

View File

@ -24,6 +24,8 @@ class Theme
//!Enable tooltips: special case treaded because it is called every frame
static bool ShowTooltips;
private:
//!Load the original Wii System Menu font
static bool loadSystemFont(bool korean);
//!Clear the font data and free the memory
static void ClearFontData();
};

View File

@ -1,7 +1,7 @@
/****************************************************************************
* USB Loader GX resource files.
* This file is generated automatically.
* Includes 189 files.
* Includes 188 files.
*
* NOTE:
* Any manual modification of this file will be overwriten by the generation.
@ -575,9 +575,6 @@ extern const u32 success_ogg_size;
extern const u8 clock_ttf[];
extern const u32 clock_ttf_size;
extern const u8 font_ttf[];
extern const u32 font_ttf_size;
RecourceFile Resources::RecourceFiles[] =
{
{"abcIcon.png", abcIcon_png, abcIcon_png_size, NULL, 0},
@ -768,7 +765,6 @@ RecourceFile Resources::RecourceFiles[] =
{"menuout.ogg", menuout_ogg, menuout_ogg_size, NULL, 0},
{"success.ogg", success_ogg, success_ogg_size, NULL, 0},
{"clock.ttf", clock_ttf, clock_ttf_size, NULL, 0},
{"font.ttf", font_ttf, font_ttf_size, NULL, 0},
{NULL, NULL, 0, NULL, 0}
};

View File

@ -282,9 +282,9 @@ int set_frag_list(u8 *id)
return ret;
// verify id matches
char discid[8];
char discid[32] ATTRIBUTE_ALIGN(32);
memset(discid, 0, sizeof(discid));
ret = WDVD_UnencryptedRead(discid, 8, 0);
ret = WDVD_UnencryptedRead(discid, 32, 0);
gprintf("Reading ID after setting fraglist: %s (expected: %s)\n", discid, id);
return (strncasecmp((char *) id, discid, 6) != 0) ? -3 : 0;
}

View File

@ -50,7 +50,7 @@ EOF
<arg>--ios=250</arg>
<arg>--usbport=0</arg>
</arguments>
--> // remove this line to enable arguments
// remove this line to enable arguments -->
<no_ios_reload/>
<short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.