Colossal Cave Adventure in the Browser — FORTRAN IV to WebAssembly with LFortran

Not sure where this post should go, sorry. Over on the Fortran Discourse forum (don’t ask me what I’m doing there) someone posted about making the original Adventure run in the browser. That’s thanks to a relatively new Fortran compiler that can target WebAssembly. Apparently it took some changes to the source code, but only what was needed to make it compile. Might be of interest to some people here.

3 Likes

Cool . Did it not have any descriptions. I can’t get look noun, or examine noun to do any. Also; I, inventory, take inventory, inv nor invent are recognized. How to show carried in in this old version?

The lack of EXAMINE is canonical. INVENTORY works in the Fortran source I have, and in fact it’s mentioned in the HELP text:

51	THE OBJECT FROM THE VERB ALONE.  SOME OBJECTS ALSO IMPLY VERBS; IN
51	PARTICULAR, "INVENTORY" IMPLIES "TAKE INVENTORY", WHICH CAUSES ME TO
51	GIVE YOU A LIST OF WHAT YOU'RE CARRYING.  THE OBJECTS HAVE SIDE
51	EFFECTS; FOR INSTANCE, THE ROD SCARES THE BIRD.  USUALLY PEOPLE HAVING

However, the version up here must be older because it doesn’t have that HELP line.

3 Likes

Some time ago (almost 6 years, YIKES!) I ported a very early version of Colossal Cave to Rust and made a web assembly version with wasm-bindgen. The Rust code is as close to a literal translation of the Fortran as I could get (I made some helpers to allow for GOTO, etc.). I believe there are no behavioral differences at all except a couple of game crashing bugs in the original that I fixed. On second thought I take that back: The command line version has no differences, but the web assembly one has a difference in how an original game bug manifests. I chose not to fix the bug because it doesn’t crash the game. In the original it is possible to trigger an endless looping message by taking a certain item down a staircase that can’t be carried up. In the web assembly version the game looks like it freezes instead due to the brain-dead way javascript’s execution loop works (the looping game never releases control for the browser to draw the output). I probably could’ve fixed it given time, but the webassembly thing was just a quick experiment to see if I could do it.

2 Likes

if-archive/games/source/adv_crowther.zip / 77-03-31 is the version we’re looking at.

1 Like

Yep, the Mar 31, 1977 f4 source is the same one I used.

The f4 version’s input is case sensitive, f77 is not.

1 Like