[Fernando] sent in a tangential project update that uses an ATtiny45 to play Pong on his television. Last time we looked in on his work he had just finished getting the eight-pin chip to display a big number on the TV via the VGA port. This expands on the idea while he continues to wait for parts.
Right now the chip plays against itself, but he’s got one input pin left and we’d love to see a button added for a simple one-player game. We’re thinking the paddle would always be moving in one direction or the other, with a click of the button to reverse that direction. The part that he’s waiting for is a Bluetooth module, which we’d love to see used for 2-player games via a pair of Wiimotes (we’re just wishing at this point and don’t know if that would even be possible). The end goal for the hardware is a Bluetooth connected scoreboard for Android devices.
The code is written in Assembly, and we found it relatively easy to follow what [Fernando] is doing with the game logic. On the graphics side of things he gets away with a 120×96 resolution because Pong is supposed to look pixelated. We love the result, which you can see for yourself after the break.
[youtube=http://www.youtube.com/watch?v=8KlHqu1tnMg&w=470]
If you just have one input free, you could still have an unlimited amount of controllers connected. Just use serial data.
You could even use something like RC5 protocol to pick up the signal from a pair of IR remotes you have kicking around (TV remote versus DVD player remote?).
Although you may need to slow the ball movement down a little.
Please, at least proofread the titles…
Pong, brilliant!
For inputs you could measure the charge and discharge rate of a single capacitor through several resistors connected to switches.
Or through a potentiometer for more authentic control. (Probably harder to do for two players though.)
Amazing! I hope the Bluetooth module won’t come for some time. I’d love to see what else Fernando has got up his sleeve! :-)
Coulden’t he connect some form of real-time clock to the leftover pin and make a pong clock?
+1 for pong clock
in the asm why is nop necessary when in the C no pauses are used?
Perhaps the generated C code is “slow” enough that the NOP isn’t needed?
The nop is to spend a cycle. At 20Mhz 1 cycle will be exactly 0.05us (micro seconds). In the code is used in a lot of places to spent the time evenly specially when a conditional branch happens. If you imagine a code in C like if (a) { do b, c } else { do d, e, f }, in the pong you will find a brxx mnemonic meaning branch if something (equal, less, etc.) that command will use 1 cycle if the condition is false and 2 cycles if its true, so I have to add nops in on side or the other to make it spend exactly the same time at the end of the “if”. In C the code is optimized (no nops), so at the end of the if you will have spent different quantity of cycles depending on the condition, you have no control on the timing which is essential for a VGA application like this. Unless you have a powerful microcontroller and you use the timer interruptions (but the fun of tiny pong is precisely not using a big micro)
Nintendo pads use only one wire for data. Shouldn’t be a problem here. :)
Hey i can’t access his website. Anyone else having the same problem?