您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

3.0KB

Skill: VIC-II Graphics, Screen, Characters, Sprites, and Raster

Use this skill when

The task involves screen memory, colors, sprites, character sets, bitmap graphics, raster interrupts, scrolling, border/background, or VIC-II banking.

Core registers

VIC-II base: $D000 / 53248.

Decimal Hex Purpose
53248-53263 $D000-$D00F Sprite X/Y coordinates
53264 $D010 High bits for sprite X positions
53265 $D011 Control register 1; vertical scroll, screen on, bitmap, raster bit 8
53266 $D012 Raster line low byte
53267 $D013 Light pen X
53268 $D014 Light pen Y
53269 $D015 Sprite enable bits
53270 $D016 Control register 2; horizontal scroll, multicolor
53271 $D017 Sprite Y expansion
53272 $D018 Memory control: screen and character/bitmap pointers
53273 $D019 Interrupt flags
53274 $D01A Interrupt enable
53275 $D01B Sprite/background priority
53276 $D01C Sprite multicolor enable
53277 $D01D Sprite X expansion
53278 $D01E Sprite-sprite collision
53279 $D01F Sprite-background collision
53280 $D020 Border color
53281 $D021 Background color 0
53282-53284 $D022-$D024 Extra background/multicolor registers
53285-53286 $D025-$D026 Sprite multicolor registers
53287-53294 $D027-$D02E Sprite individual colors

Screen basics

Default screen RAM: $0400 / 1024. Default color RAM: $D800 / 55296. Screen is 40 columns x 25 rows = 1000 character cells.

Cell address:

screen = 1024 + row * 40 + column
color  = 55296 + row * 40 + column

Sprite basics

  • Each sprite is 24 x 21 pixels.
  • Each sprite pattern uses 64 bytes.
  • Default sprite pointers are $07F8-$07FF / 2040-2047.
  • Pointer value = sprite data address / 64, within the active VIC bank.
  • Enable sprites with $D015 bits.

Example enable sprite 0 in BASIC:

POKE 53269,PEEK(53269) OR 1

VIC-II bank rule

The VIC-II sees one 16K bank at a time. CIA #2 port A controls the video bank. All active screen RAM, character data, bitmap data, and sprite data must be visible inside the selected VIC bank.

Character ROM copy warning

To copy character ROM from CPU-visible $D000-$DFFF, you must bank character ROM in and I/O out. Since I/O disappears during that window, disable interrupts briefly and restore banking immediately.

Raster interrupt principles

  • Set raster line in $D012; bit 8 is in $D011.
  • Enable raster IRQ in $D01A bit 0.
  • Acknowledge VIC interrupt by writing the relevant bit back to $D019.
  • Chain or jump to the normal KERNAL IRQ handler unless replacing the system IRQ completely.

Agent checklist

  1. Give addresses in decimal and hex.
  2. Preserve unrelated VIC register bits.
  3. Note PAL/NTSC timing differences for raster work.
  4. Keep sprite data inside active VIC bank.
  5. For character/bitmap changes, explain $D018 layout.

Powered by TurnKey Linux.