MemoryEditor::MemoryEditor() { setObjectName("memory-editor"); setWindowTitle("Memory Editor"); setGeometryString(&config().geometry.memoryEditor); application.windowList.append(this); layout = new QHBoxLayout; layout->setMargin(Style::WindowMargin); layout->setSpacing(Style::WidgetSpacing); setLayout(layout); editor = new HexEditor; editor->reader = { &MemoryEditor::reader, this }; editor->writer = { &MemoryEditor::writer, this }; editor->setFont(QFont(Style::Monospace)); editor->setMinimumWidth((editor->lineWidth() + 3) * editor->fontMetrics().width(' ')); editor->setMinimumHeight((16 + 1) * editor->fontMetrics().height()); editor->setSize(16 * 1024 * 1024); memorySource = SNES::Debugger::MemorySource::CPUBus; layout->addWidget(editor); controlLayout = new QVBoxLayout; controlLayout->setSpacing(0); layout->addLayout(controlLayout); source = new QComboBox; source->addItem("S-CPU bus"); source->addItem("S-APU bus"); source->addItem("S-PPU VRAM"); source->addItem("S-PPU OAM"); source->addItem("S-PPU CGRAM"); controlLayout->addWidget(source); controlLayout->addSpacing(2); addr = new QLineEdit; controlLayout->addWidget(addr); autoUpdateBox = new QCheckBox("Auto update"); controlLayout->addWidget(autoUpdateBox); refreshButton = new QPushButton("Refresh"); controlLayout->addWidget(refreshButton); spacer = new QWidget; spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); controlLayout->addWidget(spacer); exportButton = new QPushButton("Export"); controlLayout->addWidget(exportButton); importButton = new QPushButton("Import"); controlLayout->addWidget(importButton); connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(sourceChanged(int))); connect(addr, SIGNAL(textEdited(const QString&)), this, SLOT(updateOffset())); connect(addr, SIGNAL(returnPressed()), this, SLOT(updateOffset())); connect(refreshButton, SIGNAL(released()), this, SLOT(refresh())); connect(exportButton, SIGNAL(released()), this, SLOT(exportMemory())); connect(importButton, SIGNAL(released()), this, SLOT(importMemory())); }
vk::Move<vk::VkDeviceMemory> importMemory (const vk::DeviceInterface& vkd, vk::VkDevice device, const vk::VkMemoryRequirements& requirements, vk::VkExternalMemoryHandleTypeFlagBitsKHR externalType, NativeHandle& handle) { return importMemory(vkd, device, (vk::VkBuffer)0, (vk::VkImage)0, requirements, externalType, handle); }
void MemoryEditor::importMemory() { string basename = filepath(nall::basename(cartridge.fileName), config().path.data); importMemory(SNES::memory::cartram, string() << basename << "-sram.bin"); importMemory(SNES::memory::wram, string() << basename << "-wram.bin"); importMemory(SNES::memory::apuram, string() << basename << "-apuram.bin"); importMemory(SNES::memory::vram, string() << basename << "-vram.bin"); importMemory(SNES::memory::oam, string() << basename << "-oam.bin"); importMemory(SNES::memory::cgram, string() << basename << "-cgram.bin"); refresh(); //in case import changed values that are currently being displayed ... }
MemoryEditor::MemoryEditor() { setObjectName("memory-editor"); setWindowTitle("Memory Editor"); setGeometryString(&config().geometry.memoryEditor); application.windowList.append(this); layout = new QGridLayout; layout->setMargin(Style::WindowMargin); layout->setSpacing(Style::WidgetSpacing); setLayout(layout); editor = new QHexEdit; editor->reader = { &MemoryEditor::reader, this }; editor->writer = { &MemoryEditor::writer, this }; editor->usage = { &MemoryEditor::usage, this }; memorySource = SNES::Debugger::MemorySource::CPUBus; layout->addWidget(editor, 0, 0); controlLayout = new QVBoxLayout; controlLayout->setSpacing(0); layout->addLayout(controlLayout, 0, 1); layout->setColumnStretch(0, 1); source = new QComboBox; source->addItem("S-CPU bus"); source->addItem("S-APU bus"); source->addItem("S-PPU VRAM"); source->addItem("S-PPU OAM"); source->addItem("S-PPU CGRAM"); source->addItem("Cartridge ROM"); source->addItem("Cartridge RAM"); source->addItem("SA-1 bus"); source->addItem("GSU bus"); controlLayout->addWidget(source); controlLayout->addSpacing(2); addr = new QLineEdit; controlLayout->addWidget(addr); autoUpdateBox = new QCheckBox("Auto update"); controlLayout->addWidget(autoUpdateBox); refreshButton = new QPushButton("Refresh"); controlLayout->addWidget(refreshButton); toolLayout = new QHBoxLayout; controlLayout->addLayout(toolLayout); #define tool(widget, icon, text, slot, accel) \ widget = new QToolButton; \ toolLayout->addWidget(widget); \ widget->setAutoRaise(true); \ widget->setDefaultAction(new QAction(this)); \ widget->defaultAction()->setIcon(QIcon(":16x16/mem-" icon ".png")); \ widget->defaultAction()->setToolTip(text); \ widget->defaultAction()->setShortcut(accel); \ connect(widget->defaultAction(), SIGNAL(triggered()), this, SLOT(slot())) tool(prevCodeButton, "prev-code", "Previous Code", prevCode, 0); tool(nextCodeButton, "next-code", "Next Code", nextCode, 0); tool(prevDataButton, "prev-data", "Previous Data", prevData, 0); tool(nextDataButton, "next-data", "Next Data", nextData, 0); tool(prevUnkButton, "prev-unknown", "Previous Unknown", prevUnknown, 0); tool(nextUnkButton, "next-unknown", "Next Unknown", nextUnknown, 0); toolLayout->addStretch(); toolLayout = new QHBoxLayout; controlLayout->addLayout(toolLayout); tool(findButton, "find", "Find in Memory (Ctrl+F)", search, Qt::Key_F | Qt::CTRL); // TODO: other icons for these maybe tool(findPrevButton, "prev-unknown", "Find again up (Shift+F3)", searchPrev, Qt::Key_F3 | Qt::SHIFT); tool(findNextButton, "next-unknown", "Find again down (F3)", searchNext, Qt::Key_F3); toolLayout->addStretch(); #undef tool spacer = new QWidget; spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); controlLayout->addWidget(spacer); exportButton = new QPushButton("Export"); controlLayout->addWidget(exportButton); importButton = new QPushButton("Import"); controlLayout->addWidget(importButton); statusBar = new QLabel; layout->addWidget(statusBar, 1, 0, 1, 2); connect(editor, SIGNAL(currentAddressChanged(qint64)), this, SLOT(showAddress(qint64))); connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(sourceChanged(int))); connect(addr, SIGNAL(textEdited(const QString&)), this, SLOT(updateOffset())); connect(addr, SIGNAL(returnPressed()), this, SLOT(updateOffset())); connect(refreshButton, SIGNAL(released()), this, SLOT(refresh())); connect(exportButton, SIGNAL(released()), this, SLOT(exportMemory())); connect(importButton, SIGNAL(released()), this, SLOT(importMemory())); sourceChanged(0); }