Prompted by @SteveF's post here, here's what I've been up to:
Jeremy
- Wrote some code in C# to parse a BBC Quill database file. Yes, there's already a tool for this, (unqbbc), but I wanted to understand the file format in detail and the easiest way for me to do this was to write some code. Also, as noted elsewhere, unqbbc seems to swap two pairs of opcodes over. Possibly it's referencing a different Quill version. I'm only looking that A03 disk version myself. As part of this I'm defining classes for each object type so that a game can be representing in memory as a tree of strongly typed objects. More on this later.
- Wrote some code to export all this as text and/or JSON. This is really just to look at it, although the JSON can be trivially reloaded to recreate the object tree in memory.
- Wrote some code to recreate the Quill database file in a disk image, optionally with the interpreter prepended. This was to further check my understanding.
- Put all this in a .NET Core library.
- Given all this, one can write a C# console application which uses the library and can be used to write a new game and emit a disk image. This is done by simply adding objects to the tree in C#, then writing code to output the disk image. Other than using the Quill editor to load the generated database and list out all the object as a test that the file is valid, there's no need to use the editor at all.
- Used this to port Aural Quest to the Quill. That was quite tedious as it's a lot of copy and paste and having to get the numbers correct for all the objects in the event and status tables. See first picture.
- Refactored things so that event and status tables are created using helper methods which take typed objects as parameters rather than just numbers. There is a helper method for each opcode. As Aural Quest is a port, I've retained the numbers in object names for reference. Once this is done, objects can also be refactored so that you can refer to objects by meaningful names rather than numbers. See second picture.
- After it became clear that the first 4 Artic Adventures share a common heritage with the Quill and I stumbled across unplad I ported these 4 games over (hardly anyone noticed ). The process evolved while doing this, I hacked unplad about to emit C# source code for at least some of the data. That's kind of how I got them all out so quickly.
- In a sudden bout of insanity, I also ported The Thompson Twins Adventure. Having recovered from that...
- ... I wrote a Quill parser in C#. Again, this is mostly for my own understanding. I had briefly tried to disassemble the official interpreter but ran out of talent / enthusiasm before completing it. Mostly talent if truth be told. Clearly this code was written for compactness over readability as it seems to "jump around like an over-excited kangaroo on amphetamines" to coin a phrase.
- That mostly worked and being able to add lots of logging and the ability to write a transcript also helped. I used that to generate the transcript for Espionage Island, but if anyone picked up on the fact that I hadn't used the Quill interpreter to generate this, they've kept quiet about it.
- I then ported the C# interpreter to 6502 assembly. Writing it really wasn't that hard, although I had a couple of late nights tracking down bugs that a younger instance of me would have spotted in a few minutes, but that's old age for you. The (questionable) point of this is to be able to relocate it and/or "improve" it in some undefined manner.
- Typed in Debby Howard's example adventure from "Using the Quill - A Beginner's Guide", again, just for further testing. I kind of wish I'd researched this a bit more (actually, at all) beforehand as there are some errata and omissions from the printed text, especially as there is a repaired / patched Spectrum version here. This threw up some issues with the C# interpreter, so the next step...
- ...was to fix that by referencing the 6502 interpreter, which was working. I had envisaged the C# interpreter as being the easier one to debug and extend with a view to porting changes back to the 6502 one, but apparently not.
Jeremy
Statistics: Posted by EdwardianDuck — Sun Aug 11, 2024 3:40 pm