A9: Game

1,000 points

Remember Roller Coaster Tycoon? Game designer and developer Chris Sawyer had visions for the game that went beyond what most consumer PCs of the time could handle. So did he take a compromise on the complexity of the game mechanics? No, because the performance overhead of higher-level languages like C was significant, he simply decided to write the whole game in Assembly, such that he could carefully tune it to reach the maximum performance that was possible with the available hardware.

Assembly wouldn't be the first choice for writing a video game nowadays, however, the task still offers many engaging challenges. Whether it's an all-time classic like Snake, a reimagining of the original Roller Coaster Tycoon, or the next GTA (maybe you can finish it before 2025?), this assignment gives you the opportunity to strongly demonstrate your abilities not only in Assembly programming but also in mounting complex challenges as a whole.

There aren't many guidelines for the assignment either, though there are still some baseline requirements. Your game should be more complex than a simple (e.g., text-based) game - think of real-time components/physics/interesting mechanics/... This doesn't mean it has to be overly complex, something in the range of classics like Pong or Snake will be sufficient. However, there is also no limit (except your imagination (or your processing power..)), so more complex games are always appreciated. Furthermore, your implementation should:

  • correctly implement the rules of the game ("it's a feature, not a bug" has its limits)

  • display the state of the game, if applicable the progress/score, and so on

  • permanently record the top scores, if the rules of the game allow it, and have the option to display them - a bootable game (see below) only needs to store scores until the next reboot

  • be able to receive input from at least one player (from at least the keyboard or the mouse)

Lastly, your implementation should, of course, be in some form of Assembly language. It doesn't matter whether you write it for the x86-64, 8086, or even ARM architecture - as long as you can run, demo, and explain your game implementation!


Notes and Hints

For this extra assignment you should NOT expect content-related help from the TAs, that is, you should not expect them to debug your code or even to suggest how you should solve the assignment. Instead, this assignment allows you to demonstrate your ability to go beyond the Manual (and TAs).

Although we are sure you know how to use a search engine and understand the keywords you need to search for this assignment, we would like to give you a hint for writing games in Assembly. For the past 15 years, the demo scene and several generations of students around the world have learned much from Denthor’s Asphyxia Tutorials. In particular, you may be interested in graphics (tutorial Mode 13h).

Bootable Game

Another option is to make your game bootable so that it can run without any operating system. This means that you will have access to the graphical (VGA) memory directly, implement interrupt handlers to work with timing and input, and basically be able to (but also have to) do everything yourself. There are no standard libraries either. (So no printf, no exit, no nothing.) These advantages may also be disadvantages.

You do not need to start from scratch in implementing a bootable game. You can use a simple library that was made for this course some time ago and that will set up most of the basic things for you. This library makes sure you have a stack and lets you set interrupt handlers. After that, you are basically on your own. Again, many advantages, but these can turn easily into disadvantages.

The "bootlib" library can be found on GitHub. It contains a README (which you should read), and an example which you should try. We recommend you work on some Linux distribution, as it is not quite easy to get the compiler/linker working right on Windows or macOS.

Disclaimer for Apple Silicon Users: The "bootlib" library is not compatible with the Rosetta 2 compatibility layer. Of course, you are welcome to figure out a solution to get it running anyway.

DOSBox

One option to get that real classic retro game feel is to time travel.. Which is hard. So an alternative that has proven useful in previous iterations of the course is DOSBox. DOSBox is a free MS-DOS emulator that runs, pretty much out-of-the-box, even on macOS and Apple Silicon, and can directly mount and access your host filesystem.

DOSBox makes it easy to enter the classic VGA graphics mode (where pixels on the screen are simply mapped to addressable memory locations) allowing for proper "retro" graphics. However, it also comes with its challenges: You are now writing Assembly for the (16-bit) 8086 instruction set, which is a bit of a step away from your nice and cozy 64-bit environment that you have gotten used to. Some really appreciate the challenge and the nostalgia of past times it brings, but it is definitely not for everyone.

Example: DOS game made as part of this course (running on Apple Silicon)

Final Disclaimer

Be warned: writing your own game is really fun. So fun indeed that you may be inclined to spend your time playing that game instead of paying attention in your lectures (speaking from experience here). Make sure you have the self-control to keep your other priorities on track before starting with this assignment.

Last updated