DSP: cleanup DumpDSPCode and remove temp file write
This commit is contained in:
parent
59c863329d
commit
5f68a0dcdd
|
@ -10,6 +10,7 @@
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
#include "Common/Swap.h"
|
||||||
|
|
||||||
#include "Core/DSP/DSPAssembler.h"
|
#include "Core/DSP/DSPAssembler.h"
|
||||||
#include "Core/DSP/DSPCodeUtil.h"
|
#include "Core/DSP/DSPCodeUtil.h"
|
||||||
|
@ -221,41 +222,27 @@ bool SaveBinary(const std::vector<u16>& code, const std::string& filename)
|
||||||
|
|
||||||
bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc)
|
bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc)
|
||||||
{
|
{
|
||||||
const std::string binFile =
|
const std::string root_name =
|
||||||
StringFromFormat("%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc);
|
File::GetUserPath(D_DUMPDSP_IDX) + StringFromFormat("DSP_UC_%08X", crc);
|
||||||
const std::string txtFile =
|
const std::string binary_file = root_name + ".bin";
|
||||||
StringFromFormat("%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc);
|
const std::string text_file = root_name + ".txt";
|
||||||
|
|
||||||
File::IOFile pFile(binFile, "wb");
|
if (!File::IOFile(binary_file, "wb").WriteBytes(code_be, size_in_bytes))
|
||||||
if (pFile)
|
|
||||||
{
|
{
|
||||||
pFile.WriteBytes(code_be, size_in_bytes);
|
PanicAlert("Can't dump UCode to file '%s'!!", binary_file.c_str());
|
||||||
pFile.Close();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PanicAlert("Can't open file (%s) to dump UCode!!", binFile.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the binary back in.
|
// The disassembler works in native endian
|
||||||
std::vector<u16> code;
|
std::vector<u16> code(size_in_bytes / 2);
|
||||||
LoadBinary(binFile, code);
|
for (size_t i = 0; i < code.size(); i++)
|
||||||
|
code[i] = Common::swap16(&code_be[i * 2]);
|
||||||
AssemblerSettings settings;
|
|
||||||
settings.show_hex = true;
|
|
||||||
settings.show_pc = true;
|
|
||||||
settings.ext_separator = '\'';
|
|
||||||
settings.decode_names = true;
|
|
||||||
settings.decode_registers = true;
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
DSPDisassembler disasm(settings);
|
if (!Disassemble(code, true, text))
|
||||||
|
|
||||||
if (!disasm.Disassemble(0, code, 0x0000, text))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return File::WriteStringToFile(text, txtFile);
|
return File::WriteStringToFile(text, text_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace DSP
|
} // namespace DSP
|
||||||
|
|
Loading…
Reference in New Issue