Wednesday, March 1, 2017

Interceptor: another 10-Liner BASIC Game

My second entry to the 2017 10-Liner BASIC Game competition is an homage to Interceptor developed by Tomohiro Nishikado (of Space Invaders fame) and produced by Taito in 1976. I first learned of Interceptor while researching the games listed in the Chronology from the Ernst Cline novel Armada. I was fascinated to learn Interceptor is almost lost to time. There might be a couple machines still floating around, but no one has yet to capture the schematics needed for MAME emulation. In the original Interceptor, you are flying a fighter aircraft chasing down enemy planes. The planes appear to come in singles or pairs and can move in depth as well as x-y coordinates. You use the joystick to move them into your targeting retical and fire. The original machine uses a blue-and-white display with a plastic overlay for the cockpit framing. I hope to capture this look in the BASIC version, although the planes come in singles and there's no animation for the projectiles. Find it over on GitHub.

If you've ever played the original Interceptor arcade game, please leave a comment below about your experience.


Usually when I write these BASIC games, I save the detailed graphics for last. I start with just blocks for the sprites and don't spend too much time initially on the appearance. Rather, I try to nail down the game logic first, then polish it up. This time, I did it backwards. The look was most important to get right first; then, the logic would fit in the rest of the allowed code space. This turned out to be a challenge - at one point 6 lines were dedicated to set up, which is too much. I finally got the setup (screen drawing, sprite definition, initialization, etc.) down to four lines in the final version.


From an online video, it appears the game is the familiar blue and white motif of Atari's graphics 0 and 8 modes where pixels are one television scan line tall and one-half color clock wide. The plastic overlay is a darker blue or black color. The timer and score are displayed in large text at the bottom with a dark blue background. So in my version, I wanted three colors: light blue field, dark blue border, and white sprites and text. This led me to choose graphics mode 7, which is half the resolution (two scan lines by one color clock). I tried graphics 15, which has one-scan-line vertical resolution and is available on the 800XL, early on but concluded the extra resolution didn't add to the visual quality of my limited version. I also use double-line double-wide player sprites, which match the graphics 7 resolution. Only using half the vertical resolution in graphics 7 vs. 15 also saved on characters and commands in the code.

To simplify the game, all the enemy planes fly solo with no wingmen There are up to 3 planes on the screen at one time, one each flying left, right and vertical. This uses three of the four sprites. The fourth player is an explosion graphic that is switched in when you score a hit. To create the explosion, I took a technique from Yars Revenge to create a random pattern without storing the data: point to a location in memory that already has data (e.g., into the code itself). I point to location 95 for 17 bytes that contain a bunch of OS registers. (This technique is described in the great book Racing the Beam about the Atari VCS platform.) The biggest sacrifice made, due to both line count and speed limitations of BASIC, is the drawing of the projectiles. In the original, these are rapidly moving small lines. In mine they are solid lines. I tried some animation, but it took up too much code space. There might be some optimization that can be done, but I feel it works. After all, the BASIC version is humble nod to the original.