Hardware registers

Everything special the Atari Lynx can do lives in memory-mapped registers at the very top of the address space: Suzy at $FC00, Mikey at $FD00, the boot ROM, and — in the last six bytes — the 6502 hardware vectors. A single register, MAPCTL at $FFF9, decides which of those overlays the CPU actually sees. This page explains the vectors and what happens when you set them to various values, the MAPCTL overlay, the single-IRQ interrupt model the Lynx funnels every timer through, and the Mikey and Suzy register constants that lynxcc exposes in <lynx/_mikey.h>, <lynx/_suzy.h> and asminc/lynx/lynx.inc.

1. Memory-mapped hardware

The Lynx CPU is a 65SC02 with a flat 64 KB address space that is almost entirely RAM. The top of that space is special: the two custom chips and the boot ROM are decoded there, sharing addresses with the RAM underneath them. Reads and writes to those addresses reach the hardware, not the RAM, unless the overlay is switched off (see section 2).

RangeOverlayWhat lives there
$FC00–$FCFFSuzyThe sprite-blitter and hardware-math registers, the joypad and cartridge ports (<lynx/_suzy.h>).
$FD00–$FDFFMikeyThe eight timers, four audio channels, interrupt registers, video-DMA and serial control, and the 32-byte colour palette (<lynx/_mikey.h>).
$FE00–$FFF7Boot ROMThe 512-byte cartridge boot loader (bootldr.s); see the Cart ROM page.
$FFF8—Reserved.
$FFF9alwaysMAPCTL — the overlay control register itself, reachable in every mapping.
$FFFA–$FFFFVector spaceThe three 6502 hardware vectors: NMI, RESET and IRQ.

Because the addresses are fixed, code just reads and writes them. From C the two overlay structs MIKEY and SUZY and a handful of named pointers do this for you; from assembly the asminc/lynx/lynx.inc include defines an EQU for every register. Section 7 shows both.

2. MAPCTL: the address-space overlay

MAPCTL ($FFF9, the MAPCTL EQU and the *SPACE constants in <lynx/_suzy.h>) is the one register that is decoded no matter how the rest of the top page is mapped — it has to be, because it is what does the mapping. Each of its low four bits governs one overlay region. The sense is “1 = show the RAM underneath”: setting a bit disables the hardware/ROM decode for that range and lets the plain RAM show through; clearing it puts the chip or ROM back on top.

$FC00 $FD00 $FE00 $FFF9 $FFFA $FFFF Suzy registers Mikey registers Boot ROM MAPCTL Vectors — NMI / RESET / IRQ SUZYSPACE MIKEYSPACE ROMSPACE VECTORSPACE bit 0 bit 1 bit 2 bit 3
Each overlay region and the MAPCTL bit that maps it out to RAM. MAPCTL at $FFF9 is never overlaid, so it is always writable.

2.1. The overlay bits

ConstantValueRegionWhen the bit is set (1)
SUZYSPACE$01$FC00–$FCFFSuzy is mapped out; the RAM under Suzy is readable/writable. Clear = Suzy visible (the normal state).
MIKEYSPACE$02$FD00–$FDFFMikey is mapped out; the RAM under Mikey shows through. Clear = Mikey visible.
ROMSPACE$04$FE00–$FFF7The boot ROM is mapped out; RAM shows through. Clear = boot ROM visible.
VECTORSPACE$08$FFFA–$FFFFThe vectors come from RAM. Clear = the vectors come from the boot ROM.
HIGHSPEED$80CPU timingSelects the fast (“sequential-disable”) CPU clocking. Left clear by the runtime; most code never touches it.

Turning an overlay off is only useful when you need the RAM it hides — for example the couple of hundred bytes under the boot ROM, or the RAM behind a chip you are momentarily done talking to. It is a delicate operation: while MIKEYSPACE or SUZYSPACE is set you cannot touch that chip's registers at all, and while an interrupt could fire you must not have mapped out the vectors or Mikey out from under the handler. In practice games leave Suzy and Mikey mapped in the whole time.

2.2. What lynxcc sets

On reset the hardware clears MAPCTL to $00, so the boot ROM and its vectors are visible — that is how the machine boots. Almost the first thing the lynxcc start-up code (crt0.s) does is write:

lda #$0C          ; VECTORSPACE | ROMSPACE
sta MAPCTL        ; $FFF9

That maps out the boot ROM and the vector-space ROM, replacing both with the program's RAM, while leaving Suzy (bit 0) and Mikey (bit 1) mapped in. From then on the game runs entirely from RAM, owns the six vector bytes at $FFFA–$FFFF, and still has full access to both custom chips — the arrangement every Lynx program uses.

There is a subtlety the overlay hides: lynxcc places its display double-buffer at the very top of RAM, and screen buffer 0 ($E018–$FFF7) shares its physical DRAM with the Suzy, Mikey and boot-ROM overlay. So the 512-byte strip at $FC00–$FDFF is at once the top of that video buffer and the window onto the two chips: with the overlay in place the CPU sees Suzy and Mikey there, while Suzy's blitter writes pixels straight to the RAM underneath, bypassing MAPCTL. That overlap is deliberate and is what lets the buffer run all the way to $FFF7 without stealing usable RAM. The Memory page lays out the full map and the CPU-versus-Suzy views of this region.

3. The 6502 hardware vectors

The 65SC02, like every 6502, keeps its three fixed interrupt vectors in the top six bytes of memory. Each is a little-endian 16-bit address the CPU loads into the program counter when the corresponding event occurs.

VectorLow / highlynx.incTriggered by
NMI$FFFA / $FFFBNMIVECTL / NMIVECTHA non-maskable interrupt — no Lynx hardware drives this line.
RESET$FFFC / $FFFDRSTVECTL / RSTVECTHPower-on and hardware reset.
IRQ / BRK$FFFE / $FFFFINTVECTL / INTVECTHAny maskable interrupt, and the BRK instruction.

The VECTORS EQU ($FFFB) names the block for convenience. The names match the boot ROM's own labels; in a running game they are just six RAM bytes because crt0.s set VECTORSPACE.

$FFFA$FFFB $FFFC$FFFD $FFFE$FFFF lohi lohi lohi NMI RESET IRQ / BRK
Three little-endian word pointers. Only the IRQ vector matters to a running Lynx program; the runtime points it at its own stub.

3.1. NMI, RESET and IRQ

NMI is a dead end on the Lynx: no timer, chip or pin is wired to the CPU's non-maskable-interrupt input, so the vector is never fetched. You can leave the two bytes as whatever the linker put there; writing an address into them has no effect because nothing will ever jump through them.

RESET is fetched only by a genuine power-on or reset — and such a reset also clears MAPCTL back to $00, which maps the boot ROM back over $FFFC/$FFFD. So the address the CPU actually uses on reset is the boot ROM's, not the RAM copy your program left there. The RAM reset vector is therefore inert in practice; do not rely on it to restart your game.

IRQ is the one that matters. Every maskable interrupt the Lynx can raise — and there are eight potential sources, all of them Mikey timers — enters the CPU through this single vector, as does a BRK instruction. The runtime writes this vector during start-up so that interrupts land in its own handler (section 4).

3.2. Setting a vector to various values

Because the vectors are ordinary RAM once VECTORSPACE is set, “what a vector does” is entirely a function of the address you store in it:

From C you never poke the vector directly; call set_irq() and reset_irq() instead (section 4.3).

4. The single-IRQ interrupt model

The eight Mikey timers are the Lynx's only interrupt sources, and they all share the one 6502 IRQ line. When any enabled timer counts down to zero it sets its bit in Mikey's interrupt register and pulls IRQ low; the CPU jumps through $FFFE/$FFFF into a single handler that has to work out which timer fired, service it, and acknowledge it.

timers 0–7 timer 0 (HBL) timer 2 (VBL) timer 4 (UART) timer 7 (snd) … INTSET pending bits IRQStub callirq chain read INTSET write INTRST acknowledge IRQ
All eight timers pull the same IRQ line. The handler reads INTSET to see who fired and writes INTRST to clear it.

4.1. INTSET and INTRST

Two Mikey registers expose the interrupt latch. INTSET ($FD81) reads back a bitmask of the currently pending timer interrupts — one bit per timer. INTRST ($FD80) clears the bits you write to it; acknowledging an interrupt means writing its bit (or the whole pending mask) to INTRST. The runtime's stub does the blunt, always-correct thing — it copies every pending bit straight back:

lda INTSET        ; which timers are pending
sta INTRST        ; acknowledge them all

The same two-line idiom appears in crt0.s to clear any stale interrupts left over from the boot ROM before the game unmasks IRQ.

4.2. Timer interrupt bits

The bit for each timer is its number as a power of two; lynx.inc gives both the numeric names and friendly aliases for the four timers the runtime assigns a fixed role.

BitConstantAliasTimer / role
$01TIMER0_INTERRUPTHBL_INTERRUPTTimer 0 — horizontal-blank line timer.
$02TIMER1_INTERRUPT—Timer 1.
$04TIMER2_INTERRUPTVBL_INTERRUPTTimer 2 — vertical-blank timer.
$08TIMER3_INTERRUPT—Timer 3.
$10TIMER4_INTERRUPTSERIAL_INTERRUPTTimer 4 — the UART baud timer (see ComLynx).
$20TIMER5_INTERRUPT—Timer 5.
$40TIMER6_INTERRUPT—Timer 6.
$80TIMER7_INTERRUPTSND_INTERRUPTTimer 7 — the sound-engine tick (see Sound).

A timer only raises interrupts when its own control byte enables them (bit 7 of TIMnCTLA); crt0.s starts by clearing that bit on every timer so nothing fires until a library asks for it.

4.3. Installing a handler

C code does not touch the vector or the registers directly. The runtime installs its own IRQ stub at start-up, which saves the registers, calls the chain of C-level interrupt handlers, acknowledges the interrupt and returns. You add a handler to that chain with set_irq() and remove it with reset_irq():

#include <6502.h>

static unsigned char on_irq (void) {
    /* runs on every timer interrupt; return IRQ_HANDLED if you serviced it */
    return IRQ_NOT_HANDLED;
}

set_irq (on_irq, irq_stack, sizeof irq_stack);   /* install  */
/* ... */
reset_irq ();                                    /* remove   */

The stub always writes INTSET back to INTRST for you, so a C handler never has to acknowledge the hardware itself; it only decides whether it recognised the interrupt.

5. Mikey constants and register map

Mikey occupies $FD00–$FDFF. In C the whole block is the MIKEY overlay struct (struct __mikey in <lynx/_mikey.h>); in assembly every register has an EQU in lynx.inc. The map below groups the block by function; the curated tables that precede it give the value semantics of the fields you actually program by hand.

5.1. Timers

The eight timers sit back-to-back from $FD00, four bytes each: a reload (backup) value, a control A byte, the live count, and a control B byte. In C they are MIKEY.timer0…timer7 (each a _mikey_timer with reload, control, count, control2); the named pointers _HBL_TIMER, _VBL_TIMER and _UART_TIMER alias timers 0, 2 and 4. In assembly the per-byte EQUs are TIMnBKUP / TIMnCTLA / TIMnCNT / TIMnCTLB, with HTIMER, VTIMER and STIMER naming the horizontal, vertical and sound timers.

5.2. Audio

The four audio channels run from $FD20, eight bytes each (volume, feedback, dac, shiftlo, reload, control, count, other) — MIKEY.channel_a…channel_d, or the AUDnVOL…AUDnCTLB EQUs. The attenuation and panning registers follow at $FD40–$FD44, and the stereo-enable byte MSTEREO is at $FD50. Programming these by hand is covered on the Sound page; most code goes through the sound engine.

5.3. System and I/O control

The scattered control registers in the high half of the page are the ones a game pokes directly. The most important:

RegisterAddrWhat it does
INTRST$FD80Interrupt reset — writing a bit clears that timer's pending interrupt.
INTSET$FD81Interrupt poll — reads the pending-interrupt bitmask.
AUDIN$FD86Audio-in / parallel bit, also used as an extra cartridge I/O line.
SYSCTL1$FD87System control: bit 1 is system power (1 = on), bit 0 the cartridge address strobe. Clearing the power bit is how poweroff() switches the console off.
MIKEYHREV$FD88Mikey hardware revision (read-only).
IODIR$FD8ADirection bits for the parallel I/O port (cartridge, ComLynx, LCD).
IODAT$FD8BParallel I/O data.
SERCTL$FD8CUART control (write) / status (read). The TxIntEnable…ParEven and TxReady…ParityBit bit constants live in lynx.inc; see ComLynx.
SERDAT$FD8DUART data register.
DISPCTL$FD92Video-DMA control: enables the display DMA and selects the bit order. The runtime keeps a RAM shadow (_VIDDMA).
DISPADR$FD94Start address of the display buffer Mikey scans out (the scrbase pointer).

5.4. Full Mikey map

RangeRegisters
$FD00–$FD1FTimers 0–7 (4 bytes each: reload, control A, count, control B).
$FD20–$FD3FAudio channels A–D (8 bytes each).
$FD40–$FD44Channel attenuation (attena–attend) and panning.
$FD50MSTEREO — stereo channel-enable bits.
$FD80–$FD81INTRST, INTSET — interrupt reset / poll.
$FD84–$FD85MAGRDY0, MAGRDY1 — cartridge (mag-tape) ready bits.
$FD86–$FD8DAUDIN, SYSCTL1, MIKEYHREV, MIKEYSREV, IODIR, IODAT, SERCTL, SERDAT.
$FD90–$FD95SDONEACK (Suzy-done ack), CPUSLEEP, DISPCTL, PBKUP, DISPADR.
$FD9C–$FD9EMTEST0–2 — test registers (leave alone).
$FDA0–$FDBFThe 32-byte hardware palette: GCOLMAP (green, $FDA0) and RBCOLMAP (red-blue, $FDB0). See Graphics.

6. Suzy constants and register map

Suzy occupies $FC00–$FCFF — the SUZY overlay struct (struct __suzy in <lynx/_suzy.h>) in C, the lynx.inc EQUs in assembly. Most of Suzy is the sprite-blitter's working registers, which you rarely write by hand; the control and math constants are the part you program directly.

6.1. The sprite-engine registers

The block from $FC00 to $FC2F is the blitter's scratchpad: temporary and offset addresses, the sprite-control-block base and next pointers, the video and collision buffer addresses, the running horizontal/vertical positions and sizes, and the stretch and tilt adders. The graphics runtime and the sprite engine set these up for you from the SCB you pass in; see the Sprites and Collision detection pages. You mostly touch them directly only when driving Suzy math or writing a custom blit.

6.2. SPRCTL0, SPRCTL1 and SPRSYS

The three bytes at $FC80–$FC81 and $FC92 carry the sprite and system control bits. The first byte of every SCB is a copy of SPRCTL0; the second is SPRCTL1. Their meaning is covered in full on the Sprites page; the constants are:

RegisterConstants (from <lynx/_suzy.h>)
SPRCTL0 $FC80Bit depth BPP_1/BPP_2/BPP_3/BPP_4 ($00/$40/$80/$C0); HFLIP ($20), VFLIP ($10); sprite type TYPE_BACKGROUND…TYPE_SHADOW ($00–$07).
SPRCTL1 $FC81LITERAL ($80) vs PACKED ($00) data; reload depth RENONE/REHV/REHVS/REHVST ($00/$10/$20/$30); REUSEPAL ($08), SKIP ($04), DRAWUP ($02), DRAWLEFT ($01).
SPRSYS write $FC92SIGNMATH ($80), ACCUMULATE ($40), NO_COLLIDE ($20), VSTRETCH ($10), LEFTHAND ($08), CLR_UNSAFE ($04), SPRITESTOP ($02).
SPRSYS read $FC92MATHWORKING ($80), MATHWARNING ($40), MATHCARRY ($20), VSTRETCHING ($10), LEFTHANDED ($08), UNSAFE_ACCESS ($04), SPRITETOSTOP ($02), SPRITEWORKING ($01).
SPRGO $FC91SPRITE_GO ($01) starts the blitter; EVER_ON ($04) keeps the “everon” detector active.

SPRSYS is one address with two faces: the bits you write (math sign, accumulate, global no-collide, stretch, handedness, stop) are not the bits you read back (the math-busy/warning/carry and sprite-busy status). NO_COLLIDE here is the global collision kill switch that gfx_setcollisiondetection() toggles.

6.3. Hardware-math registers

Suzy's multiply/divide unit is a set of registers at $FC52–$FC6F. <lynx/_suzy.h> exposes them as the FACTOR_A/FACTOR_B, PRODUCT, DIVIDEND/DIVISOR, QUOTIENT and REMAINDER access macros; the raw bytes are MATHA–MATHP in lynx.inc. You almost never use these directly — the suzy_* operators and the async-math API in <lynx/suzymath.h> wrap them, handling the sign and normalisation subtleties for you.

OperationRegisters
Multiply A × BFACTOR_A ($FC54), FACTOR_B ($FC52) → PRODUCT ($FC60).
Divide dividend ÷ divisorDIVIDEND ($FC60), DIVISOR ($FC56) → QUOTIENT ($FC52), REMAINDER ($FC6C).

6.4. Joypad and switches

The controller lives in two Suzy registers. JOYSTICK ($FCB0) is the d-pad and the four face buttons; SWITCHES ($FCB1) holds the Pause switch. The raw bit masks are in <lynx/_suzy.h>:

RegisterBits
JOYSTICK $FCB0JOYPAD_UP ($80), JOYPAD_DOWN ($40), JOYPAD_LEFT ($20), JOYPAD_RIGHT ($10), BUTTON_OPTION1 ($08), BUTTON_OPTION2 ($04), BUTTON_INNER ($02), BUTTON_OUTER ($01).
SWITCHES $FCB1BUTTON_PAUSE ($01).

These are the physical register bits; the direction bits flip when the console is held left-handed, and Pause is a separate register. The joy_read() library call reads both, normalises the orientation and folds Pause into bit 8 of its result — use its JOY_*_MASK constants rather than these raw bits in game code. The Joypad input page covers reading, edge detection and debouncing.

6.5. Full Suzy map

RangeRegisters
$FC00–$FC2FSprite-engine working registers (temp/offset addresses, SCB and buffer pointers, positions, sizes, stretch, tilt).
$FC52–$FC6FHardware-math registers (MATHA–MATHP, factors, product, dividend/divisor, quotient, remainder).
$FC80–$FC83SPRCTL0, SPRCTL1, SPRCOLL (collision number), SPRINIT.
$FC88–$FC89SUZYHREV, SUZYSREV — hardware / software revision (read-only).
$FC90–$FC92SUZYBUSEN (bus enable), SPRGO (start blit), SPRSYS (system control / status).
$FCB0–$FCB3JOYSTICK, SWITCHES, RCART0, RCART1 (cartridge data ports).
$FCC0–$FCC4LEDS, PARSTATUS, PARDATA (parallel port), HOWIE.

7. Reaching the registers from C and assembly

You do not compute these addresses by hand. From C, <lynx.h> pulls in the two overlay structs and a few named pointers:

#include <lynx.h>

MIKEY.timer0.reload = 0x9E;   /* Mikey timer 0 backup value      */
MIKEY.palette[0]    = 0x00;   /* first hardware palette byte     */
SUZY.sprsys         = ACCUMULATE;   /* Suzy system control       */
_VBL_TIMER.control  = 0x1F;   /* alias for MIKEY.timer2          */

MIKEY is (*(struct __mikey *)0xFD00) and SUZY is (*(struct __suzy *)0xFC00), so a struct member access compiles straight to an absolute load or store — no pointer arithmetic at run time. The convenience aliases _HBL_TIMER, _VBL_TIMER, _UART_TIMER and _VIDDMA name the timers and the video-DMA shadow the runtime cares about.

From assembly, include the register EQUs and write the addresses by name:

.include "lynx/lynx.inc"

        lda #$0C
        sta MAPCTL          ; $FFF9

        lda INTSET          ; pending timer interrupts
        sta INTRST          ; acknowledge them

Every register named on this page has an EQU in asminc/lynx/lynx.inc, and the bit-field constants (interrupt bits, SERCTL flags) are defined alongside them. Because the constants are shared between the C headers and the include file, the two stay in step.

8. License

The Lynx runtime, like the rest of the package, is distributed under the cc65 zlib-style license. The full text, together with every other copyright notice in the distribution, is reproduced verbatim on the consolidated Licenses and copyright notices page.