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 QFont fixedFont("", 8, QFont::Normal);
47 fixedFont.setStyleHint(QFont::TypeWriter);
48 text->setFont(fixedFont);
49 //// layout->setSizeConstraint(QLayout::SetFixedSize);
52 layout->addWidget(text);
53 // layout->addWidget(refresh);
54 layout->addLayout(hbox1);
56 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
57 connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
61 void RISCDasmBrowserWindow::RefreshContents(void)
63 char string[1024];//, buf[64];
67 int pc = memBase, oldpc;
69 for(uint32_t i=0; i<32; i++)
72 pc += dasmjag(JAGUAR_GPU, buffer, pc);
73 sprintf(string, "%06X: %s<br>", oldpc, buffer);
75 buffer[0] = 0; // Clear string
76 char singleCharString[2] = { 0, 0 };
78 for(uint j=0; j<strlen(string); j++)
81 strcat(buffer, " ");
84 singleCharString[0] = string[j];
85 strcat(buffer, singleCharString);
97 void RISCDasmBrowserWindow::keyPressEvent(QKeyEvent * e)
99 if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return)
102 else if (e->key() == Qt::Key_PageUp)
111 else if (e->key() == Qt::Key_PageDown)
115 if (memBase > (0x1000000 - 480))
116 memBase = 0x1000000 - 480;
120 else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
129 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
133 if (memBase > (0x1000000 - 480))
134 memBase = 0x1000000 - 480;
142 void RISCDasmBrowserWindow::GoToAddress(void)
145 QString newAddress = address->text();
146 memBase = newAddress.toUInt(&ok, 16);