Home > CBM > BASIC > Keywords > Color 180 Subpages: (divide), (equal), (less), (minus), (more), (multiply), (plus), (power), Abs, And, Append, Asc, Atn, Auto, Backup, Bank, Begin, Bend, Bload, Boot, Box, Bsave, Bump, Catalog, Char, Chr, Circle, Close, Clr, Cmd, Collect, Collision, Concat, Cont, Copy, Cos, Data, Dclear, Dclose, Dec, Def, Delete, Dim, Directory, Dispose, Dload, Do, Dopen, Draw, Ds, Ds string, Dsave, Dverify, El, Else, End, Envelope, Er, Err, Exit, Exp, Fast, Fetch, Filter, Fn, For, Fre, Get, Get num, Getkey, Go, Gosub, Goto, Graphic, Gshape, Header, Help, Hex, If, Input, Input num, Instr, Int, Joy, Key, Left, Len, Let, List, Load, Locate, Log, Loop, Mid, Monitor, Movspr, New, Next, Not, Off, On, Open, Or, Paint, Peek, Pen, Pi, Play, Pointer, Poke, Pos, Pot, Print, Print num, Pudef, Quit, Rclr, Rdot, Read, Record, Rem, Rename, Renumber, Restore, Resume, Return, Rgr, Right, Rlum, Rnd, Rreg, Rspcolor, Rsppos, Rsprite, Run, Rwindow, Save, Scale, Scnclr, Scratch, Sgn, Sin, Sleep, Slow, Sound, Spc, Sprcolor, Sprdef, Sprite, Sprsav, Sqr, Sshape, St, Stash, Step, Stop, Str, Swap, Sys, Tab, Tan, Tempo, Then, Ti, Ti string, To, Trap, Troff, Tron, Until, Using, Usr, Val, Verify, Vol, Wait, While, Width, Window, Xor |
Keyword | Abbreviation | Token (hex) | Version(s) | Classification |
| COLOR | CO{Shift+L} | E7 | 3.5 | Command and Statement |
| COLOR | COL{Shift+O} | E7 | 7.0 | Command and Statement |
| ERR$ | E{Shift+R} | E7 | 4.7 | Function |
COLOR colorSource , chipColor [ , chipLuminance ]
| Parameters | Type | Legal Value(s) | Default Value | Note(s) |
| colorSource | Integer | 0 to 5 (version 3.5) 0 to 6 (version 7.0) | | values 2 and 3 not used in high-resolution bitmap mode values 1 to 3 not used in text mode |
| chipColor | Integer | 1 to 16 (see table below) | | |
| chipLuminance | Integer | 0 to 7 (version 3.5) 0 to 255 (version 7.0) | see table below | not used in version 7.0 |
Graphics state management; primarily set the chipColor to be used
when plotting bitmap pixels using a colorSource.
Alternatively, set chipColor for screen's background, border or text.
Although the TED and VIC chips have over a dozen colors, they are both limited
to using only 2 colors within a color cell (similar to an MPEG macro block)
for high-resolution bitmaps or only 4 colors per cell for a multi-color bitmap
(and then one of them is a global/shared color). The main reason for this
is to decrease the amount memory required to store a bitmap; For the VIC, which has only 16 colors,
this results in a 4-to-1 or 4-to-2 "compression" (high-res or multi-color mode). For the TED,
which has over a hundred colors, this jumps to about 7-to-1 or 7-to-2.
Said another way, each pixel in the bitmap is stored primarily as a single bit (high-resolution mode)
or as pair of bits (multi-color mode). Each possible bit(pair) value may be assigned any of the colors
the chip has to offer, but with only 1 or 2 bits, not much variety is possible
(which is why the concept of color cells is used). With color cells, the bitmap pixels are clustered together
into rectangular regions (which actually correspond with the area for each character in text mode)
and each cell may have its own chipColor (and for TED chipLuminance)
assigned to each of the possible bit (pair) values. Well actually one of the 4 multi-color values
is shared over the full screen and can not be set for each color cell.
Anyway, BASIC uses the colorSource to specify which bit value (or bit-pair value)
is to be written into the bitmap for each pixel plotted by the bitmap routines.
It also looks-up the chipColor assigned to the colorSource
that is being plotted and stores that value in the color cell.
Now if you define 2 (high-resolution) or 4 (multi-color) chipColors
to the 2 (or 4) different colorSources, and you never change those assignments
while generating your bitmap image, you have a "static" color map;
or you could say all 2 (or 4) chipColors are global...
the memory of the color cells isn't even really needed in that case.
For nice looking images, you probably do want to change chipColors
that are assigned while generating a bitmap image. You just need to space your color changes apart
on the bitmap so that a color change in one cell does not affect nearby pixels.
Failure to do this will result in distotion of the bitmap image
when you plot a new chipColor assignment in a cell
that was using a previous chipColor assignment (for the same colorSource). Arrr!
Its really hard to describe with words, but once you see it happen a few times
while playing with the bitmap commands, I think you will understand!
The first parameter, the colorSource specifies what graphic element is changed
by the COLOR command as a shown here:
| colorSource | Refers to | Real or Mapping | Note(s) |
| 0 | background | Real (text and multi-color) Mapping (high-resolution) | |
| 1 | foreground* | Mapping | |
| 2 | multi-color A | Mapping | |
| 3 | multi-color B | Mapping | |
| 4 | border | Real | |
| 5 | text color | Mapping | v7.0 only; the active text editor (40 or 80 column display) |
| 6 | background and border | Real | v7.0 only; 80-column display |
* The "foreground" is the default colorSource for bitmap commands,
although ironically the VIC-II sprites consider such multi-color pixels as background!
See BUMP for details.
The chipColor specifies which of the "primary" colors that can be generated
by the video chip is assigned to the colorSource.
The TED chip has more colors than the VIC-II and these are specified
with the optional chipLuminance parameter.
If omitted, the chipLuminance defaults to 7; the table below shows the luminance values
that correspond to the text mode colors (accessible with {Control + Number} or {C= + Number} key combinations).
The table also includes the control code (CHR$ value) that may be used to change text colors with PRINT.
| chipColor | CHR$ value | TED Name | TED appearance | TED luminance | VDC Name | VDC appearance | VIC-I Name | VIC-I* appearance | VIC-II Name | VIC-II appearance |
| 1 | 144 | black | | 0 | black | | black | | black | |
| 2 | 5 | white | | 7 | white | | white | | white | |
| 3 | 28 | red | | 3 | red | | red | | red | |
| 4 | 159 | cyan | | 6 | cyan | | cyan | | cyan | |
| 5 | 156 | purple | | 4 | purple | | purple | | purple | |
| 6 | 30 | green | | 3 | green | | green | | green | |
| 7 | 31 | blue | | 4 | blue | | blue | | blue | |
| 8 | 158 | yellow | | 7 | yellow | | yellow | | yellow | |
| 9 | 129 | orange | | 4 | dark purple | | orange | | orange | |
| 10 | 149 | brown | | 2 | brown | | light orange | | brown | |
| 11 | 150 | puke | | 5 | light red | | pink | | light red | |
| 12 | 151 | pink | | 6 | dark cyan | | light cyan | | dark gray | |
| 13 | 152 | sea green | | 5 | dark gray | | light purple | | medium gray | |
| 14 | 153 | indigo | | 6 | light green | | light green | | light green | |
| 15 | 154 | grape | | 2 | light blue | | light blue | | light blue | |
| 16 | 155 | lime | | 5 | light gray | | light yellow | | light gray | |
*Only the first 8 colors are available for text and border colors on the VIC-I chip used in the VIC-20.
Any floating-point numbers will first be converted to integers (see INT).
If any value is out-of-range (see above) an ILLEGAL QUANTITY ERROR is generated.
Specifiying a string for any parameter will generate a TYPE MISMATCH ERROR.
Examples:
COLOR 0,1 : REM set background to black (bitmap or 40-column text screen)
COLOR 1,6 : REM set bitmap foreground to green (high-res or multi-color)
COLOR 2,7 : REM set multi-color A to blue
COLOR 3,3 : REM set multi-color B to red
COLOR 4,5 : REM set border to purple (magenta)
COLOR 5,2 : REM set current text color to white (v7.0 only)
COLOR 6,12 : REM set 80-column background to dark cyan (v7.0 only)
|
BASIC 2.0 of the C64 doesn't have a COLOR command. However, setting text colors is pretty easy
using PRINT CHR$(n) with an n value from the table above.
To set the background or border colors, you need to use a machine-specific POKE.
You need to POKE a value one less than shown in the table above.
For example, purple has BASIC chipColor 5; you want to POKE a value of 4.
C64 Examples:
POKE 53280, 4 :REM set border to purple
POKE 53281, 4 :REM set background to purple
|
BASIC 2.0 of the VIC-20 doesn't have a COLOR command. However, setting text colors is pretty easy
using PRINT CHR$(n) with an n value from the table above.
To set the background or border colors, you need to use a machine-specific POKE.
You need to POKE a value one less than shown in the table above.
For example, purple has BASIC chipColor 5; you want to POKE a value of 4.
Note: both the background and border colors are specified by the same POKE location,
so a rather messy command involving PEEK, AND,
and OR is need to change only one.
VIC-20 Examples:
POKE 36879, (PEEK(36879) AND 248) OR 4 :REM set border to purple
POKE 36879, (PEEK(36879) AND 15) OR 16*4 :REM set background to purple
|
CHR$, POKE, SPRCOLOR,
SPRITE
RCLR, RLUM, RSPRITE,
RSPCOLOR
BOX, CIRCLE, DRAW,
GRAPHIC, GSHAPE, PAINT,
RDOT, SCNCLR
© H2Obsession, 2014
|