mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-24 04:09:15 +01:00
-cleaned up mem allocs a bit, also corrected wrong display of
usable size in mem1 region, also fixed a fatal bug in it, some bug is still in it...
This commit is contained in:
parent
db42694703
commit
f29a014ac0
@ -146,7 +146,7 @@ void CVideo::init(void)
|
|||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
if (m_rmode->viTVMode & VI_NON_INTERLACE)
|
if (m_rmode->viTVMode & VI_NON_INTERLACE)
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
m_fifo = MEM1_alloc(ALIGN32(DEFAULT_FIFO_SIZE));
|
m_fifo = MEM1_memalign(32, DEFAULT_FIFO_SIZE);
|
||||||
memset(m_fifo, 0, DEFAULT_FIFO_SIZE);
|
memset(m_fifo, 0, DEFAULT_FIFO_SIZE);
|
||||||
GX_Init(m_fifo, DEFAULT_FIFO_SIZE);
|
GX_Init(m_fifo, DEFAULT_FIFO_SIZE);
|
||||||
GX_SetCopyClear(CColor(0), 0x00FFFFFF);
|
GX_SetCopyClear(CColor(0), 0x00FFFFFF);
|
||||||
@ -178,7 +178,7 @@ void CVideo::init(void)
|
|||||||
render();
|
render();
|
||||||
VIDEO_SetBlack(FALSE);
|
VIDEO_SetBlack(FALSE);
|
||||||
VIDEO_Flush();
|
VIDEO_Flush();
|
||||||
m_stencil = MEM1_alloc(ALIGN32(CVideo::_stencilWidth * CVideo::_stencilHeight));
|
m_stencil = MEM1_memalign(32, CVideo::_stencilWidth * CVideo::_stencilHeight);
|
||||||
memset(m_stencil, 0, CVideo::_stencilWidth * CVideo::_stencilHeight);
|
memset(m_stencil, 0, CVideo::_stencilWidth * CVideo::_stencilHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
|||||||
frag_concat(fa, fs);
|
frag_concat(fa, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
frag_list = MEM1_alloc(ALIGN32(sizeof(FragList)));
|
frag_list = MEM1_memalign(32, sizeof(FragList));
|
||||||
if(frag_list == NULL)
|
if(frag_list == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
/* Macros */
|
/* Macros */
|
||||||
#define round_up(x,n) (-(-(x) & -(n)))
|
#define round_up(x,n) (-(-(x) & -(n)))
|
||||||
|
|
||||||
#define ALIGN(x) (((x) + 3) & ~3)
|
#define ALIGN(n, x) (((x) + (n - 1)) & ~(n - 1))
|
||||||
#define ALIGN32(x) (((x) + 31) & ~31)
|
#define ALIGN32(x) (((x) + 31) & ~31)
|
||||||
#define ALIGNED(x) __attribute__((aligned(x)))
|
#define ALIGNED(x) __attribute__((aligned(x)))
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "mem2.hpp"
|
#include "mem2.hpp"
|
||||||
#include "mem2alloc.hpp"
|
#include "mem2alloc.hpp"
|
||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
// Forbid the use of MEM2 through malloc
|
// Forbid the use of MEM2 through malloc
|
||||||
u32 MALLOC_MEM2 = 0;
|
u32 MALLOC_MEM2 = 0;
|
||||||
@ -44,6 +45,11 @@ void *MEM1_alloc(unsigned int s)
|
|||||||
return g_mem1gp.allocate(s);
|
return g_mem1gp.allocate(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *MEM1_memalign(unsigned int a, unsigned int s)
|
||||||
|
{
|
||||||
|
return g_mem1gp.allocate(ALIGN(a, s));
|
||||||
|
}
|
||||||
|
|
||||||
void *MEM1_realloc(void *p, unsigned int s)
|
void *MEM1_realloc(void *p, unsigned int s)
|
||||||
{
|
{
|
||||||
return g_mem1gp.reallocate(p, s);
|
return g_mem1gp.reallocate(p, s);
|
||||||
@ -54,6 +60,16 @@ void MEM1_free(void *p)
|
|||||||
g_mem1gp.release(p);
|
g_mem1gp.release(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int MEM1_usableSize(void *p)
|
||||||
|
{
|
||||||
|
return g_mem1gp.usableSize(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int MEM1_freesize()
|
||||||
|
{
|
||||||
|
return g_mem1gp.FreeSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MEM2_init(unsigned int mem2Size)
|
void MEM2_init(unsigned int mem2Size)
|
||||||
{
|
{
|
||||||
@ -81,6 +97,11 @@ void *MEM2_alloc(unsigned int s)
|
|||||||
return g_mem2gp.allocate(s);
|
return g_mem2gp.allocate(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *MEM2_memalign(unsigned int a, unsigned int s)
|
||||||
|
{
|
||||||
|
return g_mem2gp.allocate(ALIGN(a, s));
|
||||||
|
}
|
||||||
|
|
||||||
void *MEM2_realloc(void *p, unsigned int s)
|
void *MEM2_realloc(void *p, unsigned int s)
|
||||||
{
|
{
|
||||||
return g_mem2gp.reallocate(p, s);
|
return g_mem2gp.reallocate(p, s);
|
||||||
@ -88,7 +109,7 @@ void *MEM2_realloc(void *p, unsigned int s)
|
|||||||
|
|
||||||
unsigned int MEM2_usableSize(void *p)
|
unsigned int MEM2_usableSize(void *p)
|
||||||
{
|
{
|
||||||
return CMEM2Alloc::usableSize(p);
|
return g_mem2gp.usableSize(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int MEM2_freesize()
|
unsigned int MEM2_freesize()
|
||||||
|
@ -16,14 +16,18 @@ void MEM1_init(void *addr, void *end);
|
|||||||
void MEM1_cleanup(void);
|
void MEM1_cleanup(void);
|
||||||
void MEM1_clear(void);
|
void MEM1_clear(void);
|
||||||
void *MEM1_alloc(unsigned int s);
|
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_realloc(void *p, unsigned int s);
|
||||||
void MEM1_free(void *p);
|
void MEM1_free(void *p);
|
||||||
|
unsigned int MEM1_usableSize(void *p);
|
||||||
|
unsigned int MEM1_freesize();
|
||||||
|
|
||||||
void MEM2_init(unsigned int mem2Size);
|
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);
|
||||||
void *MEM2_alloc(unsigned int s);
|
void *MEM2_alloc(unsigned int s);
|
||||||
|
void *MEM2_memalign(unsigned int a, unsigned int s);
|
||||||
void *MEM2_realloc(void *p, unsigned int s);
|
void *MEM2_realloc(void *p, unsigned int s);
|
||||||
unsigned int MEM2_usableSize(void *p);
|
unsigned int MEM2_usableSize(void *p);
|
||||||
unsigned int MEM2_freesize();
|
unsigned int MEM2_freesize();
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
#include "smartptr.hpp"
|
#include "smartptr.hpp"
|
||||||
|
|
||||||
SmartBuf smartMalloc(unsigned int size)
|
|
||||||
{
|
|
||||||
return SmartBuf((unsigned char *)malloc(size), SmartBuf::SRCALL_MALLOC);
|
|
||||||
}
|
|
||||||
|
|
||||||
SmartBuf smartMemAlign32(unsigned int size)
|
SmartBuf smartMemAlign32(unsigned int size)
|
||||||
{
|
{
|
||||||
return smartAnyAlloc(size);
|
return smartAnyAlloc(size);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
template <class T> class SmartPtr
|
template <class T> class SmartPtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum SrcAlloc { SRCALL_MALLOC, SRCALL_MEM2, SRCALL_MEM1, SRCALL_NEW };
|
enum SrcAlloc { SRCALL_NEW, SRCALL_MEM1, SRCALL_MEM2 };
|
||||||
T &operator*(void) const { return *m_p; }
|
T &operator*(void) const { return *m_p; }
|
||||||
T *operator->(void) const { return m_p; }
|
T *operator->(void) const { return m_p; }
|
||||||
bool operator!(void) const { return m_p == NULL; }
|
bool operator!(void) const { return m_p == NULL; }
|
||||||
@ -25,11 +25,14 @@ public:
|
|||||||
{
|
{
|
||||||
switch(m_srcAlloc)
|
switch(m_srcAlloc)
|
||||||
{
|
{
|
||||||
case SRCALL_NEW:
|
case SRCALL_MEM1:
|
||||||
delete m_p;
|
MEM1_free(m_p);
|
||||||
|
break;
|
||||||
|
case SRCALL_MEM2:
|
||||||
|
MEM2_free(m_p);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
free(m_p);
|
delete m_p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete m_refcount;
|
delete m_refcount;
|
||||||
@ -67,7 +70,6 @@ protected:
|
|||||||
typedef SmartPtr<unsigned char> SmartBuf;
|
typedef SmartPtr<unsigned char> SmartBuf;
|
||||||
typedef SmartPtr<GuiSound> SmartGuiSound;
|
typedef SmartPtr<GuiSound> SmartGuiSound;
|
||||||
|
|
||||||
SmartBuf smartMalloc(unsigned int size);
|
|
||||||
SmartBuf smartMemAlign32(unsigned int size);
|
SmartBuf smartMemAlign32(unsigned int size);
|
||||||
SmartBuf smartMem2Alloc(unsigned int size);
|
SmartBuf smartMem2Alloc(unsigned int size);
|
||||||
SmartBuf smartAnyAlloc(unsigned int size);
|
SmartBuf smartAnyAlloc(unsigned int size);
|
||||||
|
@ -1776,7 +1776,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting)
|
|||||||
m_cameraSound->Play(255);
|
m_cameraSound->Play(255);
|
||||||
}
|
}
|
||||||
#ifdef SHOWMEM
|
#ifdef SHOWMEM
|
||||||
m_btnMgr.setText(m_mem2FreeSize, wfmt(L"Mem2 Free:%u, Mem1 Free:%u", MEM2_freesize(), SYS_GetArena1Size()), true);
|
m_btnMgr.setText(m_mem2FreeSize, wfmt(L"Mem2 Free:%u, Mem1 Free:%u", MEM2_freesize(), MEM1_freesize()), true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1420,7 +1420,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
_extractBannerTitle(banner, GetLanguage(m->m_loc.getString(m->m_curLanguage, "gametdb_code", "EN").c_str()));
|
_extractBannerTitle(banner, GetLanguage(m->m_loc.getString(m->m_curLanguage, "gametdb_code", "EN").c_str()));
|
||||||
|
|
||||||
const u8 *soundBin = banner->GetFile((char *) "sound.bin", &sndSize);
|
const u8 *soundBin = banner->GetFile((char *) "sound.bin", &sndSize);
|
||||||
delete banner;
|
MEM2_free(banner);
|
||||||
|
|
||||||
if (soundBin == NULL || (((IMD5Header *)soundBin)->fcc != 'IMD5' && ((IMD5Header *)soundBin)->fcc != 'RIFF'))
|
if (soundBin == NULL || (((IMD5Header *)soundBin)->fcc != 'IMD5' && ((IMD5Header *)soundBin)->fcc != 'RIFF'))
|
||||||
{
|
{
|
||||||
@ -1442,7 +1442,7 @@ void CMenu::_playGameSound(void)
|
|||||||
|
|
||||||
CheckGameSoundThread();
|
CheckGameSoundThread();
|
||||||
if(!gameSoundThreadStack.get())
|
if(!gameSoundThreadStack.get())
|
||||||
gameSoundThreadStack = smartAnyAlloc(gameSoundThreadStackSize);
|
gameSoundThreadStack = smartMem1Alloc(gameSoundThreadStackSize);
|
||||||
|
|
||||||
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, gameSoundThreadStack.get(), gameSoundThreadStackSize, 60);
|
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, gameSoundThreadStack.get(), gameSoundThreadStackSize, 60);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ void BufferCircle::SetBufferBlockSize(int size)
|
|||||||
{
|
{
|
||||||
if(SoundBuffer[i] != NULL)
|
if(SoundBuffer[i] != NULL)
|
||||||
MEM1_free(SoundBuffer[i]);
|
MEM1_free(SoundBuffer[i]);
|
||||||
SoundBuffer[i] = (u8 *)MEM1_alloc(ALIGN32(BufferBlockSize));
|
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
|
||||||
BufferSize[i] = 0;
|
BufferSize[i] = 0;
|
||||||
BufferReady[i] = false;
|
BufferReady[i] = false;
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ void BufferCircle::Resize(int size)
|
|||||||
for(int i = oldSize; i < Size(); i++)
|
for(int i = oldSize; i < Size(); i++)
|
||||||
{
|
{
|
||||||
if(BufferBlockSize > 0)
|
if(BufferBlockSize > 0)
|
||||||
SoundBuffer[i] = (u8 *)MEM1_alloc(ALIGN32(BufferBlockSize));
|
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
|
||||||
else
|
else
|
||||||
SoundBuffer[i] = NULL;
|
SoundBuffer[i] = NULL;
|
||||||
BufferSize[i] = 0;
|
BufferSize[i] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user