VECTREX MASTERY, a hardcover book, with a certificate of authenticity and a Vectrex cartridge
Programming Games in C

VECTREX MASTERY

From an empty folder to a cartridge you can sell — C and 6809 assembly for the Vectrex, with every number in the text measured against a ROM that really ran.

// What this book is

Every number measured

Most retro programming books assert. This one measures. Every technical claim was verified against a real build before it went into the text, every figure comes from a program that actually ran, and the tools that do the measuring were written before the first chapter — because a claim you cannot check is a claim you should not make.

The Beam, Not a Buffer

There is no frame buffer. Every line is redrawn 50 times a second by steering an electron beam, and the beam takes time to move.

What Fits in Time

The budget that hurts is not memory but the 30,000 cycles in a frame. Overrun it and the screen flickers — visibly, every time.

1 KB of RAM

About 950 bytes are yours. An entity is eight bytes, not a struct with thirty-two — and that reaches into every data structure.

C and 6809 Together

C for the shape of the game, hand-written assembly where cycles decide. The book shows exactly where the line falls, and why.

One Game, Grown

Vector Siege is the spine: fifteen stages from a cartridge that prints its own name to a finished shooter. Every stage holds 50 Hz.

To a Real Cartridge

It ends where a hobby project usually stops: verified on hardware, in a box, with an overlay — a cartridge you can actually sell.

// A few things the tools measured

Numbers from a ROM that ran

None of these are estimates. Each came out of vecdump, the headless emulator written before chapter one.

3,935cycles spent by a frame that only waits, sets intensity and prints five characters — out of 30,000.
3.36×faster the same accumulation loop runs hand-written in 6809 than as the C compiler emitted it.
42%of a frame spent on a single division — 11,188 cycles. A reciprocal multiply does it in 304.
80 → 170vectors per frame, from one call to set_scale. One line more than doubles what you can draw.
1,003 / 1,024bytes of RAM used by Polar Rescue and Spinball. The machine really is that small.
75.6%of a real frame is drawing. Movement is 15.5%, thinking 6.3%, input 2.6% — sound is nearly free.

// Read a sample

The printed edition

The printed edition, as printed: the cover, the full table of contents, and then a complete chapter — Measuring and debugging, the one that builds the habit the rest of the book depends on. Turn the pages with the arrows, your keyboard, or by clicking the outer edge of a page.

Left page
Right page
Page 1 – 2 of 7

Cover, contents and pages 28–33 of the printed edition, shown at reading size. The full book runs to 230 pages.

// The interactive edition

The same book, running

The book also reads in a browser — and there it runs. Twenty-one chapters carry the ROM they describe, and the machine beside the text is the same vecx core the book measures with, compiled to WebAssembly. The numbers you watch tick over are produced by the code that produced the numbers in the text.

The sample below is the real thing, not a mock-up: the book's own cover, its complete table of contents, and chapter 05 — Measuring and debugging — with that chapter's cartridge running beside the text. Press Run.

Open the interactive sample → Opens in a new tab · one chapter of forty-seven · nothing to install

There is an Android edition as well, built for the Pixel Fold: half-fold it and the Vectrex stands on the upper leaf while the book runs down the side, with the controller on the flat leaf. The demo carries the same sample chapter, the cover and the contents, and every stage of Vector Siege is playable beside them — fifteen cartridges, from the one that boots to the finished game, with sound.

Download the Android demo (APK, 19 MB) → Android 11 or newer · any phone or tablet, best on a foldable · installs from the browser (allow it once when Chrome asks)

// What comes with it

Every line of it, buildable

The book is not a set of listings to retype. It comes with the complete source for every chapter that ships code, the reference game at every stage, and the measuring tools the whole book is built on — the same ones that produced every number in the text. Nothing is held back for a "pro edition"; there is no such thing.

28 chaptersship a directory you can build: the C, any 6809 assembly, the Makefile and the figures measured from that exact code.
Vector Siegethe reference game at 14 stages — from a cartridge that prints its own name to a finished shooter, each one buildable.
The toolsvecdump, vecshot, vecplay, vectest — the headless emulator and the acceptance checks, source included.

A chapter is one directory holding its text, its code and its figures, so the three cannot drift apart. Build it, change a number, measure it again and see the figure move:

cd chapters/04-your-first-cartridge
make          # build the cartridge
make test     # the seven acceptance checks
make shot     # render what the beam actually drew

You need the free CMOC and lwtools toolchain, both covered in chapter 03. Verified with cmoc 0.1.98 and lwtools 4.24.

230Printed pages
47Chapters + appendices
21Runnable ROMs
46kWords

// What is inside

Forty chapters, in seven parts

Part 0 · Before the first line
  • 00 Why the Vectrex
  • 01 What "releasable" means
Part 1 · Foundations
  • 02 The machine, honestly
  • 03 A production toolchain
  • 04 Your first cartridge
  • 05 Measuring and debugging
  • 06 C and 6809 assembly together
Part 2 · The beam
  • 07 How a line is drawn
  • 08 The BIOS drawing routines
  • 09 Vector lists
  • 10 The frame budget
  • 11 Rotation and scaling
  • 12 Text and the asset pipeline
Part 3 · Engine
  • 13 Fixed-point mathematics
  • 14 Entities in 1 KB
  • 15 Collision
  • 16 World, camera and clipping
  • 17 Game states
  • 18 Wave and level data
Part 4 · Sound
  • 19 The AY-3-8912
  • 20 The BIOS music player
  • 21 Producing music and effects
Part 5 · From technique to game
  • 22 Game feel with an analog stick
  • 23 Enemy behaviour
  • 24 Bosses and wireframe 3D
  • 25 Difficulty and telemetry
  • 26 HUD, menus and high scores
Part 6 · Performance and real hardware
  • 27 Profiling
  • 28 6809 optimisation
  • 29 Assembly hot paths
  • 30 On real hardware
  • 31 The PiTrex question
Part 7 · From ROM to product
  • 32 High scores that survive
  • 33 Quality assurance
  • 34 Cartridge production
  • 35 Distribution
  • 36 Marketing and community
  • 37 Legal
  • 38 Animation
  • 39 Vector Siege, complete
Appendices
  • A–G BIOS reference, cycle tables, the error catalogue and more

// Get the book

From an empty folder to a cartridge

The manuscript is finished — 230 pages, 40 chapters, and a game that grows across all of them. The printed edition and the interactive edition are being prepared for release.