COLOR
This page was last modified 13:59, 17 August 2021 by Mars2000you. Based on work by NYYRIKKI and Gdx 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 <ForegroundColor>,<BackgroundColor>,<BorderColor>

Notes:

  • It's possible to 'skip' a color by using just a comma. Each parameter is optional except the last specified. Do not put a comma after this parameter.
  • COLOR without any parameter on MSX1 results to "Missing parameter"-error. On MSX2 and up it has same functionality as COLOR=NEW - see COLOR=.

Parameters

<ForegroundColor> 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.

<BackgroundColor> 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.

<BorderColor> is the color used for the borders (top, bottom, left, right) of the screen. There are no borders in screen 0, so if you use this parameter in screen 0, it seems to have not effect but il will be taken in account when going to another screen mode.

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 <ForegroundColor>
  • the background color displayed before the execution of COLOR does not change when specifying a new <BackgroundColor>, 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 <BorderColor>, 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 ,<BackgroundColor>: 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= instruction 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
COLOR 10
COLOR ,,13
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 MSX1 (*) booting in Arabic mode 15 - white 4 - dark blue 7 - sky blue
Arabic MSX1/2 booting in European mode 15 - white 4 - dark blue 4 - dark blue
Arabic Sakhr 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

(*) also Bawareth Perfect MSX2
(**) "forced" to 7 when using CALL DCOLOR

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 DCOLOR, CALL KANJI, CALL PALETTE, CLS, COLOR=, SCREEN, SET SCREEN

Compatibility

MSX-BASIC 1.0 or higher