CS 0447 – Project 2: Frogger

Due: Sunday, November 10, 2013 by 11:59pm

Description

Many video games of the past were programmed directly in assembly language. In this project, we’ll be taking an early Konami video game, Frogger, 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/Frogger or find a modern adaptation (or emulated old version) to try it.

The basic idea is that you are guiding a frog through an obstacle course to get to its home. You start at the bottom of the screen and make your way upwards to one of three safe lily pads.

In our version, we will be guiding the frog over moving stones that are floating by in a river of lava.

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.

Your Frog

 

 

 

 

Your frog is a 2x2 rectangle of green LEDs. It moves +2 in the indicated direction whenever a directional key is pressed.

Initially the frog is centered in the screen in the 8th and 7th rows from the bottom.

The Lava

The lava is a 48x64 rectangle of red LEDs that will be 8 LEDs from the top and bottom of the screen.

If the frog ever touches a red LED, it is dead.

A Stone

A stone will be a 8xN rectangle of yellow LEDs, where N is a random number from 8 to 12 generated for each stone.

To span the river, we will need 6 stones to float by. The stones in the 1st, 3rd, and 5th rows will head to the left. The 2nd, 4th, and 6th row stones will head to the right. Each stone will have a velocity (the number of LEDs it moves each time step) that is a random value from 1 to 3. Stones start from offscreen and each time step will move in the proper direction with the proper velocity.

After the stone has moved 2 LEDs away from the edge it started at, a new stone can spawn with probability 10% (generate a random number from 0-9. If it’s 0 spawn a new stone).

You may limit it so that there are never more than 2 stones in a given lane at any time.

Lily pads

 

 

 

 

 

 

 

 

 

 

 

 

A lily pad is a 2x6 rectangle of green LEDS. There are to be three of them, one on the left edge of the screen, one on the right edge of the screen, and one centered between them (23 LEDs from the edge ones). They appear in the 7th and 8th rows from the top of the screen.

To safely make it home, a frog must entirely be in a lily pad, with no part of it hitting the black void between them or outside of the bounds of the screen.

Game Requirements

  1. A frog is initially a 2x2 rectangle of green LEDs. It starts at the center of the LED display, 8 rows from the bottom of the screen.
  2. A red rectangle, 64 LEDs wide and 48 LEDs high will be placed 8 LEDs from the top of the screen.
  3. Yellow stones appear as described above.
  4. For a key press left or right, move the frog two LEDs in the appropriate direction. The frog can move on a log or on the black ground it began on.
  5. To animate movement, you will turn on an LED in front of the moving item and turn off an LED (set its color to the background) at the back.
  6. You will update the position of the stones every 200 milliseconds and the frog with each keypress.
    1. You can use syscall 32 in MARS to sleep for a specified number of milliseconds.
  7. A life is lost when the frog touches a red LED,  is not entirely inside of a lily pad on the final jump, or scrolls off of the screen on a stone. The game resets as per #1 above.
  8. Every time a frog lands in a lily pad, their score is incremented by 100 points and the game continues with the frog in its initial position.
  9. There are 3 lives initially.
  10. When the game ends, the score is printed using the print syscalls.
  11. You must use functions in this project. At minimum you need a function that updates the frog position, one that updates the stone positions, and one that checks if the frog is in a lily pad. You may use others, but those three are required.
  12. 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.