| name | geargrafx-debugging | ||||
|---|---|---|---|---|---|
| description | Debug and trace TurboGrafx-16 / PC Engine / SuperGrafx games using the Geargrafx emulator MCP server. Provides workflows for HuC6280 CPU debugging, breakpoint management, hardware inspection, disassembly analysis, and execution tracing. Use when the user wants to debug a PC Engine game, trace code execution, inspect CPU registers or hardware state, set breakpoints, analyze interrupts, step through HuC6280 instructions, reverse engineer game code, examine VDC/VCE/PSG registers, view the call stack, or diagnose rendering, audio, or timing issues. Also use when the user mentions PC Engine development, TurboGrafx-16 homebrew testing, SuperGrafx debugging, CD-ROM game debugging, or HuC6280 debugging with Geargrafx. | ||||
| compatibility | Requires the Geargrafx MCP server. Direct tool mode is the default. Before installing or configuring, call debug_get_status to check if the server is already connected. If --mcp-router is enabled, use get_tool_info and execute_tool for routed tools. | ||||
| metadata |
|
Debug TurboGrafx-16, PC Engine, and SuperGrafx games using the Geargrafx emulator as an MCP server. Control execution (pause, step, breakpoints), inspect the HuC6280 CPU and hardware (HuC6270 VDC, HuC6260 VCE, HuC6202 VPC, PSG), read/write memory, disassemble code, trace instructions, and capture screenshots — all through MCP tool calls. Hardware documentation is available in the references/ directory.
IMPORTANT — Check before installing: Before attempting any installation or configuration, you MUST first verify if the Geargrafx MCP server is already connected in your current session. In the default mode, call debug_get_status directly. If Geargrafx was intentionally started with --mcp-router, call get_tool_info with {"name":"debug_get_status"}, then call execute_tool with {"name":"debug_get_status","arguments":{}}. A valid response from either workflow means the server is active and ready.
Only if neither workflow is available or the call fails, you need to help install and configure the Geargrafx MCP server:
Run the bundled install script (macOS/Linux):
bash scripts/install.shThis installs Geargrafx via Homebrew on macOS or downloads the latest release on Linux. It prints the binary path on completion. You can also set INSTALL_DIR to control where the binary goes (default: ~/.local/bin).
Alternatively, download from GitHub Releases or install with brew install --cask drhelius/geardome/geargrafx on macOS.
Configure your AI client to run Geargrafx as an MCP server via STDIO transport. Example for Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"geargrafx": {
"command": "/path/to/geargrafx",
"args": ["--mcp-stdio"]
}
}
}Replace /path/to/geargrafx with the actual binary path from the install script. Add --headless before --mcp-stdio on headless machines.
PC Engine hardware documentation is available in the references/ directory. Load them into your context when investigating specific hardware.
| Reference | File | Load when... |
|---|---|---|
| HuC6280 CPU | references/huc6280_cpu.md | CPU registers, MPR mapping, timer, interrupts, I/O, speed modes |
| Instruction Set | references/huc6280_instructions.md | Opcode reference, addressing modes, cycle counts |
| PSG | references/huc6280_psg.md | 6-channel sound: waveform, noise, LFO, volume, DDA |
| HuC6270 VDC | references/huc6270_vdc.md | Video Display Controller: BAT, sprites, scroll, DMA, interrupts |
| HuC6260 VCE | references/huc6260_vce.md | Video Color Encoder: palette, dot clock, color format |
| HuC6202 VPC | references/huc6202_vpc.md | Video Priority Controller (SuperGrafx): window, priority |
| Memory Map | references/memory_map.md | Full memory map: MPR pages, I/O, WRAM, VRAM, ROM banking |
load_media → get_media_info → get_huc6280_status → get_screenshot
Start every session by loading the ROM, confirming it loaded correctly, then checking CPU state and taking a screenshot to understand the current game state. If a .sym, .lbl, or .noi file exists alongside the ROM, symbols are loaded automatically.
Load additional symbols with load_symbols or add individual labels with add_symbol.
Always call debug_pause before inspecting state. While paused:
- CPU state:
get_huc6280_status— registers A, X, Y, S, P (flags), PC, MPR mapping, timer, interrupts, I/O port, speed mode - Disassembly:
get_disassemblywith a start/end address range — only shows executed code paths - Call stack:
get_call_stack— current subroutine hierarchy - Memory:
read_memorywith a memory area tab ID (uselist_memory_areasto discover available areas and their IDs)
Use breakpoints to stop execution at points of interest:
| Breakpoint Type | Tool | Use Case |
|---|---|---|
| Execution | set_breakpoint (type: exec) |
Stop when PC reaches address |
| Read | set_breakpoint (type: read) |
Stop when memory address is read |
| Write | set_breakpoint (type: write) |
Stop when memory address is written |
| Range | set_breakpoint_range |
Cover an address range (exec/read/write) |
Breakpoints support 5 memory areas: rom_ram (default), vram, palette, huc6270_reg, huc6260_reg.
Important: Read/write breakpoints stop with PC at the instruction after the memory access.
Manage breakpoints with list_breakpoints, remove_breakpoint.
After hitting a breakpoint or pausing:
| Action | Tool | Behavior |
|---|---|---|
| Step Into | debug_step_into |
Execute one instruction, enter subroutines |
| Step Over | debug_step_over |
Execute one instruction, skip JSR calls |
| Step Out | debug_step_out |
Run until RTS/RTI returns from current subroutine |
| Step Frame | debug_step_frame |
Execute until next VBlank; use mode: "sync" before dependent calls |
| Run To | debug_run_to_cursor |
Continue until PC reaches target address |
| Continue | debug_continue |
Resume normal execution |
After each step, call get_huc6280_status and get_disassembly to see where you are.
The trace logger records CPU instructions interleaved with hardware events (VDC, VCE, PSG, timer, CD-ROM, SCSI, ADPCM, input).
set_trace_logwithenabled: trueto start recording (optionally filter event types)- Let the game run or step through code
set_trace_logwithenabled: falseto stop (entries are preserved)get_trace_logto read recorded entries
Available trace event filters: cpu_irq, vdc, vce, psg, timer, input, cdrom, adpcm, scsi. CPU tracing is always on.
Tracing is essential for understanding timing-sensitive code, interrupt handlers, and hardware interaction sequences.
get_huc6270_status— VDC state: position, control, interrupt flagsget_huc6270_registers— all 20 VDC registers (0x00-0x13), Address Register (AR), Status Register (SR)write_huc6270_register— write to a VDC register (0-19) or AR (20). Use vdc parameter (1 or 2) for SuperGrafxlist_sprites— all 64 sprites with position, size, pattern, paletteget_sprite_image— get a sprite as a PNG image
get_huc6260_status— VCE state: position, sync signals, dot clock, control
get_huc6202_status— VPC state: window settings, priority configuration
get_psg_status— all 6 PSG channels: waveform, frequency, volume, noise, LFO, DDA
get_cdrom_status— CD-ROM drive statusget_cdrom_audio_status— CD audio playback statusget_adpcm_status— ADPCM audio statusget_arcade_card_status— Arcade Card status
get_huc6280_status— full CPU state: registers, MPR, timer, interrupts, I/O, speedwrite_huc6280_register— modify a register live
get_screenshot— current rendered frame as PNG
Use screenshots after stepping or continuing to see the visual impact of changes.
- Set an execution breakpoint at the IRQ vector address (read the Memory Map resource for the vector table)
debug_continueto run until the IRQ firesget_huc6280_status+get_disassemblyto see the handler codeget_call_stackto see how deep you areadd_symbolto label the handler address and any subroutines it calls
debug_pause→get_huc6270_registers— check BAT, sprite attributes, scroll, DMA settingsget_huc6260_status— verify dot clock, color modeget_screenshot— capture the current visual stateread_memoryon VRAM and SAT areas to inspect tile/sprite data- Set read/write breakpoints (memory_area:
vramorhuc6270_reg) on display buffer addresses to catch corruption source
set_breakpointat the subroutine entry pointdebug_continue→ when hit,get_huc6280_status- Step through with
debug_step_into/debug_step_over - After each step: check registers, read relevant memory
add_symbolfor the routine and any called subroutinesadd_disassembler_bookmarkto mark interesting locations
add_memory_watchon the variable's address — watches are visible in the emulator GUI- Set a write breakpoint with
set_breakpoint(type: write) on that address - When hit,
get_disassemblyreveals what code is modifying it get_call_stackshows the call chain leading to the write
set_trace_logwithenabled: trueto start recording timer and VDC events- Let the game run through the section of interest
get_trace_logto see the interleaved CPU + hardware events- Check VDC interrupt timing via
get_huc6270_status - Correlate timer fires with code execution in the trace
load_mediawith a.cuefile to load a CD-ROM imageget_cdrom_statusto verify drive stateset_trace_logwithcdrom: trueandscsi: trueto trace CD access patternsget_adpcm_statusto inspect ADPCM audio state- Set breakpoints on CD-ROM RAM areas to catch data loading
Use list_memory_areas to get the full list with IDs and sizes. Common areas:
| Area | Description | Typical Size |
|---|---|---|
| WRAM | Working RAM | 8KB (32KB for SuperGrafx) |
| ZP | Zero Page (fast variables) | 256 bytes |
| ROM | Game ROM | Varies |
| CARD RAM | HuCard RAM | Varies |
| BRAM | Backup RAM (save data) | 2KB |
| PALETTES | VCE color table | 512 bytes |
| VRAM / VRAM 1 | VDC video RAM | 64KB |
| VRAM 2 | VDC 2 video RAM (SuperGrafx) | 64KB |
| SAT / SAT 1 | Sprite Attribute Table | 512 bytes |
| SAT 2 | SAT for VDC 2 (SuperGrafx) | 512 bytes |
| CDROM RAM | CD-ROM working RAM | Varies |
| ADPCM | ADPCM sample RAM | 64KB |
| ARCADE | Arcade Card RAM | Varies |
| MB128 | Memory Base 128 | 128KB |
- Symbols: Use
add_symbolliberally to label addresses you've identified — makes disassembly readable - Bookmarks: Use
add_disassembler_bookmarkfor code locations andadd_memory_bookmarkfor data regions - Watches: Use
add_memory_watchfor variables you're tracking across steps - Save states: Use
save_state/load_stateto snapshot and restore emulator state at interesting points - Rewind: Use
get_rewind_status+rewind_seekto scrub back through recent execution history without manual save states - Screenshots: Capture visual state with
get_screenshotafter significant changes
The emulator continuously records snapshots into a ring buffer during gameplay. You can seek to any recorded snapshot to restore full emulator state at that point in time — like time travel debugging.
- Check availability:
get_rewind_status— returns snapshot count, capacity, buffered seconds - Pause:
debug_pause— the emulator must be paused before seeking - Seek:
rewind_seekwith a snapshot number (1 = oldest, snapshot_count = newest) - Inspect:
get_huc6280_status,get_disassembly,get_screenshot,read_memory, etc. - Iterate: Seek to different snapshots to narrow down when a bug first appeared
- Resume or continue debugging:
debug_continueto resume from the seeked state
| Tool | Description |
|---|---|
get_rewind_status |
Snapshot count, capacity, buffered seconds, configuration |
rewind_seek |
Jump to snapshot N (1=oldest, count=newest). Non-destructive — can seek repeatedly |
- Non-destructive seeking:
rewind_seekloads a snapshot without removing it. You can seek to the same snapshot multiple times, or jump between different snapshots freely. - Snapshot numbering: Snapshot 1 is the oldest available, snapshot_count is the newest (most recent).
- Buffer size: Configured by the user (default: 10 seconds). When full, oldest snapshots are overwritten.
- Granularity: Snapshots are taken every N frames (configurable). Default is every frame for maximum precision.
- Let the game run past the bug occurrence
debug_pause→get_rewind_statusto see how far back you can go- Binary search with
rewind_seek: try the midpoint, check if the bug is visible (get_screenshot), then narrow the range - Once you find the exact snapshot where the bug appears, inspect CPU/memory state
- Set breakpoints at the relevant code, then
rewind_seekto a snapshot just before the bug anddebug_continue