| Home | Software developers | News and documentation | Emulators | New MSX |
In this part of "MSX screens" we will discuss the MSX 2+ screens. As you
might know, the screens are numbered 10, 11 and 12. These screens can
display many colors; screen 12 can go up to 19268 colors and screen 10
and 11 can go up to 12599.
The MSX 2+ screens have the same resolution as screen 8, which can
display only 256 colors at once. Despite this fact, the MSX 2+ screens
do not use more memory then screen 8. This has been achieved with a smart
trick to store the screens. Four consecutive pixels have approximately the
same color. You can only vary the brightness of those pixels. As a result,
the color information is divided over several pixels resulting in the ability
to display more colors without using more memory. To apply this coding screen,
the MSX 2+ has a new color system, called the YJK system. J and K stand
for the color components and Y stands for the brightness. We will explain the
YJK system for screen 12 and after that we will discuss screen 10 and 11.
Screen 12 and the YJK system
The YJK information for four consecutive pixels is stored as follows
in VRAM:
| b7 b6 b5 b4 b3 | b2 b1 b0 | |
| pixel 0 | Y0 | Kl |
| pixel 1 | Y1 | Kh |
| pixel 2 | Y2 | Jl |
| pixel 3 | Y3 | Jh |
Conversion from YJK to RGB
Despite the fact that the YJK system is very usefull to store colors
in compact way, it is more convenient to work with the RGB system. The RGB system
determines the brightnes of the three primary colors, being Red, Green and Blue.
These three colors are the basic colors for TV's, monitors and the human eye.
Fortunately, it is possible to convert YJK colors into RGB colors, using the
following formulas:
R = Y + J
G = Y + K
5 J K
B = - * Y - - - -
4 2 4
When applying these formulas, you must take into account that the VDP calculates with a 6-bit 2 complement integer unit. The J and K values are 6 bits signed values. To convert the values to 2 complement you can use the following BASIC routine:
IF J > 31 THEN J=J-64
IF K > 31 THEN K=K-64
Furthermore, you have to take into account that the resulting RGB components are 5 bit values. So, you must clip them to the range 0-31, which can be done as follows in BASIC:
IF R < 0 THEN R = 0 ELSE IF R > 31 THEN R = 31
IF G < 0 THEN G = 0 ELSE IF G > 31 THEN G = 31
IF B < 0 THEN B = 0 ELSE IF B > 31 THEN B = 31
Using this information, you can write a program to convert screen 12 pictures
into screen 8 pictures. Such a program is enclosed in the LZH file. The listing
is called LIST1.BAS.
The program works with groups of 4 pixels. For every such a group, the
J and K components will be calculated. After that, the Y component and the
RGB values are calculated per pixel.
Conversion from RGB to YJK
You can also do the opposite conversion. That is, from RGB format to YJK format.
You have to use the following formulas:
B R G
Y = - + - + -
2 4 8
J = R - Y
K = G - Y
Again, the results must be clipped to the proper range. The Y component must be
clipped to 0-31 and the J and K components must be clipped to -32 to 31.
When calculating the YJK values there is a second problem; the J and K component
must be calculated per 4 pixels, while red, green and blue can be different per pixel.
To solve this problem, you must calculate the average values for red, green and blue
per 4 pixels. These avarages can be used to calculate the J and K components. After that,
the Y can be calculated per pixel.
Using this information, you can write a program to convert screen 8 pictures into screen 12 pictures. Such a program is enclosed in the LZH file. The listing is called LIST2.BAS.
Screen 10 and 11
Although you can display very nice pictures on screen 12, the screen also
has a very big disadvantage; because of the color encoding used, you can not
have sharp color changes within a group of four pixels. For example, you can
not draw a red line on a blue background like you can in any other graphical
screen. The designers of the MSX 2+ VDP have recognized this problem and they
have found a solution for it. The solution is called screen 10 and 11. These
screens, which are actually two different names for the same screen mode, are a
mixture of screen 12 with the YJK system and screen 5 with the 16-color entries
palet system. This screen mode uses one bit less for the Y component. In stead of
a 5 bit Y component, there is a 4 bit Y component. The fifth bit is turned into a
so-called attribute bit:
When the bit is equal to zero, the pixel must be displayed using the YJK
system. Otherwise, the color palet system must be used. In the latter case, the
4 bit Y component is actually the color number. Just like on screen 5, which also
uses a 4 bit color number. The following table shows the layout of four consecutive
pixels:
| b7 b6 b5 b4 | b3 | b2 b1 b0 | |
| pixel 0 | Y0/C0 | A0 | Kl |
| pixel 1 | Y1/C1 | A1 | Kh |
| pixel 2 | Y2/C2 | A2 | Jl |
| pixel 3 | Y3/C3 | A3 | Jh |
LINE (0,0)-(255,211),&B11110111,BF,AND
The above function uses the logical AND function to reset the attribute of all pixels.
Once a picture has been converted to screen 10/11, you can draw on it with the normal BASIC commands.
The difference between screen 10 and 11
Although screen 10 and 11 have the same layout, the BASIC interpreter
makes a distiction between the two screens. This is done as a convenience
to the BASIC programmer. In screen 11, you can modify all bits of a pixel. You
can use the values 0 to 255 for the color number. The conversion from screen 12
to screen 10/11 can for example be done in screen 11. Though, drawing a
a nice graph using the palette in screen 11 is a real nightmare. You must ensure
that you only modify the upper four bits of any pixel. For example, to draw a
blue line (color 4) from coordinate (10,10) to (245, 202), you can use the following
commands:
LINE (10,10)-(245,202),7,,AND :' reset Color/Y
LINE (10,10)-(245,202),4*16+8,,OR:' teken lijn in color 4
Drawing graphs using the palette can be achieved much easier in screen 10. In screen 10 you can work as if you are in screen 5. For example, to draw the very same line as in the example above, you can use the following command:
LINE (10,10)-(245,202),4
All BASIC commands on screen 10 have this same behaviour. For example also
complex commands like CIRCLE.
So, to wrap it all up, you can use screen 11 when you want to change all parts
of a pixel, including the J and K components, while you can use screen 10
when you want to draw a graph on top of a picture using the color palette.
You can switch between screen 10, 11 and 12 without that BASIC erases
the entire screen at every screen switch!
Select MSX 2+ screens in assembly
Despite the fact that MSX BASIC can switch directly to the MSX 2+ screens, you can't
use the BIOS for this. The BIOS only goes up to screen 8! If you want to select
screen 10, 11 or 12, you must select screen 8 using the BIOS and switch the VDP to the
YJK system by writing the appropriate value to the MSX 2+ VDP registers. The 2+ screens
can be selected using 2 bits of register 25:
Sprites on the MSX 2+ screens
Sprites function the same on screen 10, 11 and 12 as on screen 5 and 7. That is,
you can use 2 colors per sprite line and the sprite colors are taken from the
modifiable color palette. This in contradiction to screen 8, which uses a fixed
color palette for the sprites which is burned into the VDP.
Normally, the sprite tables can be found at the following memory positions:
| Table name | Normal address | Length |
| Sprite$ table | #F000-#F7FF | 2048 B |
| Sprite color table | #F800-#F9FF | 512 B |
| Sprite info table | #FA00-#FA7F | 128 B |
The missing link: screen 9
Between the highest MSX 2 screen (screen 8) and the lowest MSX 2+ screen (screen 10),
one screen is missing: screen 9. There have been many rumours about what happened
to screen 9. One of the most funny stories was that Konami bought it for their games.
Unfortunately(?) this is not the case. Screen 9 is used in Korea as a screen for
the Korean character set. It most probably is one of the normal graphical MSX 2 screens,
addressed as if it is a text screen. You can compare this to the kanji screens of the
MSX 2+ models and the MSX turbo R.
With thanks to Bernard Lamers for the information about screen 9.
In the mean time, Ricardo Bittencourt from Brazil, the author of brmsx, has written more information about screen 9 to the international MSX mailing list. Screen 9 is indeed used on a Korean MSX model, to implement the hangul character set. This machine uses the V9948 VDP, from which Ademir Carchano has the complete databook.
Note: this also explains the gap between the V9938, used for MSX 2, and the V9958, used for MSX 2+. And it explains why the version number in the V9958 is 00010b in stead of 0001b.