Introduction
Our project is to make a color video game that runs primarily on the ATmega 1284P. To do this, we adhered to the NTSC standard for color video. The sync signals used for NTSC are generated on the ATmega 1284P itself, and all game logic is implemented on the microcontroller as well. To actually encode the color signal, we used an AD724 chip. This is necessary because the color video signal is created by modulating a 3.58MHz signal, and our MCU only runs at 16MHz.

We chose this project because color video is so prominent in our lives, and we were curious about how it works after doing black and white video in lab 3. For our project, we referenced the many previous color video projects, but we did not reuse the code from previous years. This was mainly because color video requires writing AVR assembly, and the code from previous years was written for the CodeVision compiler and was not compatible with GCC.
High Level Design
Logical Structure
The design of this project can logically be broken down into three parts: the hardware design, the low level software that works with hardware, and the game processing. Both the hardware and software design will be covered in detail in the Program/Hardware Design section, but the overview is as follows:

The hardware includes a joystick, the microcontroller and its logic board, the AD724 and its supporting peripherals such as a ~3.58MHz crystal, and an LCD TV with composite video input. The joystick takes user input; this can be up/down, left/right, or activating the built in push button. The microcontroller receives this input and processes it accordingly. It then outputs RGB signals as well as a sync signal to the AD724, which encodes the information into a composite signal, which is then output to the TV.
The low level software interfaces with the hardware. This involves using the ADC to take input from the joystick, using the MCU timers to accurately generate the sync signal, and using assembly code to quickly output data to the GPIO pins for the video signal.
The game logic is processed entirely on the microcontroller. After each frame is displayed, there is time during the vertical blanking period for doing calculations. All game logic is implemented here and will be detailed in the Software Design section.
Hardware/Software Tradeoffs
Using additional hardware increases costs and adds complexity to the physical design and circuit. However, additional hardware can significantly simplify software design and enable the microcontroller to perform tasks it cannot perform on its own. For our project, our approach was to use hardware as needed but only if needed. We used the AD724 to encode the color signal because our microcontroller is too slow to effectively perform that task. However, we did not use the ELM 304 sync generator used by most previous color video projects. By writing the video output code in assembly and by having relatively fast and simple game logic code, we were able to do sync generation on the ATmega 1284P without additional external hardware.
Read more: Color Video Game on AVR
