mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 02:41:55 +01:00
-fixed small stupid memory bug
-fixed codedump on exit in certain situations
This commit is contained in:
parent
48737c010a
commit
fa570d7c43
@ -227,6 +227,10 @@ CCoverFlow::CCoverFlow(void)
|
||||
m_normal_speed = 0.1f;
|
||||
m_selected_speed = 0.07f;
|
||||
//
|
||||
m_flipSound = NULL;
|
||||
m_hoverSound = NULL;
|
||||
m_selectSound = NULL;
|
||||
m_cancelSound = NULL;
|
||||
LWP_MutexInit(&m_mutex, 0);
|
||||
}
|
||||
|
||||
@ -262,13 +266,7 @@ void CCoverFlow::simulateOtherScreenFormat(bool s)
|
||||
|
||||
CCoverFlow::~CCoverFlow(void)
|
||||
{
|
||||
clear();
|
||||
if(m_flipSound != NULL)
|
||||
delete m_flipSound;
|
||||
m_flipSound = NULL;
|
||||
if(m_cancelSound != NULL)
|
||||
delete m_cancelSound;
|
||||
m_cancelSound = NULL;
|
||||
shutdown();
|
||||
LWP_MutexDestroy(m_mutex);
|
||||
}
|
||||
|
||||
@ -670,16 +668,13 @@ void CCoverFlow::clear(void)
|
||||
void CCoverFlow::shutdown(void)
|
||||
{
|
||||
gprintf("Cleanup Coverflow\n");
|
||||
clear();
|
||||
|
||||
m_dvdSkin.Cleanup();
|
||||
m_dvdSkin_Red.Cleanup();
|
||||
m_dvdSkin_Black.Cleanup();
|
||||
m_dvdSkin_Yellow.Cleanup();
|
||||
m_dvdSkin_GreenOne.Cleanup();
|
||||
m_dvdSkin_GreenTwo.Cleanup();
|
||||
m_loadingTexture.Cleanup();
|
||||
m_noCoverTexture.Cleanup();
|
||||
clear();
|
||||
|
||||
if(m_flipSound != NULL)
|
||||
delete m_flipSound;
|
||||
@ -1868,7 +1863,6 @@ bool CCoverFlow::start(const char *id)
|
||||
{
|
||||
if (m_pngLoadCoverFlat.empty() || STexture::TE_OK != m_loadingTexture.fromImageFile(m_pngLoadCoverFlat.c_str(), GX_TF_CMPR, 32, 512))
|
||||
if (STexture::TE_OK != m_loadingTexture.fromJPG(flatloading_jpg, flatloading_jpg_size, GX_TF_CMPR, 32, 512)) return false;
|
||||
|
||||
if (m_pngNoCoverFlat.empty() || STexture::TE_OK != m_noCoverTexture.fromImageFile(m_pngNoCoverFlat.c_str(), GX_TF_CMPR, 32, 512))
|
||||
if (STexture::TE_OK != m_noCoverTexture.fromPNG(flatnopic_png, GX_TF_CMPR, 32, 512)) return false;
|
||||
}
|
||||
@ -1920,18 +1914,6 @@ void CCoverFlow::right(void)
|
||||
_right(m_minDelay, m_rows >= 3 ? m_rows - 2 : 1);
|
||||
}
|
||||
|
||||
void CCoverFlow::_playSound(void)
|
||||
{
|
||||
/*if (m_soundVolume > 0)
|
||||
{
|
||||
sndCopyNum++;
|
||||
if(sndCopyNum == 4) sndCopyNum = 0;
|
||||
_playSound(m_sound[sndCopyNum]);
|
||||
//gprintf("\n\nPlaying flipsound copy # %u\n\n", sndCopyNum);
|
||||
}*/
|
||||
_playSound(m_flipSound);
|
||||
}
|
||||
|
||||
void CCoverFlow::_left(int repeatDelay, u32 step)
|
||||
{
|
||||
int prev, arrStep;
|
||||
@ -1968,7 +1950,7 @@ void CCoverFlow::_left(int repeatDelay, u32 step)
|
||||
_updateAllTargets();
|
||||
_instantTarget(0);
|
||||
}
|
||||
_playSound();
|
||||
_playSound(m_flipSound);
|
||||
m_covers[m_range / 2].angle -= _coverMovesA();
|
||||
m_covers[m_range / 2].pos -= _coverMovesP();
|
||||
}
|
||||
@ -2009,7 +1991,7 @@ void CCoverFlow::_right(int repeatDelay, u32 step)
|
||||
_updateAllTargets();
|
||||
_instantTarget(m_range - 1);
|
||||
}
|
||||
_playSound();
|
||||
_playSound(m_flipSound);
|
||||
m_covers[m_range / 2].angle -= _coverMovesA();
|
||||
m_covers[m_range / 2].pos -= _coverMovesP();
|
||||
}
|
||||
|
@ -330,8 +330,7 @@ private:
|
||||
bool _invisibleCover(u32 x, u32 y);
|
||||
void _instantTarget(int i);
|
||||
void _transposeCover(vector<CCover> &dst, u32 rows, u32 columns, int pos);
|
||||
void _playSound(void);
|
||||
|
||||
|
||||
void _stopSound(GuiSound * &snd);
|
||||
void _playSound(GuiSound * &snd);
|
||||
|
||||
|
@ -32,13 +32,13 @@ bool CCursor::init(const char *png, bool wideFix, CColor shadowColor, float shad
|
||||
if (STexture::TE_OK != m_texture.fromImageFile(png))
|
||||
{
|
||||
if (chan == 0)
|
||||
ok = STexture::TE_OK == m_texture.fromPNG(player1_point_png, GX_TF_RGBA8);
|
||||
ok = STexture::TE_OK == m_texture.fromPNG(player1_point_png);
|
||||
else if (chan == 1)
|
||||
ok = STexture::TE_OK == m_texture.fromPNG(player2_point_png, GX_TF_RGBA8);
|
||||
ok = STexture::TE_OK == m_texture.fromPNG(player2_point_png);
|
||||
else if (chan == 2)
|
||||
ok = STexture::TE_OK == m_texture.fromPNG(player3_point_png, GX_TF_RGBA8);
|
||||
ok = STexture::TE_OK == m_texture.fromPNG(player3_point_png);
|
||||
else if (chan == 3)
|
||||
ok = STexture::TE_OK == m_texture.fromPNG(player4_point_png, GX_TF_RGBA8);
|
||||
ok = STexture::TE_OK == m_texture.fromPNG(player4_point_png);
|
||||
}
|
||||
if (ok && shadow)
|
||||
{
|
||||
|
@ -215,6 +215,7 @@ bool STexture::CopyTexture(const STexture &tex)
|
||||
|
||||
STexture::TexErr STexture::fromImageFile(const char *filename, u8 f, u32 minMipSize, u32 maxMipSize)
|
||||
{
|
||||
Cleanup();
|
||||
FILE *file = fopen(filename, "rb");
|
||||
if(file == NULL)
|
||||
{
|
||||
@ -257,7 +258,10 @@ STexture::TexErr STexture::fromTHP(const u8 *src, u32 w, u32 h)
|
||||
dataSize = GX_GetTexBufferSize(width, height, format, GX_FALSE, 0);
|
||||
data = (u8*)MEM2_alloc(dataSize);
|
||||
if(data == NULL)
|
||||
{
|
||||
Cleanup();
|
||||
return TE_NOMEM;
|
||||
}
|
||||
for(u32 block = 0; block < height; block += 4)
|
||||
{
|
||||
for(u32 i = 0; i < width; i += 4)
|
||||
@ -466,8 +470,10 @@ STexture::TexErr STexture::fromPNG(const u8 *buffer, u8 f, u32 minMipSize, u32 m
|
||||
|
||||
tmpData2 = _genMipMaps(tmpData2, imgProp.imgWidth, imgProp.imgHeight, maxLODTmp, baseWidth, baseHeight);
|
||||
if(tmpData2 == NULL)
|
||||
{
|
||||
Cleanup();
|
||||
return TE_NOMEM;
|
||||
|
||||
}
|
||||
u32 nWidth = newWidth;
|
||||
u32 nHeight = newHeight;
|
||||
u8 *pSrc = tmpData2;
|
||||
@ -659,7 +665,10 @@ u8 *STexture::_genMipMaps(u8 *src, u32 width, u32 height, u8 maxLOD, u32 lod0Wid
|
||||
u32 bufSize = fixGX_GetTexBufferSize(lod0Width, lod0Height, GX_TF_RGBA8, GX_TRUE, maxLOD);
|
||||
u8 *dst = (u8*)MEM2_alloc(bufSize);
|
||||
if(dst == NULL)
|
||||
return src;
|
||||
{
|
||||
Cleanup();
|
||||
return NULL;
|
||||
}
|
||||
memset(dst, 0, bufSize);
|
||||
_resize(dst, lod0Width, lod0Height, src, width, height);
|
||||
DCFlushRange(dst, lod0Width * lod0Height * 4);
|
||||
|
@ -80,7 +80,6 @@ const int CVideo::_stencilWidth = 128;
|
||||
const int CVideo::_stencilHeight = 128;
|
||||
|
||||
static lwp_t waitThread = LWP_THREAD_NULL;
|
||||
u8 *waitThreadStack;
|
||||
|
||||
CVideo m_vid;
|
||||
CVideo::CVideo(void) :
|
||||
@ -284,13 +283,16 @@ void CVideo::cleanup(void)
|
||||
{
|
||||
if(m_defaultWaitMessages[i].data != NULL)
|
||||
free(m_defaultWaitMessages[i].data);
|
||||
m_defaultWaitMessages[i].data = NULL;
|
||||
}
|
||||
if(waitThreadStack != NULL)
|
||||
free(waitThreadStack);
|
||||
free(MEM_K1_TO_K0(m_frameBuf[0]));
|
||||
m_frameBuf[0] = NULL;
|
||||
free(MEM_K1_TO_K0(m_frameBuf[1]));
|
||||
m_frameBuf[1] = NULL;
|
||||
free(m_stencil);
|
||||
m_stencil = NULL;
|
||||
free(m_fifo);
|
||||
m_fifo = NULL;
|
||||
}
|
||||
|
||||
void CVideo::prepareAAPass(int aaStep)
|
||||
@ -558,7 +560,7 @@ void CVideo::hideWaitMessage()
|
||||
if(LWP_ThreadIsSuspended(waitThread))
|
||||
LWP_ResumeThread(waitThread);
|
||||
while(m_showingWaitMessages)
|
||||
usleep(100);
|
||||
usleep(50);
|
||||
LWP_JoinThread(waitThread, NULL);
|
||||
}
|
||||
waitThread = LWP_THREAD_NULL;
|
||||
@ -602,9 +604,7 @@ void CVideo::waitMessage(const vector<STexture> &tex, float delay)
|
||||
else if(m_waitMessages.size() > 1)
|
||||
{
|
||||
m_showWaitMessage = true;
|
||||
if(waitThreadStack != NULL)
|
||||
waitThreadStack = (u8*)MEM2_alloc(8192);
|
||||
LWP_CreateThread(&waitThread, (void *(*)(void *))_showWaitMessages, (void *)this, waitThreadStack, 8192, LWP_PRIO_HIGHEST);
|
||||
LWP_CreateThread(&waitThread, (void *(*)(void *))_showWaitMessages, (void *)this, NULL, 0, LWP_PRIO_HIGHEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
/* Variables */
|
||||
bool reset = false;
|
||||
bool shutdown = false;
|
||||
bool exiting = false;
|
||||
u8 ExitOption = 0;
|
||||
const char *NeekPath = NULL;
|
||||
|
||||
@ -61,7 +60,7 @@ void Close_Inputs(void)
|
||||
|
||||
bool Sys_Exiting(void)
|
||||
{
|
||||
return reset || shutdown || exiting;
|
||||
return reset || shutdown;
|
||||
}
|
||||
|
||||
void Sys_Shutdown(void)
|
||||
|
@ -33,10 +33,4 @@ unsigned int MEM2_freesize();
|
||||
}
|
||||
#endif
|
||||
|
||||
enum Alloc
|
||||
{
|
||||
ALLOC_MALLOC,
|
||||
ALLOC_MEM2,
|
||||
};
|
||||
|
||||
#endif // !defined(__MEM2_HPP)
|
@ -220,9 +220,6 @@ void CMenu::exitHandler(int ExitTo)
|
||||
ExitTo = EXIT_TO_HBC;
|
||||
}
|
||||
Sys_ExitTo(ExitTo);
|
||||
// Mark exiting to prevent soundhandler from restarting
|
||||
extern bool exiting;
|
||||
exiting = true;
|
||||
}
|
||||
|
||||
int CMenu::main(void)
|
||||
|
@ -147,11 +147,8 @@ void GuiSound::Init()
|
||||
void GuiSound::FreeMemory()
|
||||
{
|
||||
Stop();
|
||||
|
||||
// Prevent reinitialization of SoundHandler since we're exiting
|
||||
if(!Sys_Exiting())
|
||||
SoundHandle.RemoveDecoder(this->voice);
|
||||
|
||||
if(this->voice != -1)
|
||||
SoundHandle.RemoveDecoder(this->voice);
|
||||
if(allocated && sound != NULL)
|
||||
free(sound);
|
||||
allocated = false;
|
||||
|
Loading…
Reference in New Issue
Block a user