Configuration

Suffered a pretty nasty hard drive crash last week, but I think I’ve finally fixed everything. I’ve been working on dealing with configuration data. This tends to fall into a few categories:

  • Options that exist in both FreeSCI and ScummVM but are handled by the ScummVM backend. Here, you just want to figure out what values will clamp the FreeSCI output to what’s “expected” by ScummVM.
  • Options unique to FreeSCI: Here we query the ScummVM configuration manager for the setting, but anticipate failure and do something reasonable when it happens.
  • Options that exist in FreeSCI and ScummVM and require the engine to modify its behaviour : These are the trickier ones, as they tend to involve mapping parameters onto each other and the occasional switch() construct.

I’ve also been reading over the detection code to see what improvements are needed.

Massive info dump

As promised last week, you can find a tarball of the latest version at:
http://www.its.caltech.edu/~szerrade/scummsci.tar.bz2

Disclaimer: This is mostly for the benefit of people curious as to the current state of the project, and probably shouldn’t be used by anyone actually looking to play a game.

There are about 1700 lines of new code in this build (as compared to the repository jvprat had at the beginning of the summer). About 1200 of those are in new sound and file IO drivers, and the rest are scattered throughout the dozen or so files that had to be rewritten to use the new drivers.

The testing has been limited to King’s Quest IV and a couple of game demos on my Ubuntu PC- cross-platform/cross-game testing is reserved for the final stage of the project. To build, do:
./free_configure
make

The new files are described below. All of them are in engines/sci/src/.

scicore/file_hander.c and include/file_handler.h : This routes the file access system calls to the relevant drivers. It’s patterned after the FreeSCI exe.h/exe.c drivers. These calls are sort of a compromise between the FILE* methods used in FreeSCI and ScummVM’s methods. Getting them to fit together has sort of been a square-peg round-hole problem.

scicore/scumm_file_driver.c: This is the part that turns various FILE*-style calls into scummvm commands. The implementation is not always 100% faithful – for example, I was not able to figure out how to translate scanf into something the Scumm savefile drivers could work with – but I’ve tested it (mostly on King’s Quest IV) and it works well enough to access resource files and save/restore games.

Files are divided into save files (for which read/write is allowed) and resource files (which can only be read). This is necessary because some backends (Playstation 2 comes to mind) force you to use memory sticks for save state and read-only disks for game data. Which type of file you open depends on the driver method you call. Generally, if you want to open a file for writing you should explicity use the sci_save_write_open method.

scicore/unix_file_driver.c : This maps abstract driver commands to C FILE* methods. Currently disabled in favor of:

sfx/seq/scumm-adlib.c: This implements a sequencer that uses ScummVM’s Midi drivers to play Adlib music. The hardest part of writing this was debugging the custom instrument patches.

sfx/device/scumm-midi.c: This implements the Scumm drivers as a FreeSCI midi device, allowing them to be used by FreeSCI’s GM and MT32 drivers. You can change the driver used by modifying the invocation on line 85 – since the next stage in the project is to overhaul the config system, I didn’t see much point in setting up a runtime control for this only to have it replaced in a week.

Status update

Here’s the current state of things:

  • I’ve written an abstraction layer that allows for multiple file access “drivers”. This means one driver for Unix-style FILE* files, and another for the methods in common/savefile.h and common/file.h
  • The ScummVM file driver is finished. The UNIX one is mostly done, but I’m still trying to figure out how to have it deal with some of the path information. The driver is defined in engine/sci/src/include/file_handler.h and file_driver.h, and the actual driver and implementation are in engine/sci/src/scicore/file_handler.c and scumm_file_driver.c.
  • The FILE* invocations scattered throughout the FreeSCI source have been replaced with calls to the driver. There are a few exceptions to this, but as far as I can tell none are very critical.
  • There’s now a sequencer that uses ScummVM’s Adlib midi driver, and a midi device that uses ScummVM for output. The instrument setup in these is unfinished.

I was hoping to be done with files and audio at the beginning of this week, but the time spent making the file handling modular has put us somewhat behind schedule. The revised plan is to put in overtime and finish all the File/Audio stuff within the next three days, bundle the finished product as a stable build, and then compress the next step (configuration file management) from fourteen days to nine or ten. This should put us back on track by the time midterm evals roll around. We also have three weeks of general-purpose “debug and test” time at the end of the schedule to work with.