Useful
Inventions
Favorite
Quotes
Game
Design
Atari
Memories
Personal
Pages

Atari 2600 Programming for Newbies

Session 7: The TV and our Kernel

By Andrew Davie (adapted by Duane Alan Hahn, a.k.a. Random Terrain)

As an Amazon Associate I earn from qualifying purchases.

Page Table of Contents

Original Session

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

 

Let's take another look at the diagram with the timing information and the Pitfall! image inside.

 

 

 

 

 

 

 

 

Numbers Across the Top

Your understanding of the numbers across the top should be good, but we'll briefly revisit what they mean, just to make sure.

 

There are 228 TIA color 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 color clock for the TIA's first visible pixel on the screen is cycle #68. We should understand this timing fairly well by now.

 

 

 

 

Numbers Down the Right Side

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

 

 

 

 

Reset Signal

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 thatjust about every game does it exactly the same wayall we need to remember is that the first thing to send is that reset trigger (called VSYNC).

 

 

 

 

Vertical Blank and Overscan

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 'standardize' 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 thiswe 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.

 

 

 

 

Right Side Number Recap

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

 

3 Scanlines devoted to the vertical synchronization.

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.

 

 

 

 

Scanlines and PAL TV

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 color 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.

 

 

 

 

Scanline Standards

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 TVsthe further you deviate from these standardswill 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 programmersnowadays its quite easy to make sure we get it right.

 

 

 

 

 

Summary

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 'kernel'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 colors, etc. See you next time.

 

 

 

Other Assembly Language Tutorials

Be sure to check out the other assembly language tutorials and the general programming pages on this web site.

 

Amazon Stuff

 

< Previous Session

 

 

Next Session >

 

 

 

 

Session Links

Session 1: Start Here

Session 2: Television Display Basics

Sessions 3 & 6: The TIA and the 6502

Session 4: The TIA

Session 5: Memory Architecture

Session 7: The TV and our Kernel

Session 8: Our First Kernel

Session 9: 6502 and DASM - Assembling the Basics

Session 10: Orgasm

Session 11: Colorful Colors

Session 12: Initialization

Session 13: Playfield Basics

Session 14: Playfield Weirdness

Session 15: Playfield Continued

Session 16: Letting the Assembler do the Work

Sessions 17 & 18: Asymmetrical Playfields (Parts 1 & 2)

Session 19: Addressing Modes

Session 20: Asymmetrical Playfields (Part 3)

Session 21: Sprites

Session 22: Sprites, Horizontal Positioning (Part 1)

Session 22: Sprites, Horizontal Positioning (Part 2)

Session 23: Moving Sprites Vertically

Session 24: Some Nice Code

Session 25: Advanced Timeslicing

 

 

 

 

Atari 2600 BASIC

If assembly language is too hard for you, try batari Basic. It's a BASIC-like language for creating Atari 2600 games. It's the faster, easier way to make Atari 2600 games.

Try batari Basic
THE COURAGE TO FACE COVID-19 2000 Mules DVD The Great Awakening

Back to Top

 

Disclaimer

View this page and any external web sites at your own risk. I am not responsible for any possible spiritual, emotional, physical, financial or any other damage to you, your friends, family, ancestors, or descendants in the past, present, or future, living or dead, in this dimension or any other.

 

Use any example programs at your own risk. I am not responsible if they blow up your computer or melt your Atari 2600. Use assembly language at your own risk. I am not responsible if assembly language makes you cry or gives you brain damage.

 

Home Inventions Quotations Game Design Atari Memories Personal Pages About Site Map Contact Privacy Policy Tip Jar