I asked Drew Cook (which led to this post) but I’m still wondering how to calculate grammar (and other) sizes for z-machine games.
I attempted to use the INFODUMP.exe file from the z-machine decompiler on my game, which led to a bunch of statistics that I don’t think I’m after, also they were in (I think) hexadecimal form.
Then I tried using the TXD.exe file, but apparently the grammar table is “illegal size” and caused no output, which is weird because the last 3 Infocom parser games probably had a bigger grammar size.
I wonder what’s going on here. How would I fix it? I already used the zil abbreviations, but I’m not even sure if it’s to do with ZIL or z-machine in general.
I think the problem here is that the grammar table format isn’t part of the Z-Machine specification. Rather, it’s a mutual agreement between the parser and the compiler. So TXD has to figure out which format to assume.
The short answer is probably that to make TXD work on a game compiled with ZILF, you have to give it a serial number saying that the game was built in the 1980s. That should make TXD pick one of the Infocom grammar table formats. Otherwise, it will assume that it’s an Inform game and pick one of the Inform grammar table formats.
Or you could try using the -g option to TXD to “turn off grammar for action routines”.
At least, that’s the conclusion I came to when I was trying it time time ago. If I remember correctly.
If you look at showverbs.c (tip: this file also contains a lot of useful information about the different formats in the comments.) you see that it uses the serial-number and the version-number to identify infocom6_grammar. The serial-number (date) must be from the 80s (8xxxxx) and the z-version must be 6. The z-version is stored in byte 0 of the game file and the serial-number in bytes 18-23, you can change these with an hex-editor if you don’t have the source code. If you are compiling with Zilf you can either set the serial-numer with LOWCORE or force a serial-number with the -s directive during the Zapf-stage.
I’m not sure what variables you are after but aside from the pointers to areas defined in the header the rest is much up to how the compiler chooses to structure the data. Tis is done differently between different versions of the Zilch-compiler (Infocoms), versions of Inform, Zilf and Dialog. You need knowledge of the compiler or you need to search for patterns in the data to identify were, for example, grammar is stored, where the z-code area are and where the higt string area starts.
EDIT: There are also a couple of new opcodes added in version 1.1 of the z-machine specifications (three I think, mostly around printing and testing for Unicode-characters) that TXD can’t decode.The dissassembly gets scrambled or TXD simply crash when one is encountered.
so, in theory the best solution is adding to TXD the format used by ZILF ?
After all, the source is of 1998 vintage, a new version, whose take into account the last quarter of a century or so of Z-code development is perhaps sorely needed…
Not necessary. Zilf have no unique format. But maybe a new way to recognize a v6 game as Zork0 in Nother way than through the compilation date (the serial number).
The best solution is to update ZILF to display the statistics you want, if it doesn’t already.
EDIT-ADD: I don’t know if it does! Nor do I know where the -d debug data is written. I haven’t used ZILF, and a quick test only revealed that I don’t have the right version of Mono installed.
I’ve noticed that the Linux version can bit a bit finicky. At least on my system (unstable Debian) it won’t run out of the box:
$ zilf
FailFast:
Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
at System.Globalization.GlobalizationMode..cctor()
at System.Globalization.CultureData.CreateCultureWithInvariantData()
at System.Globalization.CultureData.get_Invariant()
at System.Globalization.CultureInfo..cctor()
at System.StringComparer..cctor()
at System.AppDomain.InitializeCompatibilityFlags()
at System.AppDomain.Setup(System.Object)
Aborted (core dumped)
Apparently it needs libicu67, which is no longer available. If I install that package from an older version, everything seems to be just fine. (I’m only mentioning this in case someone else has this problem.)