Updating Babel to recognize IFIDs more generally

There was a recent thread about embedding an IFID in new or one-off game formats. I said that the Babel spec doesn’t describe this, but it should.

I have written up a small update to fix this. This is my current draft:


2.2.2. The IFID for a game format that embeds an IFID

[This section just summarizes the IFID formats for non-legacy game files…]

Modern Z-code and Glulx game files may be branded with a text such as this:

UUID://1974A053-7DB0-4103-93A1-767C1382C0B7//

(Recall that I7 uses a UUID-generating algorithm to create IFIDs.) This text is written in a character array in byte-accessible memory. Its location cannot be guaranteed, so the whole of byte-accessible memory must be scanned for the pattern UUID://..//.

Some Hugo story files contain an embedded UUID IFID, however the text is obfuscated by 20 being added to the value of each byte. The IFID can be located by looking for hyphens in the right pattern, though note that the hyphens are themselves obfuscated (and become "A"s).

Adrift 5 story files contain an embedded iFiction record which specify the IFID of the story file. Note that this IFID is not a valid UUID.

2.2.3. The IFID for an HTML story file

[No change to this section.]

2.2.4. The IFID for other file formats

Other formats include executable files, game files from systems not described in this agreement, and other document formats (including plain text).

Such a file may include the text UUID://...// as a literal byte sequence. If it does not, then the IFID is the file’s MD5 hash code, with hexadecimal characters a to f written in upper case, A to F.

If the file format precludes storing the UUID://...// sequence, then the IFID is always the MD5 hash code.

2.2.5. IFIDs for legacy projects

A “legacy” story file is one which pre-dates the present standard; that is, it does not incorporate an IFID in one of the ways described above.

A design system may provide an algorithm to determine a IFID for a legacy story file. The method should be reasonably straight-forward and documented here. Moreover, the design system should then provide an implementation of this algorithm in portable C: see §2.3, “The “babel” tool” below.

Legacy story files not covered by such algorithms have IFIDs equal to their MD5 hashes, as described above.


I’ve dropped the later section “IFIDs for projects falling outside this agreement”, since the sections above cover those cases.

I’ve also renamed the section “The IFID for an executable file” to “The IFID for other legacy file formats”, and added the note:

The concept of “executable file” is itself something of a legacy. There are many possible “executable” formats, and this document does not need to distinguish them.

We still have the table of MZ/ELF/MACHO/etc formats. But we can leave that alone for the future and not try to add general-purpose executable formats invented since 2006.

10 Likes

Obviously this should come with an update to the babel tool to search for the UUID://...// sequence in any darn file.

2 Likes

Perhaps the treaty itself could have a Github repository? It’s a little hard to read these changes out of context, whereas in a pull request I think it would be a little easier to work with.

And perhaps https://babel.ifarchive.org/ could be on a Github, too. I’d have some PRs to file, e.g. fixing links, linking to IFDB’s IFID support, etc. etc.

2 Likes

I threw the doc into https://github.com/iftechfoundation/ifarchive-if-specs several years ago.

I hadn’t set up a PR for this change, but now that you’ve reminded me:

Admit that UUID://..// is valid in both legacy and future binary files. by erkyrath · Pull Request #18 · iftechfoundation/ifarchive-if-specs · GitHub

2 Likes

The web site as a whole doesn’t have a repository, but that’s just because it’s had so few changes since it went up twenty years ago. I could create one.

1 Like

Could it be valid for a UUID to have lower case a-f as well ?

1 Like

IFIDs are always upper case. However, if the string UUID://...// contains lower-case hex digits, they should be recognized and converted to upper case.

(Hm, the tool doesn’t do that for zcode/glulx or HTML files. I should make that more consistent.)

1 Like

Are you saying it’s ok to have lower case hex in the UUID?

It would be nice to have the scanning tools be able to recognize this in the scanning. For example, my source code cannot have upper case hex in the number part.

What scanning tool are you using?

Albeit REP*/SCASB is one of the questionable 80x86 instruction, I can’t deny its later power (a tight cycle easily identifiable during prefetch , allowing string scanning in a blink), but encouraging its placement in the earliest place possible in the binary/story file should be provided in the Treaty
(OK that I’m prone to extreme optimisation…)

Best regards from Italy,
dott. Piergiorgio.

1 Like

Wholeheartedly seconded.

1 Like

I’m not using any specific scanning tool. I’m wondering if it’s part of the requirement of scanning tools that read other story files to also recognize the UUID in number in lower case also.

Such a file may include the text UUID://...// as a literal byte sequence. If it does not, then the IFID is the file’s MD5 hash code, with hexadecimal characters a to f written in upper case, A to F.

The above has no description of the syntax of the “…” part.

After consideration, I’m going to say the answer is “no”. The UUID string has to be upper case.

Alan files seem to be an exception (the examples I build have lower-case in the UUID string) but that will only be for Alan.

I will update the document to be clearer about this.

2 Likes

ok, it’s good the spec is clearer.

See updated PR:

Admit that UUID://..// is valid in both legacy and future binary files. by erkyrath · Pull Request #18 · iftechfoundation/ifarchive-if-specs · GitHub

1 Like

agree on uppercase; for legacy story files/binaries, there’s toupper functions around since time immemorial…

Best regards from Italy,
dott. Piergiorgio.

1 Like

This is now up: https://babel.ifarchive.org

2 Likes

About the HTML games. What if the game is distributed with an interpreter (index.html)? The story file itself is a plain text file and is located in its own folder. Where should I put the IFID?

Is the game only ever played through the interpreter distributed with it, or will people take that plain text file and play it on their own interpreters?

The story file can be run in other non-browser interpreters.