SCUMM Script

Ron Gilbert posted this as a comment on The Mansion – Technical Aspects, I am re-posting it here as an article.

SCUMM script was a little odd. When I first started designing the language, I was going to base it on Lisp. I was use to using it to customize emacs that we used to do all our coding. This was not on PCs, but on large multiuser UNIX machines. The Lucasfilm games group was part of the Lucasfilm computer division (which later became Pixar) and we had some very smart people that connected the C64 to the UNIX machine. From my UNIX terminal, I had complete control over the C64 and wrote a source level debugger for SCUMM. The 6502 assembler was custom written by Chip Morningstar and ran on the UNIX machine.

But I digress. So, SCUMM started out as Lisp based, but I quickly abandon that approach in favor of something that looked a little more C-like, but some aspects of Lisp remained, mostly in the naming conventions. Commands and variables used – (dashes) as separators.

sandy-rescued = 1

This was a single variable, not sandy minus rescued. So how did SCUMM do subtraction? You didn’t. Until Monkey Island, there was no way to do complex expressions. if you wanted to subtract a value you used:

count -= 5

If you had a complex expression, you had to chain them using +=, -=, /= and *= using temp variables. Ugly, but it made the interpreter much simpler.

(Side note, the C64 interpreter was not named SPUTM, that name didn’t come about until the PC version).

One of the goals I had for the SCUMM system was that non-programers could use it. I wanted SCUMM scripts to look more like movies scripts, so the language got a little too wordy. This goal was never really reached, you always needed to be a programmer. 🙁

Some examples:

actor sandy walk-to 67,8

This is the command that walked an actor to a spot.

actor sandy face-right
actor sandy do-animation reach
walk-actor razor to-object microwave-oven
start-script watch-edna
stop-script
stop-script watch-edna
say-line dave "Don't be a tuna head."
say-line selected-kid "I don't want to use that right now."
if (melt-down) {
  say-line selected-kid "I don't think this game is very fun."
}

There were no functions, everything was a ‘script’, a small piece of code that looked a lot like a function, but it ran in it’s own virtual process.

script watch-clock {
  do {
    object clock state ON
    break-time 60
    object clock state OFF
    break-time 60
  }
}

Note the lack of a until/while on the do loop. The script would just continue until someone killed it.

Time was always measured in jiffies (1/60 second). Later on I added the ability to say ‘break-time 1 minute’ and the compiler just multiplied by 60 before emitting the opcode.

If you did…

start-script watch-edna
start-script clock-tick

…you now had 2 additional scripts running and they all ran at the same time using preemptive multitasking. It was a heck of a lot better than doing state engines. If you wanted to keep an eye on something, you’d just say…

start-script watch-edna

…and then forget about it. That one script could do whatever it needed and start a cut-scene if the need arose.

This may seem pretty tame today, but back then, it was like magic.

Bonus information: The SCUMM compiler was written in Yacc and Lex.

8 thoughts on “SCUMM Script”

  1. Ah, great that you shed some light on the mysteries of this giant among games 😉
    I really appreciate your work, even more after having had those insights of the code during reversing.
    Thanks alot Ron!

    Reply
  2. Thank you for these great articles! I always wondered how the SCUMM worked internally. I suppose it should be very difficult to create a system like this for an 8-bit machine.

    Reply
  3. There are two questions I would like to ask Ron Gilbert about SCUMM. It is mentioned that the language was originally based on Lisp (including the S-expression syntax I presume). What exactly was the reason to change to a more C-like language? Infocom had ZIL which was Lisp based and it apparently worked pretty well for them. Were you aware of that at the time or was Emacs Lisp the only inspiration?

    The second question I have concerns the aim to provide a natural language like interface for non-programmers (mentioned in one of the talks that is available on Youtube). Inform 7 tries to do that and seems to be quite successful. What is your current view on using “natural language” to script (adventure) games?

    Reply
  4. I have a (hopefully) quick question for Ron Gilbert also regarding SCUMM:

    You mentioned that all of the scripts ran concurrently in a preemptively multitasked way. What exactly did you mean by that?

    Do you just step through all active scripts running the next “step” for each script? Or are you preempting based on more complex criteria such as when state variables change and/or timers expire? (Seems like the latter would be way more complicated than necessary.)

    Reply

Leave a Comment