VDP Color Palette Registers
This page was last modified 00:34, 17 June 2017 by NYYRIKKI. Based on work by Mars2000you and Gdx.

The MSX2/2+ VDP has 16 Color Palette Registers (0-15) that can be modified in all screen modes (has no visual effect in SCREEN 8)

Contents

Default palette for SCREEN 0 to 7, 9, 10 and KANJI screens

Every color consists of the combination of three components: red, green and blue component (value 0 to 7).

Color R G B Color R G B Color R G B Color R G B
0 (*) 0 0 0 4 1 1 7 8 7 1 1 12 1 4 1
1 0 0 0 5 2 3 7 9 7 3 3 13 6 2 5
2 1 6 1 6 5 1 1 10 6 6 1 14 5 5 5
3 3 7 3 7 2 6 7 11 6 6 4 15 7 7 7


(*) color 0 is a transparent color, it means that border space is seen transparently - to handle it as a 'normal' color, you need to use VDP(9)=VDP(9) OR &H20 (back to transparent feature with VDP(9)=VDP(9) AND &HDF)

Storage of palette in VRAM

When MSX-BIOS is used, it stores copy of palette registers (32 bytes) in VRAM, but the start address is different for each screen mode. Here is list of addresses for each mode:

SCREEN Decimal Hexadecimal
0, WIDTH 40 1024 0400
0, WIDTH 80 3840 0F00
1 8224 2020
2 7040 1B80
3 8224 2020
4 7040 1B80
5-6 30336 7680
7-8 64128 FA80
9 30336 7680
10-12 64128 FA80


For the KANJI screens, it depends from the Bitmap screen used by these text modes (for more info, see CALL KANJI):

Used graphic SCREEN Decimal Hexadecimal
5 30336 7680
7 64128 FA80


How to modify a VDP Color Palette Register

1 - Set the number of the color palette register in bits 3 to 0 of VDP Control Register 16
2 - Write 2 bytes of data in specific order into VDP port #2 (9A in hexadecimal)

First Byte Second Byte
Bit Code Meaning Values Code Meaning Values
7 Always value 0 Always value 0
6 to 4 R2 to R0 Red Data Always value 0
3 Always value 0 Always value 0
2 to 0 B2 to B0 Blue Data G2 to G0 Green Data


3 - After writing pair of data to VDP port #2 the pointer in Control Register 16 auto-increments and you can write data for the next color palette register

In MSX-BASIC

  • For all concerned screens, you can combine the VDP() instruction with value 17 and the OUT instruction.
  • For screens 0 to 7, 9 and 10, you can use the COLOR= instruction.
  • For the KANJI screen modes (and SCREEN 9 in version 4 of Hangul BASIC), you can use the CALL PALETTE instruction.

Example to modify color 7 with the following RGB values: R=4, G=3, B=5. Binary value of R is 100, of G is 011 and of B is 101, first binary value for OUT is 01000101 = 69, second binary value for OUT is 00000011 = 3.

VDP(17)=7: OUT &H9A,69: OUT &H9A,3
COLOR=(7,4,3,5)
_PALETTE (7,4,3,5)