...
 
Commits (2)
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <ogc/machine/processor.h>
#include <wiiuse/wpad.h>
#include <vector>
#include <string>
#include <sys/dir.h>
#include "main.h"
#include "dolloader.h"
#include "elfloader.h"
#include "filelist.h"
#include "DiskOperations/di2.h"
#include "Tools/load_channel.h"
#include "Tools/parser.h"
#define BLOCKSIZE 70*1024 //70KB
#define MAX_CMDLINE 4096
#define MAX_ARGV 1000
#define GC_DOL_MAGIC "gchomebrew dol"
#define GC_MAGIC_BUF (char *) 0x807FFFE0
#define GC_DOL_BUF (u8 *)0x80800000
#define BC 0x0000000100000100ULL
struct __argv args;
char cmdline[MAX_CMDLINE];
char *a_argv[MAX_ARGV];
char *meta_buf = NULL;
static u8 *homebrewbuffer = (u8 *) 0x92000000;
static u32 homebrewsize = 0;
std::string filepath;
void arg_init()
{
memset(&args, 0, sizeof(args));
memset(cmdline, 0, sizeof(cmdline));
memset(a_argv, 0, sizeof(a_argv));
args.argvMagic = ARGV_MAGIC;
args.length = 1; // double \0\0
args.argc = 0;
args.commandLine = cmdline;
args.argv = a_argv;
args.endARGV = a_argv;
}
char* strcopy(char *dest, const char *src, int size)
{
strncpy(dest,src,size);
dest[size-1] = 0;
return dest;
}
int arg_add(const char *arg)
{
int len = strlen(arg);
if (args.argc >= MAX_ARGV) return -1;
if (args.length + len + 1 > MAX_CMDLINE) return -1;
strcopy(cmdline + args.length - 1, arg, len+1);
args.length += len + 1; // 0 term.
cmdline[args.length - 1] = 0; // double \0\0
args.argc++;
args.endARGV = args.argv + args.argc;
return 0;
}
/****************************************************************************
* FileSize
*
* Get filesize in bytes. u64 for files bigger than 4GB
***************************************************************************/
u64 FileSize(const char * filepath)
{
struct stat filestat;
if (stat(filepath, &filestat) != 0)
return 0;
return filestat.st_size;
}
/****************************************************************************
* LoadFileToMem
*
* Load up the file into a block of memory
***************************************************************************/
int LoadFileToMem(const char *filepath, u8 **inbuffer, u64 *size)
{
int ret = -1;
u64 filesize = FileSize(filepath);
char * filename = strrchr(filepath, '/');
if(filename)
filename++;
*inbuffer = NULL;
*size = 0;
FILE *file = fopen(filepath, "rb");
if (file == NULL)
return -1;
u8 *buffer = (u8 *) malloc(filesize);
if (buffer == NULL)
{
fclose(file);
return -2;
}
u64 done = 0;
u32 blocksize = BLOCKSIZE;
do
{
if(blocksize > filesize-done)
blocksize = filesize-done;
ret = fread(buffer+done, 1, blocksize, file);
if(ret < 0)
{
free(buffer);
fclose(file);
return -3;
}
else if(ret == 0)
{
//we are done
break;
}
done += ret;
}
while(done < filesize);
fclose(file);
if (done != filesize)
{
free(buffer);
return -3;
}
*inbuffer = buffer;
*size = filesize;
return 1;
}
int CopyHomebrewMemory(u8 *temp, u32 pos, u32 len)
{
homebrewsize += len;
memcpy((homebrewbuffer)+pos, temp, len);
return 1;
}
int LoadHomebrew(const char * path)
{
filepath = path;
u8 *buffer = NULL;
u64 filesize = 0;
int ret = LoadFileToMem(path, &buffer, &filesize);
if(ret < 0)
return ret;
ret = CopyHomebrewMemory(buffer, 0, filesize);
if(buffer) {
free(buffer);
buffer = NULL;
}
return ret;
}
int BootHomebrew()
{
if(homebrewsize == 0)
return -1;
entrypoint entry;
u32 cpu_isr;
arg_init();
arg_add(filepath.c_str()); // argv[0] = filepath
while(parser(Settings.forwarder_arg, "<arg>", "</arg>") != "")
{
arg_add(parser(Settings.forwarder_arg, "<arg>", "</arg>").c_str());
Settings.forwarder_arg.erase(0, Settings.forwarder_arg.find("</arg>") +1);
}
if ( valid_elf_image(homebrewbuffer) == 1 )
entry = (entrypoint) load_elf_image(homebrewbuffer);
else
entry = (entrypoint) load_dol(homebrewbuffer, &args);
if (!entry)
return -1;
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
_CPU_ISR_Disable (cpu_isr);
__exception_closeall();
entry();
_CPU_ISR_Restore (cpu_isr);
return 0;
}
int BootGameCubeHomebrew()
{
if(homebrewsize == 0)
return -1;
static tikview view ATTRIBUTE_ALIGN(32);
DI2_Init();
DI2_Reset();
DI2_ReadDiscID((u64 *) 0x80000000);
DI2_Mount();
strcpy(GC_MAGIC_BUF, GC_DOL_MAGIC);
DCFlushRange(GC_MAGIC_BUF, 32);
memcpy(GC_DOL_BUF, homebrewbuffer, homebrewsize);
DCFlushRange(GC_DOL_BUF, homebrewsize);
*(vu32 *) 0xCC003024 |= 0x07;
ES_GetTicketViews(BC, &view, 1);
int ret = ES_LaunchTitle(BC, &view);
if(ret < 0)
LoadHBC();
return ret;
}
#ifndef _BOOTHOMEBREW_H_
#define _BOOTHOMEBREW_H_
int BootHomebrew();
int BootGameCubeHomebrew();
int CopyHomebrewMemory(u8 *temp, u32 pos, u32 len);
void AddBootArgument(const char * arg);
int LoadHomebrew(const char * filepath);
#endif
......@@ -228,6 +228,8 @@ int BootGameCubeHomebrew()
ES_GetTicketViews(BC, &view, 1);
int ret = ES_LaunchTitle(BC, &view);
if(ret < 0)
LoadHBC();
return ret;
}
#include <dirent.h>
#include "FreeTypeGX.h"
#include "filelist.h"
#include "main.h"
#include "Tools/save.h"
FreeTypeGX * fontSystem = NULL;
static FT_Byte * MainFont = (FT_Byte *) font_ttf;
static u32 MainFontSize = font_ttf_size;
static float scale = 1;
void ClearFontData()
{
if(fontSystem)
delete fontSystem;
fontSystem = NULL;
if(MainFont != (FT_Byte *) font_ttf)
{
if(MainFont != NULL)
delete [] MainFont;
MainFont = (FT_Byte *) font_ttf;
MainFontSize = font_ttf_size;
}
}
bool SetupDefaultFont(const char *path)
{
bool result = false;
FILE *pfile = NULL;
ClearFontData();
if(path)
pfile = fopen(path, "rb");
if(pfile)
{
fseek(pfile, 0, SEEK_END);
MainFontSize = ftell(pfile);
rewind(pfile);
MainFont = new (std::nothrow) FT_Byte[MainFontSize];
if(!MainFont)
{
MainFont = (FT_Byte *) font_ttf;
MainFontSize = font_ttf_size;
}
else
{
fread(MainFont, 1, MainFontSize, pfile);
result = true;
}
fclose(pfile);
}
fontSystem = new FreeTypeGX(MainFont, MainFontSize);
return result;
}
void SetFontScale(float Scale)
{
scale = Scale;
}
float GetFontScale()
{
return scale;
}
void SetFont()
{
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
}
bool font_folder_exists()
{
// font speicher ordner erstellen
if(folder_exists())
{
DIR *pDir;
pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Fonts").c_str());
if(pDir != NULL)
{
closedir (pDir);
return true;
}
else
{
if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Fonts").c_str(), 0777) != -1)
{
closedir (pDir);
return true;
}
}
closedir (pDir);
}
return false;
}
\ No newline at end of file
#ifndef FONTSYSTEM_H_
#define FONTSYSTEM_H_
bool SetupDefaultFont(const char *path);
void ClearFontData();
void SetFontScale(float Scale);
float GetFontScale();
void SetFont();
bool font_folder_exists();
#endif
\ No newline at end of file
/***************************************************************************
* Copyright (C) 2009
* by Dimok & r-win
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Resources.cpp
*
* for WiiXplorer 2009
***************************************************************************/
#include "Resources.h"
Resources * Resources::instance = NULL;
Resources * Resources::Instance()
{
if (instance == NULL)
{
instance = new Resources();
}
return instance;
}
void Resources::DestroyInstance()
{
if (instance != NULL)
{
delete instance;
instance = NULL;
}
}
Resources::~Resources()
{
// Delete all images...
std::map<const u8 *, GuiImageData *>::iterator imgitr;
for (imgitr = images.begin(); imgitr != images.end(); imgitr++)
{
delete imgitr->second;
}
images.clear();
// Delete all sounds...
std::map<const u8 *, GuiSound *>::iterator snditr;
for (snditr = sounds.begin(); snditr != sounds.end(); snditr++)
{
delete snditr->second;
}
sounds.clear();
imageCount.clear();
soundCount.clear();
}
GuiImageData *Resources::GetImageData(const u8 *img, u32 imgSize)
{
return Resources::Instance()->InternalGetImageData(img, imgSize);
}
GuiSound *Resources::GetSound(const u8 *snd, s32 sndSize)
{
return Resources::Instance()->InternalGetSound(snd, sndSize);
}
void Resources::Remove(GuiImageData *img)
{
Resources::Instance()->InternalRemoveImageData(img);
}
void Resources::Remove(GuiSound *snd)
{
Resources::Instance()->InternalRemoveSound(snd);
}
GuiImageData *Resources::InternalGetImageData(const u8 *img, u32 imgSize)
{
std::map<const u8 *, GuiImageData *>::iterator itr = images.find(img);
if (itr == images.end())
{
// Not found, create a new one
GuiImageData *d = new GuiImageData(img);
images[img] = d;
imageCount[d] = 1;
return d;
}
imageCount[itr->second]++;
return itr->second;
}
GuiSound *Resources::InternalGetSound(const u8 *snd, s32 sndSize)
{
std::map<const u8 *, GuiSound *>::iterator itr = sounds.find(snd);
if (itr == sounds.end())
{
// Not found, create a new one
// Only unallocated sounds go here
GuiSound *d = new GuiSound(snd, sndSize, false);
sounds[snd] = d;
soundCount[d] = 1;
return d;
}
soundCount[itr->second]++;
return itr->second;
}
void Resources::InternalRemoveImageData(GuiImageData *img)
{
std::map<GuiImageData *, int>::iterator itr = imageCount.find(img);
if (itr != imageCount.end())
{
itr->second--;
if (itr->second == 0) // Remove the resource
{
imageCount.erase(itr);
std::map<const u8 *, GuiImageData *>::iterator iitr;
for (iitr = images.begin(); iitr != images.end(); iitr++)
{
if (iitr->second == img)
{
delete iitr->second;
images.erase(iitr);
break;
}
}
}
}
}
void Resources::InternalRemoveSound(GuiSound *snd)
{
std::map<GuiSound *, int>::iterator itr = soundCount.find(snd);
if (itr != soundCount.end())
{
itr->second--;
if (itr->second == 0) // Remove the resource
{
soundCount.erase(itr);
std::map<const u8 *, GuiSound *>::iterator iitr;
for (iitr = sounds.begin(); iitr != sounds.end(); iitr++)
{
if (iitr->second == snd)
{
delete iitr->second;
sounds.erase(iitr);
break;
}
}
}
}
}
/***************************************************************************
* Copyright (C) 2009
* by Dimok & r-win
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Resources.h
*
* for WiiXplorer 2009
***************************************************************************/
#ifndef _RESOURCES_H
#define _RESOURCES_H
#define UNUSED __attribute__((unused))
#include <gccore.h>
#include "libwiigui/gui.h"
#include "filelist.h"
#include <map>
class Resources
{
public:
static Resources *Instance();
static void DestroyInstance();
//! Only images/sounds that are compiled into the app go here
static GuiImageData *GetImageData(const u8 *img, u32 imgSize);
static GuiSound *GetSound(const u8 *snd, s32 sndSize);
static void Remove(GuiImageData *img);
static void Remove(GuiSound *snd);
private:
GuiImageData *InternalGetImageData(const u8 *img, u32 imgSize);
GuiSound *InternalGetSound(const u8 *snd, s32 sndSize);
void InternalRemoveImageData(GuiImageData *img);
void InternalRemoveSound(GuiSound *snd);
~Resources();
static Resources *instance;
std::map<const u8 *, GuiImageData *> images;
std::map<const u8 *, GuiSound *> sounds;
std::map<GuiImageData *, int> imageCount;
std::map<GuiSound *, int> soundCount;
};
#endif //_RESOURCES_H
#include "mem2.h"
#include "mem2alloc.hpp"
#include <malloc.h>
#include <string.h>
#define MEM2_PRIORITY_SIZE 2097152 //2MB
// Forbid the use of MEM2 through malloc
u32 MALLOC_MEM2 = 0;
static CMEM2Alloc g_mem2gp;
static bool g_bigGoesToMem2 = false;
extern "C"
{
void MEM2_takeBigOnes(bool b)
{
g_bigGoesToMem2 = b;
}
void MEM2_init(unsigned int mem2Size)
{
g_mem2gp.init(mem2Size);
}
void MEM2_cleanup(void)
{
g_mem2gp.cleanup();
}
void *MEM2_alloc(unsigned int s)
{
return g_mem2gp.allocate(s);
}
void MEM2_free(void *p)
{
g_mem2gp.release(p);
}
void *MEM2_realloc(void *p, unsigned int s)
{
return g_mem2gp.reallocate(p, s);
}
unsigned int MEM2_usableSize(void *p)
{
return CMEM2Alloc::usableSize(p);
}
unsigned int MEM2_freesize()
{
return g_mem2gp.FreeSize();
}
extern __typeof(malloc) __real_malloc;
extern __typeof(calloc) __real_calloc;
extern __typeof(realloc) __real_realloc;
extern __typeof(memalign) __real_memalign;
extern __typeof(free) __real_free;
extern __typeof(malloc_usable_size) __real_malloc_usable_size;
void *__wrap_malloc(size_t size)
{
void *p;
if (g_bigGoesToMem2 && size > MEM2_PRIORITY_SIZE)
{
p = MEM2_alloc(size);
if (p != 0) {
return p;
}
return __real_malloc(size);
}
p = __real_malloc(size);
if (p != 0) {
return p;
}
return MEM2_alloc(size);
}
void *__wrap_calloc(size_t n, size_t size)
{
void *p;
if (g_bigGoesToMem2 && size > MEM2_PRIORITY_SIZE)
{
p = MEM2_alloc(n * size);
if (p != 0)
{
memset(p, 0, n * size);
return p;
}
return __real_calloc(n, size);
}
p = __real_calloc(n, size);
if (p != 0) {
return p;
}
p = MEM2_alloc(n * size);
if (p != 0) {
memset(p, 0, n * size);
}
return p;
}
void *__wrap_memalign(size_t a, size_t size)
{
void *p;
if (g_bigGoesToMem2 && size > MEM2_PRIORITY_SIZE)
{
if (a <= 32 && 32 % a == 0)
{
p = MEM2_alloc(size);
if (p != 0) {
return p;
}
}
return __real_memalign(a, size);
}
p = __real_memalign(a, size);
if (p != 0 || a > 32 || 32 % a != 0) {
return p;
}
return MEM2_alloc(size);
}
void __wrap_free(void *p)
{
if(!p)
return;
if (((u32)p & 0x10000000) != 0)
{
MEM2_free(p);
}
else
{
__real_free(p);
}
}
void *__wrap_realloc(void *p, size_t size)
{
void *n;
// ptr from mem2
if (((u32)p & 0x10000000) != 0 || (p == 0 && g_bigGoesToMem2 && size > MEM2_PRIORITY_SIZE))
{
n = MEM2_realloc(p, size);
if (n != 0) {
return n;
}
n = __real_malloc(size);
if (n == 0) {
return 0;
}
if (p != 0)
{
memcpy(n, p, MEM2_usableSize(p) < size ? MEM2_usableSize(p) : size);
MEM2_free(p);
}
return n;
}
// ptr from malloc
n = __real_realloc(p, size);
if (n != 0) {
return n;
}
n = MEM2_alloc(size);
if (n == 0) {
return 0;
}
if (p != 0)
{
memcpy(n, p, __real_malloc_usable_size(p) < size ? __real_malloc_usable_size(p) : size);
__real_free(p);
}
return n;
}
size_t __wrap_malloc_usable_size(void *p)
{
if (((u32)p & 0x10000000) != 0)
return MEM2_usableSize(p);
return __real_malloc_usable_size(p);
}
} ///extern "C"
// 2 MEM2 allocators, one for general purpose, one for covers
// Aligned and padded to 32 bytes, as required by many functions
#ifndef __MEM2_H_
#define __MEM2_H_
#ifdef __cplusplus
extern "C" {
#endif
void MEM2_init(unsigned int mem2Size);
void MEM2_cleanup(void);
void MEM2_takeBigOnes(bool b);
void *MEM2_alloc(unsigned int s);
void *MEM2_realloc(void *p, unsigned int s);
void MEM2_free(void *p);
unsigned int MEM2_usableSize(void *p);
unsigned int MEM2_freesize();
#ifdef __cplusplus
}
#endif
#endif // !defined(__MEM2_H_)
#include "mem2alloc.hpp"
#include <ogc/system.h>
#include <algorithm>
#include <string.h>
class LockMutex
{
mutex_t &m_mutex;
public:
LockMutex(mutex_t &m) : m_mutex(m) { LWP_MutexLock(m_mutex); }
~LockMutex(void) { LWP_MutexUnlock(m_mutex); }
};
void CMEM2Alloc::init(unsigned int size)
{
m_baseAddress = (SBlock *) (((u32)SYS_GetArena2Lo() + 31) & ~31);
m_endAddress = (SBlock *) ((char *)m_baseAddress + std::min(size * 0x100000, SYS_GetArena2Size() & ~31));
if (m_endAddress > (SBlock *) 0x93300000) //rest is reserved for usb/usb2/network and other stuff... (0xE0000 bytes)
m_endAddress = (SBlock *) 0x93300000;
SYS_SetArena2Lo(m_endAddress);
LWP_MutexInit(&m_mutex, 0);
}
void CMEM2Alloc::init(void *addr, void *end)
{
m_baseAddress = (SBlock *)(((u32)addr + 31) & ~31);
m_endAddress = (SBlock *)((u32)end & ~31);
LWP_MutexInit(&m_mutex, 0);
}
void CMEM2Alloc::cleanup(void)
{
LWP_MutexDestroy(m_mutex);
m_mutex = 0;
m_first = 0;
// Try to release the range we took through SYS functions
if (SYS_GetArena2Lo() == m_endAddress)
SYS_SetArena2Lo(m_baseAddress);
m_baseAddress = 0;
m_endAddress = 0;
}
void CMEM2Alloc::clear(void)
{
m_first = 0;
memset(m_baseAddress, 0, (u8 *)m_endAddress - (u8 *)m_endAddress);
}
unsigned int CMEM2Alloc::usableSize(void *p)
{
return p == 0 ? 0 : ((SBlock *)p - 1)->s * sizeof (SBlock);
}
void *CMEM2Alloc::allocate(unsigned int s)
{
if (s == 0)
s = 1;
//
LockMutex lock(m_mutex);
//
s = (s - 1) / sizeof (SBlock) + 1;
// First block
if (m_first == 0)
{
if (m_baseAddress + s + 1 >= m_endAddress)
return 0;
m_first = m_baseAddress;
m_first->next = 0;
m_first->prev = 0;
m_first->s = s;
m_first->f = false;
return (void *)(m_first + 1);
}
// Search for a free block
SBlock *i;
SBlock *j;
for (i = m_first; i != 0; i = i->next)
{
if (i->f && i->s >= s)
break;
j = i;
}
// Create a new block
if (i == 0)
{
i = j + j->s + 1;
if (i + s + 1 >= m_endAddress)
return 0;
j->next = i;
i->prev = j;
i->next = 0;
i->s = s;
i->f = false;
return (void *)(i + 1);
}
// Reuse a free block
i->f = false;
// Split it
if (i->s > s + 1)
{
j = i + s + 1;
j->f = true;
j->s = i->s - s - 1;
i->s = s;
j->next = i->next;
j->prev = i;
i->next = j;
if (j->next != 0)
j->next->prev = j;
}
return (void *)(i + 1);
}
void CMEM2Alloc::release(void *p)
{
if (p == 0)
return;
LockMutex lock(m_mutex);
SBlock *i = (SBlock *)p - 1;
i->f = true;
// If there are no other blocks following yet,
// set the remaining size to free size. - Dimok
if(i->next == 0)
i->s = m_endAddress - i - 1;
// Merge with previous block
if (i->prev != 0 && i->prev->f)
{
i = i->prev;
i->s += i->next->s + 1;
i->next = i->next->next;
if (i->next != 0)
i->next->prev = i;
}
// Merge with next block
if (i->next != 0 && i->next->f)
{
i->s += i->next->s + 1;
i->next = i->next->next;
if (i->next != 0)
i->next->prev = i;
}
}
void *CMEM2Alloc::reallocate(void *p, unsigned int s)
{
SBlock *i;
SBlock *j;
void *n;
if (s == 0)
s = 1;
if (p == 0)
return allocate(s);
i = (SBlock *)p - 1;
s = (s - 1) / sizeof (SBlock) + 1;
{
LockMutex lock(m_mutex);
//out of memory /* Dimok */
if (i + s + 1 >= m_endAddress)
{
return 0;
}
// Last block
if (i->next == 0 && i + s + 1 < m_endAddress)
{
i->s = s;
return p;
}
// Size <= current size + next block
if (i->next != 0 && i->s < s && i->next->f && i->s + i->next->s + 1 >= s)
{
// Merge
i->s += i->next->s + 1;
i->next = i->next->next;
if (i->next != 0)
i->next->prev = i;
}
// Size <= current size
if (i->s >= s)
{
// Split
if (i->s > s + 1)
{
j = i + s + 1;
j->f = true;
j->s = i->s - s - 1;
i->s = s;
j->next = i->next;
j->prev = i;
i->next = j;
if (j->next != 0)
j->next->prev = j;
}
return p;
}
}
// Size > current size
n = allocate(s * sizeof (SBlock));
if (n == 0)
return 0;
memcpy(n, p, i->s * sizeof (SBlock));
release(p);
return n;
}
unsigned int CMEM2Alloc::FreeSize()
{
LockMutex lock(m_mutex);
if (m_first == 0)
return (const char *) m_endAddress - (const char *) m_baseAddress;
SBlock *i;
unsigned int size = 0;
for(i = m_first; i != 0; i = i->next)
{
if(i->f && i->next != 0)
size += i->s;
else if(i->f && i->next == 0)
size += m_endAddress - i - 1;
else if(!i->f && i->next == 0)
size += m_endAddress - i - i->s - 1;
}
return size*sizeof(SBlock);
}
// MEM2 allocator
// Made as a class so i can have 2 sections, one being dedicated to the covers
#ifndef __MEM2ALLOC_HPP
#define __MEM2ALLOC_HPP
#include <ogc/mutex.h>
class CMEM2Alloc
{
public:
void *allocate(unsigned int s);
void release(void *p);
void *reallocate(void *p, unsigned int s);
void init(unsigned int size);
void init(void *addr, void *end);
void cleanup(void);
void clear(void);
static unsigned int usableSize(void *p);
void forceEndAddress(void *newAddr) { m_endAddress = (SBlock *)newAddr; }
void *getEndAddress(void) const { return m_endAddress; }
void info(void *&address, unsigned int &size) const { address = m_baseAddress; size = (const char *)m_endAddress - (const char *)m_baseAddress; }
unsigned int FreeSize();
//
CMEM2Alloc(void) : m_baseAddress(0), m_endAddress(0), m_first(0), m_mutex(0) { }
private:
struct SBlock
{
unsigned int s;
SBlock *next;
SBlock *prev;
bool f;
} __attribute__((aligned(32)));
SBlock *m_baseAddress;
SBlock *m_endAddress;
SBlock *m_first;
mutex_t m_mutex;
private:
CMEM2Alloc(const CMEM2Alloc &);
};
#endif // !defined(__MEM2ALLOC_HPP)
#!/bin/sh
rm $0
"./menu_settings_file"
echo "
------------------
(program exited with code: $?)"
echo "Press return to continue"
#to be more compatible with shells like dash
dummy_var=""
read dummy_var
This diff is collapsed.
This diff is collapsed.
......@@ -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)))
{
......
......@@ -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)))
......
......@@ -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)))
{
......
......@@ -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
};
};
\ No newline at end of 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
......
......@@ -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;
......