Author Topic: Original SCI syntax  (Read 143376 times)

0 Members and 4 Guests are viewing this topic.

Offline MusicallyInspired

Re: Original SCI syntax
« Reply #60 on: May 10, 2015, 02:55:01 PM »
Here's a question, how easy would it be to add extra interactions? Different games had different interactions and some had more than others. Is it a simple matter to add new ones? Or is each interpreter locked to a certain number?
Brass Lantern Prop Competition

Offline troflip

Re: Original SCI syntax
« Reply #61 on: May 10, 2015, 03:06:50 PM »
I'm pretty sure it's just a function of the scripts, not the interpreter. I haven't looked into it enough to know for sure though.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline troflip

Re: Original SCI syntax
« Reply #62 on: May 15, 2015, 12:36:21 PM »
So it turns out that the entries in the export table don't always match the order that the procedures or instances/classes appear in the script. They will if you just compile with sci studio or sci companion, but they don't in Sierra games.

I spent a while trying to debug a decompiled script (made more difficult because scumm crashes a lot when trying to use its debugger), only to finally realize two objects had been swapped in the export table, and another script was sending a message to "export 5 of script 109", which went to the wrong object.

So Sierra must have had some markup in script to explicitly set the export table entries. I'm trying to figure out what syntax I should use.

Should it be a list of entries at the top of the script? ?.g.
[export(0) = starCon]
[export(1) = sExitSouth]
[export(2) = myProcedure]

Or should it be right before the class or procedure? E.g.
[export = 0]
(Class starCon of Rgn)
Etc.....

I'm kind of leaning towards the first option, because it makes it clear if you're calling these from other scripts.

In either case, these would be optional, and by default it would just use the order they appear in the script.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lskovlun

Re: Original SCI syntax
« Reply #63 on: May 15, 2015, 01:32:08 PM »
I spent a while trying to debug a decompiled script (made more difficult because scumm crashes a lot when trying to use its debugger), only to finally realize two objects had been swapped in the export table, and another script was sending a message to "export 5 of script 109", which went to the wrong object.
I noticed a bug in the send command earlier when researching Brandon's SQ4 easter egg request. wjp fixed it just yesterday. Or are you referring to something else?

Offline troflip

Re: Original SCI syntax
« Reply #64 on: May 15, 2015, 01:38:41 PM »
If I've been poking around in the debugger for a bit (doesn't seem to matter what I do... Sometimes just breaking into the debugger is enough), when I type 'go' to continue the game, scumm just exits.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lance.ewing

Re: Original SCI syntax
« Reply #65 on: May 15, 2015, 03:57:40 PM »
Should it be a list of entries at the top of the script? ?.g.
[export(0) = starCon]
[export(1) = sExitSouth]
[export(2) = myProcedure]

The "export(0) = " bit seems redundant. Could it simply be a list of the names in the order they appear in the export list? Or does it sometimes have gaps in the numbering, and therefore maybe needs to specify the position?

Also, given that most sections seem to be wrapped in parenthesis, maybe you could just do something like the properties section of a class, e.g. as generated by the Feature Writer:

(export
    starCon
    sExitSouth
    myProcedure
)

Or if we go down the route of specifying the position, it could exactly match the properties section generated by the Feature Writer and look like this:

(export
    myProcedure      2
    sExitSouth           1
    starCon                0
    somethingElse   7
)

Out of interest, where does the name export originally come from? Is this something mentioned only in the SCI specs? Or does the interpreter mention this name somewhere? Recently we were talking about public classes, public procedures, etc. so "public" could be another name to use.

Offline lskovlun

Re: Original SCI syntax
« Reply #66 on: May 15, 2015, 04:40:18 PM »
Ok, I'm able to invoke the feature writer, but it looks like some of the local vars need to be set to certain values in order for it to generate those cases. It also looks like it either generates or reads from a "smh" file to do something. I'll play around with it later...
The SHM files are related to the message resources. There is one included on the GK2 CD (by accident, clearly).

Offline troflip

Re: Original SCI syntax
« Reply #67 on: May 15, 2015, 05:14:26 PM »
The "export(0) = " bit seems redundant. Could it simply be a list of the names in the order they appear in the export list? Or does it sometimes have gaps in the numbering, and therefore maybe needs to specify the position?

There are gaps. And some exports can appear multiple times. So maybe something like this:

(exports
   0   starCon
   1   sExitSouth
   2   somethingElse
   6   myProcedure
   7   myProcedure    // duplicate export that appears in some games
)

Out of interest, where does the name export originally come from? Is this something mentioned only in the SCI specs? Or does the interpreter mention this name somewhere? Recently we were talking about public classes, public procedures, etc. so "public" could be another name to use.

I don't think the interpreter mentions it anywhere. Exports is what they are called in SV.exe, ScummVM, and the specs on the wiki. "public" is also a keyword, so I don't want to re-use that or something similar. Although admittedly it's redundant.

If I had to guess, I'd say the original Sierra syntax didn't have the "public" keyword, and that there was a separate section of script that mapped export slot to proc/class name.
« Last Edit: May 15, 2015, 05:16:58 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline troflip

Re: Original SCI syntax
« Reply #68 on: May 18, 2015, 05:03:21 PM »
The SHM files are related to the message resources. There is one included on the GK2 CD (by accident, clearly).

Do you or anyone else have a copy of that shm file? I'd be curious to see what it represents, what's inside it.


On an unrelated note, just for kicks, I've attached the decompiled code for QFG3. It only takes about 10 seconds to decompile a game now (down from 10 minutes), so if anyone has any request, let me know.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lskovlun

Re: Original SCI syntax
« Reply #69 on: May 18, 2015, 05:12:10 PM »
Do you or anyone else have a copy of that shm file? I'd be curious to see what it represents, what's inside it.
Just a bunch of defines, really (mapping nouns, verbs and cases to the numbers that SV displays). Interestingly, Sierra used the Message technology for KQ8 - to the point that KQ8 (which wasn't SCI) includes a header file (TALKERS.SH) with SCI-syntax defines in it (again, by accident):
http://kingsquest.wikia.com/wiki/KQ8_development
The guys behind that page didn't think to use SV on the message files in KQ8. I have, and it works  :)

EDIT: Not quite by accident... the KQ8 binary actually loads and parses this file (there's a VERBS.SH file too)
« Last Edit: May 18, 2015, 05:21:20 PM by lskovlun »

Offline lance.ewing

Re: Original SCI syntax
« Reply #70 on: May 18, 2015, 05:28:33 PM »
I was wondering if someone has done an exhaustive search across as many later SCI games as possible for scripts that generate SCI source, such as the Feature Writer?  Troflips find with the "switch" keyword was great. I'm wondering if Sierra continued to expand on the in-game code generation tools as time went on, and therefore whether we might find some gems like that in later games that might reveal more. Even if we couldn't decompile the later games yet, maybe a search across all uncompressed text for patterns that look suspiciously like source code might reveal something. I wonder how far they took these in-game code generation tools.

Offline troflip

Re: Original SCI syntax
« Reply #71 on: May 18, 2015, 06:05:10 PM »
Just a bunch of defines, really (mapping nouns, verbs and cases to the numbers that SV displays). Interestingly, Sierra used the Message technology for KQ8 - to the point that KQ8 (which wasn't SCI) includes a header file (TALKERS.SH) with SCI-syntax defines in it (again, by accident):

Hmm, if there's a talkers.sh and a verbs.sh, I wonder what the %d.shm files were for then?

I guess the nouns are unique to each room, but talkers are not? What about if a noun and a talker refer to the same thing, do they end up using the same name in the defines?

What are "cases"? Is that the "condition" property of a message?

The numbers used for "verb" appear to be flags (i.e. powers of two, 1, 2 ,4), but not always. Is there any significance to that?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lskovlun

Re: Original SCI syntax
« Reply #72 on: May 18, 2015, 06:27:05 PM »
Hmm, if there's a talkers.sh and a verbs.sh, I wonder what the %d.shm files were for then?
I'm guessing there was a provision in the message editor for marking stuff local or global.
Which reminds me, it is possible to store comments for each message in a MSG file, but I never found a reliable way to get at them; we didn't need to for the purpose of running a game.

I guess the nouns are unique to each room, but talkers are not? What about if a noun and a talker refer to the same thing, do they end up using the same name in the defines?
Here's how the process goes for playing a long dialogue in SCI: You start out with a noun/verb/case triple which identifies the dialogue uniquely. Sequence is set to 0. Then we loop over the sequence numbers, and for each message, we get the talker value (returned by the Message/GetMessage subfunction 0). We feed that talker value into the findTalker method of a "messager" object (in the main script), which translates the talker value into a reference to a talker object. We then let that talker object handle the portrait display and animation. Increment the sequence number, and repeat.

So noun and talker values live in different namespaces, there is no risk of a clash. Similarly for verbs and cases.

What are "cases"? Is that the "condition" property of a message?
Conditions and cases are the same thing. Both words were used at various times.

The numbers used for "verb" appear to be flags (i.e. powers of two, 1, 2 ,4), but not always. Is there any significance to that?
I haven't noticed this. Looking at 0.MSG in SQ5, it has 5, 1, 24, 7... where are you looking? (yes, there is some translation going on in the code, for the approachVerbs property and perhaps in other places)

Offline troflip

Re: Original SCI syntax
« Reply #73 on: May 18, 2015, 07:17:49 PM »
I see, so items in the msg resource need to have a unique [noun, verb, case] tuple.

So looking in the cliffygoeswith.sc of SQ5, I see

Code: [Select]
(send gTestMessager:say(22 0 43 0 self))

22 is the noun, 0 is the verb, 43 is the condition. Following the code, that looks like it turns into:

Code: [Select]
Message(msgGET roomNumber 22 0 43 0))

which will return the talker, in this case 19 for both sequences of this thing.

main.sc has a big case statement for resolving the talker based on this number. For 19, looks like it uses export 15 of script 240, which is tkrRoger.


As for the flags thing, yeah, I just noticed that 0, 1, 2 and 4 were often all that were used in a msg resource. But there are other numbers too, so I guess it's just a coincidence.

_approachVerbs does look like flags though. Looks like they have a hard-coded subset of verbs that get turned into flags, in order to be able to "store" multiple verbs in that property.

Code: [Select]
    (method (doit param1)
        (switch (param1)
            (case 1
                1
            )
            (case 2
                2
            )
            (case 3
                4
            )
            (case 4
                8
            )
            (case 31
                16
            )
            (case 24
                32
            )
            (case 29
                64
            )
            (case 25
                128
            )
            (default
                -32768
            )
        )
    )
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Collector

Re: Original SCI syntax
« Reply #74 on: May 18, 2015, 08:36:44 PM »
Do you or anyone else have a copy of that shm file? I'd be curious to see what it represents, what's inside it.

Here.

On an unrelated note, just for kicks, I've attached the decompiled code for QFG3. It only takes about 10 seconds to decompile a game now (down from 10 minutes), so if anyone has any request, let me know.

How about Freddy?
KQII Remake Pic


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

Page created in 0.047 seconds with 23 queries.