DSP: move DumpDSPCode from DSPLLETools to DSPCodeUtil
This code is useful outside of DSP-LLE, and I plan to modify DSP-HLE to use it in a future commit.
This commit is contained in:
parent
edb16cd399
commit
e4c779de0b
|
@ -218,4 +218,44 @@ bool SaveBinary(const std::vector<u16>& 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<u16> 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
|
||||
|
|
|
@ -27,4 +27,6 @@ void BinaryStringBEToCode(const std::string& str, std::vector<u16>& code);
|
|||
// Load code (big endian binary).
|
||||
bool LoadBinary(const std::string& filename, std::vector<u16>& code);
|
||||
bool SaveBinary(const std::vector<u16>& code, const std::string& filename);
|
||||
|
||||
bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc);
|
||||
} // namespace DSP
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<u16> 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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue