Shop OBEX P1 Docs P2 Docs Learn Events
Another colors/tiles question — Parallax Forums

Another colors/tiles question

sccoupesccoupe Posts: 118
edited 2008-12-14 02:38 in Propeller 1
The following init colors will display a purple screen with the TV driver.

repeat·i·from·0·to·63
··colors[noparse][[/noparse] i ]·:=·$78787878

The following init colors will display a black screen with a 16 pixel wide, purple·horizontal line all of the way across the screen about half way down.

repeat i from 0 to 63
· colors [noparse][[/noparse] i ] := $02020202

colors [noparse][[/noparse]·8 ] := $78787878

Now im pretty sure that I understand how these work, but what if I only wanted that purple stripe to go half way across the screen? It seems that setting the colors from colors[noparse][[/noparse]0] to colors[noparse][[/noparse]15] sets the 4 colors for the tiles a row at a time. How do I set this for an individual tile? If 0 to 15 seems to set the colors for the whole screen, why repeat the color init from 0 to 63?

Thanks all.

Jason

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-14 02:13
    Each entry in the color table provides a set of 4 colors for a tile. Each tile can have its colors chosen from one color table entry. This applies to the 2 bits per pixel display mode. There is a 1 bit per pixel mode that uses just the first two bytes of each table entry, but we're not talking about that here.

    Depending on the I/O driver, the color table can apply to each character (tile) or it can apply to an entire line of text. For the TV driver, the color table is applied on a per character basis or per tile (for graphics).

    For the TV text driver, there's a control character followed by a color # that sets the color table entry to be used until it's changed. For the graphics driver, I think it uses a color table entry for each row of tiles on the display (12 rows). You could probably add a call to the graphics driver that would change the tile pointers to use other color table entries, but that's the way the tile pointers are currently initialized.

    The initialization routine is:
      repeat dx from 0 to tv_hc - 1
        repeat dy from 0 to tv_vc - 1
          screen[noparse][[/noparse]dy * tv_hc + dx] := display_base >> 6 + dy + dx * tv_vc + ((dy & $3F) << 10)
    


    You'd need to change the "(dy & $3F)" term to something else depending on what you want.
  • sccoupesccoupe Posts: 118
    edited 2008-12-14 02:28
    Hmmm,

    That looks a littel more complicated than I figured it would be, but its all mysterious until one really understands it. What does the "dy & $3F" signify? If the graphics driver assigns colors a row at a time, that explains what I understand so far. The code that you have here, that is pointing the graphics driver to the TV color setup?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-14 02:38
    The nested loop initializes the table of tile pointers, one for each tile on the screen, arranged in rows. Each tile pointer is a 16-bit word. The high order 6 bits contains the index into the color table (0-63) for the entry to be used for this tile. The four bytes of the entry correspond to the 4 pixel values contained in a 2-bit pixel. The graphics demo initializes the tile table so that each row uses a different color table entry. Since there are only 12 rows and potentially 64 color table entries, you could divide up each row into 4 regions and let each have a different color palette. You could also write a routine that would set the tile color for any tile to be any color table entry you want.

    The (dy & $3F) << 10 just sets the upper 6 bits of the tile pointer to the row number (dy).

    Just to confuse things, the VGA drivers use a different format for the tile pointer. There the lower 6 bits contain the color table entry number.
Sign In or Register to comment.