DSP: Give the assembler and disassembler saner public APIs. Fix bug in fileutil ReadFileToString. More cleanup.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2970 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-04-14 22:30:31 +00:00
parent f9903f2054
commit d973a9e001
15 changed files with 193 additions and 288 deletions

View File

@ -45,7 +45,6 @@ bool DSPHost_Running()
u32 DSPHost_CodeLoaded(const u8 *ptr, int size)
{
u32 crc = GenerateCRC(ptr, size);
DumpDSPCode(ptr, size, crc);
return crc;
}

View File

@ -221,7 +221,7 @@ void DSPDebuggerLLE::RebuildDisAsmListView()
AssemblerSettings settings;
DSPDisassembler disasm(settings);
std::string op_str;
disasm.gd_dis_opcode(binbuf,&settings.pc, &op_str);
disasm.DisOpcode(binbuf, &settings.pc, &op_str);
const char* pParameter = NULL;
const char* pExtension = NULL;

View File

@ -21,58 +21,48 @@
#include "Common.h"
#include "Globals.h"
#include "FileUtil.h"
#include "DSPCodeUtil.h"
#include "Tools.h"
#include "disassemble.h"
#include "gdsp_interpreter.h"
bool DumpDSPCode(const u8 *data, u32 _Length, u32 crc)
{
char szFilename[MAX_PATH];
sprintf(szFilename, "%sDSP_UC_%08X.bin", FULL_DSP_DUMP_DIR, crc);
FILE* pFile = fopen(szFilename, "wb");
if (pFile)
{
fwrite(data, _Length, 1, pFile);
fclose(pFile);
}
else
{
PanicAlert("Cant open file (%s) to dump UCode!!", szFilename);
return false;
}
if (!DisasmUCodeDump(crc))
{
PanicAlert("Failed to disasm UCode!!", szFilename);
return false;
}
return true;
}
bool DisasmUCodeDump(u32 crc)
bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc)
{
char binFile[MAX_PATH];
char txtFile[MAX_PATH];
sprintf(binFile, "%sDSP_UC_%08X.bin", FULL_DSP_DUMP_DIR, crc);
sprintf(txtFile, "%sDSP_UC_%08X.txt", FULL_DSP_DUMP_DIR, crc);
FILE* t = fopen(txtFile, "wb");
if (t != NULL)
FILE* pFile = fopen(binFile, "wb");
if (pFile)
{
AssemblerSettings settings;
settings.show_hex = true;
settings.show_pc = true;
settings.ext_separator = '\t';
settings.decode_names = true;
settings.decode_registers = true;
DSPDisassembler disasm(settings);
disasm.gd_dis_file(binFile, t);
fclose(t);
return true;
fwrite(code_be, size_in_bytes, 1, pFile);
fclose(pFile);
}
else
{
PanicAlert("Cant open file (%s) to dump UCode!!", binFile);
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 = '\t';
settings.decode_names = true;
settings.decode_registers = true;
std::string text;
DSPDisassembler disasm(settings);
if (!disasm.Disassemble(0, code, &text))
return false;
return File::WriteStringToFile(true, text, txtFile);
}
u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength)

View File

@ -18,8 +18,7 @@
#ifndef _DSPLLE_TOOLS_H
#define _DSPLLE_TOOLS_H
bool DumpDSPCode(const u8 *data, u32 _Length, u32 crc);
bool DisasmUCodeDump(u32 crc);
bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc);
u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength);
bool DumpCWCode(u32 _Address, u32 _Length);