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);
42 // Need to set the size as well...
45 QFont fixedFont("Lucida Console", 8, QFont::Normal);
46 text->setFont(fixedFont);
47 //// layout->setSizeConstraint(QLayout::SetFixedSize);
50 layout->addWidget(text);
51 // layout->addWidget(refresh);
52 layout->addLayout(hbox1);
54 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
55 connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
59 void RISCDasmBrowserWindow::RefreshContents(void)
61 char string[1024];//, buf[64];
65 int pc = memBase, oldpc;
67 for(uint32_t i=0; i<32; i++)
70 pc += dasmjag(JAGUAR_GPU, buffer, pc);
71 sprintf(string, "%06X: %s<br>", oldpc, buffer);
73 buffer[0] = 0; // Clear string
74 char singleCharString[2] = { 0, 0 };
76 for(uint j=0; j<strlen(string); j++)
79 strcat(buffer, " ");
82 singleCharString[0] = string[j];
83 strcat(buffer, singleCharString);
95 void RISCDasmBrowserWindow::keyPressEvent(QKeyEvent * e)
97 if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return)
100 else if (e->key() == Qt::Key_PageUp)
109 else if (e->key() == Qt::Key_PageDown)
113 if (memBase > (0x1000000 - 480))
114 memBase = 0x1000000 - 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 > (0x1000000 - 480))
132 memBase = 0x1000000 - 480;
140 void RISCDasmBrowserWindow::GoToAddress(void)
143 QString newAddress = address->text();
144 memBase = newAddress.toUInt(&ok, 16);