2 // memorybrowser.cpp - Jaguar memory browser
5 // (C) 2012 Underground Software
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- -------------------------------------------------------------
11 // JLH 08/14/2012 Created this file
17 #include "memorybrowser.h"
21 MemoryBrowserWindow::MemoryBrowserWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),
22 // layout(new QVBoxLayout), text(new QTextBrowser),
23 layout(new QVBoxLayout), text(new QLabel),
24 refresh(new QPushButton(tr("Refresh"))),
27 setWindowTitle(tr("Memory Browser"));
29 // Need to set the size as well...
32 QFont fixedFont("Lucida Console", 8, QFont::Normal);
33 text->setFont(fixedFont);
34 //// layout->setSizeConstraint(QLayout::SetFixedSize);
37 layout->addWidget(text);
38 layout->addWidget(refresh);
40 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
44 void MemoryBrowserWindow::RefreshContents(void)
46 char string[1024], buf[64];
49 for(uint32_t i=0; i<480; i+=16)
51 sprintf(string, "%s%06X: ", (i != 0 ? "<br>" : ""), memBase + i);
53 for(uint32_t j=0; j<16; j++)
55 sprintf(buf, "%02X ", jaguarMainRAM[memBase + i + j]);
62 for(uint32_t j=0; j<16; j++)
64 uint8_t c = jaguarMainRAM[memBase + i + j];
65 sprintf(buf, "&#%i;", c);
68 sprintf(buf, " ");
70 if ((c < 0x20) || ((c > 0x7F) && (c < 0xA0)))
76 memDump += QString(string);
80 text->setText(memDump);
84 void MemoryBrowserWindow::keyPressEvent(QKeyEvent * e)
86 if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return)
88 else if (e->key() == Qt::Key_PageUp)
97 else if (e->key() == Qt::Key_PageDown)
101 if (memBase > (0x200000 - 480))
102 memBase = 0x200000 - 480;
106 else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
115 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
119 if (memBase > (0x200000 - 480))
120 memBase = 0x200000 - 480;