Two-player Snake game written in assembly language. Designed for the MIPS CPU architecture. The entire game can be found in the assembly-snake.S file. Thanks to QTMips Online, you can try it out even in a web browser.
The game can be run using the QtMips tool, both in its standard form and in the web version. Set the QtMips options to correspond with the text below. Then, simply compile the file with the code and run it.
- No pipeline, no cache
- Delay slot ON
- assembly-snake features two manually controlled snakes:
- RED SNAKE is controlled by:
- The red RGB knob or
WSAD
keys
- The red RGB knob or
- BLUE SNAKE is controlled by:
- The blue RGB knob or
IKJL
keys
- The blue RGB knob or
- RED SNAKE is controlled by:
- On Game Over, the game intentionally breaks; please recompile to play again.
- For food positions, pre-generated "random" positions are used. Optionally, the player can make the game more random by entering a
1-10
integer in theOPTIONAL_NUMBER
constant at the start of the code (this changes the pre-generated positions).
For more detailed information, see the comments in the code.
- A method with a nested for-loop that draws an 8x8 pixel square in the given color at the specified address.
- Draws the two snakes at initialization. Returns the snake’s head (
$a1
) and tail ($a2
).
- Moves the snake by adding a new head and removing the old tail.
- Includes collision detection, extension when eating food, and more.
- Returns the updated head (
$a1
) and tail ($a2
).
- Used inside
updateSnake()
to determine where the tail goes next.- The addresses where the snake changes direction are saved in an array.
- This method looks for the (old) tail in the array to check if that is where the snake changed direction.
- The core game loop that:
- Calls
updateSnake()
for both snakes. - Checks and validates input from the keyboard and knobs.
- Calls