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:
Michael Maltese
2017-05-14 20:19:34 -07:00
parent edb16cd399
commit e4c779de0b
5 changed files with 44 additions and 42 deletions

View File

@@ -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