mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-26 15:59:22 +00:00
Making the CPU debugger's bus read silent
This commit is contained in:
@@ -45,6 +45,8 @@ namespace ComSquare::Debugger
|
||||
try {
|
||||
if (this->_isPaused)
|
||||
return 0xFF;
|
||||
if (this->_isStepping)
|
||||
return this->_executeInstruction(this->_bus->read(this->_registers.pac++));
|
||||
return CPU::update();
|
||||
} catch (InvalidOpcode &e) {
|
||||
if (!this->_isPaused)
|
||||
@@ -55,10 +57,6 @@ namespace ComSquare::Debugger
|
||||
|
||||
unsigned CPUDebug::_executeInstruction(uint8_t opcode)
|
||||
{
|
||||
if (this->_isPaused) {
|
||||
this->_registers.pac--;
|
||||
return 0;
|
||||
}
|
||||
if (this->_isStepping) {
|
||||
this->_isStepping = false;
|
||||
this->_isPaused = true;
|
||||
@@ -130,10 +128,10 @@ namespace ComSquare::Debugger
|
||||
|
||||
std::string CPUDebug::_getImmediateValueForA(uint24_t pc)
|
||||
{
|
||||
unsigned value = this->_bus->read(pc);
|
||||
unsigned value = this->_bus->read(pc, true);
|
||||
|
||||
if (!this->_registers.p.m)
|
||||
value += this->_bus->read(pc + 1) << 8u;
|
||||
value += this->_bus->read(pc + 1, true) << 8u;
|
||||
std::stringstream ss;
|
||||
ss << "#$" << std::hex << value;
|
||||
return ss.str();
|
||||
@@ -141,10 +139,10 @@ namespace ComSquare::Debugger
|
||||
|
||||
std::string CPUDebug::_getImmediateValueForX(uint24_t pc)
|
||||
{
|
||||
unsigned value = this->_bus->read(pc);
|
||||
unsigned value = this->_bus->read(pc, true);
|
||||
|
||||
if (!this->_registers.p.x_b)
|
||||
value += this->_bus->read(pc + 1) << 8u;
|
||||
value += this->_bus->read(pc + 1, true) << 8u;
|
||||
std::stringstream ss;
|
||||
ss << "#$" << std::hex << value;
|
||||
return ss.str();
|
||||
@@ -153,14 +151,14 @@ namespace ComSquare::Debugger
|
||||
std::string CPUDebug::_getImmediateValue8Bits(uint24_t pc)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "#$" << std::hex << static_cast<int>(this->_bus->read(pc));
|
||||
ss << "#$" << std::hex << static_cast<int>(this->_bus->read(pc), true);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string CPUDebug::_getImmediateValue16Bits(uint24_t pc)
|
||||
{
|
||||
unsigned value = this->_bus->read(pc);
|
||||
value += this->_bus->read(pc + 1) << 8u;
|
||||
unsigned value = this->_bus->read(pc, true);
|
||||
value += this->_bus->read(pc + 1, true) << 8u;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "#$" << std::hex << value;
|
||||
@@ -170,22 +168,22 @@ namespace ComSquare::Debugger
|
||||
std::string CPUDebug::_getDirectValue(uint24_t pc)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "$" << std::hex << static_cast<int>(this->_bus->read(pc));
|
||||
ss << "$" << std::hex << static_cast<int>(this->_bus->read(pc), true);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string CPUDebug::_getAbsoluteValue(uint24_t pc)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "$" << std::hex << (this->_bus->read(pc) + (this->_bus->read(pc + 1) << 8u));
|
||||
ss << "$" << std::hex << (this->_bus->read(pc) + (this->_bus->read(pc + 1) << 8u), true);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string CPUDebug::_getAbsoluteLongValue(uint24_t pc)
|
||||
{
|
||||
unsigned value = this->_bus->read(pc++);
|
||||
value += this->_bus->read(pc++) << 8u;
|
||||
value += this->_bus->read(pc) << 16u;
|
||||
unsigned value = this->_bus->read(pc++, true);
|
||||
value += this->_bus->read(pc++, true) << 8u;
|
||||
value += this->_bus->read(pc, true) << 16u;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "$" << std::hex << value;
|
||||
@@ -194,7 +192,7 @@ namespace ComSquare::Debugger
|
||||
|
||||
std::string CPUDebug::_getDirectIndexedByXValue(uint24_t pc)
|
||||
{
|
||||
unsigned value = this->_bus->read(pc);
|
||||
unsigned value = this->_bus->read(pc, true);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "$" << std::hex << value << ", x";
|
||||
@@ -203,7 +201,7 @@ namespace ComSquare::Debugger
|
||||
|
||||
std::string CPUDebug::_getInstructionString(uint24_t pc)
|
||||
{
|
||||
uint8_t opcode = this->_bus->read(pc++);
|
||||
uint8_t opcode = this->_bus->read(pc++, true);
|
||||
|
||||
switch (opcode) {
|
||||
case Instructions::BRK: return "BRK";
|
||||
|
||||
@@ -48,12 +48,13 @@ namespace ComSquare::Debugger
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t MemoryBusDebug::read(uint24_t addr)
|
||||
uint8_t MemoryBusDebug::read(uint24_t addr, bool silence)
|
||||
{
|
||||
auto accessor = this->getAccessor(addr);
|
||||
uint8_t value = accessor->read(addr - accessor->getStart());
|
||||
this->_model.log(BusLog(false, addr, accessor, value, value));
|
||||
|
||||
if (!silence) {
|
||||
auto accessor = this->getAccessor(addr);
|
||||
uint8_t value = accessor->read(addr - accessor->getStart());
|
||||
this->_model.log(BusLog(false, addr, accessor, value, value));
|
||||
}
|
||||
return MemoryBus::read(addr);
|
||||
}
|
||||
|
||||
@@ -134,10 +135,11 @@ QVariant BusLogModel::headerData(int section, Qt::Orientation orientation, int r
|
||||
|
||||
void BusLogModel::log(ComSquare::Debugger::BusLog log)
|
||||
{
|
||||
this->_logs.push_back(log);
|
||||
int row = this->_logs.size();
|
||||
this->beginInsertRows(QModelIndex(), row, row);
|
||||
this->_logs.push_back(log);
|
||||
this->insertRow(row);
|
||||
emit this->layoutChanged();
|
||||
this->endInsertRows();
|
||||
}
|
||||
|
||||
ComSquare::Debugger::BusLog BusLogModel::getLogAt(int index)
|
||||
@@ -151,7 +153,7 @@ bool BusLoggerProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePa
|
||||
{
|
||||
ComSquare::Debugger::BusLog log = this->_parent.getLogAt(sourceRow);
|
||||
|
||||
if (log.accessor && log.accessor->getName() == "Cartridge")
|
||||
return false;
|
||||
// if (log.accessor && log.accessor->getName() == "Cartridge")
|
||||
// return false;
|
||||
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace ComSquare::Debugger
|
||||
//! @brief Read data at a global address and log it to the debugger.
|
||||
//! @param addr The address to read from.
|
||||
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
|
||||
uint8_t read(uint24_t addr) override;
|
||||
uint8_t read(uint24_t addr, bool silence = false) override;
|
||||
|
||||
//! @brief Write a data to a global address and log it to the debugger.
|
||||
//! @param addr The address to write to.
|
||||
|
||||
Reference in New Issue
Block a user