The AVGA structure
In general, the system consists of 2 parts:
1. The core
a. video.c - video sync signal generator
The superior module. It uses one 16 bit timer/counter in Fast PWM mode with no delay loops for high precission sync signal generating. The signal pattern description is defined in flash, thus it is very easy to switch between the video standards in runtime. The module is configured in video.h or config_hw.h and config_screen.h.
b. driver.s - video graphics driver
Drives the video output port. Module is written in assembler. It produces the 4 bit video pixel stream with 5 cycle pixel period. The tile width is fixed to 8 pixels. Resolution and tile height can be customized. It supports one tile scrolling along horizontal axis. The module is configured in driver.h or config_hw.h and config_screen.h.
b. sound.c - sound driver
The sound sequencer. Uses an 8bit timer/counter in CTC mode to play square wave audio sequences. The module is configured in sound.h or config_hw.h.
2. The utils
a. window.c - vertical screen mapping utility
The module can divide the screen to vertical sections. Each of it can have different parameters, for example: scrolling, color mask, tileset, reference table etc. The module is configured in window.h or config_utils.h.
b. overlay.c - flotating image rendering engine
Uses the driver's RAM mapping capability to render floating images. It provides powerful API with overlay_draw(...) which behaves just like putimage(...) in a full-graphics environment. It supports clipping, mirroring, transparency etc. The module is configured in overlay.h or config_utils.h.
c. background.c - tile-based image rendering engine
Uses the driver's PGM mapping capability to render fixed tile-based images. When combined with scrolling, it can display smooth sidescrolling game map. The module is configured in background.h or config_utils.h.