Claude Fable 5.1 Just Shipped. I Made It Scroll a Commodore 64 in Eight Directions at 50 fps.
An AI agent (Claude Code on Fable 5.1) built IRON VEIN, an 8-way scrolling platformer with colour-banded RAM, raster HUD splits, and 12 multiplexed sprites running at 50 fps on a 1 MHz C64 CPU The agent diagnosed every bug using self-built profilers and measurement instruments rather than human intuition, though it made errors that were caught by secondary instruments A critical architectural decision was "spike first": profiling a bare engine to 50 fps or failure before adding any game content,
Analysis
TL;DR
- An AI agent (Claude Code on Fable 5.1) built IRON VEIN, an 8-way scrolling platformer with colour-banded RAM, raster HUD splits, and 12 multiplexed sprites running at 50 fps on a 1 MHz C64 CPU
- The agent diagnosed every bug using self-built profilers and measurement instruments rather than human intuition, though it made errors that were caught by secondary instruments
- A critical architectural decision was "spike first": profiling a bare engine to 50 fps or failure before adding any game content, which proved essential to managing the extreme cycle budget
- The C64's colour RAM cannot be double-buffered, forcing an art-direction compromise of one colour per world row (banded cave design) to avoid visible flicker during coarse scrolling
- cc65's C-to-6502 compiler promotes byte arithmetic to int, creating hidden cycle costs; the agent learned to push per-object/per-cell code into hand-written assembly while keeping C for frame-level logic
Why It Matters
This represents a significant step in AI-driven low-level systems programming: the agent didn't just generate 6502 code, it built its own diagnostic instruments, interpreted their readings, and iteratively refined both code and measurement tools. The human's role shifted from coder to navigator, providing symptoms while the agent located and fixed the underlying causes—demonstrating a mature agent-in-the-loop workflow for performance-critical embedded development.
Technical Details
- Hardware constraints exploited: The C64's VIC chip provides hardware fine scroll (0-7 pixels per axis) but coarse scrolling requires moving the 1000-byte screen RAM and the live-read colour RAM at $D800. The agent solved the colour RAM flicker by committing to a scroll direction before crossing boundaries, stalling the camera for a frame when direction changes mid-preparation, and using a banded colour scheme (one colour per world row via table lookup) that eliminates colour RAM movement on horizontal steps
- Raster interrupt timing: The HUD/playfield split required precise $D011 writes at bad-line boundaries. The agent worked out the timing on paper (y(fy) = y(0) − fy) and verified it by freezing the emulator across all eight phases, reading the floor edge in 36 columns
- Self-built profiling instruments: The agent created a free-running CIA timer to replace an aliasing raster-line delta profiler, a missed-frame counter and a late-frame counter (revealing 20% late frames where the first counter showed zero), and a compile-flag-gated probe system costing 450 cycles each (6 per frame = 14% of budget)
- Performance budget breakdown: The final engine achieved 8-way scrolling at 1 pixel/frame with colour and HUD split at 50 fps, with 1 late frame in 1,057 on a stall-provoking route. Eight multiplexed sprites ran with 8% frame loss at 12 sprites. The cc65 compiler's int promotion turned simple expressions like r*40 into subroutine calls; the agent adopted a rule that anything per-object or per-cell must be assembly or C with static globals and no int arithmetic
- Game systems implemented: Custom physics (gravity every other frame, terminal velocity, 42-pixel jumps), a sprite rendering tool (assetsheet.py) for ASCII-based sprite editing, byte-range collision tests in assembly, a boss entity split across four multiplexed sprites, and a ripple-carry decimal score counter replacing ten 16-bit divisions per kill (which cost 700 cycles each)
Industry Insight
- The "spike first, profile to failure" methodology should be adopted as a standard pattern for AI-assisted performance-critical development: establishing a measurable performance baseline before adding features prevents the compounding of hidden costs that made the IRON VEIN boss build lose 116 frames in a minute
- Compiler behaviour awareness is critical when using AI agents for systems programming; the cc65 int-promotion issue demonstrates that agents will generate idiomatic C that has catastrophic performance characteristics on target hardware, requiring the agent to learn and encode platform-specific constraints through profiling feedback
- The expert navigator pattern (human provides direction/symptoms, agent provides velocity/implementation) scales to complex embedded domains, but the human must retain instrument-level literacy—understanding what the profiler measures and its limitations—to catch when the agent's diagnostic numbers are themselves wrong
Disclaimer: The above content is generated by AI and is for reference only.