Commit | Line | Data |
---|---|---|
cf76e892 JPM |
1 | // |
2 | // stackbrowser.cpp - Jaguar stack browser | |
3 | // | |
4 | // by James Hammons | |
5 | // (C) 2012 Underground Software | |
6 | // | |
7 | // JPM = Jean-Paul Mari <djipi.mari@gmail.com> | |
8 | // | |
9 | // Who When What | |
10 | // --- ---------- ----------------------------------------------------------- | |
11 | // JPM 01/11/2017 Created this file | |
12 | // | |
13 | ||
14 | // STILL TO DO: | |
15 | // | |
16 | ||
17 | #include "stackbrowser.h" | |
18 | #include "memory.h" | |
19 | #include "m68000/m68kinterface.h" | |
20 | #include "settings.h" | |
21 | ||
22 | ||
23 | StackBrowserWindow::StackBrowserWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog), | |
24 | // layout(new QVBoxLayout), text(new QTextBrowser), | |
25 | layout(new QVBoxLayout), | |
26 | text(new QLabel), | |
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)) | |
31 | { | |
32 | setWindowTitle(tr("Stack Browser")); | |
33 | ||
34 | /* | |
35 | address->setInputMask("hhhhhh"); | |
36 | QHBoxLayout * hbox1 = new QHBoxLayout; | |
37 | hbox1->addWidget(refresh); | |
38 | hbox1->addWidget(address); | |
39 | hbox1->addWidget(go); | |
40 | */ | |
41 | ||
42 | // Need to set the size as well... | |
43 | // resize(560, 480); | |
44 | ||
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); | |
50 | setLayout(layout); | |
51 | ||
52 | layout->addWidget(text); | |
53 | // layout->addWidget(refresh); | |
54 | /* | |
55 | layout->addLayout(hbox1); | |
56 | */ | |
57 | ||
58 | /* | |
59 | connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents())); | |
60 | connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress())); | |
61 | */ | |
62 | } | |
63 | ||
64 | ||
65 | // | |
66 | void StackBrowserWindow::RefreshContents(void) | |
67 | { | |
68 | char string[1024], buf[64]; | |
69 | QString memDump; | |
70 | size_t i, j; | |
71 | uint8_t c; | |
72 | ||
73 | if (isVisible()) | |
74 | { | |
75 | memBase = m68k_get_reg(NULL, M68K_REG_SP); | |
76 | ||
77 | for (i = 0; i < 480; i += 16) | |
78 | { | |
79 | if ((memBase + i) < vjs.DRAM_size) | |
80 | { | |
81 | sprintf(string, "%s%06X: ", (i ? "<br>" : ""), (unsigned int)(memBase + i)); | |
82 | ||
83 | for (j = 0; j < 16; j++) | |
84 | { | |
85 | if ((memBase + i + j) < vjs.DRAM_size) | |
86 | { | |
87 | sprintf(buf, "%02X ", jaguarMainRAM[memBase + i + j]); | |
88 | } | |
89 | else | |
90 | { | |
91 | if (i) | |
92 | { | |
93 | sprintf(buf, " "); | |
94 | } | |
95 | else | |
96 | { | |
97 | sprintf(buf, " "); | |
98 | } | |
99 | #ifdef _MSC_VER | |
100 | #pragma message("Warning: !!! Need to dig the reason(s) why the 2nd line needs to use the instead of space !!!") | |
101 | #else | |
102 | #warning "!!! Need to dig the reason(s) why the 2nd line needs to use the instead of space !!!" | |
103 | #endif // _MSC_VER | |
104 | } | |
105 | strcat(string, buf); | |
106 | } | |
107 | ||
108 | //sprintf(buf, "| "); | |
109 | //strcat(string, buf); | |
110 | strcat(string, "| "); | |
111 | ||
112 | for (j = 0; j < 16; j++) | |
113 | { | |
114 | if ((memBase + i + j) < vjs.DRAM_size) | |
115 | { | |
116 | c = jaguarMainRAM[memBase + i + j]; | |
117 | //sprintf(buf, "&#%i;", c); | |
118 | ||
119 | //if (c == 0x20) | |
120 | //{ | |
121 | // sprintf(buf, " "); | |
122 | //} | |
123 | //else | |
124 | { | |
125 | if ((c <= 0x20) || (c > 0x7E)) | |
126 | { | |
127 | //sprintf(buf, "."); | |
128 | buf[0] = '.'; | |
129 | } | |
130 | else | |
131 | { | |
132 | //sprintf(buf, "&#%i;", c); | |
133 | buf[0] = c; | |
134 | } | |
135 | buf[1] = 0; | |
136 | } | |
137 | ||
138 | strcat(string, buf); | |
139 | } | |
140 | } | |
141 | ||
142 | memDump += QString(string); | |
143 | } | |
144 | } | |
145 | ||
146 | text->clear(); | |
147 | text->setText(memDump); | |
148 | } | |
149 | } | |
150 | ||
151 | ||
152 | /* | |
153 | void StackBrowserWindow::keyPressEvent(QKeyEvent * e) | |
154 | { | |
155 | if (e->key() == Qt::Key_Escape) | |
156 | hide(); | |
157 | else if (e->key() == Qt::Key_PageUp) | |
158 | { | |
159 | memBase -= 480; | |
160 | ||
161 | if (memBase < 0) | |
162 | memBase = 0; | |
163 | ||
164 | RefreshContents(); | |
165 | } | |
166 | else if (e->key() == Qt::Key_PageDown) | |
167 | { | |
168 | memBase += 480; | |
169 | ||
170 | if (memBase > (0x200000 - 480)) | |
171 | memBase = 0x200000 - 480; | |
172 | ||
173 | RefreshContents(); | |
174 | } | |
175 | else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus) | |
176 | { | |
177 | memBase -= 16; | |
178 | ||
179 | if (memBase < 0) | |
180 | memBase = 0; | |
181 | ||
182 | RefreshContents(); | |
183 | } | |
184 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal) | |
185 | { | |
186 | memBase += 16; | |
187 | ||
188 | if (memBase > (0x200000 - 480)) | |
189 | memBase = 0x200000 - 480; | |
190 | ||
191 | RefreshContents(); | |
192 | } | |
193 | } | |
194 | */ | |
195 | ||
196 | ||
197 | /* | |
198 | void StackBrowserWindow::GoToAddress(void) | |
199 | { | |
200 | bool ok; | |
201 | QString newAddress = address->text(); | |
202 | memBase = newAddress.toUInt(&ok, 16); | |
203 | RefreshContents(); | |
204 | } | |
205 | */ |