-changed version to Beta 4.0.2

-increased usable mem for about 11mb by using mem1_lo (10mb) and no
mem1_hi limit (1mb)
This commit is contained in:
fix94.1 2012-09-07 18:13:04 +00:00
parent b65bdfeba6
commit f1767d5082
11 changed files with 100 additions and 48 deletions

View File

@ -1,5 +1,5 @@
#define APP_NAME "WiiFlow" #define APP_NAME "WiiFlow"
#define APP_VERSION "4.0.1" #define APP_VERSION "Beta 4.0.2"
#define APPDATA_DIR "wiiflow" #define APPDATA_DIR "wiiflow"
#define APPDATA_DIR2 "apps/wiiflow" #define APPDATA_DIR2 "apps/wiiflow"

View File

@ -227,7 +227,7 @@ CCoverFlow::CCoverFlow(void)
LWP_MutexInit(&m_mutex, 0); LWP_MutexInit(&m_mutex, 0);
} }
bool CCoverFlow::init(const SmartBuf &font, u32 font_size, bool vid_50hz) bool CCoverFlow::init(u8 *font, u32 font_size, bool vid_50hz)
{ {
// Load font // Load font
m_font.fromBuffer(font, font_size, TITLEFONT); m_font.fromBuffer(font, font_size, TITLEFONT);

View File

@ -40,7 +40,7 @@ public:
CCoverFlow(void); CCoverFlow(void);
~CCoverFlow(void); ~CCoverFlow(void);
// //
bool init(const SmartBuf &font, u32 font_size, bool vid_50hz); bool init(u8 *font, u32 font_size, bool vid_50hz);
// Cover list management // Cover list management
void clear(void); void clear(void);
void shutdown(void); void shutdown(void);

View File

@ -178,7 +178,7 @@ vector<wstringEx> stringToVector(const wstringEx &text, char sep)
return v; return v;
} }
bool SFont::fromBuffer(const SmartBuf &buffer, u32 bufferSize, u32 size, u32 lspacing, u32 w, u32 idx, const char *) bool SFont::fromBuffer(u8 *buffer, u32 bufferSize, u32 size, u32 lspacing, u32 w, u32 idx, const char *)
{ {
if (!buffer || !font) return false; if (!buffer || !font) return false;
@ -192,7 +192,7 @@ bool SFont::fromBuffer(const SmartBuf &buffer, u32 bufferSize, u32 size, u32 lsp
data = smartMem2Alloc(bufferSize); data = smartMem2Alloc(bufferSize);
if(!data) return false; if(!data) return false;
memcpy(data.get(), buffer.get(), bufferSize); memcpy(data.get(), buffer, bufferSize);
dataSize = bufferSize; dataSize = bufferSize;
font->loadFont(data.get(), dataSize, size, weight, index, false); font->loadFont(data.get(), dataSize, size, weight, index, false);

View File

@ -21,7 +21,7 @@ struct SFont
u32 weight; u32 weight;
u32 index; u32 index;
public: public:
bool fromBuffer(const SmartBuf &buffer, u32 bufferSize, u32 size, u32 lspacing, u32 w = 0, u32 idx = 0, const char *genKey = NULL); bool fromBuffer(u8 *buffer, u32 bufferSize, u32 size, u32 lspacing, u32 w = 0, u32 idx = 0, const char *genKey = NULL);
bool fromFile(const char *filename, u32 size, u32 lspacing, u32 w = 0, u32 idx = 0); bool fromFile(const char *filename, u32 size, u32 lspacing, u32 w = 0, u32 idx = 0);
SFont(void) : data(SmartBuf(NULL, SmartBuf::SRCALL_MEM2)), dataSize(0), font(SmartPtr<FreeTypeGX>(new FreeTypeGX)), lineSpacing(0), weight(0), index(0) { } SFont(void) : data(SmartBuf(NULL, SmartBuf::SRCALL_MEM2)), dataSize(0), font(SmartPtr<FreeTypeGX>(new FreeTypeGX)), lineSpacing(0), weight(0), index(0) { }
~SFont(void) { } ~SFont(void) { }

View File

@ -35,7 +35,7 @@ int main(int argc, char **argv)
vid.init(); vid.init();
Nand::Instance()->Init_ISFS(); Nand::Instance()->Init_ISFS();
MEM2_init(47); //Should be safe to use MEM_init(); //Inits both mem1lo and mem2
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV); gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
char *gameid = NULL; char *gameid = NULL;

View File

@ -8,9 +8,18 @@
#include "gecko/gecko.h" #include "gecko/gecko.h"
#include "loader/utils.h" #include "loader/utils.h"
#define MEM2_PRIORITY_SIZE 0x1000
// Forbid the use of MEM2 through malloc // Forbid the use of MEM2 through malloc
u32 MALLOC_MEM2 = 0; u32 MALLOC_MEM2 = 0;
void *MEM1_lo_start = (void*)0x80004000;
void *MEM1_lo_end = (void*)0x80A00000;
void *MEM2_start = (void*)0x90200000;
void *MEM2_end = (void*)0x93100000;
static CMEM2Alloc g_mem1lo;
static CMEM2Alloc g_mem2gp; static CMEM2Alloc g_mem2gp;
extern "C" extern "C"
@ -23,24 +32,60 @@ extern __typeof(memalign) __real_memalign;
extern __typeof(free) __real_free; extern __typeof(free) __real_free;
extern __typeof(malloc_usable_size) __real_malloc_usable_size; extern __typeof(malloc_usable_size) __real_malloc_usable_size;
void MEM_init()
{
g_mem1lo.init(MEM1_lo_start, MEM1_lo_end); //about 10mb
g_mem1lo.clear();
g_mem2gp.init(MEM2_start, MEM2_end); //about 47mb
g_mem2gp.clear();
}
void *MEM1_lo_alloc(unsigned int s)
{
return g_mem1lo.allocate(s);
}
void MEM1_lo_free(void *p)
{
if(!p)
return;
g_mem1lo.release(p);
}
void *MEM1_alloc(unsigned int s) void *MEM1_alloc(unsigned int s)
{ {
return __real_malloc(s); void *p = g_mem1lo.allocate(s);
if(!p)
p = __real_malloc(s);
return p;
} }
void *MEM1_memalign(unsigned int a, unsigned int s) void *MEM1_memalign(unsigned int a, unsigned int s)
{ {
return __real_memalign(a, s); void *p = g_mem1lo.allocate(s);
if(!p)
p = __real_memalign(a, s);
return p;
} }
void *MEM1_realloc(void *p, unsigned int s) void *MEM1_realloc(void *p, unsigned int s)
{ {
if(!p)
return NULL;
if((u32)p > (u32)MEM1_lo_start && (u32)p < (u32)MEM1_lo_end)
return g_mem1lo.reallocate(p, s);
return __real_realloc(p, s); return __real_realloc(p, s);
} }
void MEM1_free(void *p) void MEM1_free(void *p)
{ {
__real_free(p); if(!p)
return;
if((u32)p > (u32)MEM1_lo_start && (u32)p < (u32)MEM1_lo_end)
g_mem1lo.release(p);
else
__real_free(p);
} }
unsigned int MEM1_freesize() unsigned int MEM1_freesize()
@ -48,12 +93,6 @@ unsigned int MEM1_freesize()
return SYS_GetArena1Size(); return SYS_GetArena1Size();
} }
void MEM2_init(unsigned int mem2Size)
{
g_mem2gp.init(mem2Size);
g_mem2gp.clear();
}
void MEM2_cleanup(void) void MEM2_cleanup(void)
{ {
g_mem2gp.cleanup(); g_mem2gp.cleanup();
@ -66,6 +105,8 @@ void MEM2_clear(void)
void MEM2_free(void *p) void MEM2_free(void *p)
{ {
if(!p)
return;
g_mem2gp.release(p); g_mem2gp.release(p);
} }
@ -82,11 +123,15 @@ void *MEM2_memalign(unsigned int /* alignment */, unsigned int s)
void *MEM2_realloc(void *p, unsigned int s) void *MEM2_realloc(void *p, unsigned int s)
{ {
if(!p)
return NULL;
return g_mem2gp.reallocate(p, s); return g_mem2gp.reallocate(p, s);
} }
unsigned int MEM2_usableSize(void *p) unsigned int MEM2_usableSize(void *p)
{ {
if(!p)
return 0;
return g_mem2gp.usableSize(p); return g_mem2gp.usableSize(p);
} }
@ -98,7 +143,7 @@ unsigned int MEM2_freesize()
void *__wrap_malloc(size_t size) void *__wrap_malloc(size_t size)
{ {
void *p; void *p;
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE) if(size >= MEM2_PRIORITY_SIZE)
{ {
p = g_mem2gp.allocate(size); p = g_mem2gp.allocate(size);
if(p != 0) if(p != 0)
@ -114,7 +159,7 @@ void *__wrap_malloc(size_t size)
void *__wrap_calloc(size_t n, size_t size) void *__wrap_calloc(size_t n, size_t size)
{ {
void *p; void *p;
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || (n * size) >= MEM2_PRIORITY_SIZE) if((n * size) >= MEM2_PRIORITY_SIZE)
{ {
p = g_mem2gp.allocate(n * size); p = g_mem2gp.allocate(n * size);
if (p != 0) if (p != 0)
@ -137,7 +182,7 @@ void *__wrap_calloc(size_t n, size_t size)
void *__wrap_memalign(size_t a, size_t size) void *__wrap_memalign(size_t a, size_t size)
{ {
void *p; void *p;
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE) if(size >= MEM2_PRIORITY_SIZE)
{ {
if(a <= 32 && 32 % a == 0) if(a <= 32 && 32 % a == 0)
{ {
@ -162,7 +207,7 @@ void __wrap_free(void *p)
if(((u32)p & 0x10000000) != 0) if(((u32)p & 0x10000000) != 0)
g_mem2gp.release(p); g_mem2gp.release(p);
else else
__real_free(p); MEM1_free(p);
} }
void *__wrap_realloc(void *p, size_t size) void *__wrap_realloc(void *p, size_t size)

View File

@ -9,15 +9,17 @@ extern "C"
{ {
#endif #endif
#define MAX_MEM1_ARENA_LO ((void *)(0x81700000-size)) void MEM_init();
#define MEM2_PRIORITY_SIZE 0x1000
void *MEM1_lo_alloc(unsigned int s);
void MEM1_lo_free(void *p);
void *MEM1_alloc(unsigned int s); void *MEM1_alloc(unsigned int s);
void *MEM1_memalign(unsigned int a, unsigned int s); void *MEM1_memalign(unsigned int a, unsigned int s);
void *MEM1_realloc(void *p, unsigned int s); void *MEM1_realloc(void *p, unsigned int s);
void MEM1_free(void *p); void MEM1_free(void *p);
unsigned int MEM1_freesize(); unsigned int MEM1_freesize();
void MEM2_init(unsigned int mem2Size);
void MEM2_cleanup(void); void MEM2_cleanup(void);
void MEM2_clear(void); void MEM2_clear(void);
void MEM2_free(void *p); void MEM2_free(void *p);

View File

@ -112,9 +112,6 @@ extern const u8 checkboxs_png[];
extern const u8 checkboxhid_png[]; extern const u8 checkboxhid_png[];
extern const u8 checkboxreq_png[]; extern const u8 checkboxreq_png[];
SmartBuf m_wbf1_font;
SmartBuf m_wbf2_font;
CMenu::CMenu(CVideo &vid) : CMenu::CMenu(CVideo &vid) :
m_vid(vid) m_vid(vid)
{ {
@ -142,7 +139,10 @@ CMenu::CMenu(CVideo &vid) :
m_reload = false; m_reload = false;
m_gamesound_changed = false; m_gamesound_changed = false;
m_video_playing = false; m_video_playing = false;
m_base_font = NULL;
m_base_font_size = 0; m_base_font_size = 0;
m_wbf1_font = NULL;
m_wbf2_font = NULL;
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_USB;
m_Emulator_boot = false; m_Emulator_boot = false;
m_banner = new BannerWindow; m_banner = new BannerWindow;
@ -872,7 +872,7 @@ void CMenu::_loadCFLayout(int version, bool forceAA, bool otherScrnFmt)
void CMenu::_buildMenus(void) void CMenu::_buildMenus(void)
{ {
if(!m_base_font.get()) if(!m_base_font)
_loadDefaultFont(CONF_GetLanguage() == CONF_LANG_KOREAN); _loadDefaultFont(CONF_GetLanguage() == CONF_LANG_KOREAN);
// Default fonts // Default fonts
@ -2406,10 +2406,12 @@ retry:
{ {
const u8 *font_file = u8_get_file_by_index(u8_font_archive, 1, &size); // There is only one file in that app const u8 *font_file = u8_get_file_by_index(u8_font_archive, 1, &size); // There is only one file in that app
//gprintf("Extracted font: %d\n", size); //gprintf("Extracted font: %d\n", size);
m_base_font = smartMem2Alloc(size); if(m_base_font)
memcpy(m_base_font.get(), font_file, size); MEM1_free(m_base_font);
if(!!m_base_font) m_base_font = (u8*)MEM1_alloc(size);
m_base_font_size = size; memcpy(m_base_font, font_file, size);
DCFlushRange(m_base_font, size);
m_base_font_size = size;
free(u8_font_archive); free(u8_font_archive);
} }
break; break;
@ -2424,12 +2426,18 @@ retry:
if(u8_font_archive != NULL) if(u8_font_archive != NULL)
{ {
const u8 *font_file1 = u8_get_file(u8_font_archive, "wbf1.brfna", &size); const u8 *font_file1 = u8_get_file(u8_font_archive, "wbf1.brfna", &size);
m_wbf1_font = smartMem2Alloc(size); if(m_wbf1_font)
memcpy(m_wbf1_font.get(), font_file1, size); MEM1_lo_free(m_wbf1_font);
m_wbf1_font = (u8*)MEM1_lo_alloc(size);
memcpy(m_wbf1_font, font_file1, size);
DCFlushRange(m_wbf1_font, size);
const u8 *font_file2 = u8_get_file(u8_font_archive, "wbf2.brfna", &size); const u8 *font_file2 = u8_get_file(u8_font_archive, "wbf2.brfna", &size);
m_wbf2_font = smartMem2Alloc(size); if(m_wbf2_font)
memcpy(m_wbf2_font.get(), font_file2, size); MEM1_lo_free(m_wbf2_font);
m_wbf2_font = (u8*)MEM1_lo_alloc(size);
memcpy(m_wbf2_font, font_file2, size);
DCFlushRange(m_wbf2_font, size);
free(u8_font_archive); free(u8_font_archive);
} }
@ -2447,11 +2455,10 @@ retry:
void CMenu::_cleanupDefaultFont() void CMenu::_cleanupDefaultFont()
{ {
m_base_font.release(); MEM1_lo_free(m_base_font);
m_base_font_size = 0; m_base_font_size = 0;
MEM1_lo_free(m_wbf1_font);
m_wbf1_font.release(); MEM1_lo_free(m_wbf2_font);
m_wbf2_font.release();
} }
const char *CMenu::_domainFromView() const char *CMenu::_domainFromView()

View File

@ -67,8 +67,10 @@ private:
Config m_version; Config m_version;
Plugin m_plugin; Plugin m_plugin;
vector<string> m_homebrewArgs; vector<string> m_homebrewArgs;
SmartBuf m_base_font; u8 *m_base_font;
u32 m_base_font_size; u32 m_base_font_size;
u8 *m_wbf1_font;
u8 *m_wbf2_font;
u8 m_aa; u8 m_aa;
bool m_bnr_settings; bool m_bnr_settings;
bool m_directLaunch; bool m_directLaunch;

View File

@ -1533,10 +1533,6 @@ void CMenu::_gameSoundThread(CMenu *m)
m->m_gameSoundHdr = NULL; m->m_gameSoundHdr = NULL;
return; return;
} }
extern SmartBuf m_wbf1_font;
extern SmartBuf m_wbf2_font;
bool custom = false; bool custom = false;
u8 *custom_bnr_file = NULL; u8 *custom_bnr_file = NULL;
u32 custom_bnr_size = 0; u32 custom_bnr_size = 0;
@ -1580,7 +1576,7 @@ void CMenu::_gameSoundThread(CMenu *m)
disc.init(m->m_cf.getHdr()->path); disc.init(m->m_cf.getHdr()->path);
u8 *opening_bnr = disc.GetGameCubeBanner(); u8 *opening_bnr = disc.GetGameCubeBanner();
if(opening_bnr != NULL) if(opening_bnr != NULL)
m_banner->CreateGCBanner(opening_bnr, &m->m_vid, m_wbf1_font.get(), m_wbf2_font.get(), m->m_cf.getHdr()->title); m_banner->CreateGCBanner(opening_bnr, &m->m_vid, m->m_wbf1_font, m->m_wbf2_font, m->m_cf.getHdr()->title);
m->m_gameSound.Load(gc_ogg, gc_ogg_size, false); m->m_gameSound.Load(gc_ogg, gc_ogg_size, false);
m->m_gamesound_changed = true; m->m_gamesound_changed = true;
m->m_gameSoundHdr = NULL; m->m_gameSoundHdr = NULL;
@ -1615,7 +1611,7 @@ void CMenu::_gameSoundThread(CMenu *m)
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL))); _extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL)));
if(banner != NULL && banner->IsValid()) if(banner != NULL && banner->IsValid())
{ {
m_banner->LoadBanner(banner, &m->m_vid, m_wbf1_font.get(), m_wbf2_font.get()); m_banner->LoadBanner(banner, &m->m_vid, m->m_wbf1_font, m->m_wbf2_font);
soundBin = banner->GetFile((char *)"sound.bin", &sndSize); soundBin = banner->GetFile((char *)"sound.bin", &sndSize);
} }
else else