-cleaned up booter code

This commit is contained in:
fix94.1 2012-05-16 15:27:14 +00:00
parent 1f5d72f2a4
commit 1b0f97393f
3 changed files with 17 additions and 42 deletions

View File

@ -44,6 +44,8 @@ u32 vmode_reg = 0;
static u8 Tmd_Buffer[0x49e4 + 0x1C] ALIGNED(32);
extern void __exception_closeall();
entry_point p_entry;
void __Disc_SetLowMem()
{
/* Setup low memory */
@ -351,8 +353,6 @@ s32 Disc_IsGC(void)
s32 Disc_BootPartition()
{
free_wip();
if (hooktype != 0)
ocarina_do_code();
@ -364,15 +364,12 @@ s32 Disc_BootPartition()
/* Shutdown IOS subsystems */
u32 level = IRQ_Disable();
__dsp_shutdown();
__IOS_ShutdownSubsystems();
__exception_closeall();
/* Originally from tueidj - taken from NeoGamma (thx) */
*(vu32*)0xCC003024 = 1;
gprintf("Jumping to entry point\n");
if (hooktype != 0)
{
asm volatile (
@ -403,28 +400,9 @@ s32 Disc_BootPartition()
return 0;
}
s32 Disc_WiiBoot(u32 AppEntryPoint)
void RunApploader(u64 offset, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, int aspectRatio)
{
appentrypoint = AppEntryPoint;
/* Boot partition */
return Disc_BootPartition();
}
u32 RunApploader(u64 offset, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, bool disableIOSreload, int aspectRatio)
{
gprintf("Running Apploader...\n");
entry_point p_entry;
if (disableIOSreload)
IOSReloadBlock(IOS_GetVersion(), false);
else
IOSReloadBlock(IOS_GetVersion(), true);
s32 ret = WDVD_OpenPartition(offset, 0, 0, 0, Tmd_Buffer);
if (ret < 0)
return ret;
WDVD_OpenPartition(offset, 0, 0, 0, Tmd_Buffer);
/* Setup low memory */;
__Disc_SetLowMem();
@ -433,9 +411,7 @@ u32 RunApploader(u64 offset, u8 vidMode, bool vipatch, bool countryString, u8 pa
__Disc_SelectVMode(vidMode, 0);
/* Run apploader */
ret = Apploader_Run(&p_entry, vidMode, vmode, vipatch, countryString, patchVidMode, aspectRatio);
if (ret < 0)
return ret;
Apploader_Run(&p_entry, vidMode, vmode, vipatch, countryString, patchVidMode, aspectRatio);
return (u32)p_entry;
appentrypoint = (u32)p_entry;
}

View File

@ -96,10 +96,9 @@ s32 Disc_Type(bool);
s32 Disc_IsWii(void);
s32 Disc_IsGC(void);
s32 Disc_BootPartition();
s32 Disc_WiiBoot(u32);
s32 Disc_FindPartition(u64 *outbuf);
u32 RunApploader(u64 offset, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, bool disableIOSreload, int aspectRatio);
void RunApploader(u64 offset, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, int aspectRatio);
#ifdef __cplusplus
}

View File

@ -1278,6 +1278,11 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
}
}
if (disableIOSreload)
IOSReloadBlock(IOS_GetVersion(), false);
else
IOSReloadBlock(IOS_GetVersion(), true);
while(net_get_status() == -EBUSY)
usleep(100);
@ -1288,22 +1293,17 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
if(currentPartition == 0)
SDHC_Init();
// clear mem1 main
u32 size = (u32)0x80A00000 - (u32)0x80004000;
memset((void*)0x80004000, 0, size);
DCFlushRange((void*)0x80004000, size);
gprintf("Booting game\n");
usleep(100 * 1000);
/* Find game partition offset */
u64 offset;
Disc_FindPartition(&offset);
u32 AppEntryPoint = RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, disableIOSreload, aspectRatio);
gprintf("\n\nEntry Point is: 0x%08x\n", AppEntryPoint);
RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio);
DeviceHandler::DestroyInstance();
USBStorage_Deinit();
if (Disc_WiiBoot(AppEntryPoint) < 0)
Sys_LoadMenu();
free_wip();
Disc_BootPartition();
}
void CMenu::_initGameMenu(CMenu::SThemeData &theme)
@ -1438,7 +1438,7 @@ void CMenu::_playGameSound(void)
CheckGameSoundThread();
if(!gameSoundThreadStack.get())
gameSoundThreadStack = smartMem2Alloc(gameSoundThreadStackSize);
gameSoundThreadStack = smartMem1Alloc(gameSoundThreadStackSize);
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, gameSoundThreadStack.get(), gameSoundThreadStackSize, 60);
}