# HG changeset patch # User Michael Pavone # Date 1484900535 28800 # Node ID 7dd44f2eee205fa1dea3bd52f6415902fa3ab3a7 Initial commit diff -r 000000000000 -r 7dd44f2eee20 sega_vdp.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sega_vdp.html Fri Jan 20 00:22:15 2017 -0800 @@ -0,0 +1,896 @@ + + + + Sega Home System VDP Reference + + + +

Sega Home Console VDP Documentation

+

Overview

+

+ This document describes the operation of the family of related video display + processors used by Sega's 8 and 16-bit home game consoles. +

Video Modes

+ +

Mode 0 - Graphics I

+

Availabiltiy

+

+ This mode is available on the Mark III, Master System, Game Gear in addition to + systems that use the TMS9918 and derivatives including early systems from Sega + (the SG-1000 and SC-3000) as well as MSX computers and the Collecovision game + console. +

+ +

Mode 1 - Text

+

Availabiltiy

+

+ This mode is available on the Mark III, Master System, Game Gear in addition to + systems that use the TMS9918 and derivatives including early systems from Sega + (the SG-1000 and SC-3000) as well as MSX computers and the Collecovision game + console. +

+ +

Mode 2 - Graphics II

+

Availabiltiy

+

+ This mode is available on the Mark III, Master System, Game Gear in addition to + systems that use the TMS9918A and derivatives including early systems from Sega + (the SG-1000 and SC-3000) as well as MSX computers, the Collecovision game + console and TI-99/4A. It is not available on systems with the original TMS9918 + like the TI-99/4. +

+ +

Mode 3 - Multicolor

+

Availabiltiy

+

+ This mode is available on the Mark III, Master System, Game Gear in addition to + systems that use the TMS9918 and derivatives including early systems from Sega + (the SG-1000 and SC-3000) as well as MSX computers and the Collecovision game + console. +

+ +

Mode 4 (primary SMS mode)

+

Availabiltiy

+

+ Mode 4 is available on the Mark III, Master System, Game Gear and Genesis/Megadrive. +

+

Capabilities

+

+ TODO: Fill me in +

+

Selection and Resolution Control

+

+ Mode 4 is enabled by setting bit 2 in $00 - Mode Set Register 1. + On the Mark III and SMS 1, only one resolution is available 256x192. The Game Gear + uses this same resolution, but crops the visible display area to 160x144. +

+

Mode 5 (primary Genesis/Megadrive mode)

+

Availability

+

+ Mode 5 is available only on the Genesis/Megadrive and systems derived from Genesis + hardware like the System C, Mega Tech and Mega Play arcade boards. +

+

Capabilities

+

+ Mode 5 is the primary mode used by software on the Genesis/Megadrive. It provides 2 + independently scrollable background planes and 64 or 80 sprites dependign on the + horizontal resolution. Background planes can be up to 128x64 or 64x128 tiles. One of + the background planes (Plane A) can be replaced with the special Window plane for a + portion of the screen. Sprites can range from 1 to 4 tiles in size both vertically + and horizontally. Up to 16 or 20 sprites can be displayed and up to 256 or 320 sprite + pixels can be drawn per line, again depending on the horizontal resolution selected. +

+

+ Tiles in this mode are 8 by 8 pixels in size with a depth of 4 bits per pixel arranged + in a chunky configuration. This results in a size of 32 bytes with the first byte + containing the two left most pixels of the first row and the last byte containing the + two right most pixels of the last row. Each 4 bit value is used as an index into one + of 4 16-color palettes. +

+

Selection and Resolution Control

+

+ Mode 5 is enabled by setting bit 2 in $01 - Mode Set Register 2. Note + that this bit must be set before any Mode 5 specific registers can be set. Horizontal + resolution and interlace control are both set in $0C - Mode Set Register 4. + When both bit 0 and 7 of that register are set to zero, a 32-column (256 pixel) wide display + is selected. When both are set to one, a 40-column (320 pixel) wide display is selected. Any + other combination of those two bits will result in a display mode with invalid timing and + should not be used. +

+

+ Vertical resolution is controlled by a combination of the interlace control bits (bits 1 + and 2 of Register $0C) and bit 3 of $01 - Mode Set + Register 2, which enables a 30 row (240 pixel) tall display when set. It's worth noting + that this bit does not change the number of actual lines sent to the display, but only how + many lines contain image data. Additional visible lines are filled with the border color. +

Undocumented TMS9918A Modes

+ +

Sprites

+

TMS9918A Modes

+

Mode 4

+

Mode 5

+

Registers

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NumberFunction
$00Mode Set 1
$01Mode Set 2
$02Name Table Address/Scroll A Table Address
$03Color Table Address/Window Table Address
$04Pattern Generator Address/Scroll B Table Address
+

Register 0 - Mode Set 1

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BitTMS9918ASMSGame GearGenesis Mode 4Genesis Mode 5
7NoneVScroll LockNone
6NoneHScroll LockHScroll Lock[1]HScroll LockNone
5NoneCol 0 MaskNoneCol 0 MaskNone
4NoneHInt Enable
3NoneSprite Left Shift 8px1=Invalid?
2NoneMode 4 EnablePalette Select[2]
1M2[3]???HVC Latch Enable
0External Sync
+

[1] Only in SMS mode, this bit does nothing in Game Gear mode

+

[2] Normally set to 1. Only LSB of each color component in CRAM is used when 0.

+

[3] Middle bit of TMS9918 mode number when Mode 4 is disabled. Enables screen height control in Mode 4 on the SMS 2 and Game Gear.

+

Register 1 - Mode Set 2

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BitTMS9918ASMSGame GearGenesis Mode 4Genesis Mode 5
716KB VRAM ModeNone128KB VRAM Mode
6Display Enable
5VInt Enable
4M1[1]NoneDMA Enable[2]
3M3[3]???240 Line Select[4]
2None0 - Mode 5 select1 - Mode 5 select
1Sprite Size Select[5]None
0Sprite Zoom EnableNoneWeird Stuff[6]
+

[1] LSB of TMS9918A Mode, selects 224 line display in Mode 4 on SMS2 and GG if M2 is set

+

[2] Doesn't actually enable DMA, but instead enables changing CD5 which is used to trigger a DMA operation

+

[3] MSB of TMS9918A Mode, selects 240 line display in Mode 4 on SMS2 and GG if M2 is set. Not valid in combination with M1 in Mode 4. 240 line display only valid in PAL regions.

+

[4] Not valid in NTSC regions. Will result in a 255 line display with no vsync and no vertical interrupt.

+

[5] 1 selects 16x16 in TMS9918A modes and 8x16 in Mode 4. 0 Selects 8x8 in both.

+

[6] According to Charles MacDonald, setting this bit in mode 5 causes the hscroll value to modify when HSync happens

+

Register 2 - Name Table Address/Scroll A Table Address

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BitsTMS9918ASMSGame GearGenesis Mode 4Genesis Mode 5
7None
6NoneBit 16 of Table A[1]
5-4NoneBit 15-14 of Table A
3Bit 13 of table addressBit 13 of table A
2Bit 12 of table addressNone
1Bit 11 of table addressBit 11 of table address[2]Bit 11 of table addressNone
0Bit 10 of table addressBit 10 of table address[3][4]Bit 10 of table address[3]NoneNone
+

[1] Only used when in 128KB VRAM mode. No function otherwise. +

[2] On the SMS2 and Game Gear these bits have no function in 224 and 240 line modes

+

[3] Only valid in TMS9918A modes.

+

[4] On the SMS 1, this bit is anded with the MSB of the row number in name table fecthes in Mode 4. This bug was exploited by Y's and it will not render correctly on later systems as a result.

+

Register 3 - Color Table Address/Window Table Address

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BitsTMS9918ASMSGame GearGenesis Mode 4Genesis Mode 5
7Color Table bit 13 [1]None
6Color Table bit 12 [1]NoneWindow Table Bit 16 [2]
5-2Color Table Bit 11-8 [1]NoneWindow Table Bit 15-12
1Color Table Bit 7 [1]NoneWindow Table Bit 11 [3]
1Color Table Bit 6 [1]None
+

[1] Color Table only used in some TMS9918A modes and not at all in Mode 4. Should be set to all ones on the SMS in Mode 4 to avoid issues with unintended masking.

+

[2] Only used in 128KB VRAM mode

+

[3] Only used in H32 mode

+

Register 4 - Pattern Generator Address/Scroll B Table Address

+ + + + + + + + + + + + + + + + + + + + + + + +
BitsTMS9918ASMSGame GearGenesis Mode 4Genesis Mode 5
7-4None
3NoneScroll B Bit 16 [1] +
2-0Pattern Generator Bits 13-11 [2]NoneScroll B Bit 15-13
+

[1] Only used in 128KB VRAM mode

+

[2] Only used in TMS9918A modes. Should be set to 1 on SMS 1 in Mode 4 to avoid unintended masking.

+

Register 5 - Sprite Attribute Table Address

+ + + + + + + + + + + + + + + + + + + + + + + + + +
BitsTMS9918ASMSGame GearGenesis Mode 4Genesis Mode 5
7NoneSAT Bit 16 [1]
6-1SAT Bits 13-8SAT Bit 15-10
0SAT Bit 7 [2]NoneSAT Bit 9 [3]
+

[1] Only used in 128KB VRAM mode

+

[2] Only valid in TMS9918A modes. Will cause X/Pattern loads to take place from bottom half of table when cleared on SMS 1 in Mode 4.

+

[3] Only used in H32 mode

+

Register 6 - Sprite Tile Base

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BitsTMS9918ASMSGame GearGenesis Mode 4Genesis Mode 5
7-6None
5NoneTile Address Bit 16 [1]
4-3None
2Tile Address Bit 13None
1-0Tile Address Bit 12-11 [2]None
+

[1] Only used in 128KB VRAM mode

+

[2] Only valid in TMS9918A modes. Will cause masking of relevant bits of tile addresses if cleared on the SMS 1 in Mode 4.

+

Register 7 - Text/Background Color

+ + + + + + + + + + + + + + + + + + + + + + + + +
BitsTMS9918ASMSGame GearGenesis Mode 4Genesis Mode 5
7-6Text Color Bit 3-2 [1]None
5-4Text Color Bit 1-0 [1]NoneBackground Color Palette Index
3-0Background Color [2]
+

[1] Only used in TMS9918A modes.

+

[2] An index into a fixed palette in TMS9918A modes, the sprite palette in Mode 4 and the selected palette in Mode 5

+

Register 8 - Background X Scroll (Mode 4 only)

+ + + + + + + + + + + + + +
BitsSMSGame GearGenesis Mode 4Genesis Mode 5
7-0X Scroll ValueNone
+

Register 9 - Background Y Scroll (Mode 4 only)

+ + + + + + + + + + + + + +
BitsSMSGame GearGenesis Mode 4Genesis Mode 5
7-0Y Scroll ValueNone
+

Register A - Horizotal Interrupt Counter (Mode 4 & 5 only)

+ + + + + + + + + + + + +
BitsSMSGame GearGenesis Mode 4Genesis Mode 5
7-0Number of lines before HInt fires
+

Register B - Mode Set 3 (Mode 5 only)

+ + + + + + + + + + + + + + + + + + + + + + + + + +
BitsFunction
7-4None
3External Interrupt Enable
22 Column Vertical Scroll Enable
1Horizontal Scroll Table Bits 9-5 Enable
0Horizontal Scroll Table Bits 4-2 Enable
+

Register C - Mode Set 4 (Mode 5 only)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BitsFunction
7RS0 - H40 Enable [1]
6VSY - Replace VSync Output with Pixel Clock
5HSY - Something involving HSync apparently
4SPR - External Pixel Bus Enable
3SHI - Shadow/Highlight Mode Enable
2LSM1 - Double Resolution Enable [2]
1LSM0 - Interlace Enable
0RS1 - External Clock Enable [1]
+

+ [1] RS0 enables a 320 pixel wide display and changes the internal clock source to MCLK/4. + RS1 switches to the external clock source which is mostly MCLK/4, but switches to MCLK/5 for parts of HSync to get the line duration to match the H32 duration. + Normally RS0 and RS1 should be set to the same value as other combinations result in timings that are further out of spec than normal, but with a flexible enough display other combinations are possible. + The full list of modes are as follows on an NTSC system: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RS1RS0WidthHorizontal RateVertical Rate
0025615.7 kHz59.92 Hz
0132015.98 kHz60.99 Hz
1025619.62 kHz74.90 Hz
1132015.7 kHz59.92 Hz
+

On a PAL system, they are as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RS1RS0WidthHorizontal RateVertical Rate
0025615.56 kHz49.86 Hz
0132015.83 kHz50.75 Hz
1025619.45 kHz62.33 Hz
1132015.56 kHz49.86 Hz
+

[2] Should only be set along with LSM0. Unclear what happens if set by itself.

+

Register D - Horizontal Scroll Table Address (Mode 5 only)

+ + + + + + + + + + + + + + + + + +
BitsFunction
7None
6Table Address Bit 16 [1]
5-0Table Address Bit 15-10
+

[1] Only used in 128KB VRAM Mode

+

Regsiter E - Background Tile Base Address (Mode 5 only)

+ + + + + + + + + + + + + + + + + + + + + +
BitsFunction
7-5None
4Scroll B Tile Address Bit 16 [1]
3-1None
0Scroll A Tile Address Bit 16 [1]
+

[1] Only used in 128KB VRAM Mode

+

Register F - Auto Increment (Mode 5 only)

+ + + + + + + + + +
BitsFunction
7-0Value added to address register after each operation
+

VRAM Interface

+ +

Genesis Mode 5 Address Bit Mapping - 64KB Mode

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DRAM Bit (R=row,C=col)Logical Bit
R7A9
R6A8
R5A7
R4A6
R3A5
R2A4
R1A3
R0A2
C7A15
C6A14
C5A13
C4A12
C3A11
C2A10
C1A1
C0A0
+ + +

Genesis Mode 4 Address Bit Mapping

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DRAM Bit (R=row,C=col)Logical Bit
R7A8
R6A7
R5A6
R4A5
R3A4
R2A3
R1A2
R0A1
C70
C60
C5A13
C4A12
C3A11
C2A10
C1A9
C0A0
+ + \ No newline at end of file