skip navigation

HELP SUPPORT THE CHANNEL

Help keep the free Atari 2600 programming episodes and code coming by supporting the channel on Patreon.

Back to Episodes

Drawing a Playfield on an Atari 2600

Description

In this episode we talk using the Atari 2600's playfield pixels. We'll discuss the various intricacies of the registers, how we can mirror the playfield, and look at a demo of the playfield register positions on our screen.

Released:
April 12, 2021

Original Link:
Drawing a Playfield on an Atari 2600

GitHub Link:
s01e04 - Playfield Registers

Subscribe

Introducing the Playfield

Welcome back, everyone! In the last episode, we talked about how the Atari 2600, or more specifically the Television Interface Adapter, creates each frame and the various timings we need to adhere to in order to produce stable video on a CRT screen. We played around with a few TIA registers in order to control the beam and the timing of each scanline. We also used the Colour Background register to set the colour we want the scanline to draw.

In this video, we’re going to build upon this experience and introduce the playfield registers.

Now, I’m going to be honest with you here. Drawing the playfield on an Atari 2600 is interesting, but as we go on, you’ll find that it mostly makes sense when you think about it in the context of early games like Pong: two paddles, one on each side, and a bouncing ball.

Now remember, this is 1977. There are no 4K monitors with 144 Hz refresh rates. There aren’t even CGA monitors; those were created in 1981!

All we have is our CRT television, and it might not even have colour. The dimensions of our playfield are very modest at 40 pixels wide by 192 pixels high. That’s it. That’s all we get to craft our playfield. But wait, there’s more.

The Playfield Registers

The playfield is actually only 20 pixels wide, and the height? It’s actually just one scanline! So maybe by now you’re wondering why there’s a dotted line down the middle of our graphic if there are only 20 pixels. That’s because the right side of the screen is just a copy of the left! Fair enough, it can’t get any worse than this, right?

Our 20 pixels are represented as 20 bits spread across three registers on the TIA. We have PF0, PF1, and PF2. Each of these registers holds a byte value, or eight bits. However, PF0 only uses the four high bits. The low four are dropped. You can set them and forget them. They’re gone. So in total, with PF1 and PF2 together providing 16 bits and PF0’s four high bits, we get our 20 bits, or should I say our 20 pixels.

So that’s a little odd, but we can live with it: three registers representing 20 pixels on the left side of the screen and duplicated again on the right, with pixels that will keep drawing on each scanline until we change them. At least it’s simple enough to set where we want pixels to be drawn. We just set the bits in the order we want them to appear on the screen, right? Not even close! You see, the PF0 and PF2 registers are drawn to the screen in reverse order.

As to why these two registers are drawn backwards, I really don’t know, and I haven’t been able to find a full explanation. But if you know, please comment below and fill us in!

So here we are with our three registers and duplicated sides. We can see here that the PF0 pixels will start drawing from the far left side of the screen and then be duplicated on the right side, starting from the middle. Here’s something we can all be thankful for: the playfield registers are actually drawn in order, so PF1 is drawn right beside PF0, and then comes PF2.

Also, the CTRLPF register allows us to change the right half of the screen from a straight copy of the left side to a mirror image of the left. So that’s a huge improvement.

Creative Possibilities

Now, I’ve poked fun at the procedures for drawing a playfield on the Atari 2600, and I’ve probably made it seem that it’s almost impossible to create an interesting, dynamic playfield with the tools we’re given, but that’s just not the case. With just a quick glance at the Atari 2600 library, you can see how creative and diverse the developers can be. Remember, you can change the pixel layout and colour for every scanline, and even while a scanline is currently being drawn. Add to that some background colour manipulation, and you can create rich and interesting settings for your games.

The sample code provided for this episode is a quick demonstration of the playfield positions that the PF0, PF1, and PF2 pixels occupy. It will first cycle through the positions in normal mode and then again in mirrored mode.

Wrapping Up

As always, you can find the source for the demonstration on our GitHub page, which is linked in the description down below. Feel free to give it a try and see how it works. Once again, I want to thank you for watching and encourage you to join in by liking, subscribing, and sharing this video. If this is your first time here, please check out the other videos in this series.

So what do you think about the PF registers and how the pixels are drawn in reverse for PF0 and PF2? Why are there only 20 pixels when the TIA just drops the low four bits of PF0? If you know, or have any guesses, please leave a comment below.

Thanks for watching, and I’ll catch you next time.

Back to top of page