Toy Story

After working around the clock last Monday to get the new Lingo compiler ready and merged into master, I spent the rest of the week cleaning up reference compilation and polishing off chunk expressions.

As I stated in a previous post, the old Lingo compiler could not differentiate between cases when it should emit a variable reference vs. value. Previously, I dealt with this by having it always emit a reference. Then, whenever a reference was popped off the stack, unless a reference was explicitly asked for, the reference would be automatically evaluated. I have finally eliminated this hack. The new compiler can now detect every case where a reference is needed instead of a value, at least to the extent that Lingo’s syntax allows. (There is one unavoidable ambiguity. foo(bar) could either mean “call the function foo with the argument bar” or “call the object foo‘s method bar“. It isn’t possible to tell which meaning is intended until runtime.)

In addition, I think I am finally done with my work on chunk expressions! These have been quite a nuisance, offering a new undocumented behavior to implement every time I previously thought I think was done. Here are a few of the recent surprises:

  • Starting in Director 4.0.4, the last char of foo is equivalent to char -30000 of foo and is compiled as such in certain instructions.
  • Chunk references can be nested. For example: put "test" into word 3 of line 5 of foo. (This is actually mentioned in the documentation, but I’ve never seen it in use, so it slipped under my radar.)
  • You can put text into non-existent chunk expressions. For example:
    put "" into foo
    put "asdf" into line 1000 of foo
    This script will set foo to 999 newlines followed by “asdf”.
  • Chunks of text can be formatted individually. For example: set the textStyle of word 2 of field 1 to "bold". Today I added support for compiling this syntax and added stubs for the properties. Now sheep is working on actually implementing these properties, which is possible thanks to his recent improvements to MacText.

It turns out that Lingo’s chunk expression behavior is largely inherited from HyperTalk, and after finding the HyperTalk documentation, I discovered it had a much better description of them than the Lingo documentation. The document also contains precise descriptions of some syntax oddities which I had discovered through trial and error. This was a bit frustrating, but I guess I know where to look for help now. 🙂

Now that chunk expressions are fully implemented (or stubbed), Toy Story Concentration is now playable in ScummVM:

This was the first commercial use of Shockwave (the plugin which allowed Director movies to be played on the web), so it’s quite exciting to finally have it running!

See you again soon with more progress!


Leave a Reply

Your email address will not be published. Required fields are marked *