mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 02:41:55 +01:00
-forgot to clear gecko sd file buffer on exit, could make problems
-moved this stupid now hide wait message debug print to less annoying place -wiiflow wants the dsp shutdown back, so I'll leave it in -we shouldnt try to alloc mem1 after running apploader, just some good advice before booting a game, should prevent codedumps -sd file buffer can be mem1 too, we have enough left -set mem2 usage to 49mb, thats everything we get anyways -banner sounds should load faster now, also banner sound in emulator coverflow when switching game should work again -forcing check wait thread now on boot, not that the thread is still working without noticing ;)
This commit is contained in:
parent
55f8c0bf95
commit
71064e3f77
@ -68,6 +68,14 @@ static void USBGeckoOutput()
|
||||
devoptab_list[STD_ERR] = &gecko_out;
|
||||
}
|
||||
|
||||
void ClearLogBuffer()
|
||||
{
|
||||
if(tmpfilebuffer == NULL)
|
||||
return;
|
||||
MEM1_free(tmpfilebuffer);
|
||||
tmpfilebuffer = NULL;
|
||||
}
|
||||
|
||||
void WriteToFile(char* tmp)
|
||||
{
|
||||
if(tmpfilebuffer == NULL)
|
||||
@ -80,7 +88,7 @@ void WriteToFile(char* tmp)
|
||||
}
|
||||
else
|
||||
{
|
||||
MEM2_free(tmpfilebuffer);
|
||||
MEM1_free(tmpfilebuffer);
|
||||
tmpfilebuffer = NULL;
|
||||
return;
|
||||
}
|
||||
@ -160,7 +168,7 @@ bool InitGecko()
|
||||
|
||||
USBGeckoOutput();
|
||||
|
||||
tmpfilebuffer = (char*)MEM2_alloc(filebuffer + 1 * sizeof(char));
|
||||
tmpfilebuffer = (char*)MEM1_alloc(filebuffer + 1 * sizeof(char));
|
||||
if(tmpfilebuffer != NULL)
|
||||
memset(tmpfilebuffer, 0, sizeof(tmpfilebuffer));
|
||||
|
||||
|
@ -15,6 +15,7 @@ extern "C" {
|
||||
void gprintf(const char *format, ...);
|
||||
void ghexdump(void *d, int len);
|
||||
bool InitGecko();
|
||||
void ClearLogBuffer();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -547,7 +547,6 @@ void CVideo::_showWaitMessages(CVideo *m)
|
||||
|
||||
void CVideo::hideWaitMessage()
|
||||
{
|
||||
gprintf("Now hide wait message\n");
|
||||
m_showWaitMessage = false;
|
||||
CheckWaitThread();
|
||||
wiiLightOff();
|
||||
@ -558,7 +557,7 @@ void CVideo::CheckWaitThread(bool force)
|
||||
if ((!m_showingWaitMessages && waitThread != LWP_THREAD_NULL) || force)
|
||||
{
|
||||
m_showWaitMessage = false;
|
||||
gprintf("Thread running. Stop it\n");
|
||||
gprintf("Now hide wait message\n");
|
||||
|
||||
if(LWP_ThreadIsSuspended(waitThread))
|
||||
LWP_ResumeThread(waitThread);
|
||||
|
@ -102,12 +102,13 @@ void Sys_ExitTo(int option)
|
||||
|
||||
void Sys_Exit(void)
|
||||
{
|
||||
if(return_to_disable) return;
|
||||
if(return_to_disable)
|
||||
return;
|
||||
|
||||
/* Shutdown Inputs */
|
||||
Close_Inputs();
|
||||
|
||||
if (return_to_menu || return_to_priiloader || priiloader_def)
|
||||
if(return_to_menu || return_to_priiloader || priiloader_def)
|
||||
Sys_LoadMenu();
|
||||
else if(return_to_bootmii)
|
||||
IOS_ReloadIOS(254);
|
||||
@ -129,7 +130,6 @@ void __Sys_PowerCallback(void)
|
||||
shutdown = true;
|
||||
}
|
||||
|
||||
|
||||
void Sys_Init(void)
|
||||
{
|
||||
/* Set RESET/POWER button callback */
|
||||
@ -142,3 +142,23 @@ void Sys_LoadMenu(void)
|
||||
/* Return to the Wii system menu */
|
||||
WII_ReturnToMenu(); //SYS_ResetSystem doesnt work properly with new libogc
|
||||
}
|
||||
|
||||
void __dsp_shutdown(void)
|
||||
{
|
||||
u32 tick;
|
||||
|
||||
_dspReg[5] = (DSPCR_DSPRESET|DSPCR_HALT);
|
||||
_dspReg[27] &= ~0x8000;
|
||||
while(_dspReg[5]&0x400);
|
||||
while(_dspReg[5]&0x200);
|
||||
|
||||
_dspReg[5] = (DSPCR_DSPRESET|DSPCR_DSPINT|DSPCR_ARINT|DSPCR_AIINT|DSPCR_HALT);
|
||||
_dspReg[0] = 0;
|
||||
while((_SHIFTL(_dspReg[2],16,16)|(_dspReg[3]&0xffff))&0x80000000);
|
||||
|
||||
tick = gettick();
|
||||
while((gettick()-tick)<44);
|
||||
|
||||
_dspReg[5] |= DSPCR_RES;
|
||||
while(_dspReg[5]&DSPCR_RES);
|
||||
}
|
||||
|
@ -18,16 +18,28 @@ extern "C" {
|
||||
#define EXIT_TO_DISABLE 4
|
||||
#define EXIT_TO_BOOTMII 5
|
||||
|
||||
/* Prototypes */
|
||||
void Sys_Init(void);
|
||||
void Sys_LoadMenu(void);
|
||||
bool Sys_Exiting(void);
|
||||
void Sys_Test(void);
|
||||
void Sys_Exit(void);
|
||||
void Sys_ExitTo(int);
|
||||
// DSPCR bits
|
||||
#define DSPCR_DSPRESET 0x0800 // Reset DSP
|
||||
#define DSPCR_DSPINT 0x0080 // * interrupt active (RWC)
|
||||
#define DSPCR_ARINT 0x0020
|
||||
#define DSPCR_AIINT 0x0008
|
||||
#define DSPCR_HALT 0x0004 // halt DSP
|
||||
#define DSPCR_RES 0x0001 // reset DSP
|
||||
|
||||
void Open_Inputs(void);
|
||||
void Close_Inputs(void);
|
||||
#define _SHIFTL(v, s, w) \
|
||||
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
|
||||
|
||||
/* Prototypes */
|
||||
void Sys_Init(void);
|
||||
void Sys_LoadMenu(void);
|
||||
bool Sys_Exiting(void);
|
||||
void Sys_Test(void);
|
||||
void Sys_Exit(void);
|
||||
void Sys_ExitTo(int);
|
||||
void __dsp_shutdown(void);
|
||||
|
||||
void Open_Inputs(void);
|
||||
void Close_Inputs(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ int main(int argc, char **argv)
|
||||
CVideo vid;
|
||||
vid.init();
|
||||
|
||||
MEM2_init(52);
|
||||
geckoinit = InitGecko();
|
||||
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
|
||||
MEM2_init(49); //Thats everything we can get anyways
|
||||
vid.waitMessage(0.2f);
|
||||
|
||||
char *gameid = NULL;
|
||||
|
@ -14,6 +14,8 @@ u32 MALLOC_MEM2 = 0;
|
||||
static CMEM2Alloc g_mem1gp;
|
||||
static CMEM2Alloc g_mem2gp;
|
||||
|
||||
bool WrapMEM1 = true;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
@ -60,6 +62,11 @@ void MEM1_free(void *p)
|
||||
g_mem1gp.release(p);
|
||||
}
|
||||
|
||||
void MEM1_wrap(unsigned int enable)
|
||||
{
|
||||
WrapMEM1 = enable;
|
||||
}
|
||||
|
||||
unsigned int MEM1_usableSize(void *p)
|
||||
{
|
||||
return g_mem1gp.usableSize(p);
|
||||
@ -120,7 +127,7 @@ unsigned int MEM2_freesize()
|
||||
void *__wrap_malloc(size_t size)
|
||||
{
|
||||
void *p;
|
||||
if ((SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO) || size >= MEM2_PRIORITY_SIZE)
|
||||
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE || !WrapMEM1)
|
||||
{
|
||||
p = g_mem2gp.allocate(size);
|
||||
if(p != 0)
|
||||
@ -136,7 +143,7 @@ void *__wrap_malloc(size_t size)
|
||||
void *__wrap_calloc(size_t n, size_t size)
|
||||
{
|
||||
void *p;
|
||||
if ((SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO) || (n * size) >= MEM2_PRIORITY_SIZE)
|
||||
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || (n * size) >= MEM2_PRIORITY_SIZE || !WrapMEM1)
|
||||
{
|
||||
p = g_mem2gp.allocate(n * size);
|
||||
if (p != 0)
|
||||
@ -159,20 +166,17 @@ void *__wrap_calloc(size_t n, size_t size)
|
||||
void *__wrap_memalign(size_t a, size_t size)
|
||||
{
|
||||
void *p;
|
||||
if ((SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO) || size >= MEM2_PRIORITY_SIZE)
|
||||
if(SYS_GetArena1Lo() >= MAX_MEM1_ARENA_LO || size >= MEM2_PRIORITY_SIZE || !WrapMEM1)
|
||||
{
|
||||
if (a <= 32 && 32 % a == 0)
|
||||
{
|
||||
p = g_mem2gp.allocate(size);
|
||||
if (p != 0)
|
||||
return p;
|
||||
}
|
||||
p = MEM2_memalign(a, size);
|
||||
if (p != 0)
|
||||
return p;
|
||||
return __real_memalign(a, size);
|
||||
}
|
||||
p = __real_memalign(a, size);
|
||||
if(p != 0)
|
||||
return p;
|
||||
return g_mem2gp.allocate(size);
|
||||
return MEM2_memalign(a, size);
|
||||
}
|
||||
|
||||
void __wrap_free(void *p)
|
||||
@ -180,8 +184,10 @@ void __wrap_free(void *p)
|
||||
if(!p)
|
||||
return;
|
||||
|
||||
if (((u32)p & 0x10000000) != 0)
|
||||
if(((u32)p & 0x10000000) != 0)
|
||||
g_mem2gp.release(p);
|
||||
else if((u32)p < (u32)0x80b00000 && (u32)p >= (u32)0x80003f00)
|
||||
g_mem1gp.release(p);
|
||||
else
|
||||
__real_free(p);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ 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);
|
||||
void MEM1_wrap(unsigned int enable);
|
||||
unsigned int MEM1_usableSize(void *p);
|
||||
unsigned int MEM1_freesize();
|
||||
|
||||
|
@ -25,14 +25,11 @@ public:
|
||||
{
|
||||
switch(m_srcAlloc)
|
||||
{
|
||||
case SRCALL_MEM1:
|
||||
MEM1_free(m_p);
|
||||
break;
|
||||
case SRCALL_MEM2:
|
||||
MEM2_free(m_p);
|
||||
case SRCALL_NEW:
|
||||
delete m_p;
|
||||
break;
|
||||
default:
|
||||
delete m_p;
|
||||
free(m_p);
|
||||
break;
|
||||
}
|
||||
delete m_refcount;
|
||||
|
@ -468,6 +468,7 @@ void CMenu::cleanup(bool ios_reload)
|
||||
{
|
||||
m_cf.stopCoverLoader();
|
||||
m_cf.clear();
|
||||
ClearGameSoundThreadStack();
|
||||
|
||||
m_plugin.Cleanup();
|
||||
|
||||
@ -485,6 +486,7 @@ void CMenu::cleanup(bool ios_reload)
|
||||
DeviceHandler::DestroyInstance();
|
||||
m_vid.cleanup();
|
||||
wiiLightOff();
|
||||
__dsp_shutdown();
|
||||
}
|
||||
|
||||
if (!ios_reload)
|
||||
@ -498,6 +500,8 @@ void CMenu::cleanup(bool ios_reload)
|
||||
|
||||
if (!ios_reload || (!m_use_wifi_gecko && ios_reload))
|
||||
_deinitNetwork();
|
||||
ClearLogBuffer();
|
||||
|
||||
gprintf(" \nMemory cleaned up\n");
|
||||
}
|
||||
|
||||
@ -1749,7 +1753,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting)
|
||||
m_gamesound_changed = false;
|
||||
}
|
||||
else if(!m_gameSelected)
|
||||
m_gameSound.FreeMemory();
|
||||
m_gameSound.Stop();
|
||||
|
||||
CheckThreads();
|
||||
|
||||
|
@ -1092,6 +1092,7 @@ private:
|
||||
|
||||
void _playGameSound(void);
|
||||
void CheckGameSoundThread(void);
|
||||
void ClearGameSoundThreadStack(void);
|
||||
void CheckThreads(void);
|
||||
static void _gameSoundThread(CMenu *m);
|
||||
|
||||
|
@ -382,6 +382,7 @@ void CMenu::_game(bool launch)
|
||||
{
|
||||
m_gameSound.FreeMemory();
|
||||
CheckGameSoundThread();
|
||||
ClearGameSoundThreadStack();
|
||||
break;
|
||||
}
|
||||
else if (BTN_PLUS_PRESSED && m_GameTDBLoaded)
|
||||
@ -1288,7 +1289,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
|
||||
m_vid.CheckWaitThread(true);
|
||||
cleanup();
|
||||
// wifi-gecko can no longer function after cleanup
|
||||
// wifi and sd gecko doesnt work anymore after cleanup
|
||||
Close_Inputs();
|
||||
USBStorage_Deinit();
|
||||
if(currentPartition == 0)
|
||||
@ -1296,6 +1297,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
||||
|
||||
/* Clear Memory */
|
||||
MEM1_clear();
|
||||
MEM1_wrap(0);
|
||||
MEM2_clear();
|
||||
|
||||
/* Find game partition offset */
|
||||
@ -1453,9 +1455,13 @@ void CMenu::CheckGameSoundThread()
|
||||
LWP_ResumeThread(m_gameSoundThread);
|
||||
|
||||
LWP_JoinThread(m_gameSoundThread, NULL);
|
||||
m_gameSoundThread = LWP_THREAD_NULL;
|
||||
}
|
||||
|
||||
void CMenu::ClearGameSoundThreadStack()
|
||||
{
|
||||
if(gameSoundThreadStack.get())
|
||||
gameSoundThreadStack.release();
|
||||
m_gameSoundThread = LWP_THREAD_NULL;
|
||||
}
|
||||
|
||||
void CMenu::CheckThreads()
|
||||
|
@ -263,6 +263,7 @@ int CMenu::main(void)
|
||||
}
|
||||
|
||||
_showMain();
|
||||
m_vid.CheckWaitThread(true);
|
||||
m_curGameId.clear();
|
||||
_initCF();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user