2 // riscdasmbrowser.cpp - Jaguar RISC disassembly browser
5 // (C) 2013 Underground Software
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- -------------------------------------------------------------
11 // JLH 01/22/2012 Created this file
17 #include "riscdasmbrowser.h"
24 RISCDasmBrowserWindow::RISCDasmBrowserWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),
25 // layout(new QVBoxLayout), text(new QTextBrowser),
26 layout(new QVBoxLayout), text(new QLabel),
27 refresh(new QPushButton(tr("Refresh"))),
28 go(new QPushButton(tr("Go"))),
29 address(new QLineEdit),
30 gpu(new QRadioButton(tr("GPU"))),
31 dsp(new QRadioButton(tr("DSP"))),
34 setWindowTitle(tr("RISC Disassembly Browser"));
36 address->setInputMask("hhhhhh");
37 QHBoxLayout * hbox1 = new QHBoxLayout;
38 hbox1->addWidget(refresh);
39 hbox1->addWidget(address);
43 // Need to set the size as well...
46 QFont fixedFont("Lucida Console", 8, QFont::Normal);
47 text->setFont(fixedFont);
48 //// layout->setSizeConstraint(QLayout::SetFixedSize);
51 layout->addWidget(text);
52 // layout->addWidget(refresh);
53 layout->addLayout(hbox1);
55 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
56 connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
60 void RISCDasmBrowserWindow::RefreshContents(void)
62 char string[1024];//, buf[64];
66 int pc = memBase, oldpc;
68 for(uint32_t i=0; i<32; i++)
71 pc += dasmjag(JAGUAR_GPU, buffer, pc);
72 sprintf(string, "%06X: %s<br>", oldpc, buffer);
74 buffer[0] = 0; // Clear string
75 char singleCharString[2] = { 0, 0 };
77 for(uint j=0; j<strlen(string); j++)
80 strcat(buffer, " ");
83 singleCharString[0] = string[j];
84 strcat(buffer, singleCharString);
96 void RISCDasmBrowserWindow::keyPressEvent(QKeyEvent * e)
98 if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return)
101 else if (e->key() == Qt::Key_PageUp)
110 else if (e->key() == Qt::Key_PageDown)
114 if (memBase > (0x1000000 - 480))
115 memBase = 0x1000000 - 480;
119 else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
128 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
132 if (memBase > (0x1000000 - 480))
133 memBase = 0x1000000 - 480;
141 void RISCDasmBrowserWindow::GoToAddress(void)
144 QString newAddress = address->text();
145 memBase = newAddress.toUInt(&ok, 16);