Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Memory Map

MenTaLguY edited this page · 2 revisions
Clone this wiki locally

$0000 - $3FFF: VRAM (16 kbytes)
$4000 - $7DFF: VRAM (mirror) (16 kbytes - 512 bytes)
$7E00 - $7EFF: Sprite Table* (256 bytes)
$7F00 - $7F0F: BG Palette (16 bytes)
$7F10 - $7F1F: BG/Sprite Palette* (16 bytes)
$7F20 - $7FF7: unused (216 bytes)
$7FF8 - $7FFF: VDU Registers (8 bytes)
                 $7FF8: Flags
                        4-7: unused
                        3: Enable Sprites*
                        2: Enable BG
                        0-1: Mode
                               00 - Text A (40x25)
                               01 - Text B (32x28)
                               10 - Graphics A (2bpp)
                               11 - Graphics B (4bpp)
                 $7FF9: Pattern Table Base
                        Text A + B:
                          addr = (base & 0b00110000) << 8
                          addr may be one of:
                            $0000, $1000, $2000, or $3000
                        Graphics A + B:
                          addr = (base & 0b00100000) << 8
                          addr may be one of:
                            $0000 or $2000
                 $7FFA: Name Table Base
                        addr = ((base & 0b00110000) |
                                0b00001000) << 8
                        addr may be one of:
                          $0800, $1800, $2800, or $3800
                 $7FFB: unused
                 $7FFC: BG scroll X*
                 $7FFD: BG scroll Y**
                 $7FFE-7FFF: unused
$8000 - $FFFF: mirror of $0000 - $7FFF

Notes:
  *Ignored in text modes
  **In text modes, the lower 3 bits of the vertical scroll
    register are ignored and it wraps at 200 (Text A) or
    224 (Text B)

Pattern Table

The starting address of the pattern table is determined by
register $7FF9.

The rows constituting each pattern in the table are given
in sequence from top to bottom. Within each byte, the
most significant bits contribute to the leftmost pixels.

For example:

0×10110000

In a 4bpp mode where each byte determines the color for two
adjacent pixels, the left pixel has color 0×1011, and the
right pixel has color 0×0000.

Different display modes have different pattern bit depths:


Text A: 256 patterns * 8 bytes per pattern = 2k
        6x8 pixel patterns
        1 byte per pattern row, 1 bit per pixel
        most significant 2 bits ignored

Text B: 256 patterns * 8 bytes per pattern = 2k
        8x8 pixel patterns
        1 byte per patern row, 1 bit per pixel

Graphics A: 512 bg patterns * 16 bytes per pattern +
            256 sprite patterns * 32 bytes/pattern = 16k
            8x8 pixel patterns
            2 bytes/pattern row, 2 bits/pixel (bg)
            4 bytes/pattern row, 4 bits/pixel (sprites)

Graphics B: 512 patterns * 32 bytes per pattern = 16k
            8x8 pixel patterns
            4 bytes/pattern row, 4 bits/pixel
            last 256 patterns shared with sprites

Name Table

The starting address of the name table is determined by
register $7FFA.

Table sizes:

  • Text A: 40×25 characters * 2 bytes/character = 2000 bytes
  • Text B: 32×28 characters * 2 bytes/character = 1792 bytes
  • Graphics A + B: 32×32 tiles * 2 bytes per tile = 2k

Cell formats:


  Text: pppppppp bbbbffff
    p - pattern index
    f - foreground color
    b - background color

  Graphics: pppppppp -bhvcccP
    p - low byte of pattern index
    P - high bit of pattern index
    c - high bits of color
    h - horizontal flip
    v - vertical flip
    b - background priority

In graphics modes, the color is computed by taking the high
color bits and oring them with the pattern color to get a
color in the range 0-31 (with the upper 16 colors coming
from the sprite palette):

color = pattern_color | (high_bits << 2)

(However, a pattern color of 0 is always transparent
regardless of the high color bits.)

Sprite Table

Sprite patterns start 2048 bytes after the pattern table
base address specified in register $7FF9. The sprite
table itself always begins at $7E00.

4 bytes * 64 sprites = 256 bytes


xxxxxxxx yyyyyyyy pppppppp --hvHVcc

  x - X position (left edge)
  y - Y position + 1 (top edge) (0 = hidden)
  p - pattern index
  h - horizontal flip
  v - vertical flip
  H - double size horizontally
  V - double size vertically
  c - high bits of color

Sprite colors are computed as follows:

color = pattern_color | (high_bits << 2) | 16;

(As with tiles, a pattern color of 0 is always transparent.)

Palette Table

The palette table always begins at $7F00.

1 byte * 32 colors (16 bg, 16 bg/sprite)

--rrggbb

r - red
g - green
b - blue

Note that the first sprite color (color 16) is effectively
never used.

Something went wrong with that request. Please try again.