2 // stackbrowser.cpp - Jaguar stack browser
5 // (C) 2012 Underground Software
7 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
10 // --- ---------- -----------------------------------------------------------
11 // JPM 01/11/2017 Created this file
17 #include "stackbrowser.h"
19 #include "m68000/m68kinterface.h"
23 StackBrowserWindow::StackBrowserWindow(QWidget
* parent
/*= 0*/): QWidget(parent
, Qt::Dialog
),
24 // layout(new QVBoxLayout), text(new QTextBrowser),
25 layout(new QVBoxLayout
),
27 //refresh(new QPushButton(tr("Refresh"))),
28 //address(new QLineEdit),
29 //go(new QPushButton(tr("Go"))),
30 memBase(m68k_get_reg(NULL
, M68K_REG_SP
))
32 setWindowTitle(tr("Stack Browser"));
35 address->setInputMask("hhhhhh");
36 QHBoxLayout * hbox1 = new QHBoxLayout;
37 hbox1->addWidget(refresh);
38 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);
55 layout->addLayout(hbox1);
59 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
60 connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
66 void StackBrowserWindow::RefreshContents(void)
68 char string
[1024], buf
[64];
75 memBase
= m68k_get_reg(NULL
, M68K_REG_SP
);
77 for (i
= 0; i
< 480; i
+= 16)
79 if ((memBase
+ i
) < vjs
.DRAM_size
)
81 sprintf(string
, "%s%06X: ", (i
? "<br>" : ""), (unsigned int)(memBase
+ i
));
83 for (j
= 0; j
< 16; j
++)
85 if ((memBase
+ i
+ j
) < vjs
.DRAM_size
)
87 sprintf(buf
, "%02X ", jaguarMainRAM
[memBase
+ i
+ j
]);
93 sprintf(buf
, " ");
100 #pragma message("Warning: !!! Need to dig the reason(s) why the 2nd line needs to use the instead of space !!!")
102 #warning "!!! Need to dig the reason(s) why the 2nd line needs to use the instead of space !!!"
108 //sprintf(buf, "| ");
109 //strcat(string, buf);
110 strcat(string
, "| ");
112 for (j
= 0; j
< 16; j
++)
114 if ((memBase
+ i
+ j
) < vjs
.DRAM_size
)
116 c
= jaguarMainRAM
[memBase
+ i
+ j
];
117 //sprintf(buf, "&#%i;", c);
121 // sprintf(buf, " ");
125 if ((c
<= 0x20) || (c
> 0x7E))
132 //sprintf(buf, "&#%i;", c);
142 memDump
+= QString(string
);
147 text
->setText(memDump
);
153 void StackBrowserWindow::keyPressEvent(QKeyEvent * e)
155 if (e->key() == Qt::Key_Escape)
157 else if (e->key() == Qt::Key_PageUp)
166 else if (e->key() == Qt::Key_PageDown)
170 if (memBase > (0x200000 - 480))
171 memBase = 0x200000 - 480;
175 else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
184 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
188 if (memBase > (0x200000 - 480))
189 memBase = 0x200000 - 480;
198 void StackBrowserWindow::GoToAddress(void)
201 QString newAddress = address->text();
202 memBase = newAddress.toUInt(&ok, 16);