Yet Another Project: DnD1 port to JavaScript

This game ran in a computer similar to this (the lower end is the microcomputer)

Richard Garriott, creator of the Ultima Series, posted a call for warriors all around the globe to recreate one of his first games, and possibly one of the very first computer RPGs, into a modern accessible format.

How could I let this opportunity pass? as scarce the time as it always is (and more-so in these times of my life), I delved into the project; not caring much about the contest per se, but rather the option to recreate such an interesting piece of history.

The moment I saw the post I started researching on the topic and stumbled upon this video, I immediately knew what I was to do.

I decided to structure the project in two parts, a JavaScript teletype emulator (JSTTY) and the JavaScript port of the game itself; the teletype emulator was mostly fun to work in, had some help from fellow jucarave, and will probably open source it soon.

The second part was pretty different, and not straightforward at all.

At first I started just translating the original BASIC program into equivalent JS, but once I started developing the input module for JSTTY I figured out doing blocking input in JS to emulate the INPUT statements was not going to be simple. Ultimately I ditched all my advanced and rebooted development under a different paradigm.

So, instead of doing a direct translation, I had to read thru the logic and change the control flow so that it worked based on callbacks for the input methods.

My DnD 1 port
My port, running on JSTTY

Richard posted a link to a 24 pages scanned version of his BASIC source code; thankfully, dejayc, one of the members of the SoTA community went thru several iterations and finally produced a flat text file which made things much easier. I also got the absolutely awesome PDP-11 teletype font from him.

The game itself, it’s interesting trying to trace all the development that went from this initial version, to Akalabeth, the Ultima Series and beyond; there are certainly some aspect from this game that served as a bridge between the Dungeons and Dragons PnP RPG nerds and the whole cRPG genre.


3 thoughts on “Yet Another Project: DnD1 port to JavaScript

  1. Santiago, your port is awesome. I am just getting started and understand what you’re saying: “I had to read thru the logic and change the control flow so that it worked based on callbacks for the input methods.” I see your calls to PRINT() and INPUT(function) occur sequentially – as if they block. Have you got a time-based loop that is handling both simultaneously?

    1. Thank you!

      Here’s some details on how it works that I had posted on the forums:

      I’m using a function object as callback for the input function, which in turn is constantly polling the keyboard buffer which in turn is fed by the default keyboard events,

      print("Hello, what's your name?");
      print ("Nice to meet you "+name);

      the input function is something like this

      function input (callback) {
      if (inputFinished){
      } else {
      setTimeout(300, function(){input(callback);});

      And there are keyboard listeners which control both inputFinished (when enter is pressed) and inputBuffer (keypresses get appended to this one when pressed)

      There are some other components to JSTTY but these are mostly for the fancy animations.

      Hope it helps and good luck with your entry!

      1. Thanks for the help. I now have a time-based main loop that can print characters one at a time (with audio) and queue keystrokes. Specifying handler functions as an argument to input() is a nice approach. In retrospect, BASIC is a pretty interesting state machine. BTW: Watching and listening to your teletype machine is a joy. It brings back fond memories.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s