Author Topic: Leaked Original SCI Source  (Read 48693 times)

0 Members and 1 Guest are viewing this topic.

Offline Kawa

Re: Leaked Original SCI Source
« Reply #15 on: November 27, 2015, 12:31:45 PM »
I think I fucked up the logic somewhere converting SRDialog::doit. I blame the lack of continue and cond -- they make it difficult.

Offline troflip

Re: Leaked Original SCI Source
« Reply #16 on: November 27, 2015, 12:48:55 PM »
cond is just a nested if-else pattern

Code: [Select]
(cond (a A) (b B) (c C) (else D))

turns into

Code: [Select]
(if (a)
    A
)
(else
    (if (b)
        B
    )
    (else
        (if (c)
            C
        )
        (else
            D
        )
    )
)

For continue, the pattern is

Code: [Select]
(while (something)
    something1
    (if (blah)
        continue
    )
    something2
)

becomes

Code: [Select]
(while (something)
    something1
    (if (not blah)
        something2
    )
)

But of course if it's nested inside a bunch of other logic, suddenly that becomes more complicated. Can't off the top of my head figure out the right transformation. You could always set a variable and skip the rest of the stuff conditionally based on that variable.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: Leaked Original SCI Source
« Reply #17 on: November 27, 2015, 01:20:39 PM »
Thank you for that, it'll help for the second run-through. Though I think I fucked up a bit with the save catalog creation, too... no biggie though, considering as you said, the asm version works ;)

Offline OmerMor

Re: Leaked Original SCI Source
« Reply #18 on: November 27, 2015, 01:22:09 PM »
Did you notice that break, breakif, continue and continueif take an optional parameter to indicate the number of loop levels to break/continue from?

Code: [Select]
Supporting constructs for iteration:

(break [n])

     Break out of n levels of loops.  If n is not specified break out of the
     innermost loop.

(breakif expression [n])

     If expression is not FALSE, break out of n levels of loops.  If n is
     not specified, break out of the innermost loop.

(continue [n])

     Loop back to the beginning of the nth level loop.  If n is not
     specified, loop to the beginning of the innermost loop.

(contif expression [n])

     If expression is not FALSE, loop back to the beginning of the nth
     level loop.  If n is not specified, loop to the beginning of the
     innermost loop.

Offline Kawa

Re: Leaked Original SCI Source
« Reply #19 on: November 27, 2015, 01:23:59 PM »
I hadn't gotten that far in the document yet. More languages should support that.

Offline OmerMor

Re: Leaked Original SCI Source
« Reply #20 on: November 27, 2015, 01:30:09 PM »
Kawa,
in your version for GetDirectory, why did you use all those magic numbers?
Don't you have the constant definitions?
If you need some missing definitions from the original sci, let me know.

Offline troflip

Re: Leaked Original SCI Source
« Reply #21 on: November 27, 2015, 01:35:36 PM »
I'm on the fence about that :P.

The purist in me doesn't like using continue, or even break. Or even early returns (i.e. returns from the middle of a function). They're all like gotos - they break up your logic, sometimes making it harder to understand whatever algorithm you're implementing. I think some of that comes from when I coded a lot in "old style" C++ where smart pointers and RAII were not used, so you needed to ensure you always freed any resources you allocated. Jumping out of a loop at random points (or jumping out of a function from random points) often leads to resource leaks, since cleanup code is skipped.

It's not an issue with C# or modern C++ (with smart pointers and proper use of RAII). It *could* be an issue with SCI, since there is no garbage collection and no scoped variables. However, SCI doesn't follow the allocate-dosomething-free pattern all that much. There are *some* places in SCI1.1 that do that (with the Memory kernel). And problem some places that create new objects (like an Event) and dispose of them immediately.

Anyway, rant over. I do admit the multi-level break could be useful at times. And it might make things easier to understand, not harder (it's just that you *do* need to be cognizant of all the code you're skipping).

« Last Edit: November 27, 2015, 01:39:50 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lskovlun

Re: Leaked Original SCI Source
« Reply #22 on: November 27, 2015, 01:46:24 PM »
It *could* be an issue with SCI, since there is no garbage collection
There is in ScummVM  :P

Offline Kawa

Re: Leaked Original SCI Source
« Reply #23 on: November 27, 2015, 01:49:35 PM »
in your version for GetDirectory, why did you use all those magic numbers?
Don't you have the constant definitions?
If you need some missing definitions from the original sci, let me know.
For lines like = len (+ Max(29 (+ StrLen(where) 6)) 11) //29 = DIRECTORYSIZE I had the constants, but I wanted to keep it reasonably in-place replaceable.
For lines like addButton(TRUE 27 0 0 1 0 34 scriptNumber) I don't have a 990.shm, though one could be made from what save.sc reveals.

Nothing to it, really.

lol I accidentally used noun 30 instead of 29 :D

My srdialog.sc now has one big asm block, one commented-out counterpart to that block, and about 18 lines worth of noun constants.
« Last Edit: November 27, 2015, 02:16:17 PM by Kawa »

Offline OmerMor

Re: Leaked Original SCI Source
« Reply #24 on: November 27, 2015, 02:59:12 PM »
990.SHM

Code: [Select]
; 990.SHM -- Produced by SCI Message Editor 3.350
; This file should only be edited with ME

; NOUNS

(define BUTTON_CANCEL    22)
(define BUTTON_CHANGE    23)
(define BUTTON_DELETE    24)
(define BUTTON_NO        31)
(define BUTTON_NODIRCHG  38)
(define BUTTON_OK        27)
(define BUTTON_REPLACE   25)
(define BUTTON_RESTORE   26)
(define BUTTON_SAVE      28)
(define BUTTON_YES       32)
(define BUT_REPLACE       9)
(define BUT_RESTORE       7)
(define BUT_SAVE          8)
(define CANCEL_BUTTON     5)
(define CHANGE_BUTTON    18)
(define DELETE_BUTTON    19)
(define DEL_NO           13)
(define DEL_TEXT         12)
(define DEL_YES          14)
(define DIALOG_RESTORE   20)
(define DIALOG_SAVE      21)
(define DIR_INVALID      29)
(define DIR_NOROOM       30)
(define DIR_PROMPT        1)
(define DTEXT_REPLACE    33)
(define DTEXT_WITH       34)
(define INVALID_DIR       2)
(define NOROOM            6)
(define NO_DESC           3)
(define OK_BUTTON         4)
(define REPLACE_BUTTON   15)
(define RESTORE_BUTTON   16)
(define SAVE_BUTTON      17)
(define SELECT_GAME      10)
(define TEXT_REPLACE     37)
(define TEXT_RESTORE     35)
(define TEXT_SAVE        36)
(define TYPE_DESC        11)

; CASES


Offline lance.ewing

Re: Leaked Original SCI Source
« Reply #25 on: November 27, 2015, 04:44:52 PM »
I got my hands on leaked sci source code. Unfortunately I can't share it in its entirety.
Please don't try to pressure me on this.

This is awesome!!  What version of SCI are we looking at here? I see 1992 in the copyright message but I guess that gives the earliest date.

You're probably already aware that I've been working on the following web page over the past few years, adding bits and pieces to it as we've discovered them:

http://www.scriptinterpreter.com/syntax

I'm resisting the urge to fill in the gaps now.  I can't really do that without referring to this post. Are we okay to do that?

This kind of puts less emphasis on the original game disk "slack space" project I started working on a few months back.

Offline Kawa

Re: Leaked Original SCI Source
« Reply #26 on: November 27, 2015, 04:48:38 PM »
What version of SCI are we looking at here?
SCI11 at best, considering the Message calls in save.sc.

Offline lance.ewing

Re: Leaked Original SCI Source
« Reply #27 on: November 27, 2015, 04:58:27 PM »
I'll just put this pdf document here.

Code: [Select]
                      The Script Programming Language

                          Author: Jeff Stephenson
                            Date: 4 April 1988

And with that document it really does fill in the rest of the gaps. This document must be what Mark Wilden was referring on his Smalltalk page and blog post:

Quote
My brother-in-law Chris Smith, who got me a job with Sierra in late 1989, sent me some sketchy documentation for SCI. One of the highlights of my programming life was sitting on my bed reading that documentation the day I got it

http://web.archive.org/web/20101219175024/http://www.mwilden.com/smalltalk/index.htm

Quote
I'll never forget that first night reading the documentation on my bed and just being consumed with this language that did things I wanted to do and even things I didn't know I wanted it to do.

http://mwilden.blogspot.co.uk/2009/06/discovering-oop.html

Not much in the document in relation to the OO side of the language though. And it seems to be missing the switchto keyword we know existed from the SWAT source snippet. This is probably because the document states 1988 as the publish date and I guess we're assuming that it was added to over time.

Offline Kawa

Re: Leaked Original SCI Source
« Reply #28 on: November 27, 2015, 05:00:58 PM »
There are also references to other SCI manuals.

Offline lance.ewing

Re: Leaked Original SCI Source
« Reply #29 on: November 27, 2015, 05:04:51 PM »
I think only about 2% of the code "falls back" to assembly. Making changes to the decompiler at this point is too risky, and the functions in assembly don't block people from making games.

Unless you want to fund me at a full-time salary until it's done, then I'll be glad to do it :-).

Hmmm. You know Omer does imply he has a lot of this code but can't share most of it. But maybe an extraction of all of the original class names and procedure names, particularly the ones from the common framework, would be very useful for the decompiler.


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

Page created in 0.019 seconds with 22 queries.