Since the AVR architecture doesn't offer enough RAM for direct video memory, some real-time compression must be used. The common way to overcome this is a TILE-based driver. In such kind of systems, screen is divided into X*Y fields (tiles) and each tile graphic is addressed from reference table located in RAM. The true bitmaps are stored somewhere else, in a ROM for example.

Basically, AVGA is strictly TILE-based AVR interrupt driven audio-video driver for a single-chip game console. However, there are some very special features:

1. Graphic driver can get any tile bitmap to display anywhere on the screen from RAM or FLASH. What does it mean? You can copy a FLASH tile graphics, being shown somewhere, to RAM in main program. Then tell the driver that it should get source for this tile from RAM not FLASH. Nothing on the screen changes. However, you can modify that tile once it is in RAM. This feature is used by OVERLAY. There is a function named overlay_draw(pointer_to_image,x,y,width,height) in OVERLAY util. This function behaves just like putimage(...) in a full graphic environment including pixel (not tile) coordinates plus it has defineable transparency, source bitmap mirroring, clipping, selectable drawing area etc. It relocates all the tiles under the given sprite to RAM and draws it. Then you can simply call overlay_clear() and the sprite disappears - all used tiles are referenced back to FLASH. There are also classical primitive graphics functions implemented, like putpixel(...).

2. Screen can be divided into vertical sections. Each such window is something like interface between the visible screen and video RAM. You can, for example, create a window somewhere on the screen with height 50px that shows things starting at line 10 in the pseudo-videoram (reference table). You can create two windows showing the same (clone), create empty window, therefore it's video lines are not scanned - save clock cycles, window with a color mask, etc...

3. The low level graphics driver supports horizontal scrolling (one tile, pixel by pixel). This allows to write smooth sidescrolling games. BACKGROUND utility draws the tile-based object onto a specific place on the screen (window), not tile - but pixel coordinated left-top corner.

4. There are absolutely no delay loops anywhere inside the system. Whole interrupt-driven kernel is designed to return the CPU to main program whenever it is just possible. Fast PWM mode is used to generate high precission video sync pattern, with correct timings almost independent to the XTAL frequency. This gives more than 3M cycles per second to main app (19.6608MHz, full screen video, PAL, 192x144).

Everything can be customized to meet your game needs and to occupy as little flash as possible. AVGA is not part-specific. It will run in any mega AVR with at least one full 16-bit timer/counter for video.

The optimal resolution chosen for PAL is 192x144 (not overclocked). This resolution is 4:3 and dividable by eight. Each PAL frame has 288 lines, so when doubling each scanline, it covers the whole screen, with no unmapped area. For NTSC it is 160x120. Note that you can make up your own video resolution. You can even change height of the tiles. Resolution with 5 cycles per pixel could get much higher when overclocked - it's possible to achieve e.g. 320x240.

This software is provided under the terms of the GNU GPL (http://www.gnu.org/licenses/gpl.html)