From 4e3b26cea9375659ded5c87ddb9028a5576ca765 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 18 Jan 2018 13:03:59 +0100 Subject: [PATCH] display of current timer divider to debugger added --- src/common/Base.cxx | 6 +++++- src/common/Base.hxx | 3 ++- src/debugger/RiotDebug.cxx | 9 +++++++++ src/debugger/RiotDebug.hxx | 3 ++- src/debugger/gui/RiotWidget.cxx | 16 +++++++++++++--- src/debugger/gui/RiotWidget.hxx | 1 + src/gui/TimeMachineDialog.cxx | 6 +++--- 7 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/common/Base.cxx b/src/common/Base.cxx index f3d668b33..1347300f3 100644 --- a/src/common/Base.cxx +++ b/src/common/Base.cxx @@ -68,10 +68,14 @@ string Base::toString(int value, Common::Base::Format outputBase) std::snprintf(vToS_buf, 6, "%5d", value); break; - case Base::F_10_2: // base 10: 2 digits + case Base::F_10_02: // base 10: 2 digits (with leading zero) std::snprintf(vToS_buf, 3, "%02d", value); break; + case Base::F_10_4: // base 10: 4 digits + std::snprintf(vToS_buf, 5, "%4d", value); + break; + case Base::F_16_1: // base 16: 1 byte wide std::snprintf(vToS_buf, 2, myFmt[0], value); break; diff --git a/src/common/Base.hxx b/src/common/Base.hxx index 3c4916abe..8ccd739e2 100644 --- a/src/common/Base.hxx +++ b/src/common/Base.hxx @@ -47,7 +47,8 @@ class Base F_16_4, // base 16: 4 bytes wide F_16_8, // base 16: 8 bytes wide F_10, // base 10: 3 or 5 bytes (depending on value) - F_10_2, // base 10: 2 digits + F_10_02, // base 10: 02 digits + F_10_4, // base 10: 4 digits F_2, // base 2: 8 or 16 bits (depending on value) F_2_8, // base 2: 1 byte (8 bits) wide F_2_16, // base 2: 2 bytes (16 bits) wide diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx index bc8a89b99..e218a6c58 100644 --- a/src/debugger/RiotDebug.cxx +++ b/src/debugger/RiotDebug.cxx @@ -66,6 +66,7 @@ const DebuggerState& RiotDebug::getState() myState.TIMINT = timint(); myState.TIMCLKS = timClocks(); myState.INTIMCLKS = intimClocks(); + myState.TIMDIV = timDivider(); return myState; } @@ -107,6 +108,7 @@ void RiotDebug::saveOldState() myOldState.TIMINT = timint(); myOldState.TIMCLKS = timClocks(); myOldState.INTIMCLKS = intimClocks(); + myOldState.TIMDIV = timDivider(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -223,6 +225,12 @@ Int32 RiotDebug::intimClocks() const return mySystem.m6532().intimClocks(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Int32 RiotDebug::timDivider() const +{ + return mySystem.m6532().myDivider; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Controller& RiotDebug::controller(Controller::Jack jack) const { @@ -362,6 +370,7 @@ string RiotDebug::toString() << " 285/TIMINT=" << myDebugger.invIfChanged(state.TIMINT, oldstate.TIMINT) << " Timer_Clocks=" << myDebugger.invIfChanged(state.TIMCLKS, oldstate.TIMCLKS) << " INTIM_Clocks=" << myDebugger.invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS) + << " Divider=" << myDebugger.invIfChanged(state.TIMDIV, oldstate.TIMDIV) << endl << "Left/P0diff: " << diffP0String() << " Right/P1diff: " << diffP0String() diff --git a/src/debugger/RiotDebug.hxx b/src/debugger/RiotDebug.hxx index d6425d8a0..fc871d722 100644 --- a/src/debugger/RiotDebug.hxx +++ b/src/debugger/RiotDebug.hxx @@ -36,7 +36,7 @@ class RiotState : public DebuggerState BoolArray swbcntBits; uInt8 TIM1T, TIM8T, TIM64T, T1024T, INTIM, TIMINT; - Int32 TIMCLKS, INTIMCLKS; + Int32 TIMCLKS, INTIMCLKS, TIMDIV; // These are actually from the TIA, but are I/O related uInt8 INPT0, INPT1, INPT2, INPT3, INPT4, INPT5; @@ -74,6 +74,7 @@ class RiotDebug : public DebuggerSystem uInt8 timint() const; Int32 timClocks() const; Int32 intimClocks() const; + Int32 timDivider() const; /* Controller ports */ Controller& controller(Controller::Jack jack) const; diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 091abf935..39dd3b21f 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -115,9 +115,9 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, addFocusWidget(myTimWrite); // Timer registers (RO) - const char* const readNames[] = { "INTIM", "TIMINT", "Total Clks", "INTIM Clks" }; - xpos = 10; ypos += myTimWrite->getHeight() + lineHeight; - for(int row = 0; row < 4; ++row) + const char* const readNames[] = { "INTIM", "TIMINT", "Total Clks", "INTIM Clks", "Divider" }; + xpos = 10; ypos += myTimWrite->getHeight() + lineHeight / 2; + for(int row = 0; row < 5; ++row) { t = new StaticTextWidget(boss, lfont, xpos, ypos + row*lineHeight + 2, 10*fontWidth, fontHeight, readNames[row], TextAlign::Left); @@ -127,6 +127,11 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, myTimRead->setTarget(this); myTimRead->setEditable(false); + ypos += myTimRead->getHeight() - 1; + myTimDivider = new DataGridWidget(boss, nfont, xpos, ypos, 1, 1, 4, 32, Common::Base::F_10_4); + myTimDivider->setTarget(this); + myTimDivider->setEditable(false); + // Controller ports const RiotDebug& riot = instance().debugger().riotDebug(); xpos = col; ypos = 10; @@ -315,6 +320,11 @@ void RiotWidget::loadConfig() changed.push_back(state.INTIMCLKS != oldstate.INTIMCLKS); myTimRead->setList(alist, vlist, changed); + alist.clear(); vlist.clear(); changed.clear(); + alist.push_back(0); vlist.push_back(state.TIMDIV); + changed.push_back(state.TIMDIV != oldstate.TIMDIV); + myTimDivider->setList(alist, vlist, changed); + // Console switches (inverted, since 'selected' in the UI // means 'grounded' in the system) myP0Diff->setSelectedIndex(riot.diffP0(), state.swchbReadBits[1] != oldstate.swchbReadBits[1]); diff --git a/src/debugger/gui/RiotWidget.hxx b/src/debugger/gui/RiotWidget.hxx index e5f03ed13..1582872d6 100644 --- a/src/debugger/gui/RiotWidget.hxx +++ b/src/debugger/gui/RiotWidget.hxx @@ -59,6 +59,7 @@ class RiotWidget : public Widget, public CommandSender DataGridWidget* myTimWrite; DataGridWidget* myTimRead; + DataGridWidget* myTimDivider; ControllerWidget *myLeftControl, *myRightControl; PopUpWidget *myP0Diff, *myP1Diff; diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index a732bbdd9..5ff0a0340 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -336,9 +336,9 @@ string TimeMachineDialog::getTimeString(uInt64 cycles) uInt32 frames = cycles / (scanlines * 76); stringstream time; - time << Common::Base::toString(minutes, Common::Base::F_10_2) << ":"; - time << Common::Base::toString(seconds, Common::Base::F_10_2) << "."; - time << Common::Base::toString(frames, Common::Base::F_10_2); + time << Common::Base::toString(minutes, Common::Base::F_10_02) << ":"; + time << Common::Base::toString(seconds, Common::Base::F_10_02) << "."; + time << Common::Base::toString(frames, Common::Base::F_10_02); return time.str(); }