drhelius/geartowns/geartowns-debugging
- community
Checking that the SKILL.md file is still in the repository.
Debug and trace FM Towns games and software using the Geartowns emulator MCP server. Provides workflows for Intel 80386 CPU debugging, breakpoint management, hardware inspection, disassembly analysis, and execution tracing. Use when the user wants to debug an FM Towns game, trace code execution, inspect i386 registers, segment descriptors, paging or hardware state, set breakpoints, analyze interrupts, step through 80386 instructions, reverse engineer game code, examine CRTC/VRAM/sprite/YM3438/RF5C68 registers, view the call stack, or diagnose rendering, audio, or timing issues. Also use when the user mentions FM Towns development, Towns OS, FM Towns Marty, i386 or 80386 debugging, DOS-extender games, protected mode code, CD-ROM game debugging, floppy boot debugging, or FM Towns debugging with Geartowns.
Install
npx vskill@latest install drhelius/geartowns/geartowns-debuggingSKILL.md
FM Towns Game Debugging with Geartowns
Overview
Debug FM Towns games using the Geartowns emulator as an MCP server. Control execution (pause, step, breakpoints), inspect the Intel 80386 CPU and hardware (CRTC, VRAM layers, sprite engine, YM3438 FM, RF5C68 PCM, 8259A PIC, 8253 PIT, uPD71071 DMA, CD-ROM and floppy controllers, SCSI host interface), read/write memory, disassemble code, trace instructions, and capture screenshots — all through MCP tool calls. Hardware documentation is available in the references/ directory.
MCP Server Prerequisite
IMPORTANT — Check before installing: Before attempting any installation or configuration, you MUST first verify if the Geartowns MCP server is already connected in your current session. In the default mode, call debug_get_status directly. If Geartowns 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 Geartowns MCP server:
Installing Geartowns
Run the bundled install script (macOS/Linux):
This installs Geartowns 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/geartowns on macOS.
Connecting as MCP Server
Configure your AI client to run Geartowns as an MCP server via STDIO transport. For Claude Code:
For Codex:
Replace /path/to/geartowns with the actual binary path from the install script. Add --headless before --mcp-stdio on headless machines.
Firmware
The FM Towns needs its firmware (FMT_SYS.ROM and companion files). Set the BIOS directory in the emulator before starting, or call load_bios with the directory path. get_media_info reports whether the firmware is ready.
Hardware Documentation (References)
FM Towns hardware documentation is available in the references/ directory. Load them into your context when investigating specific hardware.
| Reference | File | Load when... | |
|---|---|---|---|
| Intel 80386 CPU | references/i386_cpu.md | Registers, real/protected/VM86 modes, segmentation, paging, exceptions, IDT, FM Towns IRQ vectors | |
| Memory Map | references/memory_map.md | Physical map, low memory banking, VRAM views, CMOS, debugger memory areas | |
| I/O Ports | references/io_ports.md | Every decoded I/O port, IRQ lines, DMA channels, timer counters | |
| System Devices | references/system.md | PIC, PIT, DMA, clock, system control, keyboard, game ports | |
| Video | references/video.md | CRTC, layers, video modes, palettes, FM-R compatible display | |
| Sprites | references/sprites.md | Sprite engine, Sprite RAM entries, patterns, color tables | |
| Sound | references/sound.md | YM3438 FM, RF5C68 PCM, electronic volumes, sound interrupts | |
| CD-ROM | references/cdrom.md | CD-ROM controller ports, commands, status packets, CD-DA, DMA transfer | |
| Floppy | references/floppy.md | MB8877 floppy controller, drive control, D77 disk images | |
| SCSI | references/scsi.md | SCSI host interface, bus phases, hard disk commands and sense, boot and disk layout |
Debugging Workflow
1. Load and Orient
Start every session by making sure the firmware is loaded (load_bios with the firmware directory, unless it is already configured), then load the CD image, confirming it loaded correctly with get_media_info, then checking CPU state and taking a screenshot to understand the current game state. Games are CD images (.cue, .chd, .iso, .zip) loaded with load_media. Some titles also need a boot floppy: use insert_floppy with a .d77, .d88, .hdm, .img, .xdf, .mfm, .m3u or .zip image in drive 0 or 1. Titles installed to a hard disk run from a raw image on a SCSI ID: attach_hard_disk (or load_media with .hdd, .h0-.h6, .hdm over 8 MB), which a running machine takes at the next reset. list_recent_media shows recently opened images.
Load symbols with load_symbols (a text file with ADDRESS NAME or NAME = ADDRESS per line) or add individual labels with add_symbol.
2. Pause and Inspect
Always call debug_pause before inspecting state. While paused:
- CPU state:
get_i386_status— general registers, EIP, EFLAGS bits, CS:EIP with linear and physical PC, CR0/CR2/CR3, mode (real, protected, vm86), CPL, IOPL, segment descriptor caches, GDTR/IDTR/LDTR/TR, debug registers, and anfpusection (stack, CW, SW, tags, last instruction) when an 80387 is fitted - Disassembly:
get_disassemblywithstart_addressandend_addressorcount— decodes the current contents of memory; usecode_size(auto,16,32) to force 16-bit or 32-bit decoding anddetailedfor control flow, targets, I/O port names and interrupt vector names - Call stack:
get_call_stack— calls, interrupts and exceptions with their vectors - Memory:
read_memorywith a memory area ID (uselist_memory_areasto discover available areas and their IDs) - Debugger state:
debug_get_status— paused state, what stopped execution, linear and logical PC, CPU mode, halted
Addresses
Every tool that takes an Intel 80386 address accepts:
1234ABCD,0x1234ABCDor$1234ABCD— a linear addressCS:1234— a segment register (CS, DS, ES, FS, GS, SS) and an offset, using its cached base0008:00001234— a selector in protected mode (read from the GDT or LDT) or a segment in real and VM86 mode, and an offset
Use translate_address to walk an address through segmentation and paging (PDE, PTE, page flags, physical address, region) or to find out why it fails. get_page_directory lists the present page tables. get_i386_descriptors decodes GDT, LDT and IDT entries (in real mode the IDT is the interrupt vector table).
3. Set Breakpoints
Use breakpoints to stop execution at points of interest:
| Breakpoint Type | Tool | Use Case | |
|---|---|---|---|
| Execution | set_breakpoint (type: execute) | Stop before the instruction at the address runs | |
| Read | set_breakpoint (type: read) | Stop when memory is read | |
| Write | set_breakpoint (type: write) | Stop when memory is written | |
| Access | set_breakpoint (type: access) | Stop on any read or write | |
| I/O port | set_breakpoint (space: io) | Stop on IN/OUT/INS/OUTS to a port | |
| Range | set_breakpoint (end_address) | Cover an address range (same type and space) | |
| Interrupt | set_breakpoint_on_interrupt (vector) | Stop on entry to an interrupt vector (0-255) | |
| IRQ | set_breakpoint_on_interrupt (irq) | Stop when the PIC delivers an IRQ line (0-15), whatever its vector |
Breakpoints support three address spaces (space): linear (default), physical and io. Execute breakpoints are linear or physical. enabled: false adds or keeps a breakpoint disabled. Interrupt breakpoints by vector take a source (any, exception, hardware, software) and stop before the handler's first instruction.
Important: Read, write and access breakpoints stop after the instruction that made the memory access, so the PC is at the following instruction. Execute breakpoints stop before the instruction runs. debug_get_status reports in breakpoint what stopped execution (kind, space, address, size, or the vector and source of an interrupt).
Manage breakpoints with list_breakpoints (address, interrupt and IRQ breakpoints), remove_breakpoint and clear_breakpoint_on_interrupt (by vector and source, or by irq).
4. Step Through Code
After hitting a breakpoint or pausing:
| Action | Tool | Behavior | |
|---|---|---|---|
| Step Into | debug_step_into | Execute one instruction, enter calls and interrupts | |
| Step Over | debug_step_over | Execute one instruction, run through CALL subroutines | |
| Step Out | debug_step_out | Run until the current subroutine or interrupt handler returns | |
| Step Frame | debug_step_frame | Run frames (default 1) with breakpoints active, then pause; answers with the status when done, or at once with wait: false | |
| Run To | debug_run_to_cursor | Continue until PC reaches target address | |
| Continue | debug_continue | Resume normal execution | |
| Reset | debug_reset | Reset the emulated FM Towns |
After each step, call get_i386_status and get_disassembly to see where you are.
5. Trace Execution
The trace logger records executed instructions (CS:EIP, linear address, mode, bytes, Intel syntax) interleaved with hardware events (IRQ requests, interrupt entries, I/O port accesses, DMA, CD-ROM and floppy controller commands, SCSI commands and phases, VSYNC).
set_trace_logwithenabled: trueto start recording (optionally setfiltersandoutput)- Let the game run or step through code (the trace records while the debugger runs the machine)
set_trace_logwithenabled: falseto stop (entries are preserved)get_trace_logto read recorded entries (startnegative reads the last N lines,countup to 1000)
Trace filters are event streams such as cpu.instructions, cpu.irqs, io.writes, video.vsync or cdrom.commands, or a whole group: cpu, io, pic, timer, dma, video, sprite, fm, pcm, mixer, cdrom, fdc, scsi, keyboard, input, system (the tool schema lists every stream). Instruction lines carry the general and segment registers and EFLAGS. output: "disk" also streams the trace to a text file (output_path, disk_size) for long captures; memory_size sets how many entries are kept in memory.
Tracing is essential for understanding timing-sensitive code, interrupt handlers, and hardware interaction sequences.
6. Profile
set_profiler (start, stop, reset) collects calls and CPU cycles per function and interrupt vector while the debugger runs the machine. get_profiler_data returns the results (sort: inclusive, exclusive, calls, average, max; count; filter). Use it to find the hot routines of a game before stepping through them.
Hardware Inspection
CPU (Intel 80386)
get_i386_status— full CPU state: registers, EFLAGS, CR0/CR2/CR3, mode, CPL, IOPL, descriptor caches, GDTR/IDTR/LDTR/TR, debug and test registers, and the 80387 when fittedwrite_i386_register— modify a register live (EAX-EDI, EIP, EFLAGS, CR0, CR2, CR3, DR0-DR7, CS-GS). Segment writes reload base and limit in real and VM86 mode and load the descriptor in protected modeget_i386_descriptors— decodegdt,ldtoridtentries (table,start,count)get_page_directory— present page-directory entries, or withindexthe present pages of that page table
Interrupt Controllers, Timers, DMA and Clock
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/geartowns-debugging/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/drhelius/geartowns/geartowns-debugging)