mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 06:05:11 +00:00
Reworking the memory management & fixing a bug in the memory viewer goto
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user