Community

SCI Programming => SCI Development Tools => Topic started by: Collector on October 13, 2018, 09:39:47 PM

Title: Decompilation Archive
Post by: Collector on October 13, 2018, 09:39:47 PM
Rather than continuing to hijack the QfG1 EGA source thread I thought we could have a separate thread for the decompilation and archiving of the SCI game scripts.

Here is Iceman version 1.023, interpreter 0.000.668. It has two compile errors that I have yet to track down.
Title: Re: Decompilation Archive
Post by: Kawa on October 14, 2018, 03:47:40 AM
In my own fresh Iceman decompile, I see an --UNKNOWN-PROP-NAME-- in Feature.sc Act::canBeHere. Comparing this against SQ3, that should be ignAct.

The other error is in secondCoordsScript.sc secondCoordsScript::changeState: (13 (checkThrottle active: 1 value: 1 0))
From what I can tell, this should just be value: 1.
Title: Re: Decompilation Archive
Post by: lskovlun on October 14, 2018, 07:38:32 AM
The other error is in secondCoordsScript.sc secondCoordsScript::changeState: (13 (checkThrottle active: 1 value: 1 0))
From what I can tell, this should just be value: 1.
This is a script bug, not a decompilation bug.
Title: Re: Decompilation Archive
Post by: Kawa on October 14, 2018, 08:16:04 AM
This is a script bug, not a decompilation bug.
Considering the PMachine code literally pushes those two values and a parameter count of two, I think I'd agree. Did I say it was a decompilation bug, though?

Code: [Select]
(13
; KAWA -- There was an extra push here making a mess of this case:
; (asm
; pushi #active
; push1
; push1
; pushi #value
; push2
; push1
; push0
; lofsa checkThrottle
; send 14
; )
; correctly decompiles to the uncompilable
; (checkThrottle active: 1 value: 1 0)
(checkThrottle active: 1 value: 1)
)

(Edit to correct asm annotation, had the lofsa and send switched around)
Title: Re: Decompilation Archive
Post by: Kawa on October 14, 2018, 01:40:20 PM
Here's my take on Iceman, with those two fixes and a bunch of renamed globals and procedures in Main and Print.
Title: Re: Decompilation Archive
Post by: Collector on October 14, 2018, 08:03:55 PM
Added.
Title: Re: Decompilation Archive
Post by: Kawa on October 15, 2018, 05:35:23 PM
When I recompile KQ1, the remake of course, everything seems to work... until the portcullis is closed and I get handsOn.

Suddenly, Graham turns invisible (cyan outline) and the goat's there, trying to pathfind its way around the portcullis.

It's not one of my hacks that did it either -- I have an unaltered SCI Companion in the archives that ended up with the same thing. And a freshly-unzipped KQ1 doesn't do it either. So that's something to investigate before I bother to upload a copy of KQ1_v1.000.051_intS.old.010_SRC.zip
Title: Re: Decompilation Archive
Post by: Collector on October 16, 2018, 06:44:42 PM
that was the next one I was thinking about.
Title: Re: Decompilation Archive
Post by: Kawa on October 16, 2018, 07:27:26 PM
Strange minds think alike.
Title: Re: Decompilation Archive
Post by: Collector on October 16, 2018, 08:48:39 PM
Must be.
Title: Re: Decompilation Archive
Post by: EricOakford on October 19, 2018, 12:44:56 PM
Here is my work on Quest for Glory II v1.102 (from GOG.com). I managed to write up a game.sh file to go with it, which lists all the skills, ego walk modes, and much of the event flags. Thanks go to Charles for the QFG1EGA code (which helped me identify procedures and global variables, and whose game.sh file I based mine off of) and OmerMor for some code snippets he posted previously. The scripts compile fine, with a few exceptions listed below.

Code: [Select]
Error: (CharSheet.sc) The rest modifier must be followed by a parameter name.  Line: 27, col: 9
Error: (CharSheet.sc) The rest modifier must be followed by a parameter name.  Line: 42, col: 9
Warning: (rm130.sc) Duplicate case values. Already encountered a case for '54'  Line: 1003, col: 5
Error: (BoxSelector.sc) The rest modifier must be followed by a parameter name.  Line: 32, col: 9
239 scripts compiled.
Title: Re: Decompilation Archive
Post by: troflip on October 19, 2018, 01:04:28 PM
Interesting... that seems like a bug in the compiler, actually. It always assumes &rest is the last thing in a function call (not sure why), or is followed by a parameter name. But I guess this is valid usage.

I wonder how difficult this is to fix...
Title: Re: Decompilation Archive
Post by: troflip on October 19, 2018, 02:32:11 PM
To work around it, you can replace
Code: [Select]
(procedure (SomeProc x y)
    (Display &rest #at x y ....)
)

with

Code: [Select]
(procedure (SomeProc x y moreParams)
    (Display &rest moreParams #at x y ....)
)
Title: Re: Decompilation Archive
Post by: EricOakford on November 15, 2018, 11:01:07 PM
Here is my work on LSL1VGA. Some tweaks were made to allow the game to compile fully. I played though the entire game with no known issues (except maybe for sometimes freezing when entering the casino, but I think that's an original speed bug)
Title: Re: Decompilation Archive
Post by: EricOakford on November 24, 2018, 09:23:44 PM
And now for something a little different...
Here is decompiled code for the QFG2 demo! So far, everything seems to run fine... up until the Iblis Unleashed scene, where it immediately crashes with an "Oops!" error!

By the way, I've been working on a new EGA template game, using the QFG2 demo as the foundation and the interpreter from the EGA 1990 Christmas Card (it's compatible with QFG2, and still has its internal debugger!). So far, things seem to work okay. I'll upload this template sometime soon.
Title: Re: Decompilation Archive
Post by: MusicallyInspired on November 24, 2018, 09:31:01 PM
So, an SCI01 template game?
Title: Re: Decompilation Archive
Post by: EricOakford on December 10, 2018, 11:06:29 PM
Here is my work on QFG1VGA.

With the exceptions of a few scripts, everything seems to compile okay. I even enabled the hidden "Where to, Hero?" dialog at startup, so you can test each individual room!

I was thinking of doing a patch that would fix various script bugs in the game, and restore some unused messages and interactivity. This source could work well as the basis.

This code is best compiled without any SCR and HEP patch files in the directory, so you can be sure that the game only uses the RESOURCE files. The scripts, of course, were decompiled from the patches to ensure that all official bug fixes are present.

Here is the compile log:
Code: [Select]
Error: (WizardGame.sc) Duplicate label 'code_0448'  Line: 145, col: 0
Error: (WizardGame.sc) Duplicate label 'code_0453'  Line: 152, col: 0
Error: (inputBox.sc) Undeclared identifier '--UNKNOWN-PROP-NAME--' .  Line: 1281, col: 32
Error: (egoFight.sc) Undeclared identifier '--UNKNOWN-PROP-NAME--' .  Line: 332, col: 32
252 scripts compiled.
--------------------------------
Time elapsed: 7.56 seconds.
Title: Re: Decompilation Archive
Post by: EricOakford on December 14, 2018, 09:52:30 PM
Here we go again, my new and improved decompile of QFG2! This time, I used 1.105 from the QFG Anthology, to be sure that I had the latest code. The only difference I could see is that the import patch was integrated into the resource files. The game seems to compile and run okay, but going into the actual game, it freezes when attempting to enter the maze of alleys! This might be a tough one for us to crack, but thankfully, "suck blue frog" and the EGA 1990 Christmas interpreter's internal debugger are there to help us.
Credit goes to Omer Mor for unearthing the original import and export scripts for the game. This helped me identify quite a bit of the original defines for the game, and the export script even has the original "saveHero" (which SCI Companion can't decompile).
Title: Re: Decompilation Archive
Post by: EricOakford on January 14, 2019, 09:27:07 PM
Here is a decompile of the Slater and Charlie demo. Surprisingly, it has nearly all of the system scripts! Which is odd, since it's a demo version of an interactive storybook, and would have no use for all of them. So I nabbed the original system scripts from the SCI16 archive, adapted them for Companion, and compiled them. Everything seems to work okay.

The only script I couldn't adapt for Companion was SMOOPER, since it frequently uses equational defines, which Companion doesn't support.
Title: Re: Decompilation Archive
Post by: Collector on January 14, 2019, 10:18:48 PM
The only script I couldn't adapt for Companion was SMOOPER, since it frequently uses equational defines, which Companion doesn't support.

Perhaps make a mention of this in the Companion thread for Phil?
Title: Re: Decompilation Archive
Post by: EricOakford on January 27, 2019, 05:42:20 PM
Here are decompiles of the demos for SQ1VGA, PQ3, Conquests of the Longbow, and Ms. Astro Chicken. They seem to be good stock for a possible SCI1.0 template. Ms. Astro Chicken's main script even seems to have been largely taken from the full floppy version of SQ4!
Title: Re: Decompilation Archive
Post by: MusicallyInspired on January 27, 2019, 10:37:24 PM
Somewhat off-topic possibly, but I decided to look for the text in SQ4EGA (the alternate floppy version) that gives different text dialogue for the Monochrome Bikers on your appearance whether you're playing with the EGA, CGA, or Hercules Monochrome drivers. Strangely, while the VGA floppy version lists the text in the Display kernel function as strings right in the script (620), in the EGA version the string doesn't appear at all and just shows up as "LOOKUP_ERROR". Now, I haven't searched through all the TEXT resources yes to find the actual line if it wasn't a string like in the VGA floppy version, and I couldn't find if LOOKUP_ERROR was a mislabeled variable for a TEXT resource (it didn't seem to be defined in the 620 script), or if it's some kind of error that Companion returns on trying to decompile. Now, the fact that in the VGA floppy version it's a fixed string (not included in any TEXT resources, from what I can tell) and that in the EGA version it's possibly some kind of variable makes sense because it's based on what driver you're running.

Any ideas on how to find these text strings?
Title: Re: Decompilation Archive
Post by: Kawa on January 28, 2019, 03:47:27 AM
Decompilation error. The text is in the scripts like in the VGA version but it messes up. It's there in the script's string pool. The logic goes like this:
Code: [Select]
register 1:
  global105 > 16: "Well, lookee here! If it ain't Mister Look-at-me-I'm-in-VGA."
  else: "Well, lookee here! If it ain't Mister Look-at-me-I'm-in-EGA."
register 2: "Whatsamatter, monochrome not good enough for you?"
register 3:
  global105 > 16: "What's dis? 256 colors all for one little bitmapped WIMP?! Whatta waste of VGA. Har, har!"
  else: "What's dis? 16 colors all for one little bitmapped WIMP?! Whatta waste of EGA. Har, har!"
Even though by all means the EGA version should never have global105 be higher than 16.
Title: Re: Decompilation Archive
Post by: EricOakford on March 22, 2019, 08:45:32 PM
And here we go again! A decompile of the Freddy Pharkas floppy demo! Everything compiles without error, and the game has been tested to completion  without any problems that I could see.
Title: Re: Decompilation Archive
Post by: EricOakford on March 28, 2019, 08:33:59 PM
Can't seem to stop... here are decompiles of both the demo and full game of the other SCI01 game, KQ1SCI!

Both compile without errors, and have been tested to completion.
Title: Re: Decompilation Archive
Post by: MusicallyInspired on March 29, 2019, 09:18:37 AM
Excellent.
Title: Re: Decompilation Archive
Post by: EricOakford on April 07, 2019, 07:57:35 PM
Okay, here are some new decompiles for the QFG2 demo and Seasoned Professional. I have managed to put together a list of DoSound defines in the KERNEL.SH file that correspond to those games specifically. I'll have to implement those in the SCI01 template soon.

Also, Seasoned Professional has no VOCAB.900 file, making Companion crash when it attempts to decompile the User script. The required file is included in the archive, taken from the QFG2 demo.

4/9/2019 UPDATE: And here are new decompiles for Ms. Astro Chicken and the PQ3 demo! The DoSound defines closely match that of SCI1.1, so the only thing I really need to do is change them to Sierra's original names in the SCI1.0 template.
Title: Re: Decompilation Archive
Post by: EricOakford on April 27, 2019, 07:43:48 PM
And here are decompiles of the Codename Iceman and Hero's Quest demos!
The tricky part here was that important VOCAB files were missing. Iceman had the Vocab.999 file (kernel function list), so that was used in both decompiles. Neither had the VOCAB.997 (selector list), so I had to use the one from the SCI0 version of Mixed-Up Mother Goose, which uses the same interpreter version (0.000.685, which is also the newest SCI0 interpreter).

With the exception of the DiceRm script, everything compiles and plays with no obvious issues.
Title: Re: Decompilation Archive
Post by: Charles on May 06, 2019, 01:17:49 PM
I've done a bit of touch-up work on Eric's excellent QFG1EGA src (v3).  A lot of minor changes:

It compiles, and I've done a quick play-through of a couple rooms without noticing any problems, but I haven't done an extensive start-to-finish run yet.
Title: Re: Decompilation Archive
Post by: Charles on May 22, 2019, 01:59:35 PM
Made some more improvements:

edit: fixed a variable name I copy/pasted incorrectly in arenaBearChange.sc, and fixed a long-standing bug in RandomEncounter.sc, where escaping from a fight sets Ego to Walk instead of Run.
Title: Re: Decompilation Archive
Post by: EricOakford on June 18, 2019, 08:40:14 PM
Here is the decompile for the SQ6 demo! It includes a specific interpreter (taken from the SCI tools here (http://sciprogramming.com/community/index.php?topic=1631.msg9564#msg9564)) which has an internal debugger and no version stamp check. The latter part is important, as the original interpreter will refuse to run if the RESOURCE file has been modified, saying that it has not been version-stamped.

The game has been tested to completion, and seems like a good basis for a possible SCI32 template.

All of the system scripts are based from the newest SCI32 source from 10-12-1995, with the exceptions of:
   ACTOR.SC (06-28-1995)
   TALKER.SC (decompiled original)
   MESSAGER.SC (decompiled original)
   PLANE.SC (decompiled original)
   DTEXT.SC (06-28-1995)
   STYLER.SC (06-28-1995)

The reasons:
   Plane causes the title bar to lose its custom font.
   Talker is incompatible with the game, causing a "Not an Object" error when someone talks.
   Messager is incompatible, as anyone talking just gives a small "ALT" character and no voice.
   Actor and Styler are incompatible with the game, causing a "Not an Object" error at startup.
   DText causes the ComPost text's lines to leak out of the ComPost screen.

With Actor, Styler, and DText, it was just a matter of using the earlier script revisions from June 1995, more closely matching the game's release.
On the other hand, Plane, Talker, and Messager appear to have been specially modified for SQ6's custom talker and messager, which, in turn, seem to be based on the ones for LSL6 hr-res (to the point that some views for LSL6 are hidden in the resource files!).

There's only one bug that I can find. Specifically, the game's icon bar stops working after closing the control panel. It seems to be a decompilation error in the icon bar's doit, which can't be decompiled and thus is in assembly. For this reason, I've intentionally prevented it from compiling until it can be fixed.
Title: Re: Decompilation Archive
Post by: MusicallyInspired on June 19, 2019, 02:29:05 PM
Very nice!
Title: Re: Decompilation Archive
Post by: EricOakford on July 02, 2019, 10:14:36 PM
Here are some deconmpiles of the demos for Conquests of Camelot, QFG1VGA, PQ2, and the Fun Seeker's Guide!

They all fully compile and have been tested to completion. The only issue I found was a graphical error in the PQ2 demo; specifically, at the motel scene.
Title: Re: Decompilation Archive
Post by: OmerMor on July 03, 2019, 09:40:16 AM
The only issue I found was a graphical error in the PQ2 demo; specifically, at the motel scene.

For a very long time the only available PQ2 demo was a corrupt copy.
In 2016 I managed to find a collector which had working copy (https://forums.scummvm.org/viewtopic.php?p=83298#83298), and now you can find it here:
https://www.scummvm.org/frs/demos/sci/pq2-dos-ni-demo-en.zip (https://www.scummvm.org/frs/demos/sci/pq2-dos-ni-demo-en.zip)
Title: Re: Decompilation Archive
Post by: MusicallyInspired on July 03, 2019, 11:49:35 AM
Oh oh oh oh!
Title: Re: Decompilation Archive
Post by: EricOakford on July 03, 2019, 11:21:53 PM
Regarding PQ2demo's graphical error: No, it's actually related to the SWAT team arriving at the motel. One cop erases part of the police car. I think it's related to a decompilation error in the "swatArrives" script.

In any case, here's more decompiles! They are of the demos for LSL2, The Colonel's Bequest, SQ3, and Astro Chicken. All have been tested to completion.
Title: Re: Decompilation Archive
Post by: EricOakford on July 14, 2019, 01:20:46 PM
Here's another one: the Gabriel Knight 1 demo. It seems to have been based off a beta version of the game, judging by the large amount of placeholder messages and the fact that it uses SCI1.1 rather than SCI2 like the full game does. Expect some bugs, but thankfully there are only two asm blocks (in proc211_0 and QScript). There's the needed script and interpreter to debug this thing.

I wonder why the demos for GK1, QFG4, and PQ4 used SCI1.1 instead of SCI2? My guess is that the 32-bit engine was not yet ready to be used, so the designers used the older 16-bit engine during development, then ported it to SCi2 when the full games were completed.
Title: Re: Decompilation Archive
Post by: lskovlun on July 14, 2019, 02:09:17 PM
I wonder why the demos for GK1, QFG4, and PQ4 used SCI1.1 instead of SCI2? My guess is that the 32-bit engine was not yet ready to be used, so the designers used the older 16-bit engine during development, then ported it to SCi2 when the full games were completed.
Well, things like the polygon editor do not work in SCI2. If you try, you're told to use SCI16 (i.e. SCI1.1), so they definitely had to use it for some things. And we all know how buggy QfG4 was on release (we are getting script patches for the QfG4 bugs in ScummVM, but the number of patches is crazy).
Title: Re: Decompilation Archive
Post by: Kawa on July 14, 2019, 05:47:38 PM
To be fair, the PQ4 demo is merely a slideshow with some music and a short SEQ. You don't really need the full power of SCI2 for that. I find QFG4's RemapColors differences more interesting to be honest.

I have no excuse in mind for GK1.
Title: Re: Decompilation Archive
Post by: EricOakford on July 29, 2019, 08:26:22 PM
Here's a new and improved decompile for QFG1EGA!

A major change here is that all of the system scripts and globals are based on the original SCI0 source, which is much more accurate. As a result, there should be no compatibility or decompiler issues on that side

The game generally seems to work okay, but the game crashes in certain areas (entering Meep's Peep, working at the stables, dispelling the bear), which seem to be related to decompilation errors.

Oh, yeah, there's also new decompiles for Seasoned Professional (EGA and VGA use exactly the same scripts) and the QFG2 demo. Both have been fully tested to completion.
7/31/2019 EDIT: Oops! I goofed up with the SCI01 decompiles, as I worked at adapting the original SCI0 header files for them, but uploaded incomplete versions. That has been fixed. Now they really have been tested to completion.
Title: Re: Decompilation Archive
Post by: EricOakford on October 21, 2019, 08:26:05 PM
Here are decompiles of the KQ4 demo and full game (version 1.006.004, interpreter 0.000.502)

The demo plays through without issue. Since it has no VOCAB.997, I had to use the one from the full game. The demo is pretty much just a stripped-down version of the full game anyway.

The full game starts up and plays normally... but there is a high risk of the game crashing with "Out of Heap space" errors, particularly when cleaning the dwarves' house.
Man, this game does not use memory efficiently! Of course, it is the first-ever SCI game, and the programmers were still used to AGI, so we can't blame them for that.

Next on my agenda is LSL2...