Some AR Fixes, and speedup Patch Event so AR can apply Code increments faster than the game execution, this helps fixes Jump code in some games.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4551 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
omegadox 2009-11-13 01:26:26 +00:00
parent f38aaca614
commit 00f2a30b71
3 changed files with 26 additions and 19 deletions

View File

@ -51,7 +51,7 @@ enum
ZCODE_END = 0x00, ZCODE_END = 0x00,
ZCODE_NORM = 0x02, ZCODE_NORM = 0x02,
ZCODE_ROW = 0x03, ZCODE_ROW = 0x03,
ZCODE_MEM_COPY = 0x04, ZCODE_04 = 0x04,
// Conditonal Codes // Conditonal Codes
CONDTIONAL_IF_EQUAL = 0x01, CONDTIONAL_IF_EQUAL = 0x01,
@ -227,16 +227,17 @@ void LogInfo(const char *format, ...)
void RunAllActive() void RunAllActive()
{ {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats) { if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats)
{
for (std::vector<ARCode>::iterator i = activeCodes.begin(); i != activeCodes.end(); ++i) for (std::vector<ARCode>::iterator i = activeCodes.begin(); i != activeCodes.end(); ++i)
{ {
if (i->active) if (i->active)
{ {
if (!RunCode(*i)) i->active = RunCode(*i);
i->active = false;
LogInfo("\n"); LogInfo("\n");
} }
} }
if (!b_RanOnce) if (!b_RanOnce)
b_RanOnce = true; b_RanOnce = true;
} }
@ -292,7 +293,8 @@ bool RunCode(const ARCode &arcode) {
LogInfo("Command: %08x", cmd); LogInfo("Command: %08x", cmd);
// Do Fill & Slide // Do Fill & Slide
if (doFillNSlide) { if (doFillNSlide)
{
doFillNSlide = false; doFillNSlide = false;
LogInfo("Doing Fill And Slide"); LogInfo("Doing Fill And Slide");
if (!ZeroCode_FillAndSlide(val_last, addr, data)) if (!ZeroCode_FillAndSlide(val_last, addr, data))
@ -301,7 +303,8 @@ bool RunCode(const ARCode &arcode) {
} }
// Memory Copy // Memory Copy
if (doMemoryCopy) { if (doMemoryCopy)
{
doMemoryCopy = false; doMemoryCopy = false;
LogInfo("Doing Memory Copy"); LogInfo("Doing Memory Copy");
if (!ZeroCode_MemoryCopy(val_last, addr, data)) if (!ZeroCode_MemoryCopy(val_last, addr, data))
@ -310,7 +313,8 @@ bool RunCode(const ARCode &arcode) {
} }
// ActionReplay program self modification codes // ActionReplay program self modification codes
if (addr >= 0x00002000 && addr < 0x00003000) { if (addr >= 0x00002000 && addr < 0x00003000)
{
LogInfo("This action replay simulator does not support codes that modify Action Replay itself."); LogInfo("This action replay simulator does not support codes that modify Action Replay itself.");
PanicAlert("This action replay simulator does not support codes that modify Action Replay itself."); PanicAlert("This action replay simulator does not support codes that modify Action Replay itself.");
return false; return false;
@ -339,7 +343,7 @@ bool RunCode(const ARCode &arcode) {
LogInfo("ZCode: Executes all codes in the same row, Set register 1BB4 to 1 (zcode not supported)"); LogInfo("ZCode: Executes all codes in the same row, Set register 1BB4 to 1 (zcode not supported)");
PanicAlert("Zero 3 code not supported"); PanicAlert("Zero 3 code not supported");
return false; return false;
case ZCODE_MEM_COPY: // Fill & Slide or Memory Copy case ZCODE_04: // Fill & Slide or Memory Copy
if (((addr >> 25) & 0x03) == 0x3) if (((addr >> 25) & 0x03) == 0x3)
{ {
LogInfo("ZCode: Memory Copy"); LogInfo("ZCode: Memory Copy");
@ -554,7 +558,7 @@ bool Subtype_WriteToPointer(u32 addr, u32 data)
bool Subtype_AddCode(u32 addr, u32 data) bool Subtype_AddCode(u32 addr, u32 data)
{ {
// Used to incrment a value in memory // Used to incrment a value in memory
u32 new_addr = (addr & 0x01FFFFFF) | 0x80000000; u32 new_addr = (addr & 0x81FFFFFF);
u8 size = (addr >> 25) & 0x03; u8 size = (addr >> 25) & 0x03;
LogInfo("Hardware Address: %08x", new_addr); LogInfo("Hardware Address: %08x", new_addr);
LogInfo("Size: %08x", size); LogInfo("Size: %08x", size);
@ -585,12 +589,15 @@ bool Subtype_AddCode(u32 addr, u32 data)
{ {
LogInfo("32-bit floating Add"); LogInfo("32-bit floating Add");
LogInfo("--------"); LogInfo("--------");
union conv {float x; u32 y;};
conv c1; u32 read = Memory::Read_U32(new_addr);
c1.y = Memory::Read_U32(new_addr); float fread = *((float*)&read);
c1.x += (float)data; fread += (float)data;
Memory::Write_U32((u32)c1.x, new_addr); u32 newval = *((u32*)&fread);
LogInfo("Wrote %08x to address %08x", (u32)c1.x, new_addr); Memory::Write_U32(newval, new_addr);
LogInfo("Old Value %08x", read);
LogInfo("Increment %08x", data);
LogInfo("New value %08x", newval);
LogInfo("--------"); LogInfo("--------");
break; break;
} }
@ -615,7 +622,7 @@ bool Subtype_MasterCodeAndWriteToCCXXXXXX(u32 addr, u32 data)
bool ZeroCode_FillAndSlide(u32 val_last, u32 addr, u32 data) // This needs more testing bool ZeroCode_FillAndSlide(u32 val_last, u32 addr, u32 data) // This needs more testing
{ {
u32 new_addr = (val_last & 0x01FFFFFF) | 0x80000000; u32 new_addr = (val_last & 0x81FFFFFF);
u8 size = (val_last >> 25) & 0x03; u8 size = (val_last >> 25) & 0x03;
s16 addr_incr = (s16)(data & 0xFFFF); s16 addr_incr = (s16)(data & 0xFFFF);
s8 val_incr = (s8)((data & 0xFF000000) >> 24); s8 val_incr = (s8)((data & 0xFF000000) >> 24);

View File

@ -235,8 +235,7 @@ void PatchEngineCallback(u64 userdata, int cyclesLate)
// Patch mem and run the Action Replay // Patch mem and run the Action Replay
PatchEngine::ApplyFramePatches(); PatchEngine::ApplyFramePatches();
PatchEngine::ApplyARPatches(); PatchEngine::ApplyARPatches();
CoreTiming::ScheduleEvent((CPU_CORE_CLOCK / 5000) - cyclesLate, et_PatchEngine);
CoreTiming::ScheduleEvent((GetTicksPerSecond() / 60) - cyclesLate, et_PatchEngine);
} }
void Init() void Init()

View File

@ -19,6 +19,7 @@
// Supports simple memory patches, and has a partial Action Replay implementation // Supports simple memory patches, and has a partial Action Replay implementation
// in ActionReplay.cpp/h. // in ActionReplay.cpp/h.
// TODO: Still even needed? Zelda WW now works with improved DSP code.
// Zelda item hang fixes: // Zelda item hang fixes:
// [Tue Aug 21 2007] [18:30:40] <Knuckles-> 0x802904b4 in US released // [Tue Aug 21 2007] [18:30:40] <Knuckles-> 0x802904b4 in US released
// [Tue Aug 21 2007] [18:30:53] <Knuckles-> 0x80294d54 in EUR Demo version // [Tue Aug 21 2007] [18:30:53] <Knuckles-> 0x80294d54 in EUR Demo version