CS 0447 – Project 2: Breakout

Due: Tuesday, July 9, 2013

Description

Many video games of the past were programmed directly in assembly language. In this project, we’ll be taking an early Atari video game, Breakout, and making a version in MIPS under MARS.

If you are unfamiliar with the game, you might want to look at the Wikipedia article, http://en.wikipedia.org/wiki/Breakout_%28arcade_game%29 or find a modern adaptation (or emulated old version) to try it.

The basic idea is that a large rectangle of bricks is at the top of the screen and you must break it by bouncing a ball with a paddle into the bricks which disappear when the ball hits it. Your paddle is at the bottom of the screen.

If you miss the ball, the ball resets, you lose a life, and you continue on. If you run out of lives before destroying the rectangle, the game is lost. If the rectangle is entirely removed, you win.

Tools

After your first project, you might be wondering how to get MARS to make something as awesome as a video game. For this, we can thank several graduate students and Dr. Childers for a modified version of MARS that contains a LED display which we can control. The display is an array of pixels (64 x 64) and each LED can be one of 4 colors: off (black), red, green, or yellow/orange.

In later courses, we’ll discuss two strategies for talking to I/O devices from machine instructions. In this case, the pixel display is memory-mapped. This means that a byte in our address space is reserved for each pixel, and that the content of that array is reflected in the output of our display. Learning about the memory-mapped I/O is not the core of the project and so we provide get and set methods for manipulating a pixel at a specified location.

Additionally, the LED display has support for a key pad. It can handle either button presses on the dialog box or you can use the keys on your keyboard (WASD).

You will need to download this special modified version of MARS from the class webpage in order to do this project.

When you wish to use it, go into the tools menu and select “Keypad and LED Display Simulator”. In the window that appears, click “Connect to MIPS”. Then run the program in MARS using the green play button.

Game Requirements

  1. A paddle is initially 10 yellow LEDs. It starts at the center of the LED display, 8 rows from the bottom of the screen.
  2. A rectangle, 16 bricks wide and 4 bricks high will be placed 10 pixels from the top of the screen.
    1. A brick is a 4x2 rectangle (width x height) of LEDS.
    2. The 4 rows of bricks will alternate colors:

                                                               i.      1st and 3rd rows will be green

                                                             ii.      2nd and 4th rows will be red

  1. For a key press left or right, move the paddle one LED in the appropriate direction
  2. To animate movement, you will turn on an LED in front of the paddle and turn off an LED (set its color to black) at the back.
  3. The ball will initially appear on all resets at a random x coordinate in the first 32 positions, 12 rows above the paddle.
    1. The ball will move down and to the right at 1 LED per update.
    2. The ball will begin to move (the game starts) when you hit the center “b” button.
  4. You will update the position of the paddle and ball every 20 milliseconds.
    1. You can use syscall 32 in MARS to sleep for a specified number of milliseconds.
  5. When a brick is hit, its color is set to black and the ball bounces back towards the paddle from the bottom of the now gone block.
    1. Each destroyed red block counts for one point. Each destroyed green block counts for 2 points.
  6. When the ball bounces off of the paddle, the top or side walls, or a block, use the idea that the angle of incidence equals the angle of reflection. So if a block is moving down one LED and to the left one LED, when it bounces off of the paddle, it should be moving up one LED and to the left one LED.
    1. You may alter the physics so that hitting the ball with different parts of the paddle affect its angle or speed differently. Make note of that in your submission README file.
  7. A life is lost when the ball is below the paddle. The game resets as per #5 above.
  8. There are 3 lives initially.
  9. When the game ends, the score is printed using the print string syscall.
  10. You must use functions in this project. At minimum you need a function that updates the paddle position, one that updates the ball position, and one that updates wall of blocks. You may use others, but those three are required.
  11. Functions must follow the MIPS calling convention. Use the stack for spills. Use the $a0-$a3 registers for arguments and $v0-$v1 for return values.

Submission

Create a zip file of your source code and a README.txt text file that has your name, your Pitt username and any notes for the TA to help with grading.

Name the file USERNAME-project2.zip

Use the lab submission policies to upload your project.