Skip to content

Add Z80 debugger UI: disassembler, CPU debugger, breakpoints#12

Closed
gunterhager wants to merge 27 commits intofloooh:mainfrom
gunterhager:z80-debugger-ui
Closed

Add Z80 debugger UI: disassembler, CPU debugger, breakpoints#12
gunterhager wants to merge 27 commits intofloooh:mainfrom
gunterhager:z80-debugger-ui

Conversation

@gunterhager
Copy link
Copy Markdown
Contributor

Summary

  • src/chips/z80dasm.zig — stateless Z80 disassembler ported from z80dasm.h; callback-based memory access, handles all prefix bytes (CB/DD/ED/FD), all documented and undocumented instructions
  • src/ui/ui_dasm.zig — standalone scrollable disassembler window (512 lines via ImGuiListClipper), navigation back-stack, jump-target arrow buttons for CALL/JP/JR/RST/DJNZ
  • src/ui/ui_dbg.zig — comptime-parameterized CPU debugger (Type(.{.bus=..., .cpu=...})); step-into/step-over, up to 32 address breakpoints, 256-entry execution history ring buffer, F5/F6/F7/F9 hotkeys
  • KC85 integrationexecWithDebug() for per-tick stepping/breakpoint detection, Debug menu wired up, memRead callback

Reusability

Both ui_dasm (plain struct) and ui_dbg (comptime-parameterized) use runtime read_cb function pointers for memory access — no system-specific coupling. Other emulators (Namco, Bombjack) can integrate with:

const UI_DBG = ui.ui_dbg.Type(.{ .bus = SysBus, .cpu = SysZ80 });

Test plan

  • zig build run-kc852 — emulator starts without crash
  • Debug → CPU Debugger opens the debugger window
  • F7 steps one instruction (PC advances by 1–4 bytes)
  • F5 continues/breaks execution
  • Clicking a disassembly line toggles a breakpoint (* indicator appears)
  • Breakpoint halts execution when PC reaches that address
  • Debug → Disassembler → Window Crash in Z80 decoder else branch #1/2 opens standalone disassembler
  • Jump arrow buttons (→) navigate to CALL/JP targets; ← goes back

🤖 Generated with Claude Code

gunterhager and others added 27 commits March 16, 2025 15:37
In Zig 0.14+, addIncludePath was moved from Build.Step.Compile to
Build.Module. Update the sokol/cimgui dependency hashes to latest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- src/chips/z80dasm.zig: stateless Z80 disassembler (port of z80dasm.h);
  callback-based memory access, handles all prefixes (CB/DD/ED/FD)
- src/ui/ui_dasm.zig: standalone scrollable disassembler window with
  navigation back-stack and jump-target buttons for CALL/JP/JR/RST/DJNZ
- src/ui/ui_dbg.zig: comptime-parameterized CPU debugger (bus+cpu types);
  step-into/over, breakpoints, execution history, F5/F6/F7/F9 hotkeys
- Integrated into KC85: per-tick execWithDebug() loop, Debug menu wired up

All UI is reusable for other emulators (Namco, Bombjack) via runtime
read_cb and comptime Type(.{.bus=..., .cpu=...}) instantiation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gunterhager
Copy link
Copy Markdown
Contributor Author

Sorry, I created this in the wrong repository. I wanted to target my fork.

@gunterhager gunterhager deleted the z80-debugger-ui branch March 18, 2026 17:49
@gunterhager gunterhager restored the z80-debugger-ui branch March 18, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant