If you are new to the Video Critter Hi-Res board, you should run the tutorial on compiling and uploading programs, and the video and sound tutorial.
Downloads:
After downloading the example code, unpack it, and in a terminal window run 'make' to compile the code. Then upload the resulting main.hex file.
The video routines, in the file video.c, are picky about compiler settings (such as optimization level), so there is a version of this example with those routines precompiled. If you want to get into lower level video programming, download the version thats not precompiled.
When its running, the four navigation buttons on the left side of the Game Board control the position of a square cursor. The cursor paints as it moves. The remaining four buttons control the following, from left to right: clear the screen to black, fill the screen with the current cursor color, invert the screen, and change the cursor color.
Additionally, the four navigation buttons each play a tone when held down, and the invert button causes all the tones to play 1 octave higher.
The main.c file contains the main application. It also contains several functions for reading the buttons on the Game Board and controlling the LEDs.
The file graphics.c contains higher level graphic functions for drawing pixels and printing characters. Additional graphics functions can be based on the put_pixel function.
The low level video synthesis happens in video.c. It runs using interrupts to trigger events in the video signal.
Producing audio requires an audio buffer. At each new line event (around 15.7 kHz), the video routine outputs the next value from an audio buffer to the DAC. So the sampling rate is the same as the NTSC line rate.
To produce sound, the function audio_fill_buf() in audio.c must be called every few milli-seconds. This function keeps the audio buffer filled by calculating sample values. Many audio algorithms may be used to calculate sound, in this tutorial we have a 4 voice triangle wave oscillator with adjustable frequency and amplitude.
In this example we use the lineCount variable to know when a new frame occurs, and only read the buttons and update the display every frame. In between we call audio_fill_buf() to keep the audio buffer full.