Why can't I make the TV colors show up the way I want them?
Dennis Ferron
Posts: 480
I'm trying to program Nibbles in spin and I'm a little confused about how the TV colors work. What the manual has to say about how the bits are packed (red, green, blue, & don't care) doesn't seem to have anything at all to do with what colors show up on the screen. And I don't get how the 64 colors in the array map to the screen pixels. (I'm using the graphics object, and the tv object.) I thought it was one color palette for each tile, but all of my color tiles seem to use the first color palette and changes I make to subsequent ones don't show up anywhere.
I used the graphics demo and palette demo as a starting point. I don't understand the purpose of the magic numbers the graphics demo applies to the color palette, such as "20B0C0" etc. I'm confused - I thought this was supposed to be packed RGBs; what is this really? Do we have to bitbang a complex RF video signal with the color info instead? Because when I change the magic number, I a get black and white picture more often than I do color. TV signals are outside my ken.
Once, accidently, I got the colors I wanted. I wanted blue, red, purple-pink, and white, with a different color overscan/background color. Somehow I got it to do that, but then I could never get it back.
Also, why do the demos shift left six (>>6) when they fill in the tile pointers for the screen array? And how might I calculate to go from a pixel x, y coord back to a memory location in the bitmap? (Need a "sample_pixel_color(x,y)" function in the graphics object.)
I used the graphics demo and palette demo as a starting point. I don't understand the purpose of the magic numbers the graphics demo applies to the color palette, such as "20B0C0" etc. I'm confused - I thought this was supposed to be packed RGBs; what is this really? Do we have to bitbang a complex RF video signal with the color info instead? Because when I change the magic number, I a get black and white picture more often than I do color. TV signals are outside my ken.
Once, accidently, I got the colors I wanted. I wanted blue, red, purple-pink, and white, with a different color overscan/background color. Somehow I got it to do that, but then I could never get it back.
Also, why do the demos shift left six (>>6) when they fill in the tile pointers for the screen array? And how might I calculate to go from a pixel x, y coord back to a memory location in the bitmap? (Need a "sample_pixel_color(x,y)" function in the graphics object.)
Comments
Each tile allows four colors (the pixels are 2 bits in the video generator). For efficiency in the video driver, the color choices are stored in a color table that has up to 64 color palettes (longs) containing combinations of the different magic numbers. The video drivers initialize their color tables to a default set of palettes. The text drivers have a specific method to set the color palette.
Each tile on the screen has a tile pointer that also contains the color palette number associated with the tile along with a pointer to the tile pixels elsewhere in memory. For the text driver, the tile pointer points into the font table so we have one tile per character. Since each tile contains 16 x 16 pixels at 2 bits per pixel that takes 64 bytes per tile. That's where the >>6 comes in.
4 bits for Hue.
1 for Saturation.
3 for Lightness.
In that order from MSB to LSB if I remember correctly.
http://forums.parallax.com/forums/default.aspx?f=25&m=144704
Here is a link to a page with details about HSV color space.
Jim Fouch's code is really useful if you need to work with colors.
Post Edited (Ym2413a) : 9/23/2006 9:57:39 PM GMT