core: Fix libdwarf and Qt build failure
[clinton/Virtual-Jaguar-Rx.git] / src / gui / emustatus.cpp
1 //
2 // emustatus.cpp - Jaguar emulator status
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 // JPM Apr./2021 Display number of M68K cycles used in tracing mode
12 //
13
14 // STILL TO DO:
15 //
16
17 #include "emustatus.h"
18 #include "memory.h"
19 #include "gpu.h"
20 #include "m68000/m68kinterface.h"
21 #include "jaguar.h"
22 #include "settings.h"
23
24
25 //
26 EmuStatusWindow::EmuStatusWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
27 layout(new QVBoxLayout),
28 resetcycles(new QPushButton(tr("Reset cycles"))),
29 text(new QLabel),
30 M68K_totalcycles(0),
31 M68K_opcodecycles(0),
32 GPURunning(GPUIsRunning())
33 {
34 setWindowTitle(tr("Emulator status"));
35
36 QFont fixedFont("Lucida Console", 8, QFont::Normal);
37 fixedFont.setStyleHint(QFont::TypeWriter);
38 text->setFont(fixedFont);
39 setLayout(layout);
40
41 layout->addWidget(text);
42 layout->addWidget(resetcycles);
43
44 connect(resetcycles, SIGNAL(clicked()), this, SLOT(ResetCycles()));
45 }
46
47
48 //
49 void EmuStatusWindow::ResetCycles(void)
50 {
51 ResetM68KCycles();
52 RefreshContents();
53 }
54
55
56 //
57 void EmuStatusWindow::ResetM68KCycles(void)
58 {
59 M68K_totalcycles = M68K_opcodecycles = 0;
60 }
61
62
63 //
64 void EmuStatusWindow::UpdateM68KCycles(size_t cycles)
65 {
66 M68K_totalcycles += (M68K_opcodecycles = cycles);
67 }
68
69
70 //
71 void EmuStatusWindow::RefreshContents(void)
72 {
73 char string[1024];
74 QString emuStatusDump;
75
76 if (isVisible())
77 {
78 text->clear();
79
80 GPURunning = GPUIsRunning();
81 sprintf(string, " GPU active | %s\n", (GPURunning ? "Yes" : "No"));
82 emuStatusDump += QString(string);
83 M68000DebugHaltStatus = M68KDebugHaltStatus();
84 sprintf(string, "M68K debugger status | %s\n", (M68000DebugHaltStatus ? "Halt" : "Run"));
85 emuStatusDump += QString(string);
86 sprintf(string, " M68K tracing | %s\n", (startM68KTracing ? "On" : "Off"));
87 emuStatusDump += QString(string);
88 sprintf(string, " DRAM | %zi KB\n", (vjs.DRAM_size / 1024));
89 emuStatusDump += QString(string);
90 sprintf(string, " M68K tracing | %zi cycle%s\n", M68K_opcodecycles, (M68K_opcodecycles ? "s" : ""));
91 emuStatusDump += QString(string);
92 sprintf(string, " M68K tracing total | %zi cycle%s", M68K_totalcycles, (M68K_totalcycles ? "s" : ""));
93 emuStatusDump += QString(string);
94
95 text->setText(emuStatusDump);
96 }
97 }
98
99
100 //
101 void EmuStatusWindow::keyPressEvent(QKeyEvent * e)
102 {
103 if (e->key() == Qt::Key_Escape)
104 {
105 hide();
106 }
107 }