Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


FreeSCI: Rebuilding Sierra's Classic Quests

by Howard Wen
02/03/2003

In the mid- to late 1980s, game developer Sierra On-Line (known today as Sierra Entertainment) was renowned for its adventure titles. These games typically featured animated characters moving against static background images (such as a castle or space station). The player interacted with the on-screen characters with the keyboard or, in later titles, the mouse. This gameplay mechanic was formulaic, but the company cranked out blockbuster hits like King's Quest, Space Quest, and Leisure Suit Larry, all of which spawned numerous sequels.

Sierra On-Line built these and other games upon its own SCI ("SCript Interpreter" or "Sierra Creative Interpreter") engine. Each game was comprised of scripts, graphics, and sound files that were compiled and controlled by SCI.

For the past few years, programming-capable adventure fans have been developing FreeSCI, an open source SCI clone. Their goals are to port SCI games to other platforms, to add new features to the original games, to provide an engine upon which other hobbyists can create new Sierra-style games, and simply to have fun.

Looking and Sounding Better

FreeSCI duplicates most of the functionality of the first-generation version of SCI, referred to as SCI0. It features vector-drawn EGA graphics, MIDI sound, and keyboard input. FreeSCI can run SCI0 game files on Intel, Alpha, and other architectures under several OSes, including Linux, Windows, BSD, and more. Some of the titles that the present release can play are King's Quest 4, Space Quest 3, and Leisure Suit Larry 2.

Sierra's developers would modify SCI to meet the requirements of each game, thus spinning off slightly different versions of the engine. FreeSCI attempts to bring these variants together in one program. "Each version of Sierra's interpreter would typically work with just one or a couple of games, mainly due to assumptions they made about the memory layout," says Lars Skovlund, a 22-year-old computer science student at the University of Copenhagen, Denmark, and the lead researcher for the FreeSCI development team. "Our design allows us to play all the supported games with a single executable."

FreeSCI not only emulates SCI0, but also has the capability to touch up the graphics of the classic Sierra games. It allows either vector scaling (for background images, which are specified as vector graphics) or filtered pixmap scaling (for most of the other graphic elements). Running FreeSCI with all graphical features enabled looks quite different from the original SCI format:


Figure 1 -- FreeSCI running Quest for Glory I in compatibility mode


Figure 2 -- FreeSCI running Quest for Glory I in enhanced mode

The first screenshot above is FreeSCI in SCI compatibility mode, which renders the game as it would look on an original SCI0 engine (16 colors, no special effects). The second shows FreeSCI using scaled and anti-aliased 256-color images, trilinear filtering for pixmaps, and alpha blending.

FreeSCI also improves upon SCI's sound. Its OPL/2 (Adlib) emulator, which uses PCM output, produces decent sound without needing the hardware sanctioned by Sierra's SCI games. This Adlib driver supports stereo output and additional voices. The result is that it can generate better sound than an actual OPL/2 chip.

From Shareware to Free

Work on FreeSCI began in March 1999. Early versions borrowed heavily from the SCI Decoding Project, created by Carl Muckenhoupt in 1992. He initially sold the software as shareware, but abandoned further development because he found it difficult to keep up with the changes that Sierra would make to the SCI system. So he released his code under GPL in 1997.

Understanding and decoding the various components that comprise SCI -- and the ways in which they drive a game -- was not a trivial task, but Muckenhoupt's work definitely gave FreeSCI a head start. "At the time FreeSCI was started, there was some information regarding the SCI compression scheme, graphics, and sound. The SCI Decoding Project had assembled some information regarding these. Therefore, these were the first parts we worked on," says Christoph Reichenbach, FreeSCI's maintainer, a 24-year-old from Germany and computer science student at the University of Colorado at Boulder. Being a long-time fan of Sierra's adventure games inspired him to develop FreeSCI.

(While Muckenhoupt's graphics and decompression code helped get the FreeSCI effort going, and were part of the early versions of FreeSCI, these eventually had to be replaced with originally-written material due to concerns regarding their legality.)

The core of the FreeSCI code is written in C. Lex&Yacc is used for the configuration file parser, GNU m4 for automake/autoconf, and Perl scripts for generating Huffman trees for decompression and for saving games (which are implemented by a C struct serialization mechanism implemented as a code generator). The OPL/2 emulator is dynamically linked against a variety of libraries.

Sound: Good But Not Perfect

Getting the sound to work right was a prominent problem -- one with which the FreeSCI developers are still wrangling. SCI provides sound by an asynchronous sound server, which is capable of commanding a wide array of sound devices. Likewise, the FreeSCI team's approach was to run an asynchronous process and communicate using pipes. The result turned out to be less than optimal, particularly on non-UNIX systems. This caused a game's background music to depend too much on scheduler peculiarities on individual UNIXes, causing it to run slower on most platforms other than Linux on Alpha. This problem is partly caused by the tight control that the script code of SCI has over this music, and by the FreeSCI team's goal to support some of the actual sound hardware that SCI does, such as MT-32 instruments.

Because the music for most of Sierra's SCI-built games was originally composed with the Roland MT-32 sound device in mind, it sounds best on this hardware. "So far, I haven't heard of any successful attempt at MT-32 software emulation," says Reichenbach. "This would certainly be a project quite a number of other re-implementation projects, such as Exult or ScummVM, could benefit from, too. It is not, however, something we're planning on doing ourselves at this point."

Instead, the FreeSCI developers been working on mapping MT-32 instruments to General MIDI (GM) instruments, so that GM synthesizers can be used with a game instead. "While the result is quite good, it is far from being perfect, simply because many MT-32 specific features are not present in GM devices in general," says Reichenbach. "This is particularly prominent in sound effects."

More Adventures

For the next version of FreeSCI, Reichenbach and his fellow developers have been rewriting their code to extend the 64K memory limit of the original SCI. This will enable them to support more games, including those that use 256-color graphics, like Quest for Glory 2 (see Figure 3). (FreeSCI currently supports only games that originally featured 16-color graphics.) A long-term goal is to add the more advanced features, like VGA graphics and mouse support, from the five versions of SCI that followed SCI0.


Figure 3 -- Quest for Glory 2 from the next version of FreeSCI

The FreeSCI team is also putting in something which will be helpful to those who homebrew their own classic Sierra-style adventures. Reichenbach says they want to make it so that end users can easily implement their own graphics, sound, and script files with the FreeSCI engine.

So then, besides reliving their favorite classic adventures, fans will have the means to continue them as well, with this free open source engine.

Howard Wen is a freelance writer who has contributed frequently to O'Reilly Network and written for Salon.com, Playboy.com, and Wired, among others.


Return to the Linux DevCenter.

Copyright © 2009 O'Reilly Media, Inc.