From b200cd9b73900f1ee8921a6b9624c2d8be8f6aef Mon Sep 17 00:00:00 2001 From: John Peterson Date: Fri, 3 Oct 2008 01:31:11 +0000 Subject: [PATCH] Made the debugger automatically get the PB address. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@751 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj | 6 +- Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp | 36 +++++++- Source/Plugins/Plugin_DSP_LLE/Src/Globals.h | 3 + .../Plugin_DSP_LLE/Src/Logging/AXTask.cpp | 83 +++++++++++++++++++ .../Plugin_DSP_LLE/Src/Logging/Console.cpp | 2 +- .../Plugin_DSP_LLE/Src/Logging/ReadPBs.cpp | 7 +- Source/Plugins/Plugin_DSP_LLE/Src/main.cpp | 26 +++++- 7 files changed, 150 insertions(+), 13 deletions(-) create mode 100644 Source/Plugins/Plugin_DSP_LLE/Src/Logging/AXTask.cpp diff --git a/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj b/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj index 0aff2fc067..7c19a925f4 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj +++ b/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj @@ -1,7 +1,7 @@ + + diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp index 4f33b8fb78..edfbd6a491 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp @@ -15,10 +15,13 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include // I hope this doesn't break anything #include #include +#include "Common.h" // for Common::swap #include "Globals.h" +#include "gdsp_interpreter.h" // ======================================================================================= @@ -27,17 +30,24 @@ void DebugLog(const char* _fmt, ...) { #if defined(_DEBUG) || defined(DEBUGFAST) -/* char Msg[512]; +char Msg[512]; va_list ap; va_start( ap, _fmt ); vsprintf( Msg, _fmt, ap ); va_end( ap ); - OutputDebugString(Msg); + // Only show certain messages + std::string sMsg = Msg; + if(sMsg.find("Mail") != -1 || sMsg.find("AX") != -1) + // no match = -1 + { + OutputDebugString(Msg); + g_dspInitialize.pLog(Msg); + } + + - g_dspInitialize.pLog(Msg); - */ #endif } // ============= @@ -61,3 +71,21 @@ void ErrorLog(const char* _fmt, ...) } +// ======================================================================================= +// For PB address detection +// -------------- +u32 RAM_MASK = 0x1FFFFFF; + + +u16 Memory_Read_U16(u32 _uAddress) +{ + _uAddress &= RAM_MASK; + return Common::swap16(*(u16*)&g_dsp.cpu_ram[_uAddress]); +} + +u32 Memory_Read_U32(u32 _uAddress) +{ + _uAddress &= RAM_MASK; + return Common::swap32(*(u32*)&g_dsp.cpu_ram[_uAddress]); +} +// ============= \ No newline at end of file diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Globals.h b/Source/Plugins/Plugin_DSP_LLE/Src/Globals.h index 62d6c453dd..5626b9db5e 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Globals.h +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Globals.h @@ -61,5 +61,8 @@ typedef signed long long sint64; typedef const uint32 cuint32; +u16 Memory_Read_U16(u32 _uAddress); // For PB address detection +u32 Memory_Read_U32(u32 _uAddress); + #endif diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Logging/AXTask.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Logging/AXTask.cpp new file mode 100644 index 0000000000..02ffb487e7 --- /dev/null +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Logging/AXTask.cpp @@ -0,0 +1,83 @@ +#include "../Globals.h" +#include "Common.h" + + +extern u32 m_addressPBs; + + +// ======================================================================================= +// Get the parameter block location - Example SSBM: We get the addr 8049cf00, first we +// always get 0 and go to AXLIST_STUDIOADDR, then we end up at AXLIST_PBADDR. +// -------------- +bool AXTask(u32& _uMail) +{ + u32 uAddress = _uMail; + DebugLog("AXTask - ================================================================"); + DebugLog("AXTask - AXCommandList-Addr: 0x%08x", uAddress); + + bool bExecuteList = true; + + while (bExecuteList) + { + // --------------------------------------------------------------------------------------- + // SSBM: We get the addr 8049cf00, first we always get 0 + static int last_valid_command = 0; + u16 iCommand = Memory_Read_U16(uAddress); + uAddress += 2; + // --------------------------------------------------------------------------------------- + + switch (iCommand) + { + // --------------------------------------------------------------------------------------- + // ? + case 0: // AXLIST_STUDIOADDR: //00 + { + uAddress += 4; + DebugLog("AXLIST AXLIST_SBUFFER: %08x", uAddress); + } + break; + // --------------------------------------------------------------------------------------- + + + // --------------------------------------------------------------------------------------- + case 2: // AXLIST_PBADDR: // 02 + { + m_addressPBs = Memory_Read_U32(uAddress); + uAddress += 4; + DebugLog("AXLIST PB address: %08x", m_addressPBs); + bExecuteList = false; + } + break; + + // --------------------------------------------------------------------------------------- + case 7: // AXLIST_SBUFFER: // 7 + { + // Hopefully this is where in main ram to write. + uAddress += 4; + DebugLog("AXLIST AXLIST_SBUFFER: %08x", uAddress); + } + break; + + + + default: + { + // --------------------------------------------------------------------------------------- + // Stop the execution of this TaskList + DebugLog("AXLIST default: %08x", uAddress); + bExecuteList = false; + // --------------------------------------------------------------------------------------- + } + break; + } // end of switch + } + + DebugLog("AXTask - done, send resume"); + DebugLog("AXTask - ================================================================"); + + // now resume + return true; +} +// ======================================================================================= + + diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Logging/Console.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Logging/Console.cpp index 51051a8165..fbdcfd4199 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Logging/Console.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Logging/Console.cpp @@ -76,7 +76,7 @@ void ClearScreen(); int wprintf(char *fmt, ...) { #ifdef DEBUGG - char s[4000]; // WARNING: mind this value + char s[6000]; // WARNING: mind this value va_list argptr; int cnt; diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Logging/ReadPBs.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Logging/ReadPBs.cpp index acc7af84b8..b638aa1c14 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Logging/ReadPBs.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Logging/ReadPBs.cpp @@ -22,12 +22,9 @@ // ======================================================================================= -// TODO: make this automatic +// Externals // -------------- -//u32 m_addressPBs = 0x804a1a60; // SSBM (PAL) -//u32 m_addressPBs = 0x802798c0; // Baten -//u32 m_addressPBs = 0x80576d20; // Symphonia -u32 m_addressPBs = 0x80671d00; // Paper Mario +u32 m_addressPBs = 0; // -------------- extern u32 gLastBlock; // ============== diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp index 61470cc75e..4bc344f836 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp @@ -46,14 +46,23 @@ #include "ChunkFile.h" + +// ======================================================================================= +// Globals +// -------------- DSPInitialize g_dspInitialize; #define GDSP_MBOX_CPU 0 #define GDSP_MBOX_DSP 1 - uint32 g_LastDMAAddress = 0; uint32 g_LastDMASize = 0; + +extern u32 m_addressPBs; +bool AXTask(u32& _uMail); +// ============== + + #ifdef _WIN32 BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle DWORD dwReason, // reason called @@ -331,7 +340,20 @@ void DSP_WriteMailboxLow(bool _CPUMailbox, u16 _uLowMail) { gdsp_mbox_write_l(GDSP_MBOX_CPU, _uLowMail); - DebugLog("Write CPU Mail: 0x%08x (pc=0x%04x)\n", gdsp_mbox_peek(GDSP_MBOX_CPU), g_dsp.err_pc); + u32 uAddress = gdsp_mbox_peek(GDSP_MBOX_CPU); + u16 errpc = g_dsp.err_pc; + + DebugLog("Write CPU Mail: 0x%08x (pc=0x%04x)\n", uAddress, errpc); + + // --------------------------------------------------------------------------------------- + // I couldn't find any better way to detect the AX mails so this had to do. Please feel free + // to change it. + // -------------- + if ((errpc == 0x0054 || errpc == 0x0055) && m_addressPBs == 0) + { + DebugLog("AXTask ======== 0x%08x (pc=0x%04x)", uAddress, errpc); + AXTask(uAddress); + } } else {