Graphic adventure interpreter: a few thoughts

I was thinking how the script to set up the current location in my SPUTM-like implementation demo (a.k.a. SCUMM mock-up) would look like.
I came up with something along these lines:

location locWoodtickBridge = new location("Woodtick bridge");

object objSign = new object("sign");

// Position (chars)
objSign.position.set(0x20, 0x01);

// Interactive rectangle (pixels)
objSign.rectangle.set(0x00, 0x00, 0x1c, 0x11);

// Bitmap images for this object
objSign.image_id.present = ID_FOBJ_SIGN_WITH_SHOVEL; /* Shown when the location is rendered, unless already picked up */
objSign.image_id.absent = ID_FOBJ_SIGN_WITHOUT_SHOVEL; /* Shown after the object was picked up */

// Inventory item you get when picking this object up (specifically parts of it)
objSign.item_id = ID_ITM_SHOVEL;

// Suggested verb when object is hovered on (can be changed dynamically,
// e.g. for a closed door it would be "open" and for an open door it would
// become "close")
objSign.suggested_verb = ID_VERB_LOOK_AT;

// Override the "pick up" message and its callback
objSign.message_id.pick_up = ID_FMSG_SIGN_PICK_UP;
// The default callback would remove the object from the foreground and 
// we would not be able to interact with it any longer
objSign.callback.pick_up() = {
    if (this->flag.get.pick_up() == 0) {
        // Draw the "absent" image over the "present" one

        // Add the associated item to the inventory (specifically parts of it)

    // Queue the message for "pick up"

    if (this->flag.get.pick_up() == 0) {
        // Override the "pick up" message after the first pick up attempt
        this->message_id.pick_up = ID_FMSG_SIGN_PICK_UP_MULTIPLE;

        // Now set the flag to indicate the object was picked up but can still be interacted with

// Override the "look at" message
objSign.message.look_at =;
// Default "look at" callback (given for reference). If we were to e.g.
// randomize the "look at" message we could override the callback to do so
//objSign.callback.look_at() = {
//    // Queue the message for "look at"
//    system.message.queue(this->message.look_at);

// The message for other verbs remains unchanged, i.e. "invalid" defaults are used for each verb

// Insert the new object in the location we defined earlier

The compiler would translate the above into native data structures/code and the runtime interpreter would be able to load in and follow the instructions given to it.

This entry was posted in Retrocomputing, Technical and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s