Atari Lynx Game Development SDK

lynxcc is a complete game development SDK for the Atari Lynx — a full C toolchain and runtime for building cartridge games end to end. It bundles a Lynx-tuned C compiler, macro assembler, linker and archiver alongside a runtime library with direct-call graphics, joystick and serial drivers, Suzy hardware-math operators, sprite and audio tooling, and a .lnx cartridge builder — all wired together with ready-to-build examples.

About the Atari Lynx

The Atari Lynx was the world’s first full-colour portable video game system, released in 1989 (US) and 1990 (UK). Designed at Epyx and brought to market by Atari Corporation, it was sold from 1989 to 1995, with around 3 million units shipped. Its two custom CMOS chips — Suzy (a sprite-blitting and math co-processor) and Mikey (the CPU host, video DMA and sound engine) — gave it hardware sprite scaling, distortion and clipping, a four-channel DAC and a back-lit colour LCD, well ahead of its handheld contemporaries. The whole lynxcc SDK exists to target exactly this hardware.

Atari Lynx hardware specifications
DeveloperEpyx; brought to market by Atari Corporation
Retail availability1989–1995; around 3 million units sold
Display3.5-inch back-lit colour LCD (backlight on/off switch added on the Lynx II); 160 × 102 resolution; 4096-colour (12-bit) palette, 16 simultaneous colours per scanline. The original screen can be swapped for a modern LCD mod kit, greatly improving picture quality.
Audio4 channels, 8-bit DAC per channel (a 32-bit DAC overall), roughly 100 Hz to above 20 kHz. Lynx I is mono; Lynx II adds stereo with panning. Speaker: 8 Ω 0.2 W (Lynx I), 16 Ω 0.2 W (Lynx II).
CPU8-bit 65SC02 (a MOS 6502 derivative) running up to 4 MHz (~3.6 MHz average). Later Lynx II units switched to a 65C02.
Suzy (16-bit @ 16 MHz)Blitter sprite engine with collision detection (unlimited sprites in principle, ~128 in practice); hardware sprite scaling, distortion and tilting; hardware decoding of compressed sprite data; hardware clipping and multi-directional scrolling; math co-processor. Variable frame rate up to 75 fps.
Mikey (16-bit @ 16 MHz)Hosts the CPU, drives the four-channel 8-bit-per-channel sound engine (stereo with panning on the Lynx II), and runs the video DMA driver feeding the 160 × 102, 4096-colour LCD.
Memory & storage512 bytes of bootstrap / cartridge-loading ROM; 64 KB of 120 ns DRAM; cartridges of 128, 256 and 512 KB (up to 2 MB with bank switching). SD/flash-card cartridges are available that can load many official and homebrew ROMs.
NetworkComLynx serial UART supporting up to 18-player connectivity.
Ports3.5 mm stereo headphone jack (mono on Lynx I); ComLynx network port; 9 V power.
Power9 V DC supply, or 6× AA batteries giving 4–5 hours (Lynx I) or 5–6 hours (Lynx II) of play.

Usage

IntroductionBuild a short “hello world” to learn the toolchain.intro.htmlCoding hintsGet the most effective code out of cc65.coding.htmlSelf-modifying codeKrüger's macro package for SMC.smc.htmlUsing makeBuild programs with GNU Make.using-make.htmlMigrating from cc65Move a project from upstream cc65 to the lynxcc SDK.migrating.htmlSample programsAnnotated guide to every program in samples/.samples.html

Tools

abcccThe ABC tune compiler — turns ABC text into the sound engine's event stream.abccc.htmlabcromPatches a compiled tune into a template ROM to preview it in an emulator.abcrom.htmlar65The ar65 object-file archiver.ar65.htmlca65The ca65 macro assembler.ca65.htmlcc65The cc65 C compiler.cc65.htmlcl65The cl65 compile-and-link utility.cl65.htmlda65The da65 6502/65C02 disassembler.da65.htmlhmccThe HandyMusic script compiler — turns instrument, SFX and track text into the driver's .mus/.sfx binaries.hmcc.htmlld65The ld65 linker.ld65.htmllnxThe .lnx cartridge-header inspector and patcher.lnx.htmllynxdirThe vendored Lynx ROM builder — assembles a bootable cart from a .mak config with EPYX/BLL/NewMini loaders.lynxdir.htmlpalgenTurns sixteen HTML colour codes into a 12-bit Lynx palette — emits both a gfx_setpalette() array and a setpallete() array.palgen.htmlsp65The sprite and bitmap conversion utility.sp65.htmlsprpckThe vendored Lynx sprite packer — converts BMP and ASCII SPS art that sp65 does not read.sprpck.html

Reference

Function referenceThe C functions in the standard library, plus what is not covered.funcref.htmlCart ROM and EEPROMThe .lnx binary format, cart image layout and numbered file access, reading data from the cart, and EEPROM save data.cart.htmlCollision detectionSuzy's collision buffer and the per-sprite collision depository, the collision number and sprite types, and reserving the buffer with lynx-coll.cfg.collisions.htmlComLynx serialThe single-wire ComLynx port: the Mikey UART, the serial.h library, and the historical Redeye protocol.comlynx.htmlGraphicsThe fixed 160×102 16-colour display, the gfx_* API, double buffering, frame timing and the palette.graphics.htmlLynx graphics fontsGlyph tables for the three static Lynx graphics fonts.lynx_gfx_fonts.htmlHandyMusic engineThe opt-in script-driven BGM & SFX driver: reserved data regions, the VBL tick, and the handymusic.h API.handymusic.htmlHandyMusic scoringTranscribing sheet music into HandyMusic tracks: pitches to nXo tokens, note values to 60 Hz ticks, and keeping parallel voices aligned.handymusic-scoring.htmlHardware registersThe 6502 hardware vectors and MAPCTL overlay, the single-IRQ interrupt model, and the Mikey and Suzy register constants and maps.hardware.htmlJoypad inputReading the joypad, the button and switch masks, edge detection and input debouncing.joypad.htmlMemoryThe Lynx memory map, the C runtime stack and stack-overflow checking, and the heap allocator.memory.htmlMulticartBundle a menu and several game ROMs into one bootable cart; the relocatable runtime loader and the multicart_run() hand-off.multicart.htmlSD / GD flash cartThe RetroHQ SD/GD flash-cart MCU protocol, the sdcard_gd_* file API, and the required SD card layout.sdcard-gd.htmlSoundThe compiled-stream music engine and how playback works (composing lives on the abccc tool page).sound.htmlSpritesSprite control blocks, the eight SCB struct variants and TYPE_* modes, penpal colour maps, and sizing and scaling.sprites.html

About

Compiler bugsThe tracker for wrong-code bugs: every bug fixed in this fork, and the known bugs still open.compilerbugs.htmlHistory & creditsThe original cc65 authors and Lynx contributors.history.htmlLicensesConsolidated license and copyright notices for the whole distribution.licenses.htmlOptimizations & LimitationsLynx code-generation optimizations and the hardware limitations they work within.optlim.html