Merge pull request #6483 from ligfx/dspremoveannotatedassembly
DSP: remove old, unused ReadAnnotatedAssembly
This commit is contained in:
commit
716e4ba035
|
@ -66,57 +66,10 @@ void CodeLoaded(const u8* ptr, int size)
|
|||
DSP::DumpDSPCode(ptr, size, g_dsp.iram_crc);
|
||||
}
|
||||
|
||||
Symbols::Clear();
|
||||
|
||||
// Auto load text file - if none just disassemble.
|
||||
|
||||
NOTICE_LOG(DSPLLE, "g_dsp.iram_crc: %08x", g_dsp.iram_crc);
|
||||
|
||||
Symbols::Clear();
|
||||
bool success = false;
|
||||
switch (g_dsp.iram_crc)
|
||||
{
|
||||
case 0x86840740:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_Zelda.txt");
|
||||
break;
|
||||
case 0x42f64ac4:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_Luigi.txt");
|
||||
break;
|
||||
case 0x07f88145:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_07F88145.txt");
|
||||
break;
|
||||
case 0x3ad3b7ac:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_3AD3B7AC.txt");
|
||||
break;
|
||||
case 0x3daf59b9:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_3DAF59B9.txt");
|
||||
break;
|
||||
case 0x4e8a8b21:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_4E8A8B21.txt");
|
||||
break;
|
||||
case 0xe2136399:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_E2136399.txt");
|
||||
break;
|
||||
case 0xdd7e72d5:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_GBA.txt");
|
||||
break;
|
||||
case 0x347112BA:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AXWii.txt");
|
||||
break;
|
||||
case 0xD643001F:
|
||||
success = Symbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_SuperMarioGalaxy.txt");
|
||||
break;
|
||||
default:
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Symbols::AutoDisassembly(0x0, 0x1000);
|
||||
}
|
||||
|
||||
// Always add the ROM.
|
||||
Symbols::AutoDisassembly(0x0, 0x1000);
|
||||
Symbols::AutoDisassembly(0x8000, 0x9000);
|
||||
|
||||
UpdateDebugger();
|
||||
|
|
|
@ -78,141 +78,6 @@ Symbol* DSPSymbolDB::GetSymbolFromAddr(u32 addr)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool ReadAnnotatedAssembly(const std::string& filename)
|
||||
{
|
||||
File::IOFile f(filename, "r");
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
char line[512];
|
||||
|
||||
int last_addr = 0;
|
||||
|
||||
lines.reserve(3000);
|
||||
|
||||
// Symbol generation
|
||||
int brace_count = 0;
|
||||
bool symbol_in_progress = false;
|
||||
|
||||
int symbol_count = 0;
|
||||
Symbol current_symbol;
|
||||
|
||||
while (fgets(line, 512, f.GetHandle()))
|
||||
{
|
||||
// Scan string for the first 4-digit hex string.
|
||||
size_t len = strlen(line);
|
||||
int first_hex = -1;
|
||||
bool hex_found = false;
|
||||
for (unsigned int i = 0; i < strlen(line); i++)
|
||||
{
|
||||
const char c = line[i];
|
||||
if (isxdigit(c))
|
||||
{
|
||||
if (first_hex == -1)
|
||||
{
|
||||
first_hex = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove hex notation
|
||||
if ((int)i == first_hex + 3 && (first_hex == 0 || line[first_hex - 1] != 'x') &&
|
||||
(i >= len - 1 || line[i + 1] == ' '))
|
||||
{
|
||||
hex_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i - first_hex < 3)
|
||||
{
|
||||
first_hex = -1;
|
||||
}
|
||||
if (isalpha(c))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Scan for function starts
|
||||
if (!memcmp(line, "void", 4))
|
||||
{
|
||||
char temp[256];
|
||||
for (size_t i = 6; i < len; i++)
|
||||
{
|
||||
if (line[i] == '(')
|
||||
{
|
||||
// Yep, got one.
|
||||
memcpy(temp, line + 5, i - 5);
|
||||
temp[i - 5] = 0;
|
||||
|
||||
// Mark symbol so the next hex sets the address
|
||||
current_symbol.Rename(temp);
|
||||
current_symbol.address = 0xFFFF;
|
||||
current_symbol.index = symbol_count++;
|
||||
symbol_in_progress = true;
|
||||
|
||||
// Reset brace count.
|
||||
brace_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scan for braces
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
if (line[i] == '{')
|
||||
brace_count++;
|
||||
if (line[i] == '}')
|
||||
{
|
||||
brace_count--;
|
||||
if (brace_count == 0 && symbol_in_progress)
|
||||
{
|
||||
// Commit this symbol.
|
||||
current_symbol.size = last_addr - current_symbol.address + 1;
|
||||
g_dsp_symbol_db.AddCompleteSymbol(current_symbol);
|
||||
current_symbol.address = 0xFFFF;
|
||||
symbol_in_progress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hex_found)
|
||||
{
|
||||
int hex = 0;
|
||||
sscanf(line + first_hex, "%04x", &hex);
|
||||
|
||||
// Sanity check
|
||||
if (hex > last_addr + 3 || hex < last_addr - 3)
|
||||
{
|
||||
static int errors = 0;
|
||||
INFO_LOG(DSPLLE, "Got Insane Hex Digit %04x (%04x) from %s", hex, last_addr, line);
|
||||
errors++;
|
||||
if (errors > 10)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (line_counter >= 200 && line_counter <= 220)
|
||||
// NOTICE_LOG(DSPLLE, "Got Hex Digit %04x from %s, line %i", hex, line, line_counter);
|
||||
if (symbol_in_progress && current_symbol.address == 0xFFFF)
|
||||
current_symbol.address = hex;
|
||||
|
||||
line_to_addr[line_counter] = hex;
|
||||
addr_to_line[hex] = line_counter;
|
||||
last_addr = hex;
|
||||
}
|
||||
}
|
||||
|
||||
lines.push_back(TabsToSpaces(4, line));
|
||||
line_counter++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AutoDisassembly(u16 start_addr, u16 end_addr)
|
||||
{
|
||||
AssemblerSettings settings;
|
||||
|
|
|
@ -23,7 +23,6 @@ public:
|
|||
|
||||
extern DSPSymbolDB g_dsp_symbol_db;
|
||||
|
||||
bool ReadAnnotatedAssembly(const std::string& filename);
|
||||
void AutoDisassembly(u16 start_addr, u16 end_addr);
|
||||
|
||||
void Clear();
|
||||
|
|
Loading…
Reference in New Issue