Shop OBEX P1 Docs P2 Docs Learn Events
Why can't I make the TV colors show up the way I want them? — Parallax Forums

Why can't I make the TV colors show up the way I want them?

Dennis FerronDennis Ferron Posts: 480
edited 2006-09-23 21:05 in Propeller 1
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.)

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-23 17:50
    There's a program called "graphics_palette" which shows the complete graphics palette on the screen and, when you move the mouse over the color, shows you the magic number associated with it. I believe the comments at the end of the tv (and vga) driver describe the magic numbers and the color table.

    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.
  • Ym2413aYm2413a Posts: 630
    edited 2006-09-23 21:01
    With the TV object the colors are packed as Hue, Saturation and Lightness.

    4 bits for Hue.
    1 for Saturation.
    3 for Lightness.

    In that order from MSB to LSB if I remember correctly.
  • Jim FouchJim Fouch Posts: 395
    edited 2006-09-23 21:02
    Check out my thread on this very same topic. It should help make it a bit easier for you.

    http://forums.parallax.com/forums/default.aspx?f=25&m=144704
  • Ym2413aYm2413a Posts: 630
    edited 2006-09-23 21:05
    en.wikipedia.org/wiki/HSV_color_space
    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
Sign In or Register to comment.