Playing Zork with FreeRTOS on ARM in three different Ways

You might wonder what ‘Zork‘ is? Zork is one of the first and earlist fictive computer games, written around 1977 and 1979, written in MDL on a DEC PDP-10 by members of the MIT Dynamic Modelling group (see https://en.wikipedia.org/wiki/Zork). I believe the first time I have played Zork was around 1984 on a Commodore 64.

Zork

Zork

The idea was to run that game on a ‘normal’ ARM Cortex, and I selected the NXP FRDM-K64F board for this: the board is powerful enough and has an SD card socket so the game can load from the SD card.

LPC-Link2 debugging FRDM-K64F

LPC-Link2 debugging FRDM-K64F

I started my port of Zork for the NXP FRDM-K64F board using the port from Thomas Shane. You can find my port for the FRDM-K64F on GitHub (links at the end of this article). It should be fairly simple to port it to any other board.

The game code has been converted to C using a converter (so the code looks rather ugly with lots of goto statements). All the game files are in a single folder:

Zork Files

Zork Files

The Zork game loads the game data from a file (dtext.dat). I have ported the game so it can load the game data in three different ways:

  1. Loading the data from a SD card using FatFS
  2. Loading the data from the host using Semihosting
  3. Loading the data from the on-chip FLASH memory

Which variant is used can be configured in Zork/zork_config.h:

Zork Configuration

Zork Configuration

  • If using the file system/SD card with FatFS: copy the file dtext.dat to the root folder of the SD card.
  • If using Semihosting: this requires an active debugging session, so you have to start the program with the debugger. The program then accesses the dtext.dat from the host PC.
  • The easiest way is to use the game data from FLASH memory (at least 128 KByte required). The game data gets loaded into FLASH as dtext.dat (file in the Zork folder).

Communication to the board is by default using the OpenSDA UART (USB CDC) over a virtual COM port. The application runs FreeRTOS with a shell task where I can start the game:

Zork Command Shell

Zork Command Shell

With ‘Zork play’ at any time you can start the game and play:

Playing Zork

Playing Zork

‘help’ gives a description of the commands, and quit can be used to leave the game:

leaving Zork game

leaving Zork game

Have fun playing the game and exploring the dungeon! And if you don’t know how to solve one of the puzzles, there are plenty of hints online :-).

Happy Zorking 🙂

Links

3 thoughts on “Playing Zork with FreeRTOS on ARM in three different Ways

What do you think?

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