Debugger sources code clean-up
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / GPUDasmWin.cpp
1 //
2 // GPUdasmWin.cpp - Jaguar GPU 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/01/2017 Created this file
11 //
12
13 // STILL TO DO:
14 //
15
16 #include "GPUDasmWin.h"
17 #include "dsp.h"
18 #include "gpu.h"
19 #include "jagdasm.h"
20 #include "settings.h"
21
22
23 GPUDasmWindow::GPUDasmWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),
24 layout(new QVBoxLayout), text(new QLabel),
25 memBase(GPUReadLong(0xF02110, DEBUG))
26 {
27 QFont fixedFont("Lucida Console", 8, QFont::Normal);
28 fixedFont.setStyleHint(QFont::TypeWriter);
29 text->setFont(fixedFont);
30 setLayout(layout);
31
32 layout->addWidget(text);
33 }
34
35
36 void GPUDasmWindow::RefreshContents(void)
37 {
38 char string[1024];
39 QString s;
40 char buffer[2048];
41 int pc = memBase, oldpc;
42 uint32_t GPUPC = GPUReadLong(0xF02110, DEBUG);
43 bool GPUPCShow = false;
44
45 text->clear();
46
47 for(uint32_t i=0; i<vjs.nbrdisasmlines; i++)
48 {
49 oldpc = pc;
50 pc += dasmjag(JAGUAR_GPU, buffer, pc);
51
52 if (GPUPC == oldpc)
53 {
54 sprintf(string, "=> %06X: %s<br>", oldpc, buffer);
55 GPUPCShow = true;
56 }
57 else
58 {
59 sprintf(string, " %06X: %s<br>", oldpc, buffer);
60 }
61
62 buffer[0] = 0; // Clear string
63 char singleCharString[2] = { 0, 0 };
64
65 for(uint j=0; j<strlen(string); j++)
66 {
67 if (string[j] == 32)
68 strcat(buffer, "&nbsp;");
69 else
70 {
71 singleCharString[0] = string[j];
72 strcat(buffer, singleCharString);
73 }
74 }
75
76 s += QString(buffer);
77 }
78
79 if (GPUPCShow)
80 {
81 text->setText(s);
82 }
83 else
84 {
85 UseGPUPCAddress();
86 RefreshContents();
87 }
88 }
89
90
91 // Set mem base PC address using the 68K pc current address
92 void GPUDasmWindow::UseGPUPCAddress(void)
93 {
94 memBase = GPUReadLong(0xF02110, DEBUG);
95 }
96