There have been various calls over time for some simple graphics examples, and a lot of calls to understand the colors and the tiles. While at UPEW, I knocked this out and was asked to post it in the OBEX.
I'll do that, but want to give it a dry run here.
Basically, I've gone through and commented the graphics demo and created a few new methods, and example code that make doing colors, tiles, and graphics screens easy. I've attached a few screenies here to show some of what it looks like.
One of the things in the original demo that gives people trouble is the tile color and addressing code. The way it's written is compact, but not easy for a newbie. Instead of a colors array, I moved that to a DAT section where a person can see the relationship between the palette and the displayed tile, and or only define those palette entries they think they need.
This runs with the Parallax reference video driver, and can replace graphics_demo.spin. The new methods are:
set_tile_color(tilex, tiley, palette)
set_tile_address(tilex, tiley, HUB_address)
These methods can be used to define any of the 64 possible color palette sets and assign them to any tile on the screen. Additionally, any tile at on the screen can be pointed to display from any 64 byte aligned HUB memory address.
The program runs through a few basic operations on the graphics demo, showing color and address transforms. Color indirection is shown as well, which can be useful for a lot of displays, so long as the images are tile aligned in a way that makes sense. It's possible to put all the propeller colors on the screen with this driver, and some well chosen palette entries.
Finally, it shows a working example of how gr.setup can be used to draw in a window, either on or off the screen. The graphics cog is actually very useful. It operates with any sequentially addressed tiles, and features variable coordinates.
There are lots of things possible with this driver, and maybe this will help some people explore it better. The idea here is to run the program, which includes some waitcnt statements to slow things down, then read the comments, changing things to verify what has been learned. For all around graphics display, this driver has a lot potential. The only real downside is memory consumption. That can be addressed with the tiles, and repeated use of gr.setup to make the most of HUB memory, if desired.
Any and all comments welcome.
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Wondering how to set tile colors in the graphics_demo.spin?
Safety Tip: Life is as good as YOU think it is!
Post Edited (potatohead) : 7/4/2010 9:56:25 PM GMT