change references to this strange "bios" thing to BS2 internally, IPL for gui stuff (figured it's easier...) :)

dolphin loads unmodified bootrom dumps now, instead of pre-descrambled ones.
-should we allow loading pre-descrambled dumps still?
yes, segher is a supercomputer!
also make it so we only display the "failed to load fonts" message when they are accessed, like bushing suggested

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4395 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2009-10-11 16:16:18 +00:00
parent 92b0d620b9
commit 480b648ed5
16 changed files with 208 additions and 138 deletions

View File

@ -710,6 +710,14 @@
RelativePath=".\Src\Hw\EXI_DeviceAD16.h" RelativePath=".\Src\Hw\EXI_DeviceAD16.h"
> >
</File> </File>
<File
RelativePath=".\Src\HW\EXI_DeviceAMBaseboard.cpp"
>
</File>
<File
RelativePath=".\Src\HW\EXI_DeviceAMBaseboard.h"
>
</File>
<File <File
RelativePath=".\Src\HW\EXI_DeviceEthernet.cpp" RelativePath=".\Src\HW\EXI_DeviceEthernet.cpp"
> >
@ -782,6 +790,14 @@
RelativePath=".\Src\HW\SI_Device.h" RelativePath=".\Src\HW\SI_Device.h"
> >
</File> </File>
<File
RelativePath=".\Src\HW\SI_DeviceAMBaseboard.cpp"
>
</File>
<File
RelativePath=".\Src\HW\SI_DeviceAMBaseboard.h"
>
</File>
<File <File
RelativePath=".\Src\HW\SI_DeviceGBA.cpp" RelativePath=".\Src\HW\SI_DeviceGBA.cpp"
> >
@ -1976,7 +1992,7 @@
> >
</File> </File>
<File <File
RelativePath=".\Src\Boot\Boot_BIOSEmu.cpp" RelativePath=".\Src\Boot\Boot_BS2Emu.cpp"
> >
</File> </File>
<File <File

View File

@ -136,16 +136,22 @@ bool CBoot::LoadMapFromFilename(const std::string &_rFilename, const char *_game
return success; return success;
} }
// This function does *some* of what BS1 does: loading IPL(BS2) and jumping to it
// It does not initialize the hardware or anything else like BS1 does
// Load a GC or Wii BIOS file // We should eventually just load BS1 and let it take care of everything :)
bool CBoot::Load_BIOS(const std::string& _rBiosFilename) bool CBoot::Load_BS2(const std::string& _rBootROMFilename)
{ {
// Load the whole ROM dump
std::string data; std::string data;
if (!File::ReadFileToString(false, _rBiosFilename.c_str(), data)) if (!File::ReadFileToString(false, _rBootROMFilename.c_str(), data))
return false; return false;
Memory::WriteBigEData((const u8*)data.data() + 0x820, 0x81300000, (int)data.size() - 0x820); // Run the descrambler over the encrypted section containing BS1/BS2
CEXIIPL::Descrambler((u8*)data.data()+0x100, 0x1AFE00);
//File::WriteStringToFile(false, data, "decrypted_bs1_bs2.bin");
//Memory::WriteBigEData((const u8*)data.data() + 0x100, 0x81200000, 0x700);
Memory::WriteBigEData((const u8*)data.data() + 0x820, 0x81300000, 0x1AFE00);
PC = 0x81300000; PC = 0x81300000;
return true; return true;
} }
@ -189,29 +195,28 @@ bool CBoot::BootUp()
DVDInterface::SetDiscInside(VolumeHandler::IsValid()); DVDInterface::SetDiscInside(VolumeHandler::IsValid());
// Use HLE BIOS or not // HLE BS2 or not
if (_StartupPara.bHLEBios) if (_StartupPara.bHLE_BS2)
{ {
if (!VolumeHandler::IsWii()) if (!VolumeHandler::IsWii())
EmulatedBIOS(bDebugIsoBootup); EmulatedBS2(bDebugIsoBootup);
else else
{ {
_StartupPara.bWii = true; _StartupPara.bWii = true;
EmulatedBIOS_Wii(bDebugIsoBootup); EmulatedBS2_Wii(bDebugIsoBootup);
} }
} }
else else
{ {
// If we can't load the BIOS file we use the HLE BIOS instead // If we can't load the bootrom file we HLE it instead
if (!Load_BIOS(_StartupPara.m_strBios)) if (!Load_BS2(_StartupPara.m_strBootROM))
{ {
// fails to load a BIOS so HLE it
if (!VolumeHandler::IsWii()) if (!VolumeHandler::IsWii())
EmulatedBIOS(bDebugIsoBootup); EmulatedBS2(bDebugIsoBootup);
else else
{ {
_StartupPara.bWii = true; _StartupPara.bWii = true;
EmulatedBIOS_Wii(bDebugIsoBootup); EmulatedBS2_Wii(bDebugIsoBootup);
} }
} }
} }
@ -237,19 +242,19 @@ bool CBoot::BootUp()
PanicAlert("Warning - starting DOL in wrong console mode!"); PanicAlert("Warning - starting DOL in wrong console mode!");
} }
// stop apploader from running when BIOS boots // stop apploader from running when the BS2 HLE funcs run
VolumeHandler::SetVolumeName(""); VolumeHandler::SetVolumeName("");
if (dolWii) if (dolWii)
{ {
EmulatedBIOS_Wii(false); EmulatedBS2_Wii(false);
} }
else else
{ {
if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty()) if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
{ {
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str()); VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
EmulatedBIOS(false); EmulatedBS2(false);
} }
} }
@ -282,19 +287,19 @@ bool CBoot::BootUp()
PanicAlert("Warning - starting ELF in wrong console mode!"); PanicAlert("Warning - starting ELF in wrong console mode!");
} }
// stop apploader from running when BIOS boots // stop apploader from running when the BS2 HLE funcs run
VolumeHandler::SetVolumeName(""); VolumeHandler::SetVolumeName("");
if (elfWii) if (elfWii)
{ {
EmulatedBIOS_Wii(false); EmulatedBS2_Wii(false);
} }
else else
{ {
if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty()) if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
{ {
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str()); VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
EmulatedBIOS(false); EmulatedBS2(false);
} }
} }
@ -342,12 +347,12 @@ bool CBoot::BootUp()
break; break;
// BIOS // Bootstrap 2 (AKA: Initial Program Loader, "BIOS")
// =================================================================================== // ===================================================================================
case SCoreStartupParameter::BOOT_BIOS: case SCoreStartupParameter::BOOT_BS2:
{ {
DVDInterface::SetDiscInside(VolumeHandler::IsValid()); DVDInterface::SetDiscInside(VolumeHandler::IsValid());
if (Load_BIOS(_StartupPara.m_strBios)) if (Load_BS2(_StartupPara.m_strBootROM))
{ {
if (LoadMapFromFilename(_StartupPara.m_strFilename)) if (LoadMapFromFilename(_StartupPara.m_strFilename))
HLE::PatchFunctions(); HLE::PatchFunctions();

View File

@ -36,8 +36,6 @@ public:
static bool Install_WiiWAD(const char *filename); static bool Install_WiiWAD(const char *filename);
private: private:
enum { BIOS_SIZE = 2*1024*1024 };
static void RunFunction(u32 _iAddr); static void RunFunction(u32 _iAddr);
static void UpdateDebugger_MapLoaded(const char* _gameID = NULL); static void UpdateDebugger_MapLoaded(const char* _gameID = NULL);
@ -46,9 +44,9 @@ private:
static bool Boot_ELF(const char *filename); static bool Boot_ELF(const char *filename);
static bool Boot_WiiWAD(const char *filename); static bool Boot_WiiWAD(const char *filename);
static void EmulatedBIOS(bool _bDebug); static void EmulatedBS2(bool _bDebug);
static bool EmulatedBIOS_Wii(bool _bDebug); static bool EmulatedBS2_Wii(bool _bDebug);
static bool Load_BIOS(const std::string& _rBiosFilename); static bool Load_BS2(const std::string& _rBootROMFilename);
static void Load_FST(bool _bIsWii); static void Load_FST(bool _bIsWii);
static bool SetupWiiMemory(unsigned int _CountryCode); static bool SetupWiiMemory(unsigned int _CountryCode);

View File

@ -44,13 +44,12 @@ void CBoot::RunFunction(u32 _iAddr)
} }
// __________________________________________________________________________________________________ // __________________________________________________________________________________________________
// // GameCube Bootstrap 2 HLE:
// GameCube BIOS HLE:
// copy the apploader to 0x81200000 // copy the apploader to 0x81200000
// execute the apploader, function by function, using the above utility. // execute the apploader, function by function, using the above utility.
void CBoot::EmulatedBIOS(bool _bDebug) void CBoot::EmulatedBS2(bool _bDebug)
{ {
INFO_LOG(BOOT, "Faking GC BIOS..."); INFO_LOG(BOOT, "Faking GC BS2...");
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;
@ -153,14 +152,14 @@ void CBoot::EmulatedBIOS(bool _bDebug)
// return // return
PC = PowerPC::ppcState.gpr[3]; PC = PowerPC::ppcState.gpr[3];
// --- preinit some stuff from bios --- // --- preinit some stuff from IPL ---
// Bus Clock Speed // Bus Clock Speed
Memory::Write_U32(0x09a7ec80, 0x800000F8); Memory::Write_U32(0x09a7ec80, 0x800000F8);
// CPU Clock Speed // CPU Clock Speed
Memory::Write_U32(0x1cf7c580, 0x800000FC); Memory::Write_U32(0x1cf7c580, 0x800000FC);
// fake the VI Init of the BIOS // fake the VI Init of the IPL
Memory::Write_U32(SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC Memory::Write_U32(SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC
? 0 : 1, 0x800000CC); ? 0 : 1, 0x800000CC);
@ -277,7 +276,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
Memory::Write_U16(0x0000, 0x000030e0); // PADInit Memory::Write_U16(0x0000, 0x000030e0); // PADInit
Memory::Write_U32(0x80000000, 0x00003184); // GameID Address Memory::Write_U32(0x80000000, 0x00003184); // GameID Address
// Fake the VI Init of the BIOS // Fake the VI Init of the IPL
Memory::Write_U32(SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC ? 0 : 1, 0x000000CC); Memory::Write_U32(SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC ? 0 : 1, 0x000000CC);
// Clear exception handler. Why? Don't we begin with only zeros? // Clear exception handler. Why? Don't we begin with only zeros?
@ -289,14 +288,12 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
} }
// __________________________________________________________________________________________________ // __________________________________________________________________________________________________
// // Wii Bootstrap 2 HLE:
// Wii BIOS HLE:
// copy the apploader to 0x81200000 // copy the apploader to 0x81200000
// execute the apploader // execute the apploader
// bool CBoot::EmulatedBS2_Wii(bool _bDebug)
bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
{ {
INFO_LOG(BOOT, "Faking Wii BIOS..."); INFO_LOG(BOOT, "Faking Wii BS2...");
// setup wii memory // setup wii memory
DiscIO::IVolume::ECountry CountryCode = DiscIO::IVolume::COUNTRY_UNKNOWN; DiscIO::IVolume::ECountry CountryCode = DiscIO::IVolume::COUNTRY_UNKNOWN;

View File

@ -96,7 +96,7 @@ void SConfig::SaveSettings()
ini.Set("GameList", "ListUsa", m_ListUsa); ini.Set("GameList", "ListUsa", m_ListUsa);
// Core // Core
ini.Set("Core", "HLEBios", m_LocalCoreStartupParameter.bHLEBios); ini.Set("Core", "HLE_BS2", m_LocalCoreStartupParameter.bHLE_BS2);
ini.Set("Core", "UseDynarec", m_LocalCoreStartupParameter.bUseJIT); ini.Set("Core", "UseDynarec", m_LocalCoreStartupParameter.bUseJIT);
ini.Set("Core", "UseDualCore", m_LocalCoreStartupParameter.bUseDualCore); ini.Set("Core", "UseDualCore", m_LocalCoreStartupParameter.bUseDualCore);
ini.Set("Core", "DSPThread", m_LocalCoreStartupParameter.bDSPThread); ini.Set("Core", "DSPThread", m_LocalCoreStartupParameter.bDSPThread);
@ -208,7 +208,7 @@ void SConfig::LoadSettings()
ini.Get("GameList", "ListUsa", &m_ListUsa, true); ini.Get("GameList", "ListUsa", &m_ListUsa, true);
// Core // Core
ini.Get("Core", "HLEBios", &m_LocalCoreStartupParameter.bHLEBios, true); ini.Get("Core", "HLE_BS2", &m_LocalCoreStartupParameter.bHLE_BS2, true);
ini.Get("Core", "UseDynarec", &m_LocalCoreStartupParameter.bUseJIT, true); ini.Get("Core", "UseDynarec", &m_LocalCoreStartupParameter.bUseJIT, true);
ini.Get("Core", "DSPThread", &m_LocalCoreStartupParameter.bDSPThread, true); ini.Get("Core", "DSPThread", &m_LocalCoreStartupParameter.bDSPThread, true);
ini.Get("Core", "UseDualCore", &m_LocalCoreStartupParameter.bUseDualCore, false); ini.Get("Core", "UseDualCore", &m_LocalCoreStartupParameter.bUseDualCore, false);

View File

@ -61,11 +61,11 @@ void SCoreStartupParameter::LoadDefaults()
m_strUniqueID = "00000000"; m_strUniqueID = "00000000";
} }
bool SCoreStartupParameter::AutoSetup(EBootBios _BootBios) bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
{ {
std::string Region(EUR_DIR); std::string Region(EUR_DIR);
switch (_BootBios) switch (_BootBS2)
{ {
case BOOT_DEFAULT: case BOOT_DEFAULT:
{ {
@ -191,19 +191,19 @@ bool SCoreStartupParameter::AutoSetup(EBootBios _BootBios)
} }
break; break;
case BOOT_BIOS_USA: case BOOT_BS2_USA:
Region = USA_DIR; Region = USA_DIR;
m_strFilename.clear(); m_strFilename.clear();
bNTSC = true; bNTSC = true;
break; break;
case BOOT_BIOS_JAP: case BOOT_BS2_JAP:
Region = JAP_DIR; Region = JAP_DIR;
m_strFilename.clear(); m_strFilename.clear();
bNTSC = true; bNTSC = true;
break; break;
case BOOT_BIOS_EUR: case BOOT_BS2_EUR:
Region = EUR_DIR; Region = EUR_DIR;
m_strFilename.clear(); m_strFilename.clear();
bNTSC = false; bNTSC = false;
@ -216,20 +216,20 @@ bool SCoreStartupParameter::AutoSetup(EBootBios _BootBios)
m_strSRAM = GC_SRAM_FILE; m_strSRAM = GC_SRAM_FILE;
if (!bWii) if (!bWii)
{ {
m_strBios = File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + Region + DIR_SEP GC_IPL; m_strBootROM = File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + Region + DIR_SEP GC_IPL;
if (!bHLEBios) if (!bHLE_BS2)
{ {
if (!File::Exists(m_strBios.c_str())) if (!File::Exists(m_strBootROM.c_str()))
{ {
WARN_LOG(BOOT, "BIOS file %s not found - using HLE.", m_strBios.c_str()); WARN_LOG(BOOT, "bootrom file %s not found - using HLE.", m_strBootROM.c_str());
bHLEBios = true; bHLE_BS2 = true;
} }
} }
} }
else if (bWii && !bHLEBios) else if (bWii && !bHLE_BS2)
{ {
WARN_LOG(BOOT, "GC BIOS file will not be loaded for Wii mode."); WARN_LOG(BOOT, "GC bootrom file will not be loaded for Wii mode.");
bHLEBios = true; bHLE_BS2 = true;
} }
return true; return true;

View File

@ -60,7 +60,7 @@ struct SCoreStartupParameter
bool bDSPThread; bool bDSPThread;
bool bSkipIdle; bool bSkipIdle;
bool bNTSC; bool bNTSC;
bool bHLEBios; bool bHLE_BS2;
bool bUseFastMem; bool bUseFastMem;
bool bLockThreads; bool bLockThreads;
bool bOptimizeQuantizers; bool bOptimizeQuantizers;
@ -81,12 +81,12 @@ struct SCoreStartupParameter
bool bConfirmStop, bHideCursor, bAutoHideCursor, bUsePanicHandlers; bool bConfirmStop, bHideCursor, bAutoHideCursor, bUsePanicHandlers;
int iTheme; int iTheme;
enum EBootBios enum EBootBS2
{ {
BOOT_DEFAULT, BOOT_DEFAULT,
BOOT_BIOS_JAP, BOOT_BS2_JAP,
BOOT_BIOS_USA, BOOT_BS2_USA,
BOOT_BIOS_EUR, BOOT_BS2_EUR,
}; };
enum EBootType enum EBootType
@ -95,7 +95,7 @@ struct SCoreStartupParameter
BOOT_ELF, BOOT_ELF,
BOOT_DOL, BOOT_DOL,
BOOT_WII_NAND, BOOT_WII_NAND,
BOOT_BIOS BOOT_BS2
}; };
EBootType m_BootType; EBootType m_BootType;
@ -106,7 +106,7 @@ struct SCoreStartupParameter
std::string m_strWiimotePlugin[MAXWIIMOTES]; std::string m_strWiimotePlugin[MAXWIIMOTES];
std::string m_strFilename; std::string m_strFilename;
std::string m_strBios; std::string m_strBootROM;
std::string m_strSRAM; std::string m_strSRAM;
std::string m_strDefaultGCM; std::string m_strDefaultGCM;
std::string m_strDVDRoot; std::string m_strDVDRoot;
@ -118,7 +118,7 @@ struct SCoreStartupParameter
SCoreStartupParameter(); SCoreStartupParameter();
void LoadDefaults(); void LoadDefaults();
bool AutoSetup(EBootBios _BootBios); bool AutoSetup(EBootBS2 _BootBS2);
const std::string &GetUniqueID() const { return m_strUniqueID; } const std::string &GetUniqueID() const { return m_strUniqueID; }
void CheckMemcardPath(std::string& memcardPath, std::string Region, bool isSlotA); void CheckMemcardPath(std::string& memcardPath, std::string Region, bool isSlotA);
}; };

View File

@ -58,12 +58,64 @@ static const char iplverPAL[0x100] = "(C) 1999-2001 Nintendo. All rights reserv
static const char iplverNTSC[0x100] = "(C) 1999-2001 Nintendo. All rights reserved." static const char iplverNTSC[0x100] = "(C) 1999-2001 Nintendo. All rights reserved."
"(C) 1999 ArtX Inc. All rights reserved."; "(C) 1999 ArtX Inc. All rights reserved.";
// segher is a supercomputer
void CEXIIPL::Descrambler(u8* data, u32 size)
{
u8 acc = 0;
u8 nacc = 0;
u16 t = 0x2953;
u16 u = 0xd9c2;
u16 v = 0x3ff1;
u8 x = 1;
for (u32 it = 0; it < size;)
{
int t0 = t & 1;
int t1 = (t >> 1) & 1;
int u0 = u & 1;
int u1 = (u >> 1) & 1;
int v0 = v & 1;
x ^= t1 ^ v0;
x ^= (u0 | u1);
x ^= (t0 ^ u1 ^ v0) & (t0 ^ u0);
if (t0 == u0)
{
v >>= 1;
if (v0)
v ^= 0xb3d0;
}
if (t0 == 0)
{
u >>= 1;
if (u0)
u ^= 0xfb10;
}
t >>= 1;
if (t0)
t ^= 0xa740;
nacc++;
acc = 2*acc + x;
if (nacc == 8)
{
data[it++] ^= acc;
nacc = 0;
}
}
}
CEXIIPL::CEXIIPL() : CEXIIPL::CEXIIPL() :
m_uPosition(0), m_uPosition(0),
m_uAddress(0), m_uAddress(0),
m_uRWOffset(0), m_uRWOffset(0),
m_count(0) m_count(0),
m_FontsLoaded(false)
{ {
// Determine region // Determine region
m_bNTSC = SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC; m_bNTSC = SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC;
@ -71,12 +123,24 @@ CEXIIPL::CEXIIPL() :
// Create the IPL // Create the IPL
m_pIPL = (u8*)AllocateMemoryPages(ROM_SIZE); m_pIPL = (u8*)AllocateMemoryPages(ROM_SIZE);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHLE_BS2)
{
// Copy header // Copy header
memcpy(m_pIPL, m_bNTSC ? iplverNTSC : iplverPAL, sizeof(m_bNTSC ? iplverNTSC : iplverPAL)); memcpy(m_pIPL, m_bNTSC ? iplverNTSC : iplverPAL, sizeof(m_bNTSC ? iplverNTSC : iplverPAL));
// Load fonts // Load fonts
LoadFileToIPL((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_SJIS).c_str(), 0x001aff00); LoadFileToIPL((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_SJIS), 0x1aff00);
LoadFileToIPL((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_ANSI).c_str(), 0x001fcf00); LoadFileToIPL((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + FONT_ANSI), 0x1fcf00);
}
else
{
m_FontsLoaded = true;
// Load whole ROM dump
LoadFileToIPL(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strBootROM, 0);
// Descramble the encrypted section (contains BS1 and BS2)
Descrambler(m_pIPL + 0x100, 0x1aff00);
INFO_LOG(BOOT, "Loaded bootrom: %s", m_pIPL); // yay for null-terminated strings ;p
}
// Clear RTC // Clear RTC
memset(m_RTC, 0, sizeof(m_RTC)); memset(m_RTC, 0, sizeof(m_RTC));
@ -92,7 +156,7 @@ CEXIIPL::CEXIIPL() :
{ {
m_SRAM = sram_dump; m_SRAM = sram_dump;
} }
// We Overwrite it here since it's possible on the GC to change the language as you please // We Overwrite language selection here since it's possible on the GC to change the language as you please
m_SRAM.syssram.lang = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage; m_SRAM.syssram.lang = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
WriteProtectMemory(m_pIPL, ROM_SIZE); WriteProtectMemory(m_pIPL, ROM_SIZE);
@ -122,15 +186,12 @@ CEXIIPL::~CEXIIPL()
} }
void CEXIIPL::DoState(PointerWrap &p) void CEXIIPL::DoState(PointerWrap &p)
{ {
// commented out to not break current savestates p.DoArray(m_RTC, 4);
// TODO: uncomment when adding the next savestate change
//p.DoArray(m_RTC, 4);
} }
void CEXIIPL::LoadFileToIPL(const char* filename, u32 offset) void CEXIIPL::LoadFileToIPL(std::string filename, u32 offset)
{ {
FILE* pStream = NULL; FILE* pStream = fopen(filename.c_str(), "rb");
pStream = fopen(filename, "rb");
if (pStream != NULL) if (pStream != NULL)
{ {
fseek(pStream, 0, SEEK_END); fseek(pStream, 0, SEEK_END);
@ -139,13 +200,8 @@ void CEXIIPL::LoadFileToIPL(const char* filename, u32 offset)
fread(m_pIPL + offset, 1, filesize, pStream); fread(m_pIPL + offset, 1, filesize, pStream);
fclose(pStream); fclose(pStream);
}
else m_FontsLoaded = true;
{
// This is a poor way to handle failure. We should either not display this message unless fonts
// are actually accessed, or better yet, emulate them using a system font. -bushing
PanicAlert("Error: failed to load %s. Fonts in a few games may not work, or crash the game.",
filename);
} }
} }
@ -229,31 +285,26 @@ void CEXIIPL::TransferByte(u8& _uByte)
} }
else else
{ {
// // --- Encrypted ROM ---
// --- ROM --- // atm we pre-decrypt the whole thing, see CEXIIPL ctor
//
if ((m_uAddress & 0x60000000) == 0) if ((m_uAddress & 0x60000000) == 0)
{ {
if ((m_uAddress & 0x80000000) == 0) if ((m_uAddress & 0x80000000) == 0)
_uByte = m_pIPL[((m_uAddress >> 6) & ROM_MASK) + m_uRWOffset]; {
#if 0
u32 position = ((m_uAddress >> 6) & ROM_MASK) + m_uRWOffset; u32 position = ((m_uAddress >> 6) & ROM_MASK) + m_uRWOffset;
char msg[5] = "";
if (position >= 0 && position < 0x100) // Technically we should apply descrambling here, if it's currently enabled.
sprintf(msg, "COPY"); _uByte = m_pIPL[position];
else if (position >= 0x00000100 && position <= 0x001aeee8)
sprintf(msg, "BIOS"); if ((position >= 0x001AFF00) && (position <= 0x001FF474) && !m_FontsLoaded)
else if (position >= 0x001AFF00 && position <= 0x001FA0E0) {
sprintf(msg, "SJIS"); PanicAlert("Error: Trying to access %s fonts but they are not loaded. Games may not show fonts correctly, or crash.",
else if (position >= 0x001FCF00 && position <= 0x001FF474) (position >= 0x001FCF00)?"ANSI":"SJIS");
sprintf(msg, "ANSI"); m_FontsLoaded = true; // Don't be a nag :p
WARN_LOG(EXPANSIONINTERFACE, "m_pIPL[0x%08x] = 0x%02x %s\t0x%08x 0x%08x 0x%08x", }
position, _uByte, msg, m_uPosition,m_uAddress,m_uRWOffset); }
#endif
} }
//
// --- Real Time Clock (RTC) --- // --- Real Time Clock (RTC) ---
//
else if ((m_uAddress & 0x7FFFFF00) == 0x20000000) else if ((m_uAddress & 0x7FFFFF00) == 0x20000000)
{ {
if (m_uAddress & 0x80000000) if (m_uAddress & 0x80000000)
@ -261,9 +312,7 @@ void CEXIIPL::TransferByte(u8& _uByte)
else else
_uByte = m_RTC[(m_uAddress & 0x03) + m_uRWOffset]; _uByte = m_RTC[(m_uAddress & 0x03) + m_uRWOffset];
} }
//
// --- SRAM --- // --- SRAM ---
//
else if ((m_uAddress & 0x7FFFFF00) == 0x20000100) else if ((m_uAddress & 0x7FFFFF00) == 0x20000100)
{ {
if (m_uAddress & 0x80000000) if (m_uAddress & 0x80000000)
@ -271,9 +320,7 @@ void CEXIIPL::TransferByte(u8& _uByte)
else else
_uByte = m_SRAM.p_SRAM[(m_uAddress & 0x3F) + m_uRWOffset]; _uByte = m_SRAM.p_SRAM[(m_uAddress & 0x3F) + m_uRWOffset];
} }
//
// --- UART --- // --- UART ---
//
else if ((m_uAddress & 0x7FFFFF00) == 0x20010000) else if ((m_uAddress & 0x7FFFFF00) == 0x20010000)
{ {
if (m_uAddress & 0x80000000) if (m_uAddress & 0x80000000)

View File

@ -26,13 +26,15 @@ class CEXIIPL : public IEXIDevice
public: public:
CEXIIPL(); CEXIIPL();
virtual ~CEXIIPL(); virtual ~CEXIIPL();
virtual void SetCS(int _iCS); virtual void SetCS(int _iCS);
bool IsPresent(); bool IsPresent();
static u32 GetGCTime();
void DoState(PointerWrap &p); void DoState(PointerWrap &p);
private: static u32 GetGCTime();
static void Descrambler(u8* data, u32 size);
private:
enum enum
{ {
ROM_SIZE = 1024*1024*2, ROM_SIZE = 1024*1024*2,
@ -59,10 +61,11 @@ private:
char m_szBuffer[256]; char m_szBuffer[256];
int m_count; int m_count;
bool m_FontsLoaded;
virtual void TransferByte(u8 &_uByte); virtual void TransferByte(u8 &_uByte);
void LoadFileToIPL(const char* filename, u32 offset); void LoadFileToIPL(std::string filename, u32 offset);
}; };
#endif #endif

View File

@ -36,9 +36,10 @@ enum
PI_FIFO_BASE = 0x0C, PI_FIFO_BASE = 0x0C,
PI_FIFO_END = 0x10, PI_FIFO_END = 0x10,
PI_FIFO_WPTR = 0x14, PI_FIFO_WPTR = 0x14,
PI_FIFO_RESET = 0x18, // ??? - GXAbortFrameWrites to it PI_FIFO_RESET = 0x18, // ??? - GXAbortFrame writes to it
PI_RESET_CODE = 0x24, PI_RESET_CODE = 0x24,
PI_MB_REV = 0x2C, PI_MB_REV = 0x2C,
PI_UNKNOWN = 0x30 // ??? - BS1 writes to it
}; };
@ -49,9 +50,11 @@ volatile u32 m_InterruptMask;
u32 Fifo_CPUBase; u32 Fifo_CPUBase;
u32 Fifo_CPUEnd; u32 Fifo_CPUEnd;
u32 Fifo_CPUWritePointer; u32 Fifo_CPUWritePointer;
u32 m_Fifo_Reset; u32 m_Fifo_Reset;
u32 m_ResetCode; u32 m_ResetCode;
u32 m_MBRev; u32 m_MBRev;
u32 m_Unknown;
// ID and callback for scheduling reset button presses/releases // ID and callback for scheduling reset button presses/releases
@ -69,10 +72,10 @@ void DoState(PointerWrap &p)
p.Do(Fifo_CPUBase); p.Do(Fifo_CPUBase);
p.Do(Fifo_CPUEnd); p.Do(Fifo_CPUEnd);
p.Do(Fifo_CPUWritePointer); p.Do(Fifo_CPUWritePointer);
// (shuffle2) Enable sometime ;p p.Do(m_Fifo_Reset);
// p.Do(m_Fifo_Reset); p.Do(m_ResetCode);
// p.Do(m_ResetCode); p.Do(m_MBRev);
// p.Do(m_MBRev); p.Do(m_Unknown);
} }
void Init() void Init()
@ -85,6 +88,7 @@ void Init()
Fifo_CPUWritePointer = 0; Fifo_CPUWritePointer = 0;
m_MBRev = 2 << 28; // HW2 production board m_MBRev = 2 << 28; // HW2 production board
m_Unknown = 0;
// Bleh, why? // Bleh, why?
//m_ResetCode |= 0x80000000; //m_ResetCode |= 0x80000000;

View File

@ -22,7 +22,7 @@ class PointerWrap;
namespace VideoInterface namespace VideoInterface
{ {
// For BIOS HLE // For BS2 HLE
void PreInit(bool _bNTSC); void PreInit(bool _bNTSC);
void SetRegionReg(char _region); void SetRegionReg(char _region);

View File

@ -20,7 +20,7 @@ files = ["ActionReplay.cpp",
"Tracer.cpp", "Tracer.cpp",
"VolumeHandler.cpp", "VolumeHandler.cpp",
"Boot/Boot.cpp", "Boot/Boot.cpp",
"Boot/Boot_BIOSEmu.cpp", "Boot/Boot_BS2Emu.cpp",
"Boot/Boot_DOL.cpp", "Boot/Boot_DOL.cpp",
"Boot/Boot_ELF.cpp", "Boot/Boot_ELF.cpp",
"Boot/Boot_WiiWAD.cpp", "Boot/Boot_WiiWAD.cpp",

View File

@ -31,7 +31,7 @@
Core Core.cpp Init Thread creation Core Core.cpp Init Thread creation
EmuThread Calls CBoot::BootUp EmuThread Calls CBoot::BootUp
Boot.cpp CBoot::BootUp() Boot.cpp CBoot::BootUp()
CBoot::EmulatedBIOS_Wii() / GC() or Load_BIOS() CBoot::EmulatedBS2_Wii() / GC() or Load_BS2()
*/ */
// ============= // =============

View File

@ -47,7 +47,7 @@ EVT_CHECKBOX(ID_INTERFACE_WIIMOTE_LEDS, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_INTERFACE_WIIMOTE_SPEAKERS, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_INTERFACE_WIIMOTE_SPEAKERS, CConfigMain::CoreSettingsChanged)
EVT_CHOICE(ID_INTERFACE_LANG, CConfigMain::CoreSettingsChanged) EVT_CHOICE(ID_INTERFACE_LANG, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_ALLWAYS_HLEBIOS, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_ALLWAYS_HLE_BS2, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_USEDYNAREC, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_USEDYNAREC, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_USEDUALCORE, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_USEDUALCORE, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_DSPTHREAD, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_DSPTHREAD, CConfigMain::CoreSettingsChanged)
@ -119,7 +119,7 @@ void CConfigMain::UpdateGUI()
if(Core::GetState() != Core::CORE_UNINITIALIZED) if(Core::GetState() != Core::CORE_UNINITIALIZED)
{ {
// Disable the Core stuff on GeneralPage // Disable the Core stuff on GeneralPage
AlwaysUseHLEBIOS->Disable(); AlwaysHLE_BS2->Disable();
UseDynaRec->Disable(); UseDynaRec->Disable();
UseDualCore->Disable(); UseDualCore->Disable();
DSPThread->Disable(); DSPThread->Disable();
@ -206,8 +206,8 @@ void CConfigMain::CreateGUIControls()
Framelimit->SetSelection(SConfig::GetInstance().m_Framelimit); Framelimit->SetSelection(SConfig::GetInstance().m_Framelimit);
// Core Settings - Advanced // Core Settings - Advanced
AlwaysUseHLEBIOS = new wxCheckBox(GeneralPage, ID_ALLWAYS_HLEBIOS, wxT("HLE the BIOS all the time"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); AlwaysHLE_BS2 = new wxCheckBox(GeneralPage, ID_ALLWAYS_HLE_BS2, wxT("Always HLE the IPL"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
AlwaysUseHLEBIOS->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bHLEBios); AlwaysHLE_BS2->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bHLE_BS2);
UseDynaRec = new wxCheckBox(GeneralPage, ID_USEDYNAREC, wxT("Enable the JIT dynarec"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); UseDynaRec = new wxCheckBox(GeneralPage, ID_USEDYNAREC, wxT("Enable the JIT dynarec"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
UseDynaRec->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bUseJIT); UseDynaRec->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bUseJIT);
LockThreads = new wxCheckBox(GeneralPage, ID_LOCKTHREADS, wxT("Lock threads to cores"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); LockThreads = new wxCheckBox(GeneralPage, ID_LOCKTHREADS, wxT("Lock threads to cores"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@ -296,7 +296,7 @@ void CConfigMain::CreateGUIControls()
sbBasic->Add(sFramelimit, 0, wxALL | wxEXPAND, 5); sbBasic->Add(sFramelimit, 0, wxALL | wxEXPAND, 5);
sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Advanced Settings")); sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Advanced Settings"));
sbAdvanced->Add(AlwaysUseHLEBIOS, 0, wxALL, 5); sbAdvanced->Add(AlwaysHLE_BS2, 0, wxALL, 5);
sbAdvanced->Add(UseDynaRec, 0, wxALL, 5); sbAdvanced->Add(UseDynaRec, 0, wxALL, 5);
sbAdvanced->Add(LockThreads, 0, wxALL, 5); sbAdvanced->Add(LockThreads, 0, wxALL, 5);
sbAdvanced->Add(OptimizeQuantizers, 0, wxALL, 5); sbAdvanced->Add(OptimizeQuantizers, 0, wxALL, 5);
@ -630,8 +630,8 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event)
case ID_FRAMELIMIT: case ID_FRAMELIMIT:
SConfig::GetInstance().m_Framelimit = (u32)Framelimit->GetSelection(); SConfig::GetInstance().m_Framelimit = (u32)Framelimit->GetSelection();
break; break;
case ID_ALLWAYS_HLEBIOS: // Core case ID_ALLWAYS_HLE_BS2: // Core
SConfig::GetInstance().m_LocalCoreStartupParameter.bHLEBios = AlwaysUseHLEBIOS->IsChecked(); SConfig::GetInstance().m_LocalCoreStartupParameter.bHLE_BS2 = AlwaysHLE_BS2->IsChecked();
break; break;
case ID_USEDYNAREC: case ID_USEDYNAREC:
SConfig::GetInstance().m_LocalCoreStartupParameter.bUseJIT = UseDynaRec->IsChecked(); SConfig::GetInstance().m_LocalCoreStartupParameter.bUseJIT = UseDynaRec->IsChecked();

View File

@ -62,7 +62,7 @@ private:
wxBoxSizer* sCore; wxBoxSizer* sCore;
wxStaticBoxSizer* sbBasic, *sbAdvanced, *sbInterface; wxStaticBoxSizer* sbBasic, *sbAdvanced, *sbInterface;
wxCheckBox* AlwaysUseHLEBIOS; wxCheckBox* AlwaysHLE_BS2;
wxCheckBox* UseDynaRec; wxCheckBox* UseDynaRec;
wxCheckBox* UseDualCore; wxCheckBox* UseDualCore;
wxCheckBox* DSPThread; wxCheckBox* DSPThread;
@ -153,7 +153,7 @@ private:
ID_PATHSPAGE, ID_PATHSPAGE,
ID_PLUGINPAGE, ID_PLUGINPAGE,
ID_ALLWAYS_HLEBIOS, ID_ALLWAYS_HLE_BS2,
ID_USEDYNAREC, ID_USEDYNAREC,
ID_USEDUALCORE, ID_USEDUALCORE,
ID_DSPTHREAD, ID_DSPTHREAD,

View File

@ -51,7 +51,7 @@ std::string Summarize_Settings()
{ {
return StringFromFormat( return StringFromFormat(
"Dolphin Settings\n\n" "Dolphin Settings\n\n"
"Always HLE Bios: %s\n" "HLE the IPL: %s\n"
"Use Dynarec: %s\n" "Use Dynarec: %s\n"
"Use Dual Core: %s\n" "Use Dual Core: %s\n"
"DSP Thread: %s\n" "DSP Thread: %s\n"
@ -74,7 +74,7 @@ std::string Summarize_Settings()
"Frame Limit: %d\n" "Frame Limit: %d\n"
"[Wii]Widescreen: %s\n" "[Wii]Widescreen: %s\n"
"[Wii]Progressive Scan: %s\n", "[Wii]Progressive Scan: %s\n",
Core::GetStartupParameter().bHLEBios?"True":"False", Core::GetStartupParameter().bHLE_BS2?"True":"False",
Core::GetStartupParameter().bUseJIT?"True":"False", Core::GetStartupParameter().bUseJIT?"True":"False",
Core::GetStartupParameter().bUseDualCore?"True":"False", Core::GetStartupParameter().bUseDualCore?"True":"False",
Core::GetStartupParameter().bDSPThread?"True":"False", Core::GetStartupParameter().bDSPThread?"True":"False",