Show HN: Resurrecting Infocom's Unix Z-Machine with Cosmopolitan

ChristopherDrum | 157 points

Funny coincidental timing - I just played HHGTTG a couple of times last night for the first time in thirty+ years or so.

I first played the game, way back - prior to having read the novel. It was mind-blowing. I had no idea what was going on but I got a real sense that it could be pretty funny if I did. So I read the novel eventually, and it was as good as I expected. I don't think I'd gone back to play the game until this week, though.

wyldfire | a month ago

In case anyone needs to do the sort of "fix up scattered declarations and move them to headers", you really want to use:

  gcc -Werror=missing-declarations -Werror=redundant-decls
(last I checked, Clang's implementation of this was buggy and half-useless, but I'll admit I stopped using Clang)

I recommend this for well-maintained code too, just as another way to keep the code smells away. For a lot of projects this will only require adding a bit of `static` that you were too lazy to write.

o11c | a month ago

Its interesting to see how developers get into a mindset, based on their life experience.

What we're seeing here is 40 year old code compile and run with minimal effort. Largely because the C language has respected backwards compatibility.

Yes, there were breaking changes along the way, but they were trivial to resolve in hours. And (more interesting) the author believed that to be true and so persevered.

I saw this recently as well. I run a lot of programs on Windows. Many are 32 bit, written in the 90s for Windows 95, or 98. They all still run. Microsoft bends over backwards to keep things compatible.

I also get to write a lot of web API clients. I tell customers that it won't work forever. Web APIs are constantly changing. The service (especially Google) will change something soon to break it.

The people building those APIs are expecting only currently-maintained apps to run. They have no concept (or experience) of 40 or 30 year old code "just running". Crumbs, if you get 5 years out an API client you're doing well.

bruce511 | a month ago

Cool project! But one nitpick.

K&R C has no concept of THEN. That's a peculiarity of the ZIP source code, defined as a pure no-op:

    #define THEN
https://github.com/ChristopherDrum/pez/blob/main/zip/infocom...
gamache | 25 days ago

i think ucsd p-system vm predates z-machine by a couple of years (re OP's origin of vm use comment)

joshu | a month ago

Absolutely amazing. Good work. It downloaded and ran on Arch with no problem.

fredsmith219 | a month ago

This is somewhat tangential to the precise topic but since it doesn’t come up often: if you’re into this genre I recommend a game called Vespers. Really well done and thick atmosphere.

user3939382 | a month ago

(1) The UCSD p-Machine was contemporaneous and made it feasible to compile Pascal for machines like the 6502 which were terrible targets for conventional compilers. It was atrocious in every way, particularly atrociously slow. At the time many CS professors with Microsoft BASIC being the dominant teaching languages but UCSD plus the inability to do systems programming in ISO Pascal made a generation of young programmers hate Pascal with passion.

(2) Scott Adams made an adventure interpreter was was similar but less sophisticated than the z-machine but similarly portable, in fact you could write a Scott Adams interpreter in BASIC [1] but he also wrote interpreters in assembly for the most popular platforms

https://6502disassembly.com/a2-scott-adams/interp.html

(3) Infocom developed the games on a PDP-10 machine which might be the last general purpose computer that survived with other than the 8-bit byte. (Though it had bitwise addressing which helped it cope with the industry going in that direction).

[1] Notably if you tried to write an adventure game in straight up BASIC you'd struggle. It's not like you could look up a verb in a hashtable and dispatch to subroutine. You'd be writing incredibly long if-then-else ladders nested inside if-then-else ladders which is bad enough in a civilized language.

PaulHoule | 25 days ago
[deleted]
| a month ago

What is going on here?

[~/Downloads] $ chmod +x zork*

[~/Downloads] $ ./zork1

Cannot open assembly './zork1': File does not contain a valid CIL image.

hans_0l0 | 25 days ago