skip navigation

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:
https://youtube.com/watch/K3LcLcstZE8

Transcription

Your support is greatly appreciated! https://www.patreon.com/8blit

Welcome back everyone! In the last episode we talked about how the 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 timings of each scanline. We also used the Color 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 a 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’s no 4K monitors, with 144hz refresh rates…. There’s not even CGA monitors… Those were created in 1981! All we have is our CRT television… and it might not even 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 is actually only 20 pixels wide… and the height? It’s actually just 1 scan line! 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 the PF Zero, PF One, and PF Two. Each of these registers hold a byte value (or 8 bits). However, the PF ZERO only uses the 4 high bits. The low 4 are dropped. You can set them and forget them. They’re gone. So in total, with the PF1 and PF2 together providing 16 bits, and the PF ZERO’s 4 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 right side of the screen and duplicated again on the left. 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 PF ZERO and PF TWO 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 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 PF ZERO pixels will start drawing from the far left side of the screen, and then duplicated on the right side, starting from the middle, and here’s something we can all be thankful for. The playfield registers are actually drawn in order, so PF ONE is drawn right beside PF ZERO, and then comes PF TWO. Also, The CONTROL PF 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.

Now, I’ve poked fun at the procedures for drawing a playfield on the 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 2600 library you can see how creative and diverse the developers can be. Remember, you can change the pixel layout and colour for every scan line, and even while a scan line 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 PF ZERO, PF ONE and PF TWO pixels occupy. It will first cycle through the positions in normal mode, and then again in mirrored mode.

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 PF ZERO and PF TWO? Why is there only 20 pixes when the TIA just drops the top 4 bits of PF ZEOR? 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