ASCII Pitfall!

Finally, you can experience David Crane’s classic Atari 2600 video game blockier than ever before. Warm up your Microsoft Windows Command Prompt window to prepare for this text mode port. This grandfather of all side-scrollers finally features actual scrolling—2-plane parallax scrolling to be precise. It’s time to return to jungle.

Help Pitfall Harry collect all 32 treasures in under 20 minutes. Avoid life threatening rattlesnakes, crocodiles, scorpions, and fire. Note Harry can safely step on a crocodile’s head as long as its mouth is closed. In fact, Harry cannot be eaten as long as he stands on a crocodile’s eyes. When available, use a vine to swing over quicksand, tar pits and water holes. Rolling logs are not life threatening, but touching them will remove precious time and points.

ASCII Pitfall! ASCII Pitfall!

Prerequisite: .NET 3.5


D = Jump
Arrow keys = Move
Alt+Enter = Toggle full-screen mode
Esc = Quit

ASCII Pitfall! contains the same map as the original game. To collect all the treasures in under 20 minutes—and yes indeed, there is an ending scene—Harry must traverse the jungle in a particular path. A true enthusiast would carefully record a map of the entire jungle and underworld and plot out an optimal route. But, a more efficient (lazy) gamer can take advantage of this map (mirror) created by Ben Valdes. Harry’s position is displayed in the upper-left corner of the screen. Note that Harry skips 3 screens at a time while in the underworld (i.e. underground passages are shortcuts). An even more efficient (lazier) gamer can take advantage of the hints hidden in the game. Start the game by going right. You’ll collect your first treasure on screen 7. Along the way, you’ll encounter openings to the underworld looks like this:

don't enter

Avoid those ladders. However, at screen 12, you see an opening that looks like this:


Drop down and head left, jumping over the scorpions. Keep heading left for the remainder of the game. Any time you see one of those different ladders, it’s an indication to drop down into the hole and use the tunnel as a shortcut. Sometimes, you’ll exit a tunnel and the ladder will look a little different:


That type of ladder indicates that there is actually a treasure 2 or 3 screens to the right. When you see that kind of ladder, go right to grab the treasure and then continue going left.

The ladder styles will save you the effort of memorizing the map or even referring to map while playing.

ASCII Pitfall! was written in C# 3.5. It takes advantage of Jim Mischel’s console library. Most of the graphics were borrowed from the Atari 2600 disassembly (mirror). Feel free to hack up the source. Remove the strong name key file and the certificate from the solution to avoid being prompted for a password during compilation.

If you were ever curious of how the game generates the map, here are secrets: Pitfall! programmer David Crane used a type of random number generator called a linear feedback shift register (LFSR). In this case it’s an 8-bit LFSR capable of producing a pseudo-random sequence of numbers inclusively between 1 and 255. The bits of each value are decoded to produce one screen of the map. The sequence begins with the (possibly arbitrarily selected) seed value of 0xC4. To generate the next value in the sequence, bits 3, 4, 5 and 7 of the current value are XOR-ed together and stored in a temporary bit-sized variable. Then, the current value is left-shifted such that the most significant bit is discarded and the XOR-ed result is shifted into the lowest position:

        int bit0 = 1 & (random >> 0);
        int bit1 = 1 & (random >> 1);
        int bit2 = 1 & (random >> 2);
        int bit3 = 1 & (random >> 3);
        int bit4 = 1 & (random >> 4);
        int bit5 = 1 & (random >> 5);
        int bit6 = 1 & (random >> 6);
        int bit7 = 1 & (random >> 7);

        int temp = bit3 ^ bit4 ^ bit5 ^ bit7;

        random = 0xFF & ((random << 1) | temp);

Note that the original bit 7 is lost; however, bits 3, 4 and 5 are preserved as new bits 4, 5 and 6 respectively. Since a ^ b ^ a = b, you can recover the lost bit 7, by XOR-ing the new bits 4, 5, and 6 against the new bit 0. Once it’s recovered, you can find the prior value in the sequence by right-shifting such that the least significant bit is dropped and the recovered value is shifted-in as the most significant bit.

Pitfall! took advantage of the reversibility of this LFSR. If you moved a screen to the right, it advanced the sequence. If you moved a screen to the left, it reversed the sequence.

David Crane chose this particular LFSR (most likely from a table in a book) because it produces a sequence of numbers with a period of 255. Meaning, the sequence doesn’t repeat until it covers 255 unique values. That’s the best that can be achieved for an 8-bit LFSR. This LFSR produces values between 1 and 255 inclusively. The value 0 is not part of the sequence, since XOR-ing 4 zeros together produces zero (i.e. 0 in yields 0 out). Also, note that if a different seed value is used, it does not produce a different map. Rather, it just offsets the repeating sequence. Changing the seed simply alters Harry’s starting position.

To decode one of the pseudo-random values into a scene, bits 5, 4 and 3 are used determine the scene type:

  000 = Hole with ladder
  001 = Hole with ladder surrounded by 2 holes without ladders
  010 = Tar pit with vine 
  011 = Quicksand with vine
  100 = Crocodile pit (plus a vine if bit-1 is 1)
  101 = Shifting tar pit with treasure
  110 = Shifting tar pit with vine
  111 = Shifting quicksand

If the scene contains a treasure, bits 1 and 0 determine the type of treasure:

   00 = Money bag
   01 = Silver brick
   10 = Gold brick
   11 = Diamond ring

If the scene contains a ladder, the underworld beneath contains a wall, forcing Harry in 1 direction. The wall will appear either on the left of the scene or the right of the scene determined by bit-7 (0 = left, 1 = right). Scenes without ladders contain no walls beneath, but they do contain a scorpion instead.

Note that the tunnel system manifests itself as a result of the scene type, the positions of the walls and the fact that Harry visits every third screen while moving around a tunnel. Dave Crane never explicitly picked which ladders would connect to each other via a tunnel. Rather, he played around different possible mappings until he discovered a satisfactory tunnel system. Many of the tunnels only have an entrance and fail to have an exit. That’s actually a feature since the game effectively takes place in a maze with dead ends.

If the scene doesn’t contain a treasure and it doesn’t contain crocodiles, then it contains objects determined by bits 2, 1 and 0:

  000 = 1 rolling log
  001 = 2 rolling logs close together
  010 = 2 rolling logs spaced apart
  011 = 3 rolling logs
  100 = 1 stationary log
  101 = 3 stationary logs
  110 = Fire
  111 = Rattlesnake

There are 4 tree patterns for the background determined by bits 6 and 7.

ASCII Pitfall! is a lot easier than the original Atari 2600 Pitfall!. It presents you with 5 lives instead of 3 and the obstacles are a lot easier to master. If you follow the suggestions above, you can readily obtain all 32 treasures. Good luck and watch out for those giant scorpions.