added _inTim and timInt pseudo registers (resolves #168)

This commit is contained in:
Thomas Jentzsch 2021-09-05 19:20:30 +02:00
parent 0f72f2ecf7
commit 905645a9f5
8 changed files with 41 additions and 5 deletions

View File

@ -770,9 +770,11 @@ that holds 'number of scanlines' on an actual console).</p>
<tr><td> _fTimReadCycles</td><td>Number of cycles used by timer reads since frame started</td></tr>
<tr><td> _fWsyncCycles</td><td>Number of cycles skipped by WSYNC since frame started</td></tr>
<tr><td> _iCycles</td><td> Number of cycles of last instruction</td></tr>
<tr><td> _inTim</td><td> Current INTIM value</td></tr>
<tr><td> _scan</td><td> Current scanLine count</td></tr>
<tr><td> _scanEnd</td><td> Scanline count at end of last frame</td></tr>
<tr><td> _sCycles</td><td> Number of cycles in current scanLine</td></tr>
<tr><td> _timInt</td><td> Current TIMINT value</td></tr>
<tr><td> _timWrapRead</td><td> Timer read wrapped on this cycle</td></tr>
<tr><td> _timWrapWrite</td><td> Timer write wrapped on this cycle</td></tr>
<tr><td> _vBlank</td><td> Whether vertical blank is enabled (1 or 0)</td></tr>

View File

@ -962,7 +962,7 @@ std::array<Debugger::BuiltinFunction, 18> Debugger::ourBuiltinFunctions = { {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Names are defined here, but processed in YaccParser
std::array<Debugger::PseudoRegister, 16> Debugger::ourPseudoRegisters = { {
std::array<Debugger::PseudoRegister, 18> 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::PseudoRegister, 16> 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)" },

View File

@ -366,7 +366,7 @@ class Debugger : public DialogContainer
string name, help;
};
static std::array<BuiltinFunction, 18> ourBuiltinFunctions;
static std::array<PseudoRegister, 16> ourPseudoRegisters;
static std::array<PseudoRegister, 18> ourPseudoRegisters;
static constexpr Int8 ANY_BANK = -1;
bool myFirstLog{true};

View File

@ -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);

View File

@ -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<const char*, 5> 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);

View File

@ -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};

View File

@ -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);
}

View File

@ -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;
}