2 // m68kdasmbrowser.cpp - Jaguar M68K disassembly browser
5 // (C) 2012 Underground Software
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- -------------------------------------------------------------
11 // JLH 12/01/2012 Created this file
17 #include "m68kdasmbrowser.h"
19 #include "m68000/m68kinterface.h"
24 M68KDasmBrowserWindow::M68KDasmBrowserWindow(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 address(new QLineEdit),
29 go(new QPushButton(tr("Go"))),
32 setWindowTitle(tr("M68K Disassembly Browser"));
34 address->setInputMask("hhhhhh");
35 QHBoxLayout * hbox1 = new QHBoxLayout;
36 hbox1->addWidget(refresh);
37 hbox1->addWidget(address);
40 // Need to set the size as well...
43 QFont fixedFont("Lucida Console", 8, QFont::Normal);
44 text->setFont(fixedFont);
45 //// layout->setSizeConstraint(QLayout::SetFixedSize);
48 layout->addWidget(text);
49 // layout->addWidget(refresh);
50 layout->addLayout(hbox1);
52 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
53 connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
57 void M68KDasmBrowserWindow::RefreshContents(void)
59 char string[1024];//, buf[64];
63 int pc = memBase, oldpc;
65 for(uint32_t i=0; i<32; i++)
68 pc += m68k_disassemble(buffer, pc, 0);
69 // WriteLog("%06X: %s\n", oldpc, buffer);
70 sprintf(string, "%06X: %s<br>", oldpc, buffer);
72 buffer[0] = 0; // Clear string
73 char singleCharString[2] = { 0, 0 };
75 for(int j=0; j<strlen(string); j++)
78 strcat(buffer, " ");
81 singleCharString[0] = string[j];
82 strcat(buffer, singleCharString);
86 // s += QString(string);
95 void M68KDasmBrowserWindow::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 > (0xF00000 - 64))
114 memBase = 0xF00000 - 64;
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 > (0xF00000 - 64))
132 memBase = 0xF00000 - 64;
140 void M68KDasmBrowserWindow::GoToAddress(void)
143 QString newAddress = address->text();
144 memBase = newAddress.toUInt(&ok, 16);