2. the Composite Video Signal

2. the Composite Video Signal

How to generate Color video signals in software using SX chips by Rickard Gunée http://www.rickard.gunee.com Featuring the games Tetris and Pong Copyright note How to generate color video signals in software using SX-chips © Rickard Gunée, 2003. You may distribute this document on in digital or printed form if the purpose is non commercial and the content is not modified in any way. 2 Generating color composite video signals in software, written by Rickard Gunée More info available at: http://www.rickard.gunee.com/projects Table of contents 1. BACKGROUND....................................................................................................................................... 5 2. THE COMPOSITE VIDEO SIGNAL. ................................................................................................... 7 2.1 HOW A STANDARD TV-SET WORKS....................................................................................................... 7 2.2 DIFFERENT TV STANDARDS.................................................................................................................. 8 2.3 THE INFORMATION IN THE VIDEO SIGNAL.............................................................................................. 8 2.4 THE SCAN-LINE ..................................................................................................................................... 9 2.5 PUTTING THE SCAN-LINES TOGETHER TO AN IMAGE.............................................................................. 9 2.6 VERTICAL SYNCHRONIZATION PULSES................................................................................................ 10 2.7 COLOR CODING. .................................................................................................................................. 10 2.8 QUADRATURE MODULATION............................................................................................................... 11 2.9 PUTTING IT ALL TOGETHER ................................................................................................................. 12 3. CREATING IT IN SOFTWARE .......................................................................................................... 13 3.1 THE BASICS FOR COLOR GENERATION ................................................................................................. 13 3.2 MATHEMATICAL TRICKS ..................................................................................................................... 13 3.3 KNOW YOUR HARDWARE .................................................................................................................... 14 3.4 OUR NEW PARAMETERS ...................................................................................................................... 15 3.5 PHASE ALTERNATING LINE................................................................................................................. 15 3.6 VIDEO OUTPUT HARDWARE................................................................................................................. 16 3.7 LIMITATIONS WITH COLORS ................................................................................................................ 16 3.8 USE OF PALETTE ................................................................................................................................. 17 3.9 OUTPUTTING MONOCHROME OBJECTS USING PALETTE ....................................................................... 18 3.10 COLORED TEXT LINES ....................................................................................................................... 18 3.11 EMULATORS...................................................................................................................................... 18 4. GAME SYSTEM .................................................................................................................................... 19 4.1 SCHEMATIC OVERVIEW....................................................................................................................... 19 4.2 JOYSTICKS .......................................................................................................................................... 20 4.3 THE OSCILLATOR................................................................................................................................ 20 4.4 TV CONNECTION................................................................................................................................. 21 4.5 PCB.................................................................................................................................................... 21 5. TETRIS ................................................................................................................................................... 23 5.1 HOW TO PLAY THE GAME. ................................................................................................................... 23 5.2 THE SOFTWARE................................................................................................................................... 23 6. PONG....................................................................................................................................................... 25 6.1 HOW TO PLAY THE GAME .................................................................................................................... 25 6.2 THE SOFTWARE................................................................................................................................... 25 7. CONCLUSIONS..................................................................................................................................... 27 APPENDIX A: COLOR TEST1 SOURCE CODE.................................................................................. 29 APPENDIX B: COLOR TEST2 SOURCE CODE.................................................................................. 35 APPENDIX C: TETRIS SOURCE CODE............................................................................................... 41 APPENDIX D: PONG SOURCE CODE.................................................................................................. 61 APPENDIX E: GAME SYSTEM PCB LAYOUT................................................................................... 81 Generating color composite video signals in software, written by Rickard Gunée 3 More info available at: http://www.rickard.gunee.com/projects 1. Background Back in early 1998 I made some experimenting using a PIC16F84 microcontroller (3MIPS of processor power) to generate composite B&W video signals on the fly in software, with two resistors as the only video hardware. I made the two classical games Pong and Tetris with this technique and published them including source on my homepage. Since then it has been built by several hundreds of people. During the Christmas 1998-1999 I got some PIC16F84-based Pong equipment from Scenix (nowadays known as Ubicom) and made some experiments to generate color video signals using an SX chip, but before I got any results my programmer broke down, at least that was what I believed, and I stopped developing it. In the early summer of 2001 I was told by people at Parallax that it was the early versions of the SX- chips that had a bug in them so my programmer was just fine, so they gave me some new chips and I PIC16F84-based Tetris continued my work. After some new experiments, calculating and many late hours and a bit of luck I got my TV to lock onto the color signal and by the end of summer I got a Tetris game up and running. During the fall I developed the Pong game, which was finished during the Christmas holidays 2001-2002. I didn’t release the games as there were some details left to take care of. I didn’t want to publish them until they were as perfect as possible due to my bad experience with my PIC-based games that were spread in early bad versions. Now in spring 2003 I decided that I shouldn’t do any more improvements of the games as I don’t have time to work on them and I got to stop sometime. The biggest remaining issue is that it only works good for NTSC, it is much harder to get a correct PAL signal in software, but that is a problem for someone else to solve. Another issue about the games was this text about generating color video signals that I wanted to finish before I released the games, to not get that many questions about video generation that I don’t have time to answer. After reading this document you will hopefully understand how to generate color composite video signals in software. To fully understand this you need mathematical knowledge at university level, some 5 RF-knowledge would also help a lot. SX-Tetris SX-Pong Generating color composite video signals in software, written by Rickard Gunée 5 More info available at: http://www.rickard.gunee.com/projects 2. The composite video signal. To understand anything about generating video signals in real-time, one must know how video-signals work in detail, so before we look at any code we'll have to talk about video signals. 2.1 How a standard TV-set works The electron beam drawing the screen The two part images becomes one whole image. A standard TV-set is built with a vacuum tube, which has a phosphor screen that an electron canon shoots at. When the electrons from the cannon hits the screen, light is emitted from the phosphor when the canon shoots electrons at it, and it also has a short afterglow making each pixel lit until the

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    81 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us