-limiting mem1 usage (we dont have that much in mem1 so 11mb

approx are enough) also readded memory cleanup before booting
a wii game to make sure games work
-added some small check to see if path is valid, sometimes
it codedumped on game path check
This commit is contained in:
fix94.1 2012-05-18 14:10:37 +00:00
parent 035812f062
commit eb2a6158bb
9 changed files with 41 additions and 17 deletions

View File

@ -3,6 +3,7 @@
#include <string.h>
#include "Gekko.h"
#include "gecko.h"
#include "utils.h"
#define DEFAULT_FIFO_SIZE (256 * 1024)
@ -145,7 +146,7 @@ void CVideo::init(void)
VIDEO_WaitVSync();
if (m_rmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync();
m_fifo = MEM1_memalign(32, DEFAULT_FIFO_SIZE);
m_fifo = MEM1_alloc(ALIGN32(DEFAULT_FIFO_SIZE));
memset(m_fifo, 0, DEFAULT_FIFO_SIZE);
GX_Init(m_fifo, DEFAULT_FIFO_SIZE);
GX_SetCopyClear(CColor(0), 0x00FFFFFF);
@ -177,7 +178,7 @@ void CVideo::init(void)
render();
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
m_stencil = MEM1_memalign(32, CVideo::_stencilWidth * CVideo::_stencilHeight);
m_stencil = MEM1_alloc(ALIGN32(CVideo::_stencilWidth * CVideo::_stencilHeight));
memset(m_stencil, 0, CVideo::_stencilWidth * CVideo::_stencilHeight);
}

View File

@ -46,8 +46,13 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
bool FoundDMLgame;
for(vector<string>::iterator templist = temp_pathlist.begin(); templist != temp_pathlist.end(); templist++)
{
if((*templist).size() == 0)
continue;
dir_itr = opendir((*templist).c_str());
if (!dir_itr) continue;
if(!dir_itr)
continue;
FoundDMLgame = false;
/* Read secondary entries */

View File

@ -241,7 +241,7 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
frag_concat(fa, fs);
}
frag_list = MEM1_memalign(32, ALIGN32(sizeof(FragList)));
frag_list = MEM1_alloc(ALIGN32(sizeof(FragList)));
if(frag_list == NULL)
goto out;

View File

@ -36,6 +36,7 @@ extern "C"
int main(int argc, char **argv)
{
__exception_setreload(5);
MEM1_init((void*)0x80003f00, (void*)0x80b00000);
// Init video
CVideo vid;

View File

@ -10,6 +10,7 @@
// Forbid the use of MEM2 through malloc
u32 MALLOC_MEM2 = 0;
static CMEM2Alloc g_mem1gp;
static CMEM2Alloc g_mem2gp;
extern "C"
@ -22,25 +23,35 @@ extern __typeof(memalign) __real_memalign;
extern __typeof(free) __real_free;
extern __typeof(malloc_usable_size) __real_malloc_usable_size;
void MEM1_init(void *addr, void *end)
{
g_mem1gp.init(addr, end);
g_mem1gp.clear();
}
void MEM1_cleanup(void)
{
g_mem1gp.cleanup();
}
void MEM1_clear(void)
{
g_mem1gp.clear();
}
void *MEM1_alloc(unsigned int s)
{
return __real_malloc(s);
}
void *MEM1_memalign(unsigned int a, unsigned int s)
{
return __real_memalign(a, s);
return g_mem1gp.allocate(s);
}
void *MEM1_realloc(void *p, unsigned int s)
{
return __real_realloc(p, s);
return g_mem1gp.reallocate(p, s);
}
void MEM1_free(void *p)
{
__real_free(p);
g_mem1gp.release(p);
}

View File

@ -12,8 +12,10 @@ extern "C"
#define MAX_MEM1_ARENA_LO ((void *)(0x81700000-size))
#define MEM2_PRIORITY_SIZE 0x1000
void MEM1_init(void *addr, void *end);
void MEM1_cleanup(void);
void MEM1_clear(void);
void *MEM1_alloc(unsigned int s);
void *MEM1_memalign(unsigned int a, unsigned int s);
void *MEM1_realloc(void *p, unsigned int s);
void MEM1_free(void *p);

View File

@ -1294,6 +1294,10 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
if(currentPartition == 0)
SDHC_Init();
/* Clear Memory */
MEM1_clear();
MEM2_clear();
/* Find game partition offset */
u64 offset;
s32 ret = Disc_FindPartition(&offset);
@ -1438,7 +1442,7 @@ void CMenu::_playGameSound(void)
CheckGameSoundThread();
if(!gameSoundThreadStack.get())
gameSoundThreadStack = smartMem1Alloc(gameSoundThreadStackSize);
gameSoundThreadStack = smartAnyAlloc(gameSoundThreadStackSize);
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, gameSoundThreadStack.get(), gameSoundThreadStackSize, 60);
}

View File

@ -52,7 +52,7 @@ void BufferCircle::SetBufferBlockSize(int size)
{
if(SoundBuffer[i] != NULL)
MEM1_free(SoundBuffer[i]);
SoundBuffer[i] = (u8 *)MEM1_memalign(32, ALIGN32(BufferBlockSize));
SoundBuffer[i] = (u8 *)MEM1_alloc(ALIGN32(BufferBlockSize));
BufferSize[i] = 0;
BufferReady[i] = false;
}
@ -72,7 +72,7 @@ void BufferCircle::Resize(int size)
for(int i = oldSize; i < Size(); i++)
{
if(BufferBlockSize > 0)
SoundBuffer[i] = (u8 *)MEM1_memalign(32, ALIGN32(BufferBlockSize));
SoundBuffer[i] = (u8 *)MEM1_alloc(ALIGN32(BufferBlockSize));
else
SoundBuffer[i] = NULL;
BufferSize[i] = 0;

View File

@ -43,7 +43,7 @@ SoundHandler::SoundHandler()
for(u32 i = 0; i < MAX_DECODERS; ++i)
DecoderList[i] = NULL;
ThreadStack = (u8 *)MEM1_memalign(32, 32768);
ThreadStack = (u8 *)MEM1_alloc(32768);
if(!ThreadStack)
return;