Pong in Hardware… Virtually [Hackaday]

View Article on Hackaday

We are big fans of the Falstad circuit simulator. Sure, it isn’t perfect, but there’s nothing else like it when you want to whip up a simple circuit. But we were blown away when we saw a more or less complete hardware implementation of Pong in Falstad. No kidding. Starting with the original schematics, there are multiple pages that show each sub-circuit and even a playable subset that you can play the game in your browser.

But wait… you probably noticed there’s no CRT display in the simulator’s component menu. That’s true, there isn’t. However, you can write JavaScript to interact with a running simulation, so the display is a simple bit of JavaScript that samples signals at predetermined points and does the appropriate drawings. There’s even audio output for the sound effects, although that is built into the simulator.

As an example of how the display works, look at this snippet:


// called every timestep, which is 6 nanoseconds of game time.
// we do as little work in here as possible.
function didStep(sim) {
   var c = clk.getVoltage();
   if (c == lastclk)
      return;
   if (c>2.5) {
// positive clock transition, increase x
   x++;
   if (x == 375) {
   x = -80;
   y++;
   if (sim.getNodeVoltage("VBLANK") > 2.5) {
// if we're in vertical blank, set y to 0
   y = 0;
   clearedY = -1;
   sim.setExtVoltage("PADTRIGGER1", 5);
   sim.setExtVoltage("PADTRIGGER2", 5);
}

You can see the whole thing by simply viewing the page source in your favorite browser.

Not only is this very educational if you ever wanted to know how something like this works, but it is also a great illustration of what you can do with the Falstad simulator and some Web page work. It gives us a lot of ideas. If you are interested in the Pong circuit itself, we really enjoyed how each page broke down a part of the circuit and explained it along with the relevant simulation.

Don’t forget you can try Arduino programs out in Falstad. You can even build a simple analog computer.