Sunday, November 19, 2017

Using Infocom's ZIP on the CoCo

In the previous post, I discussed some background information relating to the system used by Infocom to publish their interactive fiction games across a variety of competing computer systems that existed when their games were commercially viable. Beyond that I suggested that there were tools available which people today can still use to develop games for that same system. Moreover, I hinted that Infocom's own code (i.e. their Z interpreter or "ZIP") could be "borrowed" to enable running those new games on the CoCo. Let's explore those latter options now...

(At the end of that same post, I suggested that you take a look at Michael Sternberg's paper and the video of his KansasFest 2017 presentation on An Apple II Build Chain for Inform. If you have not done so already, then now would be an excellent time for you to check-out that source of information. Much of the information presented there is specific to the Apple II, but I believe that it nevertheless provides a good background for understanding the material presented below.)

Get Informed

Inform is the tool for compiling game descriptions into the form necessary to feed the Z interpreter. Teaching people to program in Inform is well beyond the scope of this blog post, so I will just touch on a few important points and leave the rest as an exercise for the reader...

The first version of Inform appeared in 1993, and versions progressed until a major rewrite in 1996 brought Inform 6. The Inform 6 language is largely procedural with object-oriented features. Inform 7 dates from around 2006 and features a declarative syntax with a high level of domain specificity (i.e. it is highly geared toward interactive fiction). While an Inform 6 compiler is used "under the covers" as a back-end compiler in Inform 7, the two languages are highly diverged and quite different to use.

It so happens that there are different versions of the Z machine interpreter (ZIP). Not surprisingly, the older ZIPs (such as what Infocom used on the CoCo) only support older ZIP standards. It turns-out that the last versions of Inform to effectively support such old ZIPs were somewhere in the Inform 6 range. For writing games to run on the CoCo, use of Inform version 6.1.5 as suggested in Sternberg's paper is recommended.

The point of getting an Inform 6 compiler up and running is to be able to produce story files containing Z code. In some cases these might be found pre-compiled at the Interactive Fiction archive or other sites. In still more cases, example Inform 6 source files might be found for you to compile on your own. Ideally, you will write your own games in Inform 6! But again, teaching you that skill is outside the scope of this blog post. I will suggest that you acquire a copy of the Inform Designer's Manual: 4th Edition, which apparently remains the definitive reference for the language.

Grab the ZIP!

So, the simple nugget of realization that I gleaned from the Sternberg paper was that Infocom wasn't making any use of the filesystem on the Apple II diskettes. So, why would they do things any differently on the CoCo? Applying that nugget of realization along with a hex dump of some Infocom disk images for the CoCo provided the missing information. Each of the Infocom disk images I looked at for the CoCo shared the same data for the boot track and for the initial two tracks on the disk. The data in between those tracks varied with each game, leading me to surmise that copying the boot track and the first two tracks (which I presumed to contain the Z interpreter) to a new disk along with copying a different game's Z machine story file in between would result in a disk that could boot and play that other game.

Continuing with the above theory, I created an image of an empty CoCo disk. I used the Zork I CoCo disk image as a source for it's boot track and its first two tracks (i.e the interpreter). I used the 'dd' command on Linux to retrieve those tracks from the Zork I disk image and to write their data to the appropriate locations on the new disk image. I continued by using the 'dd' command to write a different story file to the space in between the interpreter tracks and the boot track. I then tested the resulting disk image by loading it in MAME and booting it with the 'DOS' command on the emulated CoCo. I was rewarded by seeing the other game start and run.

Admittedly, the above is a bit light on some details. Moreover, there were some complicating facts that arose as I continued to investigate. For example, it turns out that there are at least 3 versions of the Z interpreter for the CoCo.  But that info and a few more details on the above are going to have to wait for now. If you want to learn more, then you will just have to stay tuned... ;-)

No comments:

Post a Comment