This important technical book – including preface, dated back to 1985, had been
reworked and modified appropriately in order to give more detailed explanation of how
V9938 chip works and how to effectively program the system based on it.
While MSX gave up to the IBM PC standard as a computing platform in early 1990s, it
is still one of the powerful specimens in the field of 8-bit home entertainment and hobbyist
platforms. It is argued that modern PC architecture origins at the MSX standard; and it is
clear that initiative, taken by Microsoft and ASCII by institutionalizing software and
hardware compatibility was taken in further developments on the IT market.
V9938 is one of the most popular video-processors in the family of Texas Instruments
original chips, improved by a group of companies from Japan and US. Its follower, V9958,
was a VDP chip for limited release of MSX2+ and MSX Turbo-R machines, and the last VDP
in the family, V9990, can only be found in add-on cartridges.
The book is provided in PDF format and is searchable to allow internet search engines
indexing it so that potential readers would easily find it.
December, 2010
Eugeny Brychkov
Rev. 1.00 (Jan 06, 2011): Initial release
Rev. 1.01 (Jan 27, 2011): corrections per Daemos et al.
Rev. 1.01a (Mar 06, 2011): corrections per ARTRAG et al.
Rev. 1.01b (June 02, 2015): corrections per yzi and ARTRAG
Please log issues with this document to the following MSX Resource Center thread:
The V9938 introduced in this manual is a Very Large-Scale Integrated Circuit (VLSI)
that was developed as a video Display Processor (VDP) for the MSX2. The MSX personal
computer standard was introduced in 1983 by ASCII Corporation and Microsoft
Incorporated. At present, the MSX is manufactured and marketed worldwide. In order to
strengthen some of the functions of the original MSX, the MSX2 standard was developed in
1985. In addition to being software-compatible with the MSX, the MSX2 supports new
media and has video processing capabilities that are not available on conventional 8-bit
personal computers.
To make the MSX2 a reality, two requirements for the Video Processor were: upward
compatibility with the existing TMS9918A (the VDP for the MSX) software and increased
number of functions. The V9938 was developed through the joint efforts of ASCII
Corporation, Microsoft Incorporated, and YAMAHA.
The following functions are supported on the V9938:
Full bit-mapped mode
80-column text display
Access using X- and Y-coordinates for easier programming; the X-Y coordinates
are independent of the screen mode
Fundamental hardware commands to decrease the processing time and reduce
programming complexity
Digitize and external synchronization
Color palette (9 bits x 16 patterns)
Linear RGB video output
More sprites per horizontal line
Because the V9938 has the above functions, it provides superior video capabilities
that make it possible for its use in a variety of applications, including the MSX2. CAPTAIN
terminals and NAPLPS terminals using the V9938 have already been developed. We hope
that the V9938 will be a standard video processing device on a worldwide basis.
This manual was written to explain how to set parameters of the v9938 and is a
reference for developing applications and system software for it.
We are pleased that you have chosen to develop software for the V9938 and that you
have referred to this manual for assistance.
Finally, we would like to express our deep gratitude to the people at NTT as well as
other related manufacturers for their valuable opinions which contributed to the
development of the V9938.
The property of an object, which controls how object looks like on the screen. Attribute
can be a color, position of an object, or control which pixel should have specific color
B
Background
Is an
object. For example, for a character displayed on the screen the pixels of its image is said
to have foreground color, while other pixels to have background color. In case of sprites,
they may be said to appear in the foreground to the font patterns, as sprites overlap
images of the font. See also
C
Collision
Sprites are said to collide when their dots having color code 1 (simply saying – dots
identified with binary 1s in their sprite pattern generator table) overlap. In some
circumstances such behavior may be changed in favor or mixing sprite colors to have
pseudo-multi-colored sprites
Color
A property of the pixel on the screen. Color of the pixel may come from various sources:
from global color register, from pattern color table or from sprite color table. Colors can
also be coded in the palette registers through setup of red, green and blue components –
in this case, if color table of the patterns and sprites remain unchanged, actual colors,
associated with them, may be different
Command
A special sequence of VDP operations, a kind of hardware acceleration. Command is
expected to streamline CPU-VDP-VRAM operations, unload CPU and increase data transfer
speed.
E
Expansion RAM
This random access memory is used to store non-displayed data or register information,
and is not necessary for proper operation of the VDP. Maximal size or expansion RAM is
64K bytes. Due to specific purposes of this RAM, it is rarely used in applications.
object
or
property
which is perceived to be in the background to another property or
A map of patterns or sprites which identify where to display specific object or which object
should be displayed in specific position. In case of patterns (font), Pattern generator Table
identifies the appearance of font, but in order to display these patterns in specific position,
programmer should put its number into Pattern Layout Table in respective location
O
Object
Font patterns or a sprite.
P
Pattern
A property of an object identifying how object looks like. Object can be a font pattern or a
sprite pattern. Pattern may be represented by one byte or 8 bytes in different modes; its
contents codes colors of the pixels displayed. For some modes, 8 bits (one byte) can code
8 pixels – 0 for background color and 1 for foreground color, in other modes 8 bits can
code 4 pixels – with colors 0, 1, 2, and 3. To display font patterns on the screen it may not
be enough to set its
pattern
, but also put its pattern number into the
layout
map. VDP,
when displaying the picture, reads the number of pattern to display, and then refers to its
actual image to font pattern generator table
Port
Is a physical latch with specific system address for CPU reads and writes to communicate
with VDP. VDP has four ports, port #0 is a read/write data port, port #1 is write register
set-up port, port #2 is write palette port, and port #3 is write register data port
R
Register
Register is a static place within VDP for control information about VDP’s mode, screen
property etc. Registers can be Status, Video or Command. They can be accessed directly
or indirectly. Access to the registers is made through consecutive writes to specific VDP
ports
, thus in order not to break the order and thus successful completion of specific
operation, programmer should disable interrupts.
RGB
Abbreviation for base colors Red, Green and Blue. It may be used to describe hardware
wiring with three analog signals; or to describe a color composition for the pixel. Note that
when coding RGB in VDP palette registers programmer uses 3 bits for every base color,
and when coding RGB in GRAPHIC 7 mode red and green occupy 3 bits each, but blue
occupies only 2 bits
T
Tile
Same as
font pattern
V
VRAM
Video Random Access Memory is a set of memory cells used by VDP to keep information
about picture displayed on the screen. VRAM is accessed for picture displaying purposes as
well as for picture modifications. Picture displaying occurs continuously when VDP is
enabled. V9938 may have 16K to 128K VRAM, and depending on the memory organization
and size may not be able to function properly in specific modes. See description of register
R#8’s bit VR for more information
V9938 has 4 ports: port #0 – port #3; port number is selected by VDP address lines
A0 and A1. Table below also shows port address allocation for MSX compatible machine.
A1 A0 Operation Primary MSX port (Hex)
Port #0 0 0 VRAM Data (R/W) 98h
Port #1 0 1 Status Register (R)
VRAM Address (W)
Register set-up (W)
Port #2 1 0 Palette registers (W) 9Ah
Port #3 1 1 Register indirect addressing (W) 9Bh
There are two ways to set data in the MSX-VIDEO control registers (R#0 to R#46).
1.1.1. Direct access to VDP registers
Output the data and the register number in sequence to port #1. The order of reads
and writes to/from VDP ports is vitally important, thus you should keep in mind that this
order can be potentially interrupted by CPU interrupt routine which can write to or read
from VDP port(s) and thus break the proper sequence. In case of Z80 CPU, use DI
(disable interrupts) at the start and EI (enable interrupts) at the end of VDP your access
code.
Data byte is written first (bits D0-D7), and register number is written next to data
byte (bits R0-R5). If interrupt involving VDP operations will occur between these two
operations, it may cause unpredictable results.
MSB 7 6 5 4 3 2 1 0 LSB
Port #1 first byte D7 D6 D5 D4 D3 D2 D1 D0 Data
Port #1 second byte 1 0 R5 R4 R3 R2 R1 R0 Register #
1.1.2. Indirect access to registers through R#17 (Control Register Pointer)
Set the register number in R#17 using direct addressing and then send data to Port
#3. MSB of the value written to R#17 (AII) controls auto-incrementing of the register
number. If auto-incrementing is enabled, after each data read or write control register
pointer is incremented; if auto-incrementing is disabled then pointer value in R#17 remains
unchanged. Auto-increment mode is useful for bulk read or update of VDP registers.
Note: data in register R#17 can not be changed by indirect addressing.
MSB 7 6 5 4 3 2 1 0 LSB
Register #17 AII0 R5 R4 R3 R2 R1 R0 Register #
0: Auto-increment is enabled
1: Auto-increment is disabled
Port #3 first byte D7 D6 D5 D4 D3 D2 D1 D0 Data
Port #3 second byte D7 D6 D5 D4 D3 D2 D1 D0 Data
…
Port #3 nth byte D7 D6 D5 D4 D3 D2 D1 D0 Data
1.2. Accessing the Palette Registers
To set data in the MSX-VIDEO palette registers (P#0 to P#15) you must first set the
palette register number in register R#16 (Color palette address pointer) and subsequently
write two bytes of data (in specific order) into port #2. Every color consists of 3 sets of 3
bits: red, green and blue component (value 0…7).
Note: after writing pair of data to port #2 palette register number (pointer) in
register R#16 auto-increments.
MSB 7 6 5 4 3 2 1 0 LSB
Register #16 0 0 0 0 C3 C2 C1 C0 Palette #
Port #2 first byte 0 R2 R1 R0 0 B2 B1 B0 Data 1
Red data Blue data
Port #2 second byte 0 0 0 0 0 G2 G1 G0 Data 2
Green data
1.3. Accessing the status registers
To read the status registers of MSX-VIDEO (S#0 to S#9) you must first set the
register number in R#15 (Status register pointer) and then read data from port #1.
A video RAM of 128K bytes plus an expansion RAM of 64K bytes can be attached to
the VDP. Memory map is shown below.
Address
1FFFFh
↑
↑
↑
↑
0FFFFh
10000h
↑
↑
↑
↑
Video RAM
(used for display)
00000h
Expansion RAM
(for data I/O
registers)
To access memory, use the following procedure:
1. Switch respective bank (VRAM or expansion RAM)
2. Set the address counter A16 to A14
3. Set the address counter A7 to A0
4. Set the address counter A13 to A8, and specify if following data command will be
read or write
5. Read or write data to the memory
Step 1: Switching banks (VRAM to expansion RAM)
Applications are used to work with Video RAM, thus re-specification of the bank is
rarely necessary. It will be required if your application will need to access expansion RAM.
After performing necessary operations on expansion RAM, ensure that you map the Video
RAM back.
VDP can logically address 128K bytes in the address range of 00000h-1FFFFh through
16 address bits A16…A0. At this step we set up bits A16…A14 writing them into register
R#14 (VRAM access base address register).
MSB 7 6 5 4 3 2 1 0 LSB
Register #14 0 0 0 0 0 A16 A15 A14 Base reg
Step 3: Setting the address counter A7 to A0
Set the low-order eight bits A7…A0 of the address counter by writing data to port #1.
MSB 7 6 5 4 3 2 1 0 LSB
Port #1 A7 A6 A5 A4 A3 A2 A1 A0 A7…A0
Step 4: Setting the address counter A13 to A8 and operation mode
Set the remaining six bits A13…A8 of the address counter by writing data to the port
#1.
You also should specify which memory operation will follow – read or write. It is very
important, as if you specify that next operation will be a “read”, VDP will pre-fetch value
from the memory (specified by the address set up earlier) and will get ready for CPU data
read. If you will not do so and issue read command, VDP may not get enough timeslot to
read data from the VRAM and CPU may get invalid data.
If you specify that next command will be a “write”, then VDP does not do pre-fetch
and waits for write instead.
MSB 7 6 5 4 3 2 1 0 LSB
Port #1 0 W A13 A12 A11 A10 A9 A8
A13…A8
0: Next command is “Data Read”
1: Next command is “Data Write”
Step 5: Reading or writing data to memory
It is important to know that after every data read or data write operation from port
#0 address counter is being incremented. It is very useful when you need to read from or
write to the memory in sequential manner. However you should mind the timing, ensuring
that VDP has enough time to write cached data or read requested data. Please refer to the
data sheet for timings.
IE2 Enables interrupts from Light pen
IE1 Enables interrupt from horizontal retrace
M5 Screen mode flag (see Screen Modes chapter)
M4 Screen mode flag (see Screen Modes chapter)
R#1
M3 Screen mode flag (see Screen Modes chapter)
BL Blank screen: if set to 1, screen display is enabled. If set to 0, screen
display is disabled and no VRAM read operations are performed.
IE0 Enables interrupt from vertical retrace
M1 Screen mode flag (see Screen Modes chapter)
M2 Screen mode flag (see Screen Modes chapter)
SI
Sprite size:
8*8
R#8
MAG
MS
Sprite enlarging:
Mouse:
mouse. If set to 1, sets color bus into output mode and disables mouse
LP
Light pen:
TP Sets the color of code 0 to the color of the palette
CB
Color bus:
color bus into output mode
VR Selects the type and organization of VRAM. If set to 1, VRAM is 64Kx1Bit
or 64Kx4bits. If set to 0, VRAM is 16Kx1Bit or 16Kx4Bits. Affects how VDP
performs refresh on DRAM chips
SPD
Sprite disable:
are not performed.
BW Black/White: if set to 1, output is grayscale in 32 tones
when set to 1, sets the color bus into input mode and enables
sets the color bus to the input or output mode
when set to 1, sprite size is 16*16. If set to 0, sprite size is
If set to 1, sprites are enlarged (double size)
when set to 1, enables light pen
when set to 1, sets color bus into input mode. If set to 0, sets
if set to 1, sprites are not displayed and related VRAM reads
if set to 1, vertical dot count is set to 212. If set to 0, vertical dot
count is 192
S1 Selects simultaneous mode
S0 Selects simultaneous mode
IL
EO
Interlace:
if set to 1, interlace; if set to 0, non-interlace mode
Even/Odd screens:
When set to 1, displays two graphic screens
interchangeably by even/odd field; if set to 0, displays same graphic
screen by even/odd field
*NT (RGB output only) If set to 1, PAL mode (313 lines, 50Hz); if set to 0,
NTSC mode (262 lines, 60Hz)
DC
Dot clock:
If set to 1, *DLCLK is in input mode; if set to 0, *DLCKL is in
output mode
2.1.2. Table Base address registers
When displaying information on the screen, VDP uses color, pattern, sprite and other
information from video RAM. It is important to set proper starting addresses of such VRAM
locations by writing to specified table base address registers.
Note: you should ensure that unused bits are set to 0. Further in the book bit set to
“0” will mean that this bit has to be set to 0, “1” will mean that this bit has to be set to 1,
and “*” will mean that value of the bit does not matter.
Color registers are used to control MSX-VIDEO text and background screen colors,
blinking and other functions.
MSB 7 6 5 4 3 2 1 0 LSB
R#7 TC3 TC2 TC1 TC0 BD3 BD2 BD1 BD0
Text color in TEXT1 and
TEXT2 modes
Screen margin /
backdrop color
Text and screen
margin color
MSB 7 6 5 4 3 2 1 0 LSB
R#12 T23 T22 T21 T20 BC3 BC2 BC1 BC0
Color part 1 Color part 0
Text and
background
blink color
In TEXT2 mode, if attributes for blinking are set, color set in this register R#12 and in
register R#7 are displayed alternatively (blinked).
MSB 7 6 5 4 3 2 1 0 LSB
R#13 ON3 ON2ON1ON0OF3 OF2 OF1 OF0
Display time for even
page
Display time for odd
page
Blinking period
register
In the TEXT2 mode and in bit map modes of GRAPHIC4 to GRAPHIC7 two pages can
be alternatively displayed (blinked). Write to this register R#13 in order for blinking to start.
MSB 7 6 5 4 3 2 1 0 LSB
R#20 0 0 0 0 0 0 0 0
R#21 0 0 1 1 1 0 1 1
R#22 0 0 0 0 0 1 0 1
Color burst
register 1
Color burst
register 2
Color burst
register 3
The above values of color burst registers are preset on power-on. If all the bits in all
three registers are set to 0, color burst of the composite video is not performed. If values
are returned to above values, VDP will start generating normal color burst signal.
The display registers are used to control display position on the screen.
MSB 7 6 5 4 3 2 1 0 LSB
R#18 V3 V2 V1 V0 H3 H2 H1 H0
Display adjust
register
Register #18 controls horizontal and vertical alignment on the screen. Please refer to
the table below.
Value
7 … 1 0 15 … 8
H Left … … Center … … Right
V Top … … Center … .. Bottom
MSB 7 6 5 4 3 2 1 0 LSB
R#23 DO7 DO6DO5DO4DO3DO2DO1DO0
Vertical offset
register
This register R#23 sets the value of the first line to display on the screen. Virtual
screen size is 256 lines, visible vertical screen size can be 192 or 212 depending on LN bit
of register R#9. Setting R#23 to value other than 0 may display un-initialized parts of the
memory which may look as garbage. Display of virtual screen is performed in cycle,
meaning that when increasing value of R#23 top of virtual screen appears at the bottom of
visible screen. Please see pictures below.
Original screen* in
GRAPHIC1 mode
Offset screen*, horizontal
scan line is 256 dots,
GRAPHIC1 mode, top
appears at the bottom
TEXT1 mode, horizontal
scan line is 240 dots,
garbage in un-initialized
memory space
* “Auf Wiedersehen Monty” image, a property of Gremlin Graphics. Used in this book for educational purposes only
VDP generates interrupt when it starts to display respective scan line if bit 4 “IE1” of
register R#0 is set to 1. Write a value to this register R#19, and when VDP will start
displaying the specified line, it will set bit 0 “FH” of status register S#1 to 1.
2.1.5. Access registers
Access registers is the set of registers used for accessing other VDP registers or VRAM.
These registers include R#14, R#15, R#16 and R#17.
MSB 7 6 5 4 3 2 1 0 LSB
R#14 0 0 0 0 0 A16 A15 A14
VRAM access
base register
R#14 contains three senior bits of VRAM access address. In all modes, except
GRAPHIC1, GRAPHIC2, MULTICOLOR and TEXT1, if there’s a carry flag from A13 the value
in this register is automatically incremented.
MSB 7 6 5 4 3 2 1 0 LSB
R#15 0 0 0 0 S3 S2 S1 S0
Status register
pointer
R#15 points to the respective status register (S#0…S#9) to be read.
MSB 7 6 5 4 3 2 1 0 LSB
R#16 0 0 0 0 C3 C2 C1 C0
Color palette
address register
R#16 points to the respective color palette register (P#0…P#15) to be accessed.
MSB 7 6 5 4 3 2 1 0 LSB
R#17 AII 0 RS5 RS4 RS3 RS2 RS1 RS0
Control register
pointer
R#17 is a register used in indirect access to other VDP registers. It also has autoincrement flag (AII) which is used to control increment of value in this register.
The following command registers are used when executing a command on the MSXVIDEO. Details on the use of these command registers will be presented in later chapter.
Pattern size (w*h) 6 dots * 8 dots
Patterns 256 types
Screen size (w*h) 40 * 24 patterns
Pattern colors Two colors out of 512 (per screen)
VRAM area per screen 4K bytes
Controls
Pattern font VRAM pattern generator table
Screen pattern location VRAM pattern name table
Pattern color code 1 High-order four bits of R#7
Pattern color code 0 Low-order four bits of R#7
Background color code Low-order four bits of R#7
Mode flags
Bit M5 (R#0) M4 (R#0) M3 (R#0) M2 (R#1) M1 (R#1)
Value 0 0 0 0 1
MSX system default values
BASIC SCREEN number Pattern generator Pattern layout
The pattern generator table is a location in VRAM that stores patterns (font). Each
pattern has number from PN0 to PN255. The font displayed on the screen for each pattern
is constructed from 8 bytes, with 6 high-order bits displayed and 2 low-order bits not
displayed. Pattern generator table base is stored in the register R#4.
Example of pattern generator table is provided below.
The pattern layout table is a map of the screen (per screen image). Every location of
the screen contains code of the pattern displayed at respective location. This table has
40*24 (960) locations where defined patterns can be displayed. Pattern layout table base
address is stored in register R#2, and corresponds to the cell (0, 0) with address 0 in the
picture below.
Columns
0 1 2 3 39
← X
0 0 1 2 3 … … 39
1 40 41 42 43 … … 79
……… … … … … … ……… … … …
Rows
22 880 881 882 … … … 919
23 920 921 922 … … … 959
↑
Y
3.1.4. Color register settings
Color settings are located in the register R#7. Bits TC3…TC0 specify pattern color
code of the pixels identified as “1” in the bitmap values of pattern generator table, bits
BD3…BD0 specify pattern color code of the pixels identified as “0” in the bitmap values of
pattern generator table as well as screen border color.
Note: screen border color is the same as the pattern backdrop color in TEXT1 mode.
Pattern size (w*h) 6 dots * 8 dots
Patterns 256 types
Screen size (w*h) 80 * 24 patterns if LN bit of R#9 set to 0
80 * 26.5 patterns if LN bit of R#9 set to 1
Pattern colors Two colors out of 512 (per screen), four if using blinking
VRAM area per screen 8K bytes
Controls
Pattern font VRAM pattern generator table
Screen pattern location VRAM pattern name table
Pattern color code 1 High-order four bits of R#7
Pattern color code 0 Low-order four bits of R#7
Background color code Low-order four bits of R#7
Blinking pattern color
code 1
Blinking pattern color
code 0
Mode flags
Bit M5 (R#0) M4 (R#0) M3 (R#0) M2 (R#1) M1 (R#1)
Value 0 1 0 0 1
Other flags
LN bit of R#9 0: 24 lines displayed
MSX system default values
BASIC SCREEN number Pattern generator Pattern layout Pattern color table
Organization of pattern generator table is the same as in TEXT1 mode. Register R#4
defines base address of the table.
3.2.3. Pattern layout table settings
The pattern layout table is a map of the screen (per screen image). Every location of
the screen contains code of the pattern displayed at respective location. This table has
80*27 (2160) locations where defined patterns can be displayed. Pattern layout table base
address is stored in register R#2 (see below), and corresponds to the cell (0, 0) with
address 0 in the picture below. Note that if LN bit of R#9 is set to 1, then 26 lines are
displayed, plus an upper half of 27th pattern line is displayed.
MSB 7 6 5 4 3 2 1 0 LSB
R#2 0 A16 A15 A14 A13 A12 1 1
Pattern layout
table
Screen mapping of pattern layout table is provided below.
Each position on the screen has separate bit for the blinking attribute, and if this bits
is set to 1, blinking will be applied to the pattern placed in this area in the pattern layout
table. Table start address is set in registers R#3 and R#10.