I always wondered how the guys/gals at Lucasfilm Games managed to cram Maniac Mansion and Zak McKracken onto a few small disks. So this competition was the perfect opportunity to test drive my ideas.
How they did it
Fortunately today the internet provides all kind of technical info at my finger tips. So it's no problem finding some of the old programmers spilling their beans. They actually created a Lisp like language that allowed them scripting even with a kind of multi threading. Incredible! Obviously the script was compiled to byte code which barely fit into memory. So that's the way I chose to follow.
Fun link of the day: Ron Gilbert on Scumm (http://grumpygamer.com/scumm_notes)
How I faked it
Tables. Tables with pointers to more tables. All verbs are represented by indices; so are items and static objects (items on screen)
Every item/object has a list of verbs to scripts. Item 5 with verb 7? Run this script. No entry for object 14 and verb 9? Show the dreaded "That doesn't work."
And there's action areas with type "room exit" or "script trigger". Room exits are handled directly while script triggers start their attached script.
Where's the beef?
It's in the script! All puzzles are handled by various script actions. A script action can set/clear flags, run a different script depending on a flag state. Characters can be "walked", get or lose an item, branch if a certain combination of items/objects is used, if the controlled character is anybody specific, etc.
This script together with rooms made up of elements (of which some may depend on certain flag states) makes for a quite small memory footprint. At the current state there's 65 flags, 39 rooms, 55 static objects and 18 items making up a total of 30355 bytes (graphics included).
Since that's all pretty abstract, here's a few excerpts.
Action table for a static object (badge reader in elevator)
SOA_BADGE_BUTTON_IN_LIFT !byte PA_EXAMINE, <CS_EXAMINE_BADGE_BUTTON, >CS_EXAMINE_BADGE_BUTTON !byte PA_LAST_ENTRY_FLAG | PA_USE, <CS_USE_BADGE_BUTTON_IN_LIFT, >CS_USE_BADGE_BUTTON_IN_LIFTStarts a sequence when a button is used in the elevator, referenced in the table above
CS_USE_BADGE_BUTTON_IN_LIFT !byte CSA_SET_HAPPEN,2 !byte CSA_REDRAW_SCREEN !byte CSA_WAIT,50 !byte CSA_IF_HAPPEN_SET,4,<CS_ACCIDENT,>CS_ACCIDENT !byte CSA_CLEAR_HAPPEN,2 !byte CSA_TOGGLE_HAPPEN,3 !byte CSA_LAST_ENTRY_FLAG | CSA_REDRAW_SCREEN</pre>