Our final project is a portable, dedicated PONG2 video game unit for use with a home television.
PONG, a video game that simulates a game of Ping-Pong between two players, has a long and pervasive history, and is said to be the first video game ever created. For our final project, we decided to pursue PONG with a twist. We designed and constructed a dual player mode, two-dimensional PONG unit. This unit sends a black and white NTSC video signal to a television and includes two separate control units for each player. The unit itself features simple ball movement sounds during game play. The control pads include a linear position slider and a knob to control y- and x-axis movements of the PONG paddle, as well as an LED scoring and winning indicator. The game boasts both a two-player mode and a score-adaptive AI single-player mode, each with increasing levels of difficulty as the game progresses.
PONG, a video game that simulates a game of Ping-PONG between two players, has a long and pervasive history, and is said to be the first video game ever created. This game puts two players head-to-head on a PONG “table” using their home television. In the game the players try to score points by getting a bouncing ball past their opponent while preventing their opponent from doing the same to them. Once a player amasses a pre-set number of points, that player is declared the winner of the game.
For our final project, we decided to pursue PONG with a twist. Instead of lateral (when facing the opponent) paddle movement, our game involves movement along two axes, allowing a player to paddle the ball further up the court. This adds difficulty, increases speed of game play, and adds countless possibilities for ball movement.
This project is a combination of hardware and software design. Hardware involves a digital-to-analog converter to generate the NTSC video signal, microcontroller hardware timers to maintain this signal timing, analog-to-digital conversion of four independent user inputs, and the fabrication of the unit prototype board and two independent control pads.
The MCU software was coded in C, and much of the code length accounts for video signal generation. Our software design controls the look and feel of the game on the screen, interpretation of ADC results from the user controls, game flow, level progression, and hit/win detection, sound and LED interactivity, and a simple, but fair AI scheme for single-player mode.
Much of the MCU computing power and memory is dedicated to producing accurate video signal timing while storing, updating, and blasting out pixel graphics for each frame. Great care was taken in coding the game software, AI, and controller ADC conversions such that it would not adversely affect critical video timing.
User-friendly interaction and paddle responsiveness is a key feature in our design. To accomplish this, we soldered independent controller pads for each player. With a total of four potentiometers controlling the x- and y-positions of each paddle, we required four pseudo-continuous analog-to-digital conversions. The challenge was to integrate these conversions into the video code without causing flicker or tearing. Eventually, we chose to initiate conversions in a round-robin style, while opting to sample the horizontal movement more frequently for a more eye-pleasing effect.
NTSC (National Television System Committee): We are utilizing the NTSC standard in order to output a video signal to any black and white NTSC-compatible consumer television set. Our signal will be in the form of a single coaxial RCA output, operating at an NTSC-specified 60 Hz vertical sync and 15.6 kHz horizontal sync, and voltage levels 0.0V sync, 0.3V black, and 1.0V white.
Patents, Trademarks, and Copyright
PONG is a registered trademark (USPTO Registration 2611782) used to represent a game first published and licensed by Atari, whose more than 75 game brands were purchased by Hasbro Interactive in 1998. We believe that our implementation of the PONG idea, which includes a virtual ball and two opposite paddles, can be considered fair use. This project is for educational purposes and will not be used for profit nor will it be publicly displayed, and we are claiming no credit to the intellectual property of the original PONG design. The final code, along with this full report and disclaimer, may be publicly available online for educational use only.
Our program begins with the foundation of NTSC standard video signal generation, explained in the Standards subsection of High Level Design. To create a visual image, the microcontroller stores a digital field array of pixels 128 wide by 100 tall and can be updated using line, point, and text routines, each with the capability of drawing, erasing, or XORing the current value. The updating occurs during the end of frame time of, at most, 3.81 ms, during which we must also fit code execution for the game and its major routines. All of our game code exists after video line 231, when the microcontroller is sending the end of frame blanking signal to the television.
The main game board, center line, and static information is generated during the initialization sequence. The main game code, within line 231, is broken into two major sections, GameStart = 0 and GameStart = 1. If GameStart = 0, the game is not in play, and is waiting for user input to begin. During this time, the user may choose to switch between two-player or single-player mode, indicated on screen by “P2” or “AI” in the lower right corner. If the user presses the start button, “READY” appears on the screen, along with a 3, 2, 1 countdown, and the game begins. Initial ball position and direction (NW, NE, SW, or SE) is randomized using a simple overflowing character within the timer.
During game play, the ball is drawn and erased using the video_pt XOR routine. Due to a presumed memory issue of unknown origin, the microcontroller may only handle four to five line draws during a single iteration. Therefore, some erasing procedures, such as erasing the old paddle positions, were implemented using an interleaving every-other-frame scheme. The ball bouncing was handled using absolute positions of the wall, and positions of the current paddles. A score is awarded to a player when the opponent allows the ball to travel past their paddle. We encountered a challenge when implementing these scoring and bouncing algorithms in conjunction with the interleaving scheme of paddle drawing and erasing, as the ball would pass through the paddle if horizontal movement was too fast. We countered this effect by checking to see if the ball was approaching the surface of the paddle within the height boundary of the paddle itself. If so, the ball position was set to move away from the paddle, and the horizontal position was set to just in front of the paddle. This allowed for smooth game play and added the ability to “push” the ball toward the center of the court, an intuitive new dimension to game strategy.
Next, we added various game levels. We chose to base the levels on cumulative score. The first of five levels gives each player a 30 pixel high paddle. As the cumulative score hits 10, the paddle sizes are reduced by 5 pixels. Thereafter, each increase in 5 cumulative points shaves off 5 pixels in paddle size. By level 5, each player has just a 10 pixel high paddle, resulting in a more challenging and interesting game. Once the total game points reaches 35, the game is over and the winner is prominently displayed. Any user may now press the New Game button to reset the scores and start a new game.
Lastly, we implemented a simple artificial intelligence to take over player 2 during single-player mode. The AI follows the ball based on its relative vertical position to the paddle midpoint, but starts off very slow. As the game levels increase, the AI gets progressively faster and more responsive. At the highest level, the speed of the AI paddle nearly matches the vertical speed of the ball. During AI play, the player 2 paddle is kept at the right wall.
We added two interactivity and user experience features that are not part of the core game structure. First, a bright green LED is lit on a player’s game pad when he or she scores against the opponent. Second, every time the software registers a ball bounce off of the top or bottom game court walls, or off of a user’s paddle, an output pin is toggled to drive a clicking sound through a piezo speaker discussed in more detail in Hardware.
The first component is a digital-to-analog converter, which takes the digital video signals from PD.5 and PD.6 and converts them through a simple resistive network to create the NTSC standard positive component of the RCA output. See a schematic of this network in the Schematics appendix.
Next, we utilized the integrated 10-bit analog-to-digital converter to sample four signals that will serve as the two-dimensional player inputs. By using 4 channels (PA.0 .. PA.3) and using the left-shifted high 8 bits, we achieved very responsive game play for two players in two dimensions. Due to timing constraints, we could not force four conversions per video frame. Instead, we sampled player 1 and player 2 vertical paddle movement once per four frames, or every 66.7 ms. To achieve a more user-friendly rendering of the paddle movement, we chose to sample horizontal movement every other frame, or every 33.3 ms.
The player interface was designed to be comfortable and intuitive. We constructed two prototype game pads on separate mini solder boards. Each board contains two linear-travel sliding potentiometers mounted vertically to control the up and down motion of the user’s paddle, a Panasonic single-turn knob potentiometer to control horizontal movement, and a green LED to serve as a score and win indicator. Power, ground, two analog signals, and LED leads were neatly wound into a cord. Spare socket pins were soldered to the game pad leads to create a convenient male header, which fit into a matching female header soldered to the main board.
Simplicity was maintained in the game interface. Two momentary-action buttons were used to implement Start/New Game (PD.1) and Single-/Two-Player mode (PD.3) functionality. Switching between Single- and Two-Player mode required state-machine button debouncing, whereas the Start/New Game button is polled only until it is activated the first time.
As an addition to the player experience, we decided to implement the classic PONG ball bouncing sound. Each time the ball bounces off of the court wall or a player’s paddle, a piezo speaker mounted on the main board is alternately sunk from Vcc and sourced back to Vcc (PA.7) to create a gentle clicking sound.
As a starting point for our project, we used Bruce Land’s sample video generation code, available in its original form at http://instruct1.cit.cornell.edu/courses/ee476/video/Video32v3.c, which was made available for the fourth structured lab assignment, the television oscilloscope. Our code consists of new variable declaration, definitions, additions to the initialization routine, and the game engine placed during the end of frame time.
When adding sound for an improved, immersive player experience, we anticipated the bouncing noise to be a louder clicking or popping sound. After experimenting with various hardware configurations and software implementations, we chose to use a single port pin to drive the speaker in an on/off toggle fashion to make the clicking sound. Since a port pin is able to sink more current than it can source, we used the pin to sink the speaker current, with its positive lead tied to Vcc. An alternative configuration for a louder popping sound would be to drive the speaker straight from power to ground using a BJT TIP31 toggled by the port. Although this would have been a good choice for the often noisy lab environment, during quiet times, our current-sinking pin configuration is more than sufficient.
Speed of Execution and Accuracy
The speed and accuracy of our codes was sufficient to meet the NTSC video generation standards and produce a signal with no tearing, flickering, or other video artifacts.
Our goal was to provide a game unit that would meet or exceed the safety of a common video game console. Users ideally will not have access to the internal components of the game unit. After household AC voltage is converted to DC by the adapter there is no risk of electric shock. The user will need to exhibit reasonably safe behavior around the television set, the safety considerations of which are the responsibility of its manufacturer and the end user.
All interaction between the users is handled either through the two push buttons on the base unit, used to select game options, and the two controllers, which the players use during the game to control their respective on-screen paddles.
Of the two buttons on the base unit, one is used to choose between the one and two player games, and the other is used to start the game.
The controllers consist of two potentiometers, which the player uses to control their on-screen paddle, and an LED, which lights up when the player either scores a point, or wins the game. The slide potentiometer is used to control the motion of the paddle in the up/down direction and the twist potentiometer is used to control the paddles motion in the left/right direction. A full sweep of the slide potentiometer will move the paddle through its range of vertical motion, which is from the very top to the very bottom of the screen. A complete turn of the twist potentiometer will move the paddle completely through its horizontal range of motion, which is from a few pixels in front of the back boundary to approximately ¾ of the way across its half of the screen.
The usability of our design is very high. Players, as described above, interface with the game using two potentiometers, which are arranged in an intuitively clear manner and which provide visual, on-screen confirmation of motion. The buttons provide click-force feedback and on-screen visual confirmation of use.
The only user limitations on use are reasonable tactile function of the hands, capable of manipulating a slider and a twist knob, as well as moderate visual acuity, capable of resolving a 128×100 black and white screen.
True portability was achieved by the post-demo addition of a 9V battery DC adapter and an RCA video output header.
Results vs. Expectations
Our results meet and exceed every benchmark we proposed. We fully implemented an intuitive and user friendly two player PONG game, as well as a single player version. On top of the traditional PONG design, we added a second dimension of possible motion, to expand upon the complexity and excitement of the game. We implemented sound, through a piezo speaker, which produces a bouncing noise whenever the ball “bounces” off an on-screen wall. We also implemented player specific LEDs that light up when the player it is assigned to scores or wins the game. We also implemented variable levels of difficulty in both the single and two player games. As the score passes certain pre-set benchmarks the paddles become smaller and in the single player game the AI moves faster and more effectively.
NTSC (National Television System Committee): We utilized the NTSC standard in order to output a video signal to any black and white NTSC-compatible consumer television set. Our signal is in the form of a single coaxial RCA output, operating at an NTSC-specified 60 Hz vertical sync and 15.6 kHz horizontal sync, and voltage levels of 0.0V for sync, 0.3V for black, and 1.0V for white.
PONG is a registered trademark (USPTO 2611782) used to represent a game first published and licensed by Atari, whose 75+ game brands were purchased by Hasbro Interactive in 1998. We believe that our implementation of the PONG design, which includes a virtual ball and two opposite paddles, can be considered fair use. This project is for educational purposes and will not be used for profit nor publicly displayed, and we are claiming no credit to the intellectual property of the PONG design. The final code will be publicly available online for educational use only.
Video generation code available from Professor Land was used, as outlined in the Software Details subsection of Program Design.
During our design we strove to always meet our ethical obligations, as specified by the IEEE code of ethics. Highlights of these ethical considerations include:
We have openly and publicly claimed responsibility for making our engineering decisions fully consistent with the safety, health, and welfare of the public and will promptly disclose any facts that come to our attention that may posed a danger to the public, as we are doing here in this report.
All of our claims and estimates have been firmly honest, reasonable, and consistent with all data available to us, as can be seen from the consistency from our project proposal to our progress reports and finally to our final design and beyond.
We have maintained our technical competence as well as expanded our technical understanding through this project and have only undertaken technical tasks within our ability to complete in a safe and competent manner as can be seen through our implementation of what we learned through our semester of lab work and our implementation of features beyond what we were taught.
We sought, accepted, and offered honest criticism as shown by both our asking for, and providing of, technical advice and help. We acknowledged and corrected errors as shown by the continual improvement of our design based on the suggestions and advice of our teachers and peers.
We assisted colleagues and co-workers in their professional development by assisting them in their technical work throughout this project development period by providing our suggestions and advice whenever it was appropriate.
Atmel AVR Mega32 MCU
Position Potentiometers (2)
Knob Potentiometers (2)
LM340T-5.0 voltage regulator
12V DC power header
16 MHz oscillator
Various disc-ceramic capacitors
RCA female header
9V Battery to DC converter
$1.60 ($0.80 x 2)
$4.32 ($2.16 x 2) Part No P12338-ND
$1.98 ($0.99 x 2) Part No P3C3503-ND
$1.86 ($0.93 x 2) Part No 401-1011-ND
For more detail: Pong2