-fixed the strange background size problems

-fixed deleting some gamecube games properly
-fixed random codedumps on switching views, entering settings etc
This commit is contained in:
fix94.1 2012-11-16 22:00:20 +00:00
parent 2356afb1c8
commit cdf717916a
6 changed files with 45 additions and 32 deletions

View File

@ -213,21 +213,23 @@ void STexture::Cleanup(void)
maxLOD = 0; maxLOD = 0;
} }
bool STexture::CopyTexture(const STexture &tex) bool STexture::CopyTexture(const STexture *tex)
{ {
Cleanup(); if(tex == this || tex == NULL || tex->data == NULL || tex->dataSize == 0)
if(tex.data == NULL || tex.dataSize == 0)
return false; return false;
data = (u8*)MEM2_alloc(tex.dataSize); if(dataSize != tex->dataSize)
Cleanup();
if(data == NULL)
data = (u8*)MEM2_alloc(tex->dataSize);
if(data == NULL) if(data == NULL)
return false; return false;
dataSize = tex.dataSize; dataSize = tex->dataSize;
memcpy(data, tex.data, dataSize); memcpy(data, tex->data, dataSize);
DCFlushRange(data, dataSize); DCFlushRange(data, dataSize);
width = tex.width; width = tex->width;
height = tex.height; height = tex->height;
format = tex.format; format = tex->format;
maxLOD = tex.maxLOD; maxLOD = tex->maxLOD;
return true; return true;
} }

View File

@ -16,7 +16,7 @@ class STexture
public: public:
STexture(void) : data(NULL), dataSize(0), width(0), height(0), format(-1), maxLOD(0), thread(false) { } STexture(void) : data(NULL), dataSize(0), width(0), height(0), format(-1), maxLOD(0), thread(false) { }
void Cleanup(); void Cleanup();
bool CopyTexture(const STexture &tex); bool CopyTexture(const STexture *tex);
u8 *data; u8 *data;
u32 dataSize; u32 dataSize;
u32 width; u32 width;

View File

@ -144,6 +144,7 @@ CMenu::CMenu()
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_USB;
m_Emulator_boot = false; m_Emulator_boot = false;
m_music_info = true; m_music_info = true;
m_nextBg = NULL;
} }
void CMenu::init() void CMenu::init()
@ -526,7 +527,7 @@ void CMenu::_Theme_Cleanup(void)
/* Backgrounds */ /* Backgrounds */
theme.bg.Cleanup(); theme.bg.Cleanup();
m_prevBg.Cleanup(); m_prevBg.Cleanup();
m_nextBg.Cleanup(); m_nextBg = NULL;
m_curBg.Cleanup(); m_curBg.Cleanup();
m_lqBg.Cleanup(); m_lqBg.Cleanup();
/* Buttons */ /* Buttons */
@ -1938,7 +1939,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
CoverFlow.setFanartTextColor(m_fa.getTextColor(m_theme.getColor("_COVERFLOW", "font_color", CColor(0xFFFFFFFF)))); CoverFlow.setFanartTextColor(m_fa.getTextColor(m_theme.getColor("_COVERFLOW", "font_color", CColor(0xFFFFFFFF))));
m_vid.prepare(); m_vid.prepare();
m_vid.setup2DProjection(); m_vid.setup2DProjection(false, true);
_updateBg(); _updateBg();
if(CoverFlow.getRenderTex()) if(CoverFlow.getRenderTex())
CoverFlow.RenderTex(); CoverFlow.RenderTex();
@ -1965,6 +1966,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
} }
else else
{ {
m_vid.setup2DProjection();
_drawBg(); _drawBg();
m_fa.draw(false); m_fa.draw(false);
if(withCF) if(withCF)
@ -2052,11 +2054,11 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
void CMenu::_setBg(const STexture &tex, const STexture &lqTex) void CMenu::_setBg(const STexture &tex, const STexture &lqTex)
{ {
m_lqBg = lqTex; m_lqBg = lqTex;
if(tex.data == m_nextBg.data) if(m_nextBg == &tex)
return; return;
m_prevBg.CopyTexture(m_curBg); m_prevBg.CopyTexture(&m_curBg);
m_curBg.Cleanup(); m_curBg.Cleanup();
m_nextBg.CopyTexture(tex); m_nextBg = &tex;
m_bgCrossFade = 0xFF; m_bgCrossFade = 0xFF;
} }
@ -2068,10 +2070,9 @@ void CMenu::_updateBg(void)
if (m_bgCrossFade == 0) return; if (m_bgCrossFade == 0) return;
m_bgCrossFade = max(0, (int)m_bgCrossFade - 14); m_bgCrossFade = max(0, (int)m_bgCrossFade - 14);
if (m_bgCrossFade == 0) if(m_bgCrossFade == 0)
{ {
m_curBg.Cleanup(); m_curBg.CopyTexture(m_nextBg);
m_curBg = m_nextBg;
return; return;
} }
GX_ClearVtxDesc(); GX_ClearVtxDesc();
@ -2103,8 +2104,11 @@ void CMenu::_updateBg(void)
GX_SetZMode(GX_DISABLE, GX_ALWAYS, GX_FALSE); GX_SetZMode(GX_DISABLE, GX_ALWAYS, GX_FALSE);
guMtxIdentity(modelViewMtx); guMtxIdentity(modelViewMtx);
GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0); GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0);
GX_InitTexObj(&texObj, m_nextBg.data, m_nextBg.width, m_nextBg.height, m_nextBg.format, GX_CLAMP, GX_CLAMP, GX_FALSE); if(m_nextBg != NULL && m_nextBg->data != NULL)
{
GX_InitTexObj(&texObj, m_nextBg->data, m_nextBg->width, m_nextBg->height, m_nextBg->format, GX_CLAMP, GX_CLAMP, GX_FALSE);
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
}
if(m_prevBg.data != NULL) if(m_prevBg.data != NULL)
{ {
GX_InitTexObj(&texObj2, m_prevBg.data, m_prevBg.width, m_prevBg.height, m_prevBg.format, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObj(&texObj2, m_prevBg.data, m_prevBg.width, m_prevBg.height, m_prevBg.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
@ -2128,8 +2132,7 @@ void CMenu::_updateBg(void)
m_vid.renderToTexture(m_curBg, true); m_vid.renderToTexture(m_curBg, true);
if(m_curBg.data == NULL) if(m_curBg.data == NULL)
{ {
m_curBg.Cleanup(); m_curBg.CopyTexture(m_nextBg);
m_curBg = m_nextBg;
m_bgCrossFade = 0; m_bgCrossFade = 0;
} }
} }

View File

@ -117,7 +117,7 @@ private:
/* End Updates */ /* End Updates */
// //
STexture m_prevBg; STexture m_prevBg;
STexture m_nextBg; const STexture *m_nextBg;
STexture m_curBg; STexture m_curBg;
STexture m_lqBg; STexture m_lqBg;
u8 m_bgCrossFade; u8 m_bgCrossFade;

View File

@ -446,9 +446,6 @@ void CMenu::_game(bool launch)
m_gameSound.Stop(); m_gameSound.Stop();
m_banner.SetShowBanner(false); m_banner.SetShowBanner(false);
_hideGame(); _hideGame();
/* Backup Background */
STexture Current_LQ_BG = m_lqBg;
STexture Current_HQ_BG = m_curBg;
/* Set Background empty */ /* Set Background empty */
STexture EmptyBG; STexture EmptyBG;
_setBg(EmptyBG, EmptyBG); _setBg(EmptyBG, EmptyBG);
@ -474,7 +471,7 @@ void CMenu::_game(bool launch)
movie.Stop(); movie.Stop();
m_curBg.Cleanup(); m_curBg.Cleanup();
/* Finished, so lets re-setup the background */ /* Finished, so lets re-setup the background */
_setBg(Current_HQ_BG, Current_LQ_BG); _setBg(m_mainBg, m_mainBgLQ);
_updateBg(); _updateBg();
/* Get back into our coverflow */ /* Get back into our coverflow */
_showGame(); _showGame();

View File

@ -380,14 +380,25 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
case CMenu::WO_REMOVE_GAME: case CMenu::WO_REMOVE_GAME:
if(CF_Hdr->type == TYPE_GC_GAME) if(CF_Hdr->type == TYPE_GC_GAME)
{ {
char GC_Path[1024];
GC_Path[1023] = '\0';
if(strcasestr(CF_Hdr->path, "boot.bin") != NULL) if(strcasestr(CF_Hdr->path, "boot.bin") != NULL)
{ {
string GC_Path(CF_Hdr->path); strncpy(GC_Path, CF_Hdr->path, 1023);
GC_Path.erase(GC_Path.end() - 13, GC_Path.end()); *strrchr(GC_Path, '/') = '\0'; //boot.bin
fsop_deleteFolder(GC_Path.c_str()); *strrchr(GC_Path, '/') = '\0'; //sys
fsop_deleteFolder(GC_Path);
} }
else else
{
strncpy(GC_Path, CF_Hdr->path, 1023);
*strrchr(GC_Path, '/') = '\0'; //iso path
const char *cmp = fmt(currentPartition == SD ? DML_DIR : m_DMLgameDir.c_str(), DeviceName[currentPartition]);
if(strcasecmp(GC_Path, cmp) == 0)
fsop_deleteFile(CF_Hdr->path); fsop_deleteFile(CF_Hdr->path);
else
fsop_deleteFolder(GC_Path);
}
upd_dml = true; upd_dml = true;
} }
else if(CF_Hdr->type == TYPE_PLUGIN) else if(CF_Hdr->type == TYPE_PLUGIN)