
The Reconstruction of ZZT - endgame
https://github.com/asiekierka/reconstruction-of-zzt/
======
csense
For those who are unaware, ZZT was a text-mode DOS adventure game written in
1991 by the founder of Epic Games, Tim Sweeney.

It included a level editor and scripting language, which allowed anyone to
unleash their creativity and design their own text-mode games using the ZZT
engine.

This was absolutely unique at the time.

As a company, Epic is still hugely successful. Most gamers in 2020 have
probably heard of Fortnite and Unreal Engine. According to Wikipedia, Tim
Sweeney still owns over 50% of the company.

ZZT explored a lot of ideas about how to build a game creation system, which
influenced Unreal Engine, which itself was hugely influential throughout the
game industry.

The standard paradigms for today's game engines and editors was clearly
influenced by ZZT.

~~~
bartread
> It included a level editor and scripting language, which allowed anyone to
> unleash their creativity and design their own text-mode games using the ZZT
> engine.

> This was absolutely revolutionary at the time.

Well... OK, I'll give you this _maybe_ in the DOS world and _maybe_ on the US
side of the Atlantic. Maybe. And granted that we didn't all, me included, have
access to the latest and greatest of anything back then: you knew only what
you were exposed to through computing magazines, cover disks, and printed
manuals, and you might not have extensive access to many of those. Almost all
of my paper round income went on computer magazines back then.

Still, AGT (Adventure Game Toolkit), based on an earlier program called GAGS,
was released for DOS in 1987.

Moreover, in the 8-bit world, The Quill was released for the ZX Spectrum in
1983, GAC (Graphic Adventure Creator) was released in 1985 for Amstrad, ZX
Spectrum, C64, and even BBC Micro, and PAW (Professional Adventure Writer) - a
successor to Quill - was released in 1987.

Point being, a wide variety of text and graphic adventure "construction set"
programs were introduced in the early 1980s, and were widespread by the early
1990s.

~~~
asiekierka
They indeed were; ZZT is far from the first game creation tool.

However, most of those were either commercial products or restricted the
editing capabilities in some manner to free users. ZZT was shareware, but the
registered version differed solely in the amount of official game worlds
available (and the lack of a registration message on exit). The editor was
fully-featured and no restrictions were put on usage. This is what I think
makes it stand out from other game creation tools of the era and what made it
a popular tool on BBSes.

~~~
mntmoss
The "free" of it definitely made a difference, but there was also a certain
lack of concern about the shape of the resulting product that made ZZT feel
different and more flexible than the preceding tools when you tried to work
with it.

It had built-in, non-configurable stuff for action gameplay with some puzzle
elements. It did very little with regards to assets, unlike contemporaries -
no animation sets or hitbox definitions or music importer or similar ideas,
really just a level editor. It was just not good in terms of shelf-space
bullet points - nothing flashy about it. If that was all that it had, it would
not be a hugely differentiated game since the level editor concept had been
around since Lode Runner.

But it also had code, and code integrated in a way that was well documented
and tutorialized. It had scripted behaviors, functionality to manipulate and
transform the board, and hypertext dialogues with event flag toggles. Having
the hypertext and flags may have been the one most critical part of all this
since it really enabled choice-based interactive storytelling techniques, and
that's a huge deal even if you didn't have enough of an algorithms background
to try abusing the other functionality to make a platformer or whatnot.

And so I think the longevity of ZZT really rests in the way that it guides you
towards code, because it has so little else to offer.

------
npongratz
This is fantastic. Tangentially, I did not know the source code was lost:

"Please don't ask for the source; if I had it, I'd release it, but I lost it
in a crash a long time ago." -Tim Sweeney

[https://web.archive.org/web/19991010013339/http://www.epicga...](https://web.archive.org/web/19991010013339/http://www.epicgames.com/zzt.htm)

I find the whole thing interesting, because I remember the shareware versions
that I downloaded from my friendly neighborhood BBS offered the source code
for a fee; a large fee, if memory serves. I wonder if any of the purchasers of
said source code might still have it sitting around on their floppies
somewhere.

~~~
asiekierka
>I remember the shareware versions that I downloaded from my friendly
neighborhood BBS offered the source code for a fee; a large fee, if memory
serves.

None of the BBS releases for ZZT we found have such a statement; though I do
think there exist some pieces of software which did.

~~~
npongratz
Very interesting! I'll try to dig out my old floppies with the shareware
version and see.

Thank you so much for what you did here! This is seriously awesome!

Edit: I haven't found the floppy yet, but as I think about it some more, I may
be remembering Kroz (and not ZZT) as offering the source code for a fee...

~~~
tssva
The source for Kroz was definitely available for a fee.

------
swimfar
"The output executable is byte-for-byte identical with said release, which
means that the source code accurately represents the original engine's
behavior."

That seems crazy that someone could reverse engineer compiled code back into
the higher level language it came from, and then have that code compile into
the exact same executable. Obviously, you can keep modifying the code until it
matches, but it's still impressive for anything other than a small program.

~~~
gameswithgo
turbo pascal went straight from text to machine code. no ast or manipulations.

~~~
gonzus
More info please? That sounds pretty hard / impossible to do.

~~~
chrisseaton
> That sounds pretty hard / impossible to do.

Why do you think that?

This is how most compilers used to work.

And languages like Pascal were specifically designed to be able to be compiled
in a mostly single pass.

Look up ‘syntax directed translation’ in an old compiler textbook.

~~~
tmzt
Does that include Go? The speed of the compiler and some of the syntax suggest
that it should be possible.

~~~
pansa2
Go creates an AST and uses an SSA intermediate representation [0].

[0] [https://eli.thegreenplace.net/2019/go-compiler-internals-
add...](https://eli.thegreenplace.net/2019/go-compiler-internals-adding-a-new-
statement-to-go-part-2/)

------
chipx86
This is awesome. ZZT was huge for me when I was young. I had already been
toying with making games and desktop programs in VisualBasic by the time I
found ZZT, but the ability to just throw together little worlds and play with
the basic primitives the game gave us, share them with friends, was such an
experience for the time.

I wonder how kids today would see ZZT. I think they'd have a lot of fun with
it once they got into it, but being an older DOS-based game, ASCII art and
all, might be particularly strange to some. A lot of modern games, Minecraft
being one that immediately comes to mind, invoke the creativity and that ZZT
did in my generation. Still, I'd love to see what people would make in ZZT
today.

Tangent: I can't believe it was this long ago now, but about 10 years ago I
started working on reverse-engineering ZZT with the goal of putting together a
web-based implementation that was compatible. That spiraled out of control
into a brand new project I called MWorlds
([https://mworlds.wordpress.com/](https://mworlds.wordpress.com/)).

Haven't toyed with this in ages, but the idea morphed into an open platform
for making web-based games, including all assets (sprites, music, script
packs, monsters, weapons, etc.), that any kid or adult could build and share
and use in their own games. I really should just open source this someday. Or
start hacking on it again.

------
Cthulhu_
ZZT was amazing, probably one of the earlier games that had - and still has -
a massive modding community. I remember the one day we got a CD with a load of
demos, games, etc in a magazine, which in addition to a Shockwave menu also
just had the file structure; in there, we found a folder full of ZZT games.

A really memorable one was Code Red
([https://museumofzzt.com/file/c/codered.zip](https://museumofzzt.com/file/c/codered.zip)),
which just had so many little interactive things in at least the first area; a
television set with multiple programs, a vacuum that would follow you around
and explode if you vacuumed the wrong thing, it just kept giving. I don't
actually remember getting very far in it though.

Anyway, more recently I got a similar "feel" that I got from ZZT back in
PICO-8, a virtual console with a very accessible yet simple and intentionally
limited editor; like ZZT, it gives you all the bells and whistles to create a
game, but it's simple enough to avoid you reaching beyond the point where you
can finish it. It having a built in game explorer (with online connectivity)
means you've got thousands of indie games to explore. It's more versatile than
ZZT, but still keeps you sane.

------
acheron
This is awesome.

Who would have guessed of all the games I was playing in 1993 that ZZT would
be the one where the creator went on to become a billionaire...

------
danbolt
This is so lovely to see! ZZT got me into programming in a very holistic,
human, way. I'm happy that it's being explored.

~~~
jschwartzi
Me too! I spent an entire summer when I was 11 making a weird adventure game
in ZZT using the scripting tools. It was pretty fun!

------
Yhippa
There's a link in there to the Museum of ZZT: [https://museumofzzt.com/about-
zzt](https://museumofzzt.com/about-zzt).

Looking through the screencaps brings back a flood of memories. I remember
playing a lot of DOS games where you had colored ASCII art and that was it.
You really had to use your imagination to immerse yourself in the game and the
default levels did a good job of conveying that.

Today's games look amazing. It's crazy to think that these text games could
make you feel like you were in the game.

------
Minor49er
ZZT is great. Without it, we wouldn't have gotten MegaZeux. Both had really
fun communities

------
AlexMax
This is amazing, and I am incredibly glad someone has put in the legwork to
see this to fruition. I spent hours with it as a kid, both with it and its
unofficial successor Megazeux.

ZZT was a fun game creation system out of the box, but what always impressed
me was some of the stuff that the community managed to come up with - mostly
documented in the ZZT encyclopedia series as well as the Super Toolkit. It
pushed the engine far beyond the limits of what it was intended for, and some
the projects done with it absolutely blew my mind.

It was unfortunate that the source was lost, and for a long time the best you
could do, aside from DOSbox, were projects like DreamZZT which, while
admirable, didn't accurately emulate all of the peculiarities that many games
relied on. But now this exists. Thank you.

------
zzo38computer
This is something I have seen. I have used ZZT, and it is still used even now.
One of my ZZT games includes a note that although the world itself is Free
software, it is "trapped" because ZZT isn't. That was written before ZZT
source code has been reconstructed in this way, and now ZZT is Free software,
although it is itself "trapped" because the compiler isn't. There are many
tricks and stuff involved in ZZT and I have figured out some things just by
trying and then make the hypothesis how they worked, and now I can check the
source code to see if it matches what I expected, too. But I can see in there
also many things I did not know ZZT does, so this is helpful. Other people
have also independently figured out many kind of tricks with ZZT (see [0] and
[1] for some details). I also wrote my own external editor for ZZT (although
unfortunately it is slow, and confusing, but I like it, and prefer that kind
of user interface, which is why I wrote it, of course).

There are now other ZZT-likes, the most popular of which is probably MegaZeux
(which is now Free software, and continues to be maintained), although there
is also ZIG, and a few others, including my own ZZ Zero. Each of them has
different set of features. Although, most of them aren't used much other than
ZZT and MegaZeux, I think.

The GitHub mentions to fix 5 annoying bugs in ZZT. I thought of fixing some
bugs in ZZT (although not those that affect the behaviour of the game), and
removing the editor (you can use an external editor instead, such as KevEdit
or ZZTQED) and any stuff that is in there because it is only used by the
editor, and probably also removing mouse and joystick mode and monochrome mode
and VideoWriteTextCO40 (I don't know why that is in there, since ZZT doesn't
use the forty column mode), and removing the initial prompt (to make it faster
to load and further reduce the file size), and possibly adding an additional
optional header in the world file which controls some new features and bug
fixes, and allows customizing the contents of the ElementDefs array (the first
number in the file would be different, so you can tell apart from standard ZZT
worlds). I don't know when or if I might try to do this, though; I will of
course need to install Turbo Pascal first, and read its documentation, before
I could do such a thing.

[0]
[https://rabbitboots.com/kfx/index.php/ZZT_Notes](https://rabbitboots.com/kfx/index.php/ZZT_Notes)

[1]
[https://rabbitboots.com/kfx/index.php/ZZT_On_ZZT](https://rabbitboots.com/kfx/index.php/ZZT_On_ZZT)

------
benhoyt
asiekierka, I'm very impressed. How did you go about building this? Did you
start with the assembly and work backwards to Pascal? Did you use a Pascal
decompiler? Even then I can't imagine how you managed to get the output byte-
for-byte equivalent...

Anyway, as someone who downloaded ZZT from BBSes and wrote ZZT-OOP back in the
day, I love this. I recently started writing a version of ZZT in Go, but
haven't progressed since being able to load and display worlds. :-|

~~~
benhoyt
His original announcement is in this video (starts at around 34:00):
[https://www.twitch.tv/videos/568019342](https://www.twitch.tv/videos/568019342)
... one of the questions asked in the chat (55:07) is "How?" and he says he's
going to answer that in more detail in the future -- tantalizing! I for one
would be very interested. He adds, "As a quick summary: I spent a lot of hours
on this. I don't even want to admit how many hours I spent on this.
Essentially lots of effort, and time, and sweat. No tears though." Kudos!

~~~
asiekierka
To correct that a little:

\- I'd love to give a more detailed explanation, but I've never managed to
consistently operate a blog, so that might need to wait a while. \- After
getting some perspective, I may have overexaggerated the scale of the number
of hours I had spent on this.

~~~
benhoyt
In that case, would you mind (pretty please? :-) writing a few paragraphs here
about how you did this, technically speaking?

