Jump to content


Session 7: The TV and our Kernel

4 replies to this topic

#1 Andrew Davie OFFLINE  

Andrew Davie


  • 1,829 posts
  • Dr.Boo
  • Location:Tasmania

Posted Fri May 23, 2003 10:10 PM

Time to complete our understanding of what constitutes a TV frame - exactly what has to be sent to the TV to make it display a picture correctly.

Revisit the diagram posted earlier, with the timing information and the Pitfall! image inside. Your understanding of the numbers across the top should be good, but just to briefly revisit what they mean:

There are 228 TIA colour clocks on each scanline. 160 of those are spent drawing pixels, and 68 of them are the horizontal retrace period for the TV's scanning of the electron beam back to the start of the next line. In the diagram we see the horizontal blank (retrace) at the left side, so our very first colour clock for the TIA's first visible pixel on the screen is cycle #68. We should understand this timing fairly well by now.

What we're going to finalise this session is our understanding of the numbers down the right hand side - which represent the scanlines sent to the TV. The diagram shows a valid NTSC TV frame - and thus it consists of 262 scanlines. A PAL diagram would consist of 312 scanlines - and the inner 'picture' area would increase from 192 lines to 242 lines.

Let's go from the top. The first thing that the TV needs is a 'reset signal' to indicate to it that a new frame is starting. This is the 3-scanline section at the very top of the frame. There are special ways to trigger the TIA to send this signal, but we're not going to have to worry too much about understanding that - just about every game does it exactly the same way - all we need to remember is that the first thing to send is that reset trigger (called VSYNCH).

TVs are not all made the same. Some cut off more of the picture than others, some show wider pictures, some show taller pictures, etc. To 'standardise' the picture, the diagram shows the recommended spread of valid picture lines, surrounded by blank (or 'overscan') lines. In this case, there are 192 lines of actual picture. We don't *HAVE* to stick to this - we could steal some of the lines from the vertical blank section, and some from the overscan section, and increase our picture section appropriately.

As long as our total number of scanlines adds up to 262 for NTSC TVs (or 312 for PAL TVs), then the TV will be able to display the frame. But remember, the further we get 'out of specs' with this method, the less likely it is that ALL TVs will show the picture section in its entirety.

OK, let's march through the numbers on the right side of the diagram.

* 3 Scanlines devoted to the vertical synchronisation
* 37 scanlines of vertical blank time
* 192 (NTSC) or 242 (PAL) lines of actual picture
* 30 scanlines of overscan

Total: 262 scanlines (NTSC) or 312 scanlines (PAL), constituting a valid TV frame. You send the TV this, and it will be a rock-solid display.

One interesting aside: if you send a PAL TV an *odd* number of scanlines, it will only display in black and white. I don't know the exact reason for this, but it must be to do with where/when the colour signal is encoded in the TV image, and where the TV looks for it. So remember, always send an even number of scanlines to a PAL TV.

You *can* send frames with different numbers of scanlines. That is, 262 and 312 are not totally immutable values. But if you do vary these numbers, it is highly likely that an increasing number of TVs - the further you deviate from these standards - will simply not be able to display your image. So, although you *can*... you shouldn't.

Fortunately, emulators available to us today are able to show us the actual number of scanlines which are being generated on each frame. This must have been quite a challenging task for early '2600 programmers - nowdays its quite easy to make sure we get it right.

Well, now we have all the knowledge we need about the composition of a TV frame. Once we know how to make the TIA generate its reset signal at the top of the frame, and how to wait the correct amount of time to allow us to correctly generate the right number of scanlines for those other sections, we will be able to design our first 'kernal' - the bit that actually 'draws' the frame.

When we have our kernel working, there's not much more to a '2600 game other than moving sprites around, changing colours, etc. See you next time.

#2 Happy_Dude OFFLINE  


    River Patroller

  • 4,212 posts
  • Forum Slacker
  • Location:Sydney, Australia

Posted Fri May 23, 2003 11:42 PM

You didn't link to The Dig : Stella Archive Excavation ;)

I think it's a little out of date but theres some good game disassemblies and tools :)

#3 kamakazi OFFLINE  



  • 530 posts
  • Location:Moberly, Missouri

Posted Wed Mar 26, 2008 12:32 AM

I know that this may sound crazy...but i just now found this information. For years, Atari has always puzzled me as to how the 2600 works. After reading these tutorials, I can honestly say that you and those who have programmed the 2600 including those during its heyday are by far the most talented people out there. I'm learning and very interested! Maybe I can fullfill my lifelong goal of creating a 2600 game. I already did an 800 game in AtariBASIC.

I'm hooked! I know nothing of assembly...but this makes me want to learn. Thank you.

#4 O'Bobson OFFLINE  


    Combat Commando

  • 5 posts
  • Location:London

Posted Sun Aug 1, 2010 4:48 PM

Just wondering, would it be possible to make a widescreen game?

#5 SeaGtGruff OFFLINE  



  • 5,566 posts
  • Location:South Carolina, USA

Posted Sun Aug 1, 2010 10:57 PM

Just wondering, would it be possible to make a widescreen game?

You can't change the basic signal being sent to the TV, so you can't make a "true" widescreen game. However, (most? all?) widescreen TVs let you horizontally stretch a 4:3 picture to fill the 16:9 screen, so you could design the graphics in a game to look "correct" when the picture is stretched horizontally.


0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users