summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2012-05-05 18:38:00 +1000
committerskidau <skidau@gmail.com>2012-12-26 23:10:40 +1100
commit0c845728ccfc5f3a93c69aa09a924a0413e8d151 (patch)
treeec8a141eb665ec6d9cfe6316f86711c989c5fec7 /Source/Core
parent88e273fac13b6c3b95256fc083867c2b6553c9d6 (diff)
Added support for Reset (from menu). Fixes Sam & Max.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Src/Boot/Boot.cpp6
-rw-r--r--Source/Core/Core/Src/HLE/HLE_Misc.cpp120
-rw-r--r--Source/Core/Core/Src/HLE/HLE_Misc.h1
-rw-r--r--Source/Core/Core/Src/HW/ProcessorInterface.cpp1
-rw-r--r--Source/Core/DiscIO/Src/FileSystemGCWii.cpp17
-rw-r--r--Source/Core/DiscIO/Src/FileSystemGCWii.h2
-rw-r--r--Source/Core/DiscIO/Src/Filesystem.h2
7 files changed, 107 insertions, 42 deletions
diff --git a/Source/Core/Core/Src/Boot/Boot.cpp b/Source/Core/Core/Src/Boot/Boot.cpp
index 7711990e65..ef3ae2a4fb 100644
--- a/Source/Core/Core/Src/Boot/Boot.cpp
+++ b/Source/Core/Core/Src/Boot/Boot.cpp
@@ -260,13 +260,15 @@ bool CBoot::BootUp()
// Scan for common HLE functions
if (!_StartupPara.bEnableDebugging)
{
- PPCAnalyst::FindFunctions(0x80000000, 0x81800000, &g_symbolDB);
+ PPCAnalyst::FindFunctions(0x80004000, 0x811fffff, &g_symbolDB);
SignatureDB db;
if (db.Load((File::GetSysDirectory() + TOTALDB).c_str()))
{
db.Apply(&g_symbolDB);
+ HLE::PatchFunctions();
+ db.Clear();
+ g_symbolDB.Clear();
}
- HLE::PatchFunctions();
}
/* Try to load the symbol map if there is one, and then scan it for
diff --git a/Source/Core/Core/Src/HLE/HLE_Misc.cpp b/Source/Core/Core/Src/HLE/HLE_Misc.cpp
index 67b2e84963..40073d401e 100644
--- a/Source/Core/Core/Src/HLE/HLE_Misc.cpp
+++ b/Source/Core/Core/Src/HLE/HLE_Misc.cpp
@@ -29,6 +29,10 @@
#include "../Boot/Boot_DOL.h"
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "HLE.h"
+#include "PowerPC/PPCAnalyst.h"
+#include "PowerPC/SignatureDB.h"
+#include "PowerPC/PPCSymbolDB.h"
+#include "CommonPaths.h"
namespace HLE_Misc
{
@@ -295,7 +299,61 @@ void HBReload()
Host_Message(WM_USER_STOP);
}
-void BootDOLFromDisc()
+void ExecuteDOL(u8* dolFile, u32 fileSize)
+{
+ CDolLoader dolLoader(dolFile, fileSize);
+ dolLoader.Load();
+
+ // Scan for common HLE functions
+ if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging)
+ {
+ PPCAnalyst::FindFunctions(0x80004000, 0x811fffff, &g_symbolDB);
+ SignatureDB db;
+ if (db.Load((File::GetSysDirectory() + TOTALDB).c_str()))
+ {
+ db.Apply(&g_symbolDB);
+ HLE::PatchFunctions();
+ db.Clear();
+ g_symbolDB.Clear();
+ }
+ }
+
+ PowerPC::ppcState.iCache.Reset();
+
+ static CWII_IPC_HLE_Device_usb_oh1_57e_305* s_Usb = GetUsbPointer();
+ for (unsigned int i = 0; i < 4; i++)
+ {
+ if (s_Usb->m_WiiMotes[i].IsConnected())
+ {
+ s_Usb->m_WiiMotes[i].Activate(false);
+ s_Usb->m_WiiMotes[i].Activate(true);
+ }
+ else
+ {
+ s_Usb->m_WiiMotes[i].Activate(false);
+ }
+ }
+
+ if (argsPtr)
+ {
+ u32 args_base = Memory::Read_U32(0x800000f4);
+ u32 ptr_to_num_args = 0xc;
+ u32 num_args = 1;
+ u32 hi_ptr = args_base + ptr_to_num_args + 4;
+ u32 new_args_ptr = args_base + ptr_to_num_args + 8;
+
+ Memory::Write_U32(ptr_to_num_args, args_base + 8);
+ Memory::Write_U32(num_args, args_base + ptr_to_num_args);
+ Memory::Write_U32(0x14, hi_ptr);
+
+ for (int i = 0; i < args.length(); i++)
+ Memory::WriteUnchecked_U8(args[i], new_args_ptr+i);
+ }
+
+ NPC = dolLoader.GetEntryPoint() | 0x80000000;
+}
+
+void LoadDOLFromDisc()
{
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename.c_str());
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume);
@@ -308,42 +366,23 @@ void BootDOLFromDisc()
if (fileSize > 0)
{
pFileSystem->ReadFile(dol.c_str(), dolFile, fileSize);
- CDolLoader dolLoader(dolFile, fileSize);
- dolLoader.Load();
- PowerPC::ppcState.iCache.Reset();
-
- static CWII_IPC_HLE_Device_usb_oh1_57e_305* s_Usb = GetUsbPointer();
- for (unsigned int i = 0; i < 4; i++)
- {
- if (s_Usb->m_WiiMotes[i].IsConnected())
- {
- s_Usb->m_WiiMotes[i].Activate(false);
- s_Usb->m_WiiMotes[i].Activate(true);
- }
- else
- {
- s_Usb->m_WiiMotes[i].Activate(false);
- }
- }
-
- if (argsPtr)
- {
- u32 args_base = Memory::Read_U32(0x800000f4);
- u32 ptr_to_num_args = 0xc;
- u32 num_args = 1;
- u32 hi_ptr = args_base + ptr_to_num_args + 4;
- u32 new_args_ptr = args_base + ptr_to_num_args + 8;
-
- Memory::Write_U32(ptr_to_num_args, args_base + 8);
- Memory::Write_U32(num_args, args_base + ptr_to_num_args);
- Memory::Write_U32(0x14, hi_ptr);
-
- for (int i = 0; i < args.length(); i++)
- Memory::WriteUnchecked_U8(args[i], new_args_ptr+i);
- }
+ ExecuteDOL(dolFile, fileSize);
+ }
+ delete[] dolFile;
+}
- NPC = dolLoader.GetEntryPoint() | 0x80000000;
+void LoadBootDOLFromDisc()
+{
+ DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename.c_str());
+ DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume);
+ u32 fileSize = pFileSystem->GetBootDOLSize();
+ u8* dolFile = new u8[fileSize];
+ if (fileSize > 0)
+ {
+ pFileSystem->GetBootDOL(dolFile, fileSize);
+ ExecuteDOL(dolFile, fileSize);
}
+ delete[] dolFile;
}
u32 GetDolFileSize()
@@ -369,8 +408,13 @@ void OSBootDol()
if ((GPR(4) >> 28) == 0x8)
{
- // Reset from menu
- PanicAlert("Reset from menu");
+ u32 resetCode = GPR(30);
+
+ // Reset game
+ Memory::Write_U32(resetCode << 3, 0xCC003024);
+ //Memory::Write_U32((resetCode << 3) | 0x80000000, 0x800030f0); // Warm reset
+ LoadBootDOLFromDisc();
+ return;
}
else if ((GPR(4) >> 28) == 0xA)
{
@@ -398,7 +442,7 @@ void OSBootDol()
argsPtr = Memory::Read_U32(GPR(5));
Memory::GetString(args, argsPtr);
- BootDOLFromDisc();
+ LoadDOLFromDisc();
return;
}
else
diff --git a/Source/Core/Core/Src/HLE/HLE_Misc.h b/Source/Core/Core/Src/HLE/HLE_Misc.h
index f831e5b600..d39280831c 100644
--- a/Source/Core/Core/Src/HLE/HLE_Misc.h
+++ b/Source/Core/Core/Src/HLE/HLE_Misc.h
@@ -40,6 +40,7 @@ namespace HLE_Misc
void FZ_rsqrt_internal();
void HBReload();
void OSBootDol();
+ void ExecuteDOL(u8* dolFile, u32 fileSize);
}
#endif
diff --git a/Source/Core/Core/Src/HW/ProcessorInterface.cpp b/Source/Core/Core/Src/HW/ProcessorInterface.cpp
index 4a18ce63b5..0e989d3f50 100644
--- a/Source/Core/Core/Src/HW/ProcessorInterface.cpp
+++ b/Source/Core/Core/Src/HW/ProcessorInterface.cpp
@@ -199,6 +199,7 @@ void Write32(const u32 _uValue, const u32 _iAddress)
case PI_RESET_CODE:
DEBUG_LOG(PROCESSORINTERFACE, "Write %08x to PI_RESET_CODE", _uValue);
+ m_ResetCode = _uValue;
break;
case PI_FLIPPER_UNK:
diff --git a/Source/Core/DiscIO/Src/FileSystemGCWii.cpp b/Source/Core/DiscIO/Src/FileSystemGCWii.cpp
index 8f40ab2f18..f1d5f20b6e 100644
--- a/Source/Core/DiscIO/Src/FileSystemGCWii.cpp
+++ b/Source/Core/DiscIO/Src/FileSystemGCWii.cpp
@@ -159,7 +159,7 @@ bool CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const
return false;
}
-bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const
+u32 CFileSystemGCWii::GetBootDOLSize() const
{
u32 DolOffset = Read32(0x420) << m_OffsetShift;
u32 DolSize = 0, offset = 0, size = 0;
@@ -181,9 +181,22 @@ bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const
if (offset + size > DolSize)
DolSize = offset + size;
}
+ return DolSize;
+}
+
+bool CFileSystemGCWii::GetBootDOL(u8* &buffer, u32 DolSize) const
+{
+ u32 DolOffset = Read32(0x420) << m_OffsetShift;
+ return m_rVolume->Read(DolOffset, DolSize, buffer);
+}
+bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const
+{
+ u32 DolOffset = Read32(0x420) << m_OffsetShift;
+ u32 DolSize = GetBootDOLSize();
u8* buffer = new u8[DolSize];
- if (m_rVolume->Read(DolOffset, DolSize, buffer))
+
+ if (GetBootDOL(buffer, DolSize))
{
char exportName[512];
sprintf(exportName, "%s/boot.dol", _rExportFolder);
diff --git a/Source/Core/DiscIO/Src/FileSystemGCWii.h b/Source/Core/DiscIO/Src/FileSystemGCWii.h
index 38e5f181f9..0e7d836d75 100644
--- a/Source/Core/DiscIO/Src/FileSystemGCWii.h
+++ b/Source/Core/DiscIO/Src/FileSystemGCWii.h
@@ -38,6 +38,8 @@ public:
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename);
virtual bool ExportApploader(const char* _rExportFolder) const;
virtual bool ExportDOL(const char* _rExportFolder) const;
+ virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const;
+ virtual u32 GetBootDOLSize() const;
private:
bool m_Initialized;
diff --git a/Source/Core/DiscIO/Src/Filesystem.h b/Source/Core/DiscIO/Src/Filesystem.h
index 71be4293e3..8bc98e6a77 100644
--- a/Source/Core/DiscIO/Src/Filesystem.h
+++ b/Source/Core/DiscIO/Src/Filesystem.h
@@ -57,6 +57,8 @@ public:
virtual bool ExportApploader(const char* _rExportFolder) const = 0;
virtual bool ExportDOL(const char* _rExportFolder) const = 0;
virtual const char* GetFileName(u64 _Address) = 0;
+ virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const = 0;
+ virtual u32 GetBootDOLSize() const = 0;
virtual const IVolume *GetVolume() const { return m_rVolume; }
protected: