mirror of https://github.com/stella-emu/stella.git
added some minor refinements of RamWidget and CpuWidget
This commit is contained in:
parent
f4fdebb425
commit
71ed38855c
|
@ -43,7 +43,7 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
|
||||||
|
|
||||||
// Create a 1x1 grid with label for the PC register
|
// Create a 1x1 grid with label for the PC register
|
||||||
xpos = x; ypos = y; lwidth = 4 * fontWidth;
|
xpos = x; ypos = y; lwidth = 4 * fontWidth;
|
||||||
new StaticTextWidget(boss, lfont, xpos, ypos+1, lwidth-2, fontHeight,
|
new StaticTextWidget(boss, lfont, xpos, ypos + 2, lwidth-2, fontHeight,
|
||||||
"PC ", TextAlign::Left);
|
"PC ", TextAlign::Left);
|
||||||
myPCGrid =
|
myPCGrid =
|
||||||
new DataGridWidget(boss, nfont, xpos + lwidth, ypos, 1, 1, 4, 16, Common::Base::Fmt::_16);
|
new DataGridWidget(boss, nfont, xpos + lwidth, ypos, 1, 1, 4, 16, Common::Base::Fmt::_16);
|
||||||
|
@ -66,14 +66,14 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
|
||||||
addFocusWidget(myCpuGrid);
|
addFocusWidget(myCpuGrid);
|
||||||
|
|
||||||
// Create a 1x4 grid with decimal and binary values for the other CPU registers
|
// Create a 1x4 grid with decimal and binary values for the other CPU registers
|
||||||
xpos = x + lwidth + myPCGrid->getWidth() + 10;
|
xpos = myPCGrid->getRight() + 10;
|
||||||
myCpuGridDecValue =
|
myCpuGridDecValue =
|
||||||
new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 3, 8, Common::Base::Fmt::_10);
|
new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 3, 8, Common::Base::Fmt::_10);
|
||||||
myCpuGridDecValue->setTarget(this);
|
myCpuGridDecValue->setTarget(this);
|
||||||
myCpuGridDecValue->setID(kCpuRegDecID);
|
myCpuGridDecValue->setID(kCpuRegDecID);
|
||||||
addFocusWidget(myCpuGridDecValue);
|
addFocusWidget(myCpuGridDecValue);
|
||||||
|
|
||||||
xpos += myCpuGridDecValue->getWidth() + 5;
|
xpos = myCpuGridDecValue->getRight() + fontWidth * 2;
|
||||||
myCpuGridBinValue =
|
myCpuGridBinValue =
|
||||||
new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 8, 8, Common::Base::Fmt::_2);
|
new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 8, 8, Common::Base::Fmt::_2);
|
||||||
myCpuGridBinValue->setTarget(this);
|
myCpuGridBinValue->setTarget(this);
|
||||||
|
@ -104,14 +104,25 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
|
||||||
const std::array<string, 4> labels = { "SP ", "A ", "X ", "Y " };
|
const std::array<string, 4> labels = { "SP ", "A ", "X ", "Y " };
|
||||||
for(int row = 0; row < 4; ++row)
|
for(int row = 0; row < 4; ++row)
|
||||||
{
|
{
|
||||||
new StaticTextWidget(boss, lfont, xpos, ypos + row*lineHeight + 1,
|
new StaticTextWidget(boss, lfont, xpos, ypos + row*lineHeight + 2,
|
||||||
lwidth-2, fontHeight,
|
lwidth-2, fontHeight,
|
||||||
labels[row], TextAlign::Left);
|
labels[row], TextAlign::Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add prefixes for decimal and binary values
|
||||||
|
for(int row = 0; row < 4; ++row)
|
||||||
|
{
|
||||||
|
new StaticTextWidget(boss, lfont, myCpuGridDecValue->getLeft() - fontWidth,
|
||||||
|
ypos + row * lineHeight + 2,
|
||||||
|
lwidth - 2, fontHeight, "#");
|
||||||
|
new StaticTextWidget(boss, lfont, myCpuGridBinValue->getLeft() - fontWidth,
|
||||||
|
ypos + row * lineHeight + 2,
|
||||||
|
lwidth - 2, fontHeight, "%");
|
||||||
|
}
|
||||||
|
|
||||||
// Create a bitfield widget for changing the processor status
|
// Create a bitfield widget for changing the processor status
|
||||||
xpos = x; ypos += 4*lineHeight + 2;
|
xpos = x; ypos += 4*lineHeight + 2;
|
||||||
new StaticTextWidget(boss, lfont, xpos, ypos+1, lwidth-2, fontHeight,
|
new StaticTextWidget(boss, lfont, xpos, ypos + 2, lwidth-2, fontHeight,
|
||||||
"PS ", TextAlign::Left);
|
"PS ", TextAlign::Left);
|
||||||
myPSRegister = new ToggleBitWidget(boss, nfont, xpos+lwidth, ypos, 8, 1);
|
myPSRegister = new ToggleBitWidget(boss, nfont, xpos+lwidth, ypos, 8, 1);
|
||||||
myPSRegister->setTarget(this);
|
myPSRegister->setTarget(this);
|
||||||
|
|
|
@ -69,6 +69,7 @@ class DataGridWidget : public EditableWidget
|
||||||
|
|
||||||
int getSelectedAddr() const { return _addrList[_selectedItem]; }
|
int getSelectedAddr() const { return _addrList[_selectedItem]; }
|
||||||
int getSelectedValue() const { return _valueList[_selectedItem]; }
|
int getSelectedValue() const { return _valueList[_selectedItem]; }
|
||||||
|
bool getSelectedChanged() const { return _changedList[_selectedItem]; }
|
||||||
|
|
||||||
void setRange(int lower, int upper);
|
void setRange(int lower, int upper);
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,16 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
|
||||||
myFontWidth(lfont.getMaxCharWidth()),
|
myFontWidth(lfont.getMaxCharWidth()),
|
||||||
myFontHeight(lfont.getFontHeight()),
|
myFontHeight(lfont.getFontHeight()),
|
||||||
myLineHeight(lfont.getLineHeight()),
|
myLineHeight(lfont.getLineHeight()),
|
||||||
myButtonHeight(myLineHeight + 4),
|
myButtonHeight(myLineHeight * 1.25),
|
||||||
myRamSize(ramsize),
|
myRamSize(ramsize),
|
||||||
myNumRows(numrows),
|
myNumRows(numrows),
|
||||||
myPageSize(pagesize)
|
myPageSize(pagesize)
|
||||||
{
|
{
|
||||||
const int bwidth = lfont.getStringWidth("Compare " + ELLIPSIS),
|
const int bwidth = lfont.getStringWidth("Compare " + ELLIPSIS),
|
||||||
bheight = myLineHeight + 2;
|
bheight = myLineHeight + 2;
|
||||||
const int VGAP = 4;
|
//const int VGAP = 4;
|
||||||
|
const int VGAP = myFontHeight / 4;
|
||||||
|
StaticTextWidget* s;
|
||||||
WidgetArray wid;
|
WidgetArray wid;
|
||||||
|
|
||||||
int ypos = y + myLineHeight;
|
int ypos = y + myLineHeight;
|
||||||
|
@ -54,7 +56,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
|
||||||
myRamGrid = new DataGridWidget(_boss, _nfont, xpos, ypos,
|
myRamGrid = new DataGridWidget(_boss, _nfont, xpos, ypos,
|
||||||
16, myNumRows, 2, 8, Common::Base::Fmt::_16, true);
|
16, myNumRows, 2, 8, Common::Base::Fmt::_16, true);
|
||||||
myRamGrid->setTarget(this);
|
myRamGrid->setTarget(this);
|
||||||
myRamGrid->setID(kRamHexID);
|
myRamGrid->setID(kRamGridID);
|
||||||
addFocusWidget(myRamGrid);
|
addFocusWidget(myRamGrid);
|
||||||
|
|
||||||
// Create actions buttons to the left of the RAM grid
|
// Create actions buttons to the left of the RAM grid
|
||||||
|
@ -119,35 +121,44 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
|
||||||
|
|
||||||
// For smaller grids, make sure RAM cell detail fields are below the RESET button
|
// For smaller grids, make sure RAM cell detail fields are below the RESET button
|
||||||
row = myNumRows < 8 ? 9 : myNumRows + 1;
|
row = myNumRows < 8 ? 9 : myNumRows + 1;
|
||||||
ypos += row * myLineHeight;
|
ypos += (row - 1) * myLineHeight + VGAP * 2;
|
||||||
|
|
||||||
// We need to define these widgets from right to left since the leftmost
|
// We need to define these widgets from right to left since the leftmost
|
||||||
// one resizes as much as possible
|
// one resizes as much as possible
|
||||||
|
|
||||||
// Add Binary display of selected RAM cell
|
// Add Binary display of selected RAM cell
|
||||||
xpos = x + w - 11*myFontWidth - 22;
|
xpos = x + w - 9.6 * myFontWidth - 9;
|
||||||
new StaticTextWidget(boss, lfont, xpos, ypos, "Bin");
|
s = new StaticTextWidget(boss, lfont, xpos, ypos, "%");
|
||||||
myBinValue = new DataGridWidget(boss, nfont, xpos + 3*myFontWidth + 5, ypos-2,
|
myBinValue = new DataGridWidget(boss, nfont, s->getRight() + myFontWidth * 0.1, ypos-2,
|
||||||
1, 1, 8, 8, Common::Base::Fmt::_2);
|
1, 1, 8, 8, Common::Base::Fmt::_2);
|
||||||
myBinValue->setTarget(this);
|
myBinValue->setTarget(this);
|
||||||
myBinValue->setID(kRamBinID);
|
myBinValue->setID(kRamBinID);
|
||||||
|
|
||||||
// Add Decimal display of selected RAM cell
|
// Add Decimal display of selected RAM cell
|
||||||
xpos -= 7*myFontWidth + 5 + 20;
|
xpos -= 6.5 * myFontWidth;
|
||||||
new StaticTextWidget(boss, lfont, xpos, ypos, "Dec");
|
s = new StaticTextWidget(boss, lfont, xpos, ypos, "#");
|
||||||
myDecValue = new DataGridWidget(boss, nfont, xpos + 3*myFontWidth + 5, ypos-2,
|
myDecValue = new DataGridWidget(boss, nfont, s->getRight(), ypos-2,
|
||||||
1, 1, 3, 8, Common::Base::Fmt::_10);
|
1, 1, 3, 8, Common::Base::Fmt::_10);
|
||||||
myDecValue->setTarget(this);
|
myDecValue->setTarget(this);
|
||||||
myDecValue->setID(kRamDecID);
|
myDecValue->setID(kRamDecID);
|
||||||
|
|
||||||
|
// Add Hex display of selected RAM cell
|
||||||
|
xpos -= 4.5 * myFontWidth;
|
||||||
|
//s = new StaticTextWidget(boss, lfont, xpos, ypos, "$");
|
||||||
|
myHexValue = new DataGridWidget(boss, nfont, xpos, ypos - 2,
|
||||||
|
1, 1, 2, 8, Common::Base::Fmt::_16);
|
||||||
|
myHexValue->setTarget(this);
|
||||||
|
myHexValue->setID(kRamHexID);
|
||||||
|
|
||||||
|
addFocusWidget(myHexValue);
|
||||||
addFocusWidget(myDecValue);
|
addFocusWidget(myDecValue);
|
||||||
addFocusWidget(myBinValue);
|
addFocusWidget(myBinValue);
|
||||||
|
|
||||||
// Add Label of selected RAM cell
|
// Add Label of selected RAM cell
|
||||||
int xpos_r = xpos - 20;
|
int xpos_r = xpos - myFontWidth * 1.5;
|
||||||
xpos = x;
|
xpos = x;
|
||||||
new StaticTextWidget(boss, lfont, xpos, ypos, "Label");
|
s = new StaticTextWidget(boss, lfont, xpos, ypos, "Label");
|
||||||
xpos += 5*myFontWidth + 5;
|
xpos = s->getRight() + myFontWidth / 2;
|
||||||
myLabel = new EditTextWidget(boss, nfont, xpos, ypos-2, xpos_r-xpos,
|
myLabel = new EditTextWidget(boss, nfont, xpos, ypos-2, xpos_r-xpos,
|
||||||
myLineHeight);
|
myLineHeight);
|
||||||
myLabel->setEditable(false, true);
|
myLabel->setEditable(false, true);
|
||||||
|
@ -184,11 +195,16 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
{
|
{
|
||||||
switch(id)
|
switch(id)
|
||||||
{
|
{
|
||||||
case kRamHexID:
|
case kRamGridID:
|
||||||
addr = myRamGrid->getSelectedAddr();
|
addr = myRamGrid->getSelectedAddr();
|
||||||
value = myRamGrid->getSelectedValue();
|
value = myRamGrid->getSelectedValue();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kRamHexID:
|
||||||
|
addr = myRamGrid->getSelectedAddr();
|
||||||
|
value = myHexValue->getSelectedValue();
|
||||||
|
break;
|
||||||
|
|
||||||
case kRamDecID:
|
case kRamDecID:
|
||||||
addr = myRamGrid->getSelectedAddr();
|
addr = myRamGrid->getSelectedAddr();
|
||||||
value = myDecValue->getSelectedValue();
|
value = myDecValue->getSelectedValue();
|
||||||
|
@ -210,6 +226,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
myUndoValue = oldval;
|
myUndoValue = oldval;
|
||||||
|
|
||||||
myRamGrid->setValueInternal(addr - myCurrentRamBank*myPageSize, value, true);
|
myRamGrid->setValueInternal(addr - myCurrentRamBank*myPageSize, value, true);
|
||||||
|
myHexValue->setValueInternal(0, value, true);
|
||||||
myDecValue->setValueInternal(0, value, true);
|
myDecValue->setValueInternal(0, value, true);
|
||||||
myBinValue->setValueInternal(0, value, true);
|
myBinValue->setValueInternal(0, value, true);
|
||||||
|
|
||||||
|
@ -222,10 +239,12 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
{
|
{
|
||||||
addr = myRamGrid->getSelectedAddr();
|
addr = myRamGrid->getSelectedAddr();
|
||||||
value = myRamGrid->getSelectedValue();
|
value = myRamGrid->getSelectedValue();
|
||||||
|
bool changed = myRamGrid->getSelectedChanged();
|
||||||
|
|
||||||
myLabel->setText(getLabel(addr));
|
myLabel->setText(getLabel(addr));
|
||||||
myDecValue->setValueInternal(0, value, false);
|
myHexValue->setValueInternal(0, value, changed);
|
||||||
myBinValue->setValueInternal(0, value, false);
|
myDecValue->setValueInternal(0, value, changed);
|
||||||
|
myBinValue->setValueInternal(0, value, changed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,6 +307,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
||||||
void RamWidget::setOpsWidget(DataGridOpsWidget* w)
|
void RamWidget::setOpsWidget(DataGridOpsWidget* w)
|
||||||
{
|
{
|
||||||
myRamGrid->setOpsWidget(w);
|
myRamGrid->setOpsWidget(w);
|
||||||
|
myHexValue->setOpsWidget(w);
|
||||||
myBinValue->setOpsWidget(w);
|
myBinValue->setOpsWidget(w);
|
||||||
myDecValue->setOpsWidget(w);
|
myDecValue->setOpsWidget(w);
|
||||||
}
|
}
|
||||||
|
@ -296,6 +316,13 @@ void RamWidget::setOpsWidget(DataGridOpsWidget* w)
|
||||||
void RamWidget::loadConfig()
|
void RamWidget::loadConfig()
|
||||||
{
|
{
|
||||||
fillGrid(true);
|
fillGrid(true);
|
||||||
|
|
||||||
|
int value = myRamGrid->getSelectedValue();
|
||||||
|
bool changed = myRamGrid->getSelectedChanged();
|
||||||
|
|
||||||
|
myHexValue->setValueInternal(0, value, changed);
|
||||||
|
myDecValue->setValueInternal(0, value, changed);
|
||||||
|
myBinValue->setValueInternal(0, value, changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -79,8 +79,10 @@ class RamWidget : public Widget, public CommandSender
|
||||||
kRestartCmd = 'RWrs',
|
kRestartCmd = 'RWrs',
|
||||||
kSValEntered = 'RWsv',
|
kSValEntered = 'RWsv',
|
||||||
kCValEntered = 'RWcv',
|
kCValEntered = 'RWcv',
|
||||||
|
kRamGridID,
|
||||||
kRamHexID,
|
kRamHexID,
|
||||||
kRamDecID,
|
kRamDecID,
|
||||||
|
kRamSignID,
|
||||||
kRamBinID
|
kRamBinID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,7 +98,9 @@ class RamWidget : public Widget, public CommandSender
|
||||||
std::array<StaticTextWidget*, 16> myRamLabels{nullptr};
|
std::array<StaticTextWidget*, 16> myRamLabels{nullptr};
|
||||||
|
|
||||||
DataGridWidget* myRamGrid{nullptr};
|
DataGridWidget* myRamGrid{nullptr};
|
||||||
|
DataGridWidget* myHexValue{nullptr};
|
||||||
DataGridWidget* myDecValue{nullptr};
|
DataGridWidget* myDecValue{nullptr};
|
||||||
|
DataGridWidget* mySignValue{nullptr};
|
||||||
DataGridWidget* myBinValue{nullptr};
|
DataGridWidget* myBinValue{nullptr};
|
||||||
EditTextWidget* myLabel{nullptr};
|
EditTextWidget* myLabel{nullptr};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue