-proper cleanup of video now, no more greenscreens should come

on game booting
-moved partition read buffer on game boot to mem1, faster
This commit is contained in:
fix94.1 2012-05-17 12:47:27 +00:00
parent 0a90ae532e
commit f94e65a54d
6 changed files with 155 additions and 142 deletions

View File

@ -225,19 +225,21 @@ void CVideo::prepare(void)
void CVideo::cleanup(void) void CVideo::cleanup(void)
{ {
gprintf("Cleaning up video...\n"); gprintf("Cleaning up video...\n");
GX_InvVtxCache();
GX_InvalidateTexAll();
VIDEO_ClearFrameBuffer(m_rmode, m_frameBuf[0], COLOR_BLACK); VIDEO_ClearFrameBuffer(m_rmode, m_frameBuf[m_curFB], COLOR_BLACK);
VIDEO_ClearFrameBuffer(m_rmode, m_frameBuf[1], COLOR_BLACK); render();
VIDEO_ClearFrameBuffer(m_rmode, m_frameBuf[m_curFB], COLOR_BLACK);
render();
GX_DrawDone();
GX_AbortFrame();
VIDEO_SetBlack(TRUE);
VIDEO_Flush(); VIDEO_Flush();
VIDEO_WaitVSync(); VIDEO_WaitVSync();
if(m_rmode->viTVMode & VI_NON_INTERLACE) if(m_rmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync(); VIDEO_WaitVSync();
GX_AbortFrame();
GX_Flush();
for(u8 i = 0; i < sizeof m_aaBuffer / sizeof m_aaBuffer[0]; ++i) for(u8 i = 0; i < sizeof m_aaBuffer / sizeof m_aaBuffer[0]; ++i)
{ {
if(m_aaBuffer[i].get()) if(m_aaBuffer[i].get())
@ -248,10 +250,26 @@ void CVideo::cleanup(void)
if(m_defaultWaitMessages[i].data.get()) if(m_defaultWaitMessages[i].data.get())
m_defaultWaitMessages[i].data.release(); m_defaultWaitMessages[i].data.release();
} }
free(MEM_K1_TO_K0(m_frameBuf[0])); if(m_frameBuf[0] != NULL)
free(MEM_K1_TO_K0(m_frameBuf[1])); {
MEM1_free(m_stencil); free(MEM_K1_TO_K0(m_frameBuf[0]));
MEM1_free(m_fifo); m_frameBuf[0] = NULL;
}
if(m_frameBuf[1] != NULL)
{
free(MEM_K1_TO_K0(m_frameBuf[1]));
m_frameBuf[0] = NULL;
}
if(m_stencil != NULL)
{
MEM1_free(m_stencil);
m_stencil = NULL;
}
if(m_fifo != NULL)
{
MEM1_free(m_fifo);
m_fifo = NULL;
}
} }
void CVideo::prepareAAPass(int aaStep) void CVideo::prepareAAPass(int aaStep)

View File

@ -167,13 +167,6 @@ void __Disc_SetVMode(void)
/* Set video mode */ /* Set video mode */
if (disc_vmode != 0) if (disc_vmode != 0)
VIDEO_Configure(disc_vmode); VIDEO_Configure(disc_vmode);
/* Setup video */
VIDEO_SetBlack(TRUE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(disc_vmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync();
} }
void __Disc_SetTime(void) void __Disc_SetTime(void)
@ -187,7 +180,7 @@ s32 Disc_FindPartition(u64 *outbuf)
u64 offset = 0; u64 offset = 0;
u32 cnt; u32 cnt;
u32 *TMP_Buffer = (u32*)MEM2_alloc(0x20); u32 *TMP_Buffer = (u32*)MEM1_alloc(0x20);
if(!TMP_Buffer) if(!TMP_Buffer)
return -1; return -1;
@ -195,7 +188,7 @@ s32 Disc_FindPartition(u64 *outbuf)
s32 ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, PTABLE_OFFSET); s32 ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, PTABLE_OFFSET);
if(ret < 0) if(ret < 0)
{ {
MEM2_free(TMP_Buffer); MEM1_free(TMP_Buffer);
return ret; return ret;
} }
@ -205,7 +198,7 @@ s32 Disc_FindPartition(u64 *outbuf)
if(nb_partitions > 8) if(nb_partitions > 8)
{ {
MEM2_free(TMP_Buffer); MEM1_free(TMP_Buffer);
return -1; return -1;
} }
@ -215,7 +208,7 @@ s32 Disc_FindPartition(u64 *outbuf)
ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, table_offset); ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, table_offset);
if (ret < 0) if (ret < 0)
{ {
MEM2_free(TMP_Buffer); MEM1_free(TMP_Buffer);
return ret; return ret;
} }
@ -228,7 +221,7 @@ s32 Disc_FindPartition(u64 *outbuf)
if(!type) if(!type)
offset = TMP_Buffer[cnt * 2] << 2; offset = TMP_Buffer[cnt * 2] << 2;
} }
MEM2_free(TMP_Buffer); MEM1_free(TMP_Buffer);
/* No game partition found */ /* No game partition found */
if (!offset) if (!offset)

View File

@ -21,9 +21,9 @@ public:
T *get(void) const { return m_p; } T *get(void) const { return m_p; }
virtual void release(void) virtual void release(void)
{ {
if (m_refcount != NULL && --*m_refcount == 0) if (m_p != NULL && m_refcount != NULL && --*m_refcount == 0)
{ {
switch (m_srcAlloc) switch(m_srcAlloc)
{ {
case SRCALL_NEW: case SRCALL_NEW:
delete m_p; delete m_p;

View File

@ -479,13 +479,14 @@ void CMenu::cleanup(bool ios_reload)
MusicPlayer::DestroyInstance(); MusicPlayer::DestroyInstance();
SoundHandler::DestroyInstance(); SoundHandler::DestroyInstance();
soundDeinit(); soundDeinit();
__dsp_shutdown();
DeviceHandler::DestroyInstance();
if(!m_reload) if(!m_reload)
{
DeviceHandler::DestroyInstance();
__dsp_shutdown();
m_vid.cleanup(); m_vid.cleanup();
wiiLightOff(); wiiLightOff();
}
if (!ios_reload) if (!ios_reload)
{ {

View File

@ -1421,7 +1421,8 @@ void CMenu::_gameSoundThread(CMenu *m)
if (soundBin == NULL || (((IMD5Header *)soundBin)->fcc != 'IMD5' && ((IMD5Header *)soundBin)->fcc != 'RIFF')) if (soundBin == NULL || (((IMD5Header *)soundBin)->fcc != 'IMD5' && ((IMD5Header *)soundBin)->fcc != 'RIFF'))
{ {
gprintf("Failed to load banner sound!\n\n"); gprintf("Failed to load banner sound!\n\n");
delete soundBin; if(soundBin != NULL)
delete soundBin;
return; return;
} }

View File

@ -38,17 +38,17 @@ SoundHandler * SoundHandler::instance = NULL;
SoundHandler::SoundHandler() SoundHandler::SoundHandler()
{ {
Decoding = false; Decoding = false;
ExitRequested = false; ExitRequested = false;
for(u32 i = 0; i < MAX_DECODERS; ++i) for(u32 i = 0; i < MAX_DECODERS; ++i)
DecoderList[i] = NULL; DecoderList[i] = NULL;
ThreadStack = (u8 *)MEM1_memalign(32, 32768); ThreadStack = (u8 *)MEM1_memalign(32, 32768);
if(!ThreadStack) if(!ThreadStack)
return; return;
LWP_CreateThread(&SoundThread, UpdateThread, this, ThreadStack, 32768, 80); LWP_CreateThread(&SoundThread, UpdateThread, this, ThreadStack, 32768, 80);
//gprintf("SHND: Running sound thread\n"); gprintf("SHND: Running sound thread\n");
} }
SoundHandler::~SoundHandler() SoundHandler::~SoundHandler()
@ -131,123 +131,123 @@ void SoundHandler::ClearDecoderList()
static inline bool CheckMP3Signature(const u8 * buffer) static inline bool CheckMP3Signature(const u8 * buffer)
{ {
const char MP3_Magic[][3] = const char MP3_Magic[][3] =
{ {
{'I', 'D', '3'}, //'ID3' {'I', 'D', '3'}, //'ID3'
{0xff, 0xfe}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'), {0xff, 0xfe}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xff}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'), {0xff, 0xff}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'),
{0xff, 0xfa}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'), {0xff, 0xfa}, //'MPEG ADTS, layer III, v1.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xfb}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'), {0xff, 0xfb}, //'MPEG ADTS, layer III, v1.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf2}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), {0xff, 0xf2}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf3}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), {0xff, 0xf3}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf4}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), {0xff, 0xf4}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf5}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), {0xff, 0xf5}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xf6}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'), {0xff, 0xf6}, //'MPEG ADTS, layer III, v2.0 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xf7}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'), {0xff, 0xf7}, //'MPEG ADTS, layer III, v2.0', 'mp3', 'audio/mpeg'),
{0xff, 0xe2}, //'MPEG ADTS, layer III, v2.5 [protected]', 'mp3', 'audio/mpeg'), {0xff, 0xe2}, //'MPEG ADTS, layer III, v2.5 [protected]', 'mp3', 'audio/mpeg'),
{0xff, 0xe3}, //'MPEG ADTS, layer III, v2.5', 'mp3', 'audio/mpeg'), {0xff, 0xe3}, //'MPEG ADTS, layer III, v2.5', 'mp3', 'audio/mpeg'),
}; };
if(buffer[0] == MP3_Magic[0][0] && buffer[1] == MP3_Magic[0][1] && if(buffer[0] == MP3_Magic[0][0] && buffer[1] == MP3_Magic[0][1] &&
buffer[2] == MP3_Magic[0][2]) buffer[2] == MP3_Magic[0][2])
{ {
return true; return true;
} }
for(int i = 1; i < 13; i++) for(int i = 1; i < 13; i++)
{ {
if(buffer[0] == MP3_Magic[i][0] && buffer[1] == MP3_Magic[i][1]) if(buffer[0] == MP3_Magic[i][0] && buffer[1] == MP3_Magic[i][1])
return true; return true;
} }
return false; return false;
} }
SoundDecoder * SoundHandler::GetSoundDecoder(const char * filepath) SoundDecoder * SoundHandler::GetSoundDecoder(const char * filepath)
{ {
u32 magic; u32 magic;
CFile f(filepath, "rb"); CFile f(filepath, "rb");
if(f.size() == 0) if(f.size() == 0)
return NULL; return NULL;
do do
{ {
f.read((u8 *) &magic, 1); f.read((u8 *) &magic, 1);
} }
while(((u8 *) &magic)[0] == 0 && f.tell() < f.size()); while(((u8 *) &magic)[0] == 0 && f.tell() < f.size());
if(f.tell() == f.size()) if(f.tell() == f.size())
return NULL; return NULL;
f.seek(f.tell()-1, SEEK_SET); f.seek(f.tell()-1, SEEK_SET);
f.read((u8 *) &magic, 4); f.read((u8 *) &magic, 4);
f.close(); f.close();
/* gprintf("SHND: Searching decoder for magic\n"); /* gprintf("SHND: Searching decoder for magic\n");
ghexdump((u8 *) &magic, 4); */ ghexdump((u8 *) &magic, 4); */
if(magic == 'OggS') if(magic == 'OggS')
{ {
return new OggDecoder(filepath); return new OggDecoder(filepath);
} }
else if(magic == 'RIFF') else if(magic == 'RIFF')
{ {
return new WavDecoder(filepath); return new WavDecoder(filepath);
} }
else if(magic == 'BNS ') else if(magic == 'BNS ')
{ {
return new BNSDecoder(filepath); return new BNSDecoder(filepath);
} }
else if(magic == 'FORM') else if(magic == 'FORM')
{ {
return new AifDecoder(filepath); return new AifDecoder(filepath);
} }
else if(CheckMP3Signature((u8 *) &magic) == true) else if(CheckMP3Signature((u8 *) &magic) == true)
{ {
return new Mp3Decoder(filepath); return new Mp3Decoder(filepath);
} }
return new SoundDecoder(filepath); return new SoundDecoder(filepath);
} }
SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, int length) SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, int length)
{ {
const u8 * check = sound; const u8 * check = sound;
int counter = 0; int counter = 0;
while(check[0] == 0 && counter < length) while(check[0] == 0 && counter < length)
{ {
check++; check++;
counter++; counter++;
} }
if(counter >= length) if(counter >= length)
return NULL; return NULL;
u32 * magic = (u32 *) check; u32 * magic = (u32 *) check;
if(magic[0] == 'OggS') if(magic[0] == 'OggS')
{ {
return new OggDecoder(sound, length); return new OggDecoder(sound, length);
} }
else if(magic[0] == 'RIFF') else if(magic[0] == 'RIFF')
{ {
return new WavDecoder(sound, length); return new WavDecoder(sound, length);
} }
else if(magic[0] == 'BNS ') else if(magic[0] == 'BNS ')
{ {
return new BNSDecoder(sound, length); return new BNSDecoder(sound, length);
} }
else if(magic[0] == 'FORM') else if(magic[0] == 'FORM')
{ {
return new AifDecoder(sound, length); return new AifDecoder(sound, length);
} }
else if(CheckMP3Signature(check) == true) else if(CheckMP3Signature(check) == true)
{ {
return new Mp3Decoder(sound, length); return new Mp3Decoder(sound, length);
} }
return new SoundDecoder(sound, length); return new SoundDecoder(sound, length);
} }
void * SoundHandler::UpdateThread(void *arg) void * SoundHandler::UpdateThread(void *arg)
@ -258,22 +258,22 @@ void * SoundHandler::UpdateThread(void *arg)
void SoundHandler::InternalSoundUpdates() void SoundHandler::InternalSoundUpdates()
{ {
u16 i = 0; u16 i = 0;
LWP_InitQueue(&ThreadQueue); LWP_InitQueue(&ThreadQueue);
while (!ExitRequested) while(!ExitRequested)
{ {
LWP_ThreadSleep(ThreadQueue); LWP_ThreadSleep(ThreadQueue);
for(i = 0; i < MAX_DECODERS; ++i) for(i = 0; i < MAX_DECODERS; ++i)
{ {
if(DecoderList[i] == NULL) if(DecoderList[i] == NULL)
continue; continue;
Decoding = true; Decoding = true;
DecoderList[i]->Decode(); DecoderList[i]->Decode();
} }
Decoding = false; Decoding = false;
} }
LWP_CloseQueue(ThreadQueue); LWP_CloseQueue(ThreadQueue);
ThreadQueue = LWP_TQUEUE_NULL; ThreadQueue = LWP_TQUEUE_NULL;
} }