2 // cpubrowser.cpp - Jaguar CPU browser
5 // (C) 2012 Underground Software
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- -------------------------------------------------------------
11 // JLH 08/14/2012 Created this file
17 #include "cpubrowser.h"
19 #include "m68000/m68kinterface.h"
24 CPUBrowserWindow::CPUBrowserWindow(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"))),
30 setWindowTitle(tr("CPU Browser"));
32 // Need to set the size as well...
35 QFont fixedFont("Lucida Console", 8, QFont::Normal);
36 text->setFont(fixedFont);
37 //// layout->setSizeConstraint(QLayout::SetFixedSize);
40 layout->addWidget(text);
41 layout->addWidget(refresh);
43 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
47 void CPUBrowserWindow::RefreshContents(void)
53 uint32_t m68kPC = m68k_get_reg(NULL, M68K_REG_PC);
54 uint32_t m68kSR = m68k_get_reg(NULL, M68K_REG_SR);
55 sprintf(string, "PC: %06X SR: %04X<br><br>", m68kPC, m68kSR);
58 uint32_t m68kA0 = m68k_get_reg(NULL, M68K_REG_A0);
59 uint32_t m68kA1 = m68k_get_reg(NULL, M68K_REG_A1);
60 uint32_t m68kA2 = m68k_get_reg(NULL, M68K_REG_A2);
61 uint32_t m68kA3 = m68k_get_reg(NULL, M68K_REG_A3);
62 sprintf(string, "A0: %08X A1: %08X A2: %08X A3: %08X<br>", m68kA0, m68kA1, m68kA2, m68kA3);
65 uint32_t m68kA4 = m68k_get_reg(NULL, M68K_REG_A4);
66 uint32_t m68kA5 = m68k_get_reg(NULL, M68K_REG_A5);
67 uint32_t m68kA6 = m68k_get_reg(NULL, M68K_REG_A6);
68 uint32_t m68kA7 = m68k_get_reg(NULL, M68K_REG_A7);
69 sprintf(string, "A4: %08X A5: %08X A6: %08X A7: %08X<br><br>", m68kA4, m68kA5, m68kA6, m68kA7);
72 uint32_t m68kD0 = m68k_get_reg(NULL, M68K_REG_D0);
73 uint32_t m68kD1 = m68k_get_reg(NULL, M68K_REG_D1);
74 uint32_t m68kD2 = m68k_get_reg(NULL, M68K_REG_D2);
75 uint32_t m68kD3 = m68k_get_reg(NULL, M68K_REG_D3);
76 sprintf(string, "D0: %08X D1: %08X D2: %08X D3: %08X<br>", m68kD0, m68kD1, m68kD2, m68kD3);
79 uint32_t m68kD4 = m68k_get_reg(NULL, M68K_REG_D4);
80 uint32_t m68kD5 = m68k_get_reg(NULL, M68K_REG_D5);
81 uint32_t m68kD6 = m68k_get_reg(NULL, M68K_REG_D6);
82 uint32_t m68kD7 = m68k_get_reg(NULL, M68K_REG_D7);
83 sprintf(string, "D4: %08X D5: %08X D6: %08X D7: %08X<br><br>", m68kD4, m68kD5, m68kD6, m68kD7);
87 sprintf(string, "GPU PC: %06X FLAGS: %08X<br><br>", GPUReadLong(0xF02010), GPUReadLong(0xF02000));
90 sprintf(string, "Bank 0:<br>"
91 "R00: %08X R01: %08X R02: %08X R03: %08X<br>"
92 "R04: %08X R05: %08X R06: %08X R07: %08X<br>"
93 "R08: %08X R09: %08X R10: %08X R11: %08X<br>"
94 "R12: %08X R13: %08X R14: %08X R15: %08X<br>"
95 "R16: %08X R17: %08X R18: %08X R19: %08X<br>"
96 "R20: %08X R21: %08X R22: %08X R23: %08X<br>"
97 "R24: %08X R25: %08X R26: %08X R27: %08X<br>"
98 "R28: %08X R29: %08X R30: %08X R31: %08X<br><br>",
99 gpu_reg_bank_0[0], gpu_reg_bank_0[1], gpu_reg_bank_0[2], gpu_reg_bank_0[3],
100 gpu_reg_bank_0[4], gpu_reg_bank_0[5], gpu_reg_bank_0[6], gpu_reg_bank_0[7],
101 gpu_reg_bank_0[8], gpu_reg_bank_0[9], gpu_reg_bank_0[10], gpu_reg_bank_0[11],
102 gpu_reg_bank_0[12], gpu_reg_bank_0[13], gpu_reg_bank_0[14], gpu_reg_bank_0[15],
103 gpu_reg_bank_0[16], gpu_reg_bank_0[17], gpu_reg_bank_0[18], gpu_reg_bank_0[19],
104 gpu_reg_bank_0[20], gpu_reg_bank_0[21], gpu_reg_bank_0[22], gpu_reg_bank_0[23],
105 gpu_reg_bank_0[24], gpu_reg_bank_0[25], gpu_reg_bank_0[26], gpu_reg_bank_0[27],
106 gpu_reg_bank_0[28], gpu_reg_bank_0[29], gpu_reg_bank_0[30], gpu_reg_bank_0[31]);
107 s += QString(string);
109 sprintf(string, "Bank 1:<br>"
110 "R00: %08X R01: %08X R02: %08X R03: %08X<br>"
111 "R04: %08X R05: %08X R06: %08X R07: %08X<br>"
112 "R08: %08X R09: %08X R10: %08X R11: %08X<br>"
113 "R12: %08X R13: %08X R14: %08X R15: %08X<br>"
114 "R16: %08X R17: %08X R18: %08X R19: %08X<br>"
115 "R20: %08X R21: %08X R22: %08X R23: %08X<br>"
116 "R24: %08X R25: %08X R26: %08X R27: %08X<br>"
117 "R28: %08X R29: %08X R30: %08X R31: %08X<br><br>",
118 gpu_reg_bank_1[0], gpu_reg_bank_1[1], gpu_reg_bank_1[2], gpu_reg_bank_1[3],
119 gpu_reg_bank_1[4], gpu_reg_bank_1[5], gpu_reg_bank_1[6], gpu_reg_bank_1[7],
120 gpu_reg_bank_1[8], gpu_reg_bank_1[9], gpu_reg_bank_1[10], gpu_reg_bank_1[11],
121 gpu_reg_bank_1[12], gpu_reg_bank_1[13], gpu_reg_bank_1[14], gpu_reg_bank_1[15],
122 gpu_reg_bank_1[16], gpu_reg_bank_1[17], gpu_reg_bank_1[18], gpu_reg_bank_1[19],
123 gpu_reg_bank_1[20], gpu_reg_bank_1[21], gpu_reg_bank_1[22], gpu_reg_bank_1[23],
124 gpu_reg_bank_1[24], gpu_reg_bank_1[25], gpu_reg_bank_1[26], gpu_reg_bank_1[27],
125 gpu_reg_bank_1[28], gpu_reg_bank_1[29], gpu_reg_bank_1[30], gpu_reg_bank_1[31]);
126 s += QString(string);
129 sprintf(string, "DSP PC: %06X FLAGS: %08X<br><br>", DSPReadLong(0xF1A110), DSPReadLong(0xF1A100));
130 s += QString(string);
132 sprintf(string, "Bank 0:<br>"
133 "R00: %08X R01: %08X R02: %08X R03: %08X<br>"
134 "R04: %08X R05: %08X R06: %08X R07: %08X<br>"
135 "R08: %08X R09: %08X R10: %08X R11: %08X<br>"
136 "R12: %08X R13: %08X R14: %08X R15: %08X<br>"
137 "R16: %08X R17: %08X R18: %08X R19: %08X<br>"
138 "R20: %08X R21: %08X R22: %08X R23: %08X<br>"
139 "R24: %08X R25: %08X R26: %08X R27: %08X<br>"
140 "R28: %08X R29: %08X R30: %08X R31: %08X<br><br>",
141 dsp_reg_bank_0[0], dsp_reg_bank_0[1], dsp_reg_bank_0[2], dsp_reg_bank_0[3],
142 dsp_reg_bank_0[4], dsp_reg_bank_0[5], dsp_reg_bank_0[6], dsp_reg_bank_0[7],
143 dsp_reg_bank_0[8], dsp_reg_bank_0[9], dsp_reg_bank_0[10], dsp_reg_bank_0[11],
144 dsp_reg_bank_0[12], dsp_reg_bank_0[13], dsp_reg_bank_0[14], dsp_reg_bank_0[15],
145 dsp_reg_bank_0[16], dsp_reg_bank_0[17], dsp_reg_bank_0[18], dsp_reg_bank_0[19],
146 dsp_reg_bank_0[20], dsp_reg_bank_0[21], dsp_reg_bank_0[22], dsp_reg_bank_0[23],
147 dsp_reg_bank_0[24], dsp_reg_bank_0[25], dsp_reg_bank_0[26], dsp_reg_bank_0[27],
148 dsp_reg_bank_0[28], dsp_reg_bank_0[29], dsp_reg_bank_0[30], dsp_reg_bank_0[31]);
149 s += QString(string);
151 sprintf(string, "Bank 1:<br>"
152 "R00: %08X R01: %08X R02: %08X R03: %08X<br>"
153 "R04: %08X R05: %08X R06: %08X R07: %08X<br>"
154 "R08: %08X R09: %08X R10: %08X R11: %08X<br>"
155 "R12: %08X R13: %08X R14: %08X R15: %08X<br>"
156 "R16: %08X R17: %08X R18: %08X R19: %08X<br>"
157 "R20: %08X R21: %08X R22: %08X R23: %08X<br>"
158 "R24: %08X R25: %08X R26: %08X R27: %08X<br>"
159 "R28: %08X R29: %08X R30: %08X R31: %08X<br>",
160 dsp_reg_bank_1[0], dsp_reg_bank_1[1], dsp_reg_bank_1[2], dsp_reg_bank_1[3],
161 dsp_reg_bank_1[4], dsp_reg_bank_1[5], dsp_reg_bank_1[6], dsp_reg_bank_1[7],
162 dsp_reg_bank_1[8], dsp_reg_bank_1[9], dsp_reg_bank_1[10], dsp_reg_bank_1[11],
163 dsp_reg_bank_1[12], dsp_reg_bank_1[13], dsp_reg_bank_1[14], dsp_reg_bank_1[15],
164 dsp_reg_bank_1[16], dsp_reg_bank_1[17], dsp_reg_bank_1[18], dsp_reg_bank_1[19],
165 dsp_reg_bank_1[20], dsp_reg_bank_1[21], dsp_reg_bank_1[22], dsp_reg_bank_1[23],
166 dsp_reg_bank_1[24], dsp_reg_bank_1[25], dsp_reg_bank_1[26], dsp_reg_bank_1[27],
167 dsp_reg_bank_1[28], dsp_reg_bank_1[29], dsp_reg_bank_1[30], dsp_reg_bank_1[31]);
168 s += QString(string);
175 void CPUBrowserWindow::keyPressEvent(QKeyEvent * e)
177 if (e->key() == Qt::Key_Escape)
179 else if (e->key() == Qt::Key_PageUp)
188 else if (e->key() == Qt::Key_PageDown)
192 if (memBase > (0x200000 - 480))
193 memBase = 0x200000 - 480;
197 else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
206 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
210 if (memBase > (0x200000 - 480))
211 memBase = 0x200000 - 480;