forge Documentation

hardware-registers

Hardware Registers

Complete hardware register reference for the Atari 8-bit computers.

Overview

Hardware registers are located in the $D000-$D7FF address range. These registers control the GTIA, POKEY, PIA, and ANTIC chips.

GTIA Registers ($D000-$D01F)

GTIA (Graphics Television Interface Adapter) handles Player/Missile graphics, colors, and collision detection.

Player/Missile Horizontal Positions

AddressHexNameDescription
$D000$D000HPOSP0Player 0 horizontal position
$D001$D001HPOSP1Player 1 horizontal position
$D002$D002HPOSP2Player 2 horizontal position
$D003$D003HPOSP3Player 3 horizontal position
$D004$D004HPOSM0Missile 0 horizontal position
$D005$D005HPOSM1Missile 1 horizontal position
$D006$D006HPOSM2Missile 2 horizontal position
$D007$D007HPOSM3Missile 3 horizontal position

Player/Missile Graphics

AddressHexNameDescription
$D00D$D00DGRAFP0Player 0 graphics
$D00E$D00EGRAFP1Player 1 graphics
$D00F$D00FGRAFP2Player 2 graphics
$D010$D010GRAFP3Player 3 graphics
$D011$D011GRAFMMissile graphics

Color Registers

AddressHexNameShadowDescription
$D012$D012COLPM0PCOLR0 $02C0Player/Missile 0 color
$D013$D013COLPM1PCOLR1 $02C1Player/Missile 1 color
$D014$D014COLPM2PCOLR2 $02C2Player/Missile 2 color
$D015$D015COLPM3PCOLR3 $02C3Player/Missile 3 color
$D016$D016COLPF0COLOR0 $02C4Playfield color 0
$D017$D017COLPF1COLOR1 $02C5Playfield color 1
$D018$D018COLPF2COLOR2 $02C6Playfield color 2
$D019$D019COLPF3COLOR3 $02C7Playfield color 3
$D01A$D01ACOLBKCOLOR4 $02C8Background color

Control Registers

AddressHexNameDescription
$D01D$D01DGRACTLGraphics control
$D01E$D01EHITCLRClear collisions
$D01F$D01FCONSOLConsole keys (START, SELECT, OPTION)

Collision Registers

AddressHexNameDescription
$D000$D000M0PFMissile 0 to playfield collisions
$D001$D001M1PFMissile 1 to playfield collisions
$D002$D002M2PFMissile 2 to playfield collisions
$D003$D003M3PFMissile 3 to playfield collisions
$D004$D004P0PFPlayer 0 to playfield collisions
$D005$D005P1PFPlayer 1 to playfield collisions
$D006$D006P2PFPlayer 2 to playfield collisions
$D007$D007P3PFPlayer 3 to playfield collisions
$D008$D008M0PLMissile 0 to player collisions
$D009$D009M1PLMissile 1 to player collisions
$D00A$D00AM2PLMissile 2 to player collisions
$D00B$D00BM3PLMissile 3 to player collisions
$D00C$D00CP0PLPlayer 0 to player collisions

POKEY Registers ($D200-$D2FF)

POKEY (Pot Keyboard) handles audio, serial I/O, timers, and keyboard.

Audio Registers

AddressHexNameDescription
$D200$D200AUDF1Audio frequency 1
$D201$D201AUDC1Audio control 1
$D202$D202AUDF2Audio frequency 2
$D203$D203AUDC2Audio control 2
$D204$D204AUDF3Audio frequency 3
$D205$D205AUDC3Audio control 3
$D206$D206AUDF4Audio frequency 4
$D207$D207AUDC4Audio control 4
$D208$D208AUDCTLGeneral audio control
$D209$D209KBCODEKeyboard code
$D20A$D20ARANDOMRandom number generator
$D20E$D20EIRQENInterrupt request enable
$D20E$D20EIRQSTInterrupt request status (read)
$D20F$D20FSKSTATSerial port status
$D20F$D20FSKCTLSerial port control (write)

Shadow Registers

AddressHexNameDescription
$0010$0010POKMSKIRQEN shadow

ANTIC Registers ($D400-$D4FF)

ANTIC (Alpha-Numeric Television Interface Controller) handles display lists, scrolling, and character sets.

Display Control

AddressHexNameShadowDescription
$D400$D400DMACTLSDMCTL $022FDirect Memory Access control
$D401$D401CHACTLCHART $02F3Character control
$D402$D402DLISTLSDLSTL $0230Display list pointer (low)
$D403$D403DLISTHSDLSTH $0231Display list pointer (high)
$D404$D404HSCROL-Horizontal scroll
$D405$D405VSCROL-Vertical scroll
$D407$D407PMBASE-Player/Missile base address
$D409$D409CHBASECHBAS $02F4Character set base address
$D40A$D40AWSYNC-Wait for horizontal sync
$D40E$D40ENMIEN-Non-maskable interrupt enable
$D40F$D40FNMIST-Non-maskable interrupt status

PIA Registers ($D300-$D3FF)

PIA (Peripheral Interface Adapter) handles peripheral interrupts.

AddressHexNameDescription
$D302$D302PACTLPeripheral A control
$D303$D303PBCTLPeripheral B control

Shadow Registers

Many hardware registers have shadow registers in RAM that are copied to the hardware registers during vertical blank. Writing to shadow registers is safer than writing directly to hardware.

Color Shadow Registers

AddressHexNameHardwareDescription
$02C0704PCOLR0$D012Player/Missile 0 color
$02C1705PCOLR1$D013Player/Missile 1 color
$02C2706PCOLR2$D014Player/Missile 2 color
$02C3707PCOLR3$D015Player/Missile 3 color
$02C4708COLOR0$D016Playfield color 0
$02C5709COLOR1$D017Playfield color 1
$02C6710COLOR2$D018Playfield color 2
$02C7711COLOR3$D019Playfield color 3
$02C8712COLOR4$D01ABackground color

Display Shadow Registers

AddressHexNameHardwareDescription
$022F559SDMCTL$D400DMA control shadow
$0230-$0231560-561SDLSTL, SDLSTH$D402-$D403Display list pointer shadow
$02F3755CHART$D401Character control shadow
$02F4756CHBAS$D409Character base shadow

Register Usage Examples

Setting Colors

' Using shadow registers (recommended)
POKE 708, 0   ' COLOR0 = black
POKE 709, 16  ' COLOR1 = white
POKE 710, 32  ' COLOR2 = red

' Direct hardware access (faster, but use with care)
POKE $D016, 0   ' COLPF0 = black
POKE $D017, 16  ' COLPF1 = white
POKE $D018, 32  ' COLPF2 = red

Player/Missile Positions

' Set Player 0 horizontal position
POKE $D000, 80  ' HPOSP0 = 80

' Set Player 1 horizontal position
POKE $D001, 100  ' HPOSP1 = 100

Audio Control

' Set audio frequency and control
POKE $D200, 121  ' AUDF1 = 121
POKE $D201, $A8  ' AUDC1 = distortion + volume

Display List

' Get display list address
DLIST = DPEEK(560)  ' SDLSTL/SDLSTH

' Wait for horizontal sync (useful in DLIs)
POKE $D40A, 0  ' WSYNC

Best Practices

  1. Use shadow registers when possible - They're updated during VBI, avoiding timing issues
  2. Direct hardware access for DLIs - In Display List Interrupts, write directly to hardware
  3. Read collision registers - They're cleared when read, so read once per frame
  4. Use WSYNC for timing - Write to WSYNC to wait for horizontal sync
  5. Document register usage - Hardware registers can be confusing

Related Topics