Some work on listconfig and friends. First of all, it's now only enabled

for single-bank ROMs, same as disassembly (since the underlying framework
has been modified).  Second, it now actually works :)  I can't see how it
worked before, and since I didn't get any complaints/reports, I really have
to question how much use this code actually gets.

Still TODO is fix errors in CODE vs. PCODE (preliminary code) (in
the Distella code, we should clearly mark the difference).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2735 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-05-16 22:05:14 +00:00
parent f533fcad34
commit a5bdbaf997
2 changed files with 54 additions and 31 deletions

View File

@ -694,6 +694,9 @@ string CartDebug::loadSymbolFile()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartDebug::loadConfigFile()
{
if(myConsole.cartridge().bankCount() > 1)
return DebuggerParser::red("multi-bank ROM not yet supported");
// There are two possible locations for loading config files
// (in order of decreasing relevance):
// 1) ROM dir based on properties entry name
@ -805,6 +808,9 @@ string CartDebug::loadConfigFile()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartDebug::saveConfigFile()
{
if(myConsole.cartridge().bankCount() > 1)
return DebuggerParser::red("multi-bank ROM not yet supported");
// While there are two possible locations for loading config files,
// the main 'config' directory is used whenever possible when saving,
// unless the rom-specific file already exists
@ -991,6 +997,9 @@ string CartDebug::saveRom()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartDebug::listConfig(int bank)
{
if(myConsole.cartridge().bankCount() > 1)
return DebuggerParser::red("multi-bank ROM not yet supported");
uInt32 startbank = 0, endbank = bankCount();
if(bank >= 0 && bank < bankCount())
{
@ -1115,46 +1124,33 @@ CartDebug::AddrType CartDebug::addressType(uInt16 addr) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::getBankDirectives(ostream& buf, BankInfo& info) const
{
// Disassemble the bank, then scan it for an up-to-date description
DisassemblyList list;
DiStella distella(*this, list, info, DiStella::settings,
(uInt8*)myDisLabels, (uInt8*)myDisDirectives,
(ReservedEquates&)myReserved, true);
if(list.size() == 0)
return;
// Start with the offset for this bank
buf << "ORG " << HEX4 << info.offset << endl;
DisasmType type = list[0].type;
uInt16 start = list[0].address, last = list[1].address;
if(start == 0) start = info.offset;
for(uInt32 i = 1; i < list.size(); ++i)
// Now consider each byte
uInt32 prev = info.offset, addr = prev + 1;
DisasmType prevType = disasmTypeAbsolute(mySystem.getAccessFlags(prev));
for( ; addr < info.offset + info.size; ++addr)
{
const DisassemblyTag& tag = list[i];
DisasmType currType = disasmTypeAbsolute(mySystem.getAccessFlags(addr));
if(tag.type == CartDebug::NONE)
continue;
else if(tag.type != type) // new range has started
// Have we changed to a new type?
if(currType != prevType)
{
// If switching data ranges, make sure the endpoint is valid
// This is necessary because DATA sections don't always generate
// consecutive numbers/addresses for the range
last = tag.address - 1;
disasmTypeAsString(buf, prevType);
buf << " " << HEX4 << prev << " " << HEX4 << (addr-1) << endl;
disasmTypeAsString(buf, type);
buf << " " << HEX4 << start << " " << HEX4 << last << endl;
type = tag.type;
start = last = tag.address;
prev = addr;
prevType = currType;
}
else
last = tag.address;
}
// Grab the last directive, making sure it accounts for all remaining space
disasmTypeAsString(buf, type);
buf << " " << HEX4 << start << " " << HEX4 << (info.offset+info.end) << endl;
if(prev != addr)
{
disasmTypeAsString(buf, prevType);
buf << " " << HEX4 << prev << " " << HEX4 << (addr-1) << endl;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1179,12 +1175,33 @@ void CartDebug::addressTypeAsString(ostream& buf, uInt16 addr) const
buf << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmType CartDebug::disasmTypeAbsolute(uInt8 flags) const
{
if(flags & CartDebug::CODE)
return CartDebug::CODE;
else if(flags & CartDebug::PCODE)
return CartDebug::PCODE;
else if(flags & CartDebug::GFX)
return CartDebug::GFX;
else if(flags & CartDebug::PGFX)
return CartDebug::PGFX;
else if(flags & CartDebug::DATA)
return CartDebug::DATA;
else if(flags & CartDebug::ROW)
return CartDebug::ROW;
else
return CartDebug::NONE;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::disasmTypeAsString(ostream& buf, DisasmType type) const
{
switch(type)
{
case CartDebug::CODE: buf << "CODE"; break;
case CartDebug::PCODE: buf << "PCODE"; break;
case CartDebug::GFX: buf << "GFX"; break;
case CartDebug::PGFX: buf << "PGFX"; break;
case CartDebug::DATA: buf << "DATA"; break;
@ -1202,6 +1219,8 @@ void CartDebug::disasmTypeAsString(ostream& buf, uInt8 flags) const
{
if(flags & CartDebug::CODE)
buf << "CODE ";
if(flags & CartDebug::PCODE)
buf << "PCODE ";
if(flags & CartDebug::GFX)
buf << "GFX ";
if(flags & CartDebug::PGFX)

View File

@ -67,7 +67,8 @@ class CartDebug : public DebuggerSystem
// debugger, or specified in a Distella cfg file, and are listed in order
// of decreasing hierarchy
//
CODE = 1 << 6, // disassemble-able code segments
CODE = 1 << 7, // disassemble-able code segments
PCODE = 1 << 6, // (preliminary) disassemble-able code segments
GFX = 1 << 5, // addresses loaded into GRPx registers
PGFX = 1 << 4, // addresses loaded into PFx registers
DATA = 1 << 3, // addresses loaded into registers other than GRPx / PFx
@ -319,6 +320,9 @@ class CartDebug : public DebuggerSystem
// based on its disassembly
void getBankDirectives(ostream& buf, BankInfo& info) const;
// Get disassembly enum type from 'flags', taking precendence into account
DisasmType disasmTypeAbsolute(uInt8 flags) const;
// Convert disassembly enum type to corresponding string and append to buf
void disasmTypeAsString(ostream& buf, DisasmType type) const;