High Level Design
Our design was implemented in such a way as to allow our MCU to display virtually anything to a TV screen. We hope that someone uses our design to built bigger and better things than Psychedelic Snake, though we do like our game J To further encourage someone else to build off of our design, we have completely abstracted the hardware and the display routine. All a user program has to do is update SRAM and flash in much the same way that a normal LCD is written to. Everything else is handled by our project. Given enough SRAM, a user could actually recreate Super Mario Brothers or any other classic game that doesn’t have demanding processing requirements. The resolution of our design (as is) is wholly limited by SRAM. For our 48 by 32 pixel (dynamic) display we need 768 of the 1024 bytes of SRAM available on the Mega163. There were a number of trade-offs we made in our design, one of which was color-depth versus resolution. After all, the higher the color depth, the more SRAM each pixel will need. We finally settled on our current 8-color scheme, and the colors are as follows:
We combine two pixels into a single byte in SRAM, with a nibble allocated to each one. There is a wasted bit in each nibble which could have been used to increase the color depth, but that would have only allowed for one of the primary colors (ie. Red, Green, Blue) to be more flexible, which would have skewed our color scheme to mostly Red (or Green or Blue).
To generate a valid picture it is necessary to create a signal that complies with the NTSC TV format. The format is show in the picture below:
Within the waveform, several important aspects of the NTSC can be seen. First, the horizontal sync is the 4.7us low level. This allows the TV to know when to retrace to begin a new line. Another type of sync (not shown in the waveform) is the vertical sync. This tells the TV’s electron gun to retrace from the bottom of the screen to the top in preparation for a new field. Another important aspect is the colorburst. This is the high frequency burst before the actual image is trasmitted. The purpose of this is to synchronize the phase of each color signal to a know value. Within the "video" portion of the waveform, the actual image resides. The intensity of the image is encoded by the height of video relative to black level. The color is encoded in the video portion via a higher frequency subcarrer (not shown).
The NTSC standards are very strict, and even though we tried our best to follow them, our design does exhibit some form of dot crawl which is visible to the naked eye. This is due to the fact that 4 TV frames are interleaved to make a “superframe.” We do separate our output fields into even and odd fields, but we do not deal with superframes. Because of this, some color phase information is lost which accounts for the aforementioned dot crawl.