Baremetal Mario for Raspberry Pi 2B

Group assignment for the Computing Machinery II course (Computer Science 359 at the University of Calgary) where we had to make a simplified clone of Nintendo’s classic Super Mario Bros. game for a baremetal Raspberry Pi 2B.

Source code

Project Summary

Objective

Use ARMv7 assembly to implement a simplified clone of the original Super Mario Bros. game by Nintendo on a baremetal Raspberry Pi 2B.

Features

  • Fully written using ARMv7 Assembly.
  • Uses NES controller as input. (Baremetal means we had to write the drivers ourselves)
  • Goomba and turtle AI.
  • Mario controller.
    • Movement (left/right or jumping)
    • Attacks (jumping on enemies)
    • Death (falling or getting hit by enemies)
  • Draws images to the screen.
  • Boxes can be destroyed or their items released.
  • Scrolls the screen as the player moves right.
  • Score system that keeps track of coins collected in the level.
  • Main and pause menus.
  • Level editor is a Python script that convert image representations of the levels into ARMv7 Assembly.

Challenges

  • Assembly really sucks for large projects like this.
  • Very low framerate due to the assembly code not being optimized enough and not making use of branch predictions.
    • Eventually I and another friend figured out how to increase the framerate but it was after the course ended.
    • As such our game’s framerate was 0.67fps for full screen refreshes if we were just using Assembly and 2-3fps for full screen refreshes if we were using C with -O4 optimization.

My Tasks

  • Everything graphics related.
    • Python scripts that converted images and sprites to assembly code for those sprites and images.
    • Figured out how to get it to run at 2-3fps instead of 0.67fps.
  • Main game loop.
  • Enemy AI.
  • Game world or level.
    • Python script that converted an image representation of the level into assembly code for that level.

Credits

  • My friend and group member Yehonatan who worked mainly on the controller, player input, physics, score system.
  • Chris who helped figure out how to increase the framerate both during and after the course was over despite being in another group for the project itself.
  • Nintendo for creating the original game which we were cloning.