FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DRAWING

Handle system color table


Well; if... the system color table would stay the same from 7.0 until the end of time, here's something you can rely on:

The system color table uses a 6x6x6 color system which generates 216 standard colors(yep, 6x6=36x6=216), and then there's 40 colors left over, which are always the same(as far as I know).

Here's that faster SetCPixel that was posted last month. I've modified it to show you all the colors of the System Rainbow...


DIM gBaseAddr&, gRowBytes%, gHOffset, gVOffset
DIM gScrnBot, gScrnRight, gScrnLineAddr&(1024)
DIM gActualDepth
DIM myRGB.6
END GLOBALS

LOCAL FN MicroSeconds&
  ` dc.w $A193
END FN

' call this before drawing esp if window may have moved
LOCAL FN GetWindowParameters
  DIM aPoint.4
  gActualDepth=SYSTEM(_crntDepth)
  aPoint.h=0: aPoint.v=0
  CALL LOCALTOGLOBAL(aPoint)
  gHOffset=aPoint.h
  gVOffset=aPoint.v
END FN

LOCAL FN GetScreenParameters
  DIM pmHand&,addr&,j
  gScrnBot={REGISTER(a5)+_screenBits+10}
  gScrnRight={REGISTER(a5)+_screenBits+12}
  pmHand&=[[FN GETMAINDEVICE]+22]
  gBaseAddr&=[[pmHand&]]
  gRowBytes%={[pmHand&]+4} AND &1FFF
  addr&=gBaseAddr&
  FOR j=0 TO gScrnBot
    gScrnLineAddr&(j)=addr&
    addr&=addr&+gRowBytes%
 NEXT j
END FN

LOCAL FN SetCPixel (x,y,pixelByte)
  x= x + gHOffset
  y =y + gVOffset
  LONG IF x>=0
    LONG IF x<= gScrnRight
      IF y<=gScrnBot THEN POKE gScrnLineAddr&(y)+x,pixelByte
    END IF
  END IF
END FN

DIM L, micrs&,j
WINDOW 1

FN GetScreenParameters
FN GetWindowParameters

L=150

LONG IF gActualDepth=8
  micrs&=FN MicroSeconds&
  FOR cc=0 TO 255
    FOR j=1 TO L
      FN SetCPixel (cc,j,cc)
    NEXT j
  NEXT cc
  micrs&=FN MicroSeconds&-micrs&
  PRINT@(0,2)"FN SetCPixel" micrs&"<mu>s"
END IF

DO
UNTIL FN BUTTON

You may expect a ROY G BIV output, but you won't because this is how the palette is set up. Here's how the colors go (I believe, but possibly they may be reversed):
red green blue
0000 0000 0000
0000 0000 3333
0000 0000 6666
0000 0000 9999
0000 0000 CCCC
0000 0000 FFFF
0000 3333 0000
0000 3333 3333
etc,
9999 FFFF 3333
etc, etc, etc...
This covers the first 216. Again, I may be incrementing the blue when I should be incrementing the green or red. But I hope you see the point.

I just recalled I do have a DOS QBASIC program that does color matching. I was using it so I could localize palettes from different images, but you do lose something if you try to re-construct an image from this rounded data. (The next step would have been dithering, I guess.) At least that's what I've learned.
If I find it I'll send it to ya'.

Terence Jordan