Initial megacommit.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-07-12 17:40:22 +00:00
parent a3be5d89ae
commit 775dc8a9c0
1920 changed files with 734652 additions and 0 deletions

View File

@ -0,0 +1,122 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "HLE.h"
#include "../PowerPC/PowerPC.h"
#include "../HW/Memmap.h"
#include "../Debugger/Debugger_SymbolMap.h"
#include "../Debugger/Debugger_BreakPoints.h"
#include "HLE_OS.h"
#include "HLE_Misc.h"
namespace HLE
{
using namespace PowerPC;
typedef void (*TPatchFunction)();
enum
{
HLE_RETURNTYPE_BLR = 0,
HLE_RETURNTYPE_RFI = 1,
};
struct SPatch
{
char m_szPatchName[128];
TPatchFunction PatchFunction;
int returnType;
};
SPatch OSPatches[] =
{
{ "FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction },
// speedup
{ "OSProtectRange", HLE_Misc::UnimplementedFunctionFalse },
// { "THPPlayerGetState", HLE_Misc:THPPlayerGetState },
// Debugout is very nice .)
{ "OSReport", HLE_OS::HLE_OSReport },
{ "OSPanic", HLE_OS::HLE_OSPanic },
{ "vprintf", HLE_OS::HLE_vprintf },
{ "printf", HLE_OS::HLE_printf },
// wii only
{ "SCCheckStatus", HLE_Misc::UnimplementedFunctionFalse }, // SC is SystemConfig ... dunn
// special
// { "GXPeekZ", HLE_Misc::GXPeekZ},
// { "GXPeekARGB", HLE_Misc::GXPeekARGB},
};
SPatch OSBreakPoints[] =
{
{ "FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction },
//{ "__OSInitAudioSystem", CHLE_Audio::__OSInitAudioSystem },
};
void PatchFunctions(const char* _gameID)
{
for (u32 i=0; i < sizeof(OSPatches) / sizeof(SPatch); i++)
{
int SymbolIndex = Debugger::FindSymbol(OSPatches[i].m_szPatchName);
if (SymbolIndex > 0)
{
const Debugger::CSymbol& rSymbol = Debugger::GetSymbol(SymbolIndex);
u32 HLEPatchValue = (1 & 0x3f) << 26;
Memory::Write_U32(HLEPatchValue | i, rSymbol.vaddress);
LOG(HLE,"Patching %s %08x", OSPatches[i].m_szPatchName, rSymbol.vaddress);
}
}
for (size_t i=1; i < sizeof(OSBreakPoints) / sizeof(SPatch); i++)
{
int SymbolIndex = Debugger::FindSymbol(OSBreakPoints[i].m_szPatchName);
if (SymbolIndex != -1)
{
const Debugger::CSymbol& rSymbol = Debugger::GetSymbol(SymbolIndex);
CBreakPoints::AddBreakPoint(rSymbol.vaddress, false);
LOG(HLE,"Adding BP to %s %08x", OSBreakPoints[i].m_szPatchName, rSymbol.vaddress);
}
}
// CBreakPoints::AddBreakPoint(0x8000D3D0, false);
}
void Execute(u32 _CurrentPC, u32 _Instruction)
{
int FunctionIndex = _Instruction & 0xFFFFF;
if ((FunctionIndex > 0) && (FunctionIndex < (sizeof(OSPatches) / sizeof(SPatch))))
{
OSPatches[FunctionIndex].PatchFunction();
}
else
{
_dbg_assert_(HLE, 0);
}
// _dbg_assert_msg_(HLE,NPC == LR, "Broken HLE function (doesn't set NPC)", OSPatches[pos].m_szPatchName);
}
}

View File

@ -0,0 +1,30 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _HLE_H
#define _HLE_H
#include "Common.h"
namespace HLE
{
void PatchFunctions(const char* _gameID = 0);
void Execute(u32 _CurrentPC, u32 _Instruction);
}
#endif

View File

@ -0,0 +1,61 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "HLE_OS.h"
#include "../PowerPC/PowerPC.h"
#include "../HW/Memmap.h"
namespace HLE_Misc
{
void UnimplementedFunction()
{
NPC = LR;
}
void UnimplementedFunctionTrue()
{
GPR(3)=1;
NPC = LR;
}
void UnimplementedFunctionFalse()
{
GPR(3)=0;
NPC = LR;
}
void THPPlayerGetState()
{
GPR(3)=3; // Video played
NPC=LR;
}
void GXPeekZ()
{
Memory::Write_U32(0xFFFFFF,GPR(5));
NPC=LR;
}
void GXPeekARGB()
{
Memory::Write_U32(0xFFFFFFFF,GPR(5));
NPC=LR;
}
}

View File

@ -0,0 +1,32 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef HLE_MISC_H
#define HLE_MISC_H
namespace HLE_Misc
{
void Pass();
void UnimplementedFunction();
void UnimplementedFunctionTrue();
void UnimplementedFunctionFalse();
void THPPlayerGetState();
void GXPeekZ();
void GXPeekARGB();
}
#endif

View File

@ -0,0 +1,127 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "StringUtil.h"
#include <string>
#include "Common.h"
#include "HLE_OS.h"
#include "../PowerPC/PowerPC.h"
#include "../HW/Memmap.h"
namespace HLE_OS
{
void GetStringVA(std::string& _rOutBuffer);
void HLE_OSPanic()
{
std::string Error;
GetStringVA(Error);
PanicAlert("PanicAlert: %s", Error.c_str());
LOG(HLE,"(PC=%08x), PanicAlert: %s", LR, Error.c_str());
NPC = LR;
}
void HLE_OSReport()
{
std::string ReportMessage;
GetStringVA(ReportMessage);
LOG(HLE,"(PC=%08x) OSReport: %s", LR, ReportMessage.c_str());
NPC = LR;
}
void HLE_vprintf()
{
std::string ReportMessage;
GetStringVA(ReportMessage);
LOG(HLE,"(PC=%08x) VPrintf: %s", LR, ReportMessage.c_str());
NPC = LR;
}
void HLE_printf()
{
std::string ReportMessage;
GetStringVA(ReportMessage);
LOG(HLE,"(PC=%08x) Printf: %s ", LR, ReportMessage.c_str());
NPC = LR;
}
void GetStringVA(std::string& _rOutBuffer)
{
char ArgumentBuffer[256];
u32 ParameterCounter = 4;
char* pString = (char*)Memory::GetPointer(GPR(3));
while(*pString)
{
if (*pString == '%')
{
char* pArgument = ArgumentBuffer;
*pArgument++ = *pString++;
while(*pString < 'A' || *pString > 'z' || *pString == 'l' || *pString == '-')
*pArgument++ = *pString++;
*pArgument++ = *pString;
*pArgument = NULL;
u32 Parameter;
if (ParameterCounter > 10)
{
Parameter = Memory::Read_U32(GPR(1) + 0x8 + ((ParameterCounter - 11) * 4));
}
else
{
Parameter = GPR(ParameterCounter);
}
ParameterCounter++;
switch(*pString)
{
case 's':
_rOutBuffer += StringFromFormat(ArgumentBuffer, (char*)Memory::GetPointer(Parameter));
break;
case 'd':
{
//u64 Double = Memory::Read_U64(Parameter);
_rOutBuffer += StringFromFormat(ArgumentBuffer, Parameter);
}
break;
default:
_rOutBuffer += StringFromFormat(ArgumentBuffer, Parameter);
break;
}
pString++;
}
else
{
_rOutBuffer += StringFromFormat("%c", *pString);
pString++;
}
}
}
}

View File

@ -0,0 +1,31 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef HLE_OS_H
#define HLE_OS_H
#include "Common.h"
namespace HLE_OS
{
void HLE_vprintf();
void HLE_printf();
void HLE_OSReport();
void HLE_OSPanic();
}
#endif