fixed support for wii elf file loading

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc 2008-07-15 08:38:04 +00:00
parent 8248a8d137
commit 050c472b38
3 changed files with 42 additions and 30 deletions

View File

@ -210,32 +210,34 @@ void CBoot::EmulatedBIOS(bool _bDebug)
// //
bool CBoot::EmulatedBIOS_Wii(bool _bDebug) bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
{ {
if (!VolumeHandler::IsValid())
{
LOG(MASTER_LOG, "Invalid volume");
return false;
}
LOG(BOOT, "Faking Wii BIOS..."); LOG(BOOT, "Faking Wii BIOS...");
// load settings.txt // load settings.txt
{ {
std::string filename; std::string filename("wii/setting-eur.txt");
switch(VolumeHandler::GetVolume()->GetCountry()) if (VolumeHandler::IsValid())
{ {
case DiscIO::IVolume::COUNTRY_JAP: switch(VolumeHandler::GetVolume()->GetCountry())
filename = "wii/setting-jpn.txt"; {
break; case DiscIO::IVolume::COUNTRY_JAP:
filename = "wii/setting-jpn.txt";
break;
case DiscIO::IVolume::COUNTRY_USA: case DiscIO::IVolume::COUNTRY_USA:
filename = "wii/setting-usa.txt"; filename = "wii/setting-usa.txt";
break; break;
default: case DiscIO::IVolume::COUNTRY_EUROPE:
filename = "wii/setting-eur.txt"; filename = "wii/setting-eur.txt";
break; break;
default:
PanicAlert("Unknown country. Wii boot process will be switched to European settings.");
filename = "wii/setting-eur.txt";
break;
}
} }
FILE* pTmp = fopen(filename.c_str(), "rb"); FILE* pTmp = fopen(filename.c_str(), "rb");
if (!pTmp) if (!pTmp)
{ {
@ -249,22 +251,25 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
// int global vars // int global vars
{ {
Memory::Write_U32(0x8179b500, 0x000000f4); // __start
Memory::Write_U32(0x00000000, 0x000030f0); // apploader Memory::Write_U32(0x00000000, 0x000030f0); // apploader
Memory::Write_U16(0x0113, 0x0000315e); // apploader Memory::Write_U16(0x0113, 0x0000315e); // apploader
Memory::Write_U32(0x5d1c9ea3, 0x00000018); // magic word it is a wii disc Memory::Write_U32(0x5d1c9ea3, 0x00000018); // magic word it is a wii disc
Memory::Write_U32(0x01800000, 0x00000028); Memory::Write_U32(0x01800000, 0x00000028);
Memory::Write_U32(0x04000000, 0x00003118); Memory::Write_U32(0x04000000, 0x00003118);
Memory::Write_U32(0x00000023, 0x0000002c); Memory::Write_U32(0x00000023, 0x0000002c);
Memory::Write_U32(0x00000000, 0x000030dc); // OSTime Memory::Write_U32(0x00000000, 0x000030dc); // Time
Memory::Write_U32(0x00000000, 0x000030d8); // OSTime Memory::Write_U32(0x00000000, 0x000030d8); // Time
Memory::Write_U32(0x00000000, 0x0000310c); // OSInit Memory::Write_U32(0x00000000, 0x00000030); // Init
Memory::Write_U32(0x90000800, 0x00003124); // OSInit - MEM2 low Memory::Write_U32(0x00000000, 0x0000310c); // Init
Memory::Write_U32(0x933e0000, 0x00003128); // OSInit - MEM2 high Memory::Write_U32(0x8179d500, 0x00003110); // Init
Memory::Write_U32(0x90000800, 0x00003124); // Init - MEM2 low
Memory::Write_U32(0x933e0000, 0x00003128); // Init - MEM2 high
Memory::Write_U32(0x933e0000, 0x00003130); // IPC MEM2 low Memory::Write_U32(0x933e0000, 0x00003130); // IPC MEM2 low
Memory::Write_U32(0x93400000, 0x00003134); // IPC MEM2 high Memory::Write_U32(0x93400000, 0x00003134); // IPC MEM2 high
Memory::Write_U32(0x38a00040, 0x00000060); // exception init Memory::Write_U32(0x38a00040, 0x00000060); // Exception init
Memory::Write_U16(0x0000, 0x000030e6); // console type Memory::Write_U16(0x0000, 0x000030e6); // Console type
Memory::Write_U32(0x00000011, 0x00003138); // console type Memory::Write_U32(0x00000011, 0x00003138); // Console type
Memory::Write_U32(0x0e7be2c0, 0x000000f8); // EXI Memory::Write_U32(0x0e7be2c0, 0x000000f8); // EXI
Memory::Write_U32(0x00000000, 0x000030c0); // EXI Memory::Write_U32(0x00000000, 0x000030c0); // EXI
Memory::Write_U32(0x00000000, 0x000030c4); // EXI Memory::Write_U32(0x00000000, 0x000030c4); // EXI
@ -279,12 +284,19 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
Memory::Write_U32(0x00000005, 0x000000cc); // VIInit Memory::Write_U32(0x00000005, 0x000000cc); // VIInit
Memory::Write_U16(0x0000, 0x000030e0); // PADInit Memory::Write_U16(0x0000, 0x000030e0); // PADInit
// clear exception handler
for (int i=0x3000; i<=0x3038; i+=4)
{
Memory::Write_U32(0x00000000, i);
}
// app // app
VolumeHandler::ReadToPtr(Memory::GetPointer(0x3180), 0, 4); VolumeHandler::ReadToPtr(Memory::GetPointer(0x3180), 0, 4);
Memory::Write_U8(0x80, 0x00003184); Memory::Write_U8(0x80, 0x00003184);
} }
// apploader // apploader
if (VolumeHandler::IsValid())
{ {
UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr); UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr);
m_MSR.FP = 1; m_MSR.FP = 1;

View File

@ -54,14 +54,15 @@ SPatch OSPatches[] =
// { "THPPlayerGetState", HLE_Misc:THPPlayerGetState }, // { "THPPlayerGetState", HLE_Misc:THPPlayerGetState },
// Debugout is very nice .) // debug out is very nice ;)
{ "OSReport", HLE_OS::HLE_OSReport }, { "OSReport", HLE_OS::HLE_OSReport },
{ "OSPanic", HLE_OS::HLE_OSPanic }, { "OSPanic", HLE_OS::HLE_OSPanic },
{ "vprintf", HLE_OS::HLE_vprintf }, { "vprintf", HLE_OS::HLE_vprintf },
{ "printf", HLE_OS::HLE_printf }, { "printf", HLE_OS::HLE_printf },
// wii only // wii only
{ "SCCheckStatus", HLE_Misc::UnimplementedFunctionFalse }, // SC is SystemConfig ... dunn { "SCCheckStatus", HLE_Misc::UnimplementedFunctionFalse },
{ "__OSInitAudioSystem", HLE_Misc::UnimplementedFunction },
// special // special
// { "GXPeekZ", HLE_Misc::GXPeekZ}, // { "GXPeekZ", HLE_Misc::GXPeekZ},
@ -71,7 +72,6 @@ SPatch OSPatches[] =
SPatch OSBreakPoints[] = SPatch OSBreakPoints[] =
{ {
{ "FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction }, { "FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction },
//{ "__OSInitAudioSystem", CHLE_Audio::__OSInitAudioSystem },
}; };
void PatchFunctions(const char* _gameID) void PatchFunctions(const char* _gameID)

View File

@ -347,7 +347,7 @@ CFrame::OnOpen(wxCommandEvent& WXUNUSED (event))
wxFileSelectorDefaultWildcardStr, wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr wxFileSelectorDefaultWildcardStr
), ),
wxFD_OPEN | wxFD_PREVIEW, wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
this); this);
if (!path) if (!path)