Shop OBEX P1 Docs P2 Docs Learn Events
Questions about the VGA_Tile_Driver_Demo2 code — Parallax Forums

Questions about the VGA_Tile_Driver_Demo2 code

retromicroretromicro Posts: 24
edited 2014-10-05 22:27 in Propeller 1
Hi

I've been messing around with this code, removing all the Lincoln and mouse stuff and adding my own code so that the Prop displays VGA output from my Z80 homebrew system.

However, there are some questions about the code (and the associated VGA_1280x1024_Tile_Driver_With_Cursor object that it uses).

Issues -
  • I can see in the code that I can call 'print' with $110 to $11F to specify a foreground text colour. That works fine. However, I'm not sure how to force a different background colour.
  • The code uses the constant 'spacetile' = $220 which is used by the clear screen utility (which loads this value into the screen buffer array). However, I'm not actually sure where the $220 comes from. I don't see any fonts being loaded but there's some mention in the library code about the built-in fonts. If you change to say, $222, the screen will fill with some graphic character not shown in the Prop font table. The library code also says that the bottom ten bits hold the base address of a bitmap. However, $220 = 544 which looks greater than the size of the internal fonts.
  • The library has a comment stating that the top six bits are used as a pointer to the colour palette. There's also some info about colours with quaternary numbers. I'm not sure if each palette entry refers to both a foreground and background colour.
  • The library has a comment stating that the color_ptr should be pointing to a table of 64 longs with the palettes info. However, the example code only defines 24 longs. Just lazy coding ?
The objective is to be able to print any character at any location with a defined foreground and background colour. Please would anyone be able to consider the above and advise what I'm missing ?


Thanks

Comments

  • ElectrodudeElectrodude Posts: 1,658
    edited 2014-10-05 15:31
    retromicro wrote: »
    I can see in the code that I can call 'print' with $110 to $11F to specify a foreground text colour. That works fine. However, I'm not sure how to force a different background colour.
    That doesn't just set a foreground color - it sets both the foreground and background color. It picks a palette number out of the color table, which specifies both foreground and background colors.
    retromicro wrote: »
    The code uses the constant 'spacetile' = $220 which is used by the clear screen utility (which loads this value into the screen buffer array). However, I'm not actually sure where the $220 comes from. I don't see any fonts being loaded but there's some mention in the library code about the built-in fonts. If you change to say, $222, the screen will fill with some graphic character not shown in the Prop font table. The library code also says that the bottom ten bits hold the base address of a bitmap. However, $220 = 544 which looks greater than the size of the internal fonts.
    $220 << 6 = $8800 which is the address of the space character.
    value = (tile_pointer >> 6) + (color << 10)
    tile_pointer = $200 (<<6 = $8000, beginning of ROM font) + $20 (=32 = space)
    retromicro wrote: »
    The library has a comment stating that the top six bits are used as a pointer to the colour palette. There's also some info about colours with quaternary numbers. I'm not sure if each palette entry refers to both a foreground and background colour.
    Each palette entry refers to both a foreground and a background color. Each nibble is a list of four colors, because of how the bitmap font works (read the propeller manual section about the ROM font). Colors can be expressed as quaternary, %%rrggbb00. Each color is one byte in the long. There are two longs for each color - the first has bytes arranged as fbfb and the second is arranged as $ffbb, where f and b stand for foreground and background colors, respectively.
    retromicro wrote: »
    The library has a comment stating that the color_ptr should be pointing to a table of 64 longs with the palettes info. However, the example code only defines 24 longs. Just lazy coding ?

    If only the first 24 are ever used, only they have to be defined. If you tell it to use the 25th color, you could get any color, because it was never defined. Defining all 64 would be a waste of RAM if they don't have any real values.
  • kuronekokuroneko Posts: 3,623
    edited 2014-10-05 22:27
    retromicro wrote: »
    The objective is to be able to print any character at any location with a defined foreground and background colour.
    AFAIK there is no full colour Parallax VGA driver1. You get paletted versions (usually 64 entries) or per line colour. (hires text drivers). Are you sure you need a per location colour pair?

    1 arguably the 512x384 bitmap driver being an exception
Sign In or Register to comment.