From 4026ca4c8090096be7dfb029f1d2e9ade7ccff75 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Tue, 27 Aug 2024 22:07:00 +0200 Subject: [PATCH] Finish state widget. --- src/debugger/gui/CartELFStateWidget.cxx | 61 ++++++++++++++++++++++++- src/debugger/gui/CartELFStateWidget.hxx | 7 +++ src/emucore/CartELF.cxx | 6 +++ src/emucore/CartELF.hxx | 1 + src/emucore/elf/BusTransactionQueue.cxx | 6 +++ src/emucore/elf/BusTransactionQueue.hxx | 1 + 6 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/debugger/gui/CartELFStateWidget.cxx b/src/debugger/gui/CartELFStateWidget.cxx index 037812116..07d5647b8 100644 --- a/src/debugger/gui/CartELFStateWidget.cxx +++ b/src/debugger/gui/CartELFStateWidget.cxx @@ -20,8 +20,10 @@ #include #include "CartELF.hxx" +#include "BusTransactionQueue.hxx" #include "DataGridWidget.hxx" #include "ToggleBitWidget.hxx" +#include "EditTextWidget.hxx" namespace { string registerName(uInt8 reg) { @@ -49,6 +51,18 @@ namespace { } } } + + string describeTransaction(uInt16 address, uInt16 mask, uInt64 timestamp) { + ostringstream s; + + s + << std::hex << std::setfill('0') + << "waiting for 0x" << std::setw(4) << address + << " mask 0x" << std::setw(4) << mask + << " time " << std::dec << timestamp; + + return s.str(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -69,9 +83,10 @@ void CartridgeELFStateWidget::initialize() int y = lineHeight / 2; new StaticTextWidget(_boss, _font, x0, y, "ARM registers:"); - const int indent = _font.getMaxCharWidth() * 15; + const int indent = _font.getMaxCharWidth() * 17; myArmRegisters = new DataGridWidget(_boss, _font, x0 + indent, y, 4, 4, 8, 8, Common::Base::Fmt::_16_8); + y += myArmRegisters->getHeight() + lineHeight / 2; myArmRegisters->setEditable(false); @@ -85,6 +100,28 @@ void CartridgeELFStateWidget::initialize() new StaticTextWidget(_boss, _font, x0 + indent + 3 + myFlags->colWidth(), y, "Z"); new StaticTextWidget(_boss, _font, x0 + indent + 3 + 2 * myFlags->colWidth(), y, "C"); new StaticTextWidget(_boss, _font, x0 + indent + 3 + 3 * myFlags->colWidth(), y, "V"); + + y += (5 * lineHeight) / 2; + + new StaticTextWidget(_boss, _font, x0, y + 4, "Time VCS:"); + myCurrentCyclesVcs = new EditTextWidget(_boss, _font, x0 + indent, y, 16 * _font.getMaxCharWidth(), lineHeight); + myCurrentCyclesVcs->setEditable(false, true); + + y += myCurrentCyclesVcs->getHeight() + lineHeight / 2; + + new StaticTextWidget(_boss, _font, x0, y + 4, "Time ARM:"); + myCurrentCyclesArm = new EditTextWidget(_boss, _font, x0 + indent, y, 16 * _font.getMaxCharWidth(), lineHeight); + myCurrentCyclesArm->setEditable(false, true); + + y += myCurrentCyclesArm->getHeight() + lineHeight / 2; + + new StaticTextWidget(_boss, _font, x0, y + 4, "Bus queue size:"); + myQueueSize = new EditTextWidget(_boss, _font, x0 + indent, y, 4 * _font.getMaxCharWidth(), lineHeight); + myQueueSize->setEditable(false, true); + + y += myQueueSize->getHeight() + lineHeight / 2; + + myNextTransaction = new StaticTextWidget(_boss, _font, x0, y, describeTransaction(0xffff, 0xffff, ~0ll)); } void CartridgeELFStateWidget::loadConfig() @@ -103,4 +140,26 @@ void CartridgeELFStateWidget::loadConfig() myFlagValues = flags; myFlags->setState(flags, flagsChanged); + + ostringstream s; + s << myCart.getVcsCyclesArm(); + myCurrentCyclesVcs->setText(s.str()); + + s.str(""); + s << myCart.getArmCycles(); + myCurrentCyclesArm->setText(s.str()); + + s.str(""); + s << myCart.myTransactionQueue.size(); + myQueueSize->setText(s.str()); + + BusTransactionQueue::Transaction* nextTransaction = myCart.myTransactionQueue.peekNextTransaction(); + myNextTransaction->setLabel(nextTransaction + ? describeTransaction( + nextTransaction->address, + nextTransaction->mask, + nextTransaction->timestamp + myCart.myArmCyclesOffset + ) + : "" + ); } diff --git a/src/debugger/gui/CartELFStateWidget.hxx b/src/debugger/gui/CartELFStateWidget.hxx index 581a06e15..62725c72d 100644 --- a/src/debugger/gui/CartELFStateWidget.hxx +++ b/src/debugger/gui/CartELFStateWidget.hxx @@ -23,6 +23,8 @@ class CartridgeELF; class DataGridWidget; class ToggleBitWidget; +class EditTextWidget; +class StaticTextWidget; class CartridgeELFStateWidget : public CartDebugWidget { public: @@ -44,6 +46,11 @@ class CartridgeELFStateWidget : public CartDebugWidget { DataGridWidget* myArmRegisters{nullptr}; ToggleBitWidget* myFlags{nullptr}; + EditTextWidget* myCurrentCyclesVcs{nullptr}; + EditTextWidget* myCurrentCyclesArm{nullptr}; + EditTextWidget* myQueueSize{nullptr}; + StaticTextWidget* myNextTransaction{nullptr}; + }; #endif // CART_ELF_INFO_WIDGET_HXX diff --git a/src/emucore/CartELF.cxx b/src/emucore/CartELF.cxx index 223be687e..c12db4e6a 100644 --- a/src/emucore/CartELF.cxx +++ b/src/emucore/CartELF.cxx @@ -434,6 +434,12 @@ inline uInt64 CartridgeELF::getArmCycles() const return myCortexEmu.getCycles() + myArmCyclesOffset; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt64 CartridgeELF::getVcsCyclesArm() const +{ + return mySystem->cycles() * myArmCyclesPer6502Cycle; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - inline uInt8 CartridgeELF::driveBus(uInt16 address, uInt8 value) { diff --git a/src/emucore/CartELF.hxx b/src/emucore/CartELF.hxx index 94dfb1d1e..428e9aa70 100644 --- a/src/emucore/CartELF.hxx +++ b/src/emucore/CartELF.hxx @@ -128,6 +128,7 @@ class CartridgeELF: public Cartridge { void resetWithConfig(); uInt64 getArmCycles() const; + uInt64 getVcsCyclesArm() const; uInt8 driveBus(uInt16 address, uInt8 value); void syncArmTime(uInt64 armCycles); diff --git a/src/emucore/elf/BusTransactionQueue.cxx b/src/emucore/elf/BusTransactionQueue.cxx index fed15cb1c..c00c32dfe 100644 --- a/src/emucore/elf/BusTransactionQueue.cxx +++ b/src/emucore/elf/BusTransactionQueue.cxx @@ -205,6 +205,12 @@ BusTransactionQueue::Transaction* BusTransactionQueue::getNextTransaction(uInt16 return nextTransaction; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +BusTransactionQueue::Transaction* BusTransactionQueue::peekNextTransaction() +{ + return myQueueSize > 0 ? &myQueue[myQueueNext] : nullptr; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void BusTransactionQueue::push(const Transaction& transaction) { diff --git a/src/emucore/elf/BusTransactionQueue.hxx b/src/emucore/elf/BusTransactionQueue.hxx index f1efd0a6e..82226f3a5 100644 --- a/src/emucore/elf/BusTransactionQueue.hxx +++ b/src/emucore/elf/BusTransactionQueue.hxx @@ -62,6 +62,7 @@ class BusTransactionQueue: public Serializable { bool hasPendingTransaction() const; Transaction* getNextTransaction(uInt16 address, uInt64 timestamp); + Transaction* peekNextTransaction(); size_t size() const { return myQueueSize;