Home
CBM
  ASCII-X
  BASIC
    Disk Commands
    Enter RUN mode
    Program Format
    Secret Variables
    Variable Format
    Expressions
    Keywords
      (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
      Color
      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
    Syntax
    Tokens
  C128
  D64plus
  Disk
  Escape Codes
  Hardware
  PCxface
  PETSCII
  Pet2asc
Futurama
IBM PC-AT
Contact
Games
Glossary
Hall of fame
Hall of shame
Miscellaneous
Privacy policy
Programming
Twisty puzzles
Keyword
AbbreviationToken (hex)Version(s)Classification
COLORCO{Shift+L}E73.5Command and Statement
COLORCOL{Shift+O}E77.0Command and Statement 
ERR$E{Shift+R}E74.7Function

Syntax 
COLOR colorSource chipColor [ , chipLuminance ]
 
ParametersTypeLegal Value(s)Default ValueNote(s)
colorSourceInteger 
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 Integer1 to 16 (see table below)
chipLuminance*Integer0 to 7 see table below
* The chipLuminance is only supported by the TED chip (v3.5).  In v7.0, any value from 0 to 255 is accepted.
 
 
Purpose 
Bitmap graphics state management; primarily set the chipColor to be used when plotting bitmap pixels using a colorSource.
Some colorSources refer to a global chip color; changing them has an immediate effect (as opposed to internal state just mentioned).

 
 
Remarks 
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) 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 to changed by the COLOR command as a shown here:
colorSourceRefers toReal or MappingNote(s)
0background 
Real (text and multi-color)
Mapping (high-resolution)
 
1foreground*Mapping
2multi-color AMapping
3multi-color B Mapping  
4border Real 
text color Mapping v7.0 only; the active text editor (40 or 80 column display)
6background and border Realv7.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!
 
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.
chipColorCHR$
value
TED
Name
TED
appearance
TED
luminance
VDC
Name
VDC
appearance
VIC-II
Name
VIC-II
appearance
1144black 0black black 
25white 7white white 
328red 3red red 
4159cyan 6cyan cyan 
5156purple 4purple purple 
630green 3green green 
731blue 4blue blue 
8158yellow 7yellow yellow 
9129orange 4dark purple orange 
10149brown 2brown brown 
11150puke 5light red light red 
12151pink 6dark cyan dark gray 
13152sea green 5dark gray medium gray 
14153indigo 6light green light green 
15154grape 2light blue light blue 
16155lime 5light gray light gray 
 
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)
  
Compare With 
  
Contrast With 
  
See Also 

© H2Obsession, 2014