Specification of Level 9 A-Code

I find multiple tools that can work with Level 9 games, but I can’t seem to find the specification of their game formats in general or their A-Code in particular. Any pointers would be appreciated.

3 Likes

I tried to use l9cut to produce The dat-file but all the games I tried was v1, which isn’t supported.

Is the dat-files binaries?

I believe the .dat files correspond to Z-code story files.

1 Like

I don’t think anyone has ever gone to the trouble of writing out a proper specification document. All the information that exists is in the Level9 interpreter source code (Index: if-archive/level9/interpreters/level9). Since the interpreter plays all the games all the details are there, it’s just a question of getting the information into a useable format.

From my now hazy recollection of events, I found that one of the Amiga Level 9 releases had an executable for the interpreter with debugging information left in. From that we could produce a semi-intelligible decompiled 68000 assembly listing of the interpreter, which Glen then used as a guide to write the core C code of the Level9 interpreter. We didn’t generate a specification as we went, which might have been worthwhile, but would have taken time and effort.

The A-code format is a virtual machine, so broadly similar to Z-code in its basic idea, but different in the details.

5 Likes

Looking at the source code of l9dis (couldn’t run the win32-exe) There are names for the opcodes. Are these canon?

I haven’t looked at l9dis in years, but assuming that the opcode names are the same as the Level9 interpreter source, they came from the above mentioned disassembly of an Amiga executable that was part of one of Level 9’s releases. So yes, they’re pretty canonical. Or at least as close as we’re going to get.

2 Likes

I’ve recompiled L9Dis as a Windows console app under VS2019. The source and a binary is here. I’m gonna test it a bit before I upload it to IF-Archive.

Attached is a disassembly of Snowball from the Silicon Dreams compilation (C64). This is the version 3 of the game. Beware! It contains spoilers.

Snowball_v3.txt (203.6 KB)

4 Likes

As far as I can see it is pretty straightforward to document the opcodes. There’s only about 32 of them.

But, building an authoring tool or compiler would need a deeper analysis and identifying and seperating library code and game code and then building some sort of data model for the, well, data.

EDIT: What do say, @pdxiv? You seemed like someone looking for a project…

Only 32? Does that include arithmetic operations? If so, maybe someone should spend an afternoon doing it. Who knows? Maybe there’s an assembly coder who wants to take on the challenge.

I was looking into this EXACT thing myself last week!

I thought it would be great if we had the same tools for A-Code that we have for Z-Code.

Adam

3 Likes

I’m not sure about that, but I saw a switch in the interpreter that looked for values under $20 when running through the code and switching out and executing the commands.

1 Like

That does sound like a fun project! I ended up thinking about authoring tools for Level 9 A-Code today when the subject was brought up in another thread.

1 Like

Actually, it’s 27, but one of them is “call function” which can be used to call seven predefined functions, including save and restore, and there are four opcodes for reading from and writing to a list. So I’d say it’s more like 37 opcodes all in all.

Arithmetic operators are included in the 27 basic opcodes. They are ADD and SUB. That’s it.

2 Likes

We could start by trying to write down the standard, by reading the source code of l9dis and interpreters, and perhaps inspecting game files in a hex editor. If we come up with something incomplete, that’s still better than what we have today.

I’d be interested in taking part in such an effort. Anyone else?

5 Likes

I’d be interesting on collaborating on that. Sounds like something I’d want to be doing anyway to sate my curiosity.

3 Likes

I’ll do what I can to contribute.

4 Likes

The book “Retrogame Archeology: Exploring Old Computer Games” by John Aycock contains some information about Level 9’s A-code format, see pages 74-76, 87-88 and 93-94.

A PDF of the book can be downloaded from here: [removed-link]

I’m not sure if that download is legal. I have removed the link until I get confirmation from John.

6 Likes

This is pure gold Stefan. Many thanks!

1 Like

Might be worth checking with John regarding the book link. He’s easily contactable https://twitter.com/herrprofdr / Unfettered by Content: John's Home Page

Thanks for that. It’s a good book and the A-Code info is spot-on, but it does seem to be commercial (very expensively so) to me at least, and John seems like a cool guy and he probably should be checked with.