PDA

View Full Version : Any info on colors in Graphics mode? (TV mode)



Mark Bramwell
08-29-2007, 12:44 AM
I want to create a controller for a radio receiver.

I have read through many of the messages on this forum and I am a bit confused.

This is what I have tried...
Using the TV.text object, I created a simple mock-up interface. I found I was only able to select a very few colors (4 or 8?)
I gave up and tried to use the Graphics object. I like this object because of the finer controller of placement and various text sizes.

BUT I seem to be limited to the 4 colors again. I have attached a simple GUI mock-up. It does nothing but display a simple status screen. I seem to be extremely limited by my color choices (4 again) but the really confusing part is I can't seem to get a solid background. The background has many colors!!??!!

So:

1. Can someone point to me how to make a solid background? I am assuming it has something to do with the tile initialization
2. How do I make any text-box or text any specific color? I am assuming it has something to do with the color initialization.

Many demos are available but the ones I tried all seem to be slight modifications of the same code and use the same initialization routines.

PS: I have also attached the text mode version but I have abandoned it in favor of the graphics mode.

deSilva
08-29-2007, 01:15 AM
Well, I am not happy with all these copied and recopied "driver examples". It is not at all difficult to explain, but it takes some pages... I think I have a new turorial ready during the next weekend.

Do you understand these lines (96 to 99 in your code)?


'init tile screen
repeat dx from 0 to tv_hc - 1
repeat dy from 0 to tv_vc - 1
screen[ dy * tv_hc + dx] := display_base >> 6 + dy + dx * tv_vc + ((dy & $3F) << 10)



They assign the four colours to be used in each tile. So when you make them colorful, they will be colorful http://forums.parallax.com/images/smilies/smile.gif
Each 16 bit word consists of the higher 10 bits of the tile address plus a COLOR REGISTER NUMBER in its own high 6 bits.

This NUMBER is what is shifted 10 places to the left. It is computed from the vertical tile number "dy" in this example; "& $3f" ensures a number between 0 and 63.

The preset of the 64 COLOR REGISTERS is done in lines 85-87


'init colors
repeat i from 0 to 63
colors[ i] := $00001010 * (i+8) & $F + $2B060C02


They describe each 4 COLOR BYTES according to the composite video hardware convention, i.e.
-- 4 bits color wheel value, 1 bit chroma enable, 3 bits luma value (note: use 2 to 6 only!)

Fore a monochrome background color, use code like this for the tiles


'init tile screen

myColorScheme := 0 << 10 ' or 1 or 2 or 63

repeat dx from 0 to tv_hc - 1
repeat dy from 0 to tv_vc - 1
screen[ dy * tv_hc + dx] := display_base >> 6 + dy + dx * tv_vc + myColorScheme

Post Edited (deSilva) : 8/28/2007 6:23:09 PM GMT

Mark Bramwell
08-29-2007, 03:09 AM
oops! I hope you are not upset with my use and re-use of the examples!! Sorry, but the documentation for spin appears to be sample-code related versus a real how-to document.

Your reply seems to verify my guess of which 2 routines were doing the color magic.

So to recap:

The screen is divided into tiles. Each tile has its own color wheel of 4 possible colors. The exact 4 colors that are used can be different for each tile. If I set the background to color #1, I must be sure that every tile has the same color assign for #1 otherwise I get the rainbow effect, right? That said, if I change the color wheel for some specific tiles, I should be able to change the background color for some text?

The text color appears to be unrelated to the tile color. I was able to draw the blue boxes and put some white text inside them even though the tiles might have pink or blue behind them. I did play with the color parameter and only 4 colors seem to be assigned. If I cycle through 0 - 63 on screen, I get re-occurring colors. Is that because of the method used to define the colors? Could a true 64 color palette be defined and used with the gr.box commands?

FYI: My desire is to create a program that connects to my Icom PCR shortwave receiver and allows me to control it using a Sony Remote and view the parameters on my TV screen. The Icom radio is a computer controlled radio and has no display or buttons, it only has a serial port, antenna-IN and audio out.

I eagerly await your updated document

deSilva
08-29-2007, 03:51 AM
(1) The code is free, of course - to use and abuse http://forums.parallax.com/images/smilies/smile.gif What I wanted to say was: Copying and recopying "just things" can lead to misunderstandings....

(2) TV_TEXT works independently WRT to colors. It uses its own palette of eight color pairs (fg, bg) you select with $0c; this palette is build-in, but you can or course change TV_TEXT. (You can also change the restriction of 8 different color pairs if you like (and don't forget line 144 in TV_TEXT))
This management is necessary, as TV_TEXT displays the entwined ROM characters in tricky 4-color mode - i.e. only two colors are usable. Don't ask...

(3) GRAPHICS works again differently. It uses the tiled TV or VGA but organizes the graohics memory linearly, with 2 bits (= 4 colors) per pixel. It is not intrested what the specific COLOR REGISTER of the tile in question contains; in fact it is not even aware of the tiling at all after it has arranged the setup.
So you can modify both COLORS (= 64 possible COLOR REGISTERS (or "color sets of 4")) and the upper 6 bits in each of the tiles according to your taste.

Post Edited (deSilva) : 8/28/2007 10:03:13 PM GMT

Mark Bramwell
08-29-2007, 04:42 AM
Thanks for the replies.

I see 2 possible uses for the graphics mode. One set of programmers will want to do the traditional graphics stuff. This might be games or fancy GUIs for technology with circles, arc and sprites. Guys like me want to use the graphics mode for menus and mostly text based controls (with boxes and different text sizes).

Perhaps your document could have a section that gives examples on how to manipulate the various options from a color scheme point of view.

A god example might be "Hello World" on all sixteen lines. The screen background would be a solid color such as light blue but the foreground and background of the text is different on each line. I believe this would require a good understanding of how to set the bits and by having 16 lines with different schemes, it means you didn't simply set a global color scheme and rotated the same 4 colors.

I keep seeing reference to the Hydra book. I know what is a Hydra because I have visited their site; have you seen the book? Does it detail everything that I have asked or is it mostly concerned about video game creation? Is it worth buying the Hydra (and tossing it) keeping the book for reference?

Update: I just noticed that the book is for sale separately and has a few chapters for download....

deSilva
08-29-2007, 04:54 AM
That would have been my proposal, to buy the book separately. It is a wealth of useful information, but what I understand is that you already possess many of them. The major part describes ways of queezing the most out of cheap hardware.. It is interesting...
The enclosd CD ROM contains lots of code and another of André's books as PDF.

The Hydra is a high quality product, especially for persons who do not want to bother with hardware issues, but concentrate on the software. However I see two shortcomings
- the hardware is no longer "mainstream", chrystal and port numbers anyhow, but what is more annoying is a different concept for keyboard and mouse...
- it is terribly overpriced