Author Topic: GAL (KQ1) extractor and decompiler  (Read 9067 times)

0 Members and 1 Guest are viewing this topic.

Offline NewRisingSun

GAL (KQ1) extractor and decompiler
« on: October 22, 2016, 09:17:12 PM »
I have finished my small extractor and decompiler for the "Game Adaptation Language" logic resources used in the early King's Quest releases. I'm sharing my work-in-progress.

GALextract.exe requires a 360K disk image, its name specified as a command-line argument; all known versions of the game should be supported. If specifically the gnome/beanstalk messages are corrupt, then your disk image is the badly-cracked version of the game that is floating around the internet.

GALdecompile takes the name of the logic resource as a command-line argument and outputs the decompiled script to the standard output. WORDS.BIN must be in the current directory; this is the equivalent to AGIv2's WORDS.TOK, which in the case of GAL is hard-coded into the main executable file, like so many things.

Being a work-in-progress, it's far from perfect --- some opcode meanings are unknown, some may have their lengths misidentified, and I may have made an incorrect guess at what some of them mean. I'm also a bit stumped by the meaning of "FB FE 00 00" in the test command blocks. I have started filling in preliminary object and variable names; they are only valid for the "PCjr/Tandy 1000 disk" of the Sierra On-Line release; their names will be off for the IBM PCjr release. Still, it's not bad for a first effort, I would say.

« Last Edit: October 22, 2016, 09:22:47 PM by NewRisingSun »



Offline Collector

Re: GAL (KQ1) extractor and decompiler
« Reply #1 on: October 22, 2016, 11:01:37 PM »
I have not yet tried to image my IBM KQ1. It is the 2nd IBM release that had just the strip keyboard overlay. I'll have to try it in a few days when I get a day off.
KQII Remake Pic

Offline lance.ewing

Re: GAL (KQ1) extractor and decompiler
« Reply #2 on: October 23, 2016, 04:56:49 AM »
Amazing what archive.org has archived for us:

http://web.archive.org/web/20090809121039/http://retrograde.trustno1.org/sierra.htm

The TANDY image seems to work with your tool. Trying the other two now...

Offline lance.ewing

Re: GAL (KQ1) extractor and decompiler
« Reply #3 on: October 23, 2016, 05:29:46 AM »
The extractor is working for me on the KQ1.IMG and the KQ1TANDY.IMG. It seems to silently ignore the KQ1PCJR.IMG.

The decompiler is working on the LOGIC files from both the KQ1.IMG and KQ1TANDY.IMG. The source output is looking really good.

I've been thinking more about the syntax used in the Donald B. Trivette article from 1985. Someone must have given him that code snippet. It isn't something he would have come up with by himself. Although it seems quite straight forward to convert that primitive syntax from the article to the more familiar AGI syntax, my money would be on that more primitive syntax being what they started out with. I guess we'll never know for certain since no one seems to remember it. Clearly there was quite a bit of redesign of the engine when they moved on to KQ2, and another lesser redesign when moving to AGI v2 (where the test and action commands were reshuffled a bit).

Offline NewRisingSun

Re: GAL (KQ1) extractor and decompiler
« Reply #4 on: October 23, 2016, 06:53:18 AM »
Quote from: lance.ewing
and another lesser redesign when moving to AGI v2 (where the test and action commands were reshuffled a bit
It would be most interesting to look at the booter version of Donald Duck's Playground. It comes with interpreter version 2.001, supports EGA and text windows, draws background pictures to a shadow buffer rather than the screen, but still has the ANIOBJ structure on the disk that was dropped later. It's basically some kind of in-between between AGI 1 and AGI 2.

There is also an extremely rare actual PC version (1.50) using AGI v2.440, plus the Amiga (game version 1.0C) and Atari (game version 1.0A) versions of the game, which despite the version number come later than the actual booter PC version (1.0Q). (The version on Al Lowe's website is the Amiga version with a rather unsuitable PC interpreter executable added.)

Will look at KQ1PCJR.IMG later.
« Last Edit: October 23, 2016, 08:21:06 AM by NewRisingSun »

Offline lance.ewing

Re: GAL (KQ1) extractor and decompiler
« Reply #5 on: October 23, 2016, 06:58:15 AM »
I haven't had a chance to look at them yet myself, but was wondering what those two versions of Donald Duck's Playground stored in the archive.org link above are?

Offline NewRisingSun

Re: GAL (KQ1) extractor and decompiler
« Reply #6 on: October 23, 2016, 08:33:27 AM »
KQ1PCJR.IMG from Retrograde Station does not work with GALextract because Demonlord removed the game's copy protection in such a way that the location of some things is not where it was on the original disk. While I hesitate to accomodate a "cracked" game in such a manner, I suppose since most people will be using that image, I better add support for it to GALextract.
Quote from: lance.ewing
what those two versions of Donald Duck's Playground stored in the archive.org link above are?
The Retrograde Station downloads of the game are the original self-booting PC version 1.0Q with AGI version 2.001. One is a disk image, the other is a "DOS conversion" (basically the self-booting disk image modified to run under DOS by way of a little launcher program). The disk image has been "cracked" again in a rather clumsy fashion that prevents it from working on a Tandy 1000, where the original copy-protected disk has no such problems.

Offline lance.ewing

Re: GAL (KQ1) extractor and decompiler
« Reply #7 on: October 23, 2016, 08:44:26 AM »
I have not yet tried to image my IBM KQ1. It is the 2nd IBM release that had just the strip keyboard overlay. I'll have to try it in a few days when I get a day off.

There appears to be a copy of the IBM PCjr KQ1 game for sale on ebay at the moment.

Collector, would that be what you already have?

http://m.ebay.co.uk/itm/Original-Complete-Kings-Quest-1984-IBM-Computer-Game-Personal-Computer-Software-/201687504490?nav=SEARCH

« Last Edit: October 23, 2016, 08:47:57 AM by lance.ewing »

Offline NewRisingSun

Re: GAL (KQ1) extractor and decompiler
« Reply #8 on: October 23, 2016, 11:59:19 AM »
Quick update: added support for the Retrograde station KQ1PCJR.IMG disk image. I have added another program:

GALsnd2vgm converts the sound resources to the .VGM format, which can be played back by many sound players with the right plugin. I have made sure that all tracks that should loop do loop properly. The syntax is GALsnd2vgm infile outfile ["English track title"] ["Japanese track title"]. The track titles are optional. If at least an English track title was given and a GD3.INF file is found in the present directory, then the generated .VGM files will each have a GD3 tag as well. GALsnd2vgm_all.cmd does this already.

Doing this both to the Radio Shack and IBM releases indicates that the IBM release has a few sounds different, notably the witch sound. There are also several unused sound resources.
« Last Edit: October 23, 2016, 12:02:41 PM by NewRisingSun »

Offline Collector

Re: GAL (KQ1) extractor and decompiler
« Reply #9 on: October 23, 2016, 12:43:18 PM »
As far as I know the box and manual of the two IBM releases are identical. It is the overlay that is the best way to tell. That listing seems to be missing the overlay.

1st release:


2nd release:
KQII Remake Pic

Offline OmerMor

Re: GAL (KQ1) extractor and decompiler
« Reply #10 on: October 23, 2016, 01:34:14 PM »
Thanks for the tools NewRisingSun!

One question though:


 :D

Offline NewRisingSun

Re: GAL (KQ1) extractor and decompiler
« Reply #11 on: October 24, 2016, 11:54:53 AM »
"Github is like facebook for programmers". That's where they lost me.

Offline lskovlun

Re: GAL (KQ1) extractor and decompiler
« Reply #12 on: October 25, 2016, 07:34:49 AM »
"Github is like facebook for programmers". That's where they lost me.
But it isn't an official position statement.

Offline lance.ewing

Re: GAL (KQ1) extractor and decompiler
« Reply #13 on: October 26, 2016, 06:26:47 AM »
I don't see how it compares to facebook at all really. To me it is more like the old Google code and sourceforge sites. It's just a place to create a repo that you can use and it gives others access to that code. I have an aversion to facebook (that incidentally I don't have to twitter or some of the others), so if I'd seen that statement before joining, I would probably have been hesitant as well. It's probably closer to LinkedIn I guess, as its more a reflection of your technical ability. Recruiters do sometimes look at people's github accounts, but if you use an unrecognisable account name, no one will know who it is.

The only drawback for some people might be that the free version of github doesn't let you create private repos. Whatever you put in to github, you have to be aware that the whole world can see it. In reality though, the whole world isn't going to be looking at it. The only people that would bother to look at my code on there are probably the ones that I wouldn't mind having a look at it.

Bitbucket lets you create private repos though. That's another alternative. Only 5 users in the free account but I guess it has to be quite a successful project to require more than 5 committers.
« Last Edit: October 26, 2016, 06:28:30 AM by lance.ewing »

Offline Collector

Re: GAL (KQ1) extractor and decompiler
« Reply #14 on: October 26, 2016, 12:53:58 PM »
Bitbucket is what I have been using. I fail to see how any parallels can be drawn between social media and Bitbucket. It is just a repository that allows multiple developers to work on the same project. It allows you to track and approve commits as well as forks. It has an integrated bug tracker and Wiki. If it is public it allows others read only access to the code. I have a GitHub account but have not used it. However I assume that it is not that much different.
KQII Remake Pic


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.035 seconds with 23 queries.