yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
debugger_ui.cc
Go to the documentation of this file.
2
3#include "absl/strings/str_format.h"
4#include "app/emu/cpu/cpu.h"
5#include "app/emu/emulator.h"
11#include "imgui/imgui.h"
13#include "util/log.h"
14
15namespace yaze {
16namespace emu {
17namespace ui {
18
19using namespace yaze::gui;
20
21namespace {
22// UI Constants
23constexpr float kStandardSpacing = 8.0f;
24constexpr float kButtonHeight = 30.0f;
25constexpr float kLargeButtonHeight = 35.0f;
26
27void AddSpacing() {
28 ImGui::Spacing();
29 ImGui::Spacing();
30}
32 ImGui::Spacing();
33 ImGui::Separator();
34 ImGui::Spacing();
35}
36
37} // namespace
38
40 if (!emu)
41 return;
42
43 auto& theme_manager = ThemeManager::Get();
44 const auto& theme = theme_manager.GetCurrentTheme();
45
46 gui::StyledChild cpu_child("##CPUDebugger", ImVec2(0, 0),
47 {.bg = ConvertColorToImVec4(theme.child_bg)},
48 true);
49
50 // Title with icon
51 ImGui::TextColored(ConvertColorToImVec4(theme.accent),
52 ICON_MD_DEVELOPER_BOARD " 65816 CPU Debugger");
53 AddSectionSpacing();
54
55 auto& cpu = emu->snes().cpu();
56
57 // Debugger Controls
58 if (ImGui::CollapsingHeader(ICON_MD_SETTINGS " Controls",
59 ImGuiTreeNodeFlags_DefaultOpen)) {
60 gui::StyleVarGuard frame_padding(ImGuiStyleVar_FramePadding, ImVec2(8, 6));
61
62 if (ImGui::Button(ICON_MD_SKIP_NEXT " Step", ImVec2(100, kButtonHeight))) {
63 cpu.RunOpcode();
64 }
65 if (ImGui::IsItemHovered()) {
66 ImGui::SetTooltip("Execute single instruction (F10)");
67 }
68
69 ImGui::SameLine();
70 if (ImGui::Button(ICON_MD_FAST_FORWARD " Run to BP",
71 ImVec2(120, kButtonHeight))) {
72 // Run until breakpoint
73 emu->set_running(true);
74 }
75 if (ImGui::IsItemHovered()) {
76 ImGui::SetTooltip("Run until next breakpoint (F5)");
77 }
78 }
79
80 AddSpacing();
81
82 // CPU Registers
83 if (ImGui::CollapsingHeader(ICON_MD_MEMORY " Registers",
84 ImGuiTreeNodeFlags_DefaultOpen)) {
85 if (ImGui::BeginTable("CPU_Registers", 4,
86 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
87 ImGui::TableSetupColumn("Reg", ImGuiTableColumnFlags_WidthFixed, 40.0f);
88 ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthFixed, 70.0f);
89 ImGui::TableSetupColumn("Reg", ImGuiTableColumnFlags_WidthFixed, 40.0f);
90 ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthFixed, 70.0f);
91 ImGui::TableHeadersRow();
92
93 // Row 1: A, X
94 ImGui::TableNextRow();
95 ImGui::TableNextColumn();
96 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary), "A:");
97 ImGui::TableNextColumn();
98 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%04X", cpu.A);
99 ImGui::TableNextColumn();
100 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary), "X:");
101 ImGui::TableNextColumn();
102 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%04X", cpu.X);
103
104 // Row 2: Y, D
105 ImGui::TableNextRow();
106 ImGui::TableNextColumn();
107 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary), "Y:");
108 ImGui::TableNextColumn();
109 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%04X", cpu.Y);
110 ImGui::TableNextColumn();
111 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary), "D:");
112 ImGui::TableNextColumn();
113 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%04X", cpu.D);
114
115 // Row 3: DB, PB
116 ImGui::TableNextRow();
117 ImGui::TableNextColumn();
118 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary), "DB:");
119 ImGui::TableNextColumn();
120 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%02X", cpu.DB);
121 ImGui::TableNextColumn();
122 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary), "PB:");
123 ImGui::TableNextColumn();
124 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%02X", cpu.PB);
125
126 // Row 4: PC, SP
127 ImGui::TableNextRow();
128 ImGui::TableNextColumn();
129 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary), "PC:");
130 ImGui::TableNextColumn();
131 ImGui::TextColored(ConvertColorToImVec4(theme.warning), "$%04X", cpu.PC);
132 ImGui::TableNextColumn();
133 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary), "SP:");
134 ImGui::TableNextColumn();
135 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%04X", cpu.SP());
136
137 ImGui::EndTable();
138 }
139
140 AddSpacing();
141
142 // Status Flags (visual checkboxes)
143 ImGui::TextColored(ConvertColorToImVec4(theme.text_secondary),
144 ICON_MD_FLAG " Flags:");
145 ImGui::Indent();
146
147 auto RenderFlag = [&](const char* name, bool value) {
148 ImVec4 color = value ? ConvertColorToImVec4(theme.success)
149 : ConvertColorToImVec4(theme.text_disabled);
150 ImGui::TextColored(
151 color, "%s %s",
153 if (ImGui::IsItemHovered()) {
154 ImGui::SetTooltip("%s: %s", name, value ? "Set" : "Clear");
155 }
156 ImGui::SameLine();
157 };
158
159 RenderFlag("N", cpu.GetNegativeFlag());
160 RenderFlag("V", cpu.GetOverflowFlag());
161 RenderFlag("D", cpu.GetDecimalFlag());
162 RenderFlag("I", cpu.GetInterruptFlag());
163 RenderFlag("Z", cpu.GetZeroFlag());
164 RenderFlag("C", cpu.GetCarryFlag());
165 ImGui::NewLine();
166
167 ImGui::Unindent();
168 }
169
170 AddSpacing();
171
172 // Breakpoint Management
173 if (ImGui::CollapsingHeader(ICON_MD_STOP_CIRCLE " Breakpoints")) {
174 static char bp_input[10] = "";
175
176 ImGui::SetNextItemWidth(150);
177 if (ImGui::InputTextWithHint("##BP", "Address (hex)", bp_input,
178 sizeof(bp_input),
179 ImGuiInputTextFlags_CharsHexadecimal |
180 ImGuiInputTextFlags_EnterReturnsTrue)) {
181 if (strlen(bp_input) > 0) {
182 uint32_t addr = std::stoi(bp_input, nullptr, 16);
183 emu->SetBreakpoint(addr);
184 memset(bp_input, 0, sizeof(bp_input));
185 }
186 }
187
188 ImGui::SameLine();
189 if (ImGui::Button(ICON_MD_ADD " Add", ImVec2(80, 0))) {
190 if (strlen(bp_input) > 0) {
191 uint32_t addr = std::stoi(bp_input, nullptr, 16);
192 emu->SetBreakpoint(addr);
193 memset(bp_input, 0, sizeof(bp_input));
194 }
195 }
196
197 ImGui::SameLine();
198 if (ImGui::Button(ICON_MD_CLEAR_ALL " Clear All", ImVec2(100, 0))) {
199 emu->ClearAllBreakpoints();
200 }
201
202 AddSpacing();
203
204 // List breakpoints
205 auto breakpoints = emu->GetBreakpoints();
206 if (!breakpoints.empty()) {
207 ImGui::BeginChild("##BPList", ImVec2(0, 150), true);
208 for (size_t i = 0; i < breakpoints.size(); ++i) {
209 uint32_t bp = breakpoints[i];
210 ImGui::PushID(i);
211
212 ImGui::TextColored(ConvertColorToImVec4(theme.accent),
213 ICON_MD_STOP " $%06X", bp);
214
215 ImGui::SameLine(200);
216 if (ImGui::SmallButton(ICON_MD_DELETE " Remove")) {
217 cpu.ClearBreakpoint(bp);
218 }
219
220 ImGui::PopID();
221 }
222 ImGui::EndChild();
223 } else {
224 ImGui::TextColored(ConvertColorToImVec4(theme.text_disabled),
225 "No breakpoints set");
226 }
227 }
228
229}
230
232 if (!emu)
233 return;
234
235 auto& theme_manager = ThemeManager::Get();
236 const auto& theme = theme_manager.GetCurrentTheme();
237
238 gui::StyledChild bp_child("##BreakpointList", ImVec2(0, 0),
239 {.bg = ConvertColorToImVec4(theme.child_bg)}, true);
240
241 ImGui::TextColored(ConvertColorToImVec4(theme.accent),
242 ICON_MD_STOP_CIRCLE " Breakpoint Manager");
243 AddSectionSpacing();
244
245 // Same content as in RenderModernCpuDebugger but with more detail
246 auto breakpoints = emu->GetBreakpoints();
247
248 ImGui::Text("Active Breakpoints: %zu", breakpoints.size());
249 AddSpacing();
250
251 if (!breakpoints.empty()) {
252 if (ImGui::BeginTable("BreakpointTable", 3,
253 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
254 ImGui::TableSetupColumn(ICON_MD_TAG, ImGuiTableColumnFlags_WidthFixed,
255 40);
256 ImGui::TableSetupColumn("Address", ImGuiTableColumnFlags_WidthFixed, 100);
257 ImGui::TableSetupColumn("Actions", ImGuiTableColumnFlags_WidthStretch);
258 ImGui::TableHeadersRow();
259
260 for (size_t i = 0; i < breakpoints.size(); ++i) {
261 ImGui::TableNextRow();
262 ImGui::TableNextColumn();
263 ImGui::TextColored(ConvertColorToImVec4(theme.error), ICON_MD_STOP);
264
265 ImGui::TableNextColumn();
266 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%06X",
267 breakpoints[i]);
268
269 ImGui::TableNextColumn();
270 ImGui::PushID(i);
271 if (ImGui::SmallButton(ICON_MD_DELETE " Remove")) {
272 emu->snes().cpu().ClearBreakpoint(breakpoints[i]);
273 }
274 ImGui::PopID();
275 }
276
277 ImGui::EndTable();
278 }
279 } else {
280 ImGui::TextColored(ConvertColorToImVec4(theme.text_disabled),
281 ICON_MD_INFO " No breakpoints set");
282 }
283
284}
285
287 if (!emu)
288 return;
289
290 auto& theme_manager = ThemeManager::Get();
291 const auto& theme = theme_manager.GetCurrentTheme();
292
293 static yaze::gui::MemoryEditorWidget mem_edit;
294
295 gui::StyledChild mem_child("##MemoryViewer", ImVec2(0, 0),
296 {.bg = ConvertColorToImVec4(theme.child_bg)},
297 true);
298
299 ImGui::TextColored(ConvertColorToImVec4(theme.accent),
300 ICON_MD_STORAGE " Memory Viewer");
301 AddSectionSpacing();
302
303 // Memory region selector
304 static int region = 0;
305 const char* regions[] = {"RAM ($0000-$1FFF)", "ROM Bank 0",
306 "WRAM ($7E0000-$7FFFFF)", "SRAM"};
307
308 ImGui::SetNextItemWidth(250);
309 if (ImGui::Combo(ICON_MD_MAP " Region", &region, regions,
310 IM_ARRAYSIZE(regions))) {
311 // Region changed
312 }
313
314 AddSpacing();
315
316 // Render memory editor
317 uint8_t* memory_base = emu->snes().get_ram();
318 size_t memory_size = 0x20000;
319
320 mem_edit.DrawContents(memory_base, memory_size, 0x0000);
321
322}
323
324void RenderCpuInstructionLog(Emulator* emu, uint32_t log_size) {
325 if (!emu)
326 return;
327
328 auto& theme_manager = ThemeManager::Get();
329 const auto& theme = theme_manager.GetCurrentTheme();
330
331 gui::StyledChild log_child("##InstructionLog", ImVec2(0, 0),
332 {.bg = ConvertColorToImVec4(theme.child_bg)},
333 true);
334
335 ImGui::TextColored(ConvertColorToImVec4(theme.warning),
336 ICON_MD_WARNING " Legacy Instruction Log");
337 ImGui::TextColored(ConvertColorToImVec4(theme.text_disabled),
338 "Deprecated - Use Disassembly Viewer instead");
339 AddSectionSpacing();
340
341 // Show DisassemblyViewer stats instead
342 ImGui::Text(ICON_MD_INFO " DisassemblyViewer Active:");
343 ImGui::BulletText("Unique addresses: %zu",
345 ImGui::BulletText("Recording: %s",
346 emu->disassembly_viewer().IsRecording() ? "ON" : "OFF");
347 ImGui::BulletText("Auto-scroll: Available in viewer");
348
349 AddSpacing();
350
351 if (ImGui::Button(ICON_MD_OPEN_IN_NEW " Open Disassembly Viewer",
352 ImVec2(-1, kLargeButtonHeight))) {
353 // TODO: Open disassembly viewer window
354 }
355
356}
357
359 if (!emu)
360 return;
361
362 auto& theme_manager = ThemeManager::Get();
363 const auto& theme = theme_manager.GetCurrentTheme();
364
365 gui::StyledChild apu_child("##ApuDebugger", ImVec2(0, 0),
366 {.bg = ConvertColorToImVec4(theme.child_bg)},
367 true);
368
369 // Title
370 ImGui::TextColored(ConvertColorToImVec4(theme.accent),
371 ICON_MD_MUSIC_NOTE " APU / SPC700 Debugger");
372 AddSectionSpacing();
373
374 auto& tracker = emu->snes().apu_handshake_tracker();
375
376 // Handshake Status with enhanced visuals
377 if (ImGui::CollapsingHeader(ICON_MD_HANDSHAKE " Handshake Status",
378 ImGuiTreeNodeFlags_DefaultOpen)) {
379 // Phase with icon and color
380 auto phase_str = tracker.GetPhaseString();
381 ImVec4 phase_color;
382 const char* phase_icon;
383
384 if (phase_str == "RUNNING") {
385 phase_color = ConvertColorToImVec4(theme.success);
386 phase_icon = ICON_MD_CHECK_CIRCLE;
387 } else if (phase_str == "TRANSFER_ACTIVE") {
388 phase_color = ConvertColorToImVec4(theme.info);
389 phase_icon = ICON_MD_SYNC;
390 } else if (phase_str == "WAITING_BBAA" || phase_str == "IPL_BOOT") {
391 phase_color = ConvertColorToImVec4(theme.warning);
392 phase_icon = ICON_MD_PENDING;
393 } else {
394 phase_color = ConvertColorToImVec4(theme.error);
395 phase_icon = ICON_MD_ERROR;
396 }
397
398 ImGui::Text(ICON_MD_SETTINGS " Phase:");
399 ImGui::SameLine();
400 ImGui::TextColored(phase_color, "%s %s", phase_icon, phase_str.c_str());
401
402 // Handshake complete indicator
403 ImGui::Text(ICON_MD_LINK " Handshake:");
404 ImGui::SameLine();
405 if (tracker.IsHandshakeComplete()) {
406 ImGui::TextColored(ConvertColorToImVec4(theme.success),
407 ICON_MD_CHECK_CIRCLE " Complete");
408 } else {
409 ImGui::TextColored(ConvertColorToImVec4(theme.warning),
410 ICON_MD_HOURGLASS_EMPTY " Waiting");
411 }
412
413 // Transfer progress
414 if (tracker.IsTransferActive() || tracker.GetBytesTransferred() > 0) {
415 AddSpacing();
416 ImGui::Text(ICON_MD_CLOUD_UPLOAD " Transfer Progress:");
417 ImGui::Indent();
418 ImGui::BulletText("Bytes: %d", tracker.GetBytesTransferred());
419 ImGui::BulletText("Blocks: %d", tracker.GetBlockCount());
420
421 auto progress = tracker.GetTransferProgress();
422 if (!progress.empty()) {
423 ImGui::TextColored(ConvertColorToImVec4(theme.info), "%s",
424 progress.c_str());
425 }
426 ImGui::Unindent();
427 }
428
429 // Status summary
430 AddSectionSpacing();
431 ImGui::TextWrapped("%s", tracker.GetStatusSummary().c_str());
432 }
433
434 // Port Activity Log
435 if (ImGui::CollapsingHeader(ICON_MD_LIST " Port Activity Log",
436 ImGuiTreeNodeFlags_DefaultOpen)) {
437 ImGui::BeginChild("##PortLog", ImVec2(0, 200), true);
438
439 const auto& history = tracker.GetPortHistory();
440
441 if (history.empty()) {
442 ImGui::TextColored(ConvertColorToImVec4(theme.text_disabled),
443 ICON_MD_INFO " No port activity yet");
444 } else {
445 // Show last 50 entries
446 int start_idx = std::max(0, static_cast<int>(history.size()) - 50);
447 for (size_t i = start_idx; i < history.size(); ++i) {
448 const auto& entry = history[i];
449
450 ImVec4 color = entry.is_cpu ? ConvertColorToImVec4(theme.accent)
451 : ConvertColorToImVec4(theme.info);
452 const char* icon =
454
455 ImGui::TextColored(color, "[%04llu] %s %s F%d = $%02X @ PC=$%04X %s",
456 entry.timestamp, entry.is_cpu ? "CPU" : "SPC", icon,
457 entry.port + 4, entry.value, entry.pc,
458 entry.description.c_str());
459 }
460
461 // Auto-scroll
462 if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
463 ImGui::SetScrollHereY(1.0f);
464 }
465 }
466
467 ImGui::EndChild();
468 }
469
470 // Current Port Values
471 if (ImGui::CollapsingHeader(ICON_MD_SETTINGS_INPUT_COMPONENT
472 " Current Port Values",
473 ImGuiTreeNodeFlags_DefaultOpen)) {
474 if (ImGui::BeginTable("APU_Ports", 4,
475 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
476 ImGui::TableSetupColumn("Port", ImGuiTableColumnFlags_WidthFixed, 50);
477 ImGui::TableSetupColumn("CPU → SPC", ImGuiTableColumnFlags_WidthFixed,
478 80);
479 ImGui::TableSetupColumn("SPC → CPU", ImGuiTableColumnFlags_WidthFixed,
480 80);
481 ImGui::TableSetupColumn("Address", ImGuiTableColumnFlags_WidthStretch);
482 ImGui::TableHeadersRow();
483
484 for (int i = 0; i < 4; ++i) {
485 ImGui::TableNextRow();
486 ImGui::TableNextColumn();
487 ImGui::Text(ICON_MD_SETTINGS " F%d", i + 4);
488
489 ImGui::TableNextColumn();
490 ImGui::TextColored(ConvertColorToImVec4(theme.accent), "$%02X",
491 emu->snes().apu().in_ports_[i]);
492
493 ImGui::TableNextColumn();
494 ImGui::TextColored(ConvertColorToImVec4(theme.info), "$%02X",
495 emu->snes().apu().out_ports_[i]);
496
497 ImGui::TableNextColumn();
498 ImGui::TextDisabled("$214%d / $F%d", i, i + 4);
499 }
500
501 ImGui::EndTable();
502 }
503 }
504
505 // Quick Actions
506 if (ImGui::CollapsingHeader(ICON_MD_BUILD " Quick Actions",
507 ImGuiTreeNodeFlags_DefaultOpen)) {
508 ImGui::TextColored(ConvertColorToImVec4(theme.warning),
509 ICON_MD_WARNING " Manual Testing Tools");
510 AddSpacing();
511
512 // Full handshake test
513 if (ImGui::Button(ICON_MD_PLAY_CIRCLE " Full Handshake Test",
514 ImVec2(-1, kLargeButtonHeight))) {
515 LOG_INFO("APU_DEBUG", "=== MANUAL HANDSHAKE TEST ===");
516 emu->snes().Write(0x002140, 0xCC);
517 emu->snes().Write(0x002141, 0x01);
518 emu->snes().Write(0x002142, 0x00);
519 emu->snes().Write(0x002143, 0x02);
520 LOG_INFO("APU_DEBUG", "Handshake sequence executed");
521 }
522 if (ImGui::IsItemHovered()) {
523 ImGui::SetTooltip(
524 "Execute full handshake sequence:\n"
525 "$CC → F4, $01 → F5, $00 → F6, $02 → F7");
526 }
527
528 AddSpacing();
529
530 // Manual port writes
531 if (ImGui::TreeNode(ICON_MD_EDIT " Manual Port Writes")) {
532 static uint8_t port_values[4] = {0xCC, 0x01, 0x00, 0x02};
533
534 for (int i = 0; i < 4; ++i) {
535 ImGui::PushID(i);
536 ImGui::Text("F%d ($214%d):", i + 4, i);
537 ImGui::SameLine();
538 ImGui::SetNextItemWidth(80);
539 ImGui::InputScalar("##val", ImGuiDataType_U8, &port_values[i], NULL,
540 NULL, "%02X", ImGuiInputTextFlags_CharsHexadecimal);
541 ImGui::SameLine();
542 if (ImGui::Button(ICON_MD_SEND " Write", ImVec2(100, 0))) {
543 emu->snes().Write(0x002140 + i, port_values[i]);
544 LOG_INFO("APU_DEBUG", "Wrote $%02X to F%d", port_values[i], i + 4);
545 }
546 ImGui::PopID();
547 }
548
549 ImGui::TreePop();
550 }
551
552 AddSectionSpacing();
553
554 // System controls
555 if (ImGui::Button(ICON_MD_RESTART_ALT " Reset APU",
556 ImVec2(-1, kButtonHeight))) {
557 emu->snes().apu().Reset();
558 LOG_INFO("APU_DEBUG", "APU reset");
559 }
560
561 if (ImGui::Button(ICON_MD_CLEAR_ALL " Clear Port History",
562 ImVec2(-1, kButtonHeight))) {
563 tracker.Reset();
564 LOG_INFO("APU_DEBUG", "Port history cleared");
565 }
566 }
567
568 ImGui::Separator();
569 ImGui::Text("Audio Resampling");
570
571 // Combo box for interpolation type
572 const char* items[] = {"Linear", "Hermite", "Cosine", "Cubic"};
573 int current_item =
574 static_cast<int>(emu->snes().apu().dsp().interpolation_type);
575 if (ImGui::Combo("Interpolation", &current_item, items,
576 IM_ARRAYSIZE(items))) {
577 emu->snes().apu().dsp().interpolation_type =
578 static_cast<InterpolationType>(current_item);
579 }
580
581}
582
584 if (!emu)
585 return;
586
587 auto& theme_manager = ThemeManager::Get();
588 const auto& theme = theme_manager.GetCurrentTheme();
589
590 gui::StyledChild ai_child("##AIAgent", ImVec2(0, 0),
591 {.bg = ConvertColorToImVec4(theme.child_bg)}, true);
592
593 ImGui::TextColored(ConvertColorToImVec4(theme.accent),
594 ICON_MD_SMART_TOY " AI Agent Integration");
595 AddSectionSpacing();
596
597 // Agent status
598 bool agent_ready = emu->IsEmulatorReady();
599 ImVec4 status_color = agent_ready ? ConvertColorToImVec4(theme.success)
600 : ConvertColorToImVec4(theme.error);
601
602 ImGui::Text("Status:");
603 ImGui::SameLine();
604 ImGui::TextColored(status_color, "%s %s",
605 agent_ready ? ICON_MD_CHECK_CIRCLE : ICON_MD_ERROR,
606 agent_ready ? "Ready" : "Not Ready");
607
608 AddSpacing();
609
610 // Emulator metrics for agents
611 if (ImGui::CollapsingHeader(ICON_MD_DATA_OBJECT " Metrics",
612 ImGuiTreeNodeFlags_DefaultOpen)) {
613 auto metrics = emu->GetMetrics();
614
615 ImGui::BulletText("FPS: %.2f", metrics.fps);
616 ImGui::BulletText("Cycles: %llu", metrics.cycles);
617 ImGui::BulletText("CPU PC: $%02X:%04X", metrics.cpu_pb, metrics.cpu_pc);
618 ImGui::BulletText("Audio Queued: %u frames", metrics.audio_frames_queued);
619 ImGui::BulletText("Running: %s", metrics.is_running ? "YES" : "NO");
620 }
621
622 // Agent controls
623 if (ImGui::CollapsingHeader(ICON_MD_PLAY_CIRCLE " Agent Controls")) {
624 if (ImGui::Button(ICON_MD_PLAY_ARROW " Start Agent Session",
625 ImVec2(-1, kLargeButtonHeight))) {
626 // TODO: Start agent
627 }
628
629 if (ImGui::Button(ICON_MD_STOP " Stop Agent", ImVec2(-1, kButtonHeight))) {
630 // TODO: Stop agent
631 }
632 }
633
634}
635
636} // namespace ui
637} // namespace emu
638} // namespace yaze
A class for emulating and debugging SNES games.
Definition emulator.h:40
bool IsEmulatorReady() const
Definition emulator.h:130
void SetBreakpoint(uint32_t address)
Definition emulator.h:136
debug::DisassemblyViewer & disassembly_viewer()
Definition emulator.h:122
void set_running(bool running)
Definition emulator.h:61
void ClearAllBreakpoints()
Definition emulator.h:137
auto snes() -> Snes &
Definition emulator.h:59
EmulatorMetrics GetMetrics()
Definition emulator.h:151
std::vector< uint32_t > GetBreakpoints()
Definition emulator.h:138
size_t GetInstructionCount() const
Get the number of unique instructions recorded.
RAII guard for ImGui style vars.
Definition style_guard.h:68
RAII guard for ImGui child windows with optional styling.
static ThemeManager & Get()
#define ICON_MD_SETTINGS
Definition icons.h:1699
#define ICON_MD_DATA_OBJECT
Definition icons.h:521
#define ICON_MD_CHECK_BOX
Definition icons.h:398
#define ICON_MD_LINK
Definition icons.h:1090
#define ICON_MD_INFO
Definition icons.h:993
#define ICON_MD_MEMORY
Definition icons.h:1195
#define ICON_MD_STORAGE
Definition icons.h:1865
#define ICON_MD_WARNING
Definition icons.h:2123
#define ICON_MD_FAST_FORWARD
Definition icons.h:724
#define ICON_MD_ARROW_FORWARD
Definition icons.h:184
#define ICON_MD_PLAY_ARROW
Definition icons.h:1479
#define ICON_MD_HANDSHAKE
Definition icons.h:907
#define ICON_MD_MAP
Definition icons.h:1173
#define ICON_MD_STOP
Definition icons.h:1862
#define ICON_MD_EDIT
Definition icons.h:645
#define ICON_MD_ERROR
Definition icons.h:686
#define ICON_MD_MUSIC_NOTE
Definition icons.h:1264
#define ICON_MD_STOP_CIRCLE
Definition icons.h:1863
#define ICON_MD_LIST
Definition icons.h:1094
#define ICON_MD_CLEAR_ALL
Definition icons.h:417
#define ICON_MD_ADD
Definition icons.h:86
#define ICON_MD_PENDING
Definition icons.h:1398
#define ICON_MD_DEVELOPER_BOARD
Definition icons.h:547
#define ICON_MD_SEND
Definition icons.h:1683
#define ICON_MD_PLAY_CIRCLE
Definition icons.h:1480
#define ICON_MD_CHECK_CIRCLE
Definition icons.h:400
#define ICON_MD_SKIP_NEXT
Definition icons.h:1773
#define ICON_MD_FLAG
Definition icons.h:784
#define ICON_MD_BUILD
Definition icons.h:328
#define ICON_MD_ARROW_BACK
Definition icons.h:173
#define ICON_MD_DELETE
Definition icons.h:530
#define ICON_MD_OPEN_IN_NEW
Definition icons.h:1354
#define ICON_MD_SYNC
Definition icons.h:1919
#define ICON_MD_RESTART_ALT
Definition icons.h:1602
#define ICON_MD_CHECK_BOX_OUTLINE_BLANK
Definition icons.h:399
#define ICON_MD_HOURGLASS_EMPTY
Definition icons.h:967
#define ICON_MD_CLOUD_UPLOAD
Definition icons.h:430
#define ICON_MD_TAG
Definition icons.h:1940
#define ICON_MD_SETTINGS_INPUT_COMPONENT
Definition icons.h:1709
#define ICON_MD_SMART_TOY
Definition icons.h:1781
#define LOG_INFO(category, format,...)
Definition log.h:105
void RenderModernCpuDebugger(Emulator *emu)
Modern CPU debugger with registers, flags, and controls.
void RenderAIAgentPanel(Emulator *emu)
AI Agent panel for automated testing/gameplay.
void RenderBreakpointList(Emulator *emu)
Breakpoint list and management.
void RenderApuDebugger(Emulator *emu)
APU/Audio debugger with handshake tracker.
void RenderMemoryViewer(Emulator *emu)
Memory viewer/editor.
void RenderCpuInstructionLog(Emulator *emu, uint32_t log_size)
CPU instruction log (legacy, prefer DisassemblyViewer)
InterpolationType
Definition dsp.h:10
Graphical User Interface (GUI) components for the application.
ImVec4 ConvertColorToImVec4(const Color &color)
Definition color.h:134
void DrawContents(void *mem_data_void, size_t mem_size, size_t base_display_addr=0x0000)