[Coco] colors
Bill Pierce
ooogalapasooo at aol.com
Wed Apr 2 00:34:12 EDT 2014
Wayne, first, Vcc is known to have an incomplete GIME emulation. Joseph was working on it when he disappeared from the Coco community. But it doesn't apply to the colors. Just odd graphics modes. So I'm not suprised you see some errors when doing low level graphics. I've never seen anything myself but have definately crashed the whole system with intense graphics. What do you expect for free :-)
I think you are confusing the way OS9 handles colors and palettes.
I don't remember the Basic09 commands for changing the colors, but I'm sure they use the same syscalls as "C". In C, with cgfx7.lib, you:
BColor(path,color) - set the background color
FColor(path,color) - set the foreground color
If I remember right, Basic09 uses RUN GFX2("Color",x,x)
Now, say you assigned RED=4, now set FColor(STDOUT,RED) or RUN GFX2("Color",RED). It would seem you setting the foreground palette to RED. But that's not the case. You are actually setting the FORGROUND value in OS9 foreground slot to the palette number you defined as RED. You are not changing the color number in the palette, but changing the palette number in OS9's FOREGROUND slot.
To actually change the foreground palette color, don't set the foreground value, instead change palette 10 to the color number in your chart using RUN GFX2("Palette",10,colorx). It should change properly every time. A good rule of thumb is compare the actual "default screen color" and determine what palette is being used from that. If the fore is black and the back is green, the GFX2("Palette",10,x) is fore, GFX2("Palette",2,x) is back. If fore is red and back is magenta, then GFX2("Palette",12,x) is fore and GFX2("Palette",6,x) is back.
This would mean if you use Color(x,x), you are rearranging the palettes so no, the fore 8 and back 8 no longer apply because you just rearranged the palettes, but if you set Pal(STDOUT,x) then the back 8 will always be fore and the front 8 will always be back.... Kind of backwards, but that's how it is (default).
Color - Sets the Palette number in OS9 foreground & background color slots.
Palette - Sets the 64 colors in the 16 palettes
(The following values are for RGB and I think OS9 uses a color conversion table for composite so that should be the same)
NitrOS9's default palettes slots are: (these are not the palettes, but where the palette choices are stored)
Foreground - Pal 10 - Black (default)
Background - Pal 2 - Green (default)
Border - Pal 2 - Green (default)
(there are other values but I never investigated further)
NitrOS9's Default palette/colors are defined as:
Pal-0 = $3F (63) - White
Pal-1 = $09 (09) - Blue
Pal-2 = $00 (00) - Black
Pal-3 = $12 (18) - Green
Pal-4 = $24 (36) - Red
Pal-5 = $36 (54) - Yellow
Pal-6 = $2D (45) - Magenta
Pal-7 = $1B (27) - Cyan
Pal-8 = $3F (63) - White
Pal-9 = $09 (09) - Blue
Pal-A = $00 (00) - Black
Pal-B = $12 (18) - Green
Pal-C = $24 (36) - Red
Pal-D = $36 (64) - Yellow
Pal-E = $2D (45) - Magenta
Pal-F = $1B (27) - Cyan
As you can see, the last 8 are mirrors of the first 8. (these values are straight from the NitrOS9 sources)
When you alter the attributes of a /Wx (with wmode), WCreate, DWSet, or OWSet color numbers, this will will alter what palette is used for BG, FG & BD slots, not the colors in the palettes.
The "Registers" that the Basic09 manual refer to are the OS9 "slots" I am referring to... NOT palettes, though palette numbers are what's stored in the registers (0-15). So when you change these "registers", you are just rearranging the palette numbers not changing palette color numbers. These "registers" are just buffers in the system and the display routine in GRFDRV read the palette number from these registers, not the color number. The color numbers are stored in OS9's "palette" registers (0-63). As I said, it gets confusing LOL
Try using the Palette cmd in gfx2 without using the Color or Border cmds and see what happens.
Just change the color numbers in palettes 10 & 2 and I think you'll see what you're looking for.
It took writing the SControl routine for me to figure out that the "color" value in OS9 had little to do with setting palette colors, it was just selecting between the 16 palettes. To set the palette colors, you set the palettes directly with the palette command.
I went through about a month of pouring through the GRFDRV, CoWin, and VTIO sources and playing with the palettes and colors because, like you, I was getting completely wrong colors. Then in writing my SControl, I started seeing what was happening.
I can now correctly predict the exact color that will be displayed on my screen on Vcc, Mess or my Coco 3 every time without fail with RGB or Composite. My Sound Chaser & DW4Man display the same on all machines and emulators no mater how you set the colors. These programs set colors for almost everything they. Varying text colors to signify various things, different backgrounds and foregrounds for every overlay window. I always get the color I ask for.
If the colors in Nitros9 were wrong (or Basic09 too), then none of the "old" games or programs would show the correct colors.... but they do. So something must be right :-)
Bill Pierce
"Today is a good day... I woke up" - Ritchie Havens
My Music from the Tandy/Radio Shack Color Computer 2 & 3
https://sites.google.com/site/dabarnstudio/
Co-Webmaster of The TRS-80 Color Computer Archive
http://www.colorcomputerarchive.com/
Co-Contributor, Co-Editor for CocoPedia
http://www.cocopedia.com/wiki/index.php/Main_Page
E-Mail: ooogalapasooo at aol.com
-----Original Message-----
From: Wayne Campbell <asa.rand at gmail.com>
To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
Sent: Tue, Apr 1, 2014 10:23 pm
Subject: Re: [Coco] colors
Thanks, Bill. Unfortunately, I have already been doing this (in a slightly
different way) with a routine I wrote named colortest. I am learning much.
For example, you say the first eight are all background, but I know that
they are not. Register 2 is window foreground. I've changed it enough times
to know. Register 3 is window background. Changing register 11 does not
change the background of the window. Changing register 10 does not affect
the foreground color either. In fact, the only 2 registers I can count on
100% of the time to be the correct foreground and background registers are
2 and 3. The cursor also uses one of the back 8, but I can't recall ATM
what that register number is. I can say it changes only the cursor color.
Trying to use it as a window color does not work. It doesn't seem to matter
what color I specify, I do not get the foreground or background color I
want. The one thing your routine does do that mine doesn't is identify the
color number of the default 8 colors. Other than black and white, I was not
sure of any color. Thanks to you I now have the correct values of the
default colors. This will help me much as I work to find the darker
versions of those colors. Once found, then it will be a matter of figuring
out how to make my program use them all.
I found an article in the January, 1987 issue of the Rainbow named Color
Chart for the CoCo 3. It contained images of both the composite and RGB
sets of the 64 colors. It also contained the source code for the program
they wrote that displays all 64 colors at once. It's written in SECB, and
includes a assembly source listing for the routine that does the work,
named CYCLE. I had to wrestle a copy from the article, as the OCR was not
very accurate, but I got it all typed in and saved.
Being a Basic09 guy, I went to the Basic09 Tour Guide to see if there was
an alternative, and there was. I typed in the code and watched as VCC not
only displayed the colors, but as the Log window recorded hitting something
multiple times. I guess VCC got overworked? It worked tho.
I don't have edtasm to compile the assembly code with, and trying to load
the BASIC source (named COLOR3.BAS) results in an error. I am not very
familiar with SECB, or COLOR BASIC at all really. I jumped right into OS-9,
and never learned CB, ECB or SECB. The Complete Guide to OS-9 Level II
contains listings for Bars and Palette procedures to display the colors in
Basic09. Not the same as the one from the article, but gives me code for
setting palette registers in Basic09. Still no help on how to setup and use
a 16-color text palette that contains 8 dark colors and 8 light colors that
can be used interchangeably as foreground and background colors. Setting
the palette registers is the easy part. Getting the system to know that I
want this register here and that register there, and be able to use all 16
of them that way, is proving to be impossible. This may still not make
sense, but it's difficult to make sense when you don't know what you need
to know to ask an informed question.
At any rate, I am still working at it. I hope I can solve this problem
soon. Worrying about screen colors was not part of what unpack was supposed
to do. But I can't give up on it. This needs to be answered, and I need to
understand how to properly use the palette. So, I continue searching.
Wayne
--
The Structure of I-Code
http://www.cocopedia.com/wiki/index.php/The_Structure_of_I-Code
decode
http://cococoding.com/wayne/
--
Coco mailing list
Coco at maltedmedia.com
http://five.pairlist.net/mailman/listinfo/coco
More information about the Coco
mailing list