COLOR
This page was last modified 08:35, 7 December 2016 by Gdx. Based on work by Mars2000you and NYYRIKKI and others.

Contents

Effect

Changes the color(s) to be used for the foreground, background and border.

Notes:
- If you use COLOR after SCREEN, you need to use CLS after COLOR on a graphic screen to initialize it with the new colors
- For screens 0 to 5, 7, 9 and 10, it's useful to use COLOR before switching to the desired screen with SCREEN
- For the Kanji text modes, it's useful to use COLOR before switching to the desired screen with CALL KANJI
- For screen 6, using of the border colors 16 to 31 is only possible after the SCREEN 6 instruction
- For screens 8, 11 and 12, COLOR must be used after SCREEN when you want to use colors higher than 15
- When all parameters are omitted on MSX2 or higher, the effect will be the same as COLOR=NEW, except in Kanji text mode. The color palette will be initialized.

Syntax

COLOR [<foreground color>],[<background color>][,<border color>]

Note: Do not put a comma if no parameters are behind.

Parameters

<foreground color> is the color used for the text or the drawing in graphic modes. This parameter can be omitted on MSX1 only if another parameter is placed behind it.

<background color> is the color used for the background. By default in text screen modes, background of all screen changes. In graphic modes, the parameter seems to have not effect but it will be taken in account when returning to another screen mode.

<border color> is the color used for the borders (top, bottom, left, right) of the screen.

Remarks about using of COLOR when you are in a Kanji text mode:

  • the text displayed before the execution of COLOR does not switch to the new color specified as <foreground color>
  • the background color displayed before the execution of COLOR does not change when specifying a new <background color>, only the background of the new texts are changed, but the new color is also applied to he border color and the keylist (check it by pressing SHIFT!). Besides, the cursor will be displayed in another color, different from the foreground color, and that will vary depending on the general background color.
  • if you specify a new <border color>, it seems to have not effect but the new color will be taken in account when returning to another screen mode.
  • To change the general background color, you need to enter COLOR,<background color>: CALL CLS

Value of each color can vary and depends from the mode set with SCREEN or CALL KANJI/CALL ANK.

SCREEN COLOR
0-5 0 - 15
6 (*) 0 - 31
7 0 - 15
8 0 - 255
9-10 0 - 15
11-12 0 - 255
KANJI0-3 0 - 15

(*) See below for the specific working of COLOR in this screen

The palette of colors 0 to 15 can be altered with the COLOR= command in all screen modes except screens 8, 11 and 12. To alter MSX color palette in KANJI text modes, you need to use CALL PALETTE.

Examples

COLOR 1, 13, 5
10 SCREEN 8: COLOR 100,150,200
20 GOTO 20

Specific working of COLOR in SCREEN 6

SCREEN 6 uses only 4 colors (0-3). The default MSX palette for these colors is used if other palette is not defined. (See COLOR= command). In case color number 0-15 is used, only bits 0 and 1 of VDP Control Register 7 will have effect.

Border color in SCREEN 6 has colors defined for odd and even pixels independently. This color encoding method is generated in order to implement high resolution sprites. When using COLOR command in SCREEN 6 BASIC expects that you want to define both colors at a same time and uses bits 0 and 1 for color number.

This can be prevented by setting bit 4 of VDP Control Register 7 to 1 (using color values 16-31). In this case bits 0 and 1 will set color for odd pixels and bits 2 and 3 will set color for even pixels. Note also that bit 4 status is not stored and when screen mode changes the border color is not converted, but native 4bit border color representation is always used as is.

Default values

SCREEN 0 to 5 and 7

Machines Foreground Background Border
Arabic MSX booting in Arabic mode 15 - white 4 - dark blue 7 - sky blue
Arabic MSX booting in European mode 15 - white 4 - dark blue 4 - dark blue
Arabic MSX2 15 - white 4 - dark blue 4 - dark blue
Brazilian Ciel MSX2+ 15 - white 4 - dark blue 7 - sky blue
Brazilian Gradiente MSX 15 - white 1 - black 1 - black
Brazilian Sharp MSX 15 - white 4 - dark blue 4 - dark blue
Daewoo CPC-300/300E MSX2 15 - white 4 - dark blue 7 - sky blue
Daewoo CPC-400/400S MSX2 15 - white 4 - dark blue 4 - dark blue
European and Russian MSX/MSX2 15 - white 4 - dark blue 4 - dark blue
Frael Bruc MSX 1 - black 13 - magenta 13 - magenta
Japanese MSX/MSX2/MSX2+/MSXturboR 15 - white 4 - dark blue 7 - sky blue
Korean MSX computers and MSX2 consoles 15 - white 4 - dark blue 7 - sky blue
Korean MSX consoles 15 - white 1 - black 1 - black


KANJI text modes

When using the command CALL KANJI, the foreground and background colors of previously used mode (especially SCREEN 0, SCREEN 1 and SCREEN 9) are directly transferred to the KANJI text mode and the background color is also used for the border.

How to change the default values

On MSX2 and higher machines, you can change these default values by using first COLOR, then SET SCREEN to save the new parameters in the Real Time Clock (RTC). It is not possible to change the default values for the Japanese KANJI text modes.

If you use SET SCREEN when you are on SCREEN 9, the computer will display the MSX-BASIC screen after booting in SCREEN 9 instead of SCREEN 0 or 1; the parameters of the other screens, especially SCREEN 0 and SCREEN 1, will also be modified.

Related to

CALL CLS, CALL KANJI, CALL PALETTE, CLS, COLOR=, SCREEN, SET SCREEN

Compatibility

MSX-BASIC 1.0 or higher