Shop OBEX P1 Docs P2 Docs Learn Events
Screen color question — Parallax Forums

Screen color question

jaegjaeg Posts: 156
edited 2010-10-22 15:16 in Propeller 1
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

  • RaymanRayman Posts: 14,889
    edited 2010-10-20 17:03
    I have some information on VGACOLORS on my website here:
    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..
  • jaegjaeg Posts: 156
    edited 2010-10-20 17:23
    Ok. So I read the link and looked at the code and I'm not seeing anything with the pattern described. So I'm unsure how
    long    $F00CF00C       'blue background with yellow letters
    long    $F0F00C0C
    
    Gives a blue background and yellow letter while
    long    $00A800A8       'grey/black
    long    $0000A8A8
    
    Gives a white background and black letters.... I'm missing something here aren't I?
  • ericballericball Posts: 774
    edited 2010-10-20 17:55
    Each long is a four color palette with each color being one byte.
    long $F00CF00C  ' color[0]=$0C, color[1]=$F0, color[2]=$0C, color[3]=$F0
    long $F0F00C0C  ' color[0]=$0C, color[1]=$0C, color[2]=$F0, color[3]=$F0
    

    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.
  • jaegjaeg Posts: 156
    edited 2010-10-20 18:01
    Thanks, I was playing with the applet in the link Rayman provided and the little light in my head came on. I was completely misreading the information on the site. I thought that FF and BB where literally supposed to be in the long but that's not the case. Thanks for your help.
  • HarleyHarley Posts: 997
    edited 2010-10-20 18:04
    jaeg,

    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.
  • jaegjaeg Posts: 156
    edited 2010-10-20 18:14
    The on-screen keyboard is something I want to do too. Shouldn't be a very difficult. Just a lot of hardcoding the boxes and touch control. At least I think so. There might be a better way to do it.
  • HarleyHarley Posts: 997
    edited 2010-10-21 16:06
    jaeg, Here's the 'keyboard, color viewer and calibrator project mentioned yesterday.

    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
  • jaegjaeg Posts: 156
    edited 2010-10-22 15:16
    Oh wow this is cool. I'll play around with it. Thanks a lot! This will really save me some time coding.
Sign In or Register to comment.