Skip to content

symbols

symbols.xc is a header of named constants for the xt6502 platform’s memory map: the hardware registers, OS vectors, and memory regions that low-level code and inline assembly refer to by address. Importing it lets you write RTCLOK instead of $12, COLBK instead of $D01A, and so on.

#import <symbols.xc>

These are the 6502 target’s hardware and OS addresses, defined as macros that cast a literal address to the width of the location: ((u8)$…) for a one-byte register, ((u16)$…) for a two-byte pointer or vector. They generate no code. You read, write or JSR through them, usually from an asm { } block or a raw pointer dereference.

The header defines about 268 symbols. The tables below cover each group it defines (the timing clock, the OS/interrupt vectors, the display and colour state, and the custom-chip register files) and list the main members of each. For the full list, read the header, which is grouped by memory page in the same order.

Sections: Timing · OS, DOS & interrupt vectors · Memory regions & pointers · Display & screen · Colour · Keyboard, console & input · Zero-page working storage · Hardware registers

The jiffy clock and the software / hardware timers. Most code uses RTCLOK, a 3-byte frame counter stored most-significant byte first. The Time class reads it.

SymbolAddressMeaning
RTCLOK$12real-time (jiffy) clock, 3 bytes, MSB first
ATRACT$4Dattract-mode timer
SRTIMR$22Bkey auto-repeat timer
CDTMV1CDTMV5$218$220system timer 1–5 countdown values
CDTMA1, CDTMA2$226, $228timer 1 / 2 callback addresses
CDTMF3, CDTMF4, CDTMF5$22A, $22C, $22Etimer 3 / 4 / 5 flags
VCOUNT$D40Bvertical line counter (read)
WSYNC$D40Await for horizontal sync (strobe)

RAM-based vectors the OS dispatches through. Install a handler by writing its address here, using the OS-safe path where one exists (see Vbi for the vertical-blank pair).

SymbolAddressMeaning
DOSVEC$0ADOS start vector
DOSINI$0CDOS init address
CASINI$02cassette initialisation vector
RUNAD$2E0program run-address vector
INITAD$2E2program init-address vector
VDSLST$200display-list interrupt vector
VKEYBD$208keyboard interrupt vector
VBREAK$206BRK instruction vector
VSERIN, VSEROR, VSEROC$20A, $20C, $20Eserial input-ready / output-ready / output-complete vectors
VTIMR1, VTIMR2, VTIMR4$210, $212, $214timer 1 / 2 / 4 interrupt vectors
VIMIRQ$216IRQ immediate vector
VVBLKI$222vertical-blank immediate vector
VVBLKD$224vertical-blank deferred vector
HATABS$31Adevice handler address table

The bounds of usable RAM. MEMLO and MEMTOP2 bracket the free region; the rest describe the memory-test and language-runtime pointers.

SymbolAddressMeaning
MEMLO$2E7start of free RAM
MEMTOP2$2E5top of display memory
MEMTOP$90top of language-runtime memory
APPMHI$0Eapplication memory high limit
RAMTOP$6ARAM size, in 256-byte pages
RAMLO$04RAM pointer for the memory test
LOMEM$80language-runtime low-memory pointer

Screen-memory location, cursor state, display mode, and the display-list / DMA control that drive the video hardware.

SymbolAddressMeaning
SAVMSC$58screen memory address
DINDEX$57current display (graphics) mode
ROWCRS$54cursor row
COLCRS$55cursor column (2 bytes)
LMARGN, RMARGN$52, $53left / right text margin
SDLSTL$230display-list pointer shadow
SDMCTL$22FDMA-control shadow
DLISTL, DLISTH$D402, $D403display-list pointer (low / high)
DMACTL$D400DMA control (hardware)
CHBAS$2F4character-set base (page) shadow
CHBASE$D409character-set base (page, hardware)
GPRIOR$26Fpriority / graphics-mode shadow

Colour is held in RAM shadows (copied to the hardware every vertical blank) and in the hardware registers themselves. Write the shadow for a stable change; write the hardware register for a mid-frame effect.

SymbolAddressMeaning
COLOR0COLOR3$2C4$2C7playfield 0–3 colour shadows
COLOR4$2C8background colour shadow
PCOLR0PCOLR3$2C0$2C3player/missile 0–3 colour shadows
COLPF0COLPF3$D016$D019playfield 0–3 colour (hardware)
COLBK$D01Abackground colour (hardware)
COLPM0COLPM3$D012$D015player/missile 0–3 colour (hardware)

Last-key state, the console keys, and the joystick / trigger ports.

SymbolAddressMeaning
CH$2FClast keyboard code pressed
KBCODE$D209keyboard code (hardware)
CONSOL$D01Fconsole switches
BRKKEY$11break-key flag
TRIG0TRIG3$D010$D013joystick trigger 0–3 (read)
PORTA$D300port A (joysticks 0 and 1)
PORTB$D301port B

Scratch and floating-point registers in page zero. The FP registers FR0, FR1, FR2 are six bytes each; the input/pointer helpers are two bytes.

SymbolAddressMeaning
FR0$D4floating-point register 0 (6 bytes)
FR1$E0floating-point register 1 (6 bytes)
FR2$E6floating-point register 2 (6 bytes)
CIX$F2character index into the FP input buffer
INBUFF$F3FP input-buffer pointer
FLPTR$FCfloating-point pointer
TEMP, HOLD1$50, $51general temp registers

The header also names the CIO and SIO zero-page blocks (ICHIDZICAX2Z around $20; STATUSDSTAT around $30) used when driving device I/O by hand.

The custom-chip register files. Many chips alias read and write at one address: the location means one thing when written and another when read, and the header has a name for each. The tables below list the commonly used registers per chip; the header defines each chip’s complete register file.

GTIA ($D000$D01F): players/missiles, collisions, priority, console:

SymbolAddressMeaning
HPOSP0HPOSP3$D000$D003player 0–3 horizontal position (write)
GRAFP0GRAFP3$D00D$D010player 0–3 graphics (write)
PRIOR$D01Bpriority select (write)
HITCLR$D01Ecollision clear (strobe)
M0PFM3PF$D000$D003missile–playfield collisions (read)
P0PLP3PL$D00C$D00Fplayer–player collisions (read)

POKEY ($D200$D20F): audio, serial, keyboard scan, random:

SymbolAddressMeaning
AUDF1/AUDC1AUDF4/AUDC4$D200$D207audio channel 1–4 frequency / control (write)
AUDCTL$D208audio control (write)
IRQEN$D20EIRQ interrupt enable (write)
SKCTL$D20Fserial-port control (write)
RANDOM$D20Arandom-number generator (read)
KBCODE$D209keyboard code (read)
IRQST$D20EIRQ status (read)

PIA ($D300$D303): the parallel ports:

SymbolAddressMeaning
PORTA$D300port A (joysticks 0 and 1)
PORTB$D301port B
PACTL$D302port A control
PBCTL$D303port B control

ANTIC ($D400$D40F): display DMA, scrolling, NMI:

SymbolAddressMeaning
DMACTL$D400DMA control (write)
CHACTL$D401character control (write)
HSCROL, VSCROL$D404, $D405horizontal / vertical scroll (write)
PMBASE$D407player/missile base address, page (write)
WSYNC$D40Await for horizontal sync (strobe)
NMIEN$D40ENMI interrupt enable (write)
VCOUNT$D40Bvertical line counter (read)
NMIST$D40FNMI status (read)
  • The 6502 standard library: the system services built on these addresses.
  • Vbi: installing vertical-blank handlers safely through the VVBLKI / VVBLKD vectors.
  • Time: the RTCLOK-based clock.