diff --git a/Source/Core/Core/DSP/DSPCodeUtil.cpp b/Source/Core/Core/DSP/DSPCodeUtil.cpp index 3d9c2641ec..52261826c9 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.cpp +++ b/Source/Core/Core/DSP/DSPCodeUtil.cpp @@ -218,4 +218,44 @@ bool SaveBinary(const std::vector& code, const std::string& filename) return false; return true; } + +bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc) +{ + const std::string binFile = + StringFromFormat("%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc); + const std::string txtFile = + StringFromFormat("%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc); + + File::IOFile pFile(binFile, "wb"); + if (pFile) + { + pFile.WriteBytes(code_be, size_in_bytes); + pFile.Close(); + } + else + { + PanicAlert("Can't open file (%s) to dump UCode!!", binFile.c_str()); + return false; + } + + // Load the binary back in. + std::vector code; + LoadBinary(binFile, code); + + AssemblerSettings settings; + settings.show_hex = true; + settings.show_pc = true; + settings.ext_separator = '\''; + settings.decode_names = true; + settings.decode_registers = true; + + std::string text; + DSPDisassembler disasm(settings); + + if (!disasm.Disassemble(0, code, 0x0000, text)) + return false; + + return File::WriteStringToFile(text, txtFile); +} + } // namespace DSP diff --git a/Source/Core/Core/DSP/DSPCodeUtil.h b/Source/Core/Core/DSP/DSPCodeUtil.h index e3d0ee8c93..5fe8d64f30 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.h +++ b/Source/Core/Core/DSP/DSPCodeUtil.h @@ -27,4 +27,6 @@ void BinaryStringBEToCode(const std::string& str, std::vector& code); // Load code (big endian binary). bool LoadBinary(const std::string& filename, std::vector& code); bool SaveBinary(const std::vector& code, const std::string& filename); + +bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc); } // namespace DSP diff --git a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp index ec4202a538..b723705044 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp @@ -8,10 +8,10 @@ #include "Common/Logging/Log.h" #include "Core/ConfigManager.h" #include "Core/DSP/DSPAnalyzer.h" +#include "Core/DSP/DSPCodeUtil.h" #include "Core/DSP/DSPCore.h" #include "Core/DSP/Jit/DSPEmitter.h" #include "Core/HW/DSP.h" -#include "Core/HW/DSPLLE/DSPLLETools.h" #include "Core/HW/DSPLLE/DSPSymbols.h" #include "Core/Host.h" #include "VideoCommon/OnScreenDisplay.h" @@ -62,7 +62,7 @@ void CodeLoaded(const u8* ptr, int size) if (SConfig::GetInstance().m_DumpUCode) { - LLE::DumpDSPCode(ptr, size, g_dsp.iram_crc); + DSP::DumpDSPCode(ptr, size, g_dsp.iram_crc); } Symbols::Clear(); diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLETools.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLETools.cpp index 3e05628ab4..2675863c23 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLETools.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLETools.cpp @@ -23,45 +23,6 @@ namespace DSP { namespace LLE { -bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc) -{ - const std::string binFile = - StringFromFormat("%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc); - const std::string txtFile = - StringFromFormat("%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc); - - File::IOFile pFile(binFile, "wb"); - if (pFile) - { - pFile.WriteBytes(code_be, size_in_bytes); - pFile.Close(); - } - else - { - PanicAlert("Can't open file (%s) to dump UCode!!", binFile.c_str()); - return false; - } - - // Load the binary back in. - std::vector code; - LoadBinary(binFile, code); - - AssemblerSettings settings; - settings.show_hex = true; - settings.show_pc = true; - settings.ext_separator = '\''; - settings.decode_names = true; - settings.decode_registers = true; - - std::string text; - DSPDisassembler disasm(settings); - - if (!disasm.Disassemble(0, code, 0x0000, text)) - return false; - - return File::WriteStringToFile(text, txtFile); -} - // TODO make this useful :p bool DumpCWCode(u32 _Address, u32 _Length) { diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLETools.h b/Source/Core/Core/HW/DSPLLE/DSPLLETools.h index 4890f47dd9..03c2a5776e 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLETools.h +++ b/Source/Core/Core/HW/DSPLLE/DSPLLETools.h @@ -10,7 +10,6 @@ namespace DSP { namespace LLE { -bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc); bool DumpCWCode(u32 _Address, u32 _Length); } // namespace DSP } // namespace LLE