CS 0447 – Project 2: Kaboom!

Due: Sunday, July 8, 2012

Description

He is ashamed to admit it, but the first video game system your professor played as a small child was the Atari 2600. His favorite game was Kaboom! by Activision, a game in which you caught falling bombs dropped by the nefarious “Mad Bomber” in water buckets.

In his opinion, the catch a falling object in a container genre peaked with Kaboom! In this project, you will recreate a simple version of the game in MIPS.

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

The mad bomber lives in row Y=1 (2nd row) of our display, in the center at X=31. He is a yellow/orange LED which starts moving a random number of pixels to the right when the center button is pressed. Along the way, he drops bombs which fall from row Y=1 towards the bottom of the screen without a change in the X position (they fall straight down). When he reaches as far right as he will go, he reverses direction and randomly moves an amount of spaces to the left, again dropping bombs periodically.

Our hero is a line of 8 green pixels at row Y=62, also initially centered in the display. The line moves one pixel left or right when the corresponding key is pressed. If the green line catches a falling bomb (that is, the position of the bomb when it is at row Y=63 is one of the green pixels of the line), the score is incremented.

Mad bomber

 

Falling bomb

 
If the line misses a bomb, the game resets, and the hero’s bucket is reduced to 6 pixels. A second miss means 4 pixels. A third miss ends the game, and the final score is displayed via the print string syscall.

Hero’s bucket of water

 
 

Figure 1: Kaboom! on the LED Display in MARS

The bombs initially will fall one pixel every 300 ms. After every 16 successfully caught, the time will decrease by 50ms.

The game goes on until lost.

Requirements

  1. The mad bomber must move in alternate directions, starting by going to the right. He will move a random distance between his current position and the edge he is moving towards.
  2. At each pixel, with probability 1/16, he will drop a bomb at his location if one does not already exist at that column.
  3. The bucket will move one pixel in response to an appropriate right or left keypress.
  4. The game starts (new game or missed bomb) when the center b button is pressed.
  5. The mad bomber and bucket start centered in the screen.
  6. The Mad bomber’s position and the bucket’s position will be updated every 50ms.
  7. Animation is achieved by turning on a new pixel and turning off (setting color to 0) a pixel you no longer want to see.
  8. A bomb’s position will be updated every 300ms initially, then for each 16 successfully caught, 50ms faster.
  9. You can use syscall 32 in MARS to sleep for a specified number of milliseconds.
  10. The bucket is initially 8 green LEDs. On the first missed bomb, the game resets (except for the score) and the bucket is reduced to 6 LEDs. One more miss makes it 4 LEDs. Another miss ends the game.
  11. When the game ends, the score is printed using the print string syscall.
  12. Each caught bomb counts for one point.
  13. You must use functions in this project. At minimum you need a function that updates the bombs’ positions, the bucket position, and the bomber position. You may use others, but those three are required.
  14. 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

When you are done, create a zip file containing your MIPS code and upload it through the class submission website at http://www.cs.pitt.edu/~jmisurda/submit