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"))),
25 address(new QLineEdit),
26 go(new QPushButton(tr("Go"))),
29 setWindowTitle(tr("Memory Browser"));
31 address->setInputMask("hhhhhh");
32 QHBoxLayout * hbox1 = new QHBoxLayout;
33 hbox1->addWidget(refresh);
34 hbox1->addWidget(address);
37 // Need to set the size as well...
40 // QFont fixedFont("Lucida Console", 8, QFont::Normal);
41 QFont fixedFont("", 8, QFont::Normal);
42 fixedFont.setStyleHint(QFont::TypeWriter);
43 text->setFont(fixedFont);
44 //// layout->setSizeConstraint(QLayout::SetFixedSize);
47 layout->addWidget(text);
48 // layout->addWidget(refresh);
49 layout->addLayout(hbox1);
51 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
52 connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
56 void MemoryBrowserWindow::RefreshContents(void)
58 char string[1024], buf[64];
61 for(uint32_t i=0; i<480; i+=16)
63 sprintf(string, "%s%06X: ", (i != 0 ? "<br>" : ""), memBase + i);
65 for(uint32_t j=0; j<16; j++)
67 sprintf(buf, "%02X ", jaguarMainRAM[memBase + i + j]);
74 for(uint32_t j=0; j<16; j++)
76 uint8_t c = jaguarMainRAM[memBase + i + j];
77 sprintf(buf, "&#%i;", c);
80 sprintf(buf, " ");
82 if ((c < 0x20) || ((c > 0x7F) && (c < 0xA0)))
88 memDump += QString(string);
92 text->setText(memDump);
96 void MemoryBrowserWindow::keyPressEvent(QKeyEvent * e)
98 if (e->key() == Qt::Key_Escape)
100 else if (e->key() == Qt::Key_PageUp)
109 else if (e->key() == Qt::Key_PageDown)
113 if (memBase > (0x200000 - 480))
114 memBase = 0x200000 - 480;
118 else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
127 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
131 if (memBase > (0x200000 - 480))
132 memBase = 0x200000 - 480;
139 void MemoryBrowserWindow::GoToAddress(void)
142 QString newAddress = address->text();
143 memBase = newAddress.toUInt(&ok, 16);