4 colors with GRAPHICS.spin?
RinksCustoms
Posts: 531
I figured out how to produce S-video -(definetly a cleaner image), but i cannot figure out how to get more than 4 colors from graphics.spin. I've "gutted" the graphics demo to make a program, but it seems to be creating more of a problem than it's solving. I'm guessing a block of code has to be changed in the init area and also in the DAT section as well to get more than 4 colors, just don't know what to change.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! The average PC while browsing the internet typically uses less than 30% of it's potential, why not donate a portion of the rest for cancer resaerch?
PUB init 'init colors repeat i from 0 to 63 colors[noparse][[/noparse]i] := $00001010 * (i+4) & $F + $2B060C02 <blah, blah, setup/main code, blah, blah> DAT ' Color codes colors long %%0000000000000000 long %%1111111111111111 long %%2222222222222222 long %%3333333333333333
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! The average PC while browsing the internet typically uses less than 30% of it's potential, why not donate a portion of the rest for cancer resaerch?
Comments
So that you do not have to buy it
Color data consists of
4 bits Chroma
1 bit Chroma enable ("Modulation")
3 Bits Luma
Not all values are permitted (Luma should stick between 2 and 6 e.g.)
The 16 Chroma values are coded along the NTCS/PAL colour wheel, e.g. 0: blue , 5: red e.t.c.
Edit: Chroma Enable ist set to zero to generate clear gray values (e.g. luma 2: black, luma 6: white, where Chroma is ignored)
Post Edited (deSilva) : 7/19/2007 9:25:24 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! The average PC while browsing the internet typically uses less than 30% of it's potential, why not donate a portion of the rest for cancer resaerch?
The Parallax TV driver only does 4 colors per tile. You can set these, for more than 4 colors, by changing the screen array values. There is a sample chapter here that covers that:
http://www.parallax.com/dl/docs/prod/prop/Hydra-Ch16Sample-v1.0.pdf
So, you are closer. Lots of colors on screen, but only 4 within one tile in particular.
From there, you essentially need different TV driver code. With that will come changes to graphics.spin to handle the different color addressing.
We've not seen 8, 16 or 32 color drivers written yet, but they are totally doable. I've got one that does high-color, but it consumes a lot of ram. One byte per pixel. It's decent at lower resolutions (160x96). It permits any standard propeller color at any pixel position. It can be found here, and is based on CardboardGuru's EASYNTSC driver demo example.
http://forums.parallax.com/forums/attach.aspx?a=14813
Read through the code header and define your horizontal resolution, vertical resolution (one scan line or two high for 96 or 192 pixels), define a screen memory area and call the driver. It does no color lookup, so it's not a bad idea to fill the screen memory area with black pixels, or whatever color you want as background first. The simple program included does this.
Before doing too much with that driver, take a hard look at the sample chapter. 4 colors per tile is not too big of a limitation and really saves on the RAM. Depending on what you want to put onto the screen, it might work very nicely.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! The average PC while browsing the internet typically uses less than 30% of it's potential, why not donate a portion of the rest for cancer resaerch?
What these colors actually end up being on screen, depends on the contents of the colors array. The key is in the rainbow color. That's really color 3, I think. (well, it's one of the 4 in any case!) Same color index, but different results on screen. All 4 colors work the same way.
In the case of the graphics demo, this definition has been applied vertically to demonstrate more colors on screen. In a nutshell, the screen is broken up into 16 x 16 pixel tiles. Each tile gets it's four colors from the colors array.
Parse through the portion of the graphics demo program that sets up the tiles, using that sample chapter. Or, If you want to, isolate one tile in particular and put your own color values into it. (simply choose one of the colors array elements and change it only) Redefine color 0 to change the background and verify you have the right tile. From there, you can learn how things are setup. Once you have control of that one tile, then it's no biggie to set the rest of them up the way you want.
I think the first colors array element has the sync colors in it. Leave that one, or the first coupla of them alone. On the Propeller, some colors are actually sync signal colors! This is unlike pretty much any other graphics engine. So, a $00 for a color is not black, but blacker than black, which is actually a signal to the TV. This is what deSilva was hinting at. $02 = black.
This is tricky, but worth it. In the end, you can make any tile display any of the standard colors, and have it display any chunk of propeller RAM. For the graphics demo, the tiles have been lined up to form a nice bitmap. They start addressing from upper left, filling horizontally, ending up at lower right. You probably want to leave the addressing alone, and setup some color constants in your program to make things easier.
Writing your own driver is tough! I was having one heck of a time until CardboardGuru wrote his nice and simple example. Still tough, but I get more hits than strikes now.
There is a table with color values here on this page: http://propeller.wikispaces.com/Colors
In the colors[noparse][[/noparse]40] line, the definitions are:
color0 = background = some purpleish color = $cd (May vary in color, depending)
color1 = dark grey = 03
color2 = med grey = 05
color3 = white = 07
Add that one line, and you should see the tile, near the middle of the screen look different from the others. I used the palette program because it would run in gear and I wanted to double check. Same approach should work for graphics_demo.spin too. Anything that uses the Parallax TV driver.
Did your s-video circuit change from your last posting? If so, mind sharing it?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Post Edited (potatohead) : 7/20/2007 7:09:22 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! The average PC while browsing the internet typically uses less than 30% of it's potential, why not donate a portion of the rest for cancer resaerch?
Post Edited (RinksCustoms) : 7/22/2007 5:49:31 AM GMT
Post Edited (deSilva) : 7/21/2007 4:19:54 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! The average PC while browsing the internet typically uses less than 30% of it's potential, why not donate a portion of the rest for cancer resaerch?