The VDP2 (Video Display Processor 2) is one of the two graphics processors for the Sega Saturn. Unlike the VDP1 where its mainly used for drawing sprites and polygons, the VDP2 is used for pretty much everything else, whether it be drawing background screens, setting priority settings, or even palettes. And because of that, it is also much more difficult to use compared to the VDP1. The VDP2 has 512kb of RAM available to it for use with cells/maps/bitmaps/etc. and 4kb of Color RAM for setting palettes for VDP1 sprites and VDP2 screens.

Screens

Basically the VDP2 consists of several different background layers, called "Screens". These can be split up into several different types of screens - Normal Scroll, Rotation, and Line Screens. Normal Scroll Screens are meant for general-purpose displays and for scrolling images. Rotation Screens are meant for doing two and three dimensional rotation of an image(which is handy for doing large levels, flooring, etc. in 3D). Line Screens just allows the programmer to set a single color to the whole screen, or a color for every line. Here's a list of all the screens:

Scroll Screens

NBG0(Can display bitmaps and cells)

NBG1(Can display bitmaps and cells)

NBG2(Can only display cells)

NBG3(Can only display cells)

Rotation Screens

RBG0(Can display bitmaps and cells)

RBG1(Can display bitmaps and cells)

Line Screens

Back(is displayed underneath all the other screens)

Line Color(is used only for color calculations)

Note: If RBG1 is enabled, you can no longer use NBG0-NBG3, so keep that in mind.

Display Format

The VDP2 generates the following types of displays:

NTSC - 60 frames per second, 263 lines per frame

PAL - 50 frames per second, 313 lines per frame

Here's a description of how each frame is composed. The NTSC displays have been visually inspected and therefore have more details about them, whereas for the PAL modes only divide the display into the active display and blanking/border/sync areas.

NTSC, 224 lines:

224 lines for the active display area
8 lines for the bottom border area
5 lines for the bottom blanking area
3 lines for the vertical sync area
15 lines for the top blanking area
8 lines for the top border area

NTSC, 240 lines:

240 lines for the active display area
5 lines for the bottom blanking area
3 lines for the vertical sync area
15 lines for the top blanking area

PAL, 224 lines:

224 lines for the active display area
32 lines for the bottom border area
25 lines for blanking and sync
32 lines for the top border area

PAL, 240 lines:

240 lines for the active display area
24 lines for the bottom border area
25 lines for blanking and sync
24 lines for the top border area

PAL, 256 lines:

256 lines for the active display area
16 lines for the bottom border area
25 lines for blanking and sync
16 lines for the top border area

When bit 2 of the HRESOx field is set, the exclusive monitor modes are enabled. It's not exactly clear what kind of monitor these modes are supposed to be used with, I would guess HDTV or possibly VGA.

Depending on the screen width, the following types of displays are generated:

320 or 640 pixels: (31kHz monitor)

480 active display lines
45 VBlank lines
525 lines total

352 or 704 pixels: (Hi-Vision monitor)

479 active display lines
82 VBlank lines
561 lines total

These display settings are identical between a NTSC and PAL Saturn. The VRESOx bits have no effect on the display size.

It seems that while the LSMDx bits will enable an interlaced display, this is not required for the exclusive monitor modes. It's likely that enabling interlacing might adversely affect the display. The VDP2 manual recommends turning interlacing off entirely.

Bitmap Mode

(finish me)

Cell Mode

This mode is for displaying cell(also called tile) maps. Basically each it consists of 4 planes(16 for rotation screens) which are in a 2x2 grid(or 4x4 for rotation screens). They're arranged as follows:

1 2
3 4

In each of those planes, there's are a number of pages(specified by the plane size register) which can be as many as 4. They're also arranged as follows:

1 2
3 4

In each of those pages, there consists a 64x64 character pattern grid. Each character pattern can be either 1x1 or 2x2 cells(specified by the screen's Character Control Register). Each cell is 8x8 pixels.

Color RAM

The VDP2 has 4K of on-chip color RAM. This memory is mapped to the address range of 0x05F00000-0x05F7FFFF, mirrored every 4K.

In mode 0, values written to CRAM offsets $000-7FF are also written to offsets 0x800-0xFFF. Likewise, values written to offsets 0x800-0xFFF are written to offsets 0x000-0x7FF. So write mirroring is done for both parts of CRAM.

In mode 1 there is no mirroring and the entire CRAM region can be accessed normally.

In mode 2 and 3 the CRAM address bus has some bits shuffled around:

MSB

LSB

Intended offset

A11

A10

A09

A08

A07

A06

A05

A04

A03

A02

A01

A00

Actual offset

A10

A09

A08

A07

A06

A05

A04

A03

A02

A01

A11

A00

This arrangement has the first two bytes of each four byte entry at CRAM offsets 0x000-0x7FF, and the last two bytes at offset 0x800-0xFFF.

This distinction between how CRAM is addressed is important if a program reads or writes data in one mode that is to be used in a different mode.

Operation Flow

This is for the most part how the draw cycle works(may need some tweaking):

How to setup a scroll screen

The following will give a step by step process on enabling the NBG0 as a 256 color scroll screen.

Notes

When the VDP2 fetches the color offset for the pixel it is to draw, it fetches whatever was last written in the Color Offset registers. So hypothetically, you could actually apply color offset effects per scanline during horizontal blanking. In fact, Albert Odyssey uses this as a cheap way of doing a gradient effect.

It looks as though V-blank in/out interrupts will not be sent if 0x8000 (DISP) bit is not set in 0x25F80000 (TVMD). More investigation should be done.

If 0x25F80000 (TVMD) does not have 0x8000 (DISP) set to 1, and 0x0100 (BDCLMD) bit is also not set, the back screen will not be displayed at all (instead black is drawn to the screen). However if 0x0100 (BDCLMD) is set, the back screen still is drawn.

Instead of adjusting the pixel density when changing between 224 and 240 line vertical resolutions, 8 pixels above and below the screen are used as a border(when using 224) or are used as a drawable area(when using 240). Looks like 256(only available on PAL systems) uses the same thing, but it'll need to be verified. As for horizontal resolutions, it looks like pixel density is adjusted, but so also the border appears to be adjusted too(by 8 pixels on each side).