From 0f72f2ecf72b33913ac75a6dac00c7495373e16c Mon Sep 17 00:00:00 2001
From: Thomas Jentzsch
Date: Sun, 5 Sep 2021 07:54:28 +0200
Subject: [PATCH 1/2] added missing missile state tracking to debugger 'tia'
command.
---
src/debugger/TIADebug.cxx | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx
index 87cb619d8..a4e05201d 100644
--- a/src/debugger/TIADebug.cxx
+++ b/src/debugger/TIADebug.cxx
@@ -81,6 +81,8 @@ const DebuggerState& TIADebug::getState()
myState.gr.push_back(myTIA.myPlayer1.getGRPOld());
myState.gr.push_back(myTIA.myBall.getENABLNew());
myState.gr.push_back(myTIA.myBall.getENABLOld());
+ myState.gr.push_back(enaM0());
+ myState.gr.push_back(enaM1());
// Player 0 & 1, Missile 0 & 1 and Ball graphics status registers
myState.ref.clear();
@@ -191,6 +193,8 @@ void TIADebug::saveOldState()
myOldState.gr.push_back(myTIA.myPlayer1.getGRPOld());
myOldState.gr.push_back(myTIA.myBall.getENABLNew());
myOldState.gr.push_back(myTIA.myBall.getENABLOld());
+ myOldState.gr.push_back(enaM0());
+ myOldState.gr.push_back(enaM1());
// Player 0 & 1, Missile 0 & 1 and Ball graphics status registers
myOldState.ref.clear();
@@ -1227,7 +1231,8 @@ string TIADebug::toString()
state.vdel[TiaState::P1] != oldState.vdel[TiaState::P1])
<< endl
<< "M0: "
- << stringOnly(enaM0() ? " ENABLED" : "disabled") << " " // TODO: changed, not tracked?
+ << stringOnly(enaM0() ? " ENABLED" : "disabled",
+ state.gr[6] != oldState.gr[6]) << " "
<< decWithLabel("pos", state.pos[TiaState::M0],
state.pos[TiaState::M0] != oldState.pos[TiaState::M0]) << " "
<< hexWithLabel("HM", state.hm[TiaState::M0],
@@ -1237,7 +1242,8 @@ string TIADebug::toString()
<< boolWithLabel("reset", resMP0(), state.resm[TiaState::P0] != oldState.resm[TiaState::P0])
<< endl
<< "M1: "
- << stringOnly(enaM1() ? " ENABLED" : "disabled") << " " // TODO: changed, not tracked?
+ << stringOnly(enaM1() ? " ENABLED" : "disabled",
+ state.gr[7] != oldState.gr[7]) << " "
<< decWithLabel("pos", state.pos[TiaState::M1],
state.pos[TiaState::M1] != oldState.pos[TiaState::M1]) << " "
<< hexWithLabel("HM", state.hm[TiaState::M1],
@@ -1278,17 +1284,17 @@ string TIADebug::toString()
<< boolWithLabel("priority", priorityPF(), state.pf[5] != oldState.pf[5])
<< endl
<< boolWithLabel("inpt0", myTIA.peek(0x08) & 0x80,
- riotState.INPT0 != oldRiotState.INPT0) << " "
+ (riotState.INPT0 & 0x80) != (oldRiotState.INPT0 & 0x80)) << " "
<< boolWithLabel("inpt1", myTIA.peek(0x09) & 0x80,
- riotState.INPT1 != oldRiotState.INPT1) << " "
+ (riotState.INPT1 & 0x80) != (oldRiotState.INPT1 & 0x80)) << " "
<< boolWithLabel("inpt2", myTIA.peek(0x0a) & 0x80,
- riotState.INPT2 != oldRiotState.INPT2) << " "
+ (riotState.INPT2 & 0x80) != (oldRiotState.INPT2 & 0x80)) << " "
<< boolWithLabel("inpt3", myTIA.peek(0x0b) & 0x80,
- riotState.INPT3 != oldRiotState.INPT3) << " "
+ (riotState.INPT3 & 0x80) != (oldRiotState.INPT3 & 0x80)) << " "
<< boolWithLabel("inpt4", myTIA.peek(0x0c) & 0x80,
- riotState.INPT4 != oldRiotState.INPT4) << " "
+ (riotState.INPT4 & 0x80) != (oldRiotState.INPT4 & 0x80)) << " "
<< boolWithLabel("inpt5", myTIA.peek(0x0d) & 0x80,
- riotState.INPT5 != oldRiotState.INPT5) << " "
+ (riotState.INPT5 & 0x80) != (oldRiotState.INPT5 & 0x80)) << " "
<< boolWithLabel("dump_gnd_0123", myTIA.myAnalogReadouts[0].vblankDumped(),
riotState.INPTDump != oldRiotState.INPTDump)
<< endl
From 905645a9f5798a8b64c2d6d291bd094adc4c7d08 Mon Sep 17 00:00:00 2001
From: Thomas Jentzsch
Date: Sun, 5 Sep 2021 19:20:30 +0200
Subject: [PATCH 2/2] added _inTim and timInt pseudo registers (resolves #168)
---
docs/debugger.html | 2 ++
src/debugger/Debugger.cxx | 4 +++-
src/debugger/Debugger.hxx | 2 +-
src/debugger/RiotDebug.hxx | 2 ++
src/debugger/gui/RiotWidget.cxx | 27 ++++++++++++++++++++++++++-
src/debugger/gui/RiotWidget.hxx | 1 +
src/emucore/M6532.cxx | 4 ++--
src/yacc/YaccParser.cxx | 4 ++++
8 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/docs/debugger.html b/docs/debugger.html
index a18739eae..1171d4864 100644
--- a/docs/debugger.html
+++ b/docs/debugger.html
@@ -770,9 +770,11 @@ that holds 'number of scanlines' on an actual console).
_fTimReadCycles | Number of cycles used by timer reads since frame started |
_fWsyncCycles | Number of cycles skipped by WSYNC since frame started |
_iCycles | Number of cycles of last instruction |
+ _inTim | Current INTIM value |
_scan | Current scanLine count |
_scanEnd | Scanline count at end of last frame |
_sCycles | Number of cycles in current scanLine |
+ _timInt | Current TIMINT value |
_timWrapRead | Timer read wrapped on this cycle |
_timWrapWrite | Timer write wrapped on this cycle |
_vBlank | Whether vertical blank is enabled (1 or 0) |
diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx
index 80835e4ba..a5260fe24 100644
--- a/src/debugger/Debugger.cxx
+++ b/src/debugger/Debugger.cxx
@@ -962,7 +962,7 @@ std::array Debugger::ourBuiltinFunctions = { {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Names are defined here, but processed in YaccParser
-std::array Debugger::ourPseudoRegisters = { {
+std::array Debugger::ourPseudoRegisters = {{
// Debugger::PseudoRegister Debugger::ourPseudoRegisters[NUM_PSEUDO_REGS] = {
{ "_bank", "Currently selected bank" },
{ "_cClocks", "Color clocks on current scanline" },
@@ -973,9 +973,11 @@ std::array Debugger::ourPseudoRegisters = { {
{ "_fTimReadCycles","Number of cycles used by timer reads since frame started" },
{ "_fWsyncCycles", "Number of cycles skipped by WSYNC since frame started" },
{ "_iCycles", "Number of cycles of last instruction" },
+ { "_inTim", "Curent INTIM value" },
{ "_scan", "Current scanline count" },
{ "_scanEnd", "Scanline count at end of last frame" },
{ "_sCycles", "Number of cycles in current scanline" },
+ { "_timInt", "Current TIMINT value" },
{ "_timWrapRead", "Timer read wrapped on this cycle" },
{ "_timWrapWrite", "Timer write wrapped on this cycle" },
{ "_vBlank", "Whether vertical blank is enabled (1 or 0)" },
diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx
index 25feebeab..a04b8f832 100644
--- a/src/debugger/Debugger.hxx
+++ b/src/debugger/Debugger.hxx
@@ -366,7 +366,7 @@ class Debugger : public DialogContainer
string name, help;
};
static std::array ourBuiltinFunctions;
- static std::array ourPseudoRegisters;
+ static std::array ourPseudoRegisters;
static constexpr Int8 ANY_BANK = -1;
bool myFirstLog{true};
diff --git a/src/debugger/RiotDebug.hxx b/src/debugger/RiotDebug.hxx
index ce5af7ec8..d2c298456 100644
--- a/src/debugger/RiotDebug.hxx
+++ b/src/debugger/RiotDebug.hxx
@@ -85,6 +85,8 @@ class RiotDebug : public DebuggerSystem
int timWrappedOnWrite() const;
int timReadCycles() const;
+ int timintAsInt() const { return int(timint()); } // so we can use _timInt pseudo-register
+ int intimAsInt() const { return int(intim()); } // so we can use _inTim pseudo-register
/* Console switches */
bool diffP0(int newVal = -1);
diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx
index 7b6f40a76..cbb577e8e 100644
--- a/src/debugger/gui/RiotWidget.cxx
+++ b/src/debugger/gui/RiotWidget.cxx
@@ -138,6 +138,13 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
myTimWrite->setID(kTimWriteID);
addFocusWidget(myTimWrite);
+ t = new StaticTextWidget(boss, lfont, myTimWrite->getRight() + _fontWidth, ypos + 2 , "#");
+ myTimClocks = new DataGridWidget(boss, nfont, t->getRight() + _fontWidth / 2, ypos,
+ 1, 1, 6, 30, Common::Base::Fmt::_10_6);
+ myTimClocks->setToolTip("Number of CPU cycles available for current timer interval.\n");
+ myTimClocks->setTarget(this);
+ myTimClocks->setEditable(false);
+
// Timer registers (RO)
static constexpr std::array readNames = {
"INTIM", "TIMINT", "Total Clks", "INTIM Clks", "Divider #"
@@ -148,7 +155,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
t = new StaticTextWidget(boss, lfont, xpos, ypos + row * lineHeight + 2,
readNames[row]);
}
- xpos += t->getWidth() + 5;
+ xpos += t->getWidth() + _fontWidth / 2;
myTimRead = new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 4, 30, Common::Base::Fmt::_16);
myTimRead->setTarget(this);
myTimRead->setEditable(false);
@@ -341,6 +348,24 @@ void RiotWidget::loadConfig()
changed.push_back(state.T1024T != oldstate.T1024T);
myTimWrite->setList(alist, vlist, changed);
+ alist.clear(); vlist.clear(); changed.clear();
+ alist.push_back(0);
+ if(state.TIM1T)
+ vlist.push_back((state.TIM1T - 1) * 1);
+ else if(state.TIM8T)
+ vlist.push_back((state.TIM8T - 1) * 8);
+ else if(state.TIM64T)
+ vlist.push_back((state.TIM64T - 1) * 64);
+ else if(state.T1024T)
+ vlist.push_back((state.T1024T - 1) * 1024);
+ else
+ vlist.push_back(0);
+ changed.push_back(state.TIM1T != oldstate.TIM1T ||
+ state.TIM8T != oldstate.TIM8T ||
+ state.TIM64T != oldstate.TIM64T ||
+ state.T1024T != oldstate.T1024T);
+ myTimClocks->setList(alist, vlist, changed);
+
// Update timer read registers
alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(state.INTIM);
diff --git a/src/debugger/gui/RiotWidget.hxx b/src/debugger/gui/RiotWidget.hxx
index 44207a0e7..78ddf5248 100644
--- a/src/debugger/gui/RiotWidget.hxx
+++ b/src/debugger/gui/RiotWidget.hxx
@@ -58,6 +58,7 @@ class RiotWidget : public Widget, public CommandSender
CheckboxWidget* myINPTDump{nullptr};
DataGridWidget* myTimWrite{nullptr};
+ DataGridWidget* myTimClocks{nullptr};
DataGridWidget* myTimRead{nullptr};
DataGridWidget* myTimDivider{nullptr};
diff --git a/src/emucore/M6532.cxx b/src/emucore/M6532.cxx
index bcfc60f67..af457baac 100644
--- a/src/emucore/M6532.cxx
+++ b/src/emucore/M6532.cxx
@@ -460,8 +460,8 @@ Int32 M6532::intimClocks()
updateEmulation();
// This method is similar to intim(), except instead of giving the actual
- // INTIM value, it will give the current number of clocks between one
- // INTIM value and the next
+ // INTIM value, it will give the current number of CPU clocks since the last
+ // TIMxxT write
return ((myInterruptFlag & TimerBit) != 0) ? 1 : (myDivider - mySubTimer);
}
diff --git a/src/yacc/YaccParser.cxx b/src/yacc/YaccParser.cxx
index 9d3a62519..0ff086de9 100644
--- a/src/yacc/YaccParser.cxx
+++ b/src/yacc/YaccParser.cxx
@@ -238,6 +238,10 @@ RiotMethod getRiotSpecial(char* ch)
return &RiotDebug::timWrappedOnWrite;
else if(BSPF::equalsIgnoreCase(ch, "_fTimReadCycles"))
return &RiotDebug::timReadCycles;
+ else if(BSPF::equalsIgnoreCase(ch, "_inTim"))
+ return &RiotDebug::intimAsInt;
+ else if(BSPF::equalsIgnoreCase(ch, "_timInt"))
+ return &RiotDebug::timintAsInt;
else
return nullptr;
}