mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-29 17:02:21 +00:00
Reworking the memory management & fixing a bug in the memory viewer goto
This commit is contained in:
@@ -155,7 +155,7 @@ namespace ComSquare::Debugger
|
||||
if (!accessor) {
|
||||
this->_model.log(BusLog(true, addr, accessor, this->_openBus, this->_openBus));
|
||||
} else {
|
||||
uint8_t value = accessor->read(addr - accessor->getStart());
|
||||
uint8_t value = accessor->read(accessor->getRelativeAddress(addr));
|
||||
this->_model.log(BusLog(false, addr, accessor, value, value));
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ namespace ComSquare::Debugger
|
||||
std::optional<uint8_t> value = std::nullopt;
|
||||
try {
|
||||
if (accessor)
|
||||
value = accessor->read(addr - accessor->getStart());
|
||||
value = accessor->read(accessor->getRelativeAddress(addr));
|
||||
} catch (InvalidAddress &) {
|
||||
value = std::nullopt;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ namespace ComSquare::Debugger
|
||||
MemoryBus::write(addr, data);
|
||||
}
|
||||
|
||||
BusLog::BusLog(bool _write, uint24_t _addr, std::shared_ptr<Memory::AMemory> &_accessor, std::optional<uint8_t> _oldData, uint8_t _newData) :
|
||||
BusLog::BusLog(bool _write, uint24_t _addr, std::shared_ptr<Memory::IMemory> &_accessor, std::optional<uint8_t> _oldData, uint8_t _newData) :
|
||||
write(_write), addr(_addr), accessor(std::move(_accessor)), oldData(_oldData), newData(_newData)
|
||||
{}
|
||||
}
|
||||
@@ -206,8 +206,10 @@ QVariant BusLogModel::data(const QModelIndex &index, int role) const
|
||||
return QString(ComSquare::Utility::to_hex(log.addr).c_str());
|
||||
case 2:
|
||||
return QString(log.accessor ? log.accessor->getName().c_str() : "Bus");
|
||||
case 3:
|
||||
return QString(log.accessor ? log.accessor->getValueName(log.addr - log.accessor->getStart()).c_str() : "Open bus");
|
||||
case 3: {
|
||||
uint24_t addr = log.accessor->getRelativeAddress(log.addr);
|
||||
return QString(log.accessor ? log.accessor->getValueName(addr).c_str() : "Open bus");
|
||||
}
|
||||
case 4:
|
||||
if (!log.oldData)
|
||||
return QString("???");
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace ComSquare::Debugger
|
||||
struct BusLog {
|
||||
BusLog(bool write,
|
||||
uint24_t addr,
|
||||
std::shared_ptr<Memory::AMemory> &accessor,
|
||||
std::shared_ptr<Memory::IMemory> &accessor,
|
||||
std::optional<uint8_t> oldData,
|
||||
uint8_t newData);
|
||||
|
||||
bool write;
|
||||
uint24_t addr;
|
||||
std::shared_ptr<Memory::AMemory> accessor;
|
||||
std::shared_ptr<Memory::IMemory> accessor;
|
||||
std::optional<uint8_t> oldData;
|
||||
uint8_t newData;
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ QVariant MemoryViewerModel::data(const QModelIndex &index, int role) const
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
char buf[3];
|
||||
snprintf(buf, 3, "%02X", this->_memory->read_internal((index.row() << 4u) + index.column()));
|
||||
snprintf(buf, 3, "%02X", this->_memory->read((index.row() << 4u) + index.column()));
|
||||
return QString(buf);
|
||||
}
|
||||
|
||||
@@ -149,31 +149,31 @@ namespace ComSquare::Debugger
|
||||
value = this->switchToAddrTab(value);
|
||||
} catch (InvalidAddress &) {}
|
||||
}
|
||||
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0000000F);
|
||||
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0F);
|
||||
this->_ui.tableView->scrollTo(index);
|
||||
this->_ui.tableView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
|
||||
unsigned MemoryViewer::switchToAddrTab(uint24_t addr)
|
||||
{
|
||||
std::shared_ptr<Memory::AMemory> accessor = this->_bus.getAccessor(addr);
|
||||
std::shared_ptr<Memory::IMemory> accessor = this->_bus.getAccessor(addr);
|
||||
if (!accessor)
|
||||
throw InvalidAddress("Memory viewer switch to address", addr);
|
||||
Memory::AMemory *ptr;
|
||||
if (accessor->isMirror())
|
||||
ptr = accessor->getMirrored().get();
|
||||
else
|
||||
ptr = accessor.get();
|
||||
|
||||
if (ptr == this->_snes.wram.get())
|
||||
switch (accessor->getComponent()) {
|
||||
case WRam:
|
||||
this->_ui.tabs->setCurrentIndex(0);
|
||||
else if (ptr == this->_snes.sram.get())
|
||||
break;
|
||||
case SRam:
|
||||
this->_ui.tabs->setCurrentIndex(1);
|
||||
else if (ptr == this->_snes.cartridge.get())
|
||||
break;
|
||||
case Rom:
|
||||
this->_ui.tabs->setCurrentIndex(2);
|
||||
else
|
||||
break;
|
||||
default:
|
||||
throw InvalidAddress("Memory viewer switch to address", addr);
|
||||
return addr - accessor->getStart();
|
||||
}
|
||||
return accessor->getRelativeAddress(addr);
|
||||
}
|
||||
|
||||
void MemoryViewer::focus()
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace ComSquare::Debugger
|
||||
model->addRegister(Register(0x4300, ":3", "Fixed", [i](SNES &snes) {
|
||||
return snes.cpu->_dmaChannels[i]._controlRegister.fixed;
|
||||
}, nullptr, Boolean));
|
||||
model->addRegister(Register(0x4300, ":4", "Increment", [i](SNES &snes) {
|
||||
model->addRegister(Register(0x4300, ":4", "Decrement", [i](SNES &snes) {
|
||||
return snes.cpu->_dmaChannels[i]._controlRegister.increment;
|
||||
}, nullptr, Boolean));
|
||||
model->addRegister(Register(0x4300, ":0-2", "Mode", [i](SNES &snes) {
|
||||
|
||||
Reference in New Issue
Block a user