Programming Pi Games With Bare Metal Assembly

pifoxWhile the most common use for a Raspberry Pi is probably a media center PC or retro game emulator, the Pi was designed as an educational computer meant to be an easy-to-use system in the hands of millions of students. Team 28 at Imperial College London certainly living up to the Raspberry Pi Foundation’s expectations with their bare metal assembly clone of Star Fox, aptly titled PiFox.

This isn’t the first time a college course has taken up the task of developing software for the Pi without an operating system; a few years ago, Cambridge University started that off with a series of bare metal tutorials for the Pi that included drawing graphics on the screen and playing around with USB keyboards. PiFox greatly expands on what those early tutorials could do, reading an NES joystick from the GPIO pins, sound with DMA, and rendering 3D objects.

If you’d like to build PiFox for yourself, or better yet, expand on the existing build, all the code is up on Github. There’s also a Raspberry Pi emulator for Linux, just in case you have an ARM assembly bug you just can’t scratch with a Raspberry Pi.

21 thoughts on “Programming Pi Games With Bare Metal Assembly

  1. Damm, If I found out this was written while riding a bear into battle against an army of undead alligators I honestly wouldn’t be surprised. This has pegged my badass meter.

  2. Why of all things Assembly? Assembly is SLOOOW. Java is FAST! Java is faster than C/C++ ASM and more current, so the optimal solution for speed, would be to have it booting a java interpreter, running on a java interpreter, running on a java interpreter all written in java. More recursion == more speed!

    I’ll bet this takes like 3 weeks to boot, while the java version would boot in like 3us.

        1. This is a FINE EXAMPLE of WHY

          this site would be better with NO COMMENTS AT ALL, the bad ones and their responses eat up all the space, by the time you are done reading them you wish you had your life back

  3. I find it interesting that they created their own rasterizer, using an interleaved image/depth framebuffer it seems. I wonder why they didn’t use the GPU, is it not possible to have some OpenGL API without some kind of binary blob perhaps ?

    1. some more info on this ‘postman’/’mailbox’ for communicating with the GPU would be nice! Besides sending framebuffers, does this interface support hardware acceleration too ?

    2. OpenGL is a layer that is present in your operating system. Drivers translate the common API into something that works with the vendor specific architecture. They would have to write a whole OpenGL implementation to use OpenGL – assuming you mean instead why don’t they just use the hardware acceleration capabilities of the chip, then they would have to track down the chip vendor’s documentation. I hear GPU vendors like to give that to just anybody.

      On the other hand, writting a rasterizer like that is something you can do as a weekend hack, and there is plenty of documentation to explain various different algorithms for rasterization.

      1. Except that Pi Foundation finally open-sourced their gfx chip.
        I don’t if it includes everything but I hope this kind of initiative “bare metal” coding will push the foundation further.

        Would be nice to revive the Amiga/Atari’s era.

  4. I’ve been debating getting a Pi since it came out, and this might finally push me off the fence… I’m not really an assembly programmer, but I like to learn a bit about the instruction set and architecture of systems I develop on, both as an aid to debugging, and for the odd inline asm function to speed things up.

    I wonder, though… Do the Team 28 folks know that they could have used a Super NES pad (or even a Virtual Boy pad, for that matter) using the same wiring by changing one integer constant in their code? I haven’t read the code, so maybe the support is already there, but they only had the older pad on-hand.

    I also wonder if “Team 28” is a reference to the (also British) game studio “Team 17”, famous for the “Worms” game series.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.