The screen is shown in the figure below.
X = a white pixel. X is the key pixel.
location of the ball is specified by the location of the key pixel.
The ball can move from -7 to +7 pixels in both the x and y directions, for each screen display (every 1/30 sec.). The ball can travel across the entire screen in about 2.5 sec. When the ball hits a paddle, it moves in the opposite x direction, but continues in the same y direction. When the ball hits the top or bottom of the screen, it reverses its y direction, but continues in the same x direction. When the ball hits the right or left edge of the screen, it goes off the edge and the game ends.
The paddle looks like this:
X indicates the key pixel for the paddle. The paddle is 28 pixels long.
The paddles move at a constant rate of 4 pixels in either or both the x direction and the y direction, depending on the direction the joystick is pushed by the player. The paddles stop at the edges of the game, and do not cross the middle "net."
The screen information is stored in a memory array. The array is 128k bits in size. It can be organized as 256 words (address locations), each 512 bits wide, or 128 k (1k is 1024) words, each 1 bit, or in many other configurations. If the 256 word option is used, the y position on the screen forms the address, and it is 8 bits long, and each word is 512 bits. If the 128k word option is used, the x and y positions on the screen form the17 bit address.The rest of this document assumes that there are 128k 1-bit words in the memory array.
There are several registers that hold current information. Three 17-bit registers hold the key pixel addresses for the paddles and the ball. Two 5-bit registers hold the scores for the two players. Two four-bit registers hold the current x and y velocities and directions of the ball. A single bit indicates whether "right" or "left" serves. There can be other registers depending on how the game is implemented.
There are two 1-bit control inputs to the game: reset and start. The joysticks produce four inputs each to the game, up, down, left and right.
3. Move Ball
4. Move Paddles
5. Check Ball Position
6. Check Paddle Positions
7. Update Score
States 3 and 4 could be combined into a single move state, but have been separated here for clarity. In the same fashion, states 5 and 6 could have been combined.
1. In the Reset state, all the registers get set to their initial values. The paddles are put into the middles of the screen sides, and the ball is put onto the paddle of the side that won the last game.
2. The start button is pressed to enter the serve state from the reset state, and the ball is positioned to move off the paddle at x and y velocities set at random. Then the game goes to the Move Ball state.
3. In the Move Ball state, the ball is moved the increment specified by the x and y velocities, and the game moves to the Move Paddles state.
4. In the Move Paddles state, the paddles are moved a single increment in the x and/or y directions, depending on the position of the joystick, and the game goes to the Check Ball Position state.
5. In the Check Ball Position state, the ball position is checked to see whether the direction needs to change or whether the ball has gone out of play to the left or right. The position of the ball is updated accordingly. The game then goes to the Check Paddle Position state.
6. In the Check Paddle Position state, the paddle position is
checked to see whether the paddle has run into the net or out of play.
The paddle position is updated accordingly. The game then goes to
either the Reset state, the Move Ball state or the Update
Score state, depending on whether reset has been pushed, the ball has
gone out of play (Update Score), or play continues (Move Ball state).
Then, the game goes to the Start state.