Screen color question
jaeg
Posts: 156
DAT vgacolors long long $00A800A8 'grey/black long $0000A8A8 long $F00CF00C 'blue background with yellow letters long $F0F00C0C long $08A808A8 'green long $0808A8A8 long $50005000 'blue long $50500000 long $FC00FC00 'white long $FCFC0000 long $FF80FF80 'red/white long $FFFF8080 long $FF20FF20 'green/white long $FFFF2020 long $FF28FF28 'cyan/white long $FFFF2828 long $00A800A8 'grey/black long $0000A8A8 long $FFC03000 '16'Colors for Graphics spcl long $F0FF9C0C '17 'Color0 white long $F0C09C0C '18 Color1 red long $F030000C '19 Color2 green long $F000000C '20 Color3 black long $FF0C9C0C '21 fill screen long $000C9C0C '22 clear screen long $FF0C9C0C '23 line mode long $FF0C9C0C '24 dots mode long 0
When I copy the grey/black to the top of this code (which comes from Raymans PSB_Paint Program that has had the Paint pub removed and just does calibration for now) the screen becomes white with black letter. This is what I want but my question is why? How are these things set? Is there something that can be called to access these colors at the beginning of the main pub? I'm assume since I messed with the vgacolors data structure this messes up the order of the colors possibly throwing off all of the colors in the rest of the program so how do I change just the screen color and text color?
I have another question that I'll throw in here since I already have a thread going. When calling a pub method does it run in another cog or does the code just jump to it like it would if it was a function in another language? When I say call a pub I mean doing this:
Pub Main ... ... Paint repeat Pub Paint ... ... ...The manual had me kind of confused by this since there is also cognew/coginit commands that for sure open a new cog
Comments
http://www.rayslogic.com/propeller/Programming/Colors.htm
look toward the bottom of the page...
The address of vgacolors is passed to the LCD driver as a parameter. But the LCD driver continuously updates the color data...
As for question #2, no you're not starting a new cog, you have to use the cognew command to do that... In your main program there is no real difference between PUB and PRI. But you can only call PUB routines in your sub-objects..
Now, assuming you are using a Demoboard style VGA interface (8 pins to 8 resistors to 5 outputs RGBHV), the bits in each color byte are RrGgBbHV. So $0C translates to R=0,G=0,B=3,H=0,V=0 and $F0 translates to R=3,G=3,B=0,H=0,V=0.
The reason there are two longs and why each color is repeated twice in each long has to do with how characters are stored in ROM. Each character is 16 pixels across. But rather than storing them as a sequence of words, two characters (odd and even) are combined into a single long with the even character using the even bits and the odd character using the odd bits.
Thus if you want to print out an even character the first palette long is used. So if the even bit is set, color 1 or 3 are output, but if the even bit is cleared, color 0 or 2 is output. For an odd character the second palette long is used and an odd bit set outputs color 2 or 3 and an odd bit clear outputs color 0 or 1.
I too had problems understanding the color stuff. Until I played with Paint app after deleting the Paint main routine and added some of my own PUBs.
One thing I'd not seen documented anywhere is that the first pair of longs defines the fg/bg colors after a clear. That made lots of sense on trying different pairs of colors. To be able to view all the colors, I wrote something that lists the longs on screen, and using the touchscreen I can increment/decrement the left and right byte values A and B as they make up the longs:
first long.........ABAB
second long.....AABB
Tomorrow I'll try to archive the sources so someone else can make use of them. There are three selections; a keyboard on-screen, the above 'color selector' and calibration. The keyboard thingee is far from complete, I was hoping to use it with SD cards.
Excuse the name, I was going in a different direction when I first started to use Paint as basis for the beginning of something else. It was going to use Basic at first; but found I was trying to include too much to fit SD card and some 'OS' to work with that. And besides, I had to learn some things about the 'color' aspect to be more comfortable with what I wanted to do.
This was configured to use a Prop Protoboard (early version, uses Prop Plug) with Rayman's breakout board for the 4.3" LCD. You may have to change the I/O pin assignment to use it.
Lower-left tile accesses a sort of debug display. Needed something to view various variables while getting it operational. Lower-right four tiles varies the brightness; left two for decrease, right to to increase. Yeah, invisible controls for my convenience.
The CAP and Shift keys don't yet work as I planned yet. CAP when red is like shift-lock. Shift, marked 'sft'. I intended to just work for capitalization of the first letter of a word; not fully deugged at this point.
Feel free to use any aspect of this for your own project. ps - calibrator crosshair got corrupted