Finally hacked Super Monkey Ball into submission! Some bonus hacking tools included.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@282 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-08-23 15:15:25 +00:00
parent 0849a96d81
commit 8be70a8ed2
17 changed files with 442 additions and 114 deletions

View File

@ -0,0 +1,34 @@
.text
800031f0 0000001c 800031f0 0 load_sp_rtoc
80007034 0000004c 80007034 0 .LoadQuantizers
80007080 00000030 80007080 0 .LoadInfinitiesEtc
800070b0 00000038 800070b0 0 .rsqrt
800070ec 00000040 800070ec 0 .sqrt_internal_needs_cr1
8000712c 00000040 8000712c 0 .rsqrt_internal_needs_cr1
800071e0 00000030 800071e0 0 .wrapping_once_fp_lookup
80007210 00000064 80007210 0 .weird2
80007274 00000030 80007274 0 .lookup_some_float_in_table_with_neg_wrap
800072a4 00000180 800072a4 0 .atan2
80007424 000000b8 80007424 0 .calls_sqrt
800074dc 0000005c 800074dc 0 .func
80007538 0000002c 80007538 0 .load_strange_matrix1
80007564 0000002c 80007564 0 .load_strange_matrix3
80007590 0000002c 80007590 0 .load_strange_matrix2
80007834 00000044 80007834 0 .push_matrix_3x3?
80007878 00000038 80007878 0 .read_top_3x3matrix
800078b0 00000038 800078b0 0 .write_top_3x3_matrix
800078e8 0000003c 800078e8 0 .read_current_3x3_matrix
80007924 00000014 80007924 0 .pop_matrix_stack
80007a50 00000170 80007a50 0 .mult_matrix?
80007ecc 000000bc 80007ecc 0 .weird_vector_op_status_in_cr2
80007f88 00000074 80007f88 0 .weird_param_in_p1_p2
800080fc 00000078 800080fc 0 .evil_normalize
80008174 00000078 80008174 0 .evil_vec_setlength
800081ec 00000070 800081ec 0 .evil_vec_cosine
80008538 000000f0 80008538 0 .calls_evil1
8000875c 00000088 8000875c 0 .another_caller
800087e4 0000008c 800087e4 0 .another_caller2
80008d30 000001b4 80008d30 0 .another_caller3
80036544 000001b4 80036544 0 .fctiwi_weird2
8003dd1c 00000110 8003dd1c 0 .fctwi_weird
80043b48 000005bc 80043b48 0 .fctwi_weird3

View File

@ -0,0 +1,34 @@
.text
800031f0 0000001c 800031f0 0 load_sp_rtoc
80007034 0000004c 80007034 0 .LoadQuantizers
80007080 00000030 80007080 0 .LoadInfinitiesEtc
800070b0 00000038 800070b0 0 .rsqrt
800070ec 00000040 800070ec 0 .sqrt_internal_needs_cr1
8000712c 00000040 8000712c 0 .rsqrt_internal_needs_cr1
800071e0 00000030 800071e0 0 .wrapping_once_fp_lookup
80007210 00000064 80007210 0 .weird2
80007274 00000030 80007274 0 .lookup_some_float_in_table_with_neg_wrap
800072a4 00000180 800072a4 0 .atan2
80007424 000000b8 80007424 0 .calls_sqrt
800074dc 0000005c 800074dc 0 .func
80007538 0000002c 80007538 0 .load_strange_matrix1
80007564 0000002c 80007564 0 .load_strange_matrix3
80007590 0000002c 80007590 0 .load_strange_matrix2
80007834 00000044 80007834 0 .push_matrix_3x3?
80007878 00000038 80007878 0 .read_top_3x3matrix
800078b0 00000038 800078b0 0 .write_top_3x3_matrix
800078e8 0000003c 800078e8 0 .read_current_3x3_matrix
80007924 00000014 80007924 0 .pop_matrix_stack
80007a50 00000170 80007a50 0 .mult_matrix?
80007ecc 000000bc 80007ecc 0 .weird_vector_op_status_in_cr2
80007f88 00000074 80007f88 0 .weird_param_in_p1_p2
800080fc 00000078 800080fc 0 .evil_normalize
80008174 00000078 80008174 0 .evil_vec_setlength
800081ec 00000070 800081ec 0 .evil_vec_cosine
80008538 000000f0 80008538 0 .calls_evil1
8000875c 00000088 8000875c 0 .another_caller
800087e4 0000008c 800087e4 0 .another_caller2
80008d30 000001b4 80008d30 0 .another_caller3
80036544 000001b4 80036544 0 .fctiwi_weird2
8003dd1c 00000110 8003dd1c 0 .fctwi_weird
80043b48 000005bc 80043b48 0 .fctwi_weird3

View File

@ -0,0 +1,34 @@
.text
800031f0 0000001c 800031f0 0 load_sp_rtoc
80007034 0000004c 80007034 0 .LoadQuantizers
80007080 00000030 80007080 0 .LoadInfinitiesEtc
800070b0 00000038 800070b0 0 .rsqrt
800070ec 00000040 800070ec 0 .sqrt_internal_needs_cr1
8000712c 00000040 8000712c 0 .rsqrt_internal_needs_cr1
800071e0 00000030 800071e0 0 .wrapping_once_fp_lookup
80007210 00000064 80007210 0 .weird2
80007274 00000030 80007274 0 .lookup_some_float_in_table_with_neg_wrap
800072a4 00000180 800072a4 0 .atan2
80007424 000000b8 80007424 0 .calls_sqrt
800074dc 0000005c 800074dc 0 .func
80007538 0000002c 80007538 0 .load_strange_matrix1
80007564 0000002c 80007564 0 .load_strange_matrix3
80007590 0000002c 80007590 0 .load_strange_matrix2
80007834 00000044 80007834 0 .push_matrix_3x3?
80007878 00000038 80007878 0 .read_top_3x3matrix
800078b0 00000038 800078b0 0 .write_top_3x3_matrix
800078e8 0000003c 800078e8 0 .read_current_3x3_matrix
80007924 00000014 80007924 0 .pop_matrix_stack
80007a50 00000170 80007a50 0 .mult_matrix?
80007ecc 000000bc 80007ecc 0 .weird_vector_op_status_in_cr2
80007f88 00000074 80007f88 0 .weird_param_in_p1_p2
800080fc 00000078 800080fc 0 .evil_normalize
80008174 00000078 80008174 0 .evil_vec_setlength
800081ec 00000070 800081ec 0 .evil_vec_cosine
80008538 000000f0 80008538 0 .calls_evil1
8000875c 00000088 8000875c 0 .another_caller
800087e4 0000008c 800087e4 0 .another_caller2
80008d30 000001b4 80008d30 0 .another_caller3
80036544 000001b4 80036544 0 .fctiwi_weird2
8003dd1c 00000110 8003dd1c 0 .fctwi_weird
80043b48 000005bc 80043b48 0 .fctwi_weird3

View File

@ -0,0 +1,34 @@
.text
800031f0 0000001c 800031f0 0 load_sp_rtoc
80007034 0000004c 80007034 0 .LoadQuantizers
80007080 00000030 80007080 0 .LoadInfinitiesEtc
800070b0 00000038 800070b0 0 .rsqrt
800070ec 00000040 800070ec 0 .sqrt_internal_needs_cr1
8000712c 00000040 8000712c 0 .rsqrt_internal_needs_cr1
800071e0 00000030 800071e0 0 .wrapping_once_fp_lookup
80007210 00000064 80007210 0 .weird2
80007274 00000030 80007274 0 .lookup_some_float_in_table_with_neg_wrap
800072a4 00000180 800072a4 0 .atan2
80007424 000000b8 80007424 0 .calls_sqrt
800074dc 0000005c 800074dc 0 .func
80007538 0000002c 80007538 0 .load_strange_matrix1
80007564 0000002c 80007564 0 .load_strange_matrix3
80007590 0000002c 80007590 0 .load_strange_matrix2
80007834 00000044 80007834 0 .push_matrix_3x3?
80007878 00000038 80007878 0 .read_top_3x3matrix
800078b0 00000038 800078b0 0 .write_top_3x3_matrix
800078e8 0000003c 800078e8 0 .read_current_3x3_matrix
80007924 00000014 80007924 0 .pop_matrix_stack
80007a50 00000170 80007a50 0 .mult_matrix?
80007ecc 000000bc 80007ecc 0 .weird_vector_op_status_in_cr2
80007f88 00000074 80007f88 0 .weird_param_in_p1_p2
800080fc 00000078 800080fc 0 .evil_normalize
80008174 00000078 80008174 0 .evil_vec_setlength
800081ec 00000070 800081ec 0 .evil_vec_cosine
80008538 000000f0 80008538 0 .calls_evil1
8000875c 00000088 8000875c 0 .another_caller
800087e4 0000008c 800087e4 0 .another_caller2
80008d30 000001b4 80008d30 0 .another_caller3
80036544 000001b4 80036544 0 .fctiwi_weird2
8003dd1c 00000110 8003dd1c 0 .fctwi_weird
80043b48 000005bc 80043b48 0 .fctwi_weird3

View File

@ -1009,46 +1009,6 @@
RelativePath=".\Src\Debugger\PPCDebugInterface.h" RelativePath=".\Src\Debugger\PPCDebugInterface.h"
> >
</File> </File>
<Filter
Name="Boot"
>
<File
RelativePath=".\Src\Boot\Boot.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot.h"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_DOL.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_DOL.h"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_ELF.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_ELF.h"
>
</File>
<File
RelativePath=".\Src\Boot\ElfReader.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\ElfReader.h"
>
</File>
<File
RelativePath=".\Src\Boot\ElfTypes.h"
>
</File>
</Filter>
</Filter> </Filter>
<Filter <Filter
Name="IPC HLE" Name="IPC HLE"
@ -1134,6 +1094,46 @@
> >
</File> </File>
</Filter> </Filter>
<Filter
Name="Boot"
>
<File
RelativePath=".\Src\Boot\Boot.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot.h"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_DOL.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_DOL.h"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_ELF.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_ELF.h"
>
</File>
<File
RelativePath=".\Src\Boot\ElfReader.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\ElfReader.h"
>
</File>
<File
RelativePath=".\Src\Boot\ElfTypes.h"
>
</File>
</Filter>
<File <File
RelativePath=".\Src\Console.cpp" RelativePath=".\Src\Console.cpp"
> >

View File

@ -353,7 +353,6 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
LOG(BOOT, "DVDRead: offset: %08x memOffse: %08x length: %i", iDVDOffset, iRamAddress, iLength); LOG(BOOT, "DVDRead: offset: %08x memOffse: %08x length: %i", iDVDOffset, iRamAddress, iLength);
DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength); DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength);
} while(PowerPC::ppcState.gpr[3] != 0x00); } while(PowerPC::ppcState.gpr[3] != 0x00);
// iAppLoaderClose // iAppLoaderClose
@ -376,23 +375,31 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
void CBoot::UpdateDebugger_MapLoaded(const char *_gameID) void CBoot::UpdateDebugger_MapLoaded(const char *_gameID)
{ {
HLE::PatchFunctions(_gameID); HLE::PatchFunctions();
Debugger::AnalyzeBackwards(); Debugger::AnalyzeBackwards();
Host_NotifyMapLoaded(); Host_NotifyMapLoaded();
Host_UpdateMemoryView(); Host_UpdateMemoryView();
} }
std::string CBoot::GenerateMapFilename()
{
/*
std::string strDriveDirectory, strFilename;
SplitPath(booted_file, &strDriveDirectory, &strFilename, NULL);
std::string strFullfilename(strFilename + _T(".map"));
std::string strMapFilename;
BuildCompleteFilename(strMapFilename, strDriveDirectory, strFullfilename);
*/
return "Maps/" + Core::GetStartupParameter().GetUniqueID() + ".map";
}
bool CBoot::LoadMapFromFilename(const std::string &_rFilename, const char *_gameID) bool CBoot::LoadMapFromFilename(const std::string &_rFilename, const char *_gameID)
{ {
if (_rFilename.size() == 0) if (_rFilename.size() == 0)
return false; return false;
std::string strDriveDirectory, strFilename; std::string strMapFilename = GenerateMapFilename();
SplitPath(_rFilename, &strDriveDirectory, &strFilename, NULL);
std::string strFullfilename(strFilename + _T(".map"));
std::string strMapFilename;
BuildCompleteFilename(strMapFilename, strDriveDirectory, strFullfilename);
bool success = false; bool success = false;
if (!Debugger::LoadSymbolMap(strMapFilename.c_str())) if (!Debugger::LoadSymbolMap(strMapFilename.c_str()))
@ -493,7 +500,7 @@ bool CBoot::BootUp(const SCoreStartupParameter& _StartupPara)
} }
if (LoadMapFromFilename(_StartupPara.m_strFilename, gameID)) if (LoadMapFromFilename(_StartupPara.m_strFilename, gameID))
{ {
HLE::PatchFunctions(gameID); HLE::PatchFunctions();
} }
else else
{ {

View File

@ -40,6 +40,8 @@ public:
static bool BootUp(const SCoreStartupParameter& _StartupPara); static bool BootUp(const SCoreStartupParameter& _StartupPara);
static bool IsElfWii(const char *filename); static bool IsElfWii(const char *filename);
static std::string GenerateMapFilename();
private: private:
enum { BIOS_SIZE = 2*1024*1024 }; enum { BIOS_SIZE = 2*1024*1024 };

View File

@ -3,6 +3,8 @@
#include <string> #include <string>
#include "DebugInterface.h"
//wrapper between disasm control and Dolphin debugger //wrapper between disasm control and Dolphin debugger
class PPCDebugInterface : public DebugInterface class PPCDebugInterface : public DebugInterface

View File

@ -63,6 +63,14 @@ static const SPatch OSPatches[] =
// wii only // wii only
{ "SCCheckStatus", HLE_Misc::UnimplementedFunctionFalse }, { "SCCheckStatus", HLE_Misc::UnimplementedFunctionFalse },
{ "__OSInitAudioSystem", HLE_Misc::UnimplementedFunction }, { "__OSInitAudioSystem", HLE_Misc::UnimplementedFunction },
// Super Monkey Ball
{ ".evil_vec_cosine", HLE_Misc::SMB_EvilVecCosine },
{ ".evil_normalize", HLE_Misc::SMB_EvilNormalize },
{ "PanicAlert", HLE_Misc::PanicAlert },
{ ".sqrt_internal_needs_cr1", HLE_Misc::SMB_sqrt_internal },
{ ".rsqrt_internal_needs_cr1", HLE_Misc::SMB_rsqrt_internal },
{ ".atan2", HLE_Misc::SMB_atan2},
// special // special
// { "GXPeekZ", HLE_Misc::GXPeekZ}, // { "GXPeekZ", HLE_Misc::GXPeekZ},
@ -74,22 +82,36 @@ static const SPatch OSBreakPoints[] =
{ "FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction }, { "FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction },
}; };
void PatchFunctions(const char* _gameID) void Patch(u32 address, const char *hle_func_name)
{
for (u32 i = 0; i < sizeof(OSPatches) / sizeof(SPatch); i++)
{
if (!strcmp(OSPatches[i].m_szPatchName, hle_func_name)) {
u32 HLEPatchValue = (1 & 0x3f) << 26;
Memory::Write_U32(HLEPatchValue | i, address);
return;
}
}
}
void PatchFunctions()
{ {
for (u32 i=0; i < sizeof(OSPatches) / sizeof(SPatch); i++) for (u32 i = 0; i < sizeof(OSPatches) / sizeof(SPatch); i++)
{ {
int SymbolIndex = Debugger::FindSymbol(OSPatches[i].m_szPatchName); int SymbolIndex = Debugger::FindSymbol(OSPatches[i].m_szPatchName);
if (SymbolIndex > 0) if (SymbolIndex > 0)
{ {
const Debugger::CSymbol& rSymbol = Debugger::GetSymbol(SymbolIndex); const Debugger::CSymbol& rSymbol = Debugger::GetSymbol(SymbolIndex);
u32 HLEPatchValue = (1 & 0x3f) << 26; u32 HLEPatchValue = (1 & 0x3f) << 26;
Memory::Write_U32(HLEPatchValue | i, rSymbol.vaddress); for (int addr = rSymbol.vaddress; addr < rSymbol.vaddress + rSymbol.size; addr+=4) {
Memory::Write_U32(HLEPatchValue | i, addr);
}
//PanicAlert("patched %s", OSPatches[i].m_szPatchName);
LOG(HLE,"Patching %s %08x", OSPatches[i].m_szPatchName, rSymbol.vaddress); LOG(HLE,"Patching %s %08x", OSPatches[i].m_szPatchName, rSymbol.vaddress);
} }
} }
for (size_t i=1; i < sizeof(OSBreakPoints) / sizeof(SPatch); i++) for (size_t i = 1; i < sizeof(OSBreakPoints) / sizeof(SPatch); i++)
{ {
int SymbolIndex = Debugger::FindSymbol(OSBreakPoints[i].m_szPatchName); int SymbolIndex = Debugger::FindSymbol(OSBreakPoints[i].m_szPatchName);
if (SymbolIndex != -1) if (SymbolIndex != -1)

View File

@ -22,7 +22,8 @@
namespace HLE namespace HLE
{ {
void PatchFunctions(const char* _gameID = 0); void PatchFunctions();
void Patch(u32 pc, const char *func_name);
void Execute(u32 _CurrentPC, u32 _Instruction); void Execute(u32 _CurrentPC, u32 _Instruction);
} }

View File

@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <cmath>
#include "Common.h"
#include "HLE_OS.h" #include "HLE_OS.h"
#include "../PowerPC/PowerPC.h" #include "../PowerPC/PowerPC.h"
@ -23,6 +25,18 @@
namespace HLE_Misc namespace HLE_Misc
{ {
inline float F(u32 addr)
{
u32 mem = Memory::ReadFast32(addr);
return *((float*)&mem);
}
inline void FW(u32 addr, float x)
{
u32 data = *((u32*)&x);
Memory::WriteUnchecked_U32(data, addr);
}
void UnimplementedFunction() void UnimplementedFunction()
{ {
NPC = LR; NPC = LR;
@ -30,32 +44,140 @@ void UnimplementedFunction()
void UnimplementedFunctionTrue() void UnimplementedFunctionTrue()
{ {
GPR(3)=1; GPR(3) = 1;
NPC = LR; NPC = LR;
} }
void UnimplementedFunctionFalse() void UnimplementedFunctionFalse()
{ {
GPR(3)=0; GPR(3) = 0;
NPC = LR; NPC = LR;
} }
void THPPlayerGetState()
{
GPR(3)=3; // Video played
NPC=LR;
}
void GXPeekZ() void GXPeekZ()
{ {
Memory::Write_U32(0xFFFFFF,GPR(5)); Memory::Write_U32(0xFFFFFF, GPR(5));
NPC=LR; NPC = LR;
} }
void GXPeekARGB() void GXPeekARGB()
{ {
Memory::Write_U32(0xFFFFFFFF,GPR(5)); Memory::Write_U32(0xFFFFFFFF, GPR(5));
NPC=LR; NPC = LR;
} }
void PanicAlert()
{
::PanicAlert("HLE: PanicAlert %08x", LR);
NPC = LR;
}
// .evil_vec_cosine
void SMB_EvilVecCosine()
{
u32 r3 = GPR(3);
u32 r4 = GPR(4);
float x1 = F(r3);
float y1 = F(r3 + 4);
float z1 = F(r3 + 8);
float x2 = F(r4);
float y2 = F(r4 + 4);
float z2 = F(r4 + 8);
float s1 = x1*x1 + y1*y1 + z1*z1;
float s2 = x2*x2 + y2*y2 + z2*z2;
float dot = x1*x2 + y1*y2 + z1*z2;
rPS0(1) = dot / sqrtf(s1 * s2);
NPC = LR;
}
void SMB_EvilNormalize()
{
u32 r3 = GPR(3);
float x = F(r3);
float y = F(r3 + 4);
float z = F(r3 + 8);
float inv_len = 1.0 / sqrt(x*x + y*y + z*z);
x *= inv_len;
y *= inv_len;
z *= inv_len;
FW(r3, x);
FW(r3 + 4, y);
FW(r3 + 8, z);
NPC = LR;
}
void SMB_sqrt_internal()
{
/*
.sqrt_internal_needs_cr1
800070ec: bgt+ cr1,0x80007090
800070f0: blt+ cr1,0x80007088
800070f4: b 0x80007080
800070f8: frsp f0,f1
800070fc: lis r4, 0xE000
80007100: mcrfs cr1, cr4
80007104: mcrfs cr0, cr3
80007108: lfs f2, 0x01A0 (r4)
8000710c: bso+ cr1,0x800070EC
80007110: bso+ 0x80007088
80007114: ble+ cr1,0x80007088
80007118: mflr r3
8000711c: bl 0x800070B0
80007120: mtlr r3
80007124: fmuls f1,f1,f0
80007128: blr
*/
double f = sqrt(rPS0(1));
rPS0(1) = f;
rPS1(1) = f;
rPS0(0) = f;
rPS1(0) = f;
NPC = LR;
}
void SMB_rsqrt_internal()
{
/*
.rsqrt_internal_needs_cr1
8000712c: bgt+ cr1,0x80007088
80007130: blt+ cr1,0x80007090
80007134: b 0x80007080
80007138: frsp f1,f1
8000713c: lis r4, 0xE000
80007140: mcrfs cr1, cr4
80007144: mcrfs cr0, cr3
80007148: lfs f2, 0x01A0 (r4)
8000714c: bso+ cr1,0x8000712C
80007150: bso+ 0x80007090
80007154: ble+ cr1,0x80007090
80007158: mflr r3
8000715c: bl 0x800070B0
80007160: mtlr r3
80007164: frsp f1,f1
80007168: blr
*/
double f = 1.0 / sqrt(rPS0(1));
rPS0(1) = f;
rPS1(1) = f;
rPS0(0) = f;
rPS1(0) = f;
NPC = LR;
}
void SMB_atan2()
{
// in: f1 = x, f2 = y
// out: r3 = angle
double angle = atan2(rPS0(1), rPS0(2));
int angle_fixpt = angle / 3.14159 * 32767;
if (angle_fixpt < -32767) angle_fixpt = -32767;
if (angle_fixpt > 32767) angle_fixpt = 32767;
GPR(3) = angle_fixpt;
NPC = LR;
}
} }

View File

@ -21,12 +21,17 @@
namespace HLE_Misc namespace HLE_Misc
{ {
void Pass(); void Pass();
void PanicAlert();
void UnimplementedFunction(); void UnimplementedFunction();
void UnimplementedFunctionTrue(); void UnimplementedFunctionTrue();
void UnimplementedFunctionFalse(); void UnimplementedFunctionFalse();
void THPPlayerGetState();
void GXPeekZ(); void GXPeekZ();
void GXPeekARGB(); void GXPeekARGB();
void SMB_EvilVecCosine();
void SMB_EvilNormalize();
void SMB_sqrt_internal();
void SMB_rsqrt_internal();
void SMB_atan2();
} }
#endif #endif

View File

@ -72,7 +72,7 @@ public:
static void fnmaddsx(UGeckoInstruction _inst); static void fnmaddsx(UGeckoInstruction _inst);
static void fnmsubsx(UGeckoInstruction _inst); static void fnmsubsx(UGeckoInstruction _inst);
static void fresx(UGeckoInstruction _inst); static void fresx(UGeckoInstruction _inst);
static void fsqrtsx(UGeckoInstruction _inst); // static void fsqrtsx(UGeckoInstruction _inst);
static void fsubsx(UGeckoInstruction _inst); static void fsubsx(UGeckoInstruction _inst);
static void fabsx(UGeckoInstruction _inst); static void fabsx(UGeckoInstruction _inst);
static void fcmpo(UGeckoInstruction _inst); static void fcmpo(UGeckoInstruction _inst);

View File

@ -652,7 +652,7 @@ void PPCTables::CompileInstruction(UGeckoInstruction _inst)
dynaOpTable[_inst.OPCD](_inst); dynaOpTable[_inst.OPCD](_inst);
GekkoOPInfo *info = GetOpInfo(_inst); GekkoOPInfo *info = GetOpInfo(_inst);
if (info) { if (info) {
if (!strcmp(info->opname, "mffsx")) { if (!strcmp(info->opname, "mcrfs")) {
rsplocations.push_back(Jit64::js.compilerPC); rsplocations.push_back(Jit64::js.compilerPC);
} }
info->compileCount++; info->compileCount++;
@ -721,9 +721,9 @@ void PPCTables::LogCompiledInstructions()
} }
} }
fclose(f); fclose(f);
f = fopen(StringFromFormat("rsp_at.txt", time).c_str(), "w"); f = fopen(StringFromFormat("mcrfs_at.txt", time).c_str(), "w");
for (int i = 0; i < rsplocations.size(); i++) { for (int i = 0; i < rsplocations.size(); i++) {
fprintf(f, "mffsx: %08x\n", rsplocations[i]); fprintf(f, "mcrfs: %08x\n", rsplocations[i]);
} }
fclose(f); fclose(f);
time++; time++;

View File

@ -16,13 +16,18 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "Debugger.h" #include "Debugger.h"
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "Common.h" #include "Common.h"
#include "StringUtil.h"
#include "Host.h"
#include "CodeView.h" #include "CodeView.h"
#include "JitWindow.h" #include "JitWindow.h"
#include <wx/event.h> #include <wx/event.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
#include <wx/textdlg.h>
enum enum
@ -34,6 +39,9 @@ enum
IDM_INSERTBLR, IDM_INSERTBLR,
IDM_RUNTOHERE, IDM_RUNTOHERE,
IDM_JITRESULTS, IDM_JITRESULTS,
IDM_RENAMESYMBOL,
IDM_PATCHALERT,
IDM_COPYFUNCTION,
}; };
@ -174,6 +182,22 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(temp))); wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(temp)));
} }
break; break;
case IDM_COPYFUNCTION:
{
int sel = Debugger::FindSymbol(selection);
if (sel > 0) {
std::string text;
text = text + Debugger::GetSymbol(sel).GetName() + "\r\n";
// we got a function
u32 start = Debugger::GetSymbol(sel).vaddress;
u32 end = start + Debugger::GetSymbol(sel).size;
for (u32 addr = start; addr != end; addr += 4) {
text = text + StringFromFormat("%08x: ", addr) + debugger->disasm(addr) + "\r\n";
}
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(text.c_str())));
}
}
break;
#endif #endif
case IDM_RUNTOHERE: case IDM_RUNTOHERE:
@ -190,6 +214,26 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
case IDM_JITRESULTS: case IDM_JITRESULTS:
CJitWindow::ViewAddr(selection); CJitWindow::ViewAddr(selection);
break; break;
case IDM_RENAMESYMBOL:
{
int sel = Debugger::FindSymbol(selection);
if (sel > 0) {
wxTextEntryDialog input_symbol(this, "Rename symbol:", wxGetTextFromUserPromptStr, Debugger::GetSymbol(sel).GetName().c_str());
if (input_symbol.ShowModal() == wxID_OK) {
Debugger::AccessSymbol(sel).SetName(input_symbol.GetValue().c_str());
}
// redraw();
Host_NotifyMapLoaded();
}
}
break;
case IDM_PATCHALERT:
{
}
break;
} }
#if wxUSE_CLIPBOARD #if wxUSE_CLIPBOARD
@ -206,12 +250,17 @@ void CCodeView::OnMouseUpR(wxMouseEvent& event)
//menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view"); //menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
#if wxUSE_CLIPBOARD #if wxUSE_CLIPBOARD
menu.Append(IDM_COPYADDRESS, wxString::FromAscii("Copy &address")); menu.Append(IDM_COPYADDRESS, wxString::FromAscii("Copy &address"));
menu.Append(IDM_COPYCODE, wxString::FromAscii("Copy &code")); menu.Append(IDM_COPYFUNCTION, wxString::FromAscii("Copy &function"));
menu.Append(IDM_COPYCODE, wxString::FromAscii("Copy &code line"));
menu.Append(IDM_COPYHEX, wxString::FromAscii("Copy &hex")); menu.Append(IDM_COPYHEX, wxString::FromAscii("Copy &hex"));
menu.AppendSeparator();
#endif #endif
menu.Append(IDM_RENAMESYMBOL, wxString::FromAscii("Rename &symbol"));
menu.AppendSeparator();
menu.Append(IDM_RUNTOHERE, _T("&Run To Here")); menu.Append(IDM_RUNTOHERE, _T("&Run To Here"));
menu.Append(IDM_INSERTBLR, wxString::FromAscii("Insert &blr"));
menu.Append(IDM_JITRESULTS, wxString::FromAscii("PPC vs X86")); menu.Append(IDM_JITRESULTS, wxString::FromAscii("PPC vs X86"));
menu.Append(IDM_INSERTBLR, wxString::FromAscii("Insert &blr"));
menu.Append(IDM_PATCHALERT, wxString::FromAscii("Patch alert"));
PopupMenu(&menu); PopupMenu(&menu);
event.Skip(true); event.Skip(true);
} }

View File

@ -17,9 +17,9 @@
#include "wx/button.h" #include "wx/button.h"
#include "wx/textctrl.h" #include "wx/textctrl.h"
#include "wx/textdlg.h"
#include "wx/listctrl.h" #include "wx/listctrl.h"
#include "wx/thread.h" #include "wx/thread.h"
#include "wx/listctrl.h"
#include "wx/mstream.h" #include "wx/mstream.h"
// ugly that this lib included code from the main // ugly that this lib included code from the main
@ -39,7 +39,9 @@
#include "CodeWindow.h" #include "CodeWindow.h"
#include "CodeView.h" #include "CodeView.h"
#include "FileUtil.h"
#include "Core.h" #include "Core.h"
#include "Boot/Boot.h"
#include "LogManager.h" #include "LogManager.h"
#include "HW/CPU.h" #include "HW/CPU.h"
#include "PowerPC/PowerPC.h" #include "PowerPC/PowerPC.h"
@ -241,7 +243,9 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
{ {
wxMenu *pSymbolsMenu = new wxMenu; wxMenu *pSymbolsMenu = new wxMenu;
pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _T("&Scan for functions")); pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _T("&Load symbol map"));
pSymbolsMenu->Append(IDM_SAVEMAPFILE, _T("&Save symbol map"));
pSymbolsMenu->Append(IDM_RENAMEFUNCTION, _T("&Rename function..."));
pMenuBar->Append(pSymbolsMenu, _T("&Symbols")); pMenuBar->Append(pSymbolsMenu, _T("&Symbols"));
} }
@ -293,50 +297,27 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
// TODO: disable menu items instead :P // TODO: disable menu items instead :P
return; return;
} }
wxString path; std::string mapfile = CBoot::GenerateMapFilename();
switch (event.GetId()) switch (event.GetId())
{ {
case IDM_SCANFUNCTIONS: case IDM_SCANFUNCTIONS:
PPCAnalyst::FindFunctions(0x80003100, 0x80400000); if (!File::Exists(mapfile))
PPCAnalyst::LoadFuncDB("Data/totaldb.dsy");
Debugger::GetFromAnalyzer();
NotifyMapLoaded();
break;
case IDM_LOADMAPFILE:
path = wxFileSelector(
_T("Select the mapfile to load"),
wxEmptyString, wxEmptyString, wxEmptyString,
wxString::Format
(
_T("Map files (*.map)|*.map|All files (%s)|%s"),
wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr
),
wxFD_OPEN | wxFD_FILE_MUST_EXIST,
this);
if (!path)
{ {
return; PPCAnalyst::FindFunctions(0x80003100, 0x80400000);
if (PPCAnalyst::LoadFuncDB("Data/totaldb.dsy"))
{
Debugger::GetFromAnalyzer();
NotifyMapLoaded();
}
} else {
Debugger::LoadSymbolMap(mapfile.c_str());
} }
Debugger::LoadSymbolMap(path.ToAscii());
break; break;
// case IDM_LOADMAPFILE:
// Debugger::LoadSymbolMap(mapfile.c_str());
// break;
case IDM_SAVEMAPFILE: case IDM_SAVEMAPFILE:
path = wxFileSelector( Debugger::SaveSymbolMap(mapfile.c_str());
_T("Name your mapfile"),
wxEmptyString, wxEmptyString, wxEmptyString,
wxString::Format
(
_T("Map files (*.map)|*.map|All files (%s)|%s"),
wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr
),
wxFD_SAVE,
this);
if (!path)
{
return;
}
Debugger::SaveSymbolMap(path.ToAscii());
break; break;
} }
} }
@ -362,7 +343,7 @@ void CCodeWindow::OnCodeStep(wxCommandEvent& event)
Update(); Update();
} }
break; break;
case IDM_STEP: case IDM_STEP:
SingleCPUStep(); SingleCPUStep();

View File

@ -83,6 +83,7 @@ class CCodeWindow
IDM_LOGINSTRUCTIONS, IDM_LOGINSTRUCTIONS,
IDM_LOADMAPFILE, IDM_LOADMAPFILE,
IDM_SAVEMAPFILE, IDM_SAVEMAPFILE,
IDM_RENAMEFUNCTION,
IDM_CLEARCODECACHE, IDM_CLEARCODECACHE,
}; };