Specification of Level 9 A-Code

Hi everyone,

I’m new here and I loved reading through this thread.

I have been slowly finding time over the years to understand some of the best childhood text adventures from writing a python based interpreter for Level 9 to decompliing the actual adventures to appreciate the art of what Level 9 achieved, to understand the mechanics of what they created and to see what hidden secrets the adventures might contain.

It’s a long journey and I have only analysed v1 adventures so far (along with a writing hopefully a good enough specification for v1). I have v2 unpublished, including the graphics rendering however that can wait.

I decompiled Snowball, Colossal and Lords of Time (all big amazing adventures in my childhood). I have almost finished Adventure Quest too. The annotations are for understanding the mechanics, features and any bugs (love these). It’s an appreciation of the complexity of what Level 9 created back in the day on basic computers and I’m in awe.

I will get to a point where I can reverse specify - but I had to do this first, at least for v1. I understand the BBC Micro “engine”, documented the specification, now on the “verbose” decompilation and think I have enough to put together the “specify this and it’ll work (assuming under size for target platform) adventure definition”.

I would like the modern definition to be JSON based with a UI for editing. How that looks right now is under consideration.

I also need to complete my v2 journey - harder because the BBC Micro version introduced graphics (I have this working in Python but the flood fill is slightly broken). Text based is working but not on github yet.

Lovely to meet you all - hope some of the investigations are useful to some adventure players especially the “variable” usage of the games.

For some reason I cannot include links in my posts (probably because my first post) so if you want to understand any of these old games go to Strident’s post above go to decompilation folder and select these.

Snowball - snowball-v1-annotated.txt
Lords of Time - lords-of-time-v1-annotated.txt
Colossal Adventure - colossal-adventure-v1-annotated.txt

There is a great deal of text in there and I apologise for any typos and grammatical errors - over time i will address them.

I hope someone out there appreciates these!

Andy

8 Likes

Yes they had two variables - one for the “freezer disk” and one other for the sector and level in the disk.

For the freezer disk - outside of the disk this was always set to 0 unless in a shuttle station where it looped from 0x1a to 0x21.

Snowball was their most complex by an order of magnitude for their v1 adventures.

The sector and level were represented in the variable as “sector x 10 + level x 1”. Outside of the disks this was always set to 0.

I documented in the decompliation how this works - I can explain it here in summary too, let me know.

This is incredible work, Andy!

I’ve only skimmed it so far, but it looks like the most complete and accessible A-Code documentation we have at this time. Thank you!

I also wanted to point you to some resources, in case you haven’t seen them. Firstly, I assume you know Glen Summers’ Level 9 interpreter. But there are also two very useful little tools by P. D. Doherty: L9Cut, which strips the data in original disk and tape images from the interpreter parts, and is mostly interesting for the file l9data_d.h that contains basic information on all known game files; and, more importantly, L9Dis, which disassembles V3 (and possibly V4) data files.

In any case, I’m very much looking forward to seeing your progress with this project!

Best regards,
Miron

Thank you Miron - I have v2 mostly working including graphics although something’s amiss with my flood fill routine. I want to finish annotating Adventure Quest (almost complete) and Dungeon Adventure (not started and I have a bug in the decomplier that makes it think there is a 6th list, there can only be max 5 for v1 games).

I am aware of Glen Summer’s amazing interpreter - part of the reason I wrote mine was because I couldn’t understand his in all honestly. I couldn’t find much documentation and that is some pretty heavyweight C code, at least for me. I wanted it to be simpler and more accessible which is why I chose Python for my first implementation. I actually resorted to decompiling the BBC v1 games (6502) and making them rebuildable (and commented).

I haven’t tried L9Cut or L9Dis, will have a look. Thank you for the pointer and the nice comments.

There will be more to come!

Andy

2 Likes

This is really interesting. With any luck, we may have a full-fledged specification, and if we’re lucky, a compiler, by the time I’m in my 40’s. :smiley:

1 Like

I wholeheartedly agree with this - it’s an investigation (and actually harder than many adventures although some non-Level 9 were so obtuse just as adventures).

I couldn’t have understood the A-code and commented it for e.g. Snowball without having decompiled the 6502 engine on the BBC micro first and understood it all (and made it fully recompile).

Knowing the component parts before getting to the A-code helped - although just looking at the engine, doesn’t tell you WHAT the lists as an example do and why they are important. And the variables… all driven by the A-code. It’s been fascinating - and each level of A-code builds on the previous version. I’m hoping when I get to the v4 (as Glen references it) will be straightforward.

The drawing engine is the most complex for the non-bitmap games. It’s clever, simple in terms of directives but complex in terms of drawing “A-code” - not sure I want to call it A-code, but it’s super similar but for, um, drawing, I’ll probably document that last, still some bugs in my implementation and I don’t think my ‘drawing’ is as course grained as old micros which is why the flood fill is failing (fills everything). The shapes are correct which is a big step forward.

I would love to see their original tools! I think they could be improved in modern times though, which is why it’s lovely that we can pair new languages / tools and old tech together. But Level 9 were SO good, it’s absolutely evident from everything you get to decompile and piece together. I think that’s part of the addiction here.

2 Likes

God, the InfoTaskforce and Graham Nelson must’ve felt the same way when they were reverse-engineering the Z-Machine for the first time. It’s like trying to construct a map to a cave that you’ve only seen parts of from the upper levels.

2 Likes

I thank you all for your patience. Mike Austin informed me today that he has made the Level 9 archive publicly available. This includes documentation and specs, the A-Code compiler and sources of many of the Level 9 games. Please continue the discussion in this thread: A-Code Compiler, Level 9 Archive, Specs, game sources: made public!

7 Likes