Difference between revisions of "Sega Mega Drive/Shadow and highlight"

From Sega Retro

(→‎Disable shadow and highlight mode: Show a full register listing with values that actually control S/TE.)
Line 49: Line 49:
  
 
==Disable shadow and highlight mode==
 
==Disable shadow and highlight mode==
The following code will set the appropriate register:
+
The shadow/highlight enable bit is located in register 12 (Mode Set Register No. 4), which also contains settings for screen width and interlacing.
  
 +
Use this instruction to set Mode Set Register No. 4 to the value <tt>$xx</tt>:
 
: <tt>move.w #$8Cxx,($c00004).l</tt>
 
: <tt>move.w #$8Cxx,($c00004).l</tt>
  
Replace <tt>xx</tt> with one of the following values:
+
To determine the value of <tt>$xx</tt>, use the following chart. The resulting value will be in binary, which can be converted to hexadecimal using a calculator:
  
 
{| style="width:auto; text-align:center"
 
{| style="width:auto; text-align:center"
|
+
|
|
+
| style="border: solid 1px black" |MSB
|colspan="3" style="border-left:solid 1px black"| Interlace
+
| style="border: solid 1px black" |
|-
+
| style="border: solid 1px black" |
|style="border-bottom:solid 1px black"|
+
| style="border: solid 1px black" |
|style="border-bottom:solid 1px black"|
+
| style="border: solid 1px black" |
|style="border-left:solid 1px black; border-bottom:solid 1px black"| disable
+
| style="border: solid 1px black" |
|style="border-bottom:solid 1px black"| enable
+
| style="border: solid 1px black" |
|style="border-bottom:solid 1px black"| double
+
| style="border: solid 1px black" |LSB
|-
+
|-
|rowspan="2"| Resolution
+
| Reg. #12
| 320 pixels wide
+
| style="border: solid 1px black" |RS0
|style="border-left:solid 1px black"| 81
+
| style="border: solid 1px black" |0
| 83
+
| style="border: solid 1px black" |0
| 87
+
| style="border: solid 1px black" |0
|-
+
| style="border: solid 1px black" |S/TE
| 256 pixels wide
+
| style="border: solid 1px black" |LSM0
|style="border-left:solid 1px black"| 00
+
| style="border: solid 1px black" |LSM1
| 02
+
| style="border: solid 1px black" |RS1
| 06
+
|}
|}
+
 
 +
RS0/RS1 controls screen width:
 +
* 00: 256 pixels (32 cells)
 +
* 11: 320 pixels (40 cells)
 +
 
 +
LSM0/LSM1 controls interlacing:
 +
* 00: No interlacing
 +
* 01: Interlacing Mode 1
 +
* 11: Interlacing Mode 2 (double resolution)
 +
 
 +
S/TE controls shadow/highlight:
 +
* 0: Disabled
 +
* 1: Enabled
  
 
[[Category:Sega Mega Drive|Shadow and highlight]]
 
[[Category:Sega Mega Drive|Shadow and highlight]]
 
[[Category:Unofficial documentation]]
 
[[Category:Unofficial documentation]]

Revision as of 01:13, 19 January 2019

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 shadow/highlight enable bit is located in register 12 (Mode Set Register No. 4), which also contains settings for screen width and interlacing.

Use this instruction to set Mode Set Register No. 4 to the value $xx:

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

To determine the value of $xx, use the following chart. The resulting value will be in binary, which can be converted to hexadecimal using a calculator:

MSB LSB
Reg. #12 RS0 0 0 0 S/TE LSM0 LSM1 RS1

RS0/RS1 controls screen width:

  • 00: 256 pixels (32 cells)
  • 11: 320 pixels (40 cells)

LSM0/LSM1 controls interlacing:

  • 00: No interlacing
  • 01: Interlacing Mode 1
  • 11: Interlacing Mode 2 (double resolution)

S/TE controls shadow/highlight:

  • 0: Disabled
  • 1: Enabled