Actions

SCHG

VDP Documentation/General/Registers

From Sonic Retro

Segaretro-round.svg It has been suggested that this page be moved over to Sega Retro as to be in accordance with both sites' policies.
Please see the talk page for relevant discussion and export procedure.

TODO: Compare the remaining information with sega:Sega Mega Drive/VDP registers

$00 - Mode Set Register No. 1

Bit Name Description
7 -- No effect
6
5 -- Left Column Blank (leftover from Mode 4)

When set, the leftmost 8 columns will always show the background color.

4 IE1 Horizontal interrupt enable

When set, horizontal interrupts will be generated.

3 -- Invalid when set
2 -- Palette select

When clear, only bit 1 of each nybble in a CRAM palette entry is used, giving 8 available colors. When set, bits 1, 2 and 3 of each nybble are used, giving 512 available colors.

1 M3 HV counter latch enable

When set, the HV counter will be latched when a level 2 interrupt is generated. The HV counter will resume normal operation when this bit is cleared. (untested, need more info)

0 -- Display disable

Setting this bit actually turns off all display generation, as opposed to the screen blanking feature which simply shows the backdrop color.

$01 - Mode Set Register No. 2

Bit Name Description
7 -- 128 KB mode enable

When set, the VDP can utilize 128 KB of VRAM. Since most Mega Drives don't have 128 KB VRAM, setting this bit will result in a corrupted display.

NOTE: This is 4K/16K select on TMS9918 and possibly the SMS VDP.

6 DISP Display Enable

When cleared, the display is blanked. Any line that is blanked is filled with the backdrop color. During this time, you can freely access VDP memory with no limitations on the number of writes per line.

5 IE0 Vertical Interrupt Enable

When set, vertical interrupts will be generated.

4 M1 DMA Enable

When set, DMA operations will be enabled. Otherwise, DMA commands will be ignored by the VDP.

3 M2 Output format

Selects between a PAL (240) and NTSC (224 lines) display.

2 -- SMS display select

Toggles between the Master System (mode 4) and Mega Drive (mode 5) display modes. While in mode 4, none of the registers which normally affect the Mega Drive work; and the unused registers (8, 9 - can't test 6) now function. The mode bits which select TMS9918 modes on a real SMS have no function here. (This is why the SMS game F16 Fighter will not work with a Power Base Converter, it uses some of the TMS9918 modes in-game).

The one exception is register $0C. You can set up a 320x192 display, but the leftmost eight columns read 'garbage' data for the name table attributes. Enabling interlace makes the display unstable. (and this is partially true for a 320x192 picture, which shakes slightly) I'd advise you set $0C to zero to enable a 256x192 display, which is the normal SMS resolution. The Mega Drive always generates a 224 line picture; the 192 lines in SMS mode are centered in the middle of the screen.

I could not get the top row or right column lock features to work while in SMS mode. Apart from this bit, the M3 pin on the cartridge connector also puts the machine into SMS mode, which may fully enable all video features.

1 -- No effect
0 -- This bit has an interesting effect; horizontal scrolling is disabled, and it would almost seem like the horizontal scroll value modifies the horizontal retrace / blanking / sync start and end positions around; the middle of the display is blanked out, and will scroll left or right. (note the blanked area scrolls - not the background) Moving too far in one direction, so the blanked area is offscreen, totally corrupts the display.

$11 - Window H Position

Bit Name Description
7 RIGT See below
6 -- No effect
5
4 WHP5 See below
3 WHP4
2 WHP3
1 WHP2
0 WHP1


This register will affect the window shown on the current line, if the current line does not fall into the vertical range specified by register $12.

The WHP field defines the horizontal range of the window, in units of two cells (16 pixels).

Setting the WHP field to zero disables the window. Any nonzero value indicates how many 2-cell columns wide the window plane is (0=no window, 1=2 cells, 2=4 cells, 3=6 cells, etc.).

When RIGT=0, the window is shown from column zero to the column specified by the WHP field. For instance, if RIGT=0 and WHP=4, the window is displayed on columns zero up to (and including) column seven.

When RIGT=1, the window is shown from the column specified in the WHP field up to the last column in the display meaning column 31 or 39 depending on the screen width setting. For instance, if RIGT=1 and WHP=4, the window is displayed on columns eight up to (and including) column 31 or 39.

Having WHP set to zero and RIGT=1 is a legal setting; it means the window is shown from column zero up to the last column in the display, meaning the entire line is taken up by the window plane.

There is a bug in the window processing. This occurs when the window is showing partially on the left side of the screen, specifically when the VDP is drawing the 2-cell column from plane A that immediately proceeds the last column the window was drawn on (i.e. WHP+1).

If the lower four bits of the horizontal scroll value for the current scan line are zero, then the name table attribute data for the current column are fetched correctly.

If the lower four bits of the horizontal scroll value for the current scan line are nonzero, the name table attribute data are fetched from next column (WHP+2).

In effect, you'll have N columns of the window plane, 1 column that has identical patterns as the next column, then the remainder of the display is drawn correctly.

Here's a diagram to illustrate this:

w   = window tiles
abc = tile columns

D3-D0 of scroll value == 0
wwwwwwwwwwwwwwwwaabbccddeeffgghh

D3-D0 of scroll value != 0
wwwwwwwwwwwwwwwwbbbbccddeeffgghh

This register can be modified with changes taking effect immediately at any point in the display frame.

Plane A is not shown in any column where plane W is shown; they cannot overlap.

$12 - Window V Position

Bit Name Description
7 DOWN See below
6 -- No effect
5
4 WVP4 See below
3 WVP3
2 WVP2
1 WVP1
0 WVP0

If the current scanline does not fall within the range specified by register $12, then register $11 determines where the window is shown for the remainder of the display.

The WVP field defines the vertical range of the window, in units of eight lines.

Setting the WVP field to zero disables the window. Any nonzero value indicates a vertical range for the window to appear in. (0=no window, 1=lines 0-$7, 2= lines 0-$F, 3= lines 0-$17, etc.)

When DOWN=0, the window is shown from line zero to the line specified by the WVP field.

For instance, if DOWN=0 and WVP=4, the window is displayed on lines zero up to (and including) line $1F.

When DOWN=1, the window is shown from the line specified in the WVP field up to the last line in the display.

For instance, if DOWN=1 and WVP=4, the window is displayed on lines $1F up to (and including) the last line in the display.

Having WVP set to zero and DOWN=1 is a legal setting; it means the window is shown from line zero up to the last line in the display, meaning the entire screen is taken up by the window plane.

Plane A is not shown in any line where plane W is shown; they cannot overlap.