mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-04-11 23:00:18 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user