When patching code in the disassembly list, the current base is now used.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2755 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-06-23 00:22:16 +00:00
parent 98886f8850
commit f5ed7ccf5c
5 changed files with 57 additions and 27 deletions

View File

@ -26,7 +26,8 @@
accurate. It also automatically differentiates between
CODE/PGFX/GFX/DATA/ROW areas, whereas normal Distella
only differentiates between CODE/GFX/ROW. For now, only
single-bank (4K and smaller) ROMs are supported.
single-bank (4K and smaller) ROMs are supported; support for
multi-bank ROMs will come in a future release.
- The disassembly now recognizes various TIA/RIOT read/write
mirrors, and marks them as such (for example, INPT4|$30 instead
@ -38,6 +39,9 @@
256 byte ROM will show only 256 bytes in the disassembly, instead
of padding duplicated data to 2K boundary.
- Fixed bug when entering patched bytes; the current number base
wasn't being used.
- Fixed labelling in ROW directives; it wasn't accurately setting
a label in the case where it occurred in the middle of the data.

View File

@ -19,6 +19,7 @@
#include "bspf.hxx"
#include "Debugger.hxx"
#include "DiStella.hxx"
#include "PackedBitArray.hxx"
#include "Widget.hxx"
#include "ScrollBarWidget.hxx"
@ -392,8 +393,8 @@ void RomListWidget::handleCommand(CommandSender* sender, int cmd, int data, int
case kCheckActionCmd:
// We let the parent class handle this
// Pass it as a kRLBreakpointChangedCmd command, since that's the intent
sendCommand(RomListWidget::kBPointChangedCmd,
myCheckList[id]->getState(), _currentPos+id);
sendCommand(RomListWidget::kBPointChangedCmd, _currentPos+id,
myCheckList[id]->getState());
break;
case kSetPositionCmd:
@ -552,15 +553,34 @@ GUI::Rect RomListWidget::getEditRect() const
bool RomListWidget::tryInsertChar(char c, int pos)
{
// Not sure how efficient this is, or should we even care?
bool insert = false;
c = tolower(c);
if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
c == '\\' || c == '#' || c == '$' || c == ' ')
switch(_base)
{
_editString.insert(pos, 1, c);
return true;
case kBASE_16:
case kBASE_16_1:
case kBASE_16_2:
case kBASE_16_4:
case kBASE_16_8:
insert = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || c == ' ';
break;
case kBASE_2:
case kBASE_2_8:
case kBASE_2_16:
insert = c == '0' || c == '1' || c == ' ';
break;
case kBASE_10:
if((c >= '0' && c <= '9') || c == ' ')
insert = true;
break;
case kBASE_DEFAULT:
break;
}
else
return false;
if(insert)
_editString.insert(pos, 1, c);
return insert;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -573,6 +593,15 @@ void RomListWidget::startEditMode()
return;
_editMode = true;
switch(myDisasm->list[_selectedItem].type)
{
case CartDebug::GFX:
case CartDebug::PGFX:
_base = DiStella::settings.gfx_format;
break;
default:
_base = instance().debugger().parser().base();
}
// Widget gets raw data while editing
EditableWidget::startEditMode();
@ -589,7 +618,7 @@ void RomListWidget::endEditMode()
// Send a message that editing finished with a return/enter key press
// The parent then calls getText() to get the newly entered data
_editMode = false;
sendCommand(RomListWidget::kRomChangedCmd, _selectedItem, _id);
sendCommand(RomListWidget::kRomChangedCmd, _selectedItem, _base);
// Reset to normal data entry
EditableWidget::endEditMode();

View File

@ -27,6 +27,7 @@ class CheckListWidget;
#include "Array.hxx"
#include "CartDebug.hxx"
#include "DebuggerParser.hxx"
#include "EditableWidget.hxx"
/** RomListWidget */
@ -34,8 +35,10 @@ class RomListWidget : public EditableWidget
{
public:
enum {
kBPointChangedCmd = 'RLbp', // click on the checkbox for a breakpoint
kBPointChangedCmd = 'RLbp', // 'data' will be disassembly line number,
// 'id' will be the checkbox state
kRomChangedCmd = 'RLpr', // 'data' will be disassembly line number
// 'id' will be the BaseFormat of the data
kSetPCCmd = 'STpc', // 'data' will be disassembly line number
kRuntoPCCmd = 'RTpc', // 'data' will be disassembly line number
kDisassembleCmd = 'REds',
@ -99,6 +102,7 @@ class RomListWidget : public EditableWidget
int _selectedItem;
int _highlightedItem;
bool _editMode;
BaseFormat _base; // base used during editing
StellaKey _currentKeyDown;
const CartDebug::Disassembly* myDisasm;

View File

@ -20,7 +20,6 @@
#include <sstream>
#include "Debugger.hxx"
#include "DebuggerParser.hxx"
#include "CartDebug.hxx"
#include "DiStella.hxx"
#include "CpuDebug.hxx"
@ -101,9 +100,9 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
switch(cmd)
{
case RomListWidget::kBPointChangedCmd:
// 'id' is the line in the disassemblylist to be accessed
// 'data' is the state of the breakpoint at 'id'
setBreak(id, data);
// 'data' is the line in the disassemblylist to be accessed
// 'id' is the state of the breakpoint at 'data'
setBreak(data, id);
// Refresh the romlist, since the breakpoint may not have
// actually changed
myRomList->setDirty();
@ -112,7 +111,8 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case RomListWidget::kRomChangedCmd:
// 'data' is the line in the disassemblylist to be accessed
patchROM(data, myRomList->getText());
// 'id' is the base to use for the data to be changed
patchROM(data, myRomList->getText(), (BaseFormat)id);
break;
case RomListWidget::kSetPCCmd:
@ -214,7 +214,7 @@ void RomWidget::runtoPC(int disasm_line)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomWidget::patchROM(int disasm_line, const string& bytes)
void RomWidget::patchROM(int disasm_line, const string& bytes, BaseFormat base)
{
const CartDebug::DisassemblyList& list =
instance().debugger().cartDebug().disassembly().list;
@ -227,11 +227,8 @@ void RomWidget::patchROM(int disasm_line, const string& bytes)
// Temporarily set to correct base, so we don't have to prefix each byte
// with the type of data
BaseFormat oldbase = instance().debugger().parser().base();
if(list[disasm_line].type == CartDebug::GFX)
instance().debugger().parser().setBase(DiStella::settings.gfx_format);
else
instance().debugger().parser().setBase(kBASE_16);
instance().debugger().parser().setBase(base);
command << "rom #" << list[disasm_line].address << " " << bytes;
instance().debugger().run(command.str());

View File

@ -24,6 +24,7 @@ class GuiObject;
class EditTextWidget;
#include "Command.hxx"
#include "DebuggerParser.hxx"
#include "RomListWidget.hxx"
class RomWidget : public Widget, public CommandSender
@ -46,15 +47,10 @@ class RomWidget : public Widget, public CommandSender
void loadConfig();
private:
enum {
kResolveDataChanged = 'ACrd',
kRomNameEntered = 'RWrn'
};
void setBreak(int disasm_line, bool state);
void setPC(int disasm_line);
void runtoPC(int disasm_line);
void patchROM(int disasm_line, const string& bytes);
void patchROM(int disasm_line, const string& bytes, BaseFormat base);
private:
RomListWidget* myRomList;