void MemoryViewerPanel::OnChangeToolsAddr(wxCommandEvent& event) { t_addr->GetValue().ToULong((unsigned long *)&m_addr, 16); t_addr->SetValue(wxString::Format("%08x", m_addr)); ShowMemory(); event.Skip(); }
void MemoryViewerPanel::OnScrollMemory(wxMouseEvent& event) { m_addr -= (event.ControlDown() ? m_rowcount : 1) * m_colcount * (event.GetWheelRotation() / event.GetWheelDelta()); t_addr->SetValue(wxString::Format("%08x", m_addr)); ShowMemory(); event.Skip(); }
void main(int argc, char *argv[]) { int n; memset(startdir,0,sizeof(startdir)); memset(cfgfilename,0,sizeof(cfgfilename)); ArgInit(argc, argv); VideoInit(); ShowCopyright(argc, argv); // CheckIfLocked(); ShowSysInfo(); ShowEnvInfo(); ShowMainMenu(); ShowMemory(); // CheckVersion(); ValidateConfig(); l1: ShowMemory(); SelectMainMenu(); l2: switch(mainmenu_sel) { case 0: ShowKernelMenu(); if(keycode==F2) { ShowMemory(); mainmenu_sel=1; goto l2; } else break; case 1: ShowExtenderMenu(); if(keycode==F1) { ShowMemory(); mainmenu_sel=0; goto l2; } else break; case 2: CreateConfig(); break; case 3: RestoreConfig();break; case 4: id32=id32_old; ClearConfigName(); break; case 5: DiscardExit(); break; case 6: ApplyExit(); break; } goto l1; }
void memory_viewer_panel::wheelEvent(QWheelEvent *event) { // Set some scrollspeed modifiers: u32 stepSize = 1; if (event->modifiers().testFlag(Qt::ControlModifier)) stepSize *= m_rowcount; QPoint numSteps = event->angleDelta() / 8 / 15; // http://doc.qt.io/qt-5/qwheelevent.html#pixelDelta m_addr -= stepSize * m_colcount * numSteps.y(); t_addr->setText(qstr(fmt::format("%08x", m_addr))); ShowMemory(); }
void MemoryViewerPanel::OnChangeToolsBytes(wxCommandEvent& event) { m_colcount = sc_bytes->GetValue(); int x, y; t_mem_hex->GetTextExtent(wxT("T"), &x, &y); t_mem_hex->SetMinSize(wxSize(x * 3*m_colcount + 6, 228)); t_mem_hex->SetMaxSize(wxSize(x * 3*m_colcount + 6, 228)); t_mem_ascii->SetMinSize(wxSize(x * m_colcount + 6, 228)); t_mem_ascii->SetMaxSize(wxSize(x * m_colcount + 6, 228)); this->Layout(); ShowMemory(); event.Skip(); }
MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent) : wxFrame(parent, wxID_ANY, "Memory Viewer", wxDefaultPosition, wxSize(700, 450)) { exit = false; m_addr = 0; m_colcount = 16; m_rowcount = 16; this->SetBackgroundColour(wxColour(240,240,240)); //This fix the ugly background color under Windows wxBoxSizer& s_panel = *new wxBoxSizer(wxVERTICAL); //Tools wxBoxSizer& s_tools = *new wxBoxSizer(wxHORIZONTAL); //Tools: Memory Viewer Options wxStaticBoxSizer& s_tools_mem = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Memory Viewer Options"); wxStaticBoxSizer& s_tools_mem_addr = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Address"); t_addr = new wxTextCtrl(this, wxID_ANY, "00000000", wxDefaultPosition, wxSize(60,-1)); t_addr->SetMaxLength(8); s_tools_mem_addr.Add(t_addr); wxStaticBoxSizer& s_tools_mem_bytes = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Bytes"); sc_bytes = new wxSpinCtrl(this, wxID_ANY, "16", wxDefaultPosition, wxSize(44,-1)); sc_bytes->SetRange(1, 16); s_tools_mem_bytes.Add(sc_bytes); wxStaticBoxSizer& s_tools_mem_buttons = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Control"); wxButton* b_fprev = new wxButton(this, wxID_ANY, "\u00AB", wxDefaultPosition, wxSize(21, 21)); wxButton* b_prev = new wxButton(this, wxID_ANY, "<", wxDefaultPosition, wxSize(21, 21)); wxButton* b_next = new wxButton(this, wxID_ANY, ">", wxDefaultPosition, wxSize(21, 21)); wxButton* b_fnext = new wxButton(this, wxID_ANY, "\u00BB", wxDefaultPosition, wxSize(21, 21)); s_tools_mem_buttons.Add(b_fprev); s_tools_mem_buttons.Add(b_prev); s_tools_mem_buttons.Add(b_next); s_tools_mem_buttons.Add(b_fnext); s_tools_mem.Add(&s_tools_mem_addr); s_tools_mem.Add(&s_tools_mem_bytes); s_tools_mem.Add(&s_tools_mem_buttons); //Tools: Raw Image Preview Options wxStaticBoxSizer& s_tools_img = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Raw Image Preview"); wxStaticBoxSizer& s_tools_img_size = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Size"); sc_img_size_x = new wxSpinCtrl(this, wxID_ANY, "256", wxDefaultPosition, wxSize(60,-1)); sc_img_size_y = new wxSpinCtrl(this, wxID_ANY, "256", wxDefaultPosition, wxSize(60,-1)); s_tools_img_size.Add(sc_img_size_x); s_tools_img_size.Add(new wxStaticText(this, wxID_ANY, " x ")); s_tools_img_size.Add(sc_img_size_y); sc_img_size_x->SetRange(1, 8192); sc_img_size_y->SetRange(1, 8192); wxStaticBoxSizer& s_tools_img_mode = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Mode"); cbox_img_mode = new wxComboBox(this, wxID_ANY); cbox_img_mode->Append("RGB"); cbox_img_mode->Append("ARGB"); cbox_img_mode->Append("RGBA"); cbox_img_mode->Append("ABGR"); cbox_img_mode->Select(1); //ARGB s_tools_img_mode.Add(cbox_img_mode); s_tools_img.Add(&s_tools_img_size); s_tools_img.Add(&s_tools_img_mode); //Tools: Run tools wxStaticBoxSizer& s_tools_buttons = *new wxStaticBoxSizer(wxVERTICAL, this, "Tools"); wxButton* b_img = new wxButton(this, wxID_ANY, "View\nimage", wxDefaultPosition, wxSize(52,-1)); s_tools_buttons.Add(b_img); //Tools: Tools = Memory Viewer Options + Raw Image Preview Options + Buttons s_tools.AddSpacer(10); s_tools.Add(&s_tools_mem); s_tools.AddSpacer(10); s_tools.Add(&s_tools_img); s_tools.AddSpacer(10); s_tools.Add(&s_tools_buttons); s_tools.AddSpacer(10); //Memory Panel wxBoxSizer& s_mem_panel = *new wxBoxSizer(wxHORIZONTAL); t_mem_addr = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER|wxTE_READONLY); t_mem_hex = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER|wxTE_READONLY); t_mem_ascii = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER|wxTE_READONLY); t_mem_addr->SetMinSize(wxSize(68, 228)); t_mem_addr->SetForegroundColour(wxColour(75, 135, 150)); t_mem_addr->SetScrollbar(wxVERTICAL, 0, 0, 0); t_mem_hex ->SetScrollbar(wxVERTICAL, 0, 0, 0); t_mem_ascii->SetScrollbar(wxVERTICAL, 0, 0, 0); t_mem_addr ->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); t_mem_hex ->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); t_mem_ascii->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); s_mem_panel.AddSpacer(10); s_mem_panel.Add(t_mem_addr); s_mem_panel.Add(t_mem_hex); s_mem_panel.Add(t_mem_ascii); s_mem_panel.AddSpacer(10); //Memory Panel: Set size of the wxTextCtrl's int x, y; t_mem_hex->GetTextExtent(wxT("T"), &x, &y); t_mem_hex->SetMinSize(wxSize(x * 3*m_colcount + 6, 228)); t_mem_hex->SetMaxSize(wxSize(x * 3*m_colcount + 6, 228)); t_mem_ascii->SetMinSize(wxSize(x * m_colcount + 6, 228)); t_mem_ascii->SetMaxSize(wxSize(x * m_colcount + 6, 228)); //Merge and display everything s_panel.AddSpacer(10); s_panel.Add(&s_tools); s_panel.AddSpacer(10); s_panel.Add(&s_mem_panel, 0, 0, 100); s_panel.AddSpacer(10); SetSizerAndFit(&s_panel); //Events Connect(t_addr->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MemoryViewerPanel::OnChangeToolsAddr) ); Connect(sc_bytes->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MemoryViewerPanel::OnChangeToolsBytes) ); Connect(sc_bytes->GetId(), wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(MemoryViewerPanel::OnChangeToolsBytes) ); Connect(b_prev->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::Prev)); Connect(b_next->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::Next)); Connect(b_fprev->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::fPrev)); Connect(b_fnext->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::fNext)); Connect(b_img->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MemoryViewerPanel::OnShowImage)); t_mem_addr ->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(MemoryViewerPanel::OnScrollMemory), NULL, this); t_mem_hex ->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(MemoryViewerPanel::OnScrollMemory), NULL, this); t_mem_ascii->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(MemoryViewerPanel::OnScrollMemory), NULL, this); //Fill the wxTextCtrl's ShowMemory(); };
void MemoryViewerPanel::fPrev(wxCommandEvent& WXUNUSED(event)) { m_addr -= m_rowcount * m_colcount; ShowMemory(); }
void MemoryViewerPanel::Next (wxCommandEvent& WXUNUSED(event)) { m_addr += m_colcount; ShowMemory(); }
memory_viewer_panel::memory_viewer_panel(QWidget* parent) : QDialog(parent) { setWindowTitle(tr("Memory Viewer")); setAttribute(Qt::WA_DeleteOnClose); exit = false; m_addr = 0; m_colcount = 16; m_rowcount = 16; pSize = 10; //Font and Colors mono = QFontDatabase::systemFont(QFontDatabase::FixedFont); mono.setPointSize(pSize); fontMetrics = new QFontMetrics(mono); pal_bg.setColor(QPalette::Background, QColor(240, 240, 240)); setPalette(pal_bg); //Layout: QVBoxLayout* vbox_panel = new QVBoxLayout(); //Tools QHBoxLayout* hbox_tools = new QHBoxLayout(); //Tools: Memory Viewer Options QGroupBox* tools_mem = new QGroupBox(tr("Memory Viewer Options")); QHBoxLayout* hbox_tools_mem = new QHBoxLayout(); //Tools: Memory Viewer Options: Address QGroupBox* tools_mem_addr = new QGroupBox(tr("Address")); QHBoxLayout* hbox_tools_mem_addr = new QHBoxLayout(); t_addr = new QLineEdit(this); t_addr->setPlaceholderText("00000000"); t_addr->setFont(mono); t_addr->setMaxLength(8); t_addr->setFixedWidth(75); t_addr->setFocus(); hbox_tools_mem_addr->addWidget(t_addr); tools_mem_addr->setLayout(hbox_tools_mem_addr); //Tools: Memory Viewer Options: Bytes QGroupBox* tools_mem_bytes = new QGroupBox(tr("Bytes")); QHBoxLayout* hbox_tools_mem_bytes = new QHBoxLayout(); sb_bytes = new QSpinBox(this); sb_bytes->setRange(1, 16); sb_bytes->setValue(16); hbox_tools_mem_bytes->addWidget(sb_bytes); tools_mem_bytes->setLayout(hbox_tools_mem_bytes); //Tools: Memory Viewer Options: Control QGroupBox* tools_mem_buttons = new QGroupBox(tr("Control")); QHBoxLayout* hbox_tools_mem_buttons = new QHBoxLayout(); QPushButton* b_fprev = new QPushButton("<<", this); QPushButton* b_prev = new QPushButton("<", this); QPushButton* b_next = new QPushButton(">", this); QPushButton* b_fnext = new QPushButton(">>", this); b_fprev->setFixedWidth(20); b_prev->setFixedWidth(20); b_next->setFixedWidth(20); b_fnext->setFixedWidth(20); b_fprev->setAutoDefault(false); b_prev->setAutoDefault(false); b_next->setAutoDefault(false); b_fnext->setAutoDefault(false); hbox_tools_mem_buttons->addWidget(b_fprev); hbox_tools_mem_buttons->addWidget(b_prev); hbox_tools_mem_buttons->addWidget(b_next); hbox_tools_mem_buttons->addWidget(b_fnext); tools_mem_buttons->setLayout(hbox_tools_mem_buttons); //Merge Tools: Memory Viewer hbox_tools_mem->addWidget(tools_mem_addr); hbox_tools_mem->addWidget(tools_mem_bytes); hbox_tools_mem->addWidget(tools_mem_buttons); tools_mem->setLayout(hbox_tools_mem); //Tools: Raw Image Preview Options QGroupBox* tools_img = new QGroupBox(tr("Raw Image Preview Options")); QHBoxLayout* hbox_tools_img = new QHBoxLayout();; //Tools: Raw Image Preview Options : Size QGroupBox* tools_img_size = new QGroupBox(tr("Size")); QHBoxLayout* hbox_tools_img_size = new QHBoxLayout(); QLabel* l_x = new QLabel(" x "); sb_img_size_x = new QSpinBox(this); sb_img_size_y = new QSpinBox(this); sb_img_size_x->setRange(1, 8192); sb_img_size_y->setRange(1, 8192); sb_img_size_x->setValue(256); sb_img_size_y->setValue(256); hbox_tools_img_size->addWidget(sb_img_size_x); hbox_tools_img_size->addWidget(l_x); hbox_tools_img_size->addWidget(sb_img_size_y); tools_img_size->setLayout(hbox_tools_img_size); //Tools: Raw Image Preview Options: Mode QGroupBox* tools_img_mode = new QGroupBox(tr("Mode")); QHBoxLayout* hbox_tools_img_mode = new QHBoxLayout(); cbox_img_mode = new QComboBox(this); cbox_img_mode->addItem("RGB"); cbox_img_mode->addItem("ARGB"); cbox_img_mode->addItem("RGBA"); cbox_img_mode->addItem("ABGR"); cbox_img_mode->setCurrentIndex(1); //ARGB hbox_tools_img_mode->addWidget(cbox_img_mode); tools_img_mode->setLayout(hbox_tools_img_mode); //Merge Tools: Raw Image Preview Options hbox_tools_img->addWidget(tools_img_size); hbox_tools_img->addWidget(tools_img_mode); tools_img->setLayout(hbox_tools_img); //Tools: Tool Buttons QGroupBox* tools_buttons = new QGroupBox(tr("Tools")); QVBoxLayout* hbox_tools_buttons = new QVBoxLayout(this); QPushButton* b_img = new QPushButton(tr("View\nimage"), this); b_img->setAutoDefault(false); hbox_tools_buttons->addWidget(b_img); tools_buttons->setLayout(hbox_tools_buttons); //Merge Tools = Memory Viewer Options + Raw Image Preview Options + Tool Buttons hbox_tools->addSpacing(10); hbox_tools->addWidget(tools_mem); hbox_tools->addWidget(tools_img); hbox_tools->addWidget(tools_buttons); hbox_tools->addSpacing(10); //Memory Panel: QHBoxLayout* hbox_mem_panel = new QHBoxLayout(); //Memory Panel: Address Panel t_mem_addr = new QLabel(""); t_mem_addr->setFont(mono); t_mem_addr->setAutoFillBackground(true); t_mem_addr->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); QPalette palette_addr = t_mem_addr->palette(); palette_addr.setColor(t_mem_addr->backgroundRole(), QColor(240, 240, 240)); palette_addr.setColor(t_mem_addr->foregroundRole(), QColor(75, 135, 150)); t_mem_addr->setPalette(palette_addr); //Memory Panel: Hex Panel t_mem_hex = new QLabel(""); t_mem_hex->setFont(mono); t_mem_hex->setAutoFillBackground(true); t_mem_hex->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); QPalette palette_hex = t_mem_hex->palette(); palette_hex.setColor(t_mem_hex->backgroundRole(), QColor(240, 240, 240)); palette_hex.setColor(t_mem_hex->foregroundRole(), Qt::black); t_mem_hex->setPalette(palette_hex); //Memory Panel: ASCII Panel t_mem_ascii = new QLabel(""); t_mem_ascii->setFont(mono); t_mem_ascii->setAutoFillBackground(true); t_mem_ascii->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); QPalette palette_ascii = t_mem_ascii->palette(); palette_ascii.setColor(t_mem_ascii->backgroundRole(), QColor(240, 240, 240)); palette_ascii.setColor(t_mem_ascii->foregroundRole(), Qt::black); t_mem_ascii->setPalette(palette_ascii); //Merge Memory Panel: hbox_mem_panel->setAlignment(Qt::AlignLeft); hbox_mem_panel->addSpacing(20); hbox_mem_panel->addWidget(t_mem_addr); hbox_mem_panel->addSpacing(10); hbox_mem_panel->addWidget(t_mem_hex); hbox_mem_panel->addSpacing(10); hbox_mem_panel->addWidget(t_mem_ascii); hbox_mem_panel->addSpacing(10); //Memory Panel: Set size of the QTextEdits t_mem_hex->setFixedSize(QSize(pSize * 3 * m_colcount + 6, 228)); t_mem_ascii->setFixedSize(QSize(pSize * m_colcount + 6, 228)); //Set Margins to adjust WindowSize vbox_panel->setContentsMargins(0, 0, 0, 0); hbox_tools->setContentsMargins(0, 0, 0, 0); tools_mem_addr->setContentsMargins(0, 10, 0, 0); tools_mem_bytes->setContentsMargins(0, 10, 0, 0); tools_mem_buttons->setContentsMargins(0, 10, 0, 0); tools_img_mode->setContentsMargins(0, 10, 0, 0); tools_img_size->setContentsMargins(0, 10, 0, 0); tools_mem->setContentsMargins(0, 10, 0, 0); tools_img->setContentsMargins(0, 10, 0, 0); tools_buttons->setContentsMargins(0, 10, 0, 0); hbox_mem_panel->setContentsMargins(0, 0, 0, 0); //Merge and display everything vbox_panel->addSpacing(10); vbox_panel->addLayout(hbox_tools); vbox_panel->addSpacing(10); vbox_panel->addLayout(hbox_mem_panel); vbox_panel->addSpacing(10); setLayout(vbox_panel); //Events connect(t_addr, &QLineEdit::returnPressed, [=](){ bool ok; m_addr = t_addr->text().toULong(&ok, 16); t_addr->setText(QString("%1").arg(m_addr, 8, 16, QChar('0'))); // get 8 digits in input line ShowMemory(); }); connect(sb_bytes, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](){ m_colcount = sb_bytes->value(); t_mem_hex->setFixedSize(QSize(pSize * 3 * m_colcount + 6, 228)); t_mem_ascii->setFixedSize(QSize(pSize * m_colcount + 6, 228)); ShowMemory(); }); connect(b_prev, &QAbstractButton::clicked, [=]() { m_addr -= m_colcount; ShowMemory(); }); connect(b_next, &QAbstractButton::clicked, [=]() { m_addr += m_colcount; ShowMemory(); }); connect(b_fprev, &QAbstractButton::clicked, [=]() { m_addr -= m_rowcount * m_colcount; ShowMemory(); }); connect(b_fnext, &QAbstractButton::clicked, [=]() { m_addr += m_rowcount * m_colcount; ShowMemory(); }); connect(b_img, &QAbstractButton::clicked, [=]() { u32 addr = m_addr; int mode = cbox_img_mode->currentIndex(); int sizex = sb_img_size_x->value(); int sizey = sb_img_size_y->value(); ShowImage(this, m_addr, mode, sizex, sizey, false); }); //Fill the QTextEdits ShowMemory(); setFixedSize(sizeHint()); };