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
;
71 for (uint32_t i
= 0; i
< 32; i
++)
74 pc
+= dasmjag(JAGUAR_GPU
, buffer
, pc
);
75 sprintf(string
, "%06X: %s<br>", oldpc
, buffer
);
77 buffer
[0] = 0; // Clear string
78 char singleCharString
[2] = { 0, 0 };
80 for (uint j
= 0; j
< strlen(string
); j
++)
83 strcat(buffer
, " ");
86 singleCharString
[0] = string
[j
];
87 strcat(buffer
, singleCharString
);
100 void RISCDasmBrowserWindow::keyPressEvent(QKeyEvent
* e
)
102 if (e
->key() == Qt::Key_Escape
|| e
->key() == Qt::Key_Return
)
105 else if (e
->key() == Qt::Key_PageUp
)
114 else if (e
->key() == Qt::Key_PageDown
)
118 if (memBase
> (0x1000000 - 480))
119 memBase
= 0x1000000 - 480;
123 else if (e
->key() == Qt::Key_Up
|| e
->key() == Qt::Key_Minus
)
132 else if (e
->key() == Qt::Key_Down
|| e
->key() == Qt::Key_Equal
)
136 if (memBase
> (0x1000000 - 480))
137 memBase
= 0x1000000 - 480;
145 void RISCDasmBrowserWindow::GoToAddress(void)
148 QString newAddress
= address
->text();
149 memBase
= newAddress
.toUInt(&ok
, 16);