Local variables window detects now if a variable is used or not by the code
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / DSPDasmWin.cpp
CommitLineData
cf76e892
JPM
1//
2// DSPDasmWin.cpp - Jaguar DSP disassembly window
3//
4// by Jean-Paul Mari
5//
6// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7//
8// Who When What
9// --- ---------- -------------------------------------------------------------
10// JPM 02/02/2017 Created this file
11//
12
13// STILL TO DO:
14//
15
16#include "DSPDasmWin.h"
17//#include "memory.h"
18#include "dsp.h"
19#include "gpu.h"
20#include "jagdasm.h"
21#include "settings.h"
22
23
24DSPDasmWindow::DSPDasmWindow(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"))),
32 //memBase(0x4000)
33 memBase(DSPReadLong(0xF1A110, DEBUG))
34{
35 //setWindowTitle(tr("RISC Disassembly Browser"));
36
37 //address->setInputMask("hhhhhh");
38 //QHBoxLayout * hbox1 = new QHBoxLayout;
39 //hbox1->addWidget(refresh);
40 //hbox1->addWidget(address);
41 //hbox1->addWidget(go);
42
43 // Need to set the size as well...
44// resize(560, 480);
45
46 QFont fixedFont("Lucida Console", 8, QFont::Normal);
47// QFont fixedFont("", 8, QFont::Normal);
48 fixedFont.setStyleHint(QFont::TypeWriter);
49 text->setFont(fixedFont);
50//// layout->setSizeConstraint(QLayout::SetFixedSize);
51 setLayout(layout);
52
53 layout->addWidget(text);
54// layout->addWidget(refresh);
55 //layout->addLayout(hbox1);
56
57 //connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
58 //connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
59}
60
61
62void DSPDasmWindow::RefreshContents(void)
63{
64 char string[1024];//, buf[64];
65 QString s;
66 char buffer[2048];
67 int pc = memBase, oldpc;
68 uint32_t DSPPC = DSPReadLong(0xF1A110, DEBUG);
69 bool DSPPCShow = false;
70
71 text->clear();
72
73 for(uint32_t i=0; i<vjs.nbrdisasmlines; i++)
74 {
75 oldpc = pc;
76 pc += dasmjag(JAGUAR_DSP, buffer, pc);
77
78 if (DSPPC == oldpc)
79 {
80 sprintf(string, "=> %06X: %s<br>", oldpc, buffer);
81 DSPPCShow = true;
82 }
83 else
84 {
85 sprintf(string, " %06X: %s<br>", oldpc, buffer);
86 }
87
88 buffer[0] = 0; // Clear string
89 char singleCharString[2] = { 0, 0 };
90
91 for(uint j=0; j<strlen(string); j++)
92 {
93 if (string[j] == 32)
94 strcat(buffer, "&nbsp;");
95 else
96 {
97 singleCharString[0] = string[j];
98 strcat(buffer, singleCharString);
99 }
100 }
101
102 s += QString(buffer);
103 }
104
105// text->clear();
106 if (DSPPCShow)
107 {
108 text->setText(s);
109 }
110 else
111 {
112 UseDSPPCAddress();
113 RefreshContents();
114 }
115}
116
117
118#if 0
119void DSPDasmWindow::keyPressEvent(QKeyEvent * e)
120{
121 if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return)
122 hide();
123#if 1
124 else if (e->key() == Qt::Key_PageUp)
125 {
126 memBase -= 64;
127
128 if (memBase < 0)
129 memBase = 0;
130
131 RefreshContents();
132 }
133 else if (e->key() == Qt::Key_PageDown)
134 {
135 memBase += 64;
136
137 if (memBase > (0x1000000 - 480))
138 memBase = 0x1000000 - 480;
139
140 RefreshContents();
141 }
142 else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
143 {
144 memBase -= 2;
145
146 if (memBase < 0)
147 memBase = 0;
148
149 RefreshContents();
150 }
151 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
152 {
153 memBase += 2;
154
155 if (memBase > (0x1000000 - 480))
156 memBase = 0x1000000 - 480;
157
158 RefreshContents();
159 }
160#endif
161}
162#endif
163
164
165#if 0
166void DSPDasmWindow::GoToAddress(void)
167{
168 bool ok;
169 QString newAddress = address->text();
170 memBase = newAddress.toUInt(&ok, 16);
171 RefreshContents();
172}
173#endif
174
175
176// Set mem base PC address using the 68K pc current address
177void DSPDasmWindow::UseDSPPCAddress(void)
178{
179 memBase = DSPReadLong(0xF1A110, DEBUG);
180}
181
182
183// Set mem base PC address
184#if 0
185void DSPDasmWindow::SetAddress(int address)
186{
187 memBase = address;
188 // RefreshContents();
189}
190#endif