-fixed boot of some wii games like brawl

This commit is contained in:
fix94.1 2012-10-20 15:43:48 +00:00
parent 600437dedf
commit 1fc6250f04
4 changed files with 100 additions and 86 deletions

View File

@ -27,13 +27,28 @@ s32 Disc_Open()
return ret; return ret;
} }
void Disc_SetLowMemPre()
{
/* Setup low memory before Apploader */
*BI2 = 0x817E5480; // BI2
*(vu32*)0xCD00643C = 0x00000000; // 32Mhz on Bus
/* Clear Disc ID */
memset((u8*)Disc_ID, 0, 32);
/* For WiiRD */
memset((void*)0x80001800, 0, 0x1800);
/* Flush everything */
DCFlushRange((void*)0x80000000, 0x3f00);
}
void Disc_SetLowMem(u32 IOS) void Disc_SetLowMem(u32 IOS)
{ {
/* Setup low memory */ /* Setup low memory */
*Sys_Magic = 0x0D15EA5E; // Standard Boot Code *Sys_Magic = 0x0D15EA5E; // Standard Boot Code
*Sys_Version = 0x00000001; // Version *Sys_Version = 0x00000001; // Version
*Arena_L = 0x00000000; // Arena Low *Arena_L = 0x00000000; // Arena Low
*BI2 = 0x817E5480; // BI2
*Bus_Speed = 0x0E7BE2C0; // Console Bus Speed *Bus_Speed = 0x0E7BE2C0; // Console Bus Speed
*CPU_Speed = 0x2B73A840; // Console CPU Speed *CPU_Speed = 0x2B73A840; // Console CPU Speed
*Assembler = 0x38A00040; // Assembler *Assembler = 0x38A00040; // Assembler
@ -41,10 +56,12 @@ void Disc_SetLowMem(u32 IOS)
*Dev_Debugger = 0x81800000; // Dev Debugger Monitor Address *Dev_Debugger = 0x81800000; // Dev Debugger Monitor Address
*Simulated_Mem = 0x01800000; // Simulated Memory Size *Simulated_Mem = 0x01800000; // Simulated Memory Size
*GameID_Address = 0x80000000; // Fix for Sam & Max (WiiPower) *GameID_Address = 0x80000000; // Fix for Sam & Max (WiiPower)
*(vu32*)0xCD00643C = 0x00000000; // 32Mhz on Bus
/* Copy disc ID */ /* Copy Disc ID */
memcpy((void *)Online_Check, (void *)Disc_ID, 4); memcpy((void*)Online_Check, (void*)Disc_ID, 4);
/* For WiiRD */
memcpy((void*)0x80001800, (void*)Disc_ID, 8);
/* Error 002 Fix (thanks WiiPower and uLoader) */ /* Error 002 Fix (thanks WiiPower and uLoader) */
*Current_IOS = (IOS << 16) | 0xffff; *Current_IOS = (IOS << 16) | 0xffff;

View File

@ -9,6 +9,7 @@ extern "C" {
s32 Disc_Open(); s32 Disc_Open();
s32 Disc_FindPartition(u32 *outbuf); s32 Disc_FindPartition(u32 *outbuf);
s32 Disc_SetUSB(const u8 *id, bool frag); s32 Disc_SetUSB(const u8 *id, bool frag);
void Disc_SetLowMemPre();
void Disc_SetLowMem(u32 IOS); void Disc_SetLowMem(u32 IOS);
void Disc_SetTime(); void Disc_SetTime();

View File

@ -140,95 +140,89 @@ void app_pokevalues()
void load_handler() void load_handler()
{ {
if (hooktype != 0x00) if(debuggerselect == 0x01)
{ {
if (debuggerselect == 0x01) //printf("Debbugger selected is gecko\n");
{ memset((void*)0x80001800,0,codehandler_size);
//printf("Debbugger selected is gecko\n"); memcpy((void*)0x80001800,codehandler,codehandler_size);
memset((void*)0x80001800,0,codehandler_size); //if (pausedstartoption == 0x01)
memcpy((void*)0x80001800,codehandler,codehandler_size); // *(u32*)0x80002798 = 1;
//if (pausedstartoption == 0x01) memcpy((void*)0x80001CDE, &codelist, 2);
// *(u32*)0x80002798 = 1; memcpy((void*)0x80001CE2, ((u8*) &codelist) + 2, 2);
memcpy((void*)0x80001CDE, &codelist, 2); memcpy((void*)0x80001F5A, &codelist, 2);
memcpy((void*)0x80001CE2, ((u8*) &codelist) + 2, 2); memcpy((void*)0x80001F5E, ((u8*) &codelist) + 2, 2);
memcpy((void*)0x80001F5A, &codelist, 2); DCFlushRange((void*)0x80001800,codehandler_size);
memcpy((void*)0x80001F5E, ((u8*) &codelist) + 2, 2); ICInvalidateRange((void*)0x80001800,codehandler_size);
DCFlushRange((void*)0x80001800,codehandler_size);
ICInvalidateRange((void*)0x80001000,codehandler_size);
}
else
{
//printf("Debbugger selected is not gecko\n");
memset((void*)0x80001800,0,codehandleronly_size);
memcpy((void*)0x80001800,codehandleronly,codehandleronly_size);
memcpy((void*)0x80001906, &codelist, 2);
memcpy((void*)0x8000190A, ((u8*) &codelist) + 2, 2);
DCFlushRange((void*)0x80001800,codehandleronly_size);
ICInvalidateRange((void*)0x80001000,codehandleronly_size);
}
// Load multidol handler
memset((void*)0x80001000,0,multidol_size);
memcpy((void*)0x80001000,multidol,multidol_size);
DCFlushRange((void*)0x80001000,multidol_size);
ICInvalidateRange((void*)0x80001000,multidol_size);
switch(hooktype)
{
case 0x01:
memcpy((void*)0x8000119C,viwiihooks,12);
memcpy((void*)0x80001198,viwiihooks+3,4);
break;
case 0x02:
memcpy((void*)0x8000119C,kpadhooks,12);
memcpy((void*)0x80001198,kpadhooks+3,4);
break;
case 0x03:
memcpy((void*)0x8000119C,joypadhooks,12);
memcpy((void*)0x80001198,joypadhooks+3,4);
break;
case 0x04:
memcpy((void*)0x8000119C,gxdrawhooks,12);
memcpy((void*)0x80001198,gxdrawhooks+3,4);
break;
case 0x05:
memcpy((void*)0x8000119C,gxflushhooks,12);
memcpy((void*)0x80001198,gxflushhooks+3,4);
break;
case 0x06:
memcpy((void*)0x8000119C,ossleepthreadhooks,12);
memcpy((void*)0x80001198,ossleepthreadhooks+3,4);
break;
case 0x07:
memcpy((void*)0x8000119C,axnextframehooks,12);
memcpy((void*)0x80001198,axnextframehooks+3,4);
break;
case 0x08:
//if (customhooksize == 16)
//{
// memcpy((void*)0x8000119C,customhook,12);
// memcpy((void*)0x80001198,customhook+3,4);
//}
break;
case 0x09:
//memcpy((void*)0x8000119C,wpadbuttonsdownhooks,12);
//memcpy((void*)0x80001198,wpadbuttonsdownhooks+3,4);
break;
case 0x0A:
//memcpy((void*)0x8000119C,wpadbuttonsdown2hooks,12);
//memcpy((void*)0x80001198,wpadbuttonsdown2hooks+3,4);
break;
}
DCFlushRange((void*)0x80001198,16);
} }
else
{
//printf("Debbugger selected is not gecko\n");
memset((void*)0x80001800,0,codehandleronly_size);
memcpy((void*)0x80001800,codehandleronly,codehandleronly_size);
memcpy((void*)0x80001906, &codelist, 2);
memcpy((void*)0x8000190A, ((u8*) &codelist) + 2, 2);
DCFlushRange((void*)0x80001800,codehandleronly_size);
ICInvalidateRange((void*)0x80001800,codehandleronly_size);
}
// Load multidol handler
memset((void*)0x80001000,0,multidol_size);
memcpy((void*)0x80001000,multidol,multidol_size);
DCFlushRange((void*)0x80001000,multidol_size);
ICInvalidateRange((void*)0x80001000,multidol_size);
switch(hooktype)
{
case 0x01:
memcpy((void*)0x8000119C,viwiihooks,12);
memcpy((void*)0x80001198,viwiihooks+3,4);
break;
case 0x02:
memcpy((void*)0x8000119C,kpadhooks,12);
memcpy((void*)0x80001198,kpadhooks+3,4);
break;
case 0x03:
memcpy((void*)0x8000119C,joypadhooks,12);
memcpy((void*)0x80001198,joypadhooks+3,4);
break;
case 0x04:
memcpy((void*)0x8000119C,gxdrawhooks,12);
memcpy((void*)0x80001198,gxdrawhooks+3,4);
break;
case 0x05:
memcpy((void*)0x8000119C,gxflushhooks,12);
memcpy((void*)0x80001198,gxflushhooks+3,4);
break;
case 0x06:
memcpy((void*)0x8000119C,ossleepthreadhooks,12);
memcpy((void*)0x80001198,ossleepthreadhooks+3,4);
break;
case 0x07:
memcpy((void*)0x8000119C,axnextframehooks,12);
memcpy((void*)0x80001198,axnextframehooks+3,4);
break;
case 0x08:
//if (customhooksize == 16)
//{
// memcpy((void*)0x8000119C,customhook,12);
// memcpy((void*)0x80001198,customhook+3,4);
//}
break;
case 0x09:
//memcpy((void*)0x8000119C,wpadbuttonsdownhooks,12);
//memcpy((void*)0x80001198,wpadbuttonsdownhooks+3,4);
break;
case 0x0A:
//memcpy((void*)0x8000119C,wpadbuttonsdown2hooks,12);
//memcpy((void*)0x80001198,wpadbuttonsdown2hooks+3,4);
break;
}
DCFlushRange((void*)0x80001198,16);
} }
int ocarina_do_code() int ocarina_do_code()
{ {
//if (!code_buf) return 0; // Need the handler loaded for hooking other than cheats! //if (!code_buf) return 0; // Need the handler loaded for hooking other than cheats!
memset((void*)0x80001800, 0, 0x1800);
load_handler(); load_handler();
memcpy((void*)0x80001800, (void*)Disc_ID, 8);
DCFlushRange((void*)0x80001800, 0x1800);
if(codelist) if(codelist)
memset(codelist, 0, (u32)codelistend - (u32)codelist); memset(codelist, 0, (u32)codelistend - (u32)codelist);

View File

@ -79,7 +79,9 @@ int main()
} }
prog10(); prog10();
memset((u8*)Disc_ID, 0, 32); /* Setup Low Memory */
Disc_SetLowMemPre();
if(normalCFG.BootType == TYPE_WII_GAME) if(normalCFG.BootType == TYPE_WII_GAME)
{ {
WDVD_Init(); WDVD_Init();