Actions

Sega Mega Drive/Shadow and highlight

From Sega Retro

Shadow and highlight is a feature of the Sega Mega Drive VDP which allows the brightness of pixels to be adjusted to three different levels: normal, shadow and highlight. This increases the potential palette of colours from 512 to around 1536 (some of those will be duplicates). It also triples the number of colours that can be displayed on screen simultaneously.

Enable shadow and highlight mode

Shadow and highlight mode is controlled by mode register 4 (register $0C). The same register also controls screen resolution (320 or 256 pixel wide mode) and interlace mode.

The following code will set the appropriate register:

move.w #$8Cxx,($c00004).l

Replace xx with one of the following values:

Interlace
disable enable double
Resolution 320 pixels wide 89 8B 8F
256 pixels wide 08 0A 0E

Rules

  • A tile on the foreground (plane A) with low priority is shadowed, with high priority it's normal.
    • Background (plane B) pixels are shadowed if the foreground is.
    • If a background tile has high priority, it will appear normal and on top of a low priority foreground tile.
    • Sprites are shadowed if the foreground is, unless their high priority bit is set, in which case they appear normal.
  • A pixel in a sprite using palette line 4, colour 15 will highlight the pixel beneath it (planes only).
    • If the pixel is shadowed by the first rule, it will appear normal.
  • A pixel in a sprite using palette line 4, colour 16 will shadow the pixel beneath it (planes only).
    • If the pixel is shadowed by the first rule, it will appear shadowed.
  • Sprites can't shadow/highlight other sprites. If sprite with a shadow/highlight pixel occludes another sprite, the plane will be visible through that pixel (with shadow/highlight applied).
  • Normal sprites can cover shadow/highlight sprites if they have a higher priority, as expected.
  • Pixels in sprites using colour 15 of palette lines 1, 2 or 3 will always appear normal. Possibly a bug.

Shadow and highlight palette.svg

Disable shadow and highlight mode

The following code will set the appropriate register:

move.w #$8Cxx,($c00004).l

Replace xx with one of the following values:

Interlace
disable enable double
Resolution 320 pixels wide 81 83 87
256 pixels wide 00 02 06