#let post_slug = "assembly-game"
#let post_preview_image = "phobos.png"
#let post_summary = "Making a rocket platformer in assembly"

= Phobos

One of the coolest things I've developed is a game, fully written in
assembly.


I say this because it is the perfect intersection of many things I enjoy;
low level programming, physics, space, simulation development, and game design.
Also small enough of a project that I could complete it in under a couple
of months, so another win. I even named the game based on the emulator, as
Phobos is a moon of Mars.

The instructions for this
assignment were very broad, to develop a platformer game in assembly.
This left a lot of room for creative freedom, especially due to the
loose definition of platformer. With infinite time I would have
developed a whole rocket simulator, and used the justification that the
launchpad was a platform.

On the technical side this was a very difficult project. There are
only about 16 variables actually usable in MIPS, and a lot of them are reserved
to specific logical controls under best practice. Then following the many
loops and recursive, real-time functionality required extensive and efficient
use of the stack. Ideally accessing a few bytes shouldn't strike the fear
of low framerates to mind, but the Mars-MIPS emulator I was using was far
from efficient.

=== Notable Features

- Raycast collision detection and repositioning
- Sub-pixel velocity and positioning
- Awesome pixel graphics (the rocket shoots fire!)
- High framerates (for a low-performance emulator)
- Enemies shooting at you!
- Loot pickups

Probably the most annoying part of this was that the emulator couldn't
handle simutaineous key inputs. Fortunately I have over a thousand hours
experience landing rockets on the #link("https://kerbalspaceprogram.fandom.com/wiki/Mun")[Mün]
so I was comfortable giving a few unique key inputs per second. I never imagined
this is something I would be proud, and I still don't think I am. However,
it works.

At this point you may have realized I am a bit of a
space nerd. Enjoy this recording I made at 1am demonstrating the
features of my game to a TA, compressed to the point that the audio has
texture.

// <video width="90%" controls>
// <track kind="captions" />
// <source src="src/lib/phobos/demo.mp4" type="video/mp4" />
// Your browser does not support the video.
// </video><br />
// The
// <a href="https://github.com/jjanella/Phobos">source code</a> is also available
// for your enjoyment.
