Skip to content

Commit c19e4e4

Browse files
committed
debug: gray out default values in timer debug window
1 parent 73977d2 commit c19e4e4

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/platform/windows/gui/debug/timers/timers.cpp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct Field {
8585
std::string bits;
8686
std::string name;
8787
std::string value;
88+
bool active = true;
8889
};
8990

9091
void drawRegisterFields(const char* name, const std::vector<Field>& fields) {
@@ -131,7 +132,9 @@ void drawRegisterFields(const char* name, const std::vector<Field>& fields) {
131132
ImGui::TextUnformatted(f.name.c_str());
132133
ImGui::NextColumn();
133134

134-
ImGui::TextUnformatted(f.value.c_str());
135+
ImVec4 color(1, 1, 1, 1);
136+
if (!f.active) color.w = 0.25;
137+
ImGui::TextColored(color, f.value.c_str());
135138
ImGui::NextColumn();
136139
}
137140

@@ -151,13 +154,23 @@ void Timers::timersWindow(System* sys) {
151154
ImGui::Columns(3);
152155
for (auto* timer : timers) {
153156
int which = timer->which;
157+
const bool syncEnabled = timer->mode.syncEnabled;
158+
const bool resetAfterTarget = timer->mode.resetToZero == timer::CounterMode::ResetToZero::whenTarget;
159+
const bool irqWhenTarget = timer->mode.irqWhenTarget;
160+
const bool irqOneShot = timer->mode.irqRepeatMode == timer::CounterMode::IrqRepeatMode::oneShot;
161+
const bool irqPulseMode = timer->mode.irqPulseMode == timer::CounterMode::IrqPulseMode::shortPulse;
162+
const auto clockSource = getClockSource(timer);
163+
154164
ImGui::Text("Timer%d", which);
155165
ImGui::Text("Value: 0x%04x", timer->current._reg);
156166
if (ImGui::IsItemHovered()) {
157167
ImGui::SetTooltip("0x%08x", timer->baseAddress + which * 0x10 + 0);
158168
}
159169

160-
ImGui::Text("Target: 0x%04x", timer->target._reg);
170+
ImVec4 color(1, 1, 1, 1);
171+
if (!irqWhenTarget && !resetAfterTarget) color.w = 0.25;
172+
173+
ImGui::TextColored(color, "Target: 0x%04x", timer->target._reg);
161174
if (ImGui::IsItemHovered()) {
162175
ImGui::SetTooltip("0x%08x", timer->baseAddress + which * 0x10 + 8);
163176
}
@@ -168,18 +181,17 @@ void Timers::timersWindow(System* sys) {
168181
}
169182

170183
const std::vector<Field> fields = {
171-
{"0", "Sync", timer->mode.syncEnabled ? "On" : "Off"},
172-
{"1-2", "SyncMode", getSyncMode(timer)},
173-
{"3", "Reset counter", timer->mode.resetToZero == timer::CounterMode::ResetToZero::whenFFFF ? "after 0xffff" : "after target"},
174-
{"4", "IRQ on target", timer->mode.irqWhenTarget ? "On" : "Off"},
175-
{"5", "IRQ on 0xFFFF", timer->mode.irqWhenFFFF ? "On" : "Off"},
176-
{"6", "IRQ repeat mode",
177-
timer->mode.irqRepeatMode == timer::CounterMode::IrqRepeatMode::repeatedly ? "Repeatedly" : "One-shot"},
178-
{"7", "IRQ pulse mode", timer->mode.irqPulseMode == timer::CounterMode::IrqPulseMode::toggle ? "Toggle bit10" : "Pulse bit10"},
179-
{"8-9", "Clock source", getClockSource(timer)},
180-
{"10", "IRQ request", timer->mode.interruptRequest ? "No" : "Pending"},
181-
{"11", "Reached target", timer->mode.reachedTarget ? "Yes" : "No"},
182-
{"12", "Reached 0xFFFF", timer->mode.reachedFFFF ? "Yes" : "No"},
184+
{"0", "Sync", syncEnabled ? "On" : "Off", syncEnabled},
185+
{"1-2", "SyncMode", getSyncMode(timer), syncEnabled},
186+
{"3", "Reset counter", resetAfterTarget ? "after target" : "after 0xffff", resetAfterTarget},
187+
{"4", "IRQ on target", timer->mode.irqWhenTarget ? "On" : "Off", (bool)timer->mode.irqWhenTarget},
188+
{"5", "IRQ on 0xFFFF", timer->mode.irqWhenFFFF ? "On" : "Off", (bool)timer->mode.irqWhenFFFF},
189+
{"6", "IRQ repeat mode", irqOneShot ? "One-shot" : "Repeatedly", !irqOneShot},
190+
{"7", "IRQ pulse mode", irqPulseMode ? "Pulse bit10" : "Toggle bit10", !irqPulseMode},
191+
{"8-9", "Clock source", clockSource, clockSource.compare("Sysclock") != 0},
192+
{"10", "IRQ request", timer->mode.interruptRequest ? "No" : "Pending", (bool)!timer->mode.interruptRequest},
193+
{"11", "Reached target", timer->mode.reachedTarget ? "Yes" : "No", (bool)timer->mode.reachedTarget},
194+
{"12", "Reached 0xFFFF", timer->mode.reachedFFFF ? "Yes" : "No", (bool)timer->mode.reachedFFFF},
183195
};
184196

185197
drawRegisterFields(string_format("flags##timer%d", which).c_str(), fields);

0 commit comments

Comments
 (0)