Difference between revisions of "Sega Mega Drive/Planes"

From Sega Retro

Line 2: Line 2:
  
 
==Nametables==
 
==Nametables==
 +
===Size===
 +
The dimensions of the foreground and background planes are set by [[Sega Mega Drive/VDP registers#10|VDP register $10]]. Both planes have the same size. The following are the possible size settings:
 +
 +
{|
 +
! Size || Space in VRAM (for 1 plane) || Code
 +
|-
 +
| 256x256 pixels (32x32 cells)
 +
| 2048 ($800) bytes
 +
| <tt>move.w #$9000,($c00004).l</tt>
 +
|-
 +
| 512x256 pixels (64x32 cells)
 +
| 4096 ($1000) bytes
 +
| <tt>move.w #$9001,($c00004).l</tt>
 +
|-
 +
| 1024x256 pixels (128x32 cells)
 +
| 8192 ($2000) bytes
 +
| <tt>move.w #$9003,($c00004).l</tt>
 +
|-
 +
| 256x512 pixels (32x64 cells)
 +
| 4096 ($1000) bytes
 +
| <tt>move.w #$9010,($c00004).l</tt>
 +
|-
 +
| 512x512 pixels (64x64 cells)
 +
| 8192 ($2000) bytes
 +
| <tt>move.w #$9011,($c00004).l</tt>
 +
|-
 +
| 256x1024 pixels (32x128 cells)
 +
| 8196 ($2000) bytes
 +
| <tt>move.w #$9030,($c00004).l</tt>
 +
|}
 +
 +
Dimensions of 512x1024 pixels (64x128 cells) and 1024x1024 pixels (128x128 cells) are not valid, because the space used by a plane can't exceed 8196 ($2000) bytes.
 +
 
===Location===
 
===Location===
 
Nametables for all three planes are stored in VRAM, and their location is set by [[Sega Mega Drive/VDP registers|VDP registers 02, 03 and 04]]. Nametables can't be placed anywhere in VRAM, rather they must be aligned to particular multiples.
 
Nametables for all three planes are stored in VRAM, and their location is set by [[Sega Mega Drive/VDP registers|VDP registers 02, 03 and 04]]. Nametables can't be placed anywhere in VRAM, rather they must be aligned to particular multiples.

Revision as of 16:43, 17 June 2018

In addition to sprites, the Sega Mega Drive uses three planes to display graphics. These planes consist of two grids of tiles - a foreground (plane A) and background (plane B) - which can be moved independently, as well as a static window plane. The content of the planes is determined by nametables, which are stored in VRAM. Planes A & B can be moved around by modifying the horizontal scroll table (in VRAM) and vertical scroll table (in VSRAM).

Nametables

Size

The dimensions of the foreground and background planes are set by VDP register $10. Both planes have the same size. The following are the possible size settings:

Size Space in VRAM (for 1 plane) Code
256x256 pixels (32x32 cells) 2048 ($800) bytes move.w #$9000,($c00004).l
512x256 pixels (64x32 cells) 4096 ($1000) bytes move.w #$9001,($c00004).l
1024x256 pixels (128x32 cells) 8192 ($2000) bytes move.w #$9003,($c00004).l
256x512 pixels (32x64 cells) 4096 ($1000) bytes move.w #$9010,($c00004).l
512x512 pixels (64x64 cells) 8192 ($2000) bytes move.w #$9011,($c00004).l
256x1024 pixels (32x128 cells) 8196 ($2000) bytes move.w #$9030,($c00004).l

Dimensions of 512x1024 pixels (64x128 cells) and 1024x1024 pixels (128x128 cells) are not valid, because the space used by a plane can't exceed 8196 ($2000) bytes.

Location

Nametables for all three planes are stored in VRAM, and their location is set by VDP registers 02, 03 and 04. Nametables can't be placed anywhere in VRAM, rather they must be aligned to particular multiples.

Nametable Valid locations Code
Foreground (Plane A) 0, $2000, $4000, $6000, $8000, $A000, $C000, $E000 move.w #$8200+($xxxx>>10),($c00004).l
Background (Plane B) 0, $2000, $4000, $6000, $8000, $A000, $C000, $E000 move.w #$8400+($xxxx>>13),($c00004).l
Window (320 pixel wide mode) 0, $1000, $2000, $3000, $4000, $5000, $6000, $7000, $8000, $9000, $A000, $B000, $C000, $D000, $E000, $F000 move.w #$8300+($xxxx>>10),($c00004).l
Window (256 pixel wide mode) 0, $800, $1000, $1800, $2000, $2800, $3000, $3800, $4000, $4800, $5000, $5800, $6000, $6800, $7000, $7800, $8000, $8800, $9000, $9800, $A000, $A800, $B000, $B800, $C000, $C800, $D000, $D800, $E000, $E800, $F000, $F800 move.w #$8300+($xxxx>>10),($c00004).l

Format

A nametable consists of one word per tile, with the following format:

7
6
5
4
3
2
1
0

PR
PL
V
H
T10-T8
7
6
5
4
3
2
1
0

T7-T0
  • PR: Priority. 1 = high; 0 = low.
  • PL: Palette line.
  • V: Vertical flip. 1 = flipped; 0 = normal.
  • H: Horizontal flip. 1 = flipped; 0 = normal.
  • T10-T0: Tile index. The number of the tile in VRAM to use, or its address divided by $20.

Window