CDF updates

* Implemented load/save state.
* Updated the debugger tab, which required the following:
   - removal of : from RAM labels (part of the debugger overhaul)
   - setCrossed() functionality in the DataGrid
This commit is contained in:
Darrell Spice, Jr 2017-04-30 11:01:27 -05:00
parent 47a2f66e11
commit 42c762ae92
9 changed files with 178 additions and 62 deletions

View File

@ -30,11 +30,11 @@ CartridgeCDFWidget::CartridgeCDFWidget(
uInt16 size = 8 * 4096;
ostringstream info;
info << "CDF Stuffing cartridge\n"
info << "CDF cartridge\n"
<< "32K ROM, seven 4K banks are accessible to 2600\n"
<< "8K CDF RAM\n"
<< "CDF registers accessible @ $F000 - $F03F\n"
<< "Banks accessible at hotspots $FF5 to $FFB\n"
<< "CDF registers accessible @ $FFF0 - $FFF3\n"
<< "Banks accessible at hotspots $FFF5 to $FFFB\n"
<< "Startup bank = " << cart.myStartBank << "\n";
#if 0
@ -53,45 +53,77 @@ CartridgeCDFWidget::CartridgeCDFWidget(
myLineHeight;
VariantList items;
VarList::push_back(items, "0 ($FF5)");
VarList::push_back(items, "1 ($FF6)");
VarList::push_back(items, "2 ($FF7)");
VarList::push_back(items, "3 ($FF8)");
VarList::push_back(items, "4 ($FF9)");
VarList::push_back(items, "5 ($FFA)");
VarList::push_back(items, "6 ($FFB)");
VarList::push_back(items, "0 ($FFF5)");
VarList::push_back(items, "1 ($FFF6)");
VarList::push_back(items, "2 ($FFF7)");
VarList::push_back(items, "3 ($FFF8)");
VarList::push_back(items, "4 ($FFF9)");
VarList::push_back(items, "5 ($FFFA)");
VarList::push_back(items, "6 ($FFFB)");
myBank =
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("0 ($FFx) "),
myLineHeight, items, "Set bank: ",
_font.getStringWidth("Set bank: "), kBankChanged);
myLineHeight, items, "Set bank ",
_font.getStringWidth("Set bank "), kBankChanged);
myBank->setTarget(this);
addFocusWidget(myBank);
int lwidth = _font.getStringWidth("Datastream Increments: "); // get width of the widest label
int lwidth = _font.getStringWidth("Datastream Increments"); // get width of the widest label
// Datastream Pointers
xpos = 0; ypos += myLineHeight + 4;
#define DS_X 30
xpos = DS_X;
ypos += myLineHeight + 4;
new StaticTextWidget(boss, _font, xpos, ypos, lwidth,
myFontHeight, "Datastream Pointers: ", kTextAlignLeft);
myFontHeight, "Datastream Pointers", kTextAlignLeft);
xpos += lwidth;
myDatastreamPointers = new DataGridWidget(boss, _nfont, 0, ypos+myLineHeight-2, 4, 8, 6, 32, Common::Base::F_16_3_2);
myDatastreamPointers = new DataGridWidget(boss, _nfont, DS_X, ypos+myLineHeight-2, 4, 8, 6, 32, Common::Base::F_16_3_2);
myDatastreamPointers->setTarget(this);
myDatastreamPointers->setEditable(false);
myDatastreamPointers2 = new DataGridWidget(boss, _nfont, DS_X + myDatastreamPointers->getWidth() * 3 / 4, ypos+myLineHeight-2 + 8*myLineHeight, 1, 2, 6, 32, Common::Base::F_16_3_2);
myDatastreamPointers2->setTarget(this);
myDatastreamPointers2->setEditable(false);
uInt32 row;
for(row = 0; row < 8; ++row)
{
myDatastreamLabels[row] =
new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "),
ypos+myLineHeight-2 + row*myLineHeight + 2,
myFontWidth*2, myFontHeight, "", kTextAlignLeft);
myDatastreamLabels[row]->setLabel(Common::Base::toString(row * 4, Common::Base::F_16_2));
}
lwidth = _font.getStringWidth("Write Data (stream 20)");
myDatastreamLabels[row] =
new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "),
ypos+myLineHeight-2 + 8*myLineHeight + 2,
lwidth, myFontHeight, "Write Data (stream 20)", kTextAlignLeft);
// myDatastreamLabels[row]->setLabel(Common::Base::toString(row * 4, Common::Base::F_16_2));
myDatastreamLabels[row] =
new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "),
ypos+myLineHeight-2 + 9*myLineHeight + 2,
lwidth, myFontHeight, "Jump Data (stream 21)", kTextAlignLeft);
// myDatastreamLabels[row]->setLabel(Common::Base::toString(row * 4, Common::Base::F_16_2));
// Datastream Increments
xpos = 0 + myDatastreamPointers->getWidth();
xpos = DS_X + myDatastreamPointers->getWidth() + 20;
new StaticTextWidget(boss, _font, xpos, ypos, lwidth,
myFontHeight, "Datastream Increments: ", kTextAlignLeft);
myFontHeight, "Datastream Increments", kTextAlignLeft);
myDatastreamIncrements = new DataGridWidget(boss, _nfont, xpos, ypos+myLineHeight-2, 4, 8, 5, 32, Common::Base::F_16_2_2);
myDatastreamIncrements->setTarget(this);
myDatastreamIncrements->setEditable(false);
myDatastreamIncrements2 = new DataGridWidget(boss, _nfont, xpos, ypos+myLineHeight-2 + 8*myLineHeight, 1, 2, 5, 32, Common::Base::F_16_2_2);
myDatastreamIncrements2->setTarget(this);
myDatastreamIncrements2->setEditable(false);
// Music counters
xpos = 10; ypos += myLineHeight*10 + 4;
xpos = 10; ypos += myLineHeight*12 + 4;
new StaticTextWidget(boss, _font, xpos, ypos, lwidth,
myFontHeight, "Music Counters: ", kTextAlignLeft);
myFontHeight, "Music Counters", kTextAlignLeft);
xpos += lwidth;
myMusicCounters = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 8, 32, Common::Base::F_16_8);
@ -101,7 +133,7 @@ CartridgeCDFWidget::CartridgeCDFWidget(
// Music frequencies
xpos = 10; ypos += myLineHeight + 4;
new StaticTextWidget(boss, _font, xpos, ypos, lwidth,
myFontHeight, "Music Frequencies: ", kTextAlignLeft);
myFontHeight, "Music Frequencies", kTextAlignLeft);
xpos += lwidth;
myMusicFrequencies = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 8, 32, Common::Base::F_16_8);
@ -111,33 +143,41 @@ CartridgeCDFWidget::CartridgeCDFWidget(
// Music waveforms
xpos = 10; ypos += myLineHeight + 4;
new StaticTextWidget(boss, _font, xpos, ypos, lwidth,
myFontHeight, "Music Waveforms: ", kTextAlignLeft);
myFontHeight, "Music Waveforms", kTextAlignLeft);
xpos += lwidth;
myMusicWaveforms = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 4, 16, Common::Base::F_16_2);
myMusicWaveforms->setTarget(this);
myMusicWaveforms->setEditable(false);
int xpossp = xpos + myMusicWaveforms->getWidth() + 20;
int lwidth2 = _font.getStringWidth("Sample Pointer ");
new StaticTextWidget(boss, _font, xpossp, ypos, lwidth2,
myFontHeight, "Sample Pointer ", kTextAlignLeft);
mySamplePointer = new DataGridWidget(boss, _nfont, xpossp + lwidth2, ypos-2, 1, 1, 8, 32, Common::Base::F_16_8);
mySamplePointer->setTarget(this);
mySamplePointer->setEditable(false);
// Music waveform sizes
xpos = 10; ypos += myLineHeight + 4;
new StaticTextWidget(boss, _font, xpos, ypos, lwidth,
myFontHeight, "Music Waveform Sizes: ", kTextAlignLeft);
myFontHeight, "Music Waveform Sizes", kTextAlignLeft);
xpos += lwidth;
myMusicWaveformSizes = new DataGridWidget(boss, _nfont, xpos, ypos-2, 3, 1, 4, 16, Common::Base::F_16_2);
myMusicWaveformSizes->setTarget(this);
myMusicWaveformSizes->setEditable(false);
// done differently than in DPC+, need to rethink debugger support
// // Fast fetch and immediate mode LDA flags
// xpos = 10; ypos += myLineHeight + 4;
// myFastFetch = new CheckboxWidget(boss, _font, xpos, ypos, "Fast Fetcher enabled");
// myFastFetch->setTarget(this);
// myFastFetch->setEditable(false);
// ypos += myLineHeight + 4;
// myIMLDA = new CheckboxWidget(boss, _font, xpos, ypos, "Immediate mode LDA");
// myIMLDA->setTarget(this);
// myIMLDA->setEditable(false);
// Fast Fetch and Digital Audio flags
xpos = 10; ypos += myLineHeight + 4;
myFastFetch = new CheckboxWidget(boss, _font, xpos, ypos, "Fast Fetcher enabled");
myFastFetch->setTarget(this);
myFastFetch->setEditable(false);
myDigitalSample = new CheckboxWidget(boss, _font, xpossp, ypos, "Digital Sample mode");
myDigitalSample->setTarget(this);
myDigitalSample->setEditable(false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -153,8 +193,9 @@ void CartridgeCDFWidget::saveOldState()
myOldState.mwaves.clear();
myOldState.mwavesizes.clear();
myOldState.internalram.clear();
myOldState.samplepointer.clear();
for(uInt32 i = 0; i < 32; i++)
for(uInt32 i = 0; i < 34; i++)
{
// Pointers are stored as:
// PPPFF---
@ -184,6 +225,8 @@ void CartridgeCDFWidget::saveOldState()
for(uInt32 i = 0; i < internalRamSize(); ++i)
myOldState.internalram.push_back(myCart.myCDFRAM[i]);
myOldState.samplepointer.push_back(myCart.getSample());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -215,6 +258,15 @@ void CartridgeCDFWidget::loadConfig()
}
myDatastreamPointers->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear();
for(int i = 32; i < 34; ++i)
{
Int32 pointervalue = myCart.getDatastreamPointer(i) >> 12;
alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreampointers[i]);
}
myDatastreamPointers2->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < 32; ++i)
{
@ -224,6 +276,15 @@ void CartridgeCDFWidget::loadConfig()
}
myDatastreamIncrements->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear();
for(int i = 32; i < 34; ++i)
{
Int32 incrementvalue = myCart.getDatastreamIncrement(i);
alist.push_back(0); vlist.push_back(incrementvalue);
changed.push_back(incrementvalue != myOldState.datastreamincrements[i]);
}
myDatastreamIncrements2->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < 3; ++i)
{
@ -256,9 +317,26 @@ void CartridgeCDFWidget::loadConfig()
}
myMusicWaveformSizes->setList(alist, vlist, changed);
// done differently than in DPC+, need to rethink debugger support
// myFastFetch->setState(myCart.myFastFetch);
// myIMLDA->setState(myCart.myLDAimmediate);
alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.getSample());
changed.push_back((myCart.getSample()) != uInt32(myOldState.samplepointer[0]));
mySamplePointer->setList(alist, vlist, changed);
myFastFetch->setState((myCart.myMode & 0x0f) == 0);
myDigitalSample->setState((myCart.myMode & 0xf0) == 0);
if ((myCart.myMode & 0xf0) == 0)
{
myMusicWaveforms->setCrossed(true);
myMusicWaveformSizes->setCrossed(true);
mySamplePointer->setCrossed(false);
}
else
{
myMusicWaveforms->setCrossed(false);
myMusicWaveformSizes->setCrossed(false);
mySamplePointer->setCrossed(true);
}
CartDebugWidget::loadConfig();
}

View File

@ -22,6 +22,7 @@ class CartridgeCDF;
class PopUpWidget;
class CheckboxWidget;
class DataGridWidget;
class StaticTextWidget;
#include "CartDebugWidget.hxx"
@ -45,6 +46,7 @@ class CartridgeCDFWidget : public CartDebugWidget
IntArray mfreqs;
IntArray mwaves;
IntArray mwavesizes;
IntArray samplepointer;
uInt32 random;
ByteArray internalram;
};
@ -54,13 +56,18 @@ class CartridgeCDFWidget : public CartDebugWidget
DataGridWidget* myDatastreamPointers;
DataGridWidget* myDatastreamIncrements;
DataGridWidget* myDatastreamPointers2;
DataGridWidget* myDatastreamIncrements2;
DataGridWidget* myMusicCounters;
DataGridWidget* myMusicFrequencies;
DataGridWidget* myMusicWaveforms;
DataGridWidget* myMusicWaveformSizes;
DataGridWidget* mySamplePointer;
StaticTextWidget* myDatastreamLabels[10];
// done differently than in DPC+, need to rethink debugger support
// CheckboxWidget* myFastFetch;
// CheckboxWidget* myIMLDA;
CheckboxWidget* myFastFetch;
CheckboxWidget* myDigitalSample;
CartState myOldState;
enum { kBankChanged = 'bkCH' };

View File

@ -52,7 +52,7 @@ class CartDebugWidget : public Widget, public CommandSender
int addBaseInformation(int bytes, const string& manufacturer,
const string& desc, const uInt16 maxlines = 10)
{
const int lwidth = _font.getStringWidth("Manufacturer: "),
const int lwidth = _font.getStringWidth("Manufacturer "),
fwidth = _w - lwidth - 20;
EditTextWidget* w = nullptr;
ostringstream buf;
@ -61,7 +61,7 @@ class CartDebugWidget : public Widget, public CommandSender
// Add ROM size, manufacturer and bankswitch info
new StaticTextWidget(_boss, _font, x, y, lwidth,
myFontHeight, "ROM Size: ", kTextAlignLeft);
myFontHeight, "ROM Size ", kTextAlignLeft);
buf << bytes << " bytes";
if(bytes >= 1024)
buf << " / " << (bytes/1024) << "KB";
@ -72,7 +72,7 @@ class CartDebugWidget : public Widget, public CommandSender
y += myLineHeight + 4;
new StaticTextWidget(_boss, _font, x, y, lwidth,
myFontHeight, "Manufacturer: ", kTextAlignLeft);
myFontHeight, "Manufacturer ", kTextAlignLeft);
w = new EditTextWidget(_boss, _nfont, x+lwidth, y,
fwidth, myLineHeight, manufacturer);
w->setEditable(false);
@ -85,7 +85,7 @@ class CartDebugWidget : public Widget, public CommandSender
if(lines > maxlines) lines = maxlines;
new StaticTextWidget(_boss, _font, x, y, lwidth,
myFontHeight, "Description: ", kTextAlignLeft);
myFontHeight, "Description ", kTextAlignLeft);
myDesc = new StringListWidget(_boss, _nfont, x+lwidth, y,
fwidth, lines * myLineHeight, false);
myDesc->setEditable(false);

View File

@ -35,7 +35,7 @@ CartRamWidget::CartRamWidget(
myLineHeight(lfont.getLineHeight()),
myButtonHeight(myLineHeight + 4)
{
int lwidth = lfont.getStringWidth("Description: "),
int lwidth = lfont.getStringWidth("Description "),
fwidth = w - lwidth - 20;
EditTextWidget* etw = nullptr;
@ -44,7 +44,7 @@ CartRamWidget::CartRamWidget(
// Add RAM size
new StaticTextWidget(_boss, _font, xpos, ypos, lwidth,
myFontHeight, "RAM Size: ", kTextAlignLeft);
myFontHeight, "RAM Size ", kTextAlignLeft);
uInt32 ramsize = cartDebug.internalRamSize();
buf << ramsize << " bytes";
@ -66,7 +66,7 @@ CartRamWidget::CartRamWidget(
if(lines > maxlines) lines = maxlines;
new StaticTextWidget(_boss, _font, xpos, ypos, lwidth,
myFontHeight, "Description: ", kTextAlignLeft);
myFontHeight, "Description ", kTextAlignLeft);
myDesc = new StringListWidget(boss, nfont, xpos+lwidth, ypos,
fwidth, lines * myLineHeight, false);
myDesc->setEditable(false);

View File

@ -41,6 +41,7 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font,
_rowHeight(font.getLineHeight()),
_colWidth(colchars * font.getMaxCharWidth() + 8),
_bits(bits),
_crossGrid(false),
_base(base),
_selectedItem(0),
_currentKeyDown(KBDK_UNKNOWN),
@ -635,6 +636,11 @@ void DataGridWidget::drawWidget(bool hilite)
// Draw the scrollbar
if(_scrollBar)
_scrollBar->recalc(); // takes care of the draw
// Cross out the grid?
if (_crossGrid)
for (row = 0; row < 4; ++row)
s.hLine(_x, _y + (row * lineheight/4), _x + linewidth, kColor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -81,6 +81,8 @@ class DataGridWidget : public EditableWidget
int colWidth() { return _colWidth; }
void setOpsWidget(DataGridOpsWidget* w) { _opsWidget = w; }
void setCrossed(bool enable) { _crossGrid = enable; }
protected:
void drawWidget(bool hilite) override;
@ -114,6 +116,7 @@ class DataGridWidget : public EditableWidget
int _bits;
int _lowerBound;
int _upperBound;
bool _crossGrid;
Common::Base::Format _base;

View File

@ -116,7 +116,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
// Add Binary display of selected RAM cell
xpos = x + w - 13*myFontWidth - 20;
new StaticTextWidget(boss, lfont, xpos, ypos, 4*myFontWidth, myFontHeight,
"Bin:", kTextAlignLeft);
"Bin", kTextAlignLeft);
myBinValue = new DataGridWidget(boss, nfont, xpos + 4*myFontWidth + 5, ypos-2,
1, 1, 8, 8, Common::Base::F_2);
myBinValue->setTarget(this);
@ -125,7 +125,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
// Add Decimal display of selected RAM cell
xpos -= 8*myFontWidth + 5 + 20;
new StaticTextWidget(boss, lfont, xpos, ypos, 4*myFontWidth, myFontHeight,
"Dec:", kTextAlignLeft);
"Dec", kTextAlignLeft);
myDecValue = new DataGridWidget(boss, nfont, xpos + 4*myFontWidth + 5, ypos-2,
1, 1, 3, 8, Common::Base::F_10);
myDecValue->setTarget(this);
@ -138,14 +138,14 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
int xpos_r = xpos - 20;
xpos = x + 10;
new StaticTextWidget(boss, lfont, xpos, ypos, 6*myFontWidth, myFontHeight,
"Label:", kTextAlignLeft);
"Label", kTextAlignLeft);
xpos += 6*myFontWidth + 5;
myLabel = new EditTextWidget(boss, nfont, xpos, ypos-2, xpos_r-xpos,
myLineHeight);
myLabel->setEditable(false, true);
// Inputbox which will pop up when searching RAM
StringList labels = { "Search: " };
StringList labels = { "Search " };
myInputBox = make_ptr<InputTextDialog>(boss, lfont, nfont, labels);
myInputBox->setTarget(this);

View File

@ -488,9 +488,24 @@ bool CartridgeCDF::save(Serializer& out) const
// Indicates which bank is currently active
out.putShort(myCurrentBank);
// Indicates current mode
out.putByte(myMode);
// State of FastJump
out.putByte(myFastJumpActive);
// Address of LDA # operand
out.putShort(myLDAimmediateOperandAddress);
// Harmony RAM
out.putByteArray(myCDFRAM, 8192);
// Audio info
out.putIntArray(myMusicCounters, 3);
out.putIntArray(myMusicFrequencies, 3);
out.putByteArray(myMusicWaveformSize, 3);
// Save cycles and clocks
out.putInt(myAudioCycles);
out.putInt((uInt32)(myFractionalClocks * 100000000.0));
out.putInt(myARMCycles);
@ -514,14 +529,27 @@ bool CartridgeCDF::load(Serializer& in)
// Indicates which bank is currently active
myCurrentBank = in.getShort();
// Indicates current mode
myMode = in.getByte();
// State of FastJump
myFastJumpActive = in.getByte();
// Address of LDA # operand
myLDAimmediateOperandAddress = in.getShort();
// Harmony RAM
in.getByteArray(myCDFRAM, 8192);
// Audio info
in.getIntArray(myMusicCounters, 3);
in.getIntArray(myMusicFrequencies, 3);
in.getByteArray(myMusicWaveformSize, 3);
// Get system cycles and fractional clocks
// Get cycles and clocks
myAudioCycles = (Int32)in.getInt();
myFractionalClocks = (double)in.getInt() / 100000000.0;
myARMCycles = (Int32)in.getInt();
}
catch(...)

View File

@ -237,13 +237,12 @@ class CartridgeCDF : public Cartridge
// Indicates which bank is currently active
uInt16 myCurrentBank;
// System cycle count when the last update to music data fetchers occurred
// System cycle count from when the last update to music data fetchers occurred
Int32 myAudioCycles;
// ARM cycle count from when the last callFunction() occurred
Int32 myARMCycles;
uInt8 mySetAddress;
// The audio routines in the driver run in 32-bit mode and take advantage
// of the FIQ Shadow Registers which are not accessible to 16-bit thumb
// code. As such, Thumbulator does not support them. The driver supplies a
@ -260,12 +259,7 @@ class CartridgeCDF : public Cartridge
r13 = channel2 frequency
r14 = timer base */
// The music mode counters
// In the driver these are stored in ARM FIQ shadow registers r8, r9 and r10
// which are not accessible to Thumb code. Thumbulator will use
// callFunction() to pass back values that end up in them so so the Thumbulator does not
// support these. So the
//
// The music counters, ARM FIQ shadow registers r8, r9, r10
uInt32 myMusicCounters[3];
// The music frequency, ARM FIQ shadow registers r11, r12, r13
@ -274,7 +268,7 @@ class CartridgeCDF : public Cartridge
// The music waveform sizes
uInt8 myMusicWaveformSize[3];
// Fractional DPC music OSC clocks unused during the last update
// Fractional CDF music, OSC clocks unused during the last update
double myFractionalClocks;
// Controls mode, lower nybble sets Fast Fetch, upper nybble sets audio